@voicenter-team/opensips-js 1.0.77 → 1.0.78
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +129 -37
- package/dist/index.d.ts +247 -164
- package/dist/opensips-js.cjs.js +102 -102
- package/dist/opensips-js.es.js +11612 -8631
- package/dist/opensips-js.iife.js +102 -102
- package/dist/opensips-js.umd.js +102 -102
- package/package.json +3 -2
- package/src/types/rtc.d.ts +10 -1
- package/src/types/timer.d.ts +6 -0
package/dist/opensips-js.cjs.js
CHANGED
@@ -1,155 +1,155 @@
|
|
1
|
-
"use strict";var nh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xt(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const rh="jssip",ih="JsSIP",lh="the Javascript SIP library",oh="3.10.0",ah="https://jssip.net",uh=["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],ch="lib/JsSIP.d.ts",fh="lib-es5/JsSIP.js",hh=["sip","websocket","webrtc","node","browser","library"],_h="MIT",dh={type:"git",url:"https://github.com/versatica/JsSIP.git"},ph={url:"https://github.com/versatica/JsSIP/issues"},mh={"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},gh={"@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"},vh={lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"},vo={name:rh,title:ih,description:lh,version:oh,homepage:ah,contributors:uh,types:ch,main:fh,keywords:hh,license:_h,repository:dh,bugs:ph,dependencies:mh,devDependencies:gh,scripts:vh};var gu=vo,tt={USER_AGENT:"".concat(gu.title," ").concat(gu.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 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 To(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Eo(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&&Hi(c,r)}function yo(c){var r=pf();return function(){var o=Fi(c),a;if(r){var t=Fi(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Th(this,a)}}function Th(c,r){return r&&(Yl(r)==="object"||typeof r=="function")?r:Eh(c)}function Eh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function nr(c){var r=typeof Map=="function"?new Map:void 0;return nr=function(o){if(o===null||!yh(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 zl(o,arguments,Fi(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),Hi(a,o)},nr(c)}function zl(c,r,n){return pf()?zl=Reflect.construct:zl=function(a,t,s){var p=[null];p.push.apply(p,t);var h=Function.bind.apply(a,p),d=new h;return s&&Hi(d,s.prototype),d},zl.apply(null,arguments)}function pf(){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 yh(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function Hi(c,r){return Hi=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Hi(c,r)}function Fi(c){return Fi=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Fi(c)}var Sh=function(c){Eo(n,c);var r=yo(n);function n(o,a){var t;return To(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}(nr(Error)),Ch=function(c){Eo(n,c);var r=yo(n);function n(o){var a;return To(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}(nr(Error)),Ah=function(c){Eo(n,c);var r=yo(n);function n(o){var a;return To(this,n),a=r.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return n}(nr(Error)),Rh=function(c){Eo(n,c);var r=yo(n);function n(o){var a;return To(this,n),a=r.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return n}(nr(Error)),xs={ConfigurationError:Sh,InvalidStateError:Ch,NotSupportedError:Ah,NotReadyError:Rh},ze={},Vo,vu;function tu(){if(vu)return Vo;vu=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=Ls(),a=Zt();return Vo=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}(),Vo}var jo,Tu;function Zt(){return Tu||(Tu=1,jo=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:z,LHEX:U,token:P,token_nodot:Z,separators:Xe,word:Q,STAR:G,SLASH:B,EQUAL:te,LPAREN:de,RPAREN:Ae,RAQUOT:Ue,LAQUOT:ye,COMMA:ne,SEMI:Te,COLON:Qe,LDQUOT:st,RDQUOT:ge,comment:Ee,ctext:Ce,quoted_string:Ie,quoted_string_clean:he,qdtext:le,quoted_pair:fe,SIP_URI_noparams:Re,SIP_URI:we,uri_scheme:Ye,uri_scheme_sips:ke,uri_scheme_sip:wt,userinfo:ot,user:mn,user_unreserved:gn,password:$s,hostport:Vt,host:ss,hostname:Hs,domainlabel:vn,toplabel:Tn,IPv6reference:Fs,IPv6address:_e,h16:re,ls32:nt,IPv4address:$t,dec_octet:ms,port:or,uri_parameters:En,uri_parameter:yn,transport_param:ar,user_param:ur,method_param:cr,ttl_param:fr,maddr_param:hr,lr_param:_r,other_param:dr,pname:pr,pvalue:gs,paramchar:vs,param_unreserved:mr,headers:qs,header:Vs,hname:gr,hvalue:Ts,hnv_unreserved:js,Request_Response:tl,Request_Line:vr,Request_URI:Sn,absoluteURI:Cn,hier_part:Tr,net_path:Bs,abs_path:Gs,opaque_part:Es,uric:ys,uric_no_slash:Er,path_segments:Ks,segment:Ss,param:ns,pchar:Cs,scheme:yr,authority:Sr,srvr:Cr,reg_name:Ar,query:An,SIP_Version:Rn,INVITEm:Rr,ACKm:Ir,OPTIONSm:br,BYEm:wr,CANCELm:Or,REGISTERm:Dr,SUBSCRIBEm:Nr,NOTIFYm:Ur,REFERm:Ws,Method:Ys,Status_Line:Pr,Status_Code:kr,extension_code:Mr,Reason_Phrase:sl,Allow_Events:Io,Call_ID:bo,Contact:In,contact_param:Ot,name_addr:Dt,display_name:As,contact_params:bn,c_p_q:xr,c_p_expires:jt,delta_seconds:Bt,qvalue:Ve,generic_param:je,gen_value:nl,Content_Disposition:rl,disp_type:wn,disp_param:On,handling_param:il,Content_Encoding:wo,Content_Length:Oo,Content_Type:ll,media_type:Lr,m_type:$r,discrete_type:Hr,composite_type:zs,extension_token:Js,x_token:Fr,m_subtype:Dn,m_parameter:Nn,m_value:ol,CSeq:al,CSeq_value:ul,Expires:Do,Event:Xs,event_type:Qs,From:qr,from_param:Zs,tag_param:Vr,Max_Forwards:No,Min_Expires:Uo,Name_Addr_Header:Po,Proxy_Authenticate:jr,challenge:Un,other_challenge:Rs,auth_param:Gt,digest_cln:en,realm:Br,realm_value:Gr,domain:tn,URI:sn,nonce:Kr,nonce_value:Wr,opaque:Yr,stale:zr,algorithm:Jr,qop_options:nn,qop_value:Pn,Proxy_Require:ko,Record_Route:kn,rec_route:Mn,Reason:Xr,reason_param:xn,reason_cause:cl,Require:Mo,Route:Ln,route_param:$n,Subscription_State:fl,substate_value:Hn,subexp_params:Fn,event_reason_value:hl,Subject:xo,Supported:Lo,To:Qr,to_param:Zr,Via:qn,via_param:Is,via_params:Vn,via_ttl:ei,via_maddr:ti,via_received:si,via_branch:ni,response_port:ri,rport:ii,sent_protocol:li,protocol_name:oi,transport:ai,sent_by:ui,via_host:ci,via_port:jn,ttl:fi,WWW_Authenticate:$o,Session_Expires:_l,s_e_expires:Bn,s_e_params:Gn,s_e_refresher:dl,extension_header:pl,header_value:ml,message_body:Ho,uuid_URI:gl,uuid:Nt,hex4:Ut,hex8:hi,hex12:vl,Refer_To:Fo,Replaces:Tl,call_id:Kn,replaces_param:Wn,to_tag:_i,from_tag:di,early_flag:El};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
|
+
"use strict";var S_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ot(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const y_="jssip",A_="JsSIP",C_="the Javascript SIP library",R_="3.10.0",I_="https://jssip.net",b_=["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],w_="lib/JsSIP.d.ts",O_="lib-es5/JsSIP.js",D_=["sip","websocket","webrtc","node","browser","library"],N_="MIT",U_={type:"git",url:"https://github.com/versatica/JsSIP.git"},P_={url:"https://github.com/versatica/JsSIP/issues"},x_={"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},M_={"@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"},k_={lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"},bo={name:y_,title:A_,description:C_,version:R_,homepage:I_,contributors:b_,types:w_,main:O_,keywords:D_,license:N_,repository:U_,bugs:P_,dependencies:x_,devDependencies:M_,scripts:k_};var Nu=bo,rt={USER_AGENT:"".concat(Nu.title," ").concat(Nu.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 so(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?so=function(r){return typeof r}:so=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},so(c)}function wo(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Oo(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&Gi(c,n)}function Do(c){var n=wf();return function(){var o=Wi(c),a;if(n){var t=Wi(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return L_(this,a)}}function L_(c,n){return n&&(so(n)==="object"||typeof n=="function")?n:$_(c)}function $_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ar(c){var n=typeof Map=="function"?new Map:void 0;return ar=function(o){if(o===null||!H_(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n<"u"){if(n.has(o))return n.get(o);n.set(o,a)}function a(){return no(o,arguments,Wi(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),Gi(a,o)},ar(c)}function no(c,n,r){return wf()?no=Reflect.construct:no=function(a,t,s){var p=[null];p.push.apply(p,t);var _=Function.bind.apply(a,p),d=new _;return s&&Gi(d,s.prototype),d},no.apply(null,arguments)}function wf(){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 H_(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function Gi(c,n){return Gi=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Gi(c,n)}function Wi(c){return Wi=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Wi(c)}var F_=function(c){Oo(r,c);var n=Do(r);function r(o,a){var t;return wo(this,r),t=n.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 r}(ar(Error)),V_=function(c){Oo(r,c);var n=Do(r);function r(o){var a;return wo(this,r),a=n.call(this),a.code=2,a.name="INVALID_STATE_ERROR",a.status=o,a.message="Invalid status: ".concat(o),a}return r}(ar(Error)),j_=function(c){Oo(r,c);var n=Do(r);function r(o){var a;return wo(this,r),a=n.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return r}(ar(Error)),q_=function(c){Oo(r,c);var n=Do(r);function r(o){var a;return wo(this,r),a=n.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return r}(ar(Error)),Fs={ConfigurationError:F_,InvalidStateError:V_,NotSupportedError:j_,NotReadyError:q_},Qe={},Xo,Uu;function du(){if(Uu)return Xo;Uu=1;function c(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function n(t,s){for(var p=0;p<s.length;p++){var _=s[p];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(t,_.key,_)}}function r(t,s,p){return s&&n(t.prototype,s),p&&n(t,p),t}var o=Vs(),a=rs();return Xo=function(){r(t,null,[{key:"parse",value:function(p){if(p=a.parse(p,"Name_Addr_Header"),p!==-1)return p}}]);function t(s,p,_){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 _)Object.prototype.hasOwnProperty.call(_,d)&&this.setParam(d,_[d])}return r(t,[{key:"setParam",value:function(p,_){p&&(this._parameters[p.toLowerCase()]=typeof _>"u"||_===null?null:_.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 _=this._parameters[p];return delete this._parameters[p],_}}},{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 _ in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,_)&&(p+=";".concat(_),this._parameters[_]!==null&&(p+="=".concat(this._parameters[_])));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}(),Xo}var Qo,Pu;function rs(){return Pu||(Pu=1,Qo=function(){function c(r){return'"'+r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(o,a){var t={CRLF:g,DIGIT:T,ALPHA:E,HEXDIG:y,WSP:A,OCTET:R,DQUOTE:I,SP:$,HTAB:L,alphanum:ae,reserved:N,unreserved:F,mark:Se,escaped:ve,LWS:M,SWS:D,HCOLON:q,TEXT_UTF8_TRIM:j,TEXT_UTF8char:z,UTF8_NONASCII:H,UTF8_CONT:J,LHEX:U,token:P,token_nodot:se,separators:et,word:ee,STAR:W,SLASH:B,EQUAL:re,LPAREN:ge,RPAREN:be,RAQUOT:xe,LAQUOT:Ce,COMMA:le,SEMI:ye,COLON:tt,LDQUOT:it,RDQUOT:Ee,comment:Ae,ctext:Ie,quoted_string:Oe,quoted_string_clean:pe,qdtext:ue,quoted_pair:de,SIP_URI_noparams:we,SIP_URI:De,uri_scheme:Xe,uri_scheme_sips:Le,uri_scheme_sip:Mt,userinfo:_t,user:Sn,user_unreserved:yn,password:js,hostport:Yt,host:ls,hostname:qs,domainlabel:An,toplabel:Cn,IPv6reference:Bs,IPv6address:me,h16:oe,ls32:lt,IPv4address:Bt,dec_octet:Es,port:_r,uri_parameters:Rn,uri_parameter:In,transport_param:hr,user_param:dr,method_param:pr,ttl_param:mr,maddr_param:gr,lr_param:Tr,other_param:vr,pname:Er,pvalue:Ss,paramchar:ys,param_unreserved:Sr,headers:Gs,header:Ws,hname:yr,hvalue:As,hnv_unreserved:Ks,Request_Response:ol,Request_Line:Ar,Request_URI:bn,absoluteURI:wn,hier_part:Cr,net_path:Ys,abs_path:zs,opaque_part:Cs,uric:Rs,uric_no_slash:Rr,path_segments:Js,segment:Is,param:os,pchar:bs,scheme:Ir,authority:br,srvr:wr,reg_name:Or,query:On,SIP_Version:Dn,INVITEm:Dr,ACKm:Nr,OPTIONSm:Ur,BYEm:Pr,CANCELm:xr,REGISTERm:Mr,SUBSCRIBEm:kr,NOTIFYm:Lr,REFERm:Xs,Method:Qs,Status_Line:$r,Status_Code:Hr,extension_code:Fr,Reason_Phrase:al,Allow_Events:Mo,Call_ID:ko,Contact:Nn,contact_param:kt,name_addr:Lt,display_name:ws,contact_params:Un,c_p_q:Vr,c_p_expires:zt,delta_seconds:Jt,qvalue:Ge,generic_param:We,gen_value:ul,Content_Disposition:cl,disp_type:Pn,disp_param:xn,handling_param:fl,Content_Encoding:Lo,Content_Length:$o,Content_Type:_l,media_type:jr,m_type:qr,discrete_type:Br,composite_type:Zs,extension_token:en,x_token:Gr,m_subtype:Mn,m_parameter:kn,m_value:hl,CSeq:dl,CSeq_value:pl,Expires:Ho,Event:tn,event_type:sn,From:Wr,from_param:nn,tag_param:Kr,Max_Forwards:Fo,Min_Expires:Vo,Name_Addr_Header:jo,Proxy_Authenticate:Yr,challenge:Ln,other_challenge:Os,auth_param:Xt,digest_cln:rn,realm:zr,realm_value:Jr,domain:ln,URI:on,nonce:Xr,nonce_value:Qr,opaque:Zr,stale:ei,algorithm:ti,qop_options:an,qop_value:$n,Proxy_Require:qo,Record_Route:Hn,rec_route:Fn,Reason:si,reason_param:Vn,reason_cause:ml,Require:Bo,Route:jn,route_param:qn,Subscription_State:gl,substate_value:Bn,subexp_params:Gn,event_reason_value:Tl,Subject:Go,Supported:Wo,To:ni,to_param:ri,Via:Wn,via_param:Ds,via_params:Kn,via_ttl:ii,via_maddr:li,via_received:oi,via_branch:ai,response_port:ui,rport:ci,sent_protocol:fi,protocol_name:_i,transport:hi,sent_by:di,via_host:pi,via_port:Yn,ttl:mi,WWW_Authenticate:Ko,Session_Expires:vl,s_e_expires:zn,s_e_params:Jn,s_e_refresher:El,extension_header:Sl,header_value:yl,message_body:Yo,uuid_URI:Al,uuid:$t,hex4:Ht,hex8:gi,hex12:Cl,Refer_To:zo,Replaces:Rl,call_id:Xn,replaces_param:Qn,to_tag:Ti,from_tag:vi,early_flag:Il};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,_=[];function d(e){s<p||(s>p&&(p=s,_=[]),_.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 z(){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 Xe(){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 G(){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 ye(){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 Qe(){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 Ie(){var e,l,u,f,_,m;if(_=s,m=s,e=D(),e!==null)if(l=w(),l!==null){for(u=[],f=le(),f===null&&(f=fe());f!==null;)u.push(f),f=le(),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=le(),f===null&&(f=fe());f!==null;)u.push(f),f=le(),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 le(){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=Ye(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=ot(),u=u!==null?u:"",u!==null?(f=Vt(),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 rs(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 we(){var e,l,u,f,_,m,T,y;return T=s,y=s,e=Ye(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=ot(),u=u!==null?u:"",u!==null?(f=Vt(),f!==null?(_=En(),_!==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 rs(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 Ye(){var e;return e=ke(),e===null&&(e=wt()),e}function ke(){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 wt(){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 ot(){var e,l,u,f,_,m;return f=s,_=s,e=mn(),e!==null?(m=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=$s(),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 mn(){var e,l;if(l=H(),l===null&&(l=me(),l===null&&(l=gn())),l!==null)for(e=[];l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(l=gn()));else e=null;return e}function gn(){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 $s(){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 Vt(){var e,l,u,f,_;return f=s,e=ss(),e!==null?(_=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=or(),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 ss(){var e,l;return l=s,e=Hs(),e===null&&(e=$t(),e===null&&(e=Fs())),e!==null&&(e=function(u){return b.host=o.substring(s,u).toLowerCase(),b.host}(l)),e===null&&(s=l),e}function Hs(){var e,l,u,f,_,m;for(f=s,_=s,e=[],m=s,l=vn(),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=vn(),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=Tn(),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 vn(){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 Tn(){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 Fs(){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,Oe,yt,bs,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?(Oe=re(),Oe!==null?(o.charCodeAt(s)===58?(yt=":",s++):(yt=null,d('":"')),yt!==null?(bs=nt(),bs!==null?e=[e,l,u,f,_,m,T,y,O,se,Oe,yt,bs]:(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?(Oe=":",s++):(Oe=null,d('":"')),Oe!==null?(yt=nt(),yt!==null?e=[e,l,u,f,_,m,T,y,O,se,Oe,yt]:(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?(Oe=nt(),Oe!==null?e=[e,l,u,f,_,m,T,y,O,se,Oe]:(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(sh){return b.host_type="IPv6",o.substring(s,sh)}(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=$t()),e}function $t(){var e,l,u,f,_,m,T,y,O;return y=s,O=s,e=ms(),e!==null?(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=ms(),u!==null?(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null?(_=ms(),_!==null?(o.charCodeAt(s)===46?(m=".",s++):(m=null,d('"."')),m!==null?(T=ms(),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 ms(){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 or(){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 En(){var e,l,u,f;for(e=[],f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=yn(),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=yn(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);return e}function yn(){var e;return e=ar(),e===null&&(e=ur(),e===null&&(e=cr(),e===null&&(e=fr(),e===null&&(e=hr(),e===null&&(e=_r(),e===null&&(e=dr())))))),e}function ar(){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 ur(){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 cr(){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=Ys(),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 fr(){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=fi(),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 hr(){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=ss(),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 _r(){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 dr(){var e,l,u,f,_,m;return f=s,_=s,e=pr(),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=gs(),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 pr(){var e,l,u;if(u=s,l=vs(),l!==null)for(e=[];l!==null;)e.push(l),l=vs();else e=null;return e!==null&&(e=function(f,_){return _.join("")}(u,e)),e===null&&(s=u),e}function gs(){var e,l,u;if(u=s,l=vs(),l!==null)for(e=[];l!==null;)e.push(l),l=vs();else e=null;return e!==null&&(e=function(f,_){return _.join("")}(u,e)),e===null&&(s=u),e}function vs(){var e;return e=mr(),e===null&&(e=H(),e===null&&(e=me())),e}function mr(){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=Vs(),l!==null){for(u=[],T=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(_=Vs(),_!==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?(_=Vs(),_!==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 Vs(){var e,l,u,f,_;return f=s,_=s,e=gr(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=Ts(),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 gr(){var e,l;if(l=js(),l===null&&(l=H(),l===null&&(l=me())),l!==null)for(e=[];l!==null;)e.push(l),l=js(),l===null&&(l=H(),l===null&&(l=me()));else e=null;return e}function Ts(){var e,l;for(e=[],l=js(),l===null&&(l=H(),l===null&&(l=me()));l!==null;)e.push(l),l=js(),l===null&&(l=H(),l===null&&(l=me()));return e}function js(){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 tl(){var e;return e=Pr(),e===null&&(e=vr()),e}function vr(){var e,l,u,f,_,m;return m=s,e=Ys(),e!==null?(l=F(),l!==null?(u=Sn(),u!==null?(f=F(),f!==null?(_=Rn(),_!==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 Sn(){var e;return e=we(),e===null&&(e=Cn()),e}function Cn(){var e,l,u,f;return f=s,e=yr(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=Tr(),u===null&&(u=Es()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Tr(){var e,l,u,f,_;return f=s,e=Bs(),e===null&&(e=Gs()),e!==null?(_=s,o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l!==null?(u=An(),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 Bs(){var e,l,u,f;return f=s,o.substr(s,2)==="//"?(e="//",s+=2):(e=null,d('"//"')),e!==null?(l=Sr(),l!==null?(u=Gs(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Gs(){var e,l,u;return u=s,o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e!==null?(l=Ks(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Es(){var e,l,u,f;if(f=s,e=Er(),e!==null){for(l=[],u=ys();u!==null;)l.push(u),u=ys();l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function ys(){var e;return e=N(),e===null&&(e=H(),e===null&&(e=me())),e}function Er(){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 Ks(){var e,l,u,f,_,m;if(_=s,e=Ss(),e!==null){for(l=[],m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Ss(),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=Ss(),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 Ss(){var e,l,u,f,_,m;for(_=s,e=[],l=Cs();l!==null;)e.push(l),l=Cs();if(e!==null){for(l=[],m=s,o.charCodeAt(s)===59?(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)===59?(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;for(e=[],l=Cs();l!==null;)e.push(l),l=Cs();return e}function Cs(){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 yr(){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 Sr(){var e;return e=Cr(),e===null&&(e=Ar()),e}function Cr(){var e,l,u,f;return u=s,f=s,e=ot(),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=Vt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e=e!==null?e:"",e}function Ar(){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 An(){var e,l;for(e=[],l=ys();l!==null;)e.push(l),l=ys();return e}function Rn(){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 Rr(){var e;return o.substr(s,6)==="INVITE"?(e="INVITE",s+=6):(e=null,d('"INVITE"')),e}function Ir(){var e;return o.substr(s,3)==="ACK"?(e="ACK",s+=3):(e=null,d('"ACK"')),e}function br(){var e;return o.substr(s,7)==="OPTIONS"?(e="OPTIONS",s+=7):(e=null,d('"OPTIONS"')),e}function wr(){var e;return o.substr(s,3)==="BYE"?(e="BYE",s+=3):(e=null,d('"BYE"')),e}function Or(){var e;return o.substr(s,6)==="CANCEL"?(e="CANCEL",s+=6):(e=null,d('"CANCEL"')),e}function Dr(){var e;return o.substr(s,8)==="REGISTER"?(e="REGISTER",s+=8):(e=null,d('"REGISTER"')),e}function Nr(){var e;return o.substr(s,9)==="SUBSCRIBE"?(e="SUBSCRIBE",s+=9):(e=null,d('"SUBSCRIBE"')),e}function Ur(){var e;return o.substr(s,6)==="NOTIFY"?(e="NOTIFY",s+=6):(e=null,d('"NOTIFY"')),e}function Ws(){var e;return o.substr(s,5)==="REFER"?(e="REFER",s+=5):(e=null,d('"REFER"')),e}function Ys(){var e,l;return l=s,e=Rr(),e===null&&(e=Ir(),e===null&&(e=br(),e===null&&(e=wr(),e===null&&(e=Or(),e===null&&(e=Dr(),e===null&&(e=Nr(),e===null&&(e=Ur(),e===null&&(e=Ws(),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 Pr(){var e,l,u,f,_,m;return m=s,e=Rn(),e!==null?(l=F(),l!==null?(u=kr(),u!==null?(f=F(),f!==null?(_=sl(),_!==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 kr(){var e,l;return l=s,e=Mr(),e!==null&&(e=function(u,f){b.status_code=parseInt(f.join(""))}(l,e)),e===null&&(s=l),e}function Mr(){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 sl(){var e,l,u;for(u=s,e=[],l=N(),l===null&&(l=H(),l===null&&(l=me(),l===null&&(l=$(),l===null&&(l=z(),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=z(),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 Io(){var e,l,u,f,_,m;if(_=s,e=Qs(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=Qs(),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=Qs(),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 bo(){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 In(){var e,l,u,f,_,m,T;if(_=s,e=G(),e===null)if(m=s,e=Ot(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=Ot(),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=Ot(),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 Ot(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Dt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=bn(),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=bn(),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 Dt(){var e,l,u,f,_;return _=s,e=As(),e=e!==null?e:"",e!==null?(l=ye(),l!==null?(u=we(),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 As(){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,Oe){return se+Oe[0]+Oe[1]},O[0])}(_,e)),e===null&&(s=_),e}function bn(){var e;return e=xr(),e===null&&(e=jt(),e===null&&(e=je())),e}function xr(){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=Ve(),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 jt(){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=Bt(),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 Bt(){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 Ve(){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 je(){var e,l,u,f,_,m;return f=s,_=s,e=P(),e!==null?(m=s,l=te(),l!==null?(u=nl(),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 nl(){var e;return e=P(),e===null&&(e=ss(),e===null&&(e=Ie())),e}function rl(){var e,l,u,f,_,m;if(_=s,e=wn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=On(),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=On(),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;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 On(){var e;return e=il(),e===null&&(e=je()),e}function il(){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 wo(){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 Oo(){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 ll(){var e,l;return l=s,e=Lr(),e!==null&&(e=function(u){b=o.substring(s,u)}(l)),e===null&&(s=l),e}function Lr(){var e,l,u,f,_,m,T,y;if(T=s,e=$r(),e!==null)if(l=B(),l!==null)if(u=Dn(),u!==null){for(f=[],y=s,_=Te(),_!==null?(m=Nn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=Te(),_!==null?(m=Nn(),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 $r(){var e;return e=Hr(),e===null&&(e=zs()),e}function Hr(){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=Js()))))),e}function zs(){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=Js())),e}function Js(){var e;return e=P(),e===null&&(e=Fr()),e}function Fr(){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 Dn(){var e;return e=Js(),e===null&&(e=P()),e}function Nn(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=ol(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ol(){var e;return e=P(),e===null&&(e=Ie()),e}function al(){var e,l,u,f;return f=s,e=ul(),e!==null?(l=M(),l!==null?(u=Ys(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ul(){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 Do(){var e,l;return l=s,e=Bt(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function Xs(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Qs(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=je(),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=je(),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 Qs(){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 qr(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Dt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Zs(),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=Zs(),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 Zs(){var e;return e=Vr(),e===null&&(e=je()),e}function Vr(){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 No(){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=Bt(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function Po(){var e,l,u,f,_,m,T,y,O,se;for(y=s,O=s,e=[],l=As();l!==null;)e.push(l),l=As();if(e!==null)if(l=ye(),l!==null)if(u=we(),u!==null)if(f=Ue(),f!==null){for(_=[],se=s,m=Te(),m!==null?(T=je(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);m!==null;)_.push(m),se=s,m=Te(),m!==null?(T=je(),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(Oe){try{b=new R(b.uri,b.display_name,b.params)}catch{b=-1}}()),e===null&&(s=y),e}function jr(){var e;return e=Un(),e}function Un(){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=en(),u!==null){for(f=[],y=s,_=ne(),_!==null?(m=en(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=ne(),_!==null?(m=en(),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=Rs()),e}function Rs(){var e,l,u,f,_,m,T,y;if(T=s,e=P(),e!==null)if(l=M(),l!==null)if(u=Gt(),u!==null){for(f=[],y=s,_=ne(),_!==null?(m=Gt(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=ne(),_!==null?(m=Gt(),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 Gt(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=P(),u===null&&(u=Ie()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function en(){var e;return e=Br(),e===null&&(e=tn(),e===null&&(e=Kr(),e===null&&(e=Yr(),e===null&&(e=zr(),e===null&&(e=Jr(),e===null&&(e=nn(),e===null&&(e=Gt()))))))),e}function Br(){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=Gr(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Gr(){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 tn(){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=sn(),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=sn(),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=sn(),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 sn(){var e;return e=Cn(),e===null&&(e=Gs()),e}function Kr(){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=Wr(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Wr(){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 Yr(){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 zr(){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 Jr(){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 nn(){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=Pn(),f!==null){for(_=[],se=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(T=Pn(),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=Pn(),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 Pn(){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 ko(){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 kn(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Mn(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=Mn(),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=Mn(),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 Mn(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Dt(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=je(),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=je(),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 Xr(){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=xn(),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=xn(),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 xn(){var e;return e=cl(),e===null&&(e=je()),e}function cl(){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 Mo(){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 Ln(){var e,l,u,f,_,m;if(_=s,e=$n(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=$n(),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=$n(),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 $n(){var e,l,u,f,_,m;if(_=s,e=Dt(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=je(),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=je(),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 fl(){var e,l,u,f,_,m;if(_=s,e=Hn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Fn(),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=Fn(),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 Hn(){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 Fn(){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=hl(),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=Bt(),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=Bt(),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=je()))),e}function hl(){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 xo(){var e;return e=V(),e=e!==null?e:"",e}function Lo(){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 Qr(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Dt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Zr(),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=Zr(),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 Zr(){var e;return e=Vr(),e===null&&(e=je()),e}function qn(){var e,l,u,f,_,m;if(_=s,e=Is(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=Is(),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=Is(),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 Is(){var e,l,u,f,_,m,T,y;if(T=s,e=li(),e!==null)if(l=M(),l!==null)if(u=ui(),u!==null){for(f=[],y=s,_=Te(),_!==null?(m=Vn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=Te(),_!==null?(m=Vn(),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 Vn(){var e;return e=ei(),e===null&&(e=ti(),e===null&&(e=si(),e===null&&(e=ni(),e===null&&(e=ri(),e===null&&(e=je()))))),e}function ei(){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=fi(),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 ti(){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=ss(),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 si(){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=$t(),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 ni(){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 ri(){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=ii(),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 ii(){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 li(){var e,l,u,f,_,m;return m=s,e=oi(),e!==null?(l=B(),l!==null?(u=P(),u!==null?(f=B(),f!==null?(_=ai(),_!==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 oi(){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 ai(){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 ui(){var e,l,u,f,_;return f=s,e=ci(),e!==null?(_=s,l=Qe(),l!==null?(u=jn(),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 ci(){var e,l;return l=s,e=$t(),e===null&&(e=Fs(),e===null&&(e=Hs())),e!==null&&(e=function(u){b.host=o.substring(s,u)}(l)),e===null&&(s=l),e}function jn(){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 fi(){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 $o(){var e;return e=Un(),e}function _l(){var e,l,u,f,_,m;if(_=s,e=Bn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Gn(),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=Gn(),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 Bn(){var e,l;return l=s,e=Bt(),e!==null&&(e=function(u,f){b.expires=f}(l,e)),e===null&&(s=l),e}function Gn(){var e;return e=dl(),e===null&&(e=je()),e}function dl(){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 pl(){var e,l,u,f;return f=s,e=P(),e!==null?(l=j(),l!==null?(u=ml(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ml(){var e,l;for(e=[],l=Y(),l===null&&(l=z(),l===null&&(l=M()));l!==null;)e.push(l),l=Y(),l===null&&(l=z(),l===null&&(l=M()));return e}function Ho(){var e,l;for(e=[],l=I();l!==null;)e.push(l),l=I();return e}function gl(){var e,l,u;return u=s,o.substr(s,5)==="uuid:"?(e="uuid:",s+=5):(e=null,d('"uuid:"')),e!==null?(l=Nt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Nt(){var e,l,u,f,_,m,T,y,O,se,Oe;return se=s,Oe=s,e=hi(),e!==null?(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l!==null?(u=Ut(),u!==null?(o.charCodeAt(s)===45?(f="-",s++):(f=null,d('"-"')),f!==null?(_=Ut(),_!==null?(o.charCodeAt(s)===45?(m="-",s++):(m=null,d('"-"')),m!==null?(T=Ut(),T!==null?(o.charCodeAt(s)===45?(y="-",s++):(y=null,d('"-"')),y!==null?(O=vl(),O!==null?e=[e,l,u,f,_,m,T,y,O]:(e=null,s=Oe)):(e=null,s=Oe)):(e=null,s=Oe)):(e=null,s=Oe)):(e=null,s=Oe)):(e=null,s=Oe)):(e=null,s=Oe)):(e=null,s=Oe)):(e=null,s=Oe),e!==null&&(e=function(yt,bs){b=o.substring(s+5,yt)}(se,e[0])),e===null&&(s=se),e}function Ut(){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 hi(){var e,l,u;return u=s,e=Ut(),e!==null?(l=Ut(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function vl(){var e,l,u,f;return f=s,e=Ut(),e!==null?(l=Ut(),l!==null?(u=Ut(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Fo(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Dt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=je(),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=je(),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 Tl(){var e,l,u,f,_,m;if(_=s,e=Kn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Wn(),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=Wn(),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 Kn(){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 Wn(){var e;return e=_i(),e===null&&(e=di(),e===null&&(e=El(),e===null&&(e=je()))),e}function _i(){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 di(){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 El(){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 qo(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 yl(){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):
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
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=tt,t=Ls(),s=Zt();ze.str_utf8_length=function(g){return unescape(encodeURIComponent(g)).length};var p=ze.isFunction=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object Function]":!1};ze.isString=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object String]":!1},ze.isDecimal=function(g){return!isNaN(g)&&parseFloat(g)===parseInt(g,10)},ze.isEmpty=function(g){return g===null||g===""||g===void 0||Array.isArray(g)&&g.length===0||typeof g=="number"&&isNaN(g)},ze.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=ze.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};ze.newTag=function(){return h(10)},ze.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},ze.hostType=function(g){if(g){if(g=s.parse(g,"host"),g!==-1)return g.host_type}else return};var d=ze.escapeUser=function(g){return encodeURIComponent(decodeURIComponent(g)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return ze.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},ze.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},ze.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},ze.getRandomTestNetIP=function(){function g(v,E){return Math.floor(Math.random()*(E-v+1)+v)}return"192.0.2.".concat(g(1,254))},ze.calculateMD5=function(g){function v(he,le){return he<<le|he>>>32-le}function E(he,le){var fe=he&2147483648,Re=le&2147483648,we=he&1073741824,Ye=le&1073741824,ke=(he&1073741823)+(le&1073741823);return we&Ye?ke^2147483648^fe^Re:we|Ye?ke&1073741824?ke^3221225472^fe^Re:ke^1073741824^fe^Re:ke^fe^Re}function S(he,le,fe){return he&le|~he&fe}function C(he,le,fe){return he&fe|le&~fe}function I(he,le,fe){return he^le^fe}function w(he,le,fe){return le^(he|~fe)}function F(he,le,fe,Re,we,Ye,ke){return he=E(he,E(E(S(le,fe,Re),we),ke)),E(v(he,Ye),le)}function L(he,le,fe,Re,we,Ye,ke){return he=E(he,E(E(C(le,fe,Re),we),ke)),E(v(he,Ye),le)}function ie(he,le,fe,Re,we,Ye,ke){return he=E(he,E(E(I(le,fe,Re),we),ke)),E(v(he,Ye),le)}function N(he,le,fe,Re,we,Ye,ke){return he=E(he,E(E(w(le,fe,Re),we),ke)),E(v(he,Ye),le)}function H(he){for(var le,fe=he.length,Re=fe+8,we=(Re-Re%64)/64,Ye=(we+1)*16,ke=new Array(Ye-1),wt=0,ot=0;ot<fe;)le=(ot-ot%4)/4,wt=ot%4*8,ke[le]=ke[le]|he.charCodeAt(ot)<<wt,ot++;return le=(ot-ot%4)/4,wt=ot%4*8,ke[le]=ke[le]|128<<wt,ke[Ye-2]=fe<<3,ke[Ye-1]=fe>>>29,ke}function ve(he){var le="",fe="",Re,we;for(we=0;we<=3;we++)Re=he>>>we*8&255,fe="0".concat(Re.toString(16)),le=le+fe.substr(fe.length-2,2);return le}function me(he){for(var le="",fe=0;fe<he.length;fe++){var Re=he.charCodeAt(fe);Re<128?le+=String.fromCharCode(Re):Re>127&&Re<2048?(le+=String.fromCharCode(Re>>6|192),le+=String.fromCharCode(Re&63|128)):(le+=String.fromCharCode(Re>>12|224),le+=String.fromCharCode(Re>>6&63|128),le+=String.fromCharCode(Re&63|128))}return le}var M=[],D,j,V,Y,$,z,U,P,Z,Xe=7,Q=12,G=17,B=22,te=5,de=9,Ae=14,Ue=20,ye=4,ne=11,Te=16,Qe=23,st=6,ge=10,Ee=15,Ce=21;for(g=me(g),M=H(g),z=1732584193,U=4023233417,P=2562383102,Z=271733878,D=0;D<M.length;D+=16)j=z,V=U,Y=P,$=Z,z=F(z,U,P,Z,M[D+0],Xe,3614090360),Z=F(Z,z,U,P,M[D+1],Q,3905402710),P=F(P,Z,z,U,M[D+2],G,606105819),U=F(U,P,Z,z,M[D+3],B,3250441966),z=F(z,U,P,Z,M[D+4],Xe,4118548399),Z=F(Z,z,U,P,M[D+5],Q,1200080426),P=F(P,Z,z,U,M[D+6],G,2821735955),U=F(U,P,Z,z,M[D+7],B,4249261313),z=F(z,U,P,Z,M[D+8],Xe,1770035416),Z=F(Z,z,U,P,M[D+9],Q,2336552879),P=F(P,Z,z,U,M[D+10],G,4294925233),U=F(U,P,Z,z,M[D+11],B,2304563134),z=F(z,U,P,Z,M[D+12],Xe,1804603682),Z=F(Z,z,U,P,M[D+13],Q,4254626195),P=F(P,Z,z,U,M[D+14],G,2792965006),U=F(U,P,Z,z,M[D+15],B,1236535329),z=L(z,U,P,Z,M[D+1],te,4129170786),Z=L(Z,z,U,P,M[D+6],de,3225465664),P=L(P,Z,z,U,M[D+11],Ae,643717713),U=L(U,P,Z,z,M[D+0],Ue,3921069994),z=L(z,U,P,Z,M[D+5],te,3593408605),Z=L(Z,z,U,P,M[D+10],de,38016083),P=L(P,Z,z,U,M[D+15],Ae,3634488961),U=L(U,P,Z,z,M[D+4],Ue,3889429448),z=L(z,U,P,Z,M[D+9],te,568446438),Z=L(Z,z,U,P,M[D+14],de,3275163606),P=L(P,Z,z,U,M[D+3],Ae,4107603335),U=L(U,P,Z,z,M[D+8],Ue,1163531501),z=L(z,U,P,Z,M[D+13],te,2850285829),Z=L(Z,z,U,P,M[D+2],de,4243563512),P=L(P,Z,z,U,M[D+7],Ae,1735328473),U=L(U,P,Z,z,M[D+12],Ue,2368359562),z=ie(z,U,P,Z,M[D+5],ye,4294588738),Z=ie(Z,z,U,P,M[D+8],ne,2272392833),P=ie(P,Z,z,U,M[D+11],Te,1839030562),U=ie(U,P,Z,z,M[D+14],Qe,4259657740),z=ie(z,U,P,Z,M[D+1],ye,2763975236),Z=ie(Z,z,U,P,M[D+4],ne,1272893353),P=ie(P,Z,z,U,M[D+7],Te,4139469664),U=ie(U,P,Z,z,M[D+10],Qe,3200236656),z=ie(z,U,P,Z,M[D+13],ye,681279174),Z=ie(Z,z,U,P,M[D+0],ne,3936430074),P=ie(P,Z,z,U,M[D+3],Te,3572445317),U=ie(U,P,Z,z,M[D+6],Qe,76029189),z=ie(z,U,P,Z,M[D+9],ye,3654602809),Z=ie(Z,z,U,P,M[D+12],ne,3873151461),P=ie(P,Z,z,U,M[D+15],Te,530742520),U=ie(U,P,Z,z,M[D+2],Qe,3299628645),z=N(z,U,P,Z,M[D+0],st,4096336452),Z=N(Z,z,U,P,M[D+7],ge,1126891415),P=N(P,Z,z,U,M[D+14],Ee,2878612391),U=N(U,P,Z,z,M[D+5],Ce,4237533241),z=N(z,U,P,Z,M[D+12],st,1700485571),Z=N(Z,z,U,P,M[D+3],ge,2399980690),P=N(P,Z,z,U,M[D+10],Ee,4293915773),U=N(U,P,Z,z,M[D+1],Ce,2240044497),z=N(z,U,P,Z,M[D+8],st,1873313359),Z=N(Z,z,U,P,M[D+15],ge,4264355552),P=N(P,Z,z,U,M[D+6],Ee,2734768916),U=N(U,P,Z,z,M[D+13],Ce,1309151649),z=N(z,U,P,Z,M[D+4],st,4149444226),Z=N(Z,z,U,P,M[D+11],ge,3174756917),P=N(P,Z,z,U,M[D+2],Ee,718787259),U=N(U,P,Z,z,M[D+9],Ce,3951481745),z=E(z,j),U=E(U,V),P=E(P,Y),Z=E(Z,$);var Ie=ve(z)+ve(U)+ve(P)+ve(Z);return Ie.toLowerCase()},ze.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()}},ze.cloneArray=function(g){return g&&g.slice()||[]},ze.cloneObject=function(g){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g&&Object.assign({},g)||v},ze}var su={exports:{}},sr=typeof Reflect=="object"?Reflect:null,Su=sr&&typeof sr.apply=="function"?sr.apply:function(r,n,o){return Function.prototype.apply.call(r,n,o)},Jl;sr&&typeof sr.ownKeys=="function"?Jl=sr.ownKeys:Object.getOwnPropertySymbols?Jl=function(r){return Object.getOwnPropertyNames(r).concat(Object.getOwnPropertySymbols(r))}:Jl=function(r){return Object.getOwnPropertyNames(r)};function Ih(c){console&&console.warn&&console.warn(c)}var mf=Number.isNaN||function(r){return r!==r};function Pe(){Pe.init.call(this)}su.exports=Pe;su.exports.once=Dh;Pe.EventEmitter=Pe;Pe.prototype._events=void 0;Pe.prototype._eventsCount=0;Pe.prototype._maxListeners=void 0;var Cu=10;function So(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 Cu},set:function(c){if(typeof c!="number"||c<0||mf(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Cu=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||mf(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 gf(c){return c._maxListeners===void 0?Pe.defaultMaxListeners:c._maxListeners}Pe.prototype.getMaxListeners=function(){return gf(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")Su(h,this,n);else for(var d=h.length,g=Sf(h,d),o=0;o<d;++o)Su(g[o],this,n);return!0};function vf(c,r,n,o){var a,t,s;if(So(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=gf(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,Ih(p)}return c}Pe.prototype.addListener=function(r,n){return vf(this,r,n,!1)};Pe.prototype.on=Pe.prototype.addListener;Pe.prototype.prependListener=function(r,n){return vf(this,r,n,!0)};function bh(){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 Tf(c,r,n){var o={fired:!1,wrapFn:void 0,target:c,type:r,listener:n},a=bh.bind(o);return a.listener=n,o.wrapFn=a,a}Pe.prototype.once=function(r,n){return So(n),this.on(r,Tf(this,r,n)),this};Pe.prototype.prependOnceListener=function(r,n){return So(n),this.prependListener(r,Tf(this,r,n)),this};Pe.prototype.removeListener=function(r,n){var o,a,t,s,p;if(So(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():wh(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 Ef(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?Oh(a):Sf(a,a.length)}Pe.prototype.listeners=function(r){return Ef(this,r,!0)};Pe.prototype.rawListeners=function(r){return Ef(this,r,!1)};Pe.listenerCount=function(c,r){return typeof c.listenerCount=="function"?c.listenerCount(r):yf.call(c,r)};Pe.prototype.listenerCount=yf;function yf(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?Jl(this._events):[]};function Sf(c,r){for(var n=new Array(r),o=0;o<r;++o)n[o]=c[o];return n}function wh(c,r){for(;r+1<c.length;r++)c[r]=c[r+1];c.pop()}function Oh(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))}Cf(c,r,t,{once:!0}),r!=="error"&&Nh(c,a,{once:!0})})}function Nh(c,r,n){typeof c.on=="function"&&Cf(c,"error",r,n)}function Cf(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 pt=su.exports,La={exports:{}},Go,Au;function Uh(){if(Au)return Go;Au=1;var c=1e3,r=c*60,n=r*60,o=n*24,a=o*7,t=o*365.25;Go=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 Go}function Ph(c){n.debug=n,n.default=n,n.coerce=h,n.disable=t,n.enable=a,n.enabled=s,n.humanize=Uh(),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 kh=Ph;(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=kh(r);const{formatters:p}=c.exports;p.j=function(h){try{return JSON.stringify(h)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(La,La.exports);var rr=La.exports;function Mh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Ru(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&&Ru(c.prototype,r),n&&Ru(c,n),c}var Yn=rr,zn="JsSIP",it=function(){function c(r){Mh(this,c),r?(this._debug=Yn.default("".concat(zn,":").concat(r)),this._warn=Yn.default("".concat(zn,":WARN:").concat(r)),this._error=Yn.default("".concat(zn,":ERROR:").concat(r))):(this._debug=Yn.default(zn),this._warn=Yn.default("".concat(zn,":WARN")),this._error=Yn.default("".concat(zn,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return xh(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),Lt={},Af={},Rf={exports:{}},Iu=Rf.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(Iu).forEach(function(c){var r=Iu[c];r.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})});var If=Rf.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=If,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}})})}})(Af);var Ko=If,Lh=/%[sdv%]/g,$h=function(c){var r=1,n=arguments,o=n.length;return c.replace(Lh,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""}})},gi=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 $h.apply(null,a)},Hh=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Fh=["i","c","b","a"],qh=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||Hh,o=r.innerOrder||Fh,a=[];return n.forEach(function(t){Ko[t].forEach(function(s){s.name in c&&c[s.name]!=null?a.push(gi(t,s,c)):s.push in c&&c[s.push]!=null&&c[s.push].forEach(function(p){a.push(gi(t,s,p))})})}),c.media.forEach(function(t){a.push(gi("m",Ko.m[0],t)),o.forEach(function(s){Ko[s].forEach(function(p){p.name in t&&t[p.name]!=null?a.push(gi(s,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(h){a.push(gi(s,p,h))})})})}),a.join(`\r
|
3
|
+
`,s+=2):(e=null,d('"\\r\\n"')),e}function T(){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 y(){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 A(){var e;return e=$(),e===null&&(e=L()),e}function R(){var e;return/^[\0-\xFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\0-\\xFF]")),e}function I(){var e;return/^["]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d('["]')),e}function $(){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 ae(){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 F(){var e;return e=ae(),e===null&&(e=Se()),e}function Se(){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 ve(){var e,l,u,f,h;return f=s,h=s,o.charCodeAt(s)===37?(e="%",s++):(e=null,d('"%"')),e!==null?(l=y(),l!==null?(u=y(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){return v.join("")}(f,e)),e===null&&(s=f),e}function M(){var e,l,u,f,h,m;for(f=s,h=s,m=s,e=[],l=A();l!==null;)e.push(l),l=A();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=A(),u!==null)for(l=[];u!==null;)l.push(u),u=A();else l=null;l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e!==null&&(e=function(v){return" "}()),e===null&&(s=f),e}function D(){var e;return e=M(),e=e!==null?e:"",e}function q(){var e,l,u,f,h;for(f=s,h=s,e=[],l=$(),l===null&&(l=L());l!==null;)e.push(l),l=$(),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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function j(){var e,l,u,f,h,m,v;if(h=s,m=s,l=z(),l!==null)for(e=[];l!==null;)e.push(l),l=z();else e=null;if(e!==null){for(l=[],v=s,u=[],f=M();f!==null;)u.push(f),f=M();for(u!==null?(f=z(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;){for(l.push(u),v=s,u=[],f=M();f!==null;)u.push(f),f=M();u!==null?(f=z(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v)}l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){return o.substring(s,S)}(h)),e===null&&(s=h),e}function z(){var e;return/^[!-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[!-~]")),e===null&&(e=H()),e}function H(){var e;return/^[\x80-\uFFFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\x80-\\uFFFF]")),e}function J(){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=T(),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=ae(),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=ae(),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 se(){var e,l,u;if(u=s,l=ae(),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=ae(),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=I(),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=$(),e===null&&(e=L())))))))))))))))))),e}function ee(){var e,l,u;if(u=s,l=ae(),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=I(),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=ae(),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=I(),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,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"*"}()),e===null&&(s=f),e}function B(){var e,l,u,f,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"/"}()),e===null&&(s=f),e}function re(){var e,l,u,f,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"="}()),e===null&&(s=f),e}function ge(){var e,l,u,f,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"("}()),e===null&&(s=f),e}function be(){var e,l,u,f,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return")"}()),e===null&&(s=f),e}function xe(){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(h){return">"}()),e===null&&(s=u),e}function Ce(){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(h){return"<"}()),e===null&&(s=u),e}function le(){var e,l,u,f,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return","}()),e===null&&(s=f),e}function ye(){var e,l,u,f,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return";"}()),e===null&&(s=f),e}function tt(){var e,l,u,f,h;return f=s,h=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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function it(){var e,l,u,f;return u=s,f=s,e=D(),e!==null?(l=I(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h){return'"'}()),e===null&&(s=u),e}function Ee(){var e,l,u,f;return u=s,f=s,e=I(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h){return'"'}()),e===null&&(s=u),e}function Ae(){var e,l,u,f;if(f=s,e=ge(),e!==null){for(l=[],u=Ie(),u===null&&(u=de(),u===null&&(u=Ae()));u!==null;)l.push(u),u=Ie(),u===null&&(u=de(),u===null&&(u=Ae()));l!==null?(u=be(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)}else e=null,s=f;return e}function Ie(){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=H(),e===null&&(e=M())))),e}function Oe(){var e,l,u,f,h,m;if(h=s,m=s,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=ue(),f===null&&(f=de());f!==null;)u.push(f),f=ue(),f===null&&(f=de());u!==null?(f=I(),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(v){return o.substring(s,v)}(h)),e===null&&(s=h),e}function pe(){var e,l,u,f,h,m;if(h=s,m=s,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=ue(),f===null&&(f=de());f!==null;)u.push(f),f=ue(),f===null&&(f=de());u!==null?(f=I(),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(v){var S=o.substring(s,v).trim();return S.substring(1,S.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(h)),e===null&&(s=h),e}function ue(){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=H())))),e}function de(){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 we(){var e,l,u,f,h,m;return h=s,m=s,e=Xe(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=_t(),u=u!==null?u:"",u!==null?(f=Yt(),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(v){try{w.uri=new as(w.scheme,w.user,w.host,w.port),delete w.scheme,delete w.user,delete w.host,delete w.host_type,delete w.port}catch{w=-1}}()),e===null&&(s=h),e}function De(){var e,l,u,f,h,m,v,S;return v=s,S=s,e=Xe(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=_t(),u=u!==null?u:"",u!==null?(f=Yt(),f!==null?(h=Rn(),h!==null?(m=Gs(),m=m!==null?m:"",m!==null?e=[e,l,u,f,h,m]:(e=null,s=S)):(e=null,s=S)):(e=null,s=S)):(e=null,s=S)):(e=null,s=S)):(e=null,s=S),e!==null&&(e=function(O){try{w.uri=new as(w.scheme,w.user,w.host,w.port,w.uri_params,w.uri_headers),delete w.scheme,delete w.user,delete w.host,delete w.host_type,delete w.port,delete w.uri_params,a==="SIP_URI"&&(w=w.uri)}catch{w=-1}}()),e===null&&(s=v),e}function Xe(){var e;return e=Le(),e===null&&(e=Mt()),e}function Le(){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){w.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function Mt(){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){w.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function _t(){var e,l,u,f,h,m;return f=s,h=s,e=Sn(),e!==null?(m=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=js(),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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(v){w.user=decodeURIComponent(o.substring(s-1,v))}(f)),e===null&&(s=f),e}function Sn(){var e,l;if(l=F(),l===null&&(l=ve(),l===null&&(l=yn())),l!==null)for(e=[];l!==null;)e.push(l),l=F(),l===null&&(l=ve(),l===null&&(l=yn()));else e=null;return e}function yn(){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 js(){var e,l,u;for(u=s,e=[],l=F(),l===null&&(l=ve(),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=F(),l===null&&(l=ve(),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){w.password=o.substring(s,f)}(u)),e===null&&(s=u),e}function Yt(){var e,l,u,f,h;return f=s,e=ls(),e!==null?(h=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=_r(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function ls(){var e,l;return l=s,e=qs(),e===null&&(e=Bt(),e===null&&(e=Bs())),e!==null&&(e=function(u){return w.host=o.substring(s,u).toLowerCase(),w.host}(l)),e===null&&(s=l),e}function qs(){var e,l,u,f,h,m;for(f=s,h=s,e=[],m=s,l=An(),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=An(),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=Cn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(v){return w.host_type="domain",o.substring(s,v)}(f)),e===null&&(s=f),e}function An(){var e,l,u,f;if(f=s,e=ae(),e!==null){for(l=[],u=ae(),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=ae(),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 Cn(){var e,l,u,f;if(f=s,e=E(),e!==null){for(l=[],u=ae(),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=ae(),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 Bs(){var e,l,u,f,h;return f=s,h=s,o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e!==null?(l=me(),l!==null?(o.charCodeAt(s)===93?(u="]",s++):(u=null,d('"]"')),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return w.host_type="IPv6",o.substring(s,m)}(f)),e===null&&(s=f),e}function me(){var e,l,u,f,h,m,v,S,O,ie,Ne,Rt,Ns,k,C,Te;return k=s,C=s,e=oe(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(s)===58?(S=":",s++):(S=null,d('":"')),S!==null?(O=oe(),O!==null?(o.charCodeAt(s)===58?(ie=":",s++):(ie=null,d('":"')),ie!==null?(Ne=oe(),Ne!==null?(o.charCodeAt(s)===58?(Rt=":",s++):(Rt=null,d('":"')),Rt!==null?(Ns=lt(),Ns!==null?e=[e,l,u,f,h,m,v,S,O,ie,Ne,Rt,Ns]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(s)===58?(v=":",s++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(ie=oe(),ie!==null?(o.charCodeAt(s)===58?(Ne=":",s++):(Ne=null,d('":"')),Ne!==null?(Rt=lt(),Rt!==null?e=[e,l,u,f,h,m,v,S,O,ie,Ne,Rt]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(s)===58?(v=":",s++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(ie=lt(),ie!==null?e=[e,l,u,f,h,m,v,S,O,ie]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(s)===58?(v=":",s++):(v=null,d('":"')),v!==null?(S=lt(),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=lt(),m!==null?e=[e,l,u,f,h,m]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=lt(),f!==null?e=[e,l,u,f]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=lt(),l!==null?e=[e,l]:(e=null,s=C)):(e=null,s=C),e===null&&(C=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?e=[e,l]:(e=null,s=C)):(e=null,s=C),e===null&&(C=s,e=oe(),e!==null?(o.substr(s,2)==="::"?(l="::",s+=2):(l=null,d('"::"')),l!==null?(u=oe(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(s)===58?(S=":",s++):(S=null,d('":"')),S!==null?(O=oe(),O!==null?(o.charCodeAt(s)===58?(ie=":",s++):(ie=null,d('":"')),ie!==null?(Ne=lt(),Ne!==null?e=[e,l,u,f,h,m,v,S,O,ie,Ne]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,e=oe(),e!==null?(Te=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,s=Te)):(l=null,s=Te),l=l!==null?l:"",l!==null?(o.substr(s,2)==="::"?(u="::",s+=2):(u=null,d('"::"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(s)===58?(v=":",s++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(ie=lt(),ie!==null?e=[e,l,u,f,h,m,v,S,O,ie]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,e=oe(),e!==null?(Te=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,s=Te)):(l=null,s=Te),l=l!==null?l:"",l!==null?(Te=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,s=Te)):(u=null,s=Te),u=u!==null?u:"",u!==null?(o.substr(s,2)==="::"?(f="::",s+=2):(f=null,d('"::"')),f!==null?(h=oe(),h!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(s)===58?(S=":",s++):(S=null,d('":"')),S!==null?(O=lt(),O!==null?e=[e,l,u,f,h,m,v,S,O]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,e=oe(),e!==null?(Te=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,s=Te)):(l=null,s=Te),l=l!==null?l:"",l!==null?(Te=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,s=Te)):(u=null,s=Te),u=u!==null?u:"",u!==null?(Te=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,s=Te)):(f=null,s=Te),f=f!==null?f:"",f!==null?(o.substr(s,2)==="::"?(h="::",s+=2):(h=null,d('"::"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(s)===58?(v=":",s++):(v=null,d('":"')),v!==null?(S=lt(),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,e=oe(),e!==null?(Te=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,s=Te)):(l=null,s=Te),l=l!==null?l:"",l!==null?(Te=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,s=Te)):(u=null,s=Te),u=u!==null?u:"",u!==null?(Te=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,s=Te)):(f=null,s=Te),f=f!==null?f:"",f!==null?(Te=s,o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?h=[h,m]:(h=null,s=Te)):(h=null,s=Te),h=h!==null?h:"",h!==null?(o.substr(s,2)==="::"?(m="::",s+=2):(m=null,d('"::"')),m!==null?(v=lt(),v!==null?e=[e,l,u,f,h,m,v]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,e=oe(),e!==null?(Te=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,s=Te)):(l=null,s=Te),l=l!==null?l:"",l!==null?(Te=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,s=Te)):(u=null,s=Te),u=u!==null?u:"",u!==null?(Te=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,s=Te)):(f=null,s=Te),f=f!==null?f:"",f!==null?(Te=s,o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?h=[h,m]:(h=null,s=Te)):(h=null,s=Te),h=h!==null?h:"",h!==null?(Te=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,s=Te)):(m=null,s=Te),m=m!==null?m:"",m!==null?(o.substr(s,2)==="::"?(v="::",s+=2):(v=null,d('"::"')),v!==null?(S=oe(),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C),e===null&&(C=s,e=oe(),e!==null?(Te=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,s=Te)):(l=null,s=Te),l=l!==null?l:"",l!==null?(Te=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,s=Te)):(u=null,s=Te),u=u!==null?u:"",u!==null?(Te=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,s=Te)):(f=null,s=Te),f=f!==null?f:"",f!==null?(Te=s,o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?h=[h,m]:(h=null,s=Te)):(h=null,s=Te),h=h!==null?h:"",h!==null?(Te=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,s=Te)):(m=null,s=Te),m=m!==null?m:"",m!==null?(Te=s,o.charCodeAt(s)===58?(v=":",s++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?v=[v,S]:(v=null,s=Te)):(v=null,s=Te),v=v!==null?v:"",v!==null?(o.substr(s,2)==="::"?(S="::",s+=2):(S=null,d('"::"')),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C)):(e=null,s=C))))))))))))))),e!==null&&(e=function(E_){return w.host_type="IPv6",o.substring(s,E_)}(k)),e===null&&(s=k),e}function oe(){var e,l,u,f,h;return h=s,e=y(),e!==null?(l=y(),l=l!==null?l:"",l!==null?(u=y(),u=u!==null?u:"",u!==null?(f=y(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e}function lt(){var e,l,u,f;return f=s,e=oe(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(e=Bt()),e}function Bt(){var e,l,u,f,h,m,v,S,O;return S=s,O=s,e=Es(),e!==null?(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=Es(),u!==null?(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null?(h=Es(),h!==null?(o.charCodeAt(s)===46?(m=".",s++):(m=null,d('"."')),m!==null?(v=Es(),v!==null?e=[e,l,u,f,h,m,v]:(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(ie){return w.host_type="IPv4",o.substring(s,ie)}(S)),e===null&&(s=S),e}function Es(){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=T(),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=T(),l!==null?(u=T(),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=T(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e===null&&(e=T())))),e}function _r(){var e,l,u,f,h,m,v;return m=s,v=s,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(h=T(),h=h!==null?h:"",h!==null?e=[e,l,u,f,h]:(e=null,s=v)):(e=null,s=v)):(e=null,s=v)):(e=null,s=v)):(e=null,s=v),e!==null&&(e=function(S,O){return O=parseInt(O.join("")),w.port=O,O}(m,e)),e===null&&(s=m),e}function Rn(){var e,l,u,f;for(e=[],f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=In(),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=In(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);return e}function In(){var e;return e=hr(),e===null&&(e=dr(),e===null&&(e=pr(),e===null&&(e=mr(),e===null&&(e=gr(),e===null&&(e=Tr(),e===null&&(e=vr())))))),e}function hr(){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(h,m){w.uri_params||(w.uri_params={}),w.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function dr(){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(h,m){w.uri_params||(w.uri_params={}),w.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function pr(){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=Qs(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){w.uri_params||(w.uri_params={}),w.uri_params.method=m}(u,e[1])),e===null&&(s=u),e}function mr(){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=mi(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){w.params||(w.params={}),w.params.ttl=m}(u,e[1])),e===null&&(s=u),e}function gr(){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=ls(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){w.uri_params||(w.uri_params={}),w.uri_params.maddr=m}(u,e[1])),e===null&&(s=u),e}function Tr(){var e,l,u,f,h,m;return f=s,h=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=h)):(e=null,s=h),e!==null&&(e=function(v){w.uri_params||(w.uri_params={}),w.uri_params.lr=void 0}()),e===null&&(s=f),e}function vr(){var e,l,u,f,h,m;return f=s,h=s,e=Er(),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=Ss(),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=h)):(e=null,s=h),e!==null&&(e=function(v,S,O){w.uri_params||(w.uri_params={}),typeof O>"u"?O=void 0:O=O[1],w.uri_params[S.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function Er(){var e,l,u;if(u=s,l=ys(),l!==null)for(e=[];l!==null;)e.push(l),l=ys();else e=null;return e!==null&&(e=function(f,h){return h.join("")}(u,e)),e===null&&(s=u),e}function Ss(){var e,l,u;if(u=s,l=ys(),l!==null)for(e=[];l!==null;)e.push(l),l=ys();else e=null;return e!==null&&(e=function(f,h){return h.join("")}(u,e)),e===null&&(s=u),e}function ys(){var e;return e=Sr(),e===null&&(e=F(),e===null&&(e=ve())),e}function Sr(){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 Gs(){var e,l,u,f,h,m,v;if(m=s,o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e!==null)if(l=Ws(),l!==null){for(u=[],v=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(h=Ws(),h!==null?f=[f,h]:(f=null,s=v)):(f=null,s=v);f!==null;)u.push(f),v=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(h=Ws(),h!==null?f=[f,h]:(f=null,s=v)):(f=null,s=v);u!==null?e=[e,l,u]:(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e}function Ws(){var e,l,u,f,h;return f=s,h=s,e=yr(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=As(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v,S){v=v.join("").toLowerCase(),S=S.join(""),w.uri_headers||(w.uri_headers={}),w.uri_headers[v]?w.uri_headers[v].push(S):w.uri_headers[v]=[S]}(f,e[0],e[2])),e===null&&(s=f),e}function yr(){var e,l;if(l=Ks(),l===null&&(l=F(),l===null&&(l=ve())),l!==null)for(e=[];l!==null;)e.push(l),l=Ks(),l===null&&(l=F(),l===null&&(l=ve()));else e=null;return e}function As(){var e,l;for(e=[],l=Ks(),l===null&&(l=F(),l===null&&(l=ve()));l!==null;)e.push(l),l=Ks(),l===null&&(l=F(),l===null&&(l=ve()));return e}function Ks(){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 ol(){var e;return e=$r(),e===null&&(e=Ar()),e}function Ar(){var e,l,u,f,h,m;return m=s,e=Qs(),e!==null?(l=$(),l!==null?(u=bn(),u!==null?(f=$(),f!==null?(h=Dn(),h!==null?e=[e,l,u,f,h]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function bn(){var e;return e=De(),e===null&&(e=wn()),e}function wn(){var e,l,u,f;return f=s,e=Ir(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=Cr(),u===null&&(u=Cs()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Cr(){var e,l,u,f,h;return f=s,e=Ys(),e===null&&(e=zs()),e!==null?(h=s,o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l!==null?(u=On(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function Ys(){var e,l,u,f;return f=s,o.substr(s,2)==="//"?(e="//",s+=2):(e=null,d('"//"')),e!==null?(l=br(),l!==null?(u=zs(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function zs(){var e,l,u;return u=s,o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e!==null?(l=Js(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Cs(){var e,l,u,f;if(f=s,e=Rr(),e!==null){for(l=[],u=Rs();u!==null;)l.push(u),u=Rs();l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Rs(){var e;return e=N(),e===null&&(e=F(),e===null&&(e=ve())),e}function Rr(){var e;return e=F(),e===null&&(e=ve(),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 Js(){var e,l,u,f,h,m;if(h=s,e=Is(),e!==null){for(l=[],m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Is(),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=Is(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Is(){var e,l,u,f,h,m;for(h=s,e=[],l=bs();l!==null;)e.push(l),l=bs();if(e!==null){for(l=[],m=s,o.charCodeAt(s)===59?(u=";",s++):(u=null,d('";"')),u!==null?(f=os(),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=os(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function os(){var e,l;for(e=[],l=bs();l!==null;)e.push(l),l=bs();return e}function bs(){var e;return e=F(),e===null&&(e=ve(),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 Ir(){var e,l,u,f,h;if(f=s,h=s,e=E(),e!==null){for(l=[],u=E(),u===null&&(u=T(),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=T(),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=h)}else e=null,s=h;return e!==null&&(e=function(m){w.scheme=o.substring(s,m)}(f)),e===null&&(s=f),e}function br(){var e;return e=wr(),e===null&&(e=Or()),e}function wr(){var e,l,u,f;return u=s,f=s,e=_t(),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=Yt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e=e!==null?e:"",e}function Or(){var e,l;if(l=F(),l===null&&(l=ve(),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=F(),l===null&&(l=ve(),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 On(){var e,l;for(e=[],l=Rs();l!==null;)e.push(l),l=Rs();return e}function Dn(){var e,l,u,f,h,m,v,S;if(v=s,S=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=T(),f!==null)for(u=[];f!==null;)u.push(f),f=T();else u=null;if(u!==null)if(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null){if(m=T(),m!==null)for(h=[];m!==null;)h.push(m),m=T();else h=null;h!==null?e=[e,l,u,f,h]:(e=null,s=S)}else e=null,s=S;else e=null,s=S}else e=null,s=S;else e=null,s=S;return e!==null&&(e=function(O){w.sip_version=o.substring(s,O)}(v)),e===null&&(s=v),e}function Dr(){var e;return o.substr(s,6)==="INVITE"?(e="INVITE",s+=6):(e=null,d('"INVITE"')),e}function Nr(){var e;return o.substr(s,3)==="ACK"?(e="ACK",s+=3):(e=null,d('"ACK"')),e}function Ur(){var e;return o.substr(s,7)==="OPTIONS"?(e="OPTIONS",s+=7):(e=null,d('"OPTIONS"')),e}function Pr(){var e;return o.substr(s,3)==="BYE"?(e="BYE",s+=3):(e=null,d('"BYE"')),e}function xr(){var e;return o.substr(s,6)==="CANCEL"?(e="CANCEL",s+=6):(e=null,d('"CANCEL"')),e}function Mr(){var e;return o.substr(s,8)==="REGISTER"?(e="REGISTER",s+=8):(e=null,d('"REGISTER"')),e}function kr(){var e;return o.substr(s,9)==="SUBSCRIBE"?(e="SUBSCRIBE",s+=9):(e=null,d('"SUBSCRIBE"')),e}function Lr(){var e;return o.substr(s,6)==="NOTIFY"?(e="NOTIFY",s+=6):(e=null,d('"NOTIFY"')),e}function Xs(){var e;return o.substr(s,5)==="REFER"?(e="REFER",s+=5):(e=null,d('"REFER"')),e}function Qs(){var e,l;return l=s,e=Dr(),e===null&&(e=Nr(),e===null&&(e=Ur(),e===null&&(e=Pr(),e===null&&(e=xr(),e===null&&(e=Mr(),e===null&&(e=kr(),e===null&&(e=Lr(),e===null&&(e=Xs(),e===null&&(e=P()))))))))),e!==null&&(e=function(u){return w.method=o.substring(s,u),w.method}(l)),e===null&&(s=l),e}function $r(){var e,l,u,f,h,m;return m=s,e=Dn(),e!==null?(l=$(),l!==null?(u=Hr(),u!==null?(f=$(),f!==null?(h=al(),h!==null?e=[e,l,u,f,h]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Hr(){var e,l;return l=s,e=Fr(),e!==null&&(e=function(u,f){w.status_code=parseInt(f.join(""))}(l,e)),e===null&&(s=l),e}function Fr(){var e,l,u,f;return f=s,e=T(),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function al(){var e,l,u;for(u=s,e=[],l=N(),l===null&&(l=F(),l===null&&(l=ve(),l===null&&(l=H(),l===null&&(l=J(),l===null&&(l=$(),l===null&&(l=L()))))));l!==null;)e.push(l),l=N(),l===null&&(l=F(),l===null&&(l=ve(),l===null&&(l=H(),l===null&&(l=J(),l===null&&(l=$(),l===null&&(l=L()))))));return e!==null&&(e=function(f){w.reason_phrase=o.substring(s,f)}(u)),e===null&&(s=u),e}function Mo(){var e,l,u,f,h,m;if(h=s,e=sn(),e!==null){for(l=[],m=s,u=le(),u!==null?(f=sn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=le(),u!==null?(f=sn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function ko(){var e,l,u,f,h,m;return f=s,h=s,e=ee(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=ee(),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=h)):(e=null,s=h),e!==null&&(e=function(v){w=o.substring(s,v)}(f)),e===null&&(s=f),e}function Nn(){var e,l,u,f,h,m,v;if(h=s,e=W(),e===null)if(m=s,e=kt(),e!==null){for(l=[],v=s,u=le(),u!==null?(f=kt(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=le(),u!==null?(f=kt(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){var O,ie;for(ie=w.multi_header.length,O=0;O<ie;O++)if(w.multi_header[O].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),e===null&&(s=h),e}function kt(){var e,l,u,f,h,m,v;if(h=s,m=s,e=we(),e===null&&(e=Lt()),e!==null){for(l=[],v=s,u=ye(),u!==null?(f=Un(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=ye(),u!==null?(f=Un(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){var O;w.multi_header||(w.multi_header=[]);try{O=new b(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{O=null}w.multi_header.push({possition:s,offset:S,parsed:O})}(h)),e===null&&(s=h),e}function Lt(){var e,l,u,f,h;return h=s,e=ws(),e=e!==null?e:"",e!==null?(l=Ce(),l!==null?(u=De(),u!==null?(f=xe(),f!==null?e=[e,l,u,f]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e}function ws(){var e,l,u,f,h,m,v;if(h=s,m=s,e=P(),e!==null){for(l=[],v=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e===null&&(e=pe()),e!==null&&(e=function(S,O){typeof O=="string"?w.display_name=O:w.display_name=O[1].reduce(function(ie,Ne){return ie+Ne[0]+Ne[1]},O[0])}(h,e)),e===null&&(s=h),e}function Un(){var e;return e=Vr(),e===null&&(e=zt(),e===null&&(e=We())),e}function Vr(){var e,l,u,f,h;return f=s,h=s,o.substr(s,1).toLowerCase()==="q"?(e=o.substr(s,1),s++):(e=null,d('"q"')),e!==null?(l=re(),l!==null?(u=Ge(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.q=v}(f,e[2])),e===null&&(s=f),e}function zt(){var e,l,u,f,h;return f=s,h=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=re(),l!==null?(u=Jt(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.expires=v}(f,e[2])),e===null&&(s=f),e}function Jt(){var e,l,u;if(u=s,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,h){return parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function Ge(){var e,l,u,f,h,m,v,S;return m=s,v=s,o.charCodeAt(s)===48?(e="0",s++):(e=null,d('"0"')),e!==null?(S=s,o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(h=T(),h=h!==null?h:"",h!==null?l=[l,u,f,h]:(l=null,s=S)):(l=null,s=S)):(l=null,s=S)):(l=null,s=S),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=v)):(e=null,s=v),e!==null&&(e=function(O){return parseFloat(o.substring(s,O))}(m)),e===null&&(s=m),e}function We(){var e,l,u,f,h,m;return f=s,h=s,e=P(),e!==null?(m=s,l=re(),l!==null?(u=ul(),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=h)):(e=null,s=h),e!==null&&(e=function(v,S,O){w.params||(w.params={}),typeof O>"u"?O=void 0:O=O[1],w.params[S.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function ul(){var e;return e=P(),e===null&&(e=ls(),e===null&&(e=Oe())),e}function cl(){var e,l,u,f,h,m;if(h=s,e=Pn(),e!==null){for(l=[],m=s,u=ye(),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=ye(),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=h)}else e=null,s=h;return e}function Pn(){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 xn(){var e;return e=fl(),e===null&&(e=We()),e}function fl(){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=re(),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 Lo(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=le(),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=le(),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=h)}else e=null,s=h;return e}function $o(){var e,l,u;if(u=s,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,h){w=parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function _l(){var e,l;return l=s,e=jr(),e!==null&&(e=function(u){w=o.substring(s,u)}(l)),e===null&&(s=l),e}function jr(){var e,l,u,f,h,m,v,S;if(v=s,e=qr(),e!==null)if(l=B(),l!==null)if(u=Mn(),u!==null){for(f=[],S=s,h=ye(),h!==null?(m=kn(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);h!==null;)f.push(h),S=s,h=ye(),h!==null?(m=kn(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);f!==null?e=[e,l,u,f]:(e=null,s=v)}else e=null,s=v;else e=null,s=v;else e=null,s=v;return e}function qr(){var e;return e=Br(),e===null&&(e=Zs()),e}function Br(){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=en()))))),e}function Zs(){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=en())),e}function en(){var e;return e=P(),e===null&&(e=Gr()),e}function Gr(){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 Mn(){var e;return e=en(),e===null&&(e=P()),e}function kn(){var e,l,u,f;return f=s,e=P(),e!==null?(l=re(),l!==null?(u=hl(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function hl(){var e;return e=P(),e===null&&(e=Oe()),e}function dl(){var e,l,u,f;return f=s,e=pl(),e!==null?(l=M(),l!==null?(u=Qs(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function pl(){var e,l,u;if(u=s,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,h){w.value=parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function Ho(){var e,l;return l=s,e=Jt(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(s=l),e}function tn(){var e,l,u,f,h,m,v;if(h=s,m=s,e=sn(),e!==null){for(l=[],v=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S,O){w.event=O.join("").toLowerCase()}(h,e[0])),e===null&&(s=h),e}function sn(){var e,l,u,f,h,m;if(h=s,e=se(),e!==null){for(l=[],m=s,o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?(f=se(),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=se(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Wr(){var e,l,u,f,h,m,v;if(h=s,m=s,e=we(),e===null&&(e=Lt()),e!==null){for(l=[],v=s,u=ye(),u!==null?(f=nn(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=ye(),u!==null?(f=nn(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){var O=w.tag;try{w=new b(w.uri,w.display_name,w.params),O&&w.setParam("tag",O)}catch{w=-1}}()),e===null&&(s=h),e}function nn(){var e;return e=Kr(),e===null&&(e=We()),e}function Kr(){var e,l,u,f,h;return f=s,h=s,o.substr(s,3).toLowerCase()==="tag"?(e=o.substr(s,3),s+=3):(e=null,d('"tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.tag=v}(f,e[2])),e===null&&(s=f),e}function Fo(){var e,l,u;if(u=s,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,h){w=parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function Vo(){var e,l;return l=s,e=Jt(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(s=l),e}function jo(){var e,l,u,f,h,m,v,S,O,ie;for(S=s,O=s,e=[],l=ws();l!==null;)e.push(l),l=ws();if(e!==null)if(l=Ce(),l!==null)if(u=De(),u!==null)if(f=xe(),f!==null){for(h=[],ie=s,m=ye(),m!==null?(v=We(),v!==null?m=[m,v]:(m=null,s=ie)):(m=null,s=ie);m!==null;)h.push(m),ie=s,m=ye(),m!==null?(v=We(),v!==null?m=[m,v]:(m=null,s=ie)):(m=null,s=ie);h!==null?e=[e,l,u,f,h]:(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(Ne){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(s=S),e}function Yr(){var e;return e=Ln(),e}function Ln(){var e,l,u,f,h,m,v,S;if(v=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=rn(),u!==null){for(f=[],S=s,h=le(),h!==null?(m=rn(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);h!==null;)f.push(h),S=s,h=le(),h!==null?(m=rn(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);f!==null?e=[e,l,u,f]:(e=null,s=v)}else e=null,s=v;else e=null,s=v;else e=null,s=v;return e===null&&(e=Os()),e}function Os(){var e,l,u,f,h,m,v,S;if(v=s,e=P(),e!==null)if(l=M(),l!==null)if(u=Xt(),u!==null){for(f=[],S=s,h=le(),h!==null?(m=Xt(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);h!==null;)f.push(h),S=s,h=le(),h!==null?(m=Xt(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);f!==null?e=[e,l,u,f]:(e=null,s=v)}else e=null,s=v;else e=null,s=v;else e=null,s=v;return e}function Xt(){var e,l,u,f;return f=s,e=P(),e!==null?(l=re(),l!==null?(u=P(),u===null&&(u=Oe()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function rn(){var e;return e=zr(),e===null&&(e=ln(),e===null&&(e=Xr(),e===null&&(e=Zr(),e===null&&(e=ei(),e===null&&(e=ti(),e===null&&(e=an(),e===null&&(e=Xt()))))))),e}function zr(){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=re(),l!==null?(u=Jr(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Jr(){var e,l;return l=s,e=pe(),e!==null&&(e=function(u,f){w.realm=f}(l,e)),e===null&&(s=l),e}function ln(){var e,l,u,f,h,m,v,S,O;if(S=s,o.substr(s,6).toLowerCase()==="domain"?(e=o.substr(s,6),s+=6):(e=null,d('"domain"')),e!==null)if(l=re(),l!==null)if(u=it(),u!==null)if(f=on(),f!==null){if(h=[],O=s,v=$(),v!==null)for(m=[];v!==null;)m.push(v),v=$();else m=null;for(m!==null?(v=on(),v!==null?m=[m,v]:(m=null,s=O)):(m=null,s=O);m!==null;){if(h.push(m),O=s,v=$(),v!==null)for(m=[];v!==null;)m.push(v),v=$();else m=null;m!==null?(v=on(),v!==null?m=[m,v]:(m=null,s=O)):(m=null,s=O)}h!==null?(m=Ee(),m!==null?e=[e,l,u,f,h,m]:(e=null,s=S)):(e=null,s=S)}else e=null,s=S;else e=null,s=S;else e=null,s=S;else e=null,s=S;return e}function on(){var e;return e=wn(),e===null&&(e=zs()),e}function Xr(){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=re(),l!==null?(u=Qr(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Qr(){var e,l;return l=s,e=pe(),e!==null&&(e=function(u,f){w.nonce=f}(l,e)),e===null&&(s=l),e}function Zr(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6).toLowerCase()==="opaque"?(e=o.substr(s,6),s+=6):(e=null,d('"opaque"')),e!==null?(l=re(),l!==null?(u=pe(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.opaque=v}(f,e[2])),e===null&&(s=f),e}function ei(){var e,l,u,f,h;return f=s,o.substr(s,5).toLowerCase()==="stale"?(e=o.substr(s,5),s+=5):(e=null,d('"stale"')),e!==null?(l=re(),l!==null?(h=s,o.substr(s,4).toLowerCase()==="true"?(u=o.substr(s,4),s+=4):(u=null,d('"true"')),u!==null&&(u=function(m){w.stale=!0}()),u===null&&(s=h),u===null&&(h=s,o.substr(s,5).toLowerCase()==="false"?(u=o.substr(s,5),s+=5):(u=null,d('"false"')),u!==null&&(u=function(m){w.stale=!1}()),u===null&&(s=h)),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ti(){var e,l,u,f,h;return f=s,h=s,o.substr(s,9).toLowerCase()==="algorithm"?(e=o.substr(s,9),s+=9):(e=null,d('"algorithm"')),e!==null?(l=re(),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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.algorithm=v.toUpperCase()}(f,e[2])),e===null&&(s=f),e}function an(){var e,l,u,f,h,m,v,S,O,ie;if(S=s,o.substr(s,3).toLowerCase()==="qop"?(e=o.substr(s,3),s+=3):(e=null,d('"qop"')),e!==null)if(l=re(),l!==null)if(u=it(),u!==null){if(O=s,f=$n(),f!==null){for(h=[],ie=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(v=$n(),v!==null?m=[m,v]:(m=null,s=ie)):(m=null,s=ie);m!==null;)h.push(m),ie=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(v=$n(),v!==null?m=[m,v]:(m=null,s=ie)):(m=null,s=ie);h!==null?f=[f,h]:(f=null,s=O)}else f=null,s=O;f!==null?(h=Ee(),h!==null?e=[e,l,u,f,h]:(e=null,s=S)):(e=null,s=S)}else e=null,s=S;else e=null,s=S;else e=null,s=S;return e}function $n(){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){w.qop||(w.qop=[]),w.qop.push(f.toLowerCase())}(l,e)),e===null&&(s=l),e}function qo(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=le(),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=le(),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=h)}else e=null,s=h;return e}function Hn(){var e,l,u,f,h,m,v;if(h=s,m=s,e=Fn(),e!==null){for(l=[],v=s,u=le(),u!==null?(f=Fn(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=le(),u!==null?(f=Fn(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){var O,ie;for(ie=w.multi_header.length,O=0;O<ie;O++)if(w.multi_header[O].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),e===null&&(s=h),e}function Fn(){var e,l,u,f,h,m,v;if(h=s,m=s,e=Lt(),e!==null){for(l=[],v=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){var O;w.multi_header||(w.multi_header=[]);try{O=new b(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{O=null}w.multi_header.push({possition:s,offset:S,parsed:O})}(h)),e===null&&(s=h),e}function si(){var e,l,u,f,h,m,v;if(h=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=[],v=s,u=ye(),u!==null?(f=Vn(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=ye(),u!==null?(f=Vn(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S,O){if(w.protocol=O.toLowerCase(),w.params||(w.params={}),w.params.text&&w.params.text[0]==='"'){var ie=w.params.text;w.text=ie.substring(1,ie.length-1),delete w.params.text}}(h,e[0])),e===null&&(s=h),e}function Vn(){var e;return e=ml(),e===null&&(e=We()),e}function ml(){var e,l,u,f,h,m;if(h=s,m=s,o.substr(s,5).toLowerCase()==="cause"?(e=o.substr(s,5),s+=5):(e=null,d('"cause"')),e!==null)if(l=re(),l!==null){if(f=T(),f!==null)for(u=[];f!==null;)u.push(f),f=T();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(v,S){w.cause=parseInt(S.join(""))}(h,e[2])),e===null&&(s=h),e}function Bo(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=le(),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=le(),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=h)}else e=null,s=h;return e}function jn(){var e,l,u,f,h,m;if(h=s,e=qn(),e!==null){for(l=[],m=s,u=le(),u!==null?(f=qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=le(),u!==null?(f=qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function qn(){var e,l,u,f,h,m;if(h=s,e=Lt(),e!==null){for(l=[],m=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function gl(){var e,l,u,f,h,m;if(h=s,e=Bn(),e!==null){for(l=[],m=s,u=ye(),u!==null?(f=Gn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ye(),u!==null?(f=Gn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Bn(){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){w.state=o.substring(s,u)}(l)),e===null&&(s=l),e}function Gn(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6).toLowerCase()==="reason"?(e=o.substr(s,6),s+=6):(e=null,d('"reason"')),e!==null?(l=re(),l!==null?(u=Tl(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){typeof v<"u"&&(w.reason=v)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,h=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=re(),l!==null?(u=Jt(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){typeof v<"u"&&(w.expires=v)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,h=s,o.substr(s,11).toLowerCase()==="retry_after"?(e=o.substr(s,11),s+=11):(e=null,d('"retry_after"')),e!==null?(l=re(),l!==null?(u=Jt(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){typeof v<"u"&&(w.retry_after=v)}(f,e[2])),e===null&&(s=f),e===null&&(e=We()))),e}function Tl(){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 Go(){var e;return e=j(),e=e!==null?e:"",e}function Wo(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=le(),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=le(),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=h)}else e=null,s=h;return e=e!==null?e:"",e}function ni(){var e,l,u,f,h,m,v;if(h=s,m=s,e=we(),e===null&&(e=Lt()),e!==null){for(l=[],v=s,u=ye(),u!==null?(f=ri(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=ye(),u!==null?(f=ri(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){var O=w.tag;try{w=new b(w.uri,w.display_name,w.params),O&&w.setParam("tag",O)}catch{w=-1}}()),e===null&&(s=h),e}function ri(){var e;return e=Kr(),e===null&&(e=We()),e}function Wn(){var e,l,u,f,h,m;if(h=s,e=Ds(),e!==null){for(l=[],m=s,u=le(),u!==null?(f=Ds(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=le(),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=h)}else e=null,s=h;return e}function Ds(){var e,l,u,f,h,m,v,S;if(v=s,e=fi(),e!==null)if(l=M(),l!==null)if(u=di(),u!==null){for(f=[],S=s,h=ye(),h!==null?(m=Kn(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);h!==null;)f.push(h),S=s,h=ye(),h!==null?(m=Kn(),m!==null?h=[h,m]:(h=null,s=S)):(h=null,s=S);f!==null?e=[e,l,u,f]:(e=null,s=v)}else e=null,s=v;else e=null,s=v;else e=null,s=v;return e}function Kn(){var e;return e=ii(),e===null&&(e=li(),e===null&&(e=oi(),e===null&&(e=ai(),e===null&&(e=ui(),e===null&&(e=We()))))),e}function ii(){var e,l,u,f,h;return f=s,h=s,o.substr(s,3).toLowerCase()==="ttl"?(e=o.substr(s,3),s+=3):(e=null,d('"ttl"')),e!==null?(l=re(),l!==null?(u=mi(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.ttl=v}(f,e[2])),e===null&&(s=f),e}function li(){var e,l,u,f,h;return f=s,h=s,o.substr(s,5).toLowerCase()==="maddr"?(e=o.substr(s,5),s+=5):(e=null,d('"maddr"')),e!==null?(l=re(),l!==null?(u=ls(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.maddr=v}(f,e[2])),e===null&&(s=f),e}function oi(){var e,l,u,f,h;return f=s,h=s,o.substr(s,8).toLowerCase()==="received"?(e=o.substr(s,8),s+=8):(e=null,d('"received"')),e!==null?(l=re(),l!==null?(u=Bt(),u===null&&(u=me()),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.received=v}(f,e[2])),e===null&&(s=f),e}function ai(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6).toLowerCase()==="branch"?(e=o.substr(s,6),s+=6):(e=null,d('"branch"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.branch=v}(f,e[2])),e===null&&(s=f),e}function ui(){var e,l,u,f,h;return f=s,o.substr(s,5).toLowerCase()==="rport"?(e=o.substr(s,5),s+=5):(e=null,d('"rport"')),e!==null?(h=s,l=re(),l!==null?(u=ci(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function ci(){var e,l,u,f,h,m,v;return m=s,v=s,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(h=T(),h=h!==null?h:"",h!==null?e=[e,l,u,f,h]:(e=null,s=v)):(e=null,s=v)):(e=null,s=v)):(e=null,s=v)):(e=null,s=v),e!==null&&(e=function(S,O){w.rport=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function fi(){var e,l,u,f,h,m;return m=s,e=_i(),e!==null?(l=B(),l!==null?(u=P(),u!==null?(f=B(),f!==null?(h=hi(),h!==null?e=[e,l,u,f,h]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function _i(){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){w.protocol=f}(l,e)),e===null&&(s=l),e}function hi(){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){w.transport=f}(l,e)),e===null&&(s=l),e}function di(){var e,l,u,f,h;return f=s,e=pi(),e!==null?(h=s,l=tt(),l!==null?(u=Yn(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function pi(){var e,l;return l=s,e=Bt(),e===null&&(e=Bs(),e===null&&(e=qs())),e!==null&&(e=function(u){w.host=o.substring(s,u)}(l)),e===null&&(s=l),e}function Yn(){var e,l,u,f,h,m,v;return m=s,v=s,e=T(),e=e!==null?e:"",e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(h=T(),h=h!==null?h:"",h!==null?e=[e,l,u,f,h]:(e=null,s=v)):(e=null,s=v)):(e=null,s=v)):(e=null,s=v)):(e=null,s=v),e!==null&&(e=function(S,O){w.port=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function mi(){var e,l,u,f,h;return f=s,h=s,e=T(),e!==null?(l=T(),l=l!==null?l:"",l!==null?(u=T(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){return parseInt(v.join(""))}(f,e)),e===null&&(s=f),e}function Ko(){var e;return e=Ln(),e}function vl(){var e,l,u,f,h,m;if(h=s,e=zn(),e!==null){for(l=[],m=s,u=ye(),u!==null?(f=Jn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ye(),u!==null?(f=Jn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function zn(){var e,l;return l=s,e=Jt(),e!==null&&(e=function(u,f){w.expires=f}(l,e)),e===null&&(s=l),e}function Jn(){var e;return e=El(),e===null&&(e=We()),e}function El(){var e,l,u,f,h;return f=s,h=s,o.substr(s,9).toLowerCase()==="refresher"?(e=o.substr(s,9),s+=9):(e=null,d('"refresher"')),e!==null?(l=re(),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=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.refresher=v.toLowerCase()}(f,e[2])),e===null&&(s=f),e}function Sl(){var e,l,u,f;return f=s,e=P(),e!==null?(l=q(),l!==null?(u=yl(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function yl(){var e,l;for(e=[],l=z(),l===null&&(l=J(),l===null&&(l=M()));l!==null;)e.push(l),l=z(),l===null&&(l=J(),l===null&&(l=M()));return e}function Yo(){var e,l;for(e=[],l=R();l!==null;)e.push(l),l=R();return e}function Al(){var e,l,u;return u=s,o.substr(s,5)==="uuid:"?(e="uuid:",s+=5):(e=null,d('"uuid:"')),e!==null?(l=$t(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function $t(){var e,l,u,f,h,m,v,S,O,ie,Ne;return ie=s,Ne=s,e=gi(),e!==null?(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l!==null?(u=Ht(),u!==null?(o.charCodeAt(s)===45?(f="-",s++):(f=null,d('"-"')),f!==null?(h=Ht(),h!==null?(o.charCodeAt(s)===45?(m="-",s++):(m=null,d('"-"')),m!==null?(v=Ht(),v!==null?(o.charCodeAt(s)===45?(S="-",s++):(S=null,d('"-"')),S!==null?(O=Cl(),O!==null?e=[e,l,u,f,h,m,v,S,O]:(e=null,s=Ne)):(e=null,s=Ne)):(e=null,s=Ne)):(e=null,s=Ne)):(e=null,s=Ne)):(e=null,s=Ne)):(e=null,s=Ne)):(e=null,s=Ne)):(e=null,s=Ne),e!==null&&(e=function(Rt,Ns){w=o.substring(s+5,Rt)}(ie,e[0])),e===null&&(s=ie),e}function Ht(){var e,l,u,f,h;return h=s,e=y(),e!==null?(l=y(),l!==null?(u=y(),u!==null?(f=y(),f!==null?e=[e,l,u,f]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e}function gi(){var e,l,u;return u=s,e=Ht(),e!==null?(l=Ht(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Cl(){var e,l,u,f;return f=s,e=Ht(),e!==null?(l=Ht(),l!==null?(u=Ht(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function zo(){var e,l,u,f,h,m,v;if(h=s,m=s,e=we(),e===null&&(e=Lt()),e!==null){for(l=[],v=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);u!==null;)l.push(u),v=s,u=ye(),u!==null?(f=We(),f!==null?u=[u,f]:(u=null,s=v)):(u=null,s=v);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(S){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(s=h),e}function Rl(){var e,l,u,f,h,m;if(h=s,e=Xn(),e!==null){for(l=[],m=s,u=ye(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ye(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Xn(){var e,l,u,f,h,m;return f=s,h=s,e=ee(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=ee(),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=h)):(e=null,s=h),e!==null&&(e=function(v){w.call_id=o.substring(s,v)}(f)),e===null&&(s=f),e}function Qn(){var e;return e=Ti(),e===null&&(e=vi(),e===null&&(e=Il(),e===null&&(e=We()))),e}function Ti(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6)==="to-tag"?(e="to-tag",s+=6):(e=null,d('"to-tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.to_tag=v}(f,e[2])),e===null&&(s=f),e}function vi(){var e,l,u,f,h;return f=s,h=s,o.substr(s,8)==="from-tag"?(e="from-tag",s+=8):(e=null,d('"from-tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,v){w.from_tag=v}(f,e[2])),e===null&&(s=f),e}function Il(){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){w.early_only=!0}()),e===null&&(s=l),e}function Jo(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 bl(){for(var e=1,l=1,u=!1,f=0;f<Math.max(s,p);f++){var h=o.charAt(f);h===`
|
4
|
+
`?(u||e++,l=1,u=!1):h==="\r"||h==="\u2028"||h==="\u2029"?(e++,l=1,u=!0):(l++,u=!1)}return{line:e,column:l}}var as=Vs(),b=du(),w={},Ei=t[a]();if(Ei===null||s!==o.length){var Si=Math.max(s,p),wl=Si<o.length?o.charAt(Si):null,i=bl();return new this.SyntaxError(Jo(_),wl,Si,i.line,i.column),-1}return w},toSource:function(){return this._source}};return n.SyntaxError=function(r,o,a,t,s){function p(_,d){var g,T;switch(_.length){case 0:g="end of input";break;case 1:g=_[0];break;default:g=_.slice(0,_.length-1).join(", ")+" or "+_[_.length-1]}return T=d?c(d):"end of input","Expected "+g+" but "+T+" found."}this.name="SyntaxError",this.expected=r,this.found=o,this.message=p(r,o),this.offset=a,this.line=t,this.column=s},n.SyntaxError.prototype=Error.prototype,n}()),Qo}var Zo,xu;function Vs(){if(xu)return Zo;xu=1;function c(d,g){var T;if(typeof Symbol>"u"||d[Symbol.iterator]==null){if(Array.isArray(d)||(T=n(d))||g&&d&&typeof d.length=="number"){T&&(d=T);var E=0,y=function(){};return{s:y,n:function(){return E>=d.length?{done:!0}:{done:!1,value:d[E++]}},e:function(L){throw L},f:y}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var A=!0,R=!1,I;return{s:function(){T=d[Symbol.iterator]()},n:function(){var L=T.next();return A=L.done,L},e:function(L){R=!0,I=L},f:function(){try{!A&&T.return!=null&&T.return()}finally{if(R)throw I}}}}function n(d,g){if(d){if(typeof d=="string")return r(d,g);var T=Object.prototype.toString.call(d).slice(8,-1);if(T==="Object"&&d.constructor&&(T=d.constructor.name),T==="Map"||T==="Set")return Array.from(d);if(T==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(T))return r(d,g)}}function r(d,g){(g==null||g>d.length)&&(g=d.length);for(var T=0,E=new Array(g);T<g;T++)E[T]=d[T];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 T=0;T<g.length;T++){var E=g[T];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(d,E.key,E)}}function t(d,g,T){return g&&a(d.prototype,g),T&&a(d,T),d}var s=rt,p=Ct(),_=rs();return Zo=function(){t(d,null,[{key:"parse",value:function(T){if(T=_.parse(T,"SIP_URI"),T!==-1)return T}}]);function d(g,T,E,y){var A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},R=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=T,this._host=E,this._port=y;for(var I in A)Object.prototype.hasOwnProperty.call(A,I)&&this.setParam(I,A[I]);for(var $ in R)Object.prototype.hasOwnProperty.call(R,$)&&this.setHeader($,R[$])}return t(d,[{key:"setParam",value:function(T,E){T&&(this._parameters[T.toLowerCase()]=typeof E>"u"||E===null?null:E.toString())}},{key:"getParam",value:function(T){if(T)return this._parameters[T.toLowerCase()]}},{key:"hasParam",value:function(T){if(T)return this._parameters.hasOwnProperty(T.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(T){if(T=T.toLowerCase(),this._parameters.hasOwnProperty(T)){var E=this._parameters[T];return delete this._parameters[T],E}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(T,E){this._headers[p.headerize(T)]=Array.isArray(E)?E:[E]}},{key:"getHeader",value:function(T){if(T)return this._headers[p.headerize(T)]}},{key:"hasHeader",value:function(T){if(T)return this._headers.hasOwnProperty(p.headerize(T))&&!0||!1}},{key:"deleteHeader",value:function(T){if(T=p.headerize(T),this._headers.hasOwnProperty(T)){var E=this._headers[T];return delete this._headers[T],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 T=[],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 y in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,y)&&(E+=";".concat(y),this._parameters[y]!==null&&(E+="=".concat(this._parameters[y])));for(var A in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,A)){var R=c(this._headers[A]),I;try{for(R.s();!(I=R.n()).done;){var $=I.value;T.push("".concat(A,"=").concat($))}}catch(L){R.e(L)}finally{R.f()}}return T.length>0&&(E+="?".concat(T.join("&"))),E}},{key:"toAor",value:function(T){var E="".concat(this._scheme,":");return this._user&&(E+="".concat(p.escapeUser(this._user),"@")),E+=this._host,T&&(this._port||this._port===0)&&(E+=":".concat(this._port)),E}},{key:"scheme",get:function(){return this._scheme},set:function(T){this._scheme=T.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(T){this._user=T}},{key:"host",get:function(){return this._host},set:function(T){this._host=T.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(T){this._port=T===0?T:parseInt(T,10)||null}}]),d}(),Zo}var Mu;function Ct(){if(Mu)return Qe;Mu=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 n(g,T){var E;if(typeof Symbol>"u"||g[Symbol.iterator]==null){if(Array.isArray(g)||(E=r(g))||T&&g&&typeof g.length=="number"){E&&(g=E);var y=0,A=function(){};return{s:A,n:function(){return y>=g.length?{done:!0}:{done:!1,value:g[y++]}},e:function(ae){throw ae},f:A}}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 R=!0,I=!1,$;return{s:function(){E=g[Symbol.iterator]()},n:function(){var ae=E.next();return R=ae.done,ae},e:function(ae){I=!0,$=ae},f:function(){try{!R&&E.return!=null&&E.return()}finally{if(I)throw $}}}}function r(g,T){if(g){if(typeof g=="string")return o(g,T);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,T)}}function o(g,T){(T==null||T>g.length)&&(T=g.length);for(var E=0,y=new Array(T);E<T;E++)y[E]=g[E];return y}var a=rt,t=Vs(),s=rs();Qe.str_utf8_length=function(g){return unescape(encodeURIComponent(g)).length};var p=Qe.isFunction=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object Function]":!1};Qe.isString=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object String]":!1},Qe.isDecimal=function(g){return!isNaN(g)&&parseFloat(g)===parseInt(g,10)},Qe.isEmpty=function(g){return g===null||g===""||g===void 0||Array.isArray(g)&&g.length===0||typeof g=="number"&&isNaN(g)},Qe.hasMethods=function(g){for(var T=arguments.length,E=new Array(T>1?T-1:0),y=1;y<T;y++)E[y-1]=arguments[y];for(var A=0,R=E;A<R.length;A++){var I=R[A];if(p(g[I]))return!1}return!0};var _=Qe.createRandomToken=function(g){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,E,y,A="";for(E=0;E<g;E++)y=Math.random()*T|0,A+=y.toString(T);return A};Qe.newTag=function(){return _(10)},Qe.newUUID=function(){var g="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(T){var E=Math.random()*16|0,y=T==="x"?E:E&3|8;return y.toString(16)});return g},Qe.hostType=function(g){if(g){if(g=s.parse(g,"host"),g!==-1)return g.host_type}else return};var d=Qe.escapeUser=function(g){return encodeURIComponent(decodeURIComponent(g)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return Qe.normalizeTarget=function(g,T){if(g){if(g instanceof t)return g;if(typeof g=="string"){var E=g.split("@"),y,A;switch(E.length){case 1:if(!T)return;y=g,A=T;break;case 2:y=E[0],A=E[1];break;default:y=E.slice(0,E.length-1).join("@"),A=E[E.length-1]}y=y.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(y)&&(y=y.replace(/[-.()]/g,"")),g="".concat(a.SIP,":").concat(d(y),"@").concat(A);var R;return(R=t.parse(g))?R:void 0}else return}else return},Qe.headerize=function(g){var T={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},E=g.toLowerCase().replace(/_/g,"-").split("-"),y="",A=E.length,R;for(R=0;R<A;R++)R!==0&&(y+="-"),y+=E[R].charAt(0).toUpperCase()+E[R].substring(1);return T[y]&&(y=T[y]),y},Qe.sipErrorCause=function(g){for(var T in a.SIP_ERROR_CAUSES)if(a.SIP_ERROR_CAUSES[T].indexOf(g)!==-1)return a.causes[T];return a.causes.SIP_FAILURE_CODE},Qe.getRandomTestNetIP=function(){function g(T,E){return Math.floor(Math.random()*(E-T+1)+T)}return"192.0.2.".concat(g(1,254))},Qe.calculateMD5=function(g){function T(pe,ue){return pe<<ue|pe>>>32-ue}function E(pe,ue){var de=pe&2147483648,we=ue&2147483648,De=pe&1073741824,Xe=ue&1073741824,Le=(pe&1073741823)+(ue&1073741823);return De&Xe?Le^2147483648^de^we:De|Xe?Le&1073741824?Le^3221225472^de^we:Le^1073741824^de^we:Le^de^we}function y(pe,ue,de){return pe&ue|~pe&de}function A(pe,ue,de){return pe&de|ue&~de}function R(pe,ue,de){return pe^ue^de}function I(pe,ue,de){return ue^(pe|~de)}function $(pe,ue,de,we,De,Xe,Le){return pe=E(pe,E(E(y(ue,de,we),De),Le)),E(T(pe,Xe),ue)}function L(pe,ue,de,we,De,Xe,Le){return pe=E(pe,E(E(A(ue,de,we),De),Le)),E(T(pe,Xe),ue)}function ae(pe,ue,de,we,De,Xe,Le){return pe=E(pe,E(E(R(ue,de,we),De),Le)),E(T(pe,Xe),ue)}function N(pe,ue,de,we,De,Xe,Le){return pe=E(pe,E(E(I(ue,de,we),De),Le)),E(T(pe,Xe),ue)}function F(pe){for(var ue,de=pe.length,we=de+8,De=(we-we%64)/64,Xe=(De+1)*16,Le=new Array(Xe-1),Mt=0,_t=0;_t<de;)ue=(_t-_t%4)/4,Mt=_t%4*8,Le[ue]=Le[ue]|pe.charCodeAt(_t)<<Mt,_t++;return ue=(_t-_t%4)/4,Mt=_t%4*8,Le[ue]=Le[ue]|128<<Mt,Le[Xe-2]=de<<3,Le[Xe-1]=de>>>29,Le}function Se(pe){var ue="",de="",we,De;for(De=0;De<=3;De++)we=pe>>>De*8&255,de="0".concat(we.toString(16)),ue=ue+de.substr(de.length-2,2);return ue}function ve(pe){for(var ue="",de=0;de<pe.length;de++){var we=pe.charCodeAt(de);we<128?ue+=String.fromCharCode(we):we>127&&we<2048?(ue+=String.fromCharCode(we>>6|192),ue+=String.fromCharCode(we&63|128)):(ue+=String.fromCharCode(we>>12|224),ue+=String.fromCharCode(we>>6&63|128),ue+=String.fromCharCode(we&63|128))}return ue}var M=[],D,q,j,z,H,J,U,P,se,et=7,ee=12,W=17,B=22,re=5,ge=9,be=14,xe=20,Ce=4,le=11,ye=16,tt=23,it=6,Ee=10,Ae=15,Ie=21;for(g=ve(g),M=F(g),J=1732584193,U=4023233417,P=2562383102,se=271733878,D=0;D<M.length;D+=16)q=J,j=U,z=P,H=se,J=$(J,U,P,se,M[D+0],et,3614090360),se=$(se,J,U,P,M[D+1],ee,3905402710),P=$(P,se,J,U,M[D+2],W,606105819),U=$(U,P,se,J,M[D+3],B,3250441966),J=$(J,U,P,se,M[D+4],et,4118548399),se=$(se,J,U,P,M[D+5],ee,1200080426),P=$(P,se,J,U,M[D+6],W,2821735955),U=$(U,P,se,J,M[D+7],B,4249261313),J=$(J,U,P,se,M[D+8],et,1770035416),se=$(se,J,U,P,M[D+9],ee,2336552879),P=$(P,se,J,U,M[D+10],W,4294925233),U=$(U,P,se,J,M[D+11],B,2304563134),J=$(J,U,P,se,M[D+12],et,1804603682),se=$(se,J,U,P,M[D+13],ee,4254626195),P=$(P,se,J,U,M[D+14],W,2792965006),U=$(U,P,se,J,M[D+15],B,1236535329),J=L(J,U,P,se,M[D+1],re,4129170786),se=L(se,J,U,P,M[D+6],ge,3225465664),P=L(P,se,J,U,M[D+11],be,643717713),U=L(U,P,se,J,M[D+0],xe,3921069994),J=L(J,U,P,se,M[D+5],re,3593408605),se=L(se,J,U,P,M[D+10],ge,38016083),P=L(P,se,J,U,M[D+15],be,3634488961),U=L(U,P,se,J,M[D+4],xe,3889429448),J=L(J,U,P,se,M[D+9],re,568446438),se=L(se,J,U,P,M[D+14],ge,3275163606),P=L(P,se,J,U,M[D+3],be,4107603335),U=L(U,P,se,J,M[D+8],xe,1163531501),J=L(J,U,P,se,M[D+13],re,2850285829),se=L(se,J,U,P,M[D+2],ge,4243563512),P=L(P,se,J,U,M[D+7],be,1735328473),U=L(U,P,se,J,M[D+12],xe,2368359562),J=ae(J,U,P,se,M[D+5],Ce,4294588738),se=ae(se,J,U,P,M[D+8],le,2272392833),P=ae(P,se,J,U,M[D+11],ye,1839030562),U=ae(U,P,se,J,M[D+14],tt,4259657740),J=ae(J,U,P,se,M[D+1],Ce,2763975236),se=ae(se,J,U,P,M[D+4],le,1272893353),P=ae(P,se,J,U,M[D+7],ye,4139469664),U=ae(U,P,se,J,M[D+10],tt,3200236656),J=ae(J,U,P,se,M[D+13],Ce,681279174),se=ae(se,J,U,P,M[D+0],le,3936430074),P=ae(P,se,J,U,M[D+3],ye,3572445317),U=ae(U,P,se,J,M[D+6],tt,76029189),J=ae(J,U,P,se,M[D+9],Ce,3654602809),se=ae(se,J,U,P,M[D+12],le,3873151461),P=ae(P,se,J,U,M[D+15],ye,530742520),U=ae(U,P,se,J,M[D+2],tt,3299628645),J=N(J,U,P,se,M[D+0],it,4096336452),se=N(se,J,U,P,M[D+7],Ee,1126891415),P=N(P,se,J,U,M[D+14],Ae,2878612391),U=N(U,P,se,J,M[D+5],Ie,4237533241),J=N(J,U,P,se,M[D+12],it,1700485571),se=N(se,J,U,P,M[D+3],Ee,2399980690),P=N(P,se,J,U,M[D+10],Ae,4293915773),U=N(U,P,se,J,M[D+1],Ie,2240044497),J=N(J,U,P,se,M[D+8],it,1873313359),se=N(se,J,U,P,M[D+15],Ee,4264355552),P=N(P,se,J,U,M[D+6],Ae,2734768916),U=N(U,P,se,J,M[D+13],Ie,1309151649),J=N(J,U,P,se,M[D+4],it,4149444226),se=N(se,J,U,P,M[D+11],Ee,3174756917),P=N(P,se,J,U,M[D+2],Ae,718787259),U=N(U,P,se,J,M[D+9],Ie,3951481745),J=E(J,q),U=E(U,j),P=E(P,z),se=E(se,H);var Oe=Se(J)+Se(U)+Se(P)+Se(se);return Oe.toLowerCase()},Qe.closeMediaStream=function(g){if(g)try{var T;if(g.getTracks){T=g.getTracks();var E=n(T),y;try{for(E.s();!(y=E.n()).done;){var A=y.value;A.stop()}}catch(F){E.e(F)}finally{E.f()}}else{T=g.getAudioTracks();var R=n(T),I;try{for(R.s();!(I=R.n()).done;){var $=I.value;$.stop()}}catch(F){R.e(F)}finally{R.f()}T=g.getVideoTracks();var L=n(T),ae;try{for(L.s();!(ae=L.n()).done;){var N=ae.value;N.stop()}}catch(F){L.e(F)}finally{L.f()}}}catch{(typeof g.stop=="function"||c(g.stop)==="object")&&g.stop()}},Qe.cloneArray=function(g){return g&&g.slice()||[]},Qe.cloneObject=function(g){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g&&Object.assign({},g)||T},Qe}var pu={exports:{}},or=typeof Reflect=="object"?Reflect:null,ku=or&&typeof or.apply=="function"?or.apply:function(n,r,o){return Function.prototype.apply.call(n,r,o)},ro;or&&typeof or.ownKeys=="function"?ro=or.ownKeys:Object.getOwnPropertySymbols?ro=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:ro=function(n){return Object.getOwnPropertyNames(n)};function B_(c){console&&console.warn&&console.warn(c)}var Of=Number.isNaN||function(n){return n!==n};function ke(){ke.init.call(this)}pu.exports=ke;pu.exports.once=Y_;ke.EventEmitter=ke;ke.prototype._events=void 0;ke.prototype._eventsCount=0;ke.prototype._maxListeners=void 0;var Lu=10;function No(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(ke,"defaultMaxListeners",{enumerable:!0,get:function(){return Lu},set:function(c){if(typeof c!="number"||c<0||Of(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Lu=c}});ke.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};ke.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||Of(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Df(c){return c._maxListeners===void 0?ke.defaultMaxListeners:c._maxListeners}ke.prototype.getMaxListeners=function(){return Df(this)};ke.prototype.emit=function(n){for(var r=[],o=1;o<arguments.length;o++)r.push(arguments[o]);var a=n==="error",t=this._events;if(t!==void 0)a=a&&t.error===void 0;else if(!a)return!1;if(a){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var p=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw p.context=s,p}var _=t[n];if(_===void 0)return!1;if(typeof _=="function")ku(_,this,r);else for(var d=_.length,g=Mf(_,d),o=0;o<d;++o)ku(g[o],this,r);return!0};function Nf(c,n,r,o){var a,t,s;if(No(r),t=c._events,t===void 0?(t=c._events=Object.create(null),c._eventsCount=0):(t.newListener!==void 0&&(c.emit("newListener",n,r.listener?r.listener:r),t=c._events),s=t[n]),s===void 0)s=t[n]=r,++c._eventsCount;else if(typeof s=="function"?s=t[n]=o?[r,s]:[s,r]:o?s.unshift(r):s.push(r),a=Df(c),a>0&&s.length>a&&!s.warned){s.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=c,p.type=n,p.count=s.length,B_(p)}return c}ke.prototype.addListener=function(n,r){return Nf(this,n,r,!1)};ke.prototype.on=ke.prototype.addListener;ke.prototype.prependListener=function(n,r){return Nf(this,n,r,!0)};function G_(){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 Uf(c,n,r){var o={fired:!1,wrapFn:void 0,target:c,type:n,listener:r},a=G_.bind(o);return a.listener=r,o.wrapFn=a,a}ke.prototype.once=function(n,r){return No(r),this.on(n,Uf(this,n,r)),this};ke.prototype.prependOnceListener=function(n,r){return No(r),this.prependListener(n,Uf(this,n,r)),this};ke.prototype.removeListener=function(n,r){var o,a,t,s,p;if(No(r),a=this._events,a===void 0)return this;if(o=a[n],o===void 0)return this;if(o===r||o.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete a[n],a.removeListener&&this.emit("removeListener",n,o.listener||r));else if(typeof o!="function"){for(t=-1,s=o.length-1;s>=0;s--)if(o[s]===r||o[s].listener===r){p=o[s].listener,t=s;break}if(t<0)return this;t===0?o.shift():W_(o,t),o.length===1&&(a[n]=o[0]),a.removeListener!==void 0&&this.emit("removeListener",n,p||r)}return this};ke.prototype.off=ke.prototype.removeListener;ke.prototype.removeAllListeners=function(n){var r,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[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[n]),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(r=o[n],typeof r=="function")this.removeListener(n,r);else if(r!==void 0)for(a=r.length-1;a>=0;a--)this.removeListener(n,r[a]);return this};function Pf(c,n,r){var o=c._events;if(o===void 0)return[];var a=o[n];return a===void 0?[]:typeof a=="function"?r?[a.listener||a]:[a]:r?K_(a):Mf(a,a.length)}ke.prototype.listeners=function(n){return Pf(this,n,!0)};ke.prototype.rawListeners=function(n){return Pf(this,n,!1)};ke.listenerCount=function(c,n){return typeof c.listenerCount=="function"?c.listenerCount(n):xf.call(c,n)};ke.prototype.listenerCount=xf;function xf(c){var n=this._events;if(n!==void 0){var r=n[c];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ke.prototype.eventNames=function(){return this._eventsCount>0?ro(this._events):[]};function Mf(c,n){for(var r=new Array(n),o=0;o<n;++o)r[o]=c[o];return r}function W_(c,n){for(;n+1<c.length;n++)c[n]=c[n+1];c.pop()}function K_(c){for(var n=new Array(c.length),r=0;r<n.length;++r)n[r]=c[r].listener||c[r];return n}function Y_(c,n){return new Promise(function(r,o){function a(s){c.removeListener(n,t),o(s)}function t(){typeof c.removeListener=="function"&&c.removeListener("error",a),r([].slice.call(arguments))}kf(c,n,t,{once:!0}),n!=="error"&&z_(c,a,{once:!0})})}function z_(c,n,r){typeof c.on=="function"&&kf(c,"error",n,r)}function kf(c,n,r,o){if(typeof c.on=="function")o.once?c.once(n,r):c.on(n,r);else if(typeof c.addEventListener=="function")c.addEventListener(n,function a(t){o.once&&c.removeEventListener(n,a),r(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ct=pu.exports,za={exports:{}},ea,$u;function J_(){if($u)return ea;$u=1;var c=1e3,n=c*60,r=n*60,o=r*24,a=o*7,t=o*365.25;ea=function(g,T){T=T||{};var E=typeof g;if(E==="string"&&g.length>0)return s(g);if(E==="number"&&isFinite(g))return T.long?_(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 T=/^(-?(?:\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(T){var E=parseFloat(T[1]),y=(T[2]||"ms").toLowerCase();switch(y){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*r;case"minutes":case"minute":case"mins":case"min":case"m":return E*n;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 T=Math.abs(g);return T>=o?Math.round(g/o)+"d":T>=r?Math.round(g/r)+"h":T>=n?Math.round(g/n)+"m":T>=c?Math.round(g/c)+"s":g+"ms"}function _(g){var T=Math.abs(g);return T>=o?d(g,T,o,"day"):T>=r?d(g,T,r,"hour"):T>=n?d(g,T,n,"minute"):T>=c?d(g,T,c,"second"):g+" ms"}function d(g,T,E,y){var A=T>=E*1.5;return Math.round(g/E)+" "+y+(A?"s":"")}return ea}function X_(c){r.debug=r,r.default=r,r.coerce=_,r.disable=t,r.enable=a,r.enabled=s,r.humanize=J_(),r.destroy=d,Object.keys(c).forEach(g=>{r[g]=c[g]}),r.names=[],r.skips=[],r.formatters={};function n(g){let T=0;for(let E=0;E<g.length;E++)T=(T<<5)-T+g.charCodeAt(E),T|=0;return r.colors[Math.abs(T)%r.colors.length]}r.selectColor=n;function r(g){let T,E=null,y,A;function R(...I){if(!R.enabled)return;const $=R,L=Number(new Date),ae=L-(T||L);$.diff=ae,$.prev=T,$.curr=L,T=L,I[0]=r.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let N=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(Se,ve)=>{if(Se==="%%")return"%";N++;const M=r.formatters[ve];if(typeof M=="function"){const D=I[N];Se=M.call($,D),I.splice(N,1),N--}return Se}),r.formatArgs.call($,I),($.log||r.log).apply($,I)}return R.namespace=g,R.useColors=r.useColors(),R.color=r.selectColor(g),R.extend=o,R.destroy=r.destroy,Object.defineProperty(R,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(y!==r.namespaces&&(y=r.namespaces,A=r.enabled(g)),A),set:I=>{E=I}}),typeof r.init=="function"&&r.init(R),R}function o(g,T){const E=r(this.namespace+(typeof T>"u"?":":T)+g);return E.log=this.log,E}function a(g){r.save(g),r.namespaces=g,r.names=[],r.skips=[];let T;const E=(typeof g=="string"?g:"").split(/[\s,]+/),y=E.length;for(T=0;T<y;T++)E[T]&&(g=E[T].replace(/\*/g,".*?"),g[0]==="-"?r.skips.push(new RegExp("^"+g.slice(1)+"$")):r.names.push(new RegExp("^"+g+"$")))}function t(){const g=[...r.names.map(p),...r.skips.map(p).map(T=>"-"+T)].join(",");return r.enable(""),g}function s(g){if(g[g.length-1]==="*")return!0;let T,E;for(T=0,E=r.skips.length;T<E;T++)if(r.skips[T].test(g))return!1;for(T=0,E=r.names.length;T<E;T++)if(r.names[T].test(g))return!0;return!1}function p(g){return g.toString().substring(2,g.toString().length-2).replace(/\.\*\?$/,"*")}function _(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 r.enable(r.load()),r}var Q_=X_;(function(c,n){n.formatArgs=o,n.save=a,n.load=t,n.useColors=r,n.storage=s(),n.destroy=(()=>{let _=!1;return()=>{_||(_=!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`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){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(_){if(_[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+_[0]+(this.useColors?"%c ":" ")+"+"+c.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;_.splice(1,0,d,"color: inherit");let g=0,T=0;_[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(g++,E==="%c"&&(T=g))}),_.splice(T,0,d)}n.log=console.debug||console.log||(()=>{});function a(_){try{_?n.storage.setItem("debug",_):n.storage.removeItem("debug")}catch{}}function t(){let _;try{_=n.storage.getItem("debug")}catch{}return!_&&typeof process<"u"&&"env"in process&&(_=process.env.DEBUG),_}function s(){try{return localStorage}catch{}}c.exports=Q_(n);const{formatters:p}=c.exports;p.j=function(_){try{return JSON.stringify(_)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(za,za.exports);var ur=za.exports;function Z_(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Hu(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function eh(c,n,r){return n&&Hu(c.prototype,n),r&&Hu(c,r),c}var Zn=ur,er="JsSIP",ft=function(){function c(n){Z_(this,c),n?(this._debug=Zn.default("".concat(er,":").concat(n)),this._warn=Zn.default("".concat(er,":WARN:").concat(n)),this._error=Zn.default("".concat(er,":ERROR:").concat(n))):(this._debug=Zn.default(er),this._warn=Zn.default("".concat(er,":WARN")),this._error=Zn.default("".concat(er,":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}(),Nt={},Lf={},$f={exports:{}},Fu=$f.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 n="candidate:%s %d %s %d %s %d typ %s";return n+=c.raddr!=null?" raddr %s rport %d":"%v%v",n+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(n+=" generation %d"),n+=c["network-id"]!=null?" network-id %d":"%v",n+=c["network-cost"]!=null?" network-cost %d":"%v",n}},{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 n="ssrc:%d";return c.attribute!=null&&(n+=" %s",c.value!=null&&(n+=":%s")),n}},{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 n="mediaclk:";return n+=c.id!=null?"id=%s %s":"%v%s",n+=c.mediaClockValue!=null?"=%s":"",n+=c.rateNumerator!=null?" rate=%s":"",n+=c.rateDenominator!=null?"/%s":"",n}},{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(Fu).forEach(function(c){var n=Fu[c];n.forEach(function(r){r.reg||(r.reg=/(.*)/),r.format||(r.format="%s")})});var Hf=$f.exports;(function(c){var n=function(p){return String(Number(p))===p?Number(p):p},r=function(p,_,d,g){if(g&&!d)_[g]=n(p[1]);else for(var T=0;T<d.length;T+=1)p[T+1]!=null&&(_[d[T]]=n(p[T+1]))},o=function(p,_,d){var g=p.name&&p.names;p.push&&!_[p.push]?_[p.push]=[]:g&&!_[p.name]&&(_[p.name]={});var T=p.push?{}:g?_[p.name]:_;r(d.match(p.reg),T,p.names,p.name),p.push&&_[p.push].push(T)},a=Hf,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(p){var _={},d=[],g=_;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(T){var E=T[0],y=T.slice(2);E==="m"&&(d.push({rtp:[],fmtp:[]}),g=d[d.length-1]);for(var A=0;A<(a[E]||[]).length;A+=1){var R=a[E][A];if(R.reg.test(y))return o(R,g,y)}}),_.media=d,_};var s=function(p,_){var d=_.split(/=(.+)/,2);return d.length===2?p[d[0]]=n(d[1]):d.length===1&&_.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 _=[],d=p.split(" ").map(n),g=0;g<d.length;g+=3)_.push({component:d[g],ip:d[g+1],port:d[g+2]});return _},c.parseImageAttributes=function(p){return p.split(" ").map(function(_){return _.substring(1,_.length-1).split(",").reduce(s,{})})},c.parseSimulcastStreamList=function(p){return p.split(";").map(function(_){return _.split(",").map(function(d){var g,T=!1;return d[0]!=="~"?g=n(d):(g=n(d.substring(1,d.length)),T=!0),{scid:g,paused:T}})})}})(Lf);var ta=Hf,th=/%[sdv%]/g,sh=function(c){var n=1,r=arguments,o=r.length;return c.replace(th,function(a){if(n>=o)return a;var t=r[n];switch(n+=1,a){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},yi=function(c,n,r){var o=n.format instanceof Function?n.format(n.push?r:r[n.name]):n.format,a=[c+"="+o];if(n.names)for(var t=0;t<n.names.length;t+=1){var s=n.names[t];n.name?a.push(r[n.name][s]):a.push(r[n.names[t]])}else a.push(r[n.name]);return sh.apply(null,a)},nh=["v","o","s","i","u","e","p","c","b","t","r","z","a"],rh=["i","c","b","a"],ih=function(c,n){n=n||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var r=n.outerOrder||nh,o=n.innerOrder||rh,a=[];return r.forEach(function(t){ta[t].forEach(function(s){s.name in c&&c[s.name]!=null?a.push(yi(t,s,c)):s.push in c&&c[s.push]!=null&&c[s.push].forEach(function(p){a.push(yi(t,s,p))})})}),c.media.forEach(function(t){a.push(yi("m",ta.m[0],t)),o.forEach(function(s){ta[s].forEach(function(p){p.name in t&&t[p.name]!=null?a.push(yi(s,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(_){a.push(yi(s,p,_))})})})}),a.join(`\r
|
7
7
|
`)+`\r
|
8
|
-
`},
|
9
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){
|
10
|
-
`);for(var o in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,o)){var a=
|
11
|
-
`)}}catch(
|
12
|
-
`)}}catch(
|
13
|
-
`),
|
14
|
-
`),
|
15
|
-
`),this.body){var E=
|
8
|
+
`},En=Lf,lh=ih;Nt.write=lh;Nt.parse=En.parse;Nt.parseParams=En.parseParams;Nt.parseFmtpConfig=En.parseFmtpConfig;Nt.parsePayloads=En.parsePayloads;Nt.parseRemoteCandidates=En.parseRemoteCandidates;Nt.parseImageAttributes=En.parseImageAttributes;Nt.parseSimulcastStreamList=En.parseSimulcastStreamList;function io(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?io=function(r){return typeof r}:io=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},io(c)}function mu(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&Ja(c,n)}function Ja(c,n){return Ja=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ja(c,n)}function gu(c){var n=uh();return function(){var o=go(c),a;if(n){var t=go(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return oh(this,a)}}function oh(c,n){return n&&(io(n)==="object"||typeof n=="function")?n:ah(c)}function ah(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function uh(){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 go(c){return go=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},go(c)}function jt(c,n){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=ch(c))||n&&c&&typeof c.length=="number"){r&&(c=r);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
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var d=r.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(s)throw p}}}}function ch(c,n){if(c){if(typeof c=="string")return Vu(c,n);var r=Object.prototype.toString.call(c).slice(8,-1);if(r==="Object"&&c.constructor&&(r=c.constructor.name),r==="Map"||r==="Set")return Array.from(c);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Vu(c,n)}}function Vu(c,n){(n==null||n>c.length)&&(n=c.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=c[r];return o}function zi(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function ju(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Uo(c,n,r){return n&&ju(c.prototype,n),r&&ju(c,r),c}var Ff=Nt,fh=ft,Tt=rt,st=Ct(),qu=du(),_h=rs(),sa=new fh("SIPMessage"),Vf=function(){function c(n,r,o,a,t,s){if(zi(this,c),!n||!r||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=n,this.ruri=r,this.body=s,this.extraHeaders=st.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",Tt.MAX_FORWARDS);var p=a.to_uri||r,_=a.to_tag?{tag:a.to_tag}:null,d=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new qu(p,d,_),this.setHeader("to",this.to.toString());var g=a.from_uri||o.configuration.uri,T={tag:a.from_tag||st.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 qu(g,E,T),this.setHeader("from",this.from.toString());var y=a.call_id||o.configuration.jssip_id+st.createRandomToken(15);this.call_id=y,this.setHeader("call-id",y);var A=a.cseq||Math.floor(Math.random()*1e4);this.cseq=A,this.setHeader("cseq","".concat(A," ").concat(n))}return Uo(c,[{key:"setHeader",value:function(r,o){for(var a=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),t=0;t<this.extraHeaders.length;t++)a.test(this.extraHeaders[t])&&this.extraHeaders.splice(t,1);this.headers[st.headerize(r)]=Array.isArray(o)?o:[o]}},{key:"getHeader",value:function(r){var o=this.headers[st.headerize(r)];if(o){if(o[0])return o[0]}else{var a=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),t=jt(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(_){t.e(_)}finally{t.f()}}}},{key:"getHeaders",value:function(r){var o=this.headers[st.headerize(r)],a=[];if(o){var t=jt(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 _=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),d=jt(this.extraHeaders),g;try{for(d.s();!(g=d.n()).done;){var T=g.value;_.test(T)&&a.push(T.substring(T.indexOf(":")+1).trim())}}catch(E){d.e(E)}finally{d.f()}return a}}},{key:"hasHeader",value:function(r){if(this.headers[st.headerize(r)])return!0;var o=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),a=jt(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(r){return!r&&this.sdp?this.sdp:(this.sdp=Ff.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var r="".concat(this.method," ").concat(this.ruri,` SIP/2.0\r
|
10
|
+
`);for(var o in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,o)){var a=jt(this.headers[o]),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;r+="".concat(o,": ").concat(s,`\r
|
11
|
+
`)}}catch(y){a.e(y)}finally{a.f()}}var p=jt(this.extraHeaders),_;try{for(p.s();!(_=p.n()).done;){var d=_.value;r+="".concat(d.trim(),`\r
|
12
|
+
`)}}catch(y){p.e(y)}finally{p.f()}var g=[];switch(this.method){case Tt.REGISTER:g.push("path","gruu");break;case Tt.INVITE:this.ua.configuration.session_timers&&g.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&g.push("gruu"),g.push("ice","replaces");break;case Tt.UPDATE:this.ua.configuration.session_timers&&g.push("timer"),g.push("ice");break}g.push("outbound");var T=this.ua.configuration.user_agent||Tt.USER_AGENT;if(r+="Allow: ".concat(Tt.ALLOWED_METHODS,`\r
|
13
|
+
`),r+="Supported: ".concat(g,`\r
|
14
|
+
`),r+="User-Agent: ".concat(T,`\r
|
15
|
+
`),this.body){var E=st.str_utf8_length(this.body);r+="Content-Length: ".concat(E,`\r
|
16
16
|
\r
|
17
|
-
`),
|
17
|
+
`),r+=this.body}else r+=`Content-Length: 0\r
|
18
18
|
\r
|
19
|
-
`;return
|
20
|
-
`);if(this.method===
|
21
|
-
`)}}catch(D){
|
22
|
-
`)}}catch(D){L.e(D)}finally{L.f()}!this.to_tag&&a>100?
|
19
|
+
`;return r}},{key:"clone",value:function(){var r=new c(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(o){r.headers[o]=this.headers[o].slice()},this),r.body=this.body,r.extraHeaders=st.cloneArray(this.extraHeaders),r.to=this.to,r.from=this.from,r.call_id=this.call_id,r.cseq=this.cseq,r}}]),c}(),hh=function(c){mu(r,c);var n=gu(r);function r(o,a,t,s,p){var _;return zi(this,r),_=n.call(this,Tt.INVITE,o,a,t,s,p),_.transaction=null,_}return Uo(r,[{key:"cancel",value:function(a){this.transaction.cancel(a)}},{key:"clone",value:function(){var a=new r(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(t){a.headers[t]=this.headers[t].slice()},this),a.body=this.body,a.extraHeaders=st.cloneArray(this.extraHeaders),a.to=this.to,a.from=this.from,a.call_id=this.call_id,a.cseq=this.cseq,a.transaction=this.transaction,a}}]),r}(Vf),jf=function(){function c(){zi(this,c),this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}return Uo(c,[{key:"addHeader",value:function(r,o){var a={raw:o};r=st.headerize(r),this.headers[r]?this.headers[r].push(a):this.headers[r]=[a]}},{key:"getHeader",value:function(r){var o=this.headers[st.headerize(r)];if(o){if(o[0])return o[0].raw}else return}},{key:"getHeaders",value:function(r){var o=this.headers[st.headerize(r)],a=[];if(!o)return[];var t=jt(o),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;a.push(p.raw)}}catch(_){t.e(_)}finally{t.f()}return a}},{key:"hasHeader",value:function(r){return!!this.headers[st.headerize(r)]}},{key:"parseHeader",value:function(r){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(r=st.headerize(r),this.headers[r]){if(o>=this.headers[r].length){sa.debug('not so many "'.concat(r,'" headers present'));return}}else{sa.debug('header "'.concat(r,'" not present'));return}var a=this.headers[r][o],t=a.raw;if(a.parsed)return a.parsed;var s=_h.parse(t,r.replace(/-/g,"_"));if(s===-1){this.headers[r].splice(o,1),sa.debug('error parsing "'.concat(r,'" header field with value "').concat(t,'"'));return}else return a.parsed=s,s}},{key:"s",value:function(r,o){return this.parseHeader(r,o)}},{key:"setHeader",value:function(r,o){var a={raw:o};this.headers[st.headerize(r)]=[a]}},{key:"parseSDP",value:function(r){return!r&&this.sdp?this.sdp:(this.sdp=Ff.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),c}(),dh=function(c){mu(r,c);var n=gu(r);function r(o){var a;return zi(this,r),a=n.call(this),a.ua=o,a.headers={},a.ruri=null,a.transport=null,a.server_transaction=null,a}return Uo(r,[{key:"reply",value:function(a,t,s,p,_,d){var g=[],T=this.getHeader("To");if(a=a||null,t=t||null,!a||a<100||a>699)throw new TypeError("Invalid status_code: ".concat(a));if(t&&typeof t!="string"&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||Tt.REASON_PHRASE[a]||"",s=st.cloneArray(s),this.ua.configuration.extra_headers&&(s=s.concat(this.ua.configuration.extra_headers));var E="SIP/2.0 ".concat(a," ").concat(t,`\r
|
20
|
+
`);if(this.method===Tt.INVITE&&a>100&&a<=200){var y=this.getHeaders("record-route"),A=jt(y),R;try{for(A.s();!(R=A.n()).done;){var I=R.value;E+="Record-Route: ".concat(I,`\r
|
21
|
+
`)}}catch(D){A.e(D)}finally{A.f()}}var $=this.getHeaders("via"),L=jt($),ae;try{for(L.s();!(ae=L.n()).done;){var N=ae.value;E+="Via: ".concat(N,`\r
|
22
|
+
`)}}catch(D){L.e(D)}finally{L.f()}!this.to_tag&&a>100?T+=";tag=".concat(st.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(T+=";tag=".concat(this.to_tag)),E+="To: ".concat(T,`\r
|
23
23
|
`),E+="From: ".concat(this.getHeader("From"),`\r
|
24
24
|
`),E+="Call-ID: ".concat(this.call_id,`\r
|
25
25
|
`),E+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
|
26
|
-
`);var
|
27
|
-
`)}}catch(D){
|
28
|
-
`),E+="Accept: ".concat(
|
29
|
-
`)):a===405?E+="Allow: ".concat(
|
30
|
-
`):a===415&&(E+="Accept: ".concat(
|
26
|
+
`);var F=jt(s),Se;try{for(F.s();!(Se=F.n()).done;){var ve=Se.value;E+="".concat(ve.trim(),`\r
|
27
|
+
`)}}catch(D){F.e(D)}finally{F.f()}switch(this.method){case Tt.INVITE:this.ua.configuration.session_timers&&g.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&g.push("gruu"),g.push("ice","replaces");break;case Tt.UPDATE:this.ua.configuration.session_timers&&g.push("timer"),p&&g.push("ice"),g.push("replaces")}if(g.push("outbound"),this.method===Tt.OPTIONS?(E+="Allow: ".concat(Tt.ALLOWED_METHODS,`\r
|
28
|
+
`),E+="Accept: ".concat(Tt.ACCEPTED_BODY_TYPES,`\r
|
29
|
+
`)):a===405?E+="Allow: ".concat(Tt.ALLOWED_METHODS,`\r
|
30
|
+
`):a===415&&(E+="Accept: ".concat(Tt.ACCEPTED_BODY_TYPES,`\r
|
31
31
|
`)),E+="Supported: ".concat(g,`\r
|
32
|
-
`),p){var M=
|
32
|
+
`),p){var M=st.str_utf8_length(p);E+=`Content-Type: application/sdp\r
|
33
33
|
`,E+="Content-Length: ".concat(M,`\r
|
34
34
|
\r
|
35
35
|
`),E+=p}else E+="Content-Length: ".concat(0,`\r
|
36
36
|
\r
|
37
|
-
`);this.server_transaction.receiveResponse(a,E,
|
38
|
-
`),
|
39
|
-
`)}}catch(
|
37
|
+
`);this.server_transaction.receiveResponse(a,E,_,d)}},{key:"reply_sl",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,s=this.getHeaders("via");if(!a||a<100||a>699)throw new TypeError("Invalid status_code: ".concat(a));if(t&&typeof t!="string"&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||Tt.REASON_PHRASE[a]||"";var p="SIP/2.0 ".concat(a," ").concat(t,`\r
|
38
|
+
`),_=jt(s),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;p+="Via: ".concat(g,`\r
|
39
|
+
`)}}catch(R){_.e(R)}finally{_.f()}var T=this.getHeader("To");if(!this.to_tag&&a>100?T+=";tag=".concat(st.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(T+=";tag=".concat(this.to_tag)),p+="To: ".concat(T,`\r
|
40
40
|
`),p+="From: ".concat(this.getHeader("From"),`\r
|
41
41
|
`),p+="Call-ID: ".concat(this.call_id,`\r
|
42
42
|
`),p+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
|
43
|
-
`),this.ua.configuration.extra_headers){var E=
|
44
|
-
`)}}catch(
|
43
|
+
`),this.ua.configuration.extra_headers){var E=jt(this.ua.configuration.extra_headers),y;try{for(E.s();!(y=E.n()).done;){var A=y.value;p+="".concat(A.trim(),`\r
|
44
|
+
`)}}catch(R){E.e(R)}finally{E.f()}}p+="Content-Length: ".concat(0,`\r
|
45
45
|
\r
|
46
|
-
`),this.transport.send(p)}}]),n}(Of),Xh=function(c){nu(n,c);var r=ru(n);function n(){var o;return ji(this,n),o=r.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return n}(Of),_s={OutgoingRequest:wf,InitialOutgoingInviteRequest:zh,IncomingRequest:Jh,IncomingResponse:Xh};function Qh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Du(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 Zh(c,r,n){return r&&Du(c.prototype,r),n&&Du(c,n),c}var e_=it,is=Et(),Ht=new e_("DigestAuthentication"),t_=function(){function c(r){Qh(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 Zh(c,[{key:"get",value:function(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:Ht.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 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(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 Ht.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||is.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=is.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=is.calculateMD5(d),Ht.debug('authenticate() | using qop=auth [a2:"%s"]',d),this._response=is.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(is.calculateMD5(s||"")),g=is.calculateMD5(d),Ht.debug('authenticate() | using qop=auth-int [a2:"%s"]',d),this._response=is.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=is.calculateMD5(d),Ht.debug('authenticate() | using qop=null [a2:"%s"]',d),this._response=is.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(g))),Ht.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}(),ls=500,s_=4e3,Nu=5e3,Df={T1:ls,T2:s_,T4:Nu,TIMER_B:64*ls,TIMER_D:0*ls,TIMER_F:64*ls,TIMER_H:64*ls,TIMER_I:0*ls,TIMER_J:0*ls,TIMER_K:0*Nu,TIMER_L:64*ls,TIMER_M:64*ls,PROVISIONAL_RESPONSE_INTERVAL:6e4};function Ql(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ql=function(n){return typeof n}:Ql=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ql(c)}function Bi(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Uu(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 Gi(c,r,n){return r&&Uu(c.prototype,r),n&&Uu(c,n),c}function Ki(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&&Ha(c,r)}function Ha(c,r){return Ha=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ha(c,r)}function Wi(c){var r=r_();return function(){var o=uo(c),a;if(r){var t=uo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return n_(this,a)}}function n_(c,r){return r&&(Ql(r)==="object"||typeof r=="function")?r:ks(c)}function ks(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function r_(){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 uo(c){return uo=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},uo(c)}var Yi=pt.EventEmitter,zi=it,Mi=tt,Pu=_s,Xt=Df,ku=new zi("NonInviteClientTransaction"),Cl=new zi("InviteClientTransaction"),i_=new zi("AckClientTransaction"),Mu=new zi("NonInviteServerTransaction"),Al=new zi("InviteServerTransaction"),ue={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"},l_=function(c){Ki(n,c);var r=Wi(n);function n(o,a,t,s){var p;Bi(this,n),p=r.call(this),p.type=ue.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(ks(p)),p}return Gi(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(ue.STATUS_TRYING),this.F=setTimeout(function(){a.timer_F()},Xt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){ku.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){ku.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(ue.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 ue.STATUS_TRYING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break}else switch(this.state){case ue.STATUS_TRYING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},Xt.TIMER_K);break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),n}(Yi),o_=function(c){Ki(n,c);var r=Wi(n);function n(o,a,t,s){var p;Bi(this,n),p=r.call(this),p.type=ue.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=ks(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(ks(p)),p}return Gi(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(ue.STATUS_CALLING),this.B=setTimeout(function(){a.timer_B()},Xt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==ue.STATUS_ACCEPTED&&(Cl.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){Cl.debug("Timer M expired for transaction ".concat(this.id)),this.state===ue.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){Cl.debug("Timer B expired for transaction ".concat(this.id)),this.state===ue.STATUS_CALLING&&(this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){Cl.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(a){var t=this,s=new Pu.OutgoingRequest(Mi.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()},Xt.TIMER_D),this.transport.send(s)}},{key:"cancel",value:function(a){if(this.state===ue.STATUS_PROCEEDING){var t=new Pu.OutgoingRequest(Mi.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 ue.STATUS_CALLING:this.stateChanged(ue.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(a);break}else if(s>=200&&s<=299)switch(this.state){case ue.STATUS_CALLING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},Xt.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(s>=300&&s<=699)switch(this.state){case ue.STATUS_CALLING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_COMPLETED),this.sendACK(a),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_COMPLETED:this.sendACK(a);break}}},{key:"C",get:function(){return ue}}]),n}(Yi),a_=function(c){Ki(n,c);var r=Wi(n);function n(o,a,t,s){var p;Bi(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 Gi(n,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){i_.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return ue}}]),n}(Yi),u_=function(c){Ki(n,c);var r=Wi(n);function n(o,a,t){var s;return Bi(this,n),s=r.call(this),s.type=ue.NON_INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=ks(s),s.state=ue.STATUS_TRYING,o.newTransaction(ks(s)),s}return Gi(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){Mu.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Mu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(a,t,s,p){var h=this;if(a===100)switch(this.state){case ue.STATUS_TRYING:this.stateChanged(ue.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case ue.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 ue.STATUS_TRYING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){h.timer_J()},Xt.TIMER_J),this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),n}(Yi),c_=function(c){Ki(n,c);var r=Wi(n);function n(o,a,t){var s;return Bi(this,n),s=r.call(this),s.type=ue.INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=ks(s),s.state=ue.STATUS_PROCEEDING,o.newTransaction(ks(s)),s.resendProvisionalTimer=null,t.reply(100),s}return Gi(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){Al.debug("Timer H expired for transaction ".concat(this.id)),this.state===ue.STATUS_COMPLETED&&Al.debug("ACK not received, dialog will be terminated"),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){Al.debug("Timer L expired for transaction ".concat(this.id)),this.state===ue.STATUS_ACCEPTED&&(this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Al.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(ue.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 ue.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t;break}if(a>100&&a<=199&&this.state===ue.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){h.resend_provisional()},Xt.PROVISIONAL_RESPONSE_INTERVAL));else if(a>=200&&a<=299)switch(this.state){case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){h.timer_L()},Xt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ue.STATUS_ACCEPTED:this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=300&&a<=699)switch(this.state){case ue.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(ue.STATUS_COMPLETED),this.H=setTimeout(function(){h.timer_H()},Xt.TIMER_H),s&&s()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return ue}}]),n}(Yi);function f_(c,r){var n=c._transactions,o;switch(r.method){case Mi.INVITE:if(o=n.ist[r.via_branch],o){switch(o.state){case ue.STATUS_PROCEEDING:o.transport.send(o.last_response);break;case ue.STATUS_ACCEPTED:break}return!0}break;case Mi.ACK:if(o=n.ist[r.via_branch],o){if(o.state===ue.STATUS_ACCEPTED)return!1;if(o.state===ue.STATUS_COMPLETED)return o.state=ue.STATUS_CONFIRMED,o.I=setTimeout(function(){o.timer_I()},Xt.TIMER_I),!0}else return!1;break;case Mi.CANCEL:return o=n.ist[r.via_branch],o?(r.reply_sl(200),o.state!==ue.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(o=n.nist[r.via_branch],o){switch(o.state){case ue.STATUS_TRYING:break;case ue.STATUS_PROCEEDING:case ue.STATUS_COMPLETED:o.transport.send(o.last_response);break}return!0}break}}var Ji={C:ue,NonInviteClientTransaction:l_,InviteClientTransaction:o_,AckClientTransaction:a_,NonInviteServerTransaction:u_,InviteServerTransaction:c_,checkTransaction:f_};function h_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function xu(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 __(c,r,n){return r&&xu(c.prototype,r),n&&xu(c,n),c}var d_=it,Lu=tt,p_=t_,Yo=Ji,m_=new d_("RequestSender"),zo={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Xi=function(){function c(r,n,o){h_(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 zo)Object.prototype.hasOwnProperty.call(zo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=zo[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==Lu.BYE||this._method!==Lu.ACK)&&this._eventHandlers.onTransportError()}return __(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 Yo.InviteClientTransaction(this._ua,this._ua.transport,this._request,o);break;case"ACK":this.clientTransaction=new Yo.AckClientTransaction(this._ua,this._ua.transport,this._request,o);break;default:this.clientTransaction=new Yo.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){m_.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 p_({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 g_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function $u(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 v_(c,r,n){return r&&$u(c.prototype,r),n&&$u(c,n),c}var T_=it,Jo=Et(),rn=tt,Hu=_s,Fu=Xi,vi=new T_("Registrator"),Rl=10,E_=function(){function c(r,n){g_(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=Jo.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 v_(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){vi.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 Hu.OutgoingRequest(rn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new Fu(this._ua,a,{onRequestTimeout:function(){n._registrationFailure(null,rn.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._registrationFailure(null,rn.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")){vi.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){vi.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<Rl&&(g=Rl);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<Rl&&(n._expires=Rl),n.register()):(vi.debug("423 response received for REGISTER without Min-Expires"),n._registrationFailure(p,rn.causes.SIP_FAILURE_CODE));break}default:{var E=Jo.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){vi.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 Hu.OutgoingRequest(rn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),s=new Fu(this._ua,t,{onRequestTimeout:function(){n._unregistered(null,rn.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._unregistered(null,rn.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=Jo.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 y_(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 S_(c,r,n){return r&&qu(c.prototype,r),n&&qu(c,n),c}var Xo=tt,Il=Ji,C_=Xi,Qo={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},A_=function(){function c(r,n,o){y_(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 Qo)Object.prototype.hasOwnProperty.call(Qo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Qo[a]))}return S_(c,[{key:"send",value:function(){var n=this,o=new C_(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===Xo.INVITE||this._request.method===Xo.UPDATE&&this._request.body)&&o.clientTransaction.state!==Il.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===Il.C.STATUS_ACCEPTED||o.clientTransaction.state===Il.C.STATUS_COMPLETED||o.clientTransaction.state===Il.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===Xo.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 R_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Vu(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 ju(c,r,n){return r&&Vu(c.prototype,r),n&&Vu(c,n),c}var I_=it,Bu=_s,ws=tt,Ti=Ji,b_=A_,Zo=Et(),ea=new I_("Dialog"),Os={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},w_=function(){ju(c,null,[{key:"C",get:function(){return Os}}]);function c(r,n,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Os.STATUS_CONFIRMED;if(R_(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 Bu.IncomingResponse&&(a=n.status_code<200?Os.STATUS_EARLY:Os.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),ea.debug("new ".concat(o," dialog created with status ").concat(this._state===Os.STATUS_EARLY?"EARLY":"CONFIRMED"))}return ju(c,[{key:"isTerminated",value:function(){return this._status===Os.STATUS_TERMINATED}},{key:"update",value:function(n,o){this._state=Os.STATUS_CONFIRMED,ea.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),o==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){ea.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Os.STATUS_TERMINATED}},{key:"sendRequest",value:function(n){var o=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=Zo.cloneArray(a.extraHeaders),s=Zo.cloneObject(a.eventHandlers),p=a.body||null,h=this._createRequest(n,t,p);s.onAuthenticated=function(){o._local_seqnum+=1};var d=new b_(this,h,s);return d.send(),h}},{key:"receiveRequest",value:function(n){this._checkInDialogRequest(n)&&(n.method===ws.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===ws.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}},{key:"_createRequest",value:function(n,o,a){o=Zo.cloneArray(o),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var t=n===ws.CANCEL||n===ws.ACK?this._local_seqnum:this._local_seqnum+=1,s=new Bu.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===ws.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===ws.INVITE||n.method===ws.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===Ti.C.STATUS_ACCEPTED||n.server_transaction.state===Ti.C.STATUS_COMPLETED||n.server_transaction.state===Ti.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===Ti.C.STATUS_ACCEPTED&&(o._remote_target=n.parseHeader("contact").uri)})}else n.method===ws.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",function(){n.server_transaction.state===Ti.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}(),iu={exports:{}};function Zl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Zl=function(n){return typeof n}:Zl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Zl(c)}function O_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Gu(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&&Gu(c.prototype,r),n&&Gu(c,n),c}function N_(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&&Fa(c,r)}function Fa(c,r){return Fa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Fa(c,r)}function U_(c){var r=M_();return function(){var o=co(c),a;if(r){var t=co(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return P_(this,a)}}function P_(c,r){return r&&(Zl(r)==="object"||typeof r=="function")?r:k_(c)}function k_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function M_(){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 co(c){return co=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},co(c)}var x_=pt.EventEmitter,L_=it,$_=tt,H_=xs,Ku=Et(),F_=new L_("RTCSession:DTMF"),Nf={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};iu.exports=function(c){N_(n,c);var r=U_(n);function n(o){var a;return O_(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 H_.InvalidStateError(this._session.status);var p=Ku.cloneArray(s.extraHeaders);if(this.eventHandlers=Ku.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
|
-
`);
|
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=
|
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 md(c,r){if(c){if(typeof c=="string")return Qu(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 Qu(c,r)}}function Qu(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 gd(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 ec(c,r,n){return r&&Zu(c.prototype,r),n&&Zu(c,n),c}function vd(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&&ja(c,r)}function ja(c,r){return ja=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ja(c,r)}function Td(c){var r=Sd();return function(){var o=_o(c),a;if(r){var t=_o(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Ed(this,a)}}function Ed(c,r){return r&&(so(r)==="object"||typeof r=="function")?r:yd(c)}function yd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Sd(){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 _o(c){return _o=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},_o(c)}var Cd=pt.EventEmitter,tc=Lt,Ad=it,oe=tt,on=xs,sc=Ji,Fe=Et(),yi=Df,Rd=_s,bl=w_,Id=Xi,It=q_,nc=Z_,bd=rd,wd=pd,rc=Ls(),K=new Ad("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},wl=["audio","video"],Od=function(c){vd(n,c);var r=Td(n);ec(n,null,[{key:"C",get:function(){return J}}]);function n(o){var a;return gd(this,n),K.debug("new"),a=r.call(this),a._id=null,a._ua=o,a._status=J.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 ec(n,[{key:"isInProgress",value:function(){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}}},{key:"isEstablished",value:function(){switch(this._status){case J.STATUS_ANSWERED:case J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case J.STATUS_CANCELED:case J.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){console.log("rtcOfferConstraints connect");var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;K.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!==J.STATUS_NULL)throw new on.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new on.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 rc("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 rc("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 Rd.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;K.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=J.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=J.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===J.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!==J.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]:{};K.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 on.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==J.STATUS_WAITING_FOR_ANSWER)throw new on.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=J.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=os(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=os(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=os(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===J.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),a._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',$),a.emit("getusermediafailed",$),new Error("getUserMedia() failed"))})}).then(function($){if(a._status===J.STATUS_TERMINATED)throw new Error("terminated");a._localMediaStream=$,$&&$.getTracks().forEach(function(z){a._connection.addTrack(z,$)})}).then(function(){if(!a._late_sdp){var $={originator:"remote",type:"offer",sdp:s.body};K.debug('emit "sdp"'),a.emit("sdp",$);var z=new RTCSessionDescription({type:"offer",sdp:$.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(z)}).catch(function(U){throw s.reply(488),a._failed("system",null,oe.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),a.emit("peerconnection:setremotedescriptionfailed",U),new Error("peerconnection.setRemoteDescription() failed")}),a._connectionPromiseQueue}}).then(function(){if(a._status===J.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===J.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(s,p),s.reply(200,null,p,$,function(){a._status=J.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!==J.STATUS_TERMINATED&&K.warn($)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.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===J.STATUS_TERMINATED)throw new on.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"),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===J.STATUS_NULL||this._status===J.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=d):this._status===J.STATUS_1XX_RECEIVED&&this._request.cancel(d),this._status=J.STATUS_CANCELED,this._failed("local",null,oe.causes.CANCELED);break;case J.STATUS_WAITING_FOR_ANSWER:case J.STATUS_ANSWERED:if(K.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 J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:if(K.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===J.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==sc.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===sc.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]:{};K.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!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new on.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<It.C.MIN_DURATION?(K.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(It.C.MIN_DURATION," milliseconds")),p=It.C.MIN_DURATION):p>It.C.MAX_DURATION?(K.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(It.C.MAX_DURATION," milliseconds")),p=It.C.MAX_DURATION):p=Math.abs(p):p=It.C.DEFAULT_DURATION,t.duration=p,h&&!Fe.isDecimal(h))throw new TypeError("Invalid interToneGap: ".concat(h));if(h?h<It.C.MIN_INTER_TONE_GAP?(K.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(It.C.MIN_INTER_TONE_GAP," milliseconds")),h=It.C.MIN_INTER_TONE_GAP):h=Math.abs(h):h=It.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===J.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 It(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(K.debug("sendInfo()"),this._status!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new on.InvalidStateError(this._status);var p=new nc(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};K.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};K.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(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");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(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");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;K.debug("renegotiate()");var p=t.rtcOfferConstraints||null;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.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;K.debug("refer()");var p=a;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));var h=new wd(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 K.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(K.debug("receiveRequest()"),a.method===oe.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",a,oe.causes.CANCELED));else switch(a.method){case oe.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(!a.body){this.terminate({cause:oe.causes.MISSING_SDP,status_code:400});break}var s={originator:"remote",type:"answer",sdp:a.body};K.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}),K.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===J.STATUS_CONFIRMED||this._status===J.STATUS_WAITING_FOR_ACK?(a.reply(200),this._ended("remote",a,oe.causes.BYE)):this._status===J.STATUS_INVITE_RECEIVED||this._status===J.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===J.STATUS_CONFIRMED?a.hasHeader("replaces")?this._receiveReplaces(a):this._receiveReinvite(a):a.reply(403,"Wrong Status");break;case oe.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){var h=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;h&&h.match(/^application\/dtmf-relay/i)?new It(this).init_incoming(a):h!==void 0?new nc(this).init_incoming(a):a.reply(415)}else a.reply(403,"Wrong Status");break;case oe.UPDATE:this._status===J.STATUS_CONFIRMED?this._receiveUpdate(a):a.reply(403,"Wrong Status");break;case oe.REFER:this._status===J.STATUS_CONFIRMED?this._receiveRefer(a):a.reply(403,"Wrong Status");break;case oe.NOTIFY:this._status===J.STATUS_CONFIRMED?this._receiveNotify(a):a.reply(403,"Wrong Status");break;default:a.reply(501)}}},{key:"onTransportError",value:function(){K.warn("onTransportError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.CONNECTION_ERROR,cause:oe.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){K.warn("onRequestTimeout()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:oe.causes.REQUEST_TIMEOUT,cause:oe.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){K.warn("onDialogError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.DIALOG_ERROR,cause:oe.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(a){K.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){K.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?(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)}},{key:"_close",value:function(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),Fe.closeMediaStream(this._localMediaStream)),this._status!==J.STATUS_TERMINATED){if(this._status=J.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){K.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=yi.T1;function p(){this._status===J.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),s<yi.T2&&(s=s*2,s>yi.T2&&(s=yi.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===J.STATUS_WAITING_FOR_ACK&&(K.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(oe.BYE),a._ended("remote",null,oe.causes.NO_ACK))},yi.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})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var s=this;if(K.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 K.warn('emit "peerconnection:createofferfailed" [error:%o]',h),s.emit("peerconnection:createofferfailed",h),Promise.reject(h)}):p.createAnswer(t).catch(function(h){return K.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,K.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 K.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};K.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?(K.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?(K.debug(v.error),this._failed("remote",a,oe.causes.INTERNAL_ERROR),!1):(this._dialog=v,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;K.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!==J.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"){K.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==J.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){K.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=J.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(a,v),E._setACKTimer()}),typeof p.callback=="function"&&p.callback()}}},{key:"_receiveUpdate",value:function(a){var t=this;K.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!==J.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"){K.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==J.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){K.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;K.debug("_processInDialogSdpOffer()");var s=a.parseSDP(),p=!1,h=os(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};K.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===J.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(S).catch(function(C){throw a.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',C),t.emit("peerconnection:setremotedescriptionfailed",C),C})}).then(function(){if(t._status===J.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===J.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(C){throw a.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',C),C})}).catch(function(C){K.warn("_processInDialogSdpOffer() failed [error: %o]",C)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(K.debug("receiveRefer()"),!a.refer_to){K.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==oe.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var s=new bd(this,a.cseq);K.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!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.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(K.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;K.debug("receiveReplaces()");function s(h){var d=this;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;var g=new n(this._ua);g.on("confirmed",function(){d.terminate()}),g.init_incoming(a,h)}function p(){K.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;console.log("rtcOfferConstraints",t);var h=new Id(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===J.STATUS_TERMINATED?new Error("terminated"):(p._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',d),p.emit("getusermediafailed",d),d)})}).then(function(d){if(p._status===J.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===J.STATUS_TERMINATED)throw new Error("terminated");p._request.body=d,p._status=J.STATUS_INVITE_SENT,K.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),h.send()}).catch(function(d){p._status!==J.STATUS_TERMINATED&&K.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)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(K.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){K.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!==J.STATUS_INVITE_SENT&&this._status!==J.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(a.status_code):this._status=J.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(a.status_code):{if(!a.to_tag){K.debug("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this._createDialog(a,"UAC",!0))break;if(this._status=J.STATUS_1XX_RECEIVED,!a.body){this._progress("remote",a);break}var p={originator:"remote",type:"answer",sdp:a.body};K.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){K.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=J.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};K.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),K.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]:{};K.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};K.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!==J.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};K.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),K.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]:{};K.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};K.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!==J.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};K.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),K.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){K.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=J.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(a){if(!this._localHold&&!this._remoteHold)return a;if(a=tc.parse(a),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");var t=os(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){K.debug("mangleOffer() | both on hold, mangling offer");var h=os(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){K.debug("mangleOffer() | remote on hold, mangling offer");var v=os(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!==J.STATUS_TERMINATED&&a._isReadyToReOffer()&&(K.debug("runSessionTimer() | sending session refresh request"),a._sessionTimers.refreshMethod===oe.UPDATE?a._sendUpdate():a._sendReinvite())},t*500):this._sessionTimers.timer=setTimeout(function(){a._status!==J.STATUS_TERMINATED&&(K.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=os(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=os(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){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,s){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:s})}},{key:"_failed",value:function(a,t,s){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:s}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:s})}},{key:"_onhold",value:function(a){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,s=a.video;K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:t,video:s})}},{key:"_onunmute",value:function(a){var t=a.audio,s=a.video;K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:s})}},{key:"C",get:function(){return J}},{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}(Cd);function no(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?no=function(n){return typeof n}:no=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},no(c)}function Dd(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 Nd(c,r,n){return r&&ic(c.prototype,r),n&&ic(c,n),c}function Ud(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&&Ba(c,r)}function Ba(c,r){return Ba=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ba(c,r)}function Pd(c){var r=xd();return function(){var o=po(c),a;if(r){var t=po(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return kd(this,a)}}function kd(c,r){return r&&(no(r)==="object"||typeof r=="function")?r:Md(c)}function Md(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function xd(){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 po(c){return po=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},po(c)}var Ld=pt.EventEmitter,$d=it,sa=tt,Hd=_s,Si=Et(),Fd=Xi,lc=xs,qd=Ls(),Ol=new $d("Message"),Vd=function(c){Ud(n,c);var r=Pd(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 Nd(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=Si.cloneArray(p.extraHeaders),g=Si.cloneObject(p.eventHandlers),v=p.contentType||"text/plain",E={};p.fromUserName&&(E.from_uri=new qd("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 Hd.OutgoingRequest(sa.MESSAGE,a,this._ua,E,d),t&&(this._request.body=t);var C=new Fd(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=Si.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new lc.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=Si.cloneArray(a.extraHeaders),h=a.body;if(this._direction!=="incoming")throw new lc.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=Si.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:"_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){Ol.debug("MESSAGE failed"),this._close(),Ol.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){Ol.debug("MESSAGE succeeded"),this._close(),Ol.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}(Ld);function ro(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ro=function(n){return typeof n}:ro=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},ro(c)}function jd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function oc(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 Bd(c,r,n){return r&&oc(c.prototype,r),n&&oc(c,n),c}function Gd(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&&Ga(c,r)}function Ga(c,r){return Ga=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ga(c,r)}function Kd(c){var r=zd();return function(){var o=mo(c),a;if(r){var t=mo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Wd(this,a)}}function Wd(c,r){return r&&(ro(r)==="object"||typeof r=="function")?r:Yd(c)}function Yd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function zd(){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 mo(c){return mo=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},mo(c)}var Jd=pt.EventEmitter,Xd=it,na=tt,Qd=_s,Ci=Et(),Zd=Xi,ac=xs,Dl=new Xd("Options"),ep=function(c){Gd(n,c);var r=Kd(n);function n(o){var a;return jd(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 Bd(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=Ci.cloneArray(p.extraHeaders),g=Ci.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 Qd.OutgoingRequest(na.OPTIONS,a,this._ua,null,d),t&&(this._request.body=t);var S=new Zd(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=Ci.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new ac.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=Ci.cloneArray(a.extraHeaders),h=a.body;if(this._direction!=="incoming")throw new ac.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=Ci.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,na.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,na.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){Dl.debug("OPTIONS failed"),this._close(),Dl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){Dl.debug("OPTIONS succeeded"),this._close(),Dl.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}(Jd),lu={},tp=it,ra=Et(),sp=Zt(),Ai=new tp("Socket");lu.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return Ai.warn("undefined JsSIP.Socket instance"),!1;try{if(!ra.isString(c.url))throw Ai.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ra.isString(c.via_transport))throw Ai.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(sp.parse(c.sip_uri,"SIP_URI")===-1)throw Ai.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 Ai.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 np(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function uc(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 rp(c,r,n){return r&&uc(c.prototype,r),n&&uc(c,n),c}var ip=it,lp=lu,cc=tt,At=new ip("Transport"),Pt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:cc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:cc.CONNECTION_RECOVERY_MAX_INTERVAL}},op=function(){function c(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pt.recovery_options;np(this,c),At.debug("new()"),this.status=Pt.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){At.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(!lp.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:Pt.SOCKET_STATUS_READY})},this),this._getSocket()}return rp(c,[{key:"connect",value:function(){if(At.debug("connect()"),this.isConnected()){At.debug("Transport is already connected");return}else if(this.isConnecting()){At.debug("Transport is connecting");return}this.close_requested=!1,this.status=Pt.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(){At.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Pt.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(At.debug("send()"),!this.isConnected())return At.warn("unable to send message, transport is not connected"),!1;var o=n.toString();return At.debug(`sending message:
|
46
|
+
`),this.transport.send(p)}}]),r}(jf),ph=function(c){mu(r,c);var n=gu(r);function r(){var o;return zi(this,r),o=n.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return r}(jf),gs={OutgoingRequest:Vf,InitialOutgoingInviteRequest:hh,IncomingRequest:dh,IncomingResponse:ph};function mh(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Bu(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function gh(c,n,r){return n&&Bu(c.prototype,n),r&&Bu(c,r),c}var Th=ft,us=Ct(),Gt=new Th("DigestAuthentication"),vh=function(){function c(n){mh(this,c),this._credentials=n,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 gh(c,[{key:"get",value:function(r){switch(r){case"realm":return this._realm;case"ha1":return this._ha1;default:Gt.warn('get() | cannot get "%s" parameter',r);return}}},{key:"authenticate",value:function(r,o){var a=r.method,t=r.ruri,s=r.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 Gt.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Gt.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Gt.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Gt.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Gt.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 Gt.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||us.createRandomToken(12),this._nc+=1;var _=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-_.length)+_,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=us.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=us.calculateMD5(d),Gt.debug('authenticate() | using qop=auth [a2:"%s"]',d),this._response=us.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(us.calculateMD5(s||"")),g=us.calculateMD5(d),Gt.debug('authenticate() | using qop=auth-int [a2:"%s"]',d),this._response=us.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=us.calculateMD5(d),Gt.debug('authenticate() | using qop=null [a2:"%s"]',d),this._response=us.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(g))),Gt.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var r=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return r.push("algorithm=".concat(this._algorithm)),r.push('username="'.concat(this._credentials.username,'"')),r.push('realm="'.concat(this._realm,'"')),r.push('nonce="'.concat(this._nonce,'"')),r.push('uri="'.concat(this._uri,'"')),r.push('response="'.concat(this._response,'"')),this._opaque&&r.push('opaque="'.concat(this._opaque,'"')),this._qop&&(r.push("qop=".concat(this._qop)),r.push('cnonce="'.concat(this._cnonce,'"')),r.push("nc=".concat(this._ncHex))),"Digest ".concat(r.join(", "))}}]),c}(),cs=500,Eh=4e3,Gu=5e3,qf={T1:cs,T2:Eh,T4:Gu,TIMER_B:64*cs,TIMER_D:0*cs,TIMER_F:64*cs,TIMER_H:64*cs,TIMER_I:0*cs,TIMER_J:0*cs,TIMER_K:0*Gu,TIMER_L:64*cs,TIMER_M:64*cs,PROVISIONAL_RESPONSE_INTERVAL:6e4};function lo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?lo=function(r){return typeof r}:lo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},lo(c)}function Ji(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Wu(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Xi(c,n,r){return n&&Wu(c.prototype,n),r&&Wu(c,r),c}function Qi(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&Xa(c,n)}function Xa(c,n){return Xa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Xa(c,n)}function Zi(c){var n=yh();return function(){var o=To(c),a;if(n){var t=To(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Sh(this,a)}}function Sh(c,n){return n&&(lo(n)==="object"||typeof n=="function")?n:$s(c)}function $s(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function yh(){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 To(c){return To=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},To(c)}var el=ct.EventEmitter,tl=ft,Vi=rt,Ku=gs,ss=qf,Yu=new tl("NonInviteClientTransaction"),Ol=new tl("InviteClientTransaction"),Ah=new tl("AckClientTransaction"),zu=new tl("NonInviteServerTransaction"),Dl=new tl("InviteServerTransaction"),_e={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"},Ch=function(c){Qi(r,c);var n=Zi(r);function r(o,a,t,s){var p;Ji(this,r),p=n.call(this),p.type=_e.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 _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p.ua.newTransaction($s(p)),p}return Xi(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(_e.STATUS_TRYING),this.F=setTimeout(function(){a.timer_F()},ss.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Yu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){Yu.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(_e.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 _e.STATUS_TRYING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break}else switch(this.state){case _e.STATUS_TRYING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},ss.TIMER_K);break;case _e.STATUS_COMPLETED:break}}},{key:"C",get:function(){return _e}}]),r}(el),Rh=function(c){Qi(r,c);var n=Zi(r);function r(o,a,t,s){var p;Ji(this,r),p=n.call(this),p.type=_e.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=$s(p);var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p.ua.newTransaction($s(p)),p}return Xi(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(_e.STATUS_CALLING),this.B=setTimeout(function(){a.timer_B()},ss.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==_e.STATUS_ACCEPTED&&(Ol.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){Ol.debug("Timer M expired for transaction ".concat(this.id)),this.state===_e.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){Ol.debug("Timer B expired for transaction ".concat(this.id)),this.state===_e.STATUS_CALLING&&(this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){Ol.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(a){var t=this,s=new Ku.OutgoingRequest(Vi.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()},ss.TIMER_D),this.transport.send(s)}},{key:"cancel",value:function(a){if(this.state===_e.STATUS_PROCEEDING){var t=new Ku.OutgoingRequest(Vi.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 _e.STATUS_CALLING:this.stateChanged(_e.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break;case _e.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(a);break}else if(s>=200&&s<=299)switch(this.state){case _e.STATUS_CALLING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},ss.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case _e.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(s>=300&&s<=699)switch(this.state){case _e.STATUS_CALLING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_COMPLETED),this.sendACK(a),this.eventHandlers.onReceiveResponse(a);break;case _e.STATUS_COMPLETED:this.sendACK(a);break}}},{key:"C",get:function(){return _e}}]),r}(el),Ih=function(c){Qi(r,c);var n=Zi(r);function r(o,a,t,s){var p;Ji(this,r),p=n.call(this),p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.transport=a,p.request=t,p.eventHandlers=s;var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p}return Xi(r,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Ah.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return _e}}]),r}(el),bh=function(c){Qi(r,c);var n=Zi(r);function r(o,a,t){var s;return Ji(this,r),s=n.call(this),s.type=_e.NON_INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=$s(s),s.state=_e.STATUS_TRYING,o.newTransaction($s(s)),s}return Xi(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){zu.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,zu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(a,t,s,p){var _=this;if(a===100)switch(this.state){case _e.STATUS_TRYING:this.stateChanged(_e.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case _e.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 _e.STATUS_TRYING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){_.timer_J()},ss.TIMER_J),this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break;case _e.STATUS_COMPLETED:break}}},{key:"C",get:function(){return _e}}]),r}(el),wh=function(c){Qi(r,c);var n=Zi(r);function r(o,a,t){var s;return Ji(this,r),s=n.call(this),s.type=_e.INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=$s(s),s.state=_e.STATUS_PROCEEDING,o.newTransaction($s(s)),s.resendProvisionalTimer=null,t.reply(100),s}return Xi(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){Dl.debug("Timer H expired for transaction ".concat(this.id)),this.state===_e.STATUS_COMPLETED&&Dl.debug("ACK not received, dialog will be terminated"),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){Dl.debug("Timer L expired for transaction ".concat(this.id)),this.state===_e.STATUS_ACCEPTED&&(this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Dl.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(_e.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 _=this;if(a>=100&&a<=199)switch(this.state){case _e.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t;break}if(a>100&&a<=199&&this.state===_e.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){_.resend_provisional()},ss.PROVISIONAL_RESPONSE_INTERVAL));else if(a>=200&&a<=299)switch(this.state){case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){_.timer_L()},ss.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case _e.STATUS_ACCEPTED:this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=300&&a<=699)switch(this.state){case _e.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(_e.STATUS_COMPLETED),this.H=setTimeout(function(){_.timer_H()},ss.TIMER_H),s&&s()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return _e}}]),r}(el);function Oh(c,n){var r=c._transactions,o;switch(n.method){case Vi.INVITE:if(o=r.ist[n.via_branch],o){switch(o.state){case _e.STATUS_PROCEEDING:o.transport.send(o.last_response);break;case _e.STATUS_ACCEPTED:break}return!0}break;case Vi.ACK:if(o=r.ist[n.via_branch],o){if(o.state===_e.STATUS_ACCEPTED)return!1;if(o.state===_e.STATUS_COMPLETED)return o.state=_e.STATUS_CONFIRMED,o.I=setTimeout(function(){o.timer_I()},ss.TIMER_I),!0}else return!1;break;case Vi.CANCEL:return o=r.ist[n.via_branch],o?(n.reply_sl(200),o.state!==_e.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:if(o=r.nist[n.via_branch],o){switch(o.state){case _e.STATUS_TRYING:break;case _e.STATUS_PROCEEDING:case _e.STATUS_COMPLETED:o.transport.send(o.last_response);break}return!0}break}}var sl={C:_e,NonInviteClientTransaction:Ch,InviteClientTransaction:Rh,AckClientTransaction:Ih,NonInviteServerTransaction:bh,InviteServerTransaction:wh,checkTransaction:Oh};function Dh(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Ju(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Nh(c,n,r){return n&&Ju(c.prototype,n),r&&Ju(c,r),c}var Uh=ft,Xu=rt,Ph=vh,na=sl,xh=new Uh("RequestSender"),ra={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},nl=function(){function c(n,r,o){Dh(this,c),this._ua=n,this._eventHandlers=o,this._method=r.method,this._request=r,this._auth=null,this._challenged=!1,this._staled=!1;for(var a in ra)Object.prototype.hasOwnProperty.call(ra,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=ra[a]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==Xu.BYE||this._method!==Xu.ACK)&&this._eventHandlers.onTransportError()}return Nh(c,[{key:"send",value:function(){var r=this,o={onRequestTimeout:function(){r._eventHandlers.onRequestTimeout()},onTransportError:function(){r._eventHandlers.onTransportError()},onReceiveResponse:function(t){r._receiveResponse(t)}};switch(this._method){case"INVITE":this.clientTransaction=new na.InviteClientTransaction(this._ua,this._ua.transport,this._request,o);break;case"ACK":this.clientTransaction=new na.AckClientTransaction(this._ua,this._ua.transport,this._request,o);break;default:this.clientTransaction=new na.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(r){var o,a,t=r.status_code;if((t===401||t===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(r.status_code===401?(o=r.parseHeader("www-authenticate"),a="authorization"):(o=r.parseHeader("proxy-authenticate"),a="proxy-authorization"),!o){xh.debug("".concat(r.status_code," with wrong or missing challenge, cannot authenticate")),this._eventHandlers.onReceiveResponse(r);return}if(!this._challenged||!this._staled&&o.stale===!0){if(this._auth||(this._auth=new Ph({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(r);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(r)}else this._eventHandlers.onReceiveResponse(r)}}]),c}();function Mh(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Qu(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function kh(c,n,r){return n&&Qu(c.prototype,n),r&&Qu(c,r),c}var Lh=ft,ia=Ct(),un=rt,Zu=gs,ec=nl,Ai=new Lh("Registrator"),Nl=10,$h=function(){function c(n,r){Mh(this,c),this._reg_id=1,this._ua=n,this._transport=r,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=ia.createRandomToken(22),this._cseq=0,this._to_uri=n.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 kh(c,[{key:"setExtraHeaders",value:function(r){Array.isArray(r)||(r=[]),this._extraHeaders=r.slice()}},{key:"setExtraContactParams",value:function(r){r instanceof Object||(r={}),this._extraContactParams="";for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o)){var a=r[o];this._extraContactParams+=";".concat(o),a&&(this._extraContactParams+="=".concat(a))}}},{key:"register",value:function(){var r=this;if(this._registering){Ai.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 Zu.OutgoingRequest(un.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new ec(this._ua,a,{onRequestTimeout:function(){r._registrationFailure(null,un.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._registrationFailure(null,un.causes.CONNECTION_ERROR)},onAuthenticated:function(){r._cseq+=1},onReceiveResponse:function(p){if(p.cseq===r._cseq)switch(r._registrationTimer!==null&&(clearTimeout(r._registrationTimer),r._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):{if(r._registering=!1,!p.hasHeader("Contact")){Ai.debug("no Contact header in response to REGISTER, response ignored");break}var _=p.headers.Contact.reduce(function(y,A){return y.concat(A.parsed)},[]),d=_.find(function(y){return r._sipInstance===y.getParam("+sip.instance")&&r._reg_id===parseInt(y.getParam("reg-id"))});if(d||(d=_.find(function(y){return y.uri.user===r._ua.contact.uri.user})),!d){Ai.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=r._expires),g=Number(g),g<Nl&&(g=Nl);var T=g>64?g*1e3/2+Math.floor((g/2-32)*1e3*Math.random()):g*1e3-5e3;r._registrationTimer=setTimeout(function(){r._registrationTimer=null,r._ua.listeners("registrationExpiring").length===0?r.register():r._ua.emit("registrationExpiring")},T),d.hasParam("temp-gruu")&&(r._ua.contact.temp_gruu=d.getParam("temp-gruu").replace(/"/g,"")),d.hasParam("pub-gruu")&&(r._ua.contact.pub_gruu=d.getParam("pub-gruu").replace(/"/g,"")),r._registered||(r._registered=!0,r._ua.registered({response:p}));break}case/^423$/.test(p.status_code):{p.hasHeader("min-expires")?(r._expires=Number(p.getHeader("min-expires")),r._expires<Nl&&(r._expires=Nl),r.register()):(Ai.debug("423 response received for REGISTER without Min-Expires"),r._registrationFailure(p,un.causes.SIP_FAILURE_CODE));break}default:{var E=ia.sipErrorCause(p.status_code);r._registrationFailure(p,E)}}}});this._registering=!0,t.send()}},{key:"unregister",value:function(){var r=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){Ai.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 Zu.OutgoingRequest(un.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),s=new ec(this._ua,t,{onRequestTimeout:function(){r._unregistered(null,un.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._unregistered(null,un.causes.CONNECTION_ERROR)},onAuthenticated:function(){r._cseq+=1},onReceiveResponse:function(_){switch(!0){case/^1[0-9]{2}$/.test(_.status_code):break;case/^2[0-9]{2}$/.test(_.status_code):r._unregistered(_);break;default:{var d=ia.sipErrorCause(_.status_code);r._unregistered(_,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(r,o){this._registering=!1,this._ua.registrationFailed({response:r||null,cause:o}),this._registered&&(this._registered=!1,this._ua.unregistered({response:r||null,cause:o}))}},{key:"_unregistered",value:function(r,o){this._registering=!1,this._registered=!1,this._ua.unregistered({response:r||null,cause:o||null})}},{key:"registered",get:function(){return this._registered}}]),c}();function Hh(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function tc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Fh(c,n,r){return n&&tc(c.prototype,n),r&&tc(c,r),c}var la=rt,Ul=sl,Vh=nl,oa={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},jh=function(){function c(n,r,o){Hh(this,c),this._dialog=n,this._ua=n._ua,this._request=r,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(var a in oa)Object.prototype.hasOwnProperty.call(oa,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=oa[a]))}return Fh(c,[{key:"send",value:function(){var r=this,o=new Vh(this._ua,this._request,{onRequestTimeout:function(){r._eventHandlers.onRequestTimeout()},onTransportError:function(){r._eventHandlers.onTransportError()},onAuthenticated:function(s){r._eventHandlers.onAuthenticated(s)},onReceiveResponse:function(s){r._receiveResponse(s)}});if(o.send(),(this._request.method===la.INVITE||this._request.method===la.UPDATE&&this._request.body)&&o.clientTransaction.state!==Ul.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===Ul.C.STATUS_ACCEPTED||o.clientTransaction.state===Ul.C.STATUS_COMPLETED||o.clientTransaction.state===Ul.C.STATUS_TERMINATED)&&(o.clientTransaction.removeListener("stateChanged",t),r._dialog.uac_pending_reply=!1)};o.clientTransaction.on("stateChanged",a)}}},{key:"_receiveResponse",value:function(r){var o=this;r.status_code===408||r.status_code===481?this._eventHandlers.onDialogError(r):r.method===la.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(function(){o._dialog.isTerminated()||(o._reattempt=!0,o.send())},1e3)):r.status_code>=200&&r.status_code<300?this._eventHandlers.onSuccessResponse(r):r.status_code>=300&&this._eventHandlers.onErrorResponse(r)}},{key:"request",get:function(){return this._request}}]),c}();function qh(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function sc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function nc(c,n,r){return n&&sc(c.prototype,n),r&&sc(c,r),c}var Bh=ft,rc=gs,Us=rt,Ci=sl,Gh=jh,aa=Ct(),ua=new Bh("Dialog"),Ps={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},Wh=function(){nc(c,null,[{key:"C",get:function(){return Ps}}]);function c(n,r,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ps.STATUS_CONFIRMED;if(qh(this,c),this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!r.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};r instanceof rc.IncomingResponse&&(a=r.status_code<200?Ps.STATUS_EARLY:Ps.STATUS_CONFIRMED);var t=r.parseHeader("contact");o==="UAS"?(this._id={call_id:r.call_id,local_tag:r.to_tag,remote_tag:r.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=r.cseq,this._local_uri=r.parseHeader("to").uri,this._remote_uri=r.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=r.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:r.call_id,local_tag:r.from_tag,remote_tag:r.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=r.cseq,this._local_uri=r.parseHeader("from").uri,this._remote_uri=r.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=r.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),ua.debug("new ".concat(o," dialog created with status ").concat(this._state===Ps.STATUS_EARLY?"EARLY":"CONFIRMED"))}return nc(c,[{key:"isTerminated",value:function(){return this._status===Ps.STATUS_TERMINATED}},{key:"update",value:function(r,o){this._state=Ps.STATUS_CONFIRMED,ua.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),o==="UAC"&&(this._route_set=r.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){ua.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Ps.STATUS_TERMINATED}},{key:"sendRequest",value:function(r){var o=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=aa.cloneArray(a.extraHeaders),s=aa.cloneObject(a.eventHandlers),p=a.body||null,_=this._createRequest(r,t,p);s.onAuthenticated=function(){o._local_seqnum+=1};var d=new Gh(this,_,s);return d.send(),_}},{key:"receiveRequest",value:function(r){this._checkInDialogRequest(r)&&(r.method===Us.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===Us.INVITE&&(this._ack_seqnum=r.cseq),this._owner.receiveRequest(r))}},{key:"_createRequest",value:function(r,o,a){o=aa.cloneArray(o),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var t=r===Us.CANCEL||r===Us.ACK?this._local_seqnum:this._local_seqnum+=1,s=new rc.OutgoingRequest(r,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(r){var o=this;if(!this._remote_seqnum)this._remote_seqnum=r.cseq;else if(r.cseq<this._remote_seqnum)if(r.method===Us.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===Us.INVITE||r.method===Us.UPDATE&&r.body){if(this._uac_pending_reply===!0)r.reply(491);else if(this._uas_pending_reply===!0){var a=(Math.random()*10|0)+1;return r.reply(500,null,["Retry-After:".concat(a)]),!1}else{this._uas_pending_reply=!0;var t=function s(){(r.server_transaction.state===Ci.C.STATUS_ACCEPTED||r.server_transaction.state===Ci.C.STATUS_COMPLETED||r.server_transaction.state===Ci.C.STATUS_TERMINATED)&&(r.server_transaction.removeListener("stateChanged",s),o._uas_pending_reply=!1)};r.server_transaction.on("stateChanged",t)}r.hasHeader("contact")&&r.server_transaction.on("stateChanged",function(){r.server_transaction.state===Ci.C.STATUS_ACCEPTED&&(o._remote_target=r.parseHeader("contact").uri)})}else r.method===Us.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",function(){r.server_transaction.state===Ci.C.STATUS_COMPLETED&&(o._remote_target=r.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(r){this._local_seqnum=r}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(r){this._uac_pending_reply=r}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),c}(),Tu={exports:{}};function oo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?oo=function(r){return typeof r}:oo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},oo(c)}function Kh(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function ic(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Yh(c,n,r){return n&&ic(c.prototype,n),r&&ic(c,r),c}function zh(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&Qa(c,n)}function Qa(c,n){return Qa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Qa(c,n)}function Jh(c){var n=Zh();return function(){var o=vo(c),a;if(n){var t=vo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Xh(this,a)}}function Xh(c,n){return n&&(oo(n)==="object"||typeof n=="function")?n:Qh(c)}function Qh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Zh(){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 vo(c){return vo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},vo(c)}var ed=ct.EventEmitter,td=ft,sd=rt,nd=Fs,lc=Ct(),rd=new td("RTCSession:DTMF"),Bf={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Tu.exports=function(c){zh(r,c);var n=Jh(r);function r(o){var a;return Kh(this,r),a=n.call(this),a._session=o,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return Yh(r,[{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 nd.InvalidStateError(this._session.status);var p=lc.cloneArray(s.extraHeaders);if(this.eventHandlers=lc.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 _="Signal=".concat(this._tone,`\r
|
47
|
+
`);_+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(sd.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:_})}},{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=Bf.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):rd.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),r}(ed);Tu.exports.C=Bf;var id=Tu.exports;function ao(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ao=function(r){return typeof r}:ao=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ao(c)}function ld(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function oc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function od(c,n,r){return n&&oc(c.prototype,n),r&&oc(c,r),c}function ad(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&Za(c,n)}function Za(c,n){return Za=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Za(c,n)}function ud(c){var n=_d();return function(){var o=Eo(c),a;if(n){var t=Eo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return cd(this,a)}}function cd(c,n){return n&&(ao(n)==="object"||typeof n=="function")?n:fd(c)}function fd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function _d(){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 Eo(c){return Eo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Eo(c)}var hd=ct.EventEmitter,dd=rt,pd=Fs,md=Ct(),gd=function(c){ad(r,c);var n=ud(r);function r(o){var a;return ld(this,r),a=n.call(this),a._session=o,a._direction=null,a._contentType=null,a._body=null,a}return od(r,[{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 pd.InvalidStateError(this._session.status);this._contentType=a,this._body=t;var _=md.cloneArray(p.extraHeaders);_.push("Content-Type: ".concat(a)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(dd.INFO,{extraHeaders:_,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}}]),r}(hd);function Td(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function ac(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function vd(c,n,r){return n&&ac(c.prototype,n),r&&ac(c,r),c}var Ed=ft,uc=rt,Sd=new Ed("RTCSession:ReferNotifier"),ca={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300},yd=function(){function c(n,r,o){Td(this,c),this._session=n,this._id=r,this._expires=o||ca.expires,this._active=!0,this.notify(100)}return vd(c,[{key:"notify",value:function(r,o){if(Sd.debug("notify()"),this._active!==!1){o=o||uc.REASON_PHRASE[r]||"";var a;r>=200?a="terminated;reason=noresource":a="active;expires=".concat(this._expires),this._session.sendRequest(uc.NOTIFY,{extraHeaders:["Event: ".concat(ca.event_type,";id=").concat(this._id),"Subscription-State: ".concat(a),"Content-Type: ".concat(ca.body_type)],body:"SIP/2.0 ".concat(r," ").concat(o),eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),c}();function uo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?uo=function(r){return typeof r}:uo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},uo(c)}function Ad(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function cc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Cd(c,n,r){return n&&cc(c.prototype,n),r&&cc(c,r),c}function Rd(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&eu(c,n)}function eu(c,n){return eu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},eu(c,n)}function Id(c){var n=Od();return function(){var o=So(c),a;if(n){var t=So(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return bd(this,a)}}function bd(c,n){return n&&(uo(n)==="object"||typeof n=="function")?n:wd(c)}function wd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Od(){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 So(c){return So=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},So(c)}var Dd=ct.EventEmitter,Nd=ft,Ri=rt,Ud=rs(),fc=Ct(),cn=new Nd("RTCSession:ReferSubscriber"),Pd=function(c){Rd(r,c);var n=Id(r);function r(o){var a;return Ad(this,r),a=n.call(this),a._id=null,a._session=o,a}return Cd(r,[{key:"sendRefer",value:function(a){var t=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};cn.debug("sendRefer()");var p=fc.cloneArray(s.extraHeaders),_=fc.cloneObject(s.eventHandlers);for(var d in _)Object.prototype.hasOwnProperty.call(_,d)&&this.on(d,_[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 T="Refer-To: <".concat(a).concat(g?"?Replaces=".concat(g):"",">");if(p.push(T),!p.some(function(A){return A.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 y=this._session.sendRequest(Ri.REFER,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(R){t._requestSucceeded(R)},onErrorResponse:function(R){t._requestFailed(R,Ri.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,Ri.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,Ri.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,Ri.causes.DIALOG_ERROR)}}});this._id=y.cseq}},{key:"receiveNotify",value:function(a){if(cn.debug("receiveNotify()"),!!a.body){var t=Ud.parse(a.body.trim().split(`\r
|
49
|
+
`,1)[0],"Status_Line");if(t===-1){cn.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){cn.debug("REFER succeeded"),cn.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:a})}},{key:"_requestFailed",value:function(a,t){cn.debug("REFER failed"),cn.debug('emit "requestFailed"'),this.emit("requestFailed",{response:a||null,cause:t})}},{key:"id",get:function(){return this._id}}]),r}(Dd);function co(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?co=function(r){return typeof r}:co=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},co(c)}function fs(c,n){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=xd(c))||n&&c&&typeof c.length=="number"){r&&(c=r);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(){r=c[Symbol.iterator]()},n:function(){var d=r.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(s)throw p}}}}function xd(c,n){if(c){if(typeof c=="string")return _c(c,n);var r=Object.prototype.toString.call(c).slice(8,-1);if(r==="Object"&&c.constructor&&(r=c.constructor.name),r==="Map"||r==="Set")return Array.from(c);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _c(c,n)}}function _c(c,n){(n==null||n>c.length)&&(n=c.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=c[r];return o}function Md(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function hc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function dc(c,n,r){return n&&hc(c.prototype,n),r&&hc(c,r),c}function kd(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&tu(c,n)}function tu(c,n){return tu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},tu(c,n)}function Ld(c){var n=Fd();return function(){var o=yo(c),a;if(n){var t=yo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return $d(this,a)}}function $d(c,n){return n&&(co(n)==="object"||typeof n=="function")?n:Hd(c)}function Hd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Fd(){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 yo(c){return yo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},yo(c)}var Vd=ct.EventEmitter,pc=Nt,jd=ft,ce=rt,fn=Fs,mc=sl,qe=Ct(),Ii=qf,qd=gs,Pl=Wh,Bd=nl,Ut=id,gc=gd,Gd=yd,Wd=Pd,Tc=Vs(),K=new jd("RTCSession"),X={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},xl=["audio","video"],Kd=function(c){kd(r,c);var n=Ld(r);dc(r,null,[{key:"C",get:function(){return X}}]);function r(o){var a;return Md(this,r),K.debug("new"),a=n.call(this),a._id=null,a._ua=o,a._status=X.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:ce.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},a._referSubscribers={},a._data={},a}return dc(r,[{key:"isInProgress",value:function(){switch(this._status){case X.STATUS_NULL:case X.STATUS_INVITE_SENT:case X.STATUS_1XX_RECEIVED:case X.STATUS_INVITE_RECEIVED:case X.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case X.STATUS_ANSWERED:case X.STATUS_WAITING_FOR_ACK:case X.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case X.STATUS_CANCELED:case X.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){console.log("rtcOfferConstraints connect");var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;K.debug("connect()");var p=a,_=qe.cloneObject(t.eventHandlers),d=qe.cloneArray(t.extraHeaders),g=qe.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),T=t.mediaStream||null,E=qe.cloneObject(t.pcConfig,{iceServers:[]}),y=t.rtcConstraints||null,A=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=A,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,a===void 0)throw new TypeError("Not enough arguments");if(this._status!==X.STATUS_NULL)throw new fn.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new fn.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));this._sessionTimers.enabled&&qe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=ce.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=ce.SESSION_EXPIRES);for(var R in _)Object.prototype.hasOwnProperty.call(_,R)&&this.on(R,_[R]);this._from_tag=qe.newTag();var I=t.anonymous||!1,$={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:I,outbound:!0}),I?($.from_display_name="Anonymous",$.from_uri=new Tc("sip","anonymous","anonymous.invalid"),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),d.push("Privacy: id")):t.fromUserName&&($.from_uri=new Tc("sip",t.fromUserName,this._ua.configuration.uri.host),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&($.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 qd.InitialOutgoingInviteRequest(a,this._ua,$,d),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(E,y),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,A,T)}},{key:"init_incoming",value:function(a,t){var s=this;K.debug("init_incoming()");var p,_=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;if(a.body&&_!=="application/sdp"){a.reply(415);return}if(this._status=X.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=qe.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=X.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){a.reply(408),s._failed("local",null,ce.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),p&&(this._timers.expiresTimer=setTimeout(function(){s._status===X.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),s._failed("system",null,ce.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!==X.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]:{};K.debug("answer()");var s=this._request,p=qe.cloneArray(t.extraHeaders),_=qe.cloneObject(t.mediaConstraints),d=t.mediaStream||null,g=qe.cloneObject(t.pcConfig,{iceServers:[]}),T=t.rtcConstraints||null,E=t.rtcAnswerConstraints||null,y=qe.cloneObject(t.rtcOfferConstraints),A,R=!1,I=!1,$=!1,L=!1;if(this._rtcAnswerConstraints=E,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,this._direction!=="incoming")throw new fn.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==X.STATUS_WAITING_FOR_ANSWER)throw new fn.InvalidStateError(this._status);if(this._sessionTimers.enabled&&qe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=ce.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=ce.SESSION_EXPIRES),this._status=X.STATUS_ANSWERED,!this._createDialog(s,"UAS")){s.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),p.unshift("Contact: ".concat(this._contact));var ae=s.parseSDP();Array.isArray(ae.media)||(ae.media=[ae.media]);var N=fs(ae.media),F;try{for(N.s();!(F=N.n()).done;){var Se=F.value;Se.type==="audio"&&(R=!0,(!Se.direction||Se.direction==="sendrecv")&&($=!0)),Se.type==="video"&&(I=!0,(!Se.direction||Se.direction==="sendrecv")&&(L=!0))}}catch(H){N.e(H)}finally{N.f()}if(d&&_.audio===!1){A=d.getAudioTracks();var ve=fs(A),M;try{for(ve.s();!(M=ve.n()).done;){var D=M.value;d.removeTrack(D)}}catch(H){ve.e(H)}finally{ve.f()}}if(d&&_.video===!1){A=d.getVideoTracks();var q=fs(A),j;try{for(q.s();!(j=q.n()).done;){var z=j.value;d.removeTrack(z)}}catch(H){q.e(H)}finally{q.f()}}!d&&_.audio===void 0&&(_.audio=$),!d&&_.video===void 0&&(_.video=L),!d&&!R&&!y.offerToReceiveAudio&&(_.audio=!1),!d&&!I&&!y.offerToReceiveVideo&&(_.video=!1),this._createRTCConnection(g,T),Promise.resolve().then(function(){if(d)return d;if(_.audio||_.video)return a._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(_).catch(function(H){throw a._status===X.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),a._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',H),a.emit("getusermediafailed",H),new Error("getUserMedia() failed"))})}).then(function(H){if(a._status===X.STATUS_TERMINATED)throw new Error("terminated");a._localMediaStream=H,H&&H.getTracks().forEach(function(J){a._connection.addTrack(J,H)})}).then(function(){if(!a._late_sdp){var H={originator:"remote",type:"offer",sdp:s.body};K.debug('emit "sdp"'),a.emit("sdp",H);var J=new RTCSessionDescription({type:"offer",sdp:H.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(J)}).catch(function(U){throw s.reply(488),a._failed("system",null,ce.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),a.emit("peerconnection:setremotedescriptionfailed",U),new Error("peerconnection.setRemoteDescription() failed")}),a._connectionPromiseQueue}}).then(function(){if(a._status===X.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(H){if(a._status===X.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(s,p),s.reply(200,null,p,H,function(){a._status=X.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(s,H),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,ce.causes.CONNECTION_ERROR)})}).catch(function(H){a._status!==X.STATUS_TERMINATED&&K.warn(H)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.debug("terminate()");var s=t.cause||ce.causes.BYE,p=qe.cloneArray(t.extraHeaders),_=t.body,d,g=t.status_code,T=t.reason_phrase;if(this._status===X.STATUS_TERMINATED)throw new fn.InvalidStateError(this._status);switch(this._status){case X.STATUS_NULL:case X.STATUS_INVITE_SENT:case X.STATUS_1XX_RECEIVED:if(K.debug("canceling session"),g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));g&&(T=T||ce.REASON_PHRASE[g]||"",d="SIP ;cause=".concat(g,' ;text="').concat(T,'"')),this._status===X.STATUS_NULL||this._status===X.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=d):this._status===X.STATUS_1XX_RECEIVED&&this._request.cancel(d),this._status=X.STATUS_CANCELED,this._failed("local",null,ce.causes.CANCELED);break;case X.STATUS_WAITING_FOR_ANSWER:case X.STATUS_ANSWERED:if(K.debug("rejecting session"),g=g||480,g<300||g>=700)throw new TypeError("Invalid status_code: ".concat(g));this._request.reply(g,T,p,_),this._failed("local",null,ce.causes.REJECTED);break;case X.STATUS_WAITING_FOR_ACK:case X.STATUS_CONFIRMED:if(K.debug("terminating session"),T=t.reason_phrase||ce.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(T,'"')),this._status===X.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==mc.C.STATUS_TERMINATED){var E=this._dialog;this.receiveRequest=function(y){var A=y.method;A===ce.ACK&&(a.sendRequest(ce.BYE,{extraHeaders:p,body:_}),E.terminate())},this._request.server_transaction.on("stateChanged",function(){a._request.server_transaction.state===mc.C.STATUS_TERMINATED&&(a.sendRequest(ce.BYE,{extraHeaders:p,body:_}),E.terminate())}),this._ended("local",null,s),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(ce.BYE,{extraHeaders:p,body:_}),this._ended("local",null,s)}}},{key:"sendDTMF",value:function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};K.debug("sendDTMF() | tones: %s",a);var s=0,p=t.duration||null,_=t.interToneGap||null,d=t.transportType||ce.DTMF_TRANSPORT.INFO;if(a===void 0)throw new TypeError("Not enough arguments");if(this._status!==X.STATUS_CONFIRMED&&this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_1XX_RECEIVED)throw new fn.InvalidStateError(this._status);if(d!==ce.DTMF_TRANSPORT.INFO&&d!==ce.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&&!qe.isDecimal(p))throw new TypeError("Invalid tone duration: ".concat(p));if(p?p<Ut.C.MIN_DURATION?(K.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(Ut.C.MIN_DURATION," milliseconds")),p=Ut.C.MIN_DURATION):p>Ut.C.MAX_DURATION?(K.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(Ut.C.MAX_DURATION," milliseconds")),p=Ut.C.MAX_DURATION):p=Math.abs(p):p=Ut.C.DEFAULT_DURATION,t.duration=p,_&&!qe.isDecimal(_))throw new TypeError("Invalid interToneGap: ".concat(_));if(_?_<Ut.C.MIN_INTER_TONE_GAP?(K.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(Ut.C.MIN_INTER_TONE_GAP," milliseconds")),_=Ut.C.MIN_INTER_TONE_GAP):_=Math.abs(_):_=Ut.C.DEFAULT_INTER_TONE_GAP,d===ce.DTMF_TRANSPORT.RFC2833){var g=this._getDTMFRTPSender();g&&(a=g.toneBuffer+a,g.insertDTMF(a,p,_));return}if(this._tones){this._tones+=a;return}this._tones=a,T.call(this);function T(){var E=this,y;if(this._status===X.STATUS_TERMINATED||!this._tones||s>=this._tones.length){this._tones=null;return}var A=this._tones[s];if(s+=1,A===",")y=2e3;else{var R=new Ut(this);t.eventHandlers={onFailed:function(){E._tones=null}},R.send(A,t),y=p+_}setTimeout(T.bind(this),y)}}},{key:"sendInfo",value:function(a,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(K.debug("sendInfo()"),this._status!==X.STATUS_CONFIRMED&&this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_1XX_RECEIVED)throw new fn.InvalidStateError(this._status);var p=new gc(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};K.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};K.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(K.debug("hold()"),this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.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:ce.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(K.debug("unhold()"),this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.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:ce.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;K.debug("renegotiate()");var p=t.rtcOfferConstraints||null;if(this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var _={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:ce.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:_,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:_,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(a,t){var s=this;K.debug("refer()");var p=a;if(this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED)return!1;if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));var _=new Wd(this);_.sendRefer(a,t);var d=_.id;return this._referSubscribers[d]=_,_.on("requestFailed",function(){delete s._referSubscribers[d]}),_.on("accepted",function(){delete s._referSubscribers[d]}),_.on("failed",function(){delete s._referSubscribers[d]}),_}},{key:"sendRequest",value:function(a,t){return K.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(K.debug("receiveRequest()"),a.method===ce.CANCEL)(this._status===X.STATUS_WAITING_FOR_ANSWER||this._status===X.STATUS_ANSWERED)&&(this._status=X.STATUS_CANCELED,this._request.reply(487),this._failed("remote",a,ce.causes.CANCELED));else switch(a.method){case ce.ACK:if(this._status!==X.STATUS_WAITING_FOR_ACK)return;if(this._status=X.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!a.body){this.terminate({cause:ce.causes.MISSING_SDP,status_code:400});break}var s={originator:"remote",type:"answer",sdp:a.body};K.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:ce.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),t.emit("peerconnection:setremotedescriptionfailed",d)})}else this._is_confirmed||this._confirmed("remote",a);break;case ce.BYE:this._status===X.STATUS_CONFIRMED||this._status===X.STATUS_WAITING_FOR_ACK?(a.reply(200),this._ended("remote",a,ce.causes.BYE)):this._status===X.STATUS_INVITE_RECEIVED||this._status===X.STATUS_WAITING_FOR_ANSWER?(a.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",a,ce.causes.BYE)):a.reply(403,"Wrong Status");break;case ce.INVITE:this._status===X.STATUS_CONFIRMED?a.hasHeader("replaces")?this._receiveReplaces(a):this._receiveReinvite(a):a.reply(403,"Wrong Status");break;case ce.INFO:if(this._status===X.STATUS_1XX_RECEIVED||this._status===X.STATUS_WAITING_FOR_ANSWER||this._status===X.STATUS_ANSWERED||this._status===X.STATUS_WAITING_FOR_ACK||this._status===X.STATUS_CONFIRMED){var _=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;_&&_.match(/^application\/dtmf-relay/i)?new Ut(this).init_incoming(a):_!==void 0?new gc(this).init_incoming(a):a.reply(415)}else a.reply(403,"Wrong Status");break;case ce.UPDATE:this._status===X.STATUS_CONFIRMED?this._receiveUpdate(a):a.reply(403,"Wrong Status");break;case ce.REFER:this._status===X.STATUS_CONFIRMED?this._receiveRefer(a):a.reply(403,"Wrong Status");break;case ce.NOTIFY:this._status===X.STATUS_CONFIRMED?this._receiveNotify(a):a.reply(403,"Wrong Status");break;default:a.reply(501)}}},{key:"onTransportError",value:function(){K.warn("onTransportError()"),this._status!==X.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ce.causes.CONNECTION_ERROR,cause:ce.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){K.warn("onRequestTimeout()"),this._status!==X.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ce.causes.REQUEST_TIMEOUT,cause:ce.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){K.warn("onDialogError()"),this._status!==X.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ce.causes.DIALOG_ERROR,cause:ce.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(a){K.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){K.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?(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)}},{key:"_close",value:function(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),qe.closeMediaStream(this._localMediaStream)),this._status!==X.STATUS_TERMINATED){if(this._status=X.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){K.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=Ii.T1;function p(){this._status===X.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),s<Ii.T2&&(s=s*2,s>Ii.T2&&(s=Ii.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===X.STATUS_WAITING_FOR_ACK&&(K.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(ce.BYE),a._ended("remote",null,ce.causes.NO_ACK))},Ii.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:ce.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ce.causes.RTP_TIMEOUT})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var s=this;if(K.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(_){return K.warn('emit "peerconnection:createofferfailed" [error:%o]',_),s.emit("peerconnection:createofferfailed",_),Promise.reject(_)}):p.createAnswer(t).catch(function(_){return K.warn('emit "peerconnection:createanswerfailed" [error:%o]',_),s.emit("peerconnection:createanswerfailed",_),Promise.reject(_)})}).then(function(_){return p.setLocalDescription(_).catch(function(d){return s._rtcReady=!0,K.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',d),s.emit("peerconnection:setlocaldescriptionfailed",d),Promise.reject(d)})}).then(function(){var _=t&&t.iceRestart;if(p.iceGatheringState==="complete"&&!_||p.iceGatheringState==="gathering"&&s._iceReady){s._rtcReady=!0;var d={originator:"local",type:a,sdp:p.localDescription.sdp};return K.debug('emit "sdp"'),s.emit("sdp",d),Promise.resolve(d.sdp)}return new Promise(function(g){var T=!1,E,y;s._iceReady=!1;var A=function(){p.removeEventListener("icecandidate",E),p.removeEventListener("icegatheringstatechange",y),T=!0,s._rtcReady=!0,s._iceReady=!0;var I={originator:"local",type:a,sdp:p.localDescription.sdp};K.debug('emit "sdp"'),s.emit("sdp",I),g(I.sdp)};p.addEventListener("icecandidate",E=function(I){var $=I.candidate;$?s.emit("icecandidate",{candidate:$,ready:A}):T||A()}),p.addEventListener("icegatheringstatechange",y=function(){p.iceGatheringState==="complete"&&!T&&A()})})})}},{key:"_createDialog",value:function(a,t,s){var p=t==="UAS"?a.to_tag:a.from_tag,_=t==="UAS"?a.from_tag:a.to_tag,d=a.call_id+p+_,g=this._earlyDialogs[d];if(s)return g?!0:(g=new Pl(this,a,t,Pl.C.STATUS_EARLY),g.error?(K.debug(g.error),this._failed("remote",a,ce.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 T=new Pl(this,a,t);return T.error?(K.debug(T.error),this._failed("remote",a,ce.causes.INTERNAL_ERROR),!1):(this._dialog=T,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;K.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)},_=!1;function d(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_=!0;var E=T.status_code||403,y=T.reason_phrase||"",A=qe.cloneArray(T.extraHeaders);if(this._status!==X.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,y,A)}if(this.emit("reinvite",p),_)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(T){g.call(t,T)}).catch(function(){a.reply(500)});return}if(s!=="application/sdp"){K.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(T){t._status!==X.STATUS_TERMINATED&&g.call(t,T)}).catch(function(T){K.warn(T)});function g(T){var E=this,y=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,y),this._late_sdp&&(T=this._mangleOffer(T)),a.reply(200,null,y,T,function(){E._status=X.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(a,T),E._setACKTimer()}),typeof p.callback=="function"&&p.callback()}}},{key:"_receiveUpdate",value:function(a){var t=this;K.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)},_=!1;function d(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_=!0;var E=T.status_code||403,y=T.reason_phrase||"",A=qe.cloneArray(T.extraHeaders);if(this._status!==X.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,y,A)}if(this.emit("update",p),_)return;if(!a.body){g.call(this,null);return}if(s!=="application/sdp"){K.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(T){t._status!==X.STATUS_TERMINATED&&g.call(t,T)}).catch(function(T){K.warn(T)});function g(T){var E=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,E),a.reply(200,null,E,T),typeof p.callback=="function"&&p.callback()}}},{key:"_processInDialogSdpOffer",value:function(a){var t=this;K.debug("_processInDialogSdpOffer()");var s=a.parseSDP(),p=!1,_=fs(s.media),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;if(xl.indexOf(g.type)!==-1){var T=g.direction||s.direction||"sendrecv";if(T==="sendonly"||T==="inactive")p=!0;else{p=!1;break}}}}catch(A){_.e(A)}finally{_.f()}var E={originator:"remote",type:"offer",sdp:a.body};K.debug('emit "sdp"'),this.emit("sdp",E);var y=new RTCSessionDescription({type:"offer",sdp:E.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===X.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(y).catch(function(A){throw a.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',A),t.emit("peerconnection:setremotedescriptionfailed",A),A})}).then(function(){if(t._status===X.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===X.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(A){throw a.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',A),A})}).catch(function(A){K.warn("_processInDialogSdpOffer() failed [error: %o]",A)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(K.debug("receiveRefer()"),!a.refer_to){K.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==ce.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var s=new Gd(this,a.cseq);K.debug('emit "refer"'),this.emit("refer",{request:a,accept:function(g,T){p.call(t,g,T)},reject:function(){_.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!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED)return!1;var T=new r(this._ua);if(T.on("progress",function(y){var A=y.response;s.notify(A.status_code,A.reason_phrase)}),T.on("accepted",function(y){var A=y.response;s.notify(A.status_code,A.reason_phrase)}),T.on("_failed",function(y){var A=y.message,R=y.cause;A?s.notify(A.status_code,A.reason_phrase):s.notify(487,R)}),a.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(a.refer_to.uri.getHeader("replaces"));g.extraHeaders=qe.cloneArray(g.extraHeaders),g.extraHeaders.push("Replaces: ".concat(E))}T.connect(a.refer_to.uri.toAor(),g,d)}function _(){s.notify(603)}}},{key:"_receiveNotify",value:function(a){switch(K.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;K.debug("receiveReplaces()");function s(_){var d=this;if(this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED)return!1;var g=new r(this._ua);g.on("confirmed",function(){d.terminate()}),g.init_incoming(a,_)}function p(){K.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;console.log("rtcOfferConstraints",t);var _=new Bd(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===X.STATUS_TERMINATED?new Error("terminated"):(p._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',d),p.emit("getusermediafailed",d),d)})}).then(function(d){if(p._status===X.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,ce.causes.WEBRTC_ERROR),g})}).then(function(d){if(p._is_canceled||p._status===X.STATUS_TERMINATED)throw new Error("terminated");p._request.body=d,p._status=X.STATUS_INVITE_SENT,K.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),_.send()}).catch(function(d){p._status!==X.STATUS_TERMINATED&&K.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)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(K.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(ce.ACK);return}else{var s=new Pl(this,a,"UAC");if(s.error!==void 0){K.debug(s.error);return}this.sendRequest(ce.ACK),this.sendRequest(ce.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!==X.STATUS_INVITE_SENT&&this._status!==X.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(a.status_code):this._status=X.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(a.status_code):{if(!a.to_tag){K.debug("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this._createDialog(a,"UAC",!0))break;if(this._status=X.STATUS_1XX_RECEIVED,!a.body){this._progress("remote",a);break}var p={originator:"remote",type:"answer",sdp:a.body};K.debug('emit "sdp"'),this.emit("sdp",p);var _=new RTCSessionDescription({type:"answer",sdp:p.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(_)}).then(function(){return t._progress("remote",a)}).catch(function(E){K.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=X.STATUS_CONFIRMED,!a.body){this._acceptAndTerminate(a,400,ce.causes.MISSING_SDP),this._failed("remote",a,ce.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(a,"UAC"))break;var d={originator:"remote",type:"answer",sdp:a.body};K.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,ce.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(g).then(function(){t._handleSessionTimersInIncomingResponse(a),t._accepted("remote",a),t.sendRequest(ce.ACK),t._confirmed("local",null)}).catch(function(E){t._acceptAndTerminate(a,488,"Not Acceptable Here"),t._failed("remote",a,ce.causes.BAD_MEDIA_DESCRIPTION),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var T=qe.sipErrorCause(a.status_code);this._failed("remote",a,T)}}}},{key:"_sendReinvite",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.debug("sendReinvite()");var s=qe.cloneArray(t.extraHeaders),p=qe.cloneObject(t.eventHandlers),_=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",_)}).then(function(E){E=a._mangleOffer(E);var y={originator:"local",type:"offer",sdp:E};K.debug('emit "sdp"'),a.emit("sdp",y),a.sendRequest(ce.INVITE,{extraHeaders:s,body:E,eventHandlers:{onSuccessResponse:function(R){g.call(a,R),d=!0},onErrorResponse:function(R){T.call(a,R)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){T()});function g(E){var y=this;if(this._status!==X.STATUS_TERMINATED&&(this.sendRequest(ce.ACK),!d)){if(this._handleSessionTimersInIncomingResponse(E),E.body){if(!E.hasHeader("Content-Type")||E.getHeader("Content-Type").toLowerCase()!=="application/sdp"){T.call(this);return}}else{T.call(this);return}var A={originator:"remote",type:"answer",sdp:E.body};K.debug('emit "sdp"'),this.emit("sdp",A);var R=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return y._connection.setRemoteDescription(R)}).then(function(){p.succeeded&&p.succeeded(E)}).catch(function(I){T.call(y),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',I),y.emit("peerconnection:setremotedescriptionfailed",I)})}}function T(E){p.failed&&p.failed(E)}}},{key:"_sendUpdate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.debug("sendUpdate()");var s=qe.cloneArray(t.extraHeaders),p=qe.cloneObject(t.eventHandlers),_=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",_)}).then(function(y){y=a._mangleOffer(y);var A={originator:"local",type:"offer",sdp:y};K.debug('emit "sdp"'),a.emit("sdp",A),a.sendRequest(ce.UPDATE,{extraHeaders:s,body:y,eventHandlers:{onSuccessResponse:function(I){T.call(a,I),g=!0},onErrorResponse:function(I){E.call(a,I)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){E.call(a)})):this.sendRequest(ce.UPDATE,{extraHeaders:s,eventHandlers:{onSuccessResponse:function(A){T.call(a,A)},onErrorResponse:function(A){E.call(a,A)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}});function T(y){var A=this;if(this._status!==X.STATUS_TERMINATED&&!g)if(this._handleSessionTimersInIncomingResponse(y),d){if(y.body){if(!y.hasHeader("Content-Type")||y.getHeader("Content-Type").toLowerCase()!=="application/sdp"){E.call(this);return}}else{E.call(this);return}var R={originator:"remote",type:"answer",sdp:y.body};K.debug('emit "sdp"'),this.emit("sdp",R);var I=new RTCSessionDescription({type:"answer",sdp:R.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return A._connection.setRemoteDescription(I)}).then(function(){p.succeeded&&p.succeeded(y)}).catch(function($){E.call(A),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',$),A.emit("peerconnection:setremotedescriptionfailed",$)})}else p.succeeded&&p.succeeded(y)}function E(y){p.failed&&p.failed(y)}}},{key:"_acceptAndTerminate",value:function(a,t,s){K.debug("acceptAndTerminate()");var p=[];t&&(s=s||ce.REASON_PHRASE[t]||"",p.push("Reason: SIP ;cause=".concat(t,'; text="').concat(s,'"'))),(this._dialog||this._createDialog(a,"UAC"))&&(this.sendRequest(ce.ACK),this.sendRequest(ce.BYE,{extraHeaders:p})),this._status=X.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(a){if(!this._localHold&&!this._remoteHold)return a;if(a=pc.parse(a),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");var t=fs(a.media),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;xl.indexOf(p.type)!==-1&&(p.direction?p.direction==="sendrecv"?p.direction="sendonly":p.direction==="recvonly"&&(p.direction="inactive"):p.direction="sendonly")}}catch(A){t.e(A)}finally{t.f()}}else if(this._localHold&&this._remoteHold){K.debug("mangleOffer() | both on hold, mangling offer");var _=fs(a.media),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;xl.indexOf(g.type)!==-1&&(g.direction="inactive")}}catch(A){_.e(A)}finally{_.f()}}else if(this._remoteHold){K.debug("mangleOffer() | remote on hold, mangling offer");var T=fs(a.media),E;try{for(T.s();!(E=T.n()).done;){var y=E.value;xl.indexOf(y.type)!==-1&&(y.direction?y.direction==="sendrecv"?y.direction="recvonly":y.direction==="recvonly"&&(y.direction="inactive"):y.direction="recvonly")}}catch(A){T.e(A)}finally{T.f()}}return pc.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>=ce.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>=ce.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!==X.STATUS_TERMINATED&&a._isReadyToReOffer()&&(K.debug("runSessionTimer() | sending session refresh request"),a._sessionTimers.refreshMethod===ce.UPDATE?a._sendUpdate():a._sendReinvite())},t*500):this._sessionTimers.timer=setTimeout(function(){a._status!==X.STATUS_TERMINATED&&(K.warn("runSessionTimer() | timer expired, terminating the session"),a.terminate({cause:ce.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=fs(t),p;try{for(s.s();!(p=s.n()).done;){var _=p.value;_.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=fs(t),p;try{for(s.s();!(p=s.n()).done;){var _=p.value;_.track.enabled=!a}}catch(d){s.e(d)}finally{s.f()}}},{key:"_newRTCSession",value:function(a,t){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,s){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:s})}},{key:"_failed",value:function(a,t,s){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:s}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:s})}},{key:"_onhold",value:function(a){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,s=a.video;K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:t,video:s})}},{key:"_onunmute",value:function(a){var t=a.audio,s=a.video;K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:s})}},{key:"C",get:function(){return X}},{key:"causes",get:function(){return ce.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}}]),r}(Vd);function fo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?fo=function(r){return typeof r}:fo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fo(c)}function Yd(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function vc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function zd(c,n,r){return n&&vc(c.prototype,n),r&&vc(c,r),c}function Jd(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&su(c,n)}function su(c,n){return su=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},su(c,n)}function Xd(c){var n=ep();return function(){var o=Ao(c),a;if(n){var t=Ao(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Qd(this,a)}}function Qd(c,n){return n&&(fo(n)==="object"||typeof n=="function")?n:Zd(c)}function Zd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ep(){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 Ao(c){return Ao=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ao(c)}var tp=ct.EventEmitter,sp=ft,fa=rt,np=gs,bi=Ct(),rp=nl,Ec=Fs,ip=Vs(),Ml=new sp("Message"),lp=function(c){Jd(r,c);var n=Xd(r);function r(o){var a;return Yd(this,r),a=n.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 zd(r,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},_=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(_));var d=bi.cloneArray(p.extraHeaders),g=bi.cloneObject(p.eventHandlers),T=p.contentType||"text/plain",E={};p.fromUserName&&(E.from_uri=new ip("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 y in g)Object.prototype.hasOwnProperty.call(g,y)&&this.on(y,g[y]);d.push("Content-Type: ".concat(T)),this._request=new np.OutgoingRequest(fa.MESSAGE,a,this._ua,E,d),t&&(this._request.body=t);var A=new rp(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(I){s._receiveResponse(I)}});this._newMessage("local",this._request),A.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=bi.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new Ec.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=bi.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new Ec.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,_)}},{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=bi.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,fa.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,fa.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){Ml.debug("MESSAGE failed"),this._close(),Ml.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){Ml.debug("MESSAGE succeeded"),this._close(),Ml.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}}]),r}(tp);function _o(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_o=function(r){return typeof r}:_o=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},_o(c)}function op(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Sc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function ap(c,n,r){return n&&Sc(c.prototype,n),r&&Sc(c,r),c}function up(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&nu(c,n)}function nu(c,n){return nu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},nu(c,n)}function cp(c){var n=hp();return function(){var o=Co(c),a;if(n){var t=Co(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return fp(this,a)}}function fp(c,n){return n&&(_o(n)==="object"||typeof n=="function")?n:_p(c)}function _p(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function hp(){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 Co(c){return Co=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Co(c)}var dp=ct.EventEmitter,pp=ft,_a=rt,mp=gs,wi=Ct(),gp=nl,yc=Fs,kl=new pp("Options"),Tp=function(c){up(r,c);var n=cp(r);function r(o){var a;return op(this,r),a=n.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 ap(r,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},_=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(_));var d=wi.cloneArray(p.extraHeaders),g=wi.cloneObject(p.eventHandlers),T=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(T)),this._request=new mp.OutgoingRequest(_a.OPTIONS,a,this._ua,null,d),t&&(this._request.body=t);var y=new gp(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(R){s._receiveResponse(R)}});this._newOptions("local",this._request),y.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=wi.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new yc.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=wi.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new yc.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,_)}},{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=wi.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,_a.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,_a.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}}]),r}(dp),vu={},vp=ft,ha=Ct(),Ep=rs(),Oi=new vp("Socket");vu.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return Oi.warn("undefined JsSIP.Socket instance"),!1;try{if(!ha.isString(c.url))throw Oi.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ha.isString(c.via_transport))throw Oi.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Ep.parse(c.sip_uri,"SIP_URI")===-1)throw Oi.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(n){if(!ha.isFunction(c[n]))throw Oi.warn("missing or invalid JsSIP.Socket method: ".concat(n)),new Error("Missing or invalid JsSIP.Socket method: ".concat(n))})}catch{return!1}return!0};function Sp(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Ac(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function yp(c,n,r){return n&&Ac(c.prototype,n),r&&Ac(c,r),c}var Ap=ft,Cp=vu,Cc=rt,wt=new Ap("Transport"),Ft={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Cc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Cc.CONNECTION_RECOVERY_MAX_INTERVAL}},Rp=function(){function c(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ft.recovery_options;Sp(this,c),wt.debug("new()"),this.status=Ft.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=r,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){wt.warn("cannot use TextDecoder: ".concat(o))}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(o){if(!Cp.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:Ft.SOCKET_STATUS_READY})},this),this._getSocket()}return yp(c,[{key:"connect",value:function(){if(wt.debug("connect()"),this.isConnected()){wt.debug("Transport is already connected");return}else if(this.isConnecting()){wt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ft.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(){wt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ft.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(r){if(wt.debug("send()"),!this.isConnected())return wt.warn("unable to send message, transport is not connected"),!1;var o=r.toString();return wt.debug(`sending message:
|
51
51
|
|
52
52
|
`.concat(o,`
|
53
|
-
`)),this.socket.send(o)}},{key:"isConnected",value:function(){return this.status===
|
54
|
-
`){
|
53
|
+
`)),this.socket.send(o)}},{key:"isConnected",value:function(){return this.status===Ft.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===Ft.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var r=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),wt.debug("reconnection attempt: ".concat(this.recover_attempts,". next connection attempt in ").concat(o," seconds")),this.recovery_timer=setTimeout(function(){!r.close_requested&&!(r.isConnected()||r.isConnecting())&&(r._getSocket(),r.connect())},o*1e3)}},{key:"_getSocket",value:function(){var r=[];if(this.sockets.forEach(function(a){a.status!==Ft.SOCKET_STATUS_ERROR&&(r.length===0?r.push(a):a.weight>r[0].weight?r=[a]:a.weight===r[0].weight&&r.push(a))}),r.length===0){this.sockets.forEach(function(a){a.status=Ft.SOCKET_STATUS_READY}),this._getSocket();return}var o=Math.floor(Math.random()*r.length);this.socket=r[o].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=Ft.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(r,o,a){this.status=Ft.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:r,code:o,reason:a}),!this.close_requested&&(this.sockets.forEach(function(t){this.socket===t.socket&&(t.status=Ft.SOCKET_STATUS_ERROR)},this),this._reconnect(r))}},{key:"_onData",value:function(r){if(r===`\r
|
54
|
+
`){wt.debug("received message with CRLF Keep Alive response");return}else if(typeof r!="string"){try{this.textDecoder?r=this.textDecoder.decode(r):r=String.fromCharCode.apply(null,new Uint8Array(r))}catch{wt.debug("received binary message failed to be converted into string, message discarded");return}wt.debug(`received binary message:
|
55
55
|
|
56
|
-
`.concat(
|
57
|
-
`))}else
|
56
|
+
`.concat(r,`
|
57
|
+
`))}else wt.debug(`received text message:
|
58
58
|
|
59
|
-
`.concat(
|
60
|
-
`));this.ondata({transport:this,message:
|
61
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){
|
62
|
-
`);if(a===-1){
|
63
|
-
`,
|
64
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){
|
65
|
-
`),a=
|
66
|
-
`)}}catch(p){a.e(p)}finally{a.f()}
|
67
|
-
`),o+="From: ".concat(
|
68
|
-
`),o+="Call-ID: ".concat(
|
69
|
-
`),o+="CSeq: ".concat(
|
59
|
+
`.concat(r,`
|
60
|
+
`));this.ondata({transport:this,message:r})}},{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}(),Gf={};function Rc(c,n){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Ip(c))||n&&c&&typeof c.length=="number"){r&&(c=r);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(){r=c[Symbol.iterator]()},n:function(){var d=r.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(s)throw p}}}}function Ip(c,n){if(c){if(typeof c=="string")return Ic(c,n);var r=Object.prototype.toString.call(c).slice(8,-1);if(r==="Object"&&c.constructor&&(r=c.constructor.name),r==="Map"||r==="Set")return Array.from(c);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ic(c,n)}}function Ic(c,n){(n==null||n>c.length)&&(n=c.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=c[r];return o}var bp=ft,ru=rs(),iu=gs,Ll=new bp("Parser");Gf.parseMessage=function(c,n){var r,o,a=c.indexOf(`\r
|
62
|
+
`);if(a===-1){Ll.warn("parseMessage() | no CRLF found, not a SIP message");return}var t=c.substring(0,a),s=ru.parse(t,"Request_Response");if(s===-1){Ll.warn('parseMessage() | error parsing first line of SIP message: "'.concat(t,'"'));return}else s.status_code?(r=new iu.IncomingResponse,r.status_code=s.status_code,r.reason_phrase=s.reason_phrase):(r=new iu.IncomingRequest(n),r.method=s.method,r.ruri=s.uri);r.data=c;for(var p=a+2;;){if(a=wp(c,p),a===-2){o=p+2;break}else if(a===-1){Ll.warn("parseMessage() | malformed message");return}if(s=Op(r,c,p,a),s!==!0){Ll.warn("parseMessage() |",s.error);return}p=a+2}if(r.hasHeader("content-length")){var _=r.getHeader("content-length");r.body=c.substr(o,_)}else r.body=c.substring(o);return r};function wp(c,n){var r=n,o=0,a=0;if(c.substring(r,r+2).match(/(^\r\n)/))return-2;for(;o===0;){if(a=c.indexOf(`\r
|
63
|
+
`,r),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?r=a+2:o=a}return o}function Op(c,n,r,o){var a,t=n.indexOf(":",r),s=n.substring(r,t).trim(),p=n.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=ru.parse(p,"Record_Route"),a===-1)a=void 0;else{var _=Rc(a),d;try{for(_.s();!(d=_.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(A){_.e(A)}finally{_.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=ru.parse(p,"Contact"),a===-1)a=void 0;else{var T=Rc(a),E;try{for(T.s();!(E=T.n()).done;){var y=E.value;c.addHeader("contact",p.substring(y.possition,y.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=y.parsed}}catch(A){T.e(A)}finally{T.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 iu.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 ho(c,n){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Dp(c))||n&&c&&typeof c.length=="number"){r&&(c=r);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(){r=c[Symbol.iterator]()},n:function(){var d=r.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(s)throw p}}}}function Dp(c,n){if(c){if(typeof c=="string")return bc(c,n);var r=Object.prototype.toString.call(c).slice(8,-1);if(r==="Object"&&c.constructor&&(r=c.constructor.name),r==="Map"||r==="Set")return Array.from(c);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return bc(c,n)}}function bc(c,n){(n==null||n>c.length)&&(n=c.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=c[r];return o}var Np=ft,Wf=rt,wc=gs,Eu=Ct(),Su=new Np("sanityCheck"),Up=[jp],Pp=[kp,Lp,$p,Hp],xp=[Fp,Vp],He,Qt,Kf,Mp=function(c,n,r){He=c,Qt=n,Kf=r;var o=ho(Up),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(He instanceof wc.IncomingRequest){var s=ho(Pp),p;try{for(s.s();!(p=s.n()).done;){var _=p.value;if(_()===!1)return!1}}catch(E){s.e(E)}finally{s.f()}}else if(He instanceof wc.IncomingResponse){var d=ho(xp),g;try{for(d.s();!(g=d.n()).done;){var T=g.value;if(T()===!1)return!1}}catch(E){d.e(E)}finally{d.f()}}return!0};function kp(){if(He.s("to").uri.scheme!=="sip")return Ki(416),!1}function Lp(){if(!He.to_tag&&He.call_id.substr(0,5)===Qt.configuration.jssip_id)return Ki(482),!1}function $p(){var c=Eu.str_utf8_length(He.body),n=He.getHeader("content-length");if(c<n)return Ki(400),!1}function Hp(){var c=He.from_tag,n=He.call_id,r=He.cseq,o;if(!He.to_tag)if(He.method===Wf.INVITE){if(Qt._transactions.ist[He.via_branch])return!1;for(var a in Qt._transactions.ist)if(Object.prototype.hasOwnProperty.call(Qt._transactions.ist,a)&&(o=Qt._transactions.ist[a],o.request.from_tag===c&&o.request.call_id===n&&o.request.cseq===r))return Ki(482),!1}else{if(Qt._transactions.nist[He.via_branch])return!1;for(var t in Qt._transactions.nist)if(Object.prototype.hasOwnProperty.call(Qt._transactions.nist,t)&&(o=Qt._transactions.nist[t],o.request.from_tag===c&&o.request.call_id===n&&o.request.cseq===r))return Ki(482),!1}}function Fp(){if(He.getHeaders("via").length>1)return Su.debug("more than one Via header field present in the response, dropping the response"),!1}function Vp(){var c=Eu.str_utf8_length(He.body),n=He.getHeader("content-length");if(c<n)return Su.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function jp(){for(var c=["from","to","call_id","cseq","via"],n=0,r=c;n<r.length;n++){var o=r[n];if(!He.hasHeader(o))return Su.debug("missing mandatory header field : ".concat(o,", dropping the response")),!1}}function Ki(c){var n=He.getHeaders("via"),r,o="SIP/2.0 ".concat(c," ").concat(Wf.REASON_PHRASE[c],`\r
|
65
|
+
`),a=ho(n),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;o+="Via: ".concat(s,`\r
|
66
|
+
`)}}catch(p){a.e(p)}finally{a.f()}r=He.getHeader("To"),He.to_tag||(r+=";tag=".concat(Eu.newTag())),o+="To: ".concat(r,`\r
|
67
|
+
`),o+="From: ".concat(He.getHeader("From"),`\r
|
68
|
+
`),o+="Call-ID: ".concat(He.call_id,`\r
|
69
|
+
`),o+="CSeq: ".concat(He.cseq," ").concat(He.method,`\r
|
70
70
|
`),o+=`\r
|
71
|
-
`,
|
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 Rp(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}var Zn=Et(),hn=tt,ia=Zt(),gc=Ls(),la=lu,oa=xs;uu.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:hn.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:hn.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:hn.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(Zn.createRandomToken(12),".invalid")};var Ul={mandatory:{sockets:function(r){var n=[];if(la.isSocket(r))n.push({socket:r});else if(Array.isArray(r)&&r.length){var o=pc(r),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&la.isSocket(t.socket)?n.push(t):la.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(hn.SIP,":").concat(r));var n=gc.parse(r);if(n)return n.user?n:void 0}},optional:{authorization_user:function(r){if(ia.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(Zn.isDecimal(r)){var n=Number(r);if(n>0)return n}},connection_recovery_min_interval:function(r){if(Zn.isDecimal(r)){var n=Number(r);if(n>0)return n}},contact_uri:function(r){if(typeof r=="string"){var n=ia.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)),ia.parse(r,"uuid")!==-1)return r},no_answer_timeout:function(r){if(Zn.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===hn.INVITE||r===hn.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(Zn.isDecimal(r)){var n=Number(r);if(n>0)return n}},registrar_server:function(r){/^sip:/i.test(r)||(r="".concat(hn.SIP,":").concat(r));var n=gc.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=pc(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}}};uu.load=function(c,r){for(var n in Ul.mandatory)if(r.hasOwnProperty(n)){var o=r[n],a=Ul.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new oa.ConfigurationError(n,o)}else throw new oa.ConfigurationError(n);for(var t in Ul.optional)if(r.hasOwnProperty(t)){var s=r[t];if(Zn.isEmpty(s))continue;var p=Ul.optional[t](s);if(p!==void 0)c[t]=p;else throw new oa.ConfigurationError(t,s)}};function lo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?lo=function(n){return typeof n}:lo=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},lo(c)}function Ip(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function vc(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 Tc(c,r,n){return r&&vc(c.prototype,r),n&&vc(c,n),c}function bp(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&&Ya(c,r)}function Ya(c,r){return Ya=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ya(c,r)}function wp(c){var r=Dp();return function(){var o=go(c),a;if(r){var t=go(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Op(this,a)}}function Op(c,r){return r&&(lo(r)==="object"||typeof r=="function")?r:Mf(c)}function Mf(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 go(c){return go=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},go(c)}var Np=pt.EventEmitter,Up=it,at=tt,Pp=E_,Ec=Od,yc=Vd,Sc=ep,aa=Ji,kp=op,Pl=Et(),Mp=xs,xp=Ls(),Lp=Uf,ua=_s,$p=gp,ca=uu,$e=new Up("UA"),ft={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Hp=function(c){bp(n,c);var r=wp(n);Tc(n,null,[{key:"C",get:function(){return ft}}]);function n(o){var a;if(Ip(this,n),$e.debug("new() [configuration:%o]",o),a=r.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},ca.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=ft.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=ft.STATUS_NOT_READY,a._error=ft.CONFIGURATION_ERROR,t}return a._registrator=new Pp(Mf(a)),a}return Tc(n,[{key:"start",value:function(){$e.debug("start()"),this._status===ft.STATUS_INIT?this._transport.connect():this._status===ft.STATUS_USER_CLOSED?($e.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ft.STATUS_INIT,this._transport.connect()):this._status===ft.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 Ec(this);return s.connect(a,t),s}},{key:"sendMessage",value:function(a,t,s){$e.debug("sendMessage()");var p=new yc(this);return p.send(a,t,s),p}},{key:"sendOptions",value:function(a,t,s){$e.debug("sendOptions()");var p=new Sc(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===ft.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=ft.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 Pl.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!==at.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===at.SIPS){a.reply_sl(416);return}if(!aa.checkTransaction(this,a)){if(t===at.INVITE?new aa.InviteServerTransaction(this,this._transport,a):t!==at.ACK&&t!==at.CANCEL&&new aa.NonInviteServerTransaction(this,this._transport,a),t===at.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var s=new Sc(this);s.init_incoming(a)}else if(t===at.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new yc(this);p.init_incoming(a)}else if(t===at.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===at.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!==at.ACK&&a.reply(481);else switch(t){case at.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 Ec(this),d.init_incoming(a);else $e.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case at.BYE:a.reply(481);break;case at.CANCEL:d=this._findSession(a),d?d.receiveRequest(a):$e.debug("received CANCEL request for a non existent session");break;case at.ACK:break;case at.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{ca.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=Pl.newUUID()),this._configuration.jssip_id=Pl.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new kp(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Fp.bind(this),this._transport.onconnect=qp.bind(this),this._transport.ondisconnect=Vp.bind(this),this._transport.ondata=jp.bind(this)}catch(g){throw $e.warn(g),new Mp.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 xp("sip",Pl.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(ca.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 ft}},{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}(Np);function Fp(c){this.emit("connecting",c)}function qp(c){this._status!==ft.STATUS_USER_CLOSED&&(this._status=ft.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Vp(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!==ft.STATUS_USER_CLOSED&&(this._status=ft.STATUS_NOT_READY,this._error=ft.NETWORK_ERROR)}function jp(c){var r=c.transport,n=c.message;if(n=Lp.parseMessage(n,this),!!n&&!(this._status===ft.STATUS_USER_CLOSED&&n instanceof ua.IncomingRequest)&&$p(n,this,r)){if(n instanceof ua.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof ua.IncomingResponse){var o;switch(n.method){case at.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case at.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}function Bp(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 Gp(c,r,n){return r&&Cc(c.prototype,r),n&&Cc(c,n),c}var Kp=it,Wp=Zt(),St=new Kp("WebSocketInterface"),Yp=function(){function c(r){Bp(this,c),St.debug('new() [url:"%s"]',r),this._url=r,this._sip_uri=null,this._via_transport=null,this._ws=null;var n=Wp.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 Gp(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}(),za=vo,zp=tt,Jp=xs,Xp=Et(),Qp=Hp,Zp=Ls(),em=tu(),tm=Zt(),sm=Yp,nm=rr("JsSIP");nm("version %s",za.version);var Ac={C:zp,Exceptions:Jp,Utils:Xp,UA:Qp,URI:Zp,NameAddrHeader:em,WebSocketInterface:sm,Grammar:tm,debug:rr,get name(){return za.title},get version(){return za.version}};const Jn=rr,Xn="JsSIP";var lt=class{constructor(r){r?(this._debug=Jn.default(`${Xn}:${r}`),this._warn=Jn.default(`${Xn}:WARN:${r}`),this._error=Jn.default(`${Xn}:ERROR:${r}`)):(this._debug=Jn.default(Xn),this._warn=Jn.default(`${Xn}:WARN`),this._error=Jn.default(`${Xn}: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 Rc=vo;var De={USER_AGENT:`${Rc.title} ${Rc.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 be=xt(De);var Je={},fa,Ic;function cu(){if(Ic)return fa;Ic=1;const c=ds(),r=es();return fa=class xf{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 xf(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}},fa}var ha,bc;function es(){return bc||(bc=1,ha=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:z,token:U,token_nodot:P,separators:Z,word:Xe,STAR:Q,SLASH:G,EQUAL:B,LPAREN:te,RPAREN:de,RAQUOT:Ae,LAQUOT:Ue,COMMA:ye,SEMI:ne,COLON:Te,LDQUOT:Qe,RDQUOT:st,comment:ge,ctext:Ee,quoted_string:Ce,quoted_string_clean:Ie,qdtext:he,quoted_pair:le,SIP_URI_noparams:fe,SIP_URI:Re,uri_scheme:we,uri_scheme_sips:Ye,uri_scheme_sip:ke,userinfo:wt,user:ot,user_unreserved:mn,password:gn,hostport:$s,host:Vt,hostname:ss,domainlabel:Hs,toplabel:vn,IPv6reference:Tn,IPv6address:Fs,h16:_e,ls32:re,IPv4address:nt,dec_octet:$t,port:ms,uri_parameters:or,uri_parameter:En,transport_param:yn,user_param:ar,method_param:ur,ttl_param:cr,maddr_param:fr,lr_param:hr,other_param:_r,pname:dr,pvalue:pr,paramchar:gs,param_unreserved:vs,headers:mr,header:qs,hname:Vs,hvalue:gr,hnv_unreserved:Ts,Request_Response:js,Request_Line:tl,Request_URI:vr,absoluteURI:Sn,hier_part:Cn,net_path:Tr,abs_path:Bs,opaque_part:Gs,uric:Es,uric_no_slash:ys,path_segments:Er,segment:Ks,param:Ss,pchar:ns,scheme:Cs,authority:yr,srvr:Sr,reg_name:Cr,query:Ar,SIP_Version:An,INVITEm:Rn,ACKm:Rr,OPTIONSm:Ir,BYEm:br,CANCELm:wr,REGISTERm:Or,SUBSCRIBEm:Dr,NOTIFYm:Nr,REFERm:Ur,Method:Ws,Status_Line:Ys,Status_Code:Pr,extension_code:kr,Reason_Phrase:Mr,Allow_Events:sl,Call_ID:Io,Contact:bo,contact_param:In,name_addr:Ot,display_name:Dt,contact_params:As,c_p_q:bn,c_p_expires:xr,delta_seconds:jt,qvalue:Bt,generic_param:Ve,gen_value:je,Content_Disposition:nl,disp_type:rl,disp_param:wn,handling_param:On,Content_Encoding:il,Content_Length:wo,Content_Type:Oo,media_type:ll,m_type:Lr,discrete_type:$r,composite_type:Hr,extension_token:zs,x_token:Js,m_subtype:Fr,m_parameter:Dn,m_value:Nn,CSeq:ol,CSeq_value:al,Expires:ul,Event:Do,event_type:Xs,From:Qs,from_param:qr,tag_param:Zs,Max_Forwards:Vr,Min_Expires:No,Name_Addr_Header:Uo,Proxy_Authenticate:Po,challenge:jr,other_challenge:Un,auth_param:Rs,digest_cln:Gt,realm:en,realm_value:Br,domain:Gr,URI:tn,nonce:sn,nonce_value:Kr,opaque:Wr,stale:Yr,algorithm:zr,qop_options:Jr,qop_value:nn,Proxy_Require:Pn,Record_Route:ko,rec_route:kn,Reason:Mn,reason_param:Xr,reason_cause:xn,Require:cl,Route:Mo,route_param:Ln,Subscription_State:$n,substate_value:fl,subexp_params:Hn,event_reason_value:Fn,Subject:hl,Supported:xo,To:Lo,to_param:Qr,Via:Zr,via_param:qn,via_params:Is,via_ttl:Vn,via_maddr:ei,via_received:ti,via_branch:si,response_port:ni,rport:ri,sent_protocol:ii,protocol_name:li,transport:oi,sent_by:ai,via_host:ui,via_port:ci,ttl:jn,WWW_Authenticate:fi,Session_Expires:$o,s_e_expires:_l,s_e_params:Bn,s_e_refresher:Gn,extension_header:dl,header_value:pl,message_body:ml,uuid_URI:Ho,uuid:gl,hex4:Nt,hex8:Ut,hex12:hi,Refer_To:vl,Replaces:Fo,call_id:Tl,replaces_param:Kn,to_tag:Wn,from_tag:_i,early_flag:di};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
|
71
|
+
`,Kf.send(o)}var yu={};function Oc(c,n){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=qp(c))||n&&c&&typeof c.length=="number"){r&&(c=r);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(){r=c[Symbol.iterator]()},n:function(){var d=r.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(s)throw p}}}}function qp(c,n){if(c){if(typeof c=="string")return Dc(c,n);var r=Object.prototype.toString.call(c).slice(8,-1);if(r==="Object"&&c.constructor&&(r=c.constructor.name),r==="Map"||r==="Set")return Array.from(c);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Dc(c,n)}}function Dc(c,n){(n==null||n>c.length)&&(n=c.length);for(var r=0,o=new Array(n);r<n;r++)o[r]=c[r];return o}var rr=Ct(),gn=rt,da=rs(),Nc=Vs(),pa=vu,ma=Fs;yu.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:gn.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:gn.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:gn.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(rr.createRandomToken(12),".invalid")};var $l={mandatory:{sockets:function(n){var r=[];if(pa.isSocket(n))r.push({socket:n});else if(Array.isArray(n)&&n.length){var o=Oc(n),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&pa.isSocket(t.socket)?r.push(t):pa.isSocket(t)&&r.push({socket:t})}}catch(s){o.e(s)}finally{o.f()}}else return;return r},uri:function(n){/^sip:/i.test(n)||(n="".concat(gn.SIP,":").concat(n));var r=Nc.parse(n);if(r)return r.user?r:void 0}},optional:{authorization_user:function(n){if(da.parse('"'.concat(n,'"'),"quoted_string")!==-1)return n},authorization_jwt:function(n){if(typeof n=="string")return n},user_agent:function(n){if(typeof n=="string")return n},connection_recovery_max_interval:function(n){if(rr.isDecimal(n)){var r=Number(n);if(r>0)return r}},connection_recovery_min_interval:function(n){if(rr.isDecimal(n)){var r=Number(n);if(r>0)return r}},contact_uri:function(n){if(typeof n=="string"){var r=da.parse(n,"SIP_URI");if(r!==-1)return r}},display_name:function(n){return n},instance_id:function(n){if(/^uuid:/i.test(n)&&(n=n.substr(5)),da.parse(n,"uuid")!==-1)return n},no_answer_timeout:function(n){if(rr.isDecimal(n)){var r=Number(n);if(r>0)return r}},session_timers:function(n){if(typeof n=="boolean")return n},session_timers_refresh_method:function(n){if(typeof n=="string"&&(n=n.toUpperCase(),n===gn.INVITE||n===gn.UPDATE))return n},session_timers_force_refresher:function(n){if(typeof n=="boolean")return n},password:function(n){return String(n)},realm:function(n){return String(n)},ha1:function(n){return String(n)},register:function(n){if(typeof n=="boolean")return n},register_expires:function(n){if(rr.isDecimal(n)){var r=Number(n);if(r>0)return r}},registrar_server:function(n){/^sip:/i.test(n)||(n="".concat(gn.SIP,":").concat(n));var r=Nc.parse(n);if(r)return r.user?void 0:r},use_preloaded_route:function(n){if(typeof n=="boolean")return n},extra_headers:function(n){var r=[];if(Array.isArray(n)&&n.length){var o=Oc(n),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;typeof t=="string"&&r.push(t)}}catch(s){o.e(s)}finally{o.f()}}else return;return r}}};yu.load=function(c,n){for(var r in $l.mandatory)if(n.hasOwnProperty(r)){var o=n[r],a=$l.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new ma.ConfigurationError(r,o)}else throw new ma.ConfigurationError(r);for(var t in $l.optional)if(n.hasOwnProperty(t)){var s=n[t];if(rr.isEmpty(s))continue;var p=$l.optional[t](s);if(p!==void 0)c[t]=p;else throw new ma.ConfigurationError(t,s)}};function po(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?po=function(r){return typeof r}:po=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},po(c)}function Bp(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Uc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Pc(c,n,r){return n&&Uc(c.prototype,n),r&&Uc(c,r),c}function Gp(c,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(n&&n.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),n&&lu(c,n)}function lu(c,n){return lu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},lu(c,n)}function Wp(c){var n=Yp();return function(){var o=Ro(c),a;if(n){var t=Ro(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Kp(this,a)}}function Kp(c,n){return n&&(po(n)==="object"||typeof n=="function")?n:Yf(c)}function Yf(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Yp(){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 Ro(c){return Ro=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ro(c)}var zp=ct.EventEmitter,Jp=ft,ht=rt,Xp=$h,xc=Kd,Mc=lp,kc=Tp,ga=sl,Qp=Rp,Hl=Ct(),Zp=Fs,em=Vs(),tm=Gf,Ta=gs,sm=Mp,va=yu,Ve=new Jp("UA"),mt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},nm=function(c){Gp(r,c);var n=Wp(r);Pc(r,null,[{key:"C",get:function(){return mt}}]);function r(o){var a;if(Bp(this,r),Ve.debug("new() [configuration:%o]",o),a=n.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},va.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=mt.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=mt.STATUS_NOT_READY,a._error=mt.CONFIGURATION_ERROR,t}return a._registrator=new Xp(Yf(a)),a}return Pc(r,[{key:"start",value:function(){Ve.debug("start()"),this._status===mt.STATUS_INIT?this._transport.connect():this._status===mt.STATUS_USER_CLOSED?(Ve.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=mt.STATUS_INIT,this._transport.connect()):this._status===mt.STATUS_READY?Ve.debug("UA is in READY status, not restarted"):Ve.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){Ve.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(a){Ve.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){Ve.debug("call()");var s=new xc(this);return s.connect(a,t),s}},{key:"sendMessage",value:function(a,t,s){Ve.debug("sendMessage()");var p=new Mc(this);return p.send(a,t,s),p}},{key:"sendOptions",value:function(a,t,s){Ve.debug("sendOptions()");var p=new kc(this);return p.send(a,t,s),p}},{key:"terminateSessions",value:function(a){Ve.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(Ve.debug("stop()"),this._dynConfiguration={},this._status===mt.STATUS_USER_CLOSED){Ve.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)){Ve.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=mt.STATUS_USER_CLOSED;var _=Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length;_===0&&t===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){a._closeTimer=null,a._transport.disconnect()},2e3)}},{key:"normalizeTarget",value:function(a){return Hl.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:Ve.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 Ve.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){Ve.debug("Request-URI does not point to us"),a.method!==ht.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===ht.SIPS){a.reply_sl(416);return}if(!ga.checkTransaction(this,a)){if(t===ht.INVITE?new ga.InviteServerTransaction(this,this._transport,a):t!==ht.ACK&&t!==ht.CANCEL&&new ga.NonInviteServerTransaction(this,this._transport,a),t===ht.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var s=new kc(this);s.init_incoming(a)}else if(t===ht.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new Mc(this);p.init_incoming(a)}else if(t===ht.INVITE&&!a.to_tag&&this.listeners("newRTCSession").length===0){a.reply(405);return}var _,d;if(a.to_tag)_=this._findDialog(a.call_id,a.from_tag,a.to_tag),_?_.receiveRequest(a):t===ht.NOTIFY?(d=this._findSession(a),d?d.receiveRequest(a):(Ve.debug("received NOTIFY request for a non existent subscription"),a.reply(481,"Subscription does not exist"))):t!==ht.ACK&&a.reply(481);else switch(t){case ht.INVITE:if(window.RTCPeerConnection)if(a.hasHeader("replaces")){var g=a.replaces;_=this._findDialog(g.call_id,g.from_tag,g.to_tag),_?(d=_.owner,d.isEnded()?a.reply(603):d.receiveRequest(a)):a.reply(481)}else d=new xc(this),d.init_incoming(a);else Ve.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case ht.BYE:a.reply(481);break;case ht.CANCEL:d=this._findSession(a),d?d.receiveRequest(a):Ve.debug("received CANCEL request for a non existent session");break;case ht.ACK:break;case ht.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,_=t+s,d=this._sessions[_],g=t+p,T=this._sessions[g];return d||T||null}},{key:"_findDialog",value:function(a,t,s){var p=a+t+s,_=this._dialogs[p];return _||(p=a+s+t,_=this._dialogs[p],_||null)}},{key:"_loadConfig",value:function(a){try{va.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=Hl.newUUID()),this._configuration.jssip_id=Hl.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new Qp(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=rm.bind(this),this._transport.onconnect=im.bind(this),this._transport.ondisconnect=lm.bind(this),this._transport.ondata=om.bind(this)}catch(g){throw Ve.warn(g),new Zp.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 em("sip",Hl.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 T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=T.anonymous||null,y=T.outbound||null,A="<";return E?A+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":A+=this.pub_gruu||this.uri.toString(),y&&(E?!this.temp_gruu:!this.pub_gruu)&&(A+=";ob"),A+=">",A}};var p=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var _ in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,_)&&(p.indexOf(_)!==-1?Object.defineProperty(this._configuration,_,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,_,{writable:!1,configurable:!1}));Ve.debug("configuration parameters after validation:");for(var d in this._configuration)if(Object.prototype.hasOwnProperty.call(va.settings,d))switch(d){case"uri":case"registrar_server":Ve.debug("- ".concat(d,": ").concat(this._configuration[d]));break;case"password":case"ha1":case"authorization_jwt":Ve.debug("- ".concat(d,": NOT SHOWN"));break;default:Ve.debug("- ".concat(d,": ").concat(JSON.stringify(this._configuration[d])))}}},{key:"C",get:function(){return mt}},{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}}]),r}(zp);function rm(c){this.emit("connecting",c)}function im(c){this._status!==mt.STATUS_USER_CLOSED&&(this._status=mt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function lm(c){for(var n=["nict","ict","nist","ist"],r=0,o=n;r<o.length;r++){var a=o[r];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!==mt.STATUS_USER_CLOSED&&(this._status=mt.STATUS_NOT_READY,this._error=mt.NETWORK_ERROR)}function om(c){var n=c.transport,r=c.message;if(r=tm.parseMessage(r,this),!!r&&!(this._status===mt.STATUS_USER_CLOSED&&r instanceof Ta.IncomingRequest)&&sm(r,this,n)){if(r instanceof Ta.IncomingRequest)r.transport=n,this.receiveRequest(r);else if(r instanceof Ta.IncomingResponse){var o;switch(r.method){case ht.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case ht.ACK:break;default:o=this._transactions.nict[r.via_branch],o&&o.receiveResponse(r);break}}}}function am(c,n){if(!(c instanceof n))throw new TypeError("Cannot call a class as a function")}function Lc(c,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function um(c,n,r){return n&&Lc(c.prototype,n),r&&Lc(c,r),c}var cm=ft,fm=rs(),It=new cm("WebSocketInterface"),_m=function(){function c(n){am(this,c),It.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;var r=fm.parse(n,"absoluteURI");if(r===-1)throw It.warn("invalid WebSocket URI: ".concat(n)),new TypeError("Invalid argument: ".concat(n));if(r.scheme!=="wss"&&r.scheme!=="ws")throw It.warn("invalid WebSocket URI scheme: ".concat(r.scheme)),new TypeError("Invalid argument: ".concat(n));this._sip_uri="sip:".concat(r.host).concat(r.port?":".concat(r.port):"",";transport=ws"),this._via_transport=r.scheme.toUpperCase()}return um(c,[{key:"connect",value:function(){if(It.debug("connect()"),this.isConnected()){It.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){It.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),It.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(r){this._onError(r)}}},{key:"disconnect",value:function(){It.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(r){return It.debug("send()"),this.isConnected()?(this._ws.send(r),!0):(It.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(){It.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(r){var o=r.wasClean,a=r.code,t=r.reason;It.debug("WebSocket ".concat(this._url," closed")),o===!1&&It.debug("WebSocket abrupt disconnection"),this.ondisconnect(!o,a,t)}},{key:"_onMessage",value:function(r){var o=r.data;It.debug("received WebSocket message"),this.ondata(o)}},{key:"_onError",value:function(r){It.warn("WebSocket ".concat(this._url," error: "),r)}},{key:"via_transport",get:function(){return this._via_transport},set:function(r){this._via_transport=r.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),c}(),ou=bo,hm=rt,dm=Fs,pm=Ct(),mm=nm,gm=Vs(),Tm=du(),vm=rs(),Em=_m,Sm=ur("JsSIP");Sm("version %s",ou.version);var $c={C:hm,Exceptions:dm,Utils:pm,UA:mm,URI:gm,NameAddrHeader:Tm,WebSocketInterface:Em,Grammar:vm,debug:ur,get name(){return ou.title},get version(){return ou.version}};const tr=ur,sr="JsSIP";var at=class{constructor(n){n?(this._debug=tr.default(`${sr}:${n}`),this._warn=tr.default(`${sr}:WARN:${n}`),this._error=tr.default(`${sr}:ERROR:${n}`)):(this._debug=tr.default(sr),this._warn=tr.default(`${sr}:WARN`),this._error=tr.default(`${sr}: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 zf=ot(at),Hc=bo;var Ue={USER_AGENT:`${Hc.title} ${Hc.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 G=ot(Ue);var Ze={},Ea,Fc;function Au(){if(Fc)return Ea;Fc=1;const c=Ts(),n=is();return Ea=class Jf{static parse(o){if(o=n.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 Jf(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}},Ea}var Sa,Vc;function is(){return Vc||(Vc=1,Sa=function(){function c(r){return'"'+r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(r,o){var a={CRLF:d,DIGIT:g,ALPHA:T,HEXDIG:E,WSP:y,OCTET:A,DQUOTE:R,SP:I,HTAB:$,alphanum:L,reserved:ae,unreserved:N,mark:F,escaped:Se,LWS:ve,SWS:M,HCOLON:D,TEXT_UTF8_TRIM:q,TEXT_UTF8char:j,UTF8_NONASCII:z,UTF8_CONT:H,LHEX:J,token:U,token_nodot:P,separators:se,word:et,STAR:ee,SLASH:W,EQUAL:B,LPAREN:re,RPAREN:ge,RAQUOT:be,LAQUOT:xe,COMMA:Ce,SEMI:le,COLON:ye,LDQUOT:tt,RDQUOT:it,comment:Ee,ctext:Ae,quoted_string:Ie,quoted_string_clean:Oe,qdtext:pe,quoted_pair:ue,SIP_URI_noparams:de,SIP_URI:we,uri_scheme:De,uri_scheme_sips:Xe,uri_scheme_sip:Le,userinfo:Mt,user:_t,user_unreserved:Sn,password:yn,hostport:js,host:Yt,hostname:ls,domainlabel:qs,toplabel:An,IPv6reference:Cn,IPv6address:Bs,h16:me,ls32:oe,IPv4address:lt,dec_octet:Bt,port:Es,uri_parameters:_r,uri_parameter:Rn,transport_param:In,user_param:hr,method_param:dr,ttl_param:pr,maddr_param:mr,lr_param:gr,other_param:Tr,pname:vr,pvalue:Er,paramchar:Ss,param_unreserved:ys,headers:Sr,header:Gs,hname:Ws,hvalue:yr,hnv_unreserved:As,Request_Response:Ks,Request_Line:ol,Request_URI:Ar,absoluteURI:bn,hier_part:wn,net_path:Cr,abs_path:Ys,opaque_part:zs,uric:Cs,uric_no_slash:Rs,path_segments:Rr,segment:Js,param:Is,pchar:os,scheme:bs,authority:Ir,srvr:br,reg_name:wr,query:Or,SIP_Version:On,INVITEm:Dn,ACKm:Dr,OPTIONSm:Nr,BYEm:Ur,CANCELm:Pr,REGISTERm:xr,SUBSCRIBEm:Mr,NOTIFYm:kr,REFERm:Lr,Method:Xs,Status_Line:Qs,Status_Code:$r,extension_code:Hr,Reason_Phrase:Fr,Allow_Events:al,Call_ID:Mo,Contact:ko,contact_param:Nn,name_addr:kt,display_name:Lt,contact_params:ws,c_p_q:Un,c_p_expires:Vr,delta_seconds:zt,qvalue:Jt,generic_param:Ge,gen_value:We,Content_Disposition:ul,disp_type:cl,disp_param:Pn,handling_param:xn,Content_Encoding:fl,Content_Length:Lo,Content_Type:$o,media_type:_l,m_type:jr,discrete_type:qr,composite_type:Br,extension_token:Zs,x_token:en,m_subtype:Gr,m_parameter:Mn,m_value:kn,CSeq:hl,CSeq_value:dl,Expires:pl,Event:Ho,event_type:tn,From:sn,from_param:Wr,tag_param:nn,Max_Forwards:Kr,Min_Expires:Fo,Name_Addr_Header:Vo,Proxy_Authenticate:jo,challenge:Yr,other_challenge:Ln,auth_param:Os,digest_cln:Xt,realm:rn,realm_value:zr,domain:Jr,URI:ln,nonce:on,nonce_value:Xr,opaque:Qr,stale:Zr,algorithm:ei,qop_options:ti,qop_value:an,Proxy_Require:$n,Record_Route:qo,rec_route:Hn,Reason:Fn,reason_param:si,reason_cause:Vn,Require:ml,Route:Bo,route_param:jn,Subscription_State:qn,substate_value:gl,subexp_params:Bn,event_reason_value:Gn,Subject:Tl,Supported:Go,To:Wo,to_param:ni,Via:ri,via_param:Wn,via_params:Ds,via_ttl:Kn,via_maddr:ii,via_received:li,via_branch:oi,response_port:ai,rport:ui,sent_protocol:ci,protocol_name:fi,transport:_i,sent_by:hi,via_host:di,via_port:pi,ttl:Yn,WWW_Authenticate:mi,Session_Expires:Ko,s_e_expires:vl,s_e_params:zn,s_e_refresher:Jn,extension_header:El,header_value:Sl,message_body:yl,uuid_URI:Yo,uuid:Al,hex4:$t,hex8:Ht,hex12:gi,Refer_To:Cl,Replaces:zo,call_id:Rl,replaces_param:Xn,to_tag:Qn,from_tag:Ti,early_flag:vi};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 _(i){t<s||(t>s&&(s=t,p=[]),p.push(i))}function d(){var i;return r.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 z(){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 Xe(){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 G(){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 ye(){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 Qe(){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=le(),l===null&&(l=ge()));l!==null;)e.push(l),l=Ee(),l===null&&(l=le(),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=le());u!==null;)l.push(u),u=he(),u===null&&(u=le());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 Ie(){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=le());u!==null;)l.push(u),u=he(),u===null&&(u=le());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 le(){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=we(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=wt(),l=l!==null?l:"",l!==null?(u=$s(),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 yl(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=we(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=wt(),l=l!==null?l:"",l!==null?(u=$s(),u!==null?(f=or(),f!==null?(_=mr(),_=_!==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 yl(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 we(){var i;return i=Ye(),i===null&&(i=ke()),i}function Ye(){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 ke(){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 wt(){var i,e,l,u,f,_;return u=t,f=t,i=ot(),i!==null?(_=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=gn(),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 ot(){var i,e;if(e=N(),e===null&&(e=ve(),e===null&&(e=mn())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(e=mn()));else i=null;return i}function mn(){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 gn(){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 $s(){var i,e,l,u,f;return u=t,i=Vt(),i!==null?(f=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=ms(),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 Vt(){var i,e;return e=t,i=ss(),i===null&&(i=nt(),i===null&&(i=Tn())),i!==null&&(i=function(l){return R.host=n.substring(t,l).toLowerCase(),R.host}(e)),i===null&&(t=e),i}function ss(){var i,e,l,u,f,_;for(u=t,f=t,i=[],_=t,e=Hs(),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=Hs(),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=vn(),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 Hs(){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 vn(){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 Tn(){var i,e,l,u,f;return u=t,f=t,n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i!==null?(e=Fs(),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 Fs(){var i,e,l,u,f,_,m,T,y,O,se,Oe,yt,bs,x,A;return bs=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?(Oe=":",t++):(Oe=null,h('":"')),Oe!==null?(yt=re(),yt!==null?i=[i,e,l,u,f,_,m,T,y,O,se,Oe,yt]:(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?(Oe=re(),Oe!==null?i=[i,e,l,u,f,_,m,T,y,O,se,Oe]:(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)}(bs)),i===null&&(t=bs),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=$t(),i!==null?(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e!==null?(l=$t(),l!==null?(n.charCodeAt(t)===46?(u=".",t++):(u=null,h('"."')),u!==null?(f=$t(),f!==null?(n.charCodeAt(t)===46?(_=".",t++):(_=null,h('"."')),_!==null?(m=$t(),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 $t(){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 ms(){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 or(){var i,e,l,u;for(i=[],u=t,n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e!==null?(l=En(),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=En(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function En(){var i;return i=yn(),i===null&&(i=ar(),i===null&&(i=ur(),i===null&&(i=cr(),i===null&&(i=fr(),i===null&&(i=hr(),i===null&&(i=_r())))))),i}function yn(){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 ar(){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 ur(){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=Ws(),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 cr(){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=jn(),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 fr(){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=Vt(),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 hr(){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 _r(){var i,e,l,u,f,_;return u=t,f=t,i=dr(),i!==null?(_=t,n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=pr(),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 dr(){var i,e,l;if(l=t,e=gs(),e!==null)for(i=[];e!==null;)i.push(e),e=gs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function pr(){var i,e,l;if(l=t,e=gs(),e!==null)for(i=[];e!==null;)i.push(e),e=gs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function gs(){var i;return i=vs(),i===null&&(i=N(),i===null&&(i=ve())),i}function vs(){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 mr(){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=Vs(),i!==null?(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=gr(),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 Vs(){var i,e;if(e=Ts(),e===null&&(e=N(),e===null&&(e=ve())),e!==null)for(i=[];e!==null;)i.push(e),e=Ts(),e===null&&(e=N(),e===null&&(e=ve()));else i=null;return i}function gr(){var i,e;for(i=[],e=Ts(),e===null&&(e=N(),e===null&&(e=ve()));e!==null;)i.push(e),e=Ts(),e===null&&(e=N(),e===null&&(e=ve()));return i}function Ts(){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 js(){var i;return i=Ys(),i===null&&(i=tl()),i}function tl(){var i,e,l,u,f,_;return _=t,i=Ws(),i!==null?(e=w(),e!==null?(l=vr(),l!==null?(u=w(),u!==null?(f=An(),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 vr(){var i;return i=Re(),i===null&&(i=Sn()),i}function Sn(){var i,e,l,u;return u=t,i=Cs(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Cn(),l===null&&(l=Gs()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Cn(){var i,e,l,u,f;return u=t,i=Tr(),i===null&&(i=Bs()),i!==null?(f=t,n.charCodeAt(t)===63?(e="?",t++):(e=null,h('"?"')),e!==null?(l=Ar(),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 Tr(){var i,e,l,u;return u=t,n.substr(t,2)==="//"?(i="//",t+=2):(i=null,h('"//"')),i!==null?(e=yr(),e!==null?(l=Bs(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Bs(){var i,e,l;return l=t,n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i!==null?(e=Er(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Gs(){var i,e,l,u;if(u=t,i=ys(),i!==null){for(e=[],l=Es();l!==null;)e.push(l),l=Es();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Es(){var i;return i=ie(),i===null&&(i=N(),i===null&&(i=ve())),i}function ys(){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 Er(){var i,e,l,u,f,_;if(f=t,i=Ks(),i!==null){for(e=[],_=t,n.charCodeAt(t)===47?(l="/",t++):(l=null,h('"/"')),l!==null?(u=Ks(),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=Ks(),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 Ks(){var i,e,l,u,f,_;for(f=t,i=[],e=ns();e!==null;)i.push(e),e=ns();if(i!==null){for(e=[],_=t,n.charCodeAt(t)===59?(l=";",t++):(l=null,h('";"')),l!==null?(u=Ss(),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=Ss(),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 Ss(){var i,e;for(i=[],e=ns();e!==null;)i.push(e),e=ns();return i}function ns(){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 Cs(){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 yr(){var i;return i=Sr(),i===null&&(i=Cr()),i}function Sr(){var i,e,l,u;return l=t,u=t,i=wt(),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=$s(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function Cr(){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 Ar(){var i,e;for(i=[],e=Es();e!==null;)i.push(e),e=Es();return i}function An(){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 Rn(){var i;return n.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,h('"INVITE"')),i}function Rr(){var i;return n.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,h('"ACK"')),i}function Ir(){var i;return n.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,h('"OPTIONS"')),i}function br(){var i;return n.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,h('"BYE"')),i}function wr(){var i;return n.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,h('"CANCEL"')),i}function Or(){var i;return n.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,h('"REGISTER"')),i}function Dr(){var i;return n.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,h('"SUBSCRIBE"')),i}function Nr(){var i;return n.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,h('"NOTIFY"')),i}function Ur(){var i;return n.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,h('"REFER"')),i}function Ws(){var i,e;return e=t,i=Rn(),i===null&&(i=Rr(),i===null&&(i=Ir(),i===null&&(i=br(),i===null&&(i=wr(),i===null&&(i=Or(),i===null&&(i=Dr(),i===null&&(i=Nr(),i===null&&(i=Ur(),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 Ys(){var i,e,l,u,f,_;return _=t,i=An(),i!==null?(e=w(),e!==null?(l=Pr(),l!==null?(u=w(),u!==null?(f=Mr(),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 Pr(){var i,e;return e=t,i=kr(),i!==null&&(i=function(l,u){R.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function kr(){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 Mr(){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 sl(){var i,e,l,u,f,_;if(f=t,i=Xs(),i!==null){for(e=[],_=t,l=ye(),l!==null?(u=Xs(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ye(),l!==null?(u=Xs(),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 Io(){var i,e,l,u,f,_;return u=t,f=t,i=Xe(),i!==null?(_=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?(l=Xe(),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 bo(){var i,e,l,u,f,_,m;if(f=t,i=Q(),i===null)if(_=t,i=In(),i!==null){for(e=[],m=t,l=ye(),l!==null?(u=In(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ye(),l!==null?(u=In(),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 In(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=Ot()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=As(),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=As(),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 rs(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 Ot(){var i,e,l,u,f;return f=t,i=Dt(),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 Dt(){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=Ie()),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 As(){var i;return i=bn(),i===null&&(i=xr(),i===null&&(i=Ve())),i}function bn(){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=Bt(),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 xr(){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=jt(),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 jt(){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 Bt(){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 Ve(){var i,e,l,u,f,_;return u=t,f=t,i=U(),i!==null?(_=t,e=B(),e!==null?(l=je(),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 je(){var i;return i=U(),i===null&&(i=Vt(),i===null&&(i=Ce())),i}function nl(){var i,e,l,u,f,_;if(f=t,i=rl(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=wn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=wn(),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 rl(){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 wn(){var i;return i=On(),i===null&&(i=Ve()),i}function On(){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 il(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=ye(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ye(),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 wo(){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 Oo(){var i,e;return e=t,i=ll(),i!==null&&(i=function(l){R=n.substring(t,l)}(e)),i===null&&(t=e),i}function ll(){var i,e,l,u,f,_,m,T;if(m=t,i=Lr(),i!==null)if(e=G(),e!==null)if(l=Fr(),l!==null){for(u=[],T=t,f=ne(),f!==null?(_=Dn(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(_=Dn(),_!==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 Lr(){var i;return i=$r(),i===null&&(i=Hr()),i}function $r(){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=zs()))))),i}function Hr(){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=zs())),i}function zs(){var i;return i=U(),i===null&&(i=Js()),i}function Js(){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 Fr(){var i;return i=zs(),i===null&&(i=U()),i}function Dn(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=Nn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Nn(){var i;return i=U(),i===null&&(i=Ce()),i}function ol(){var i,e,l,u;return u=t,i=al(),i!==null?(e=me(),e!==null?(l=Ws(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function al(){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 ul(){var i,e;return e=t,i=jt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function Do(){var i,e,l,u,f,_,m;if(f=t,_=t,i=Xs(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ve(),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=Ve(),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 Xs(){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 Qs(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=Ot()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=qr(),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=qr(),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 rs(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function qr(){var i;return i=Zs(),i===null&&(i=Ve()),i}function Zs(){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 Vr(){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 No(){var i,e;return e=t,i=jt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function Uo(){var i,e,l,u,f,_,m,T,y,O;for(T=t,y=t,i=[],e=Dt();e!==null;)i.push(e),e=Dt();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=Ve(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);_!==null;)f.push(_),O=t,_=ne(),_!==null?(m=Ve(),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 rs(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=T),i}function Po(){var i;return i=jr(),i}function jr(){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=Gt(),l!==null){for(u=[],T=t,f=ye(),f!==null?(_=Gt(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ye(),f!==null?(_=Gt(),_!==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=Un()),i}function Un(){var i,e,l,u,f,_,m,T;if(m=t,i=U(),i!==null)if(e=me(),e!==null)if(l=Rs(),l!==null){for(u=[],T=t,f=ye(),f!==null?(_=Rs(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ye(),f!==null?(_=Rs(),_!==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 Rs(){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 Gt(){var i;return i=en(),i===null&&(i=Gr(),i===null&&(i=sn(),i===null&&(i=Wr(),i===null&&(i=Yr(),i===null&&(i=zr(),i===null&&(i=Jr(),i===null&&(i=Rs()))))))),i}function en(){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=Br(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Br(){var i,e;return e=t,i=Ie(),i!==null&&(i=function(l,u){R.realm=u}(e,i)),i===null&&(t=e),i}function Gr(){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=Qe(),l!==null)if(u=tn(),u!==null){if(f=[],y=t,m=w(),m!==null)for(_=[];m!==null;)_.push(m),m=w();else _=null;for(_!==null?(m=tn(),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=tn(),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 tn(){var i;return i=Sn(),i===null&&(i=Bs()),i}function sn(){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=Kr(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Kr(){var i,e;return e=t,i=Ie(),i!==null&&(i=function(l,u){R.nonce=u}(e,i)),i===null&&(t=e),i}function Wr(){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=Ie(),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 Yr(){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 zr(){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 Jr(){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=Qe(),l!==null){if(y=t,u=nn(),u!==null){for(f=[],O=t,n.charCodeAt(t)===44?(_=",",t++):(_=null,h('","')),_!==null?(m=nn(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);_!==null;)f.push(_),O=t,n.charCodeAt(t)===44?(_=",",t++):(_=null,h('","')),_!==null?(m=nn(),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 nn(){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 Pn(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=ye(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ye(),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 ko(){var i,e,l,u,f,_,m;if(f=t,_=t,i=kn(),i!==null){for(e=[],m=t,l=ye(),l!==null?(u=kn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ye(),l!==null?(u=kn(),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 kn(){var i,e,l,u,f,_,m;if(f=t,_=t,i=Ot(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ve(),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=Ve(),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 rs(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 Mn(){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=Xr(),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=Xr(),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 Xr(){var i;return i=xn(),i===null&&(i=Ve()),i}function xn(){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 cl(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=ye(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ye(),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 Mo(){var i,e,l,u,f,_;if(f=t,i=Ln(),i!==null){for(e=[],_=t,l=ye(),l!==null?(u=Ln(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ye(),l!==null?(u=Ln(),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 Ln(){var i,e,l,u,f,_;if(f=t,i=Ot(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Ve(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Ve(),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 $n(){var i,e,l,u,f,_;if(f=t,i=fl(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Hn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Hn(),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 fl(){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 Hn(){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=Fn(),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=jt(),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=jt(),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=Ve()))),i}function Fn(){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 hl(){var i;return i=j(),i=i!==null?i:"",i}function xo(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=ye(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ye(),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 Lo(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=Ot()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Qr(),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=Qr(),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 rs(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function Qr(){var i;return i=Zs(),i===null&&(i=Ve()),i}function Zr(){var i,e,l,u,f,_;if(f=t,i=qn(),i!==null){for(e=[],_=t,l=ye(),l!==null?(u=qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ye(),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 qn(){var i,e,l,u,f,_,m,T;if(m=t,i=ii(),i!==null)if(e=me(),e!==null)if(l=ai(),l!==null){for(u=[],T=t,f=ne(),f!==null?(_=Is(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(_=Is(),_!==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 Is(){var i;return i=Vn(),i===null&&(i=ei(),i===null&&(i=ti(),i===null&&(i=si(),i===null&&(i=ni(),i===null&&(i=Ve()))))),i}function Vn(){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=jn(),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 ei(){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=Vt(),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 ti(){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=Fs()),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 si(){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 ni(){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=ri(),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,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 ii(){var i,e,l,u,f,_;return _=t,i=li(),i!==null?(e=G(),e!==null?(l=U(),l!==null?(u=G(),u!==null?(f=oi(),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 li(){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 oi(){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 ai(){var i,e,l,u,f;return u=t,i=ui(),i!==null?(f=t,e=Te(),e!==null?(l=ci(),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 ui(){var i,e;return e=t,i=nt(),i===null&&(i=Tn(),i===null&&(i=ss())),i!==null&&(i=function(l){R.host=n.substring(t,l)}(e)),i===null&&(t=e),i}function ci(){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 jn(){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 fi(){var i;return i=jr(),i}function $o(){var i,e,l,u,f,_;if(f=t,i=_l(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Bn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Bn(),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 _l(){var i,e;return e=t,i=jt(),i!==null&&(i=function(l,u){R.expires=u}(e,i)),i===null&&(t=e),i}function Bn(){var i;return i=Gn(),i===null&&(i=Ve()),i}function Gn(){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 dl(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=pl(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function pl(){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 ml(){var i,e;for(i=[],e=C();e!==null;)i.push(e),e=C();return i}function Ho(){var i,e,l;return l=t,n.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,h('"uuid:"')),i!==null?(e=gl(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function gl(){var i,e,l,u,f,_,m,T,y,O,se;return O=t,se=t,i=Ut(),i!==null?(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e!==null?(l=Nt(),l!==null?(n.charCodeAt(t)===45?(u="-",t++):(u=null,h('"-"')),u!==null?(f=Nt(),f!==null?(n.charCodeAt(t)===45?(_="-",t++):(_=null,h('"-"')),_!==null?(m=Nt(),m!==null?(n.charCodeAt(t)===45?(T="-",t++):(T=null,h('"-"')),T!==null?(y=hi(),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(Oe,yt){R=n.substring(t+5,Oe)}(O,i[0])),i===null&&(t=O),i}function Nt(){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 Ut(){var i,e,l;return l=t,i=Nt(),i!==null?(e=Nt(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function hi(){var i,e,l,u;return u=t,i=Nt(),i!==null?(e=Nt(),e!==null?(l=Nt(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function vl(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=Ot()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ve(),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=Ve(),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 rs(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=f),i}function Fo(){var i,e,l,u,f,_;if(f=t,i=Tl(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Kn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Kn(),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 Tl(){var i,e,l,u,f,_;return u=t,f=t,i=Xe(),i!==null?(_=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?(l=Xe(),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 Kn(){var i;return i=Wn(),i===null&&(i=_i(),i===null&&(i=di(),i===null&&(i=Ve()))),i}function Wn(){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 _i(){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 di(){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 El(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 qo(){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 yl=ds(),rs=cu(),R={},b=a[o]();if(b===null||t!==n.length){var pi=Math.max(t,s),mi=pi<n.length?n.charAt(pi):null,Sl=qo();return new this.SyntaxError(El(p),mi,pi,Sl.line,Sl.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}()),ha}var _a,wc;function ds(){if(wc)return _a;wc=1;const c=De,r=mt(),n=es();return _a=class Lf{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 Lf(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}},_a}var Oc;function mt(){if(Oc)return Je;Oc=1;const c=De,r=ds(),n=es();Je.str_utf8_length=s=>unescape(encodeURIComponent(s)).length;const o=Je.isFunction=s=>s!==void 0?Object.prototype.toString.call(s)==="[object Function]":!1;Je.isString=s=>s!==void 0?Object.prototype.toString.call(s)==="[object String]":!1,Je.isDecimal=s=>!isNaN(s)&&parseFloat(s)===parseInt(s,10),Je.isEmpty=s=>s===null||s===""||s===void 0||Array.isArray(s)&&s.length===0||typeof s=="number"&&isNaN(s),Je.hasMethods=function(s,...p){for(const h of p)if(o(s[h]))return!1;return!0};const a=Je.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};Je.newTag=()=>a(10),Je.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)}),Je.hostType=s=>{if(s){if(s=n.parse(s,"host"),s!==-1)return s.host_type}else return};const t=Je.escapeUser=s=>encodeURIComponent(decodeURIComponent(s)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return Je.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},Je.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},Je.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},Je.getRandomTestNetIP=()=>{function s(p,h){return Math.floor(Math.random()*(h-p+1)+p)}return`192.0.2.${s(1,254)}`},Je.calculateMD5=s=>{function p(ge,Ee){return ge<<Ee|ge>>>32-Ee}function h(ge,Ee){const Ce=ge&2147483648,Ie=Ee&2147483648,he=ge&1073741824,le=Ee&1073741824,fe=(ge&1073741823)+(Ee&1073741823);return he&le?fe^2147483648^Ce^Ie:he|le?fe&1073741824?fe^3221225472^Ce^Ie:fe^1073741824^Ce^Ie:fe^Ce^Ie}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,Ie,he,le,fe){return ge=h(ge,h(h(d(Ee,Ce,Ie),he),fe)),h(p(ge,le),Ee)}function C(ge,Ee,Ce,Ie,he,le,fe){return ge=h(ge,h(h(g(Ee,Ce,Ie),he),fe)),h(p(ge,le),Ee)}function I(ge,Ee,Ce,Ie,he,le,fe){return ge=h(ge,h(h(v(Ee,Ce,Ie),he),fe)),h(p(ge,le),Ee)}function w(ge,Ee,Ce,Ie,he,le,fe){return ge=h(ge,h(h(E(Ee,Ce,Ie),he),fe)),h(p(ge,le),Ee)}function F(ge){let Ee;const Ce=ge.length,Ie=Ce+8,le=((Ie-Ie%64)/64+1)*16,fe=new Array(le-1);let Re=0,we=0;for(;we<Ce;)Ee=(we-we%4)/4,Re=we%4*8,fe[Ee]=fe[Ee]|ge.charCodeAt(we)<<Re,we++;return Ee=(we-we%4)/4,Re=we%4*8,fe[Ee]=fe[Ee]|128<<Re,fe[le-2]=Ce<<3,fe[le-1]=Ce>>>29,fe}function L(ge){let Ee="",Ce="",Ie,he;for(he=0;he<=3;he++)Ie=ge>>>he*8&255,Ce=`0${Ie.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 Ie=ge.charCodeAt(Ce);Ie<128?Ee+=String.fromCharCode(Ie):Ie>127&&Ie<2048?(Ee+=String.fromCharCode(Ie>>6|192),Ee+=String.fromCharCode(Ie&63|128)):(Ee+=String.fromCharCode(Ie>>12|224),Ee+=String.fromCharCode(Ie>>6&63|128),Ee+=String.fromCharCode(Ie&63|128))}return Ee}let N=[],H,ve,me,M,D,j,V,Y,$;const z=7,U=12,P=17,Z=22,Xe=5,Q=9,G=14,B=20,te=4,de=11,Ae=16,Ue=23,ye=6,ne=10,Te=15,Qe=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],z,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],z,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],z,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],z,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],Xe,4129170786),$=C($,j,V,Y,N[H+6],Q,3225465664),Y=C(Y,$,j,V,N[H+11],G,643717713),V=C(V,Y,$,j,N[H+0],B,3921069994),j=C(j,V,Y,$,N[H+5],Xe,3593408605),$=C($,j,V,Y,N[H+10],Q,38016083),Y=C(Y,$,j,V,N[H+15],G,3634488961),V=C(V,Y,$,j,N[H+4],B,3889429448),j=C(j,V,Y,$,N[H+9],Xe,568446438),$=C($,j,V,Y,N[H+14],Q,3275163606),Y=C(Y,$,j,V,N[H+3],G,4107603335),V=C(V,Y,$,j,N[H+8],B,1163531501),j=C(j,V,Y,$,N[H+13],Xe,2850285829),$=C($,j,V,Y,N[H+2],Q,4243563512),Y=C(Y,$,j,V,N[H+7],G,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],ye,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],Qe,4237533241),j=w(j,V,Y,$,N[H+12],ye,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],Qe,2240044497),j=w(j,V,Y,$,N[H+8],ye,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],Qe,1309151649),j=w(j,V,Y,$,N[H+4],ye,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],Qe,3951481745),j=h(j,ve),V=h(V,me),Y=h(Y,M),$=h($,D);return(L(j)+L(V)+L(Y)+L($)).toLowerCase()},Je.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()}},Je.cloneArray=s=>s&&s.slice()||[],Je.cloneObject=(s,p={})=>s&&Object.assign({},s)||p,Je}const $f=Lt,rm=lt,dt=De,et=mt(),Dc=cu(),im=es(),da=new rm("SIPMessage");class Ao{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=et.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",dt.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 Dc(p,d,h),this.setHeader("to",this.to.toString());const g=a.from_uri||o.configuration.uri,v={tag:a.from_tag||et.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 Dc(g,E,v),this.setHeader("from",this.from.toString());const S=a.call_id||o.configuration.jssip_id+et.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[et.headerize(r)]=Array.isArray(n)?n:[n]}getHeader(r){const n=this.headers[et.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[et.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[et.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=$f.parse(this.body||""),this.sdp)}toString(){let r=`${this.method} ${this.ruri} SIP/2.0\r
|
76
|
-
`;for(const a in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,a))for(const t of this.headers[a])
|
77
|
-
`;for(const a of this.extraHeaders)
|
78
|
-
`;const
|
79
|
-
`,
|
80
|
-
`,
|
81
|
-
`,this.body){const a=
|
74
|
+
`,t+=2):(i=null,_('"\\r\\n"')),i}function g(){var i;return/^[0-9]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[0-9]")),i}function T(){var i;return/^[a-zA-Z]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[a-zA-Z]")),i}function E(){var i;return/^[0-9a-fA-F]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[0-9a-fA-F]")),i}function y(){var i;return i=I(),i===null&&(i=$()),i}function A(){var i;return/^[\0-\xFF]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[\\0-\\xFF]")),i}function R(){var i;return/^["]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_('["]')),i}function I(){var i;return r.charCodeAt(t)===32?(i=" ",t++):(i=null,_('" "')),i}function $(){var i;return r.charCodeAt(t)===9?(i=" ",t++):(i=null,_('"\\t"')),i}function L(){var i;return/^[a-zA-Z0-9]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[a-zA-Z0-9]")),i}function ae(){var i;return r.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(r.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(r.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(r.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(r.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(r.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(r.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(r.charCodeAt(t)===44?(i=",",t++):(i=null,_('","'))))))))))),i}function N(){var i;return i=L(),i===null&&(i=F()),i}function F(){var i;return r.charCodeAt(t)===45?(i="-",t++):(i=null,_('"-"')),i===null&&(r.charCodeAt(t)===95?(i="_",t++):(i=null,_('"_"')),i===null&&(r.charCodeAt(t)===46?(i=".",t++):(i=null,_('"."')),i===null&&(r.charCodeAt(t)===33?(i="!",t++):(i=null,_('"!"')),i===null&&(r.charCodeAt(t)===126?(i="~",t++):(i=null,_('"~"')),i===null&&(r.charCodeAt(t)===42?(i="*",t++):(i=null,_('"*"')),i===null&&(r.charCodeAt(t)===39?(i="'",t++):(i=null,_(`"'"`)),i===null&&(r.charCodeAt(t)===40?(i="(",t++):(i=null,_('"("')),i===null&&(r.charCodeAt(t)===41?(i=")",t++):(i=null,_('")"')))))))))),i}function Se(){var i,e,l,u,f;return u=t,f=t,r.charCodeAt(t)===37?(i="%",t++):(i=null,_('"%"')),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(h,m){return m.join("")}(u,i)),i===null&&(t=u),i}function ve(){var i,e,l,u,f,h;for(u=t,f=t,h=t,i=[],e=y();e!==null;)i.push(e),e=y();if(i!==null?(e=d(),e!==null?i=[i,e]:(i=null,t=h)):(i=null,t=h),i=i!==null?i:"",i!==null){if(l=y(),l!==null)for(e=[];l!==null;)e.push(l),l=y();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=ve(),i=i!==null?i:"",i}function D(){var i,e,l,u,f;for(u=t,f=t,i=[],e=I(),e===null&&(e=$());e!==null;)i.push(e),e=I(),e===null&&(e=$());return i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),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(h){return":"}()),i===null&&(t=u),i}function q(){var i,e,l,u,f,h,m;if(f=t,h=t,e=j(),e!==null)for(i=[];e!==null;)i.push(e),e=j();else i=null;if(i!==null){for(e=[],m=t,l=[],u=ve();u!==null;)l.push(u),u=ve();for(l!==null?(u=j(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;){for(e.push(l),m=t,l=[],u=ve();u!==null;)l.push(u),u=ve();l!==null?(u=j(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m)}e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(v){return r.substring(t,v)}(f)),i===null&&(t=f),i}function j(){var i;return/^[!-~]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[!-~]")),i===null&&(i=z()),i}function z(){var i;return/^[\x80-\uFFFF]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[\\x80-\\uFFFF]")),i}function H(){var i;return/^[\x80-\xBF]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[\\x80-\\xBF]")),i}function J(){var i;return i=g(),i===null&&(/^[a-f]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[a-f]"))),i}function U(){var i,e,l;if(l=t,e=L(),e===null&&(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(r.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(r.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(r.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(r.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(r.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(r.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(r.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(r.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(r.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(r.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(r.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(r.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"'))))))))))));else i=null;return i!==null&&(i=function(u){return r.substring(t,u)}(l)),i===null&&(t=l),i}function P(){var i,e,l;if(l=t,e=L(),e===null&&(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(r.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(r.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(r.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(r.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(r.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(r.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(r.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(r.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(r.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(r.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(r.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(r.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')))))))))));else i=null;return i!==null&&(i=function(u){return r.substring(t,u)}(l)),i===null&&(t=l),i}function se(){var i;return r.charCodeAt(t)===40?(i="(",t++):(i=null,_('"("')),i===null&&(r.charCodeAt(t)===41?(i=")",t++):(i=null,_('")"')),i===null&&(r.charCodeAt(t)===60?(i="<",t++):(i=null,_('"<"')),i===null&&(r.charCodeAt(t)===62?(i=">",t++):(i=null,_('">"')),i===null&&(r.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(r.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')),i===null&&(r.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(r.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(r.charCodeAt(t)===92?(i="\\",t++):(i=null,_('"\\\\"')),i===null&&(i=R(),i===null&&(r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(r.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i===null&&(r.charCodeAt(t)===93?(i="]",t++):(i=null,_('"]"')),i===null&&(r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(r.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(r.charCodeAt(t)===123?(i="{",t++):(i=null,_('"{"')),i===null&&(r.charCodeAt(t)===125?(i="}",t++):(i=null,_('"}"')),i===null&&(i=I(),i===null&&(i=$())))))))))))))))))),i}function et(){var i,e,l;if(l=t,e=L(),e===null&&(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(r.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(r.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(r.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(r.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(r.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(r.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')),e===null&&(r.charCodeAt(t)===40?(e="(",t++):(e=null,_('"("')),e===null&&(r.charCodeAt(t)===41?(e=")",t++):(e=null,_('")"')),e===null&&(r.charCodeAt(t)===60?(e="<",t++):(e=null,_('"<"')),e===null&&(r.charCodeAt(t)===62?(e=">",t++):(e=null,_('">"')),e===null&&(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(r.charCodeAt(t)===92?(e="\\",t++):(e=null,_('"\\\\"')),e===null&&(e=R(),e===null&&(r.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e===null&&(r.charCodeAt(t)===91?(e="[",t++):(e=null,_('"["')),e===null&&(r.charCodeAt(t)===93?(e="]",t++):(e=null,_('"]"')),e===null&&(r.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e===null&&(r.charCodeAt(t)===123?(e="{",t++):(e=null,_('"{"')),e===null&&(r.charCodeAt(t)===125?(e="}",t++):(e=null,_('"}"'))))))))))))))))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(r.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(r.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(r.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(r.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(r.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(r.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')),e===null&&(r.charCodeAt(t)===40?(e="(",t++):(e=null,_('"("')),e===null&&(r.charCodeAt(t)===41?(e=")",t++):(e=null,_('")"')),e===null&&(r.charCodeAt(t)===60?(e="<",t++):(e=null,_('"<"')),e===null&&(r.charCodeAt(t)===62?(e=">",t++):(e=null,_('">"')),e===null&&(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(r.charCodeAt(t)===92?(e="\\",t++):(e=null,_('"\\\\"')),e===null&&(e=R(),e===null&&(r.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e===null&&(r.charCodeAt(t)===91?(e="[",t++):(e=null,_('"["')),e===null&&(r.charCodeAt(t)===93?(e="]",t++):(e=null,_('"]"')),e===null&&(r.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e===null&&(r.charCodeAt(t)===123?(e="{",t++):(e=null,_('"{"')),e===null&&(r.charCodeAt(t)===125?(e="}",t++):(e=null,_('"}"')))))))))))))))))))))))));else i=null;return i!==null&&(i=function(u){return r.substring(t,u)}(l)),i===null&&(t=l),i}function ee(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),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(h){return"*"}()),i===null&&(t=u),i}function W(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),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(h){return"/"}()),i===null&&(t=u),i}function B(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),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(h){return"="}()),i===null&&(t=u),i}function re(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===40?(e="(",t++):(e=null,_('"("')),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(h){return"("}()),i===null&&(t=u),i}function ge(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===41?(e=")",t++):(e=null,_('")"')),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(h){return")"}()),i===null&&(t=u),i}function be(){var i,e,l,u;return l=t,u=t,r.charCodeAt(t)===62?(i=">",t++):(i=null,_('">"')),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 xe(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(r.charCodeAt(t)===60?(e="<",t++):(e=null,_('"<"')),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 Ce(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===44?(e=",",t++):(e=null,_('","')),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(h){return","}()),i===null&&(t=u),i}function le(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),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(h){return";"}()),i===null&&(t=u),i}function ye(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),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(h){return":"}()),i===null&&(t=u),i}function tt(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(e=R(),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 it(){var i,e,l,u;return l=t,u=t,i=R(),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 Ee(){var i,e,l,u;if(u=t,i=re(),i!==null){for(e=[],l=Ae(),l===null&&(l=ue(),l===null&&(l=Ee()));l!==null;)e.push(l),l=Ae(),l===null&&(l=ue(),l===null&&(l=Ee()));e!==null?(l=ge(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)}else i=null,t=u;return i}function Ae(){var i;return/^[!-']/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[!-']")),i===null&&(/^[*-[]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[*-[]")),i===null&&(/^[\]-~]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[\\]-~]")),i===null&&(i=z(),i===null&&(i=ve())))),i}function Ie(){var i,e,l,u,f,h;if(f=t,h=t,i=M(),i!==null)if(e=R(),e!==null){for(l=[],u=pe(),u===null&&(u=ue());u!==null;)l.push(u),u=pe(),u===null&&(u=ue());l!==null?(u=R(),u!==null?i=[i,e,l,u]:(i=null,t=h)):(i=null,t=h)}else i=null,t=h;else i=null,t=h;return i!==null&&(i=function(m){return r.substring(t,m)}(f)),i===null&&(t=f),i}function Oe(){var i,e,l,u,f,h;if(f=t,h=t,i=M(),i!==null)if(e=R(),e!==null){for(l=[],u=pe(),u===null&&(u=ue());u!==null;)l.push(u),u=pe(),u===null&&(u=ue());l!==null?(u=R(),u!==null?i=[i,e,l,u]:(i=null,t=h)):(i=null,t=h)}else i=null,t=h;else i=null,t=h;return i!==null&&(i=function(m){var v=r.substring(t,m).trim();return v.substring(1,v.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(f)),i===null&&(t=f),i}function pe(){var i;return i=ve(),i===null&&(r.charCodeAt(t)===33?(i="!",t++):(i=null,_('"!"')),i===null&&(/^[#-[]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[#-[]")),i===null&&(/^[\]-~]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[\\]-~]")),i===null&&(i=z())))),i}function ue(){var i,e,l;return l=t,r.charCodeAt(t)===92?(i="\\",t++):(i=null,_('"\\\\"')),i!==null?(/^[\0-\t]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[\\0-\\t]")),e===null&&(/^[\x0B-\f]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[\\x0B-\\f]")),e===null&&(/^[\x0E-]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[\\x0E-]")))),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function de(){var i,e,l,u,f,h;return f=t,h=t,i=De(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Mt(),l=l!==null?l:"",l!==null?(u=js(),u!==null?i=[i,e,l,u]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i!==null&&(i=function(m){try{b.uri=new bl(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}}()),i===null&&(t=f),i}function we(){var i,e,l,u,f,h,m,v;return m=t,v=t,i=De(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Mt(),l=l!==null?l:"",l!==null?(u=js(),u!==null?(f=_r(),f!==null?(h=Sr(),h=h!==null?h:"",h!==null?i=[i,e,l,u,f,h]:(i=null,t=v)):(i=null,t=v)):(i=null,t=v)):(i=null,t=v)):(i=null,t=v)):(i=null,t=v),i!==null&&(i=function(S){try{b.uri=new bl(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,o==="SIP_URI"&&(b=b.uri)}catch{b=-1}}()),i===null&&(t=m),i}function De(){var i;return i=Xe(),i===null&&(i=Le()),i}function Xe(){var i,e;return e=t,r.substr(t,4).toLowerCase()==="sips"?(i=r.substr(t,4),t+=4):(i=null,_('"sips"')),i!==null&&(i=function(l,u){b.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Le(){var i,e;return e=t,r.substr(t,3).toLowerCase()==="sip"?(i=r.substr(t,3),t+=3):(i=null,_('"sip"')),i!==null&&(i=function(l,u){b.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Mt(){var i,e,l,u,f,h;return u=t,f=t,i=_t(),i!==null?(h=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=yn(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?(r.charCodeAt(t)===64?(l="@",t++):(l=null,_('"@"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){b.user=decodeURIComponent(r.substring(t-1,m))}(u)),i===null&&(t=u),i}function _t(){var i,e;if(e=N(),e===null&&(e=Se(),e===null&&(e=Sn())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=Se(),e===null&&(e=Sn()));else i=null;return i}function Sn(){var i;return r.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(r.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(r.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(r.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(r.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')),i===null&&(r.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"'))))))))),i}function yn(){var i,e,l;for(l=t,i=[],e=N(),e===null&&(e=Se(),e===null&&(r.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(r.charCodeAt(t)===44?(e=",",t++):(e=null,_('","'))))))));e!==null;)i.push(e),e=N(),e===null&&(e=Se(),e===null&&(r.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(r.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(r.charCodeAt(t)===44?(e=",",t++):(e=null,_('","'))))))));return i!==null&&(i=function(u){b.password=r.substring(t,u)}(l)),i===null&&(t=l),i}function js(){var i,e,l,u,f;return u=t,i=Yt(),i!==null?(f=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Es(),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 Yt(){var i,e;return e=t,i=ls(),i===null&&(i=lt(),i===null&&(i=Cn())),i!==null&&(i=function(l){return b.host=r.substring(t,l).toLowerCase(),b.host}(e)),i===null&&(t=e),i}function ls(){var i,e,l,u,f,h;for(u=t,f=t,i=[],h=t,e=qs(),e!==null?(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h);e!==null;)i.push(e),h=t,e=qs(),e!==null?(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h);return i!==null?(e=An(),e!==null?(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),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 b.host_type="domain",r.substring(t,m)}(u)),i===null&&(t=u),i}function qs(){var i,e,l,u;if(u=t,i=L(),i!==null){for(e=[],l=L(),l===null&&(r.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(r.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(r.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(r.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function An(){var i,e,l,u;if(u=t,i=T(),i!==null){for(e=[],l=L(),l===null&&(r.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(r.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(r.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(r.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Cn(){var i,e,l,u,f;return u=t,f=t,r.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i!==null?(e=Bs(),e!==null?(r.charCodeAt(t)===93?(l="]",t++):(l=null,_('"]"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return b.host_type="IPv6",r.substring(t,h)}(u)),i===null&&(t=u),i}function Bs(){var i,e,l,u,f,h,m,v,S,O,ie,Ne,Rt,Ns,k,C;return Ns=t,k=t,i=me(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?(r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?(r.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=me(),m!==null?(r.charCodeAt(t)===58?(v=":",t++):(v=null,_('":"')),v!==null?(S=me(),S!==null?(r.charCodeAt(t)===58?(O=":",t++):(O=null,_('":"')),O!==null?(ie=me(),ie!==null?(r.charCodeAt(t)===58?(Ne=":",t++):(Ne=null,_('":"')),Ne!==null?(Rt=oe(),Rt!==null?i=[i,e,l,u,f,h,m,v,S,O,ie,Ne,Rt]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,r.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=me(),e!==null?(r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?(r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=me(),v!==null?(r.charCodeAt(t)===58?(S=":",t++):(S=null,_('":"')),S!==null?(O=me(),O!==null?(r.charCodeAt(t)===58?(ie=":",t++):(ie=null,_('":"')),ie!==null?(Ne=oe(),Ne!==null?i=[i,e,l,u,f,h,m,v,S,O,ie,Ne]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,r.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=me(),e!==null?(r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?(r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=me(),v!==null?(r.charCodeAt(t)===58?(S=":",t++):(S=null,_('":"')),S!==null?(O=oe(),O!==null?i=[i,e,l,u,f,h,m,v,S,O]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,r.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=me(),e!==null?(r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?(r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?i=[i,e,l,u,f,h,m,v]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,r.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=me(),e!==null?(r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?(r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=oe(),h!==null?i=[i,e,l,u,f,h]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,r.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=me(),e!==null?(r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=oe(),u!==null?i=[i,e,l,u]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,r.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=oe(),e!==null?i=[i,e]:(i=null,t=k)):(i=null,t=k),i===null&&(k=t,r.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=me(),e!==null?i=[i,e]:(i=null,t=k)):(i=null,t=k),i===null&&(k=t,i=me(),i!==null?(r.substr(t,2)==="::"?(e="::",t+=2):(e=null,_('"::"')),e!==null?(l=me(),l!==null?(r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?(r.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=me(),m!==null?(r.charCodeAt(t)===58?(v=":",t++):(v=null,_('":"')),v!==null?(S=me(),S!==null?(r.charCodeAt(t)===58?(O=":",t++):(O=null,_('":"')),O!==null?(ie=oe(),ie!==null?i=[i,e,l,u,f,h,m,v,S,O,ie]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,i=me(),i!==null?(C=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=C)):(e=null,t=C),e=e!==null?e:"",e!==null?(r.substr(t,2)==="::"?(l="::",t+=2):(l=null,_('"::"')),l!==null?(u=me(),u!==null?(r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=me(),v!==null?(r.charCodeAt(t)===58?(S=":",t++):(S=null,_('":"')),S!==null?(O=oe(),O!==null?i=[i,e,l,u,f,h,m,v,S,O]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,i=me(),i!==null?(C=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=C)):(e=null,t=C),e=e!==null?e:"",e!==null?(C=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=C)):(l=null,t=C),l=l!==null?l:"",l!==null?(r.substr(t,2)==="::"?(u="::",t+=2):(u=null,_('"::"')),u!==null?(f=me(),f!==null?(r.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=me(),m!==null?(r.charCodeAt(t)===58?(v=":",t++):(v=null,_('":"')),v!==null?(S=oe(),S!==null?i=[i,e,l,u,f,h,m,v,S]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,i=me(),i!==null?(C=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=C)):(e=null,t=C),e=e!==null?e:"",e!==null?(C=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=C)):(l=null,t=C),l=l!==null?l:"",l!==null?(C=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=C)):(u=null,t=C),u=u!==null?u:"",u!==null?(r.substr(t,2)==="::"?(f="::",t+=2):(f=null,_('"::"')),f!==null?(h=me(),h!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?i=[i,e,l,u,f,h,m,v]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,i=me(),i!==null?(C=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=C)):(e=null,t=C),e=e!==null?e:"",e!==null?(C=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=C)):(l=null,t=C),l=l!==null?l:"",l!==null?(C=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=C)):(u=null,t=C),u=u!==null?u:"",u!==null?(C=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?f=[f,h]:(f=null,t=C)):(f=null,t=C),f=f!==null?f:"",f!==null?(r.substr(t,2)==="::"?(h="::",t+=2):(h=null,_('"::"')),h!==null?(m=oe(),m!==null?i=[i,e,l,u,f,h,m]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,i=me(),i!==null?(C=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=C)):(e=null,t=C),e=e!==null?e:"",e!==null?(C=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=C)):(l=null,t=C),l=l!==null?l:"",l!==null?(C=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=C)):(u=null,t=C),u=u!==null?u:"",u!==null?(C=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?f=[f,h]:(f=null,t=C)):(f=null,t=C),f=f!==null?f:"",f!==null?(C=t,r.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=me(),m!==null?h=[h,m]:(h=null,t=C)):(h=null,t=C),h=h!==null?h:"",h!==null?(r.substr(t,2)==="::"?(m="::",t+=2):(m=null,_('"::"')),m!==null?(v=me(),v!==null?i=[i,e,l,u,f,h,m,v]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k),i===null&&(k=t,i=me(),i!==null?(C=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=C)):(e=null,t=C),e=e!==null?e:"",e!==null?(C=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=C)):(l=null,t=C),l=l!==null?l:"",l!==null?(C=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=C)):(u=null,t=C),u=u!==null?u:"",u!==null?(C=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?f=[f,h]:(f=null,t=C)):(f=null,t=C),f=f!==null?f:"",f!==null?(C=t,r.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=me(),m!==null?h=[h,m]:(h=null,t=C)):(h=null,t=C),h=h!==null?h:"",h!==null?(C=t,r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=me(),v!==null?m=[m,v]:(m=null,t=C)):(m=null,t=C),m=m!==null?m:"",m!==null?(r.substr(t,2)==="::"?(v="::",t+=2):(v=null,_('"::"')),v!==null?i=[i,e,l,u,f,h,m,v]:(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k)):(i=null,t=k))))))))))))))),i!==null&&(i=function(Te){return b.host_type="IPv6",r.substring(t,Te)}(Ns)),i===null&&(t=Ns),i}function me(){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 oe(){var i,e,l,u;return u=t,i=me(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(i=lt()),i}function lt(){var i,e,l,u,f,h,m,v,S;return v=t,S=t,i=Bt(),i!==null?(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e!==null?(l=Bt(),l!==null?(r.charCodeAt(t)===46?(u=".",t++):(u=null,_('"."')),u!==null?(f=Bt(),f!==null?(r.charCodeAt(t)===46?(h=".",t++):(h=null,_('"."')),h!==null?(m=Bt(),m!==null?i=[i,e,l,u,f,h,m]:(i=null,t=S)):(i=null,t=S)):(i=null,t=S)):(i=null,t=S)):(i=null,t=S)):(i=null,t=S)):(i=null,t=S),i!==null&&(i=function(O){return b.host_type="IPv4",r.substring(t,O)}(v)),i===null&&(t=v),i}function Bt(){var i,e,l,u;return u=t,r.substr(t,2)==="25"?(i="25",t+=2):(i=null,_('"25"')),i!==null?(/^[0-5]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[0-5]")),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i===null&&(u=t,r.charCodeAt(t)===50?(i="2",t++):(i=null,_('"2"')),i!==null?(/^[0-4]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[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,r.charCodeAt(t)===49?(i="1",t++):(i=null,_('"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(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[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 Es(){var i,e,l,u,f,h,m;return h=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(v,S){return S=parseInt(S.join("")),b.port=S,S}(h,i)),i===null&&(t=h),i}function _r(){var i,e,l,u;for(i=[],u=t,r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=Rn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);e!==null;)i.push(e),u=t,r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=Rn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function Rn(){var i;return i=In(),i===null&&(i=hr(),i===null&&(i=dr(),i===null&&(i=pr(),i===null&&(i=mr(),i===null&&(i=gr(),i===null&&(i=Tr())))))),i}function In(){var i,e,l,u;return l=t,u=t,r.substr(t,10).toLowerCase()==="transport="?(i=r.substr(t,10),t+=10):(i=null,_('"transport="')),i!==null?(r.substr(t,3).toLowerCase()==="udp"?(e=r.substr(t,3),t+=3):(e=null,_('"udp"')),e===null&&(r.substr(t,3).toLowerCase()==="tcp"?(e=r.substr(t,3),t+=3):(e=null,_('"tcp"')),e===null&&(r.substr(t,4).toLowerCase()==="sctp"?(e=r.substr(t,4),t+=4):(e=null,_('"sctp"')),e===null&&(r.substr(t,3).toLowerCase()==="tls"?(e=r.substr(t,3),t+=3):(e=null,_('"tls"')),e===null&&(e=U())))),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){b.uri_params||(b.uri_params={}),b.uri_params.transport=h.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function hr(){var i,e,l,u;return l=t,u=t,r.substr(t,5).toLowerCase()==="user="?(i=r.substr(t,5),t+=5):(i=null,_('"user="')),i!==null?(r.substr(t,5).toLowerCase()==="phone"?(e=r.substr(t,5),t+=5):(e=null,_('"phone"')),e===null&&(r.substr(t,2).toLowerCase()==="ip"?(e=r.substr(t,2),t+=2):(e=null,_('"ip"')),e===null&&(e=U())),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){b.uri_params||(b.uri_params={}),b.uri_params.user=h.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function dr(){var i,e,l,u;return l=t,u=t,r.substr(t,7).toLowerCase()==="method="?(i=r.substr(t,7),t+=7):(i=null,_('"method="')),i!==null?(e=Xs(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){b.uri_params||(b.uri_params={}),b.uri_params.method=h}(l,i[1])),i===null&&(t=l),i}function pr(){var i,e,l,u;return l=t,u=t,r.substr(t,4).toLowerCase()==="ttl="?(i=r.substr(t,4),t+=4):(i=null,_('"ttl="')),i!==null?(e=Yn(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){b.params||(b.params={}),b.params.ttl=h}(l,i[1])),i===null&&(t=l),i}function mr(){var i,e,l,u;return l=t,u=t,r.substr(t,6).toLowerCase()==="maddr="?(i=r.substr(t,6),t+=6):(i=null,_('"maddr="')),i!==null?(e=Yt(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){b.uri_params||(b.uri_params={}),b.uri_params.maddr=h}(l,i[1])),i===null&&(t=l),i}function gr(){var i,e,l,u,f,h;return u=t,f=t,r.substr(t,2).toLowerCase()==="lr"?(i=r.substr(t,2),t+=2):(i=null,_('"lr"')),i!==null?(h=t,r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=U(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){b.uri_params||(b.uri_params={}),b.uri_params.lr=void 0}()),i===null&&(t=u),i}function Tr(){var i,e,l,u,f,h;return u=t,f=t,i=vr(),i!==null?(h=t,r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=Er(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,v,S){b.uri_params||(b.uri_params={}),typeof S>"u"?S=void 0:S=S[1],b.uri_params[v.toLowerCase()]=S}(u,i[0],i[1])),i===null&&(t=u),i}function vr(){var i,e,l;if(l=t,e=Ss(),e!==null)for(i=[];e!==null;)i.push(e),e=Ss();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function Er(){var i,e,l;if(l=t,e=Ss(),e!==null)for(i=[];e!==null;)i.push(e),e=Ss();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function Ss(){var i;return i=ys(),i===null&&(i=N(),i===null&&(i=Se())),i}function ys(){var i;return r.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i===null&&(r.charCodeAt(t)===93?(i="]",t++):(i=null,_('"]"')),i===null&&(r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(r.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(r.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(r.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(r.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')))))))),i}function Sr(){var i,e,l,u,f,h,m;if(h=t,r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i!==null)if(e=Gs(),e!==null){for(l=[],m=t,r.charCodeAt(t)===38?(u="&",t++):(u=null,_('"&"')),u!==null?(f=Gs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);u!==null;)l.push(u),m=t,r.charCodeAt(t)===38?(u="&",t++):(u=null,_('"&"')),u!==null?(f=Gs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);l!==null?i=[i,e,l]:(i=null,t=h)}else i=null,t=h;else i=null,t=h;return i}function Gs(){var i,e,l,u,f;return u=t,f=t,i=Ws(),i!==null?(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=yr(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m,v){m=m.join("").toLowerCase(),v=v.join(""),b.uri_headers||(b.uri_headers={}),b.uri_headers[m]?b.uri_headers[m].push(v):b.uri_headers[m]=[v]}(u,i[0],i[2])),i===null&&(t=u),i}function Ws(){var i,e;if(e=As(),e===null&&(e=N(),e===null&&(e=Se())),e!==null)for(i=[];e!==null;)i.push(e),e=As(),e===null&&(e=N(),e===null&&(e=Se()));else i=null;return i}function yr(){var i,e;for(i=[],e=As(),e===null&&(e=N(),e===null&&(e=Se()));e!==null;)i.push(e),e=As(),e===null&&(e=N(),e===null&&(e=Se()));return i}function As(){var i;return r.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i===null&&(r.charCodeAt(t)===93?(i="]",t++):(i=null,_('"]"')),i===null&&(r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(r.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(r.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(r.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')))))))),i}function Ks(){var i;return i=Qs(),i===null&&(i=ol()),i}function ol(){var i,e,l,u,f,h;return h=t,i=Xs(),i!==null?(e=I(),e!==null?(l=Ar(),l!==null?(u=I(),u!==null?(f=On(),f!==null?i=[i,e,l,u,f]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i}function Ar(){var i;return i=we(),i===null&&(i=bn()),i}function bn(){var i,e,l,u;return u=t,i=bs(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=wn(),l===null&&(l=zs()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function wn(){var i,e,l,u,f;return u=t,i=Cr(),i===null&&(i=Ys()),i!==null?(f=t,r.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e!==null?(l=Or(),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 Cr(){var i,e,l,u;return u=t,r.substr(t,2)==="//"?(i="//",t+=2):(i=null,_('"//"')),i!==null?(e=Ir(),e!==null?(l=Ys(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ys(){var i,e,l;return l=t,r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i!==null?(e=Rr(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function zs(){var i,e,l,u;if(u=t,i=Rs(),i!==null){for(e=[],l=Cs();l!==null;)e.push(l),l=Cs();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Cs(){var i;return i=ae(),i===null&&(i=N(),i===null&&(i=Se())),i}function Rs(){var i;return i=N(),i===null&&(i=Se(),i===null&&(r.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(r.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(r.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(r.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(r.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(r.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(r.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(r.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')))))))))))),i}function Rr(){var i,e,l,u,f,h;if(f=t,i=Js(),i!==null){for(e=[],h=t,r.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=Js(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,r.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=Js(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Js(){var i,e,l,u,f,h;for(f=t,i=[],e=os();e!==null;)i.push(e),e=os();if(i!==null){for(e=[],h=t,r.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=Is(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,r.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=Is(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Is(){var i,e;for(i=[],e=os();e!==null;)i.push(e),e=os();return i}function os(){var i;return i=N(),i===null&&(i=Se(),i===null&&(r.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(r.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(r.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(r.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(r.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(r.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(r.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')))))))))),i}function bs(){var i,e,l,u,f;if(u=t,f=t,i=T(),i!==null){for(e=[],l=T(),l===null&&(l=g(),l===null&&(r.charCodeAt(t)===43?(l="+",t++):(l=null,_('"+"')),l===null&&(r.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."'))))));l!==null;)e.push(l),l=T(),l===null&&(l=g(),l===null&&(r.charCodeAt(t)===43?(l="+",t++):(l=null,_('"+"')),l===null&&(r.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."'))))));e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i!==null&&(i=function(h){b.scheme=r.substring(t,h)}(u)),i===null&&(t=u),i}function Ir(){var i;return i=br(),i===null&&(i=wr()),i}function br(){var i,e,l,u;return l=t,u=t,i=Mt(),i!==null?(r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i=i!==null?i:"",i!==null?(e=js(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function wr(){var i,e;if(e=N(),e===null&&(e=Se(),e===null&&(r.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(r.charCodeAt(t)===44?(e=",",t++):(e=null,_('","')),e===null&&(r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e===null&&(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e===null&&(r.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=Se(),e===null&&(r.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(r.charCodeAt(t)===44?(e=",",t++):(e=null,_('","')),e===null&&(r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e===null&&(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e===null&&(r.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(r.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')))))))))));else i=null;return i}function Or(){var i,e;for(i=[],e=Cs();e!==null;)i.push(e),e=Cs();return i}function On(){var i,e,l,u,f,h,m,v;if(m=t,v=t,r.substr(t,3).toLowerCase()==="sip"?(i=r.substr(t,3),t+=3):(i=null,_('"SIP"')),i!==null)if(r.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e!==null){if(u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;if(l!==null)if(r.charCodeAt(t)===46?(u=".",t++):(u=null,_('"."')),u!==null){if(h=g(),h!==null)for(f=[];h!==null;)f.push(h),h=g();else f=null;f!==null?i=[i,e,l,u,f]:(i=null,t=v)}else i=null,t=v;else i=null,t=v}else i=null,t=v;else i=null,t=v;return i!==null&&(i=function(S){b.sip_version=r.substring(t,S)}(m)),i===null&&(t=m),i}function Dn(){var i;return r.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,_('"INVITE"')),i}function Dr(){var i;return r.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,_('"ACK"')),i}function Nr(){var i;return r.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,_('"OPTIONS"')),i}function Ur(){var i;return r.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,_('"BYE"')),i}function Pr(){var i;return r.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,_('"CANCEL"')),i}function xr(){var i;return r.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,_('"REGISTER"')),i}function Mr(){var i;return r.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,_('"SUBSCRIBE"')),i}function kr(){var i;return r.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,_('"NOTIFY"')),i}function Lr(){var i;return r.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,_('"REFER"')),i}function Xs(){var i,e;return e=t,i=Dn(),i===null&&(i=Dr(),i===null&&(i=Nr(),i===null&&(i=Ur(),i===null&&(i=Pr(),i===null&&(i=xr(),i===null&&(i=Mr(),i===null&&(i=kr(),i===null&&(i=Lr(),i===null&&(i=U()))))))))),i!==null&&(i=function(l){return b.method=r.substring(t,l),b.method}(e)),i===null&&(t=e),i}function Qs(){var i,e,l,u,f,h;return h=t,i=On(),i!==null?(e=I(),e!==null?(l=$r(),l!==null?(u=I(),u!==null?(f=Fr(),f!==null?i=[i,e,l,u,f]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i}function $r(){var i,e;return e=t,i=Hr(),i!==null&&(i=function(l,u){b.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function Hr(){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 Fr(){var i,e,l;for(l=t,i=[],e=ae(),e===null&&(e=N(),e===null&&(e=Se(),e===null&&(e=z(),e===null&&(e=H(),e===null&&(e=I(),e===null&&(e=$()))))));e!==null;)i.push(e),e=ae(),e===null&&(e=N(),e===null&&(e=Se(),e===null&&(e=z(),e===null&&(e=H(),e===null&&(e=I(),e===null&&(e=$()))))));return i!==null&&(i=function(u){b.reason_phrase=r.substring(t,u)}(l)),i===null&&(t=l),i}function al(){var i,e,l,u,f,h;if(f=t,i=tn(),i!==null){for(e=[],h=t,l=Ce(),l!==null?(u=tn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Ce(),l!==null?(u=tn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Mo(){var i,e,l,u,f,h;return u=t,f=t,i=et(),i!==null?(h=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){b=r.substring(t,m)}(u)),i===null&&(t=u),i}function ko(){var i,e,l,u,f,h,m;if(f=t,i=ee(),i===null)if(h=t,i=Nn(),i!==null){for(e=[],m=t,l=Ce(),l!==null?(u=Nn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Ce(),l!==null?(u=Nn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(v){var S,O;for(O=b.multi_header.length,S=0;S<O;S++)if(b.multi_header[S].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),i===null&&(t=f),i}function Nn(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=ws(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=ws(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(v){var S;b.multi_header||(b.multi_header=[]);try{S=new as(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{S=null}b.multi_header.push({possition:t,offset:v,parsed:S})}(f)),i===null&&(t=f),i}function kt(){var i,e,l,u,f;return f=t,i=Lt(),i=i!==null?i:"",i!==null?(e=xe(),e!==null?(l=we(),l!==null?(u=be(),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,u,f,h,m;if(f=t,h=t,i=U(),i!==null){for(e=[],m=t,l=ve(),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=ve(),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=h)}else i=null,t=h;return i===null&&(i=Oe()),i!==null&&(i=function(v,S){typeof S=="string"?b.display_name=S:b.display_name=S[1].reduce(function(O,ie){return O+ie[0]+ie[1]},S[0])}(f,i)),i===null&&(t=f),i}function ws(){var i;return i=Un(),i===null&&(i=Vr(),i===null&&(i=Ge())),i}function Un(){var i,e,l,u,f;return u=t,f=t,r.substr(t,1).toLowerCase()==="q"?(i=r.substr(t,1),t++):(i=null,_('"q"')),i!==null?(e=B(),e!==null?(l=Jt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){b.params||(b.params={}),b.params.q=m}(u,i[2])),i===null&&(t=u),i}function Vr(){var i,e,l,u,f;return u=t,f=t,r.substr(t,7).toLowerCase()==="expires"?(i=r.substr(t,7),t+=7):(i=null,_('"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(h,m){b.params||(b.params={}),b.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 Jt(){var i,e,l,u,f,h,m,v;return h=t,m=t,r.charCodeAt(t)===48?(i="0",t++):(i=null,_('"0"')),i!==null?(v=t,r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),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=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(S){return parseFloat(r.substring(t,S))}(h)),i===null&&(t=h),i}function Ge(){var i,e,l,u,f,h;return u=t,f=t,i=U(),i!==null?(h=t,e=B(),e!==null?(l=We(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,v,S){b.params||(b.params={}),typeof S>"u"?S=void 0:S=S[1],b.params[v.toLowerCase()]=S}(u,i[0],i[1])),i===null&&(t=u),i}function We(){var i;return i=U(),i===null&&(i=Yt(),i===null&&(i=Ie())),i}function ul(){var i,e,l,u,f,h;if(f=t,i=cl(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=Pn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=le(),l!==null?(u=Pn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function cl(){var i;return r.substr(t,6).toLowerCase()==="render"?(i=r.substr(t,6),t+=6):(i=null,_('"render"')),i===null&&(r.substr(t,7).toLowerCase()==="session"?(i=r.substr(t,7),t+=7):(i=null,_('"session"')),i===null&&(r.substr(t,4).toLowerCase()==="icon"?(i=r.substr(t,4),t+=4):(i=null,_('"icon"')),i===null&&(r.substr(t,5).toLowerCase()==="alert"?(i=r.substr(t,5),t+=5):(i=null,_('"alert"')),i===null&&(i=U())))),i}function Pn(){var i;return i=xn(),i===null&&(i=Ge()),i}function xn(){var i,e,l,u;return u=t,r.substr(t,8).toLowerCase()==="handling"?(i=r.substr(t,8),t+=8):(i=null,_('"handling"')),i!==null?(e=B(),e!==null?(r.substr(t,8).toLowerCase()==="optional"?(l=r.substr(t,8),t+=8):(l=null,_('"optional"')),l===null&&(r.substr(t,8).toLowerCase()==="required"?(l=r.substr(t,8),t+=8):(l=null,_('"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 fl(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Lo(){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){b=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function $o(){var i,e;return e=t,i=_l(),i!==null&&(i=function(l){b=r.substring(t,l)}(e)),i===null&&(t=e),i}function _l(){var i,e,l,u,f,h,m,v;if(m=t,i=jr(),i!==null)if(e=W(),e!==null)if(l=Gr(),l!==null){for(u=[],v=t,f=le(),f!==null?(h=Mn(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=le(),f!==null?(h=Mn(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);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 jr(){var i;return i=qr(),i===null&&(i=Br()),i}function qr(){var i;return r.substr(t,4).toLowerCase()==="text"?(i=r.substr(t,4),t+=4):(i=null,_('"text"')),i===null&&(r.substr(t,5).toLowerCase()==="image"?(i=r.substr(t,5),t+=5):(i=null,_('"image"')),i===null&&(r.substr(t,5).toLowerCase()==="audio"?(i=r.substr(t,5),t+=5):(i=null,_('"audio"')),i===null&&(r.substr(t,5).toLowerCase()==="video"?(i=r.substr(t,5),t+=5):(i=null,_('"video"')),i===null&&(r.substr(t,11).toLowerCase()==="application"?(i=r.substr(t,11),t+=11):(i=null,_('"application"')),i===null&&(i=Zs()))))),i}function Br(){var i;return r.substr(t,7).toLowerCase()==="message"?(i=r.substr(t,7),t+=7):(i=null,_('"message"')),i===null&&(r.substr(t,9).toLowerCase()==="multipart"?(i=r.substr(t,9),t+=9):(i=null,_('"multipart"')),i===null&&(i=Zs())),i}function Zs(){var i;return i=U(),i===null&&(i=en()),i}function en(){var i,e,l;return l=t,r.substr(t,2).toLowerCase()==="x-"?(i=r.substr(t,2),t+=2):(i=null,_('"x-"')),i!==null?(e=U(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Gr(){var i;return i=Zs(),i===null&&(i=U()),i}function Mn(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=kn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function kn(){var i;return i=U(),i===null&&(i=Ie()),i}function hl(){var i,e,l,u;return u=t,i=dl(),i!==null?(e=ve(),e!==null?(l=Xs(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function dl(){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){b.value=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function pl(){var i,e;return e=t,i=zt(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function Ho(){var i,e,l,u,f,h,m;if(f=t,h=t,i=tn(),i!==null){for(e=[],m=t,l=le(),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=le(),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=h)}else i=null,t=h;return i!==null&&(i=function(v,S){b.event=S.join("").toLowerCase()}(f,i[0])),i===null&&(t=f),i}function tn(){var i,e,l,u,f,h;if(f=t,i=P(),i!==null){for(e=[],h=t,r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function sn(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Wr(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=Wr(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(v){var S=b.tag;try{b=new as(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function Wr(){var i;return i=nn(),i===null&&(i=Ge()),i}function nn(){var i,e,l,u,f;return u=t,f=t,r.substr(t,3).toLowerCase()==="tag"?(i=r.substr(t,3),t+=3):(i=null,_('"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(h,m){b.tag=m}(u,i[2])),i===null&&(t=u),i}function Kr(){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){b=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function Fo(){var i,e;return e=t,i=zt(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function Vo(){var i,e,l,u,f,h,m,v,S,O;for(v=t,S=t,i=[],e=Lt();e!==null;)i.push(e),e=Lt();if(i!==null)if(e=xe(),e!==null)if(l=we(),l!==null)if(u=be(),u!==null){for(f=[],O=t,h=le(),h!==null?(m=Ge(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);h!==null;)f.push(h),O=t,h=le(),h!==null?(m=Ge(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);f!==null?i=[i,e,l,u,f]:(i=null,t=S)}else i=null,t=S;else i=null,t=S;else i=null,t=S;else i=null,t=S;return i!==null&&(i=function(ie){try{b=new as(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=v),i}function jo(){var i;return i=Yr(),i}function Yr(){var i,e,l,u,f,h,m,v;if(m=t,r.substr(t,6).toLowerCase()==="digest"?(i=r.substr(t,6),t+=6):(i=null,_('"Digest"')),i!==null)if(e=ve(),e!==null)if(l=Xt(),l!==null){for(u=[],v=t,f=Ce(),f!==null?(h=Xt(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Ce(),f!==null?(h=Xt(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);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=Ln()),i}function Ln(){var i,e,l,u,f,h,m,v;if(m=t,i=U(),i!==null)if(e=ve(),e!==null)if(l=Os(),l!==null){for(u=[],v=t,f=Ce(),f!==null?(h=Os(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Ce(),f!==null?(h=Os(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);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 Os(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=U(),l===null&&(l=Ie()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Xt(){var i;return i=rn(),i===null&&(i=Jr(),i===null&&(i=on(),i===null&&(i=Qr(),i===null&&(i=Zr(),i===null&&(i=ei(),i===null&&(i=ti(),i===null&&(i=Os()))))))),i}function rn(){var i,e,l,u;return u=t,r.substr(t,5).toLowerCase()==="realm"?(i=r.substr(t,5),t+=5):(i=null,_('"realm"')),i!==null?(e=B(),e!==null?(l=zr(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function zr(){var i,e;return e=t,i=Oe(),i!==null&&(i=function(l,u){b.realm=u}(e,i)),i===null&&(t=e),i}function Jr(){var i,e,l,u,f,h,m,v,S;if(v=t,r.substr(t,6).toLowerCase()==="domain"?(i=r.substr(t,6),t+=6):(i=null,_('"domain"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null)if(u=ln(),u!==null){if(f=[],S=t,m=I(),m!==null)for(h=[];m!==null;)h.push(m),m=I();else h=null;for(h!==null?(m=ln(),m!==null?h=[h,m]:(h=null,t=S)):(h=null,t=S);h!==null;){if(f.push(h),S=t,m=I(),m!==null)for(h=[];m!==null;)h.push(m),m=I();else h=null;h!==null?(m=ln(),m!==null?h=[h,m]:(h=null,t=S)):(h=null,t=S)}f!==null?(h=it(),h!==null?i=[i,e,l,u,f,h]:(i=null,t=v)):(i=null,t=v)}else i=null,t=v;else i=null,t=v;else i=null,t=v;else i=null,t=v;return i}function ln(){var i;return i=bn(),i===null&&(i=Ys()),i}function on(){var i,e,l,u;return u=t,r.substr(t,5).toLowerCase()==="nonce"?(i=r.substr(t,5),t+=5):(i=null,_('"nonce"')),i!==null?(e=B(),e!==null?(l=Xr(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Xr(){var i,e;return e=t,i=Oe(),i!==null&&(i=function(l,u){b.nonce=u}(e,i)),i===null&&(t=e),i}function Qr(){var i,e,l,u,f;return u=t,f=t,r.substr(t,6).toLowerCase()==="opaque"?(i=r.substr(t,6),t+=6):(i=null,_('"opaque"')),i!==null?(e=B(),e!==null?(l=Oe(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){b.opaque=m}(u,i[2])),i===null&&(t=u),i}function Zr(){var i,e,l,u,f;return u=t,r.substr(t,5).toLowerCase()==="stale"?(i=r.substr(t,5),t+=5):(i=null,_('"stale"')),i!==null?(e=B(),e!==null?(f=t,r.substr(t,4).toLowerCase()==="true"?(l=r.substr(t,4),t+=4):(l=null,_('"true"')),l!==null&&(l=function(h){b.stale=!0}()),l===null&&(t=f),l===null&&(f=t,r.substr(t,5).toLowerCase()==="false"?(l=r.substr(t,5),t+=5):(l=null,_('"false"')),l!==null&&(l=function(h){b.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 ei(){var i,e,l,u,f;return u=t,f=t,r.substr(t,9).toLowerCase()==="algorithm"?(i=r.substr(t,9),t+=9):(i=null,_('"algorithm"')),i!==null?(e=B(),e!==null?(r.substr(t,3).toLowerCase()==="md5"?(l=r.substr(t,3),t+=3):(l=null,_('"MD5"')),l===null&&(r.substr(t,8).toLowerCase()==="md5-sess"?(l=r.substr(t,8),t+=8):(l=null,_('"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(h,m){b.algorithm=m.toUpperCase()}(u,i[2])),i===null&&(t=u),i}function ti(){var i,e,l,u,f,h,m,v,S,O;if(v=t,r.substr(t,3).toLowerCase()==="qop"?(i=r.substr(t,3),t+=3):(i=null,_('"qop"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null){if(S=t,u=an(),u!==null){for(f=[],O=t,r.charCodeAt(t)===44?(h=",",t++):(h=null,_('","')),h!==null?(m=an(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);h!==null;)f.push(h),O=t,r.charCodeAt(t)===44?(h=",",t++):(h=null,_('","')),h!==null?(m=an(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);f!==null?u=[u,f]:(u=null,t=S)}else u=null,t=S;u!==null?(f=it(),f!==null?i=[i,e,l,u,f]:(i=null,t=v)):(i=null,t=v)}else i=null,t=v;else i=null,t=v;else i=null,t=v;return i}function an(){var i,e;return e=t,r.substr(t,8).toLowerCase()==="auth-int"?(i=r.substr(t,8),t+=8):(i=null,_('"auth-int"')),i===null&&(r.substr(t,4).toLowerCase()==="auth"?(i=r.substr(t,4),t+=4):(i=null,_('"auth"')),i===null&&(i=U())),i!==null&&(i=function(l,u){b.qop||(b.qop=[]),b.qop.push(u.toLowerCase())}(e,i)),i===null&&(t=e),i}function $n(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function qo(){var i,e,l,u,f,h,m;if(f=t,h=t,i=Hn(),i!==null){for(e=[],m=t,l=Ce(),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=Ce(),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=h)}else i=null,t=h;return i!==null&&(i=function(v){var S,O;for(O=b.multi_header.length,S=0;S<O;S++)if(b.multi_header[S].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),i===null&&(t=f),i}function Hn(){var i,e,l,u,f,h,m;if(f=t,h=t,i=kt(),i!==null){for(e=[],m=t,l=le(),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=le(),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=h)}else i=null,t=h;return i!==null&&(i=function(v){var S;b.multi_header||(b.multi_header=[]);try{S=new as(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{S=null}b.multi_header.push({possition:t,offset:v,parsed:S})}(f)),i===null&&(t=f),i}function Fn(){var i,e,l,u,f,h,m;if(f=t,h=t,r.substr(t,3).toLowerCase()==="sip"?(i=r.substr(t,3),t+=3):(i=null,_('"SIP"')),i===null&&(i=U()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=si(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=si(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(v,S){if(b.protocol=S.toLowerCase(),b.params||(b.params={}),b.params.text&&b.params.text[0]==='"'){var O=b.params.text;b.text=O.substring(1,O.length-1),delete b.params.text}}(f,i[0])),i===null&&(t=f),i}function si(){var i;return i=Vn(),i===null&&(i=Ge()),i}function Vn(){var i,e,l,u,f,h;if(f=t,h=t,r.substr(t,5).toLowerCase()==="cause"?(i=r.substr(t,5),t+=5):(i=null,_('"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=h)}else i=null,t=h;else i=null,t=h;return i!==null&&(i=function(m,v){b.cause=parseInt(v.join(""))}(f,i[2])),i===null&&(t=f),i}function ml(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Bo(){var i,e,l,u,f,h;if(f=t,i=jn(),i!==null){for(e=[],h=t,l=Ce(),l!==null?(u=jn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Ce(),l!==null?(u=jn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function jn(){var i,e,l,u,f,h;if(f=t,i=kt(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function qn(){var i,e,l,u,f,h;if(f=t,i=gl(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=Bn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=le(),l!==null?(u=Bn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function gl(){var i,e;return e=t,r.substr(t,6).toLowerCase()==="active"?(i=r.substr(t,6),t+=6):(i=null,_('"active"')),i===null&&(r.substr(t,7).toLowerCase()==="pending"?(i=r.substr(t,7),t+=7):(i=null,_('"pending"')),i===null&&(r.substr(t,10).toLowerCase()==="terminated"?(i=r.substr(t,10),t+=10):(i=null,_('"terminated"')),i===null&&(i=U()))),i!==null&&(i=function(l){b.state=r.substring(t,l)}(e)),i===null&&(t=e),i}function Bn(){var i,e,l,u,f;return u=t,f=t,r.substr(t,6).toLowerCase()==="reason"?(i=r.substr(t,6),t+=6):(i=null,_('"reason"')),i!==null?(e=B(),e!==null?(l=Gn(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){typeof m<"u"&&(b.reason=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,r.substr(t,7).toLowerCase()==="expires"?(i=r.substr(t,7),t+=7):(i=null,_('"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(h,m){typeof m<"u"&&(b.expires=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,r.substr(t,11).toLowerCase()==="retry_after"?(i=r.substr(t,11),t+=11):(i=null,_('"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(h,m){typeof m<"u"&&(b.retry_after=m)}(u,i[2])),i===null&&(t=u),i===null&&(i=Ge()))),i}function Gn(){var i;return r.substr(t,11).toLowerCase()==="deactivated"?(i=r.substr(t,11),t+=11):(i=null,_('"deactivated"')),i===null&&(r.substr(t,9).toLowerCase()==="probation"?(i=r.substr(t,9),t+=9):(i=null,_('"probation"')),i===null&&(r.substr(t,8).toLowerCase()==="rejected"?(i=r.substr(t,8),t+=8):(i=null,_('"rejected"')),i===null&&(r.substr(t,7).toLowerCase()==="timeout"?(i=r.substr(t,7),t+=7):(i=null,_('"timeout"')),i===null&&(r.substr(t,6).toLowerCase()==="giveup"?(i=r.substr(t,6),t+=6):(i=null,_('"giveup"')),i===null&&(r.substr(t,10).toLowerCase()==="noresource"?(i=r.substr(t,10),t+=10):(i=null,_('"noresource"')),i===null&&(r.substr(t,9).toLowerCase()==="invariant"?(i=r.substr(t,9),t+=9):(i=null,_('"invariant"')),i===null&&(i=U()))))))),i}function Tl(){var i;return i=q(),i=i!==null?i:"",i}function Go(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i=i!==null?i:"",i}function Wo(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=ni(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=ni(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(v){var S=b.tag;try{b=new as(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function ni(){var i;return i=nn(),i===null&&(i=Ge()),i}function ri(){var i,e,l,u,f,h;if(f=t,i=Wn(),i!==null){for(e=[],h=t,l=Ce(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Ce(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Wn(){var i,e,l,u,f,h,m,v;if(m=t,i=ci(),i!==null)if(e=ve(),e!==null)if(l=hi(),l!==null){for(u=[],v=t,f=le(),f!==null?(h=Ds(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=le(),f!==null?(h=Ds(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);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 Ds(){var i;return i=Kn(),i===null&&(i=ii(),i===null&&(i=li(),i===null&&(i=oi(),i===null&&(i=ai(),i===null&&(i=Ge()))))),i}function Kn(){var i,e,l,u,f;return u=t,f=t,r.substr(t,3).toLowerCase()==="ttl"?(i=r.substr(t,3),t+=3):(i=null,_('"ttl"')),i!==null?(e=B(),e!==null?(l=Yn(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){b.ttl=m}(u,i[2])),i===null&&(t=u),i}function ii(){var i,e,l,u,f;return u=t,f=t,r.substr(t,5).toLowerCase()==="maddr"?(i=r.substr(t,5),t+=5):(i=null,_('"maddr"')),i!==null?(e=B(),e!==null?(l=Yt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){b.maddr=m}(u,i[2])),i===null&&(t=u),i}function li(){var i,e,l,u,f;return u=t,f=t,r.substr(t,8).toLowerCase()==="received"?(i=r.substr(t,8),t+=8):(i=null,_('"received"')),i!==null?(e=B(),e!==null?(l=lt(),l===null&&(l=Bs()),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){b.received=m}(u,i[2])),i===null&&(t=u),i}function oi(){var i,e,l,u,f;return u=t,f=t,r.substr(t,6).toLowerCase()==="branch"?(i=r.substr(t,6),t+=6):(i=null,_('"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(h,m){b.branch=m}(u,i[2])),i===null&&(t=u),i}function ai(){var i,e,l,u,f;return u=t,r.substr(t,5).toLowerCase()==="rport"?(i=r.substr(t,5),t+=5):(i=null,_('"rport"')),i!==null?(f=t,e=B(),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 ui(){var i,e,l,u,f,h,m;return h=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(v,S){b.rport=parseInt(S.join(""))}(h,i)),i===null&&(t=h),i}function ci(){var i,e,l,u,f,h;return h=t,i=fi(),i!==null?(e=W(),e!==null?(l=U(),l!==null?(u=W(),u!==null?(f=_i(),f!==null?i=[i,e,l,u,f]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i}function fi(){var i,e;return e=t,r.substr(t,3).toLowerCase()==="sip"?(i=r.substr(t,3),t+=3):(i=null,_('"SIP"')),i===null&&(i=U()),i!==null&&(i=function(l,u){b.protocol=u}(e,i)),i===null&&(t=e),i}function _i(){var i,e;return e=t,r.substr(t,3).toLowerCase()==="udp"?(i=r.substr(t,3),t+=3):(i=null,_('"UDP"')),i===null&&(r.substr(t,3).toLowerCase()==="tcp"?(i=r.substr(t,3),t+=3):(i=null,_('"TCP"')),i===null&&(r.substr(t,3).toLowerCase()==="tls"?(i=r.substr(t,3),t+=3):(i=null,_('"TLS"')),i===null&&(r.substr(t,4).toLowerCase()==="sctp"?(i=r.substr(t,4),t+=4):(i=null,_('"SCTP"')),i===null&&(i=U())))),i!==null&&(i=function(l,u){b.transport=u}(e,i)),i===null&&(t=e),i}function hi(){var i,e,l,u,f;return u=t,i=di(),i!==null?(f=t,e=ye(),e!==null?(l=pi(),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 di(){var i,e;return e=t,i=lt(),i===null&&(i=Cn(),i===null&&(i=ls())),i!==null&&(i=function(l){b.host=r.substring(t,l)}(e)),i===null&&(t=e),i}function pi(){var i,e,l,u,f,h,m;return h=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(v,S){b.port=parseInt(S.join(""))}(h,i)),i===null&&(t=h),i}function Yn(){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(h,m){return parseInt(m.join(""))}(u,i)),i===null&&(t=u),i}function mi(){var i;return i=Yr(),i}function Ko(){var i,e,l,u,f,h;if(f=t,i=vl(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=zn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=le(),l!==null?(u=zn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function vl(){var i,e;return e=t,i=zt(),i!==null&&(i=function(l,u){b.expires=u}(e,i)),i===null&&(t=e),i}function zn(){var i;return i=Jn(),i===null&&(i=Ge()),i}function Jn(){var i,e,l,u,f;return u=t,f=t,r.substr(t,9).toLowerCase()==="refresher"?(i=r.substr(t,9),t+=9):(i=null,_('"refresher"')),i!==null?(e=B(),e!==null?(r.substr(t,3).toLowerCase()==="uac"?(l=r.substr(t,3),t+=3):(l=null,_('"uac"')),l===null&&(r.substr(t,3).toLowerCase()==="uas"?(l=r.substr(t,3),t+=3):(l=null,_('"uas"'))),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){b.refresher=m.toLowerCase()}(u,i[2])),i===null&&(t=u),i}function El(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=Sl(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Sl(){var i,e;for(i=[],e=j(),e===null&&(e=H(),e===null&&(e=ve()));e!==null;)i.push(e),e=j(),e===null&&(e=H(),e===null&&(e=ve()));return i}function yl(){var i,e;for(i=[],e=A();e!==null;)i.push(e),e=A();return i}function Yo(){var i,e,l;return l=t,r.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,_('"uuid:"')),i!==null?(e=Al(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Al(){var i,e,l,u,f,h,m,v,S,O,ie;return O=t,ie=t,i=Ht(),i!==null?(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e!==null?(l=$t(),l!==null?(r.charCodeAt(t)===45?(u="-",t++):(u=null,_('"-"')),u!==null?(f=$t(),f!==null?(r.charCodeAt(t)===45?(h="-",t++):(h=null,_('"-"')),h!==null?(m=$t(),m!==null?(r.charCodeAt(t)===45?(v="-",t++):(v=null,_('"-"')),v!==null?(S=gi(),S!==null?i=[i,e,l,u,f,h,m,v,S]:(i=null,t=ie)):(i=null,t=ie)):(i=null,t=ie)):(i=null,t=ie)):(i=null,t=ie)):(i=null,t=ie)):(i=null,t=ie)):(i=null,t=ie)):(i=null,t=ie),i!==null&&(i=function(Ne,Rt){b=r.substring(t+5,Ne)}(O,i[0])),i===null&&(t=O),i}function $t(){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 Ht(){var i,e,l;return l=t,i=$t(),i!==null?(e=$t(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function gi(){var i,e,l,u;return u=t,i=$t(),i!==null?(e=$t(),e!==null?(l=$t(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Cl(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=le(),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=le(),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=h)}else i=null,t=h;return i!==null&&(i=function(v){try{b=new as(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=f),i}function zo(){var i,e,l,u,f,h;if(f=t,i=Rl(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=le(),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Rl(){var i,e,l,u,f,h;return u=t,f=t,i=et(),i!==null?(h=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){b.call_id=r.substring(t,m)}(u)),i===null&&(t=u),i}function Xn(){var i;return i=Qn(),i===null&&(i=Ti(),i===null&&(i=vi(),i===null&&(i=Ge()))),i}function Qn(){var i,e,l,u,f;return u=t,f=t,r.substr(t,6)==="to-tag"?(i="to-tag",t+=6):(i=null,_('"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(h,m){b.to_tag=m}(u,i[2])),i===null&&(t=u),i}function Ti(){var i,e,l,u,f;return u=t,f=t,r.substr(t,8)==="from-tag"?(i="from-tag",t+=8):(i=null,_('"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(h,m){b.from_tag=m}(u,i[2])),i===null&&(t=u),i}function vi(){var i,e;return e=t,r.substr(t,10)==="early-only"?(i="early-only",t+=10):(i=null,_('"early-only"')),i!==null&&(i=function(l){b.early_only=!0}()),i===null&&(t=e),i}function Il(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 Jo(){for(var i=1,e=1,l=!1,u=0;u<Math.max(t,s);u++){var f=r.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 bl=Ts(),as=Au(),b={},w=a[o]();if(w===null||t!==r.length){var Ei=Math.max(t,s),Si=Ei<r.length?r.charAt(Ei):null,wl=Jo();return new this.SyntaxError(Il(p),Si,Ei,wl.line,wl.column),-1}return b},toSource:function(){return this._source}};return n.SyntaxError=function(r,o,a,t,s){function p(_,d){var g,T;switch(_.length){case 0:g="end of input";break;case 1:g=_[0];break;default:g=_.slice(0,_.length-1).join(", ")+" or "+_[_.length-1]}return T=d?c(d):"end of input","Expected "+g+" but "+T+" found."}this.name="SyntaxError",this.expected=r,this.found=o,this.message=p(r,o),this.offset=a,this.line=t,this.column=s},n.SyntaxError.prototype=Error.prototype,n}()),Sa}var ya,jc;function Ts(){if(jc)return ya;jc=1;const c=Ue,n=Et(),r=is();return ya=class Xf{static parse(a){if(a=r.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,t,s,p,_={},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 _)Object.prototype.hasOwnProperty.call(_,g)&&this.setParam(g,_[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[n.headerize(a)]=Array.isArray(t)?t:[t]}getHeader(a){if(a)return this._headers[n.headerize(a)]}hasHeader(a){if(a)return this._headers.hasOwnProperty(n.headerize(a))&&!0||!1}deleteHeader(a){if(a=n.headerize(a),this._headers.hasOwnProperty(a)){const t=this._headers[a];return delete this._headers[a],t}}clearHeaders(){this._headers={}}clone(){return new Xf(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+=`${n.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+=`${n.escapeUser(this._user)}@`),t+=this._host,a&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},ya}var qc;function Et(){if(qc)return Ze;qc=1;const c=Ue,n=Ts(),r=is();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 _ of p)if(o(s[_]))return!1;return!0};const a=Ze.createRandomToken=(s,p=32)=>{let _,d,g="";for(_=0;_<s;_++)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 _=Math.random()*16|0;return(p==="x"?_:_&3|8).toString(16)}),Ze.hostType=s=>{if(s){if(s=r.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 n)return s;if(typeof s=="string"){const _=s.split("@");let d,g;switch(_.length){case 1:if(!p)return;d=s,g=p;break;case 2:d=_[0],g=_[1];break;default:d=_.slice(0,_.length-1).join("@"),g=_[_.length-1]}d=d.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(d)&&(d=d.replace(/[-.()]/g,"")),s=`${c.SIP}:${t(d)}@${g}`;let T;return(T=n.parse(s))?T:void 0}else return}else return},Ze.headerize=s=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},_=s.toLowerCase().replace(/_/g,"-").split("-");let d="";const g=_.length;let T;for(T=0;T<g;T++)T!==0&&(d+="-"),d+=_[T].charAt(0).toUpperCase()+_[T].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,_){return Math.floor(Math.random()*(_-p+1)+p)}return`192.0.2.${s(1,254)}`},Ze.calculateMD5=s=>{function p(Ee,Ae){return Ee<<Ae|Ee>>>32-Ae}function _(Ee,Ae){const Ie=Ee&2147483648,Oe=Ae&2147483648,pe=Ee&1073741824,ue=Ae&1073741824,de=(Ee&1073741823)+(Ae&1073741823);return pe&ue?de^2147483648^Ie^Oe:pe|ue?de&1073741824?de^3221225472^Ie^Oe:de^1073741824^Ie^Oe:de^Ie^Oe}function d(Ee,Ae,Ie){return Ee&Ae|~Ee&Ie}function g(Ee,Ae,Ie){return Ee&Ie|Ae&~Ie}function T(Ee,Ae,Ie){return Ee^Ae^Ie}function E(Ee,Ae,Ie){return Ae^(Ee|~Ie)}function y(Ee,Ae,Ie,Oe,pe,ue,de){return Ee=_(Ee,_(_(d(Ae,Ie,Oe),pe),de)),_(p(Ee,ue),Ae)}function A(Ee,Ae,Ie,Oe,pe,ue,de){return Ee=_(Ee,_(_(g(Ae,Ie,Oe),pe),de)),_(p(Ee,ue),Ae)}function R(Ee,Ae,Ie,Oe,pe,ue,de){return Ee=_(Ee,_(_(T(Ae,Ie,Oe),pe),de)),_(p(Ee,ue),Ae)}function I(Ee,Ae,Ie,Oe,pe,ue,de){return Ee=_(Ee,_(_(E(Ae,Ie,Oe),pe),de)),_(p(Ee,ue),Ae)}function $(Ee){let Ae;const Ie=Ee.length,Oe=Ie+8,ue=((Oe-Oe%64)/64+1)*16,de=new Array(ue-1);let we=0,De=0;for(;De<Ie;)Ae=(De-De%4)/4,we=De%4*8,de[Ae]=de[Ae]|Ee.charCodeAt(De)<<we,De++;return Ae=(De-De%4)/4,we=De%4*8,de[Ae]=de[Ae]|128<<we,de[ue-2]=Ie<<3,de[ue-1]=Ie>>>29,de}function L(Ee){let Ae="",Ie="",Oe,pe;for(pe=0;pe<=3;pe++)Oe=Ee>>>pe*8&255,Ie=`0${Oe.toString(16)}`,Ae=Ae+Ie.substr(Ie.length-2,2);return Ae}function ae(Ee){let Ae="";for(let Ie=0;Ie<Ee.length;Ie++){const Oe=Ee.charCodeAt(Ie);Oe<128?Ae+=String.fromCharCode(Oe):Oe>127&&Oe<2048?(Ae+=String.fromCharCode(Oe>>6|192),Ae+=String.fromCharCode(Oe&63|128)):(Ae+=String.fromCharCode(Oe>>12|224),Ae+=String.fromCharCode(Oe>>6&63|128),Ae+=String.fromCharCode(Oe&63|128))}return Ae}let N=[],F,Se,ve,M,D,q,j,z,H;const J=7,U=12,P=17,se=22,et=5,ee=9,W=14,B=20,re=4,ge=11,be=16,xe=23,Ce=6,le=10,ye=15,tt=21;for(s=ae(s),N=$(s),q=1732584193,j=4023233417,z=2562383102,H=271733878,F=0;F<N.length;F+=16)Se=q,ve=j,M=z,D=H,q=y(q,j,z,H,N[F+0],J,3614090360),H=y(H,q,j,z,N[F+1],U,3905402710),z=y(z,H,q,j,N[F+2],P,606105819),j=y(j,z,H,q,N[F+3],se,3250441966),q=y(q,j,z,H,N[F+4],J,4118548399),H=y(H,q,j,z,N[F+5],U,1200080426),z=y(z,H,q,j,N[F+6],P,2821735955),j=y(j,z,H,q,N[F+7],se,4249261313),q=y(q,j,z,H,N[F+8],J,1770035416),H=y(H,q,j,z,N[F+9],U,2336552879),z=y(z,H,q,j,N[F+10],P,4294925233),j=y(j,z,H,q,N[F+11],se,2304563134),q=y(q,j,z,H,N[F+12],J,1804603682),H=y(H,q,j,z,N[F+13],U,4254626195),z=y(z,H,q,j,N[F+14],P,2792965006),j=y(j,z,H,q,N[F+15],se,1236535329),q=A(q,j,z,H,N[F+1],et,4129170786),H=A(H,q,j,z,N[F+6],ee,3225465664),z=A(z,H,q,j,N[F+11],W,643717713),j=A(j,z,H,q,N[F+0],B,3921069994),q=A(q,j,z,H,N[F+5],et,3593408605),H=A(H,q,j,z,N[F+10],ee,38016083),z=A(z,H,q,j,N[F+15],W,3634488961),j=A(j,z,H,q,N[F+4],B,3889429448),q=A(q,j,z,H,N[F+9],et,568446438),H=A(H,q,j,z,N[F+14],ee,3275163606),z=A(z,H,q,j,N[F+3],W,4107603335),j=A(j,z,H,q,N[F+8],B,1163531501),q=A(q,j,z,H,N[F+13],et,2850285829),H=A(H,q,j,z,N[F+2],ee,4243563512),z=A(z,H,q,j,N[F+7],W,1735328473),j=A(j,z,H,q,N[F+12],B,2368359562),q=R(q,j,z,H,N[F+5],re,4294588738),H=R(H,q,j,z,N[F+8],ge,2272392833),z=R(z,H,q,j,N[F+11],be,1839030562),j=R(j,z,H,q,N[F+14],xe,4259657740),q=R(q,j,z,H,N[F+1],re,2763975236),H=R(H,q,j,z,N[F+4],ge,1272893353),z=R(z,H,q,j,N[F+7],be,4139469664),j=R(j,z,H,q,N[F+10],xe,3200236656),q=R(q,j,z,H,N[F+13],re,681279174),H=R(H,q,j,z,N[F+0],ge,3936430074),z=R(z,H,q,j,N[F+3],be,3572445317),j=R(j,z,H,q,N[F+6],xe,76029189),q=R(q,j,z,H,N[F+9],re,3654602809),H=R(H,q,j,z,N[F+12],ge,3873151461),z=R(z,H,q,j,N[F+15],be,530742520),j=R(j,z,H,q,N[F+2],xe,3299628645),q=I(q,j,z,H,N[F+0],Ce,4096336452),H=I(H,q,j,z,N[F+7],le,1126891415),z=I(z,H,q,j,N[F+14],ye,2878612391),j=I(j,z,H,q,N[F+5],tt,4237533241),q=I(q,j,z,H,N[F+12],Ce,1700485571),H=I(H,q,j,z,N[F+3],le,2399980690),z=I(z,H,q,j,N[F+10],ye,4293915773),j=I(j,z,H,q,N[F+1],tt,2240044497),q=I(q,j,z,H,N[F+8],Ce,1873313359),H=I(H,q,j,z,N[F+15],le,4264355552),z=I(z,H,q,j,N[F+6],ye,2734768916),j=I(j,z,H,q,N[F+13],tt,1309151649),q=I(q,j,z,H,N[F+4],Ce,4149444226),H=I(H,q,j,z,N[F+11],le,3174756917),z=I(z,H,q,j,N[F+2],ye,718787259),j=I(j,z,H,q,N[F+9],tt,3951481745),q=_(q,Se),j=_(j,ve),z=_(z,M),H=_(H,D);return(L(q)+L(j)+L(z)+L(H)).toLowerCase()},Ze.closeMediaStream=s=>{if(s)try{let p;if(s.getTracks){p=s.getTracks();for(const _ of p)_.stop()}else{p=s.getAudioTracks();for(const _ of p)_.stop();p=s.getVideoTracks();for(const _ of p)_.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 Qf=Nt,ym=at,vt=Ue,nt=Et(),Bc=Au(),Am=is(),Aa=new ym("SIPMessage");class Po{constructor(n,r,o,a,t,s){if(!n||!r||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=n,this.ruri=r,this.body=s,this.extraHeaders=nt.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",vt.MAX_FORWARDS);const p=a.to_uri||r,_=a.to_tag?{tag:a.to_tag}:null,d=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Bc(p,d,_),this.setHeader("to",this.to.toString());const g=a.from_uri||o.configuration.uri,T={tag:a.from_tag||nt.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 Bc(g,E,T),this.setHeader("from",this.from.toString());const y=a.call_id||o.configuration.jssip_id+nt.createRandomToken(15);this.call_id=y,this.setHeader("call-id",y);const A=a.cseq||Math.floor(Math.random()*1e4);this.cseq=A,this.setHeader("cseq",`${A} ${n}`)}setHeader(n,r){const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(let a=0;a<this.extraHeaders.length;a++)o.test(this.extraHeaders[a])&&this.extraHeaders.splice(a,1);this.headers[nt.headerize(n)]=Array.isArray(r)?r:[r]}getHeader(n){const r=this.headers[nt.headerize(n)];if(r){if(r[0])return r[0]}else{const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(const a of this.extraHeaders)if(o.test(a))return a.substring(a.indexOf(":")+1).trim()}}getHeaders(n){const r=this.headers[nt.headerize(n)],o=[];if(r){for(const a of r)o.push(a);return o}else{const a=new RegExp(`^\\s*${n}\\s*:`,"i");for(const t of this.extraHeaders)a.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(n){if(this.headers[nt.headerize(n)])return!0;{const r=new RegExp(`^\\s*${n}\\s*:`,"i");for(const o of this.extraHeaders)if(r.test(o))return!0}return!1}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=Qf.parse(this.body||""),this.sdp)}toString(){let n=`${this.method} ${this.ruri} SIP/2.0\r
|
76
|
+
`;for(const a in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,a))for(const t of this.headers[a])n+=`${a}: ${t}\r
|
77
|
+
`;for(const a of this.extraHeaders)n+=`${a.trim()}\r
|
78
|
+
`;const r=[];switch(this.method){case vt.REGISTER:r.push("path","gruu");break;case vt.INVITE:this.ua.configuration.session_timers&&r.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&r.push("gruu"),r.push("ice","replaces");break;case vt.UPDATE:this.ua.configuration.session_timers&&r.push("timer"),r.push("ice");break}r.push("outbound");const o=this.ua.configuration.user_agent||vt.USER_AGENT;if(n+=`Allow: ${vt.ALLOWED_METHODS}\r
|
79
|
+
`,n+=`Supported: ${r}\r
|
80
|
+
`,n+=`User-Agent: ${o}\r
|
81
|
+
`,this.body){const a=nt.str_utf8_length(this.body);n+=`Content-Length: ${a}\r
|
82
82
|
\r
|
83
|
-
`,
|
83
|
+
`,n+=this.body}else n+=`Content-Length: 0\r
|
84
84
|
\r
|
85
|
-
`;return
|
86
|
-
`;if(this.method===
|
87
|
-
`}const g=this.getHeaders("via");for(const
|
88
|
-
`;!this.to_tag&&
|
85
|
+
`;return n}clone(){const n=new Po(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(r){n.headers[r]=this.headers[r].slice()},this),n.body=this.body,n.extraHeaders=nt.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n}}class Cu extends Po{constructor(n,r,o,a,t){super(vt.INVITE,n,r,o,a,t),this.transaction=null}cancel(n){this.transaction.cancel(n)}clone(){const n=new Cu(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(r){n.headers[r]=this.headers[r].slice()},this),n.body=this.body,n.extraHeaders=nt.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n.transaction=this.transaction,n}}class Zf{constructor(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}addHeader(n,r){const o={raw:r};n=nt.headerize(n),this.headers[n]?this.headers[n].push(o):this.headers[n]=[o]}getHeader(n){const r=this.headers[nt.headerize(n)];if(r){if(r[0])return r[0].raw}else return}getHeaders(n){const r=this.headers[nt.headerize(n)],o=[];if(!r)return[];for(const a of r)o.push(a.raw);return o}hasHeader(n){return!!this.headers[nt.headerize(n)]}parseHeader(n,r=0){if(n=nt.headerize(n),this.headers[n]){if(r>=this.headers[n].length){Aa.debug(`not so many "${n}" headers present`);return}}else{Aa.debug(`header "${n}" not present`);return}const o=this.headers[n][r],a=o.raw;if(o.parsed)return o.parsed;const t=Am.parse(a,n.replace(/-/g,"_"));if(t===-1){this.headers[n].splice(r,1),Aa.debug(`error parsing "${n}" header field with value "${a}"`);return}else return o.parsed=t,t}s(n,r){return this.parseHeader(n,r)}setHeader(n,r){const o={raw:r};this.headers[nt.headerize(n)]=[o]}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=Qf.parse(this.body||""),this.sdp)}toString(){return this.data}}class Cm extends Zf{constructor(n){super(),this.ua=n,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(n,r,o,a,t,s){const p=[];let _=this.getHeader("To");if(n=n||null,r=r||null,!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(r&&typeof r!="string"&&!(r instanceof String))throw new TypeError(`Invalid reason_phrase: ${r}`);r=r||vt.REASON_PHRASE[n]||"",o=nt.cloneArray(o),this.ua.configuration.extra_headers&&(o=o.concat(this.ua.configuration.extra_headers));let d=`SIP/2.0 ${n} ${r}\r
|
86
|
+
`;if(this.method===vt.INVITE&&n>100&&n<=200){const T=this.getHeaders("record-route");for(const E of T)d+=`Record-Route: ${E}\r
|
87
|
+
`}const g=this.getHeaders("via");for(const T of g)d+=`Via: ${T}\r
|
88
|
+
`;!this.to_tag&&n>100?_+=`;tag=${nt.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(_+=`;tag=${this.to_tag}`),d+=`To: ${_}\r
|
89
89
|
`,d+=`From: ${this.getHeader("From")}\r
|
90
90
|
`,d+=`Call-ID: ${this.call_id}\r
|
91
91
|
`,d+=`CSeq: ${this.cseq} ${this.method}\r
|
92
|
-
`;for(const
|
93
|
-
`;switch(this.method){case
|
94
|
-
`,d+=`Accept: ${
|
95
|
-
`):
|
96
|
-
`:
|
92
|
+
`;for(const T of o)d+=`${T.trim()}\r
|
93
|
+
`;switch(this.method){case vt.INVITE:this.ua.configuration.session_timers&&p.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&p.push("gruu"),p.push("ice","replaces");break;case vt.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),a&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===vt.OPTIONS?(d+=`Allow: ${vt.ALLOWED_METHODS}\r
|
94
|
+
`,d+=`Accept: ${vt.ACCEPTED_BODY_TYPES}\r
|
95
|
+
`):n===405?d+=`Allow: ${vt.ALLOWED_METHODS}\r
|
96
|
+
`:n===415&&(d+=`Accept: ${vt.ACCEPTED_BODY_TYPES}\r
|
97
97
|
`),d+=`Supported: ${p}\r
|
98
|
-
`,a){const
|
99
|
-
`,d+=`Content-Length: ${
|
98
|
+
`,a){const T=nt.str_utf8_length(a);d+=`Content-Type: application/sdp\r
|
99
|
+
`,d+=`Content-Length: ${T}\r
|
100
100
|
\r
|
101
101
|
`,d+=a}else d+=`Content-Length: 0\r
|
102
102
|
\r
|
103
|
-
`;this.server_transaction.receiveResponse(
|
103
|
+
`;this.server_transaction.receiveResponse(n,d,t,s)}reply_sl(n=null,r=null){const o=this.getHeaders("via");if(!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(r&&typeof r!="string"&&!(r instanceof String))throw new TypeError(`Invalid reason_phrase: ${r}`);r=r||vt.REASON_PHRASE[n]||"";let a=`SIP/2.0 ${n} ${r}\r
|
104
104
|
`;for(const s of o)a+=`Via: ${s}\r
|
105
|
-
`;let t=this.getHeader("To");if(!this.to_tag&&
|
105
|
+
`;let t=this.getHeader("To");if(!this.to_tag&&n>100?t+=`;tag=${nt.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(t+=`;tag=${this.to_tag}`),a+=`To: ${t}\r
|
106
106
|
`,a+=`From: ${this.getHeader("From")}\r
|
107
107
|
`,a+=`Call-ID: ${this.call_id}\r
|
108
108
|
`,a+=`CSeq: ${this.cseq} ${this.method}\r
|
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 om extends Hf{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var ts={OutgoingRequest:Ao,InitialOutgoingInviteRequest:fu,IncomingRequest:lm,IncomingResponse:om};const am=lt,as=mt(),Ft=new am("DigestAuthentication");var Ff=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:Ft.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 Ft.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Ft.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Ft.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Ft.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Ft.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 Ft.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||as.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=as.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=as.calculateMD5(p),Ft.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=as.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${h}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${as.calculateMD5(o||"")}`,h=as.calculateMD5(p),Ft.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=as.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${h}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,h=as.calculateMD5(p),Ft.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=as.calculateMD5(`${this._ha1}:${this._nonce}:${h}`)),Ft.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 um=xt(Ff),us=500,cm=4e3,Nc=5e3;var qf={T1:us,T2:cm,T4:Nc,TIMER_B:64*us,TIMER_D:0*us,TIMER_F:64*us,TIMER_H:64*us,TIMER_I:0*us,TIMER_J:0*us,TIMER_K:0*Nc,TIMER_L:64*us,TIMER_M:64*us,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Qi=pt.EventEmitter,Zi=lt,xi=De,Uc=ts,Qt=qf,Pc=new Zi("NonInviteClientTransaction"),kl=new Zi("InviteClientTransaction"),fm=new Zi("AckClientTransaction"),kc=new Zi("NonInviteServerTransaction"),Ml=new Zi("InviteServerTransaction"),ce={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 hm extends Qi{constructor(r,n,o,a){super(),this.type=ce.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 ce}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ce.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},Qt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){Pc.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){Pc.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(r){const n=r.status_code;if(n<200)switch(this.state){case ce.STATUS_TRYING:case ce.STATUS_PROCEEDING:this.stateChanged(ce.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break}else switch(this.state){case ce.STATUS_TRYING:case ce.STATUS_PROCEEDING:this.stateChanged(ce.STATUS_COMPLETED),clearTimeout(this.F),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(r),this.K=setTimeout(()=>{this.timer_K()},Qt.TIMER_K);break;case ce.STATUS_COMPLETED:break}}}class _m extends Qi{constructor(r,n,o,a){super(),this.type=ce.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 ce}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ce.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},Qt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==ce.STATUS_ACCEPTED&&(kl.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){kl.debug(`Timer M expired for transaction ${this.id}`),this.state===ce.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){kl.debug(`Timer B expired for transaction ${this.id}`),this.state===ce.STATUS_CALLING&&(this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){kl.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(r){const n=new Uc.OutgoingRequest(xi.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()},Qt.TIMER_D),this.transport.send(n)}cancel(r){if(this.state!==ce.STATUS_PROCEEDING)return;const n=new Uc.OutgoingRequest(xi.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 ce.STATUS_CALLING:this.stateChanged(ce.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break;case ce.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(r);break}else if(n>=200&&n<=299)switch(this.state){case ce.STATUS_CALLING:case ce.STATUS_PROCEEDING:this.stateChanged(ce.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},Qt.TIMER_M),this.eventHandlers.onReceiveResponse(r);break;case ce.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(r);break}else if(n>=300&&n<=699)switch(this.state){case ce.STATUS_CALLING:case ce.STATUS_PROCEEDING:this.stateChanged(ce.STATUS_COMPLETED),this.sendACK(r),this.eventHandlers.onReceiveResponse(r);break;case ce.STATUS_COMPLETED:this.sendACK(r);break}}}class dm extends Qi{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 ce}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){fm.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class pm extends Qi{constructor(r,n,o){super(),this.type=ce.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=ce.STATUS_TRYING,r.newTransaction(this)}get C(){return ce}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_J(){kc.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,kc.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(r,n,o,a){if(r===100)switch(this.state){case ce.STATUS_TRYING:this.stateChanged(ce.STATUS_PROCEEDING),this.transport.send(n)||this.onTransportError();break;case ce.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 ce.STATUS_TRYING:case ce.STATUS_PROCEEDING:this.stateChanged(ce.STATUS_COMPLETED),this.last_response=n,this.J=setTimeout(()=>{this.timer_J()},Qt.TIMER_J),this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break;case ce.STATUS_COMPLETED:break}}}class mm extends Qi{constructor(r,n,o){super(),this.type=ce.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=ce.STATUS_PROCEEDING,r.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return ce}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_H(){Ml.debug(`Timer H expired for transaction ${this.id}`),this.state===ce.STATUS_COMPLETED&&Ml.debug("ACK not received, dialog will be terminated"),this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){Ml.debug(`Timer L expired for transaction ${this.id}`),this.state===ce.STATUS_ACCEPTED&&(this.stateChanged(ce.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,Ml.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(ce.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 ce.STATUS_PROCEEDING:this.transport.send(n)||this.onTransportError(),this.last_response=n;break}if(r>100&&r<=199&&this.state===ce.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},Qt.PROVISIONAL_RESPONSE_INTERVAL));else if(r>=200&&r<=299)switch(this.state){case ce.STATUS_PROCEEDING:this.stateChanged(ce.STATUS_ACCEPTED),this.last_response=n,this.L=setTimeout(()=>{this.timer_L()},Qt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ce.STATUS_ACCEPTED:this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break}else if(r>=300&&r<=699)switch(this.state){case ce.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(n)?(this.stateChanged(ce.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},Qt.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function gm({_transactions:c},r){let n;switch(r.method){case xi.INVITE:if(n=c.ist[r.via_branch],n){switch(n.state){case ce.STATUS_PROCEEDING:n.transport.send(n.last_response);break;case ce.STATUS_ACCEPTED:break}return!0}break;case xi.ACK:if(n=c.ist[r.via_branch],n){if(n.state===ce.STATUS_ACCEPTED)return!1;if(n.state===ce.STATUS_COMPLETED)return n.state=ce.STATUS_CONFIRMED,n.I=setTimeout(()=>{n.timer_I()},Qt.TIMER_I),!0}else return!1;break;case xi.CANCEL:return n=c.ist[r.via_branch],n?(r.reply_sl(200),n.state!==ce.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(n=c.nist[r.via_branch],n){switch(n.state){case ce.STATUS_TRYING:break;case ce.STATUS_PROCEEDING:case ce.STATUS_COMPLETED:n.transport.send(n.last_response);break}return!0}break}}var ir={C:ce,NonInviteClientTransaction:hm,InviteClientTransaction:_m,AckClientTransaction:dm,NonInviteServerTransaction:pm,InviteServerTransaction:mm,checkTransaction:gm};const Li=xt(ir),vm=lt,Mc=De,Tm=Ff,pa=ir,Em=new vm("RequestSender"),ma={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var lr=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 ma)Object.prototype.hasOwnProperty.call(ma,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=ma[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==Mc.BYE||this._method!==Mc.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 pa.InviteClientTransaction(this._ua,this._ua.transport,this._request,r);break;case"ACK":this.clientTransaction=new pa.AckClientTransaction(this._ua,this._ua.transport,this._request,r);break;default:this.clientTransaction=new pa.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){Em.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 Tm({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 ym=xt(lr),Sm=lt,ga=mt(),an=De,xc=ts,Lc=lr,Ri=new Sm("Registrator"),xl=10;var Cm=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=ga.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){Ri.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 xc.OutgoingRequest(an.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r),o=new Lc(this._ua,n,{onRequestTimeout:()=>{this._registrationFailure(null,an.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,an.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")){Ri.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){Ri.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<xl&&(p=xl);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<xl&&(this._expires=xl),this.register()):(Ri.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,an.causes.SIP_FAILURE_CODE));break}default:{const t=ga.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(r={}){if(!this._registered){Ri.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 xc.OutgoingRequest(an.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new Lc(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,an.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,an.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=ga.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 Rm extends Error{constructor(r){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=r,this.message=`Invalid status: ${r}`}}class Im extends Error{constructor(r){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=r}}class bm extends Error{constructor(r){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=r}}var ps={ConfigurationError:Am,InvalidStateError:Rm,NotSupportedError:Im,NotReadyError:bm};const wm=xt(ps),va=De,Ll=ir,Om=lr,Ta={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 Ta)Object.prototype.hasOwnProperty.call(Ta,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Ta[a]))}get request(){return this._request}send(){const r=new Om(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===va.INVITE||this._request.method===va.UPDATE&&this._request.body)&&r.clientTransaction.state!==Ll.C.STATUS_TERMINATED){console.log("this._request.body",this._request.body),this._dialog.uac_pending_reply=!0;const n=()=>{(r.clientTransaction.state===Ll.C.STATUS_ACCEPTED||r.clientTransaction.state===Ll.C.STATUS_COMPLETED||r.clientTransaction.state===Ll.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===va.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 Nm=lt,$c=ts,Ds=De,Ii=ir,Um=Dm,Ea=mt(),ya=new Nm("Dialog"),Ns={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var Vf=class{static get C(){return Ns}constructor(r,n,o,a=Ns.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 $c.IncomingResponse&&(a=n.status_code<200?Ns.STATUS_EARLY:Ns.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),ya.debug(`new ${o} dialog created with status ${this._state===Ns.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===Ns.STATUS_TERMINATED}update(r,n){this._state=Ns.STATUS_CONFIRMED,ya.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),n==="UAC"&&(this._route_set=r.getHeaders("record-route").reverse())}terminate(){ya.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Ns.STATUS_TERMINATED}sendRequest(r,n={}){const o=Ea.cloneArray(n.extraHeaders),a=Ea.cloneObject(n.eventHandlers),t=n.body||null,s=this._createRequest(r,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new Um(this,s,a).send(),s}receiveRequest(r){this._checkInDialogRequest(r)&&(r.method===Ds.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===Ds.INVITE&&(this._ack_seqnum=r.cseq),this._owner.receiveRequest(r))}_createRequest(r,n,o){n=Ea.cloneArray(n),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=r===Ds.CANCEL||r===Ds.ACK?this._local_seqnum:this._local_seqnum+=1;return new $c.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===Ds.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===Ds.INVITE||r.method===Ds.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===Ii.C.STATUS_ACCEPTED||r.server_transaction.state===Ii.C.STATUS_COMPLETED||r.server_transaction.state===Ii.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===Ii.C.STATUS_ACCEPTED&&(this._remote_target=r.parseHeader("contact").uri)})}else r.method===Ds.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",()=>{r.server_transaction.state===Ii.C.STATUS_COMPLETED&&(this._remote_target=r.parseHeader("contact").uri)});return!0}};const $l=xt(Vf);var hu={exports:{}};const Pm=pt.EventEmitter,km=lt,Mm=De,xm=ps,Hc=mt(),Lm=new km("RTCSession:DTMF"),jf={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};hu.exports=class extends Pm{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 xm.InvalidStateError(this._session.status);const o=Hc.cloneArray(n.extraHeaders);if(this.eventHandlers=Hc.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
|
-
`;a+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(
|
114
|
-
`);a.length>=1&&
|
115
|
-
`,1)[0],"Status_Line");if(n===-1){un.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){un.debug("REFER succeeded"),un.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:r})}_requestFailed(r,n){un.debug("REFER failed"),un.debug('emit "requestFailed"'),this.emit("requestFailed",{response:r||null,cause:n})}};const Xm=pt.EventEmitter,Vc=Lt,Qm=lt,ae=De,cn=ps,jc=ir,qe=mt(),wi=qf,Zm=ts,Hl=Vf,eg=lr,bt=$m,Bc=Bf,tg=Km,sg=Jm,Gc=ds(),W=new Qm("RTCSession"),X={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},Fl=["audio","video"];var Gf=class Ja extends Xm{static get C(){return X}constructor(r){W.debug("new"),super(),this._id=null,this._ua=r,this._status=X.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:ae.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return X}get causes(){return ae.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 X.STATUS_NULL:case X.STATUS_INVITE_SENT:case X.STATUS_1XX_RECEIVED:case X.STATUS_INVITE_RECEIVED:case X.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case X.STATUS_ANSWERED:case X.STATUS_WAITING_FOR_ACK:case X.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case X.STATUS_CANCELED:case X.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){console.log("rtcOfferConstraints connect"),W.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!==X.STATUS_NULL)throw new cn.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new cn.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>=ae.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=ae.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 Gc("sip","anonymous","anonymous.invalid"),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),s.push("Privacy: id")):n.fromUserName&&(S.from_uri=new Gc("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 Zm.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){W.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=X.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=X.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),this._failed("local",null,ae.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===X.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),this._failed("system",null,ae.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!==X.STATUS_TERMINATED&&(r.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(r={}){W.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 cn.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==X.STATUS_WAITING_FOR_ANSWER)throw new cn.InvalidStateError(this._status);if(this._sessionTimers.enabled&&qe.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=ae.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=ae.SESSION_EXPIRES),this._status=X.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===X.STATUS_TERMINATED?new Error("terminated"):(n.reply(480),this._failed("local",null,ae.causes.USER_DENIED_MEDIA_ACCESS),W.warn('emit "getusermediafailed" [error:%o]',w),this.emit("getusermediafailed",w),new Error("getUserMedia() failed"))})}).then(w=>{if(this._status===X.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};W.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,ae.causes.WEBRTC_ERROR),W.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===X.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===X.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(n,o),n.reply(200,null,o,w,()=>{this._status=X.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,w),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,ae.causes.CONNECTION_ERROR)})}).catch(w=>{this._status!==X.STATUS_TERMINATED&&W.warn(w)})}terminate(r={}){W.debug("terminate()");const n=r.cause||ae.causes.BYE,o=qe.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===X.STATUS_TERMINATED)throw new cn.InvalidStateError(this._status);switch(this._status){case X.STATUS_NULL:case X.STATUS_INVITE_SENT:case X.STATUS_1XX_RECEIVED:if(W.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||ae.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===X.STATUS_NULL||this._status===X.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===X.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=X.STATUS_CANCELED,this._failed("local",null,ae.causes.CANCELED);break;case X.STATUS_WAITING_FOR_ANSWER:case X.STATUS_ANSWERED:if(W.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,ae.causes.REJECTED);break;case X.STATUS_WAITING_FOR_ACK:case X.STATUS_CONFIRMED:if(W.debug("terminating session"),p=r.reason_phrase||ae.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===X.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==jc.C.STATUS_TERMINATED){const h=this._dialog;this.receiveRequest=({method:d})=>{d===ae.ACK&&(this.sendRequest(ae.BYE,{extraHeaders:o,body:a}),h.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===jc.C.STATUS_TERMINATED&&(this.sendRequest(ae.BYE,{extraHeaders:o,body:a}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else this.sendRequest(ae.BYE,{extraHeaders:o,body:a}),this._ended("local",null,n)}}sendDTMF(r,n={}){W.debug("sendDTMF() | tones: %s",r);let o=0,a=n.duration||null,t=n.interToneGap||null;const s=n.transportType||ae.DTMF_TRANSPORT.INFO;if(r===void 0)throw new TypeError("Not enough arguments");if(this._status!==X.STATUS_CONFIRMED&&this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_1XX_RECEIVED)throw new cn.InvalidStateError(this._status);if(s!==ae.DTMF_TRANSPORT.INFO&&s!==ae.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<bt.C.MIN_DURATION?(W.debug(`"duration" value is lower than the minimum allowed, setting it to ${bt.C.MIN_DURATION} milliseconds`),a=bt.C.MIN_DURATION):a>bt.C.MAX_DURATION?(W.debug(`"duration" value is greater than the maximum allowed, setting it to ${bt.C.MAX_DURATION} milliseconds`),a=bt.C.MAX_DURATION):a=Math.abs(a):a=bt.C.DEFAULT_DURATION,n.duration=a,t&&!qe.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<bt.C.MIN_INTER_TONE_GAP?(W.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${bt.C.MIN_INTER_TONE_GAP} milliseconds`),t=bt.C.MIN_INTER_TONE_GAP):t=Math.abs(t):t=bt.C.DEFAULT_INTER_TONE_GAP,s===ae.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===X.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 bt(this);n.eventHandlers={onFailed:()=>{this._tones=null}},g.send(d,n),h=a+t}setTimeout(p.bind(this),h)}}sendInfo(r,n,o={}){if(W.debug("sendInfo()"),this._status!==X.STATUS_CONFIRMED&&this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_1XX_RECEIVED)throw new cn.InvalidStateError(this._status);new Bc(this).send(r,n,o)}mute(r={audio:!0,video:!1}){W.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}){W.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(W.debug("hold()"),this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ae.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(W.debug("unhold()"),this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ae.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){W.debug("renegotiate()");const o=r.rtcOfferConstraints||null;if(this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ae.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){W.debug("refer()");const o=r;if(this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED)return!1;if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${o}`);const a=new sg(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 W.debug("sendRequest()"),this._dialog.sendRequest(r,n)}receiveRequest(r){if(W.debug("receiveRequest()"),r.method===ae.CANCEL)(this._status===X.STATUS_WAITING_FOR_ANSWER||this._status===X.STATUS_ANSWERED)&&(this._status=X.STATUS_CANCELED,this._request.reply(487),this._failed("remote",r,ae.causes.CANCELED));else switch(r.method){case ae.ACK:if(this._status!==X.STATUS_WAITING_FOR_ACK)return;if(this._status=X.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:ae.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:r.body};W.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:ae.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),W.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",r);break;case ae.BYE:this._status===X.STATUS_CONFIRMED||this._status===X.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,ae.causes.BYE)):this._status===X.STATUS_INVITE_RECEIVED||this._status===X.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,ae.causes.BYE)):r.reply(403,"Wrong Status");break;case ae.INVITE:this._status===X.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case ae.INFO:if(this._status===X.STATUS_1XX_RECEIVED||this._status===X.STATUS_WAITING_FOR_ANSWER||this._status===X.STATUS_ANSWERED||this._status===X.STATUS_WAITING_FOR_ACK||this._status===X.STATUS_CONFIRMED){const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;n&&n.match(/^application\/dtmf-relay/i)?new bt(this).init_incoming(r):n!==void 0?new Bc(this).init_incoming(r):r.reply(415)}else r.reply(403,"Wrong Status");break;case ae.UPDATE:this._status===X.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case ae.REFER:this._status===X.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case ae.NOTIFY:this._status===X.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){W.warn("onTransportError()"),this._status!==X.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ae.causes.CONNECTION_ERROR,cause:ae.causes.CONNECTION_ERROR})}onRequestTimeout(){W.warn("onRequestTimeout()"),this._status!==X.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ae.causes.REQUEST_TIMEOUT,cause:ae.causes.REQUEST_TIMEOUT})}onDialogError(){W.warn("onDialogError()"),this._status!==X.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ae.causes.DIALOG_ERROR,cause:ae.causes.DIALOG_ERROR})}newDTMF(r){W.debug("newDTMF()"),this.emit("newDTMF",r)}newInfo(r){W.debug("newInfo()"),this.emit("newInfo",r)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(W.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(W.debug("_isReadyToReOffer() | session not established yet"),!1):(W.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(W.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(W.debug("close() | closing local MediaStream"),qe.closeMediaStream(this._localMediaStream)),this._status!==X.STATUS_TERMINATED){if(this._status=X.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){W.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=wi.T1;function a(){this._status===X.STATUS_WAITING_FOR_ACK&&(r.reply(200,null,[`Contact: ${this._contact}`],n),o<wi.T2&&(o=o*2,o>wi.T2&&(o=wi.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),o))}this._timers.invite2xxTimer=setTimeout(a.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===X.STATUS_WAITING_FOR_ACK&&(W.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(ae.BYE),this._ended("remote",null,ae.causes.NO_ACK))},wi.TIMER_H)}_createRTCConnection(r,n){this._connection=new RTCPeerConnection(r,n),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:ae.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ae.causes.RTP_TIMEOUT})}),W.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(r,n){if(W.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=>(W.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(n).catch(a=>(W.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,W.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 W.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};W.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 Hl(this,r,n,Hl.C.STATUS_EARLY),p.error?(W.debug(p.error),this._failed("remote",r,ae.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 Hl(this,r,n);return h.error?(W.debug(h.error),this._failed("remote",r,ae.causes.INTERNAL_ERROR),!1):(this._dialog=h,!0)}}_receiveReinvite(r){W.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!==X.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"){W.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==X.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{W.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=X.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(r,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(r){W.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!==X.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"){W.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==X.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{W.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){W.debug("_processInDialogSdpOffer()");const n=r.parseSDP();let o=!1;for(const s of n.media){if(Fl.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};W.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===X.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(s=>{throw r.reply(488),W.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',s),this.emit("peerconnection:setremotedescriptionfailed",s),s})}).then(()=>{if(this._status===X.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===X.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(s=>{throw r.reply(500),W.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',s),s})}).catch(s=>{W.warn("_processInDialogSdpOffer() failed [error: %o]",s)}),this._connectionPromiseQueue}_receiveRefer(r){if(W.debug("receiveRefer()"),!r.refer_to){W.debug("no Refer-To header field present in REFER"),r.reply(400);return}if(r.refer_to.uri.scheme!==ae.SIP){W.debug("Refer-To header field points to a non-SIP URI scheme"),r.reply(416);return}r.reply(202);const n=new tg(this,r.cseq);W.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!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED)return!1;const p=new Ja(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(W.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){W.debug("receiveReplaces()");function n(a){if(this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_CONFIRMED)return!1;const t=new Ja(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(r,a)}function o(){W.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 eg(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===X.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,ae.causes.USER_DENIED_MEDIA_ACCESS),W.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===X.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,ae.causes.WEBRTC_ERROR),s})}).then(t=>{if(this._is_canceled||this._status===X.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=X.STATUS_INVITE_SENT,W.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==X.STATUS_TERMINATED&&W.warn(t)})}_getDTMFRTPSender(){const r=this._connection.getSenders().find(n=>n.track&&n.track.kind==="audio");if(!(r&&r.dtmf)){W.warn("sendDTMF() | no local audio track to send DTMF with");return}return r.dtmf}_receiveInviteResponse(r){if(W.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(ae.ACK);return}else{const n=new Hl(this,r,"UAC");if(n.error!==void 0){W.debug(n.error);return}this.sendRequest(ae.ACK),this.sendRequest(ae.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!==X.STATUS_INVITE_SENT&&this._status!==X.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(r.status_code):this._status=X.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(r.status_code):{if(!r.to_tag){W.debug("1xx response received without to tag");break}if(r.hasHeader("contact")&&!this._createDialog(r,"UAC",!0))break;if(this._status=X.STATUS_1XX_RECEIVED,!r.body){this._progress("remote",r);break}const n={originator:"remote",type:"answer",sdp:r.body};W.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=>{W.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=X.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,ae.causes.MISSING_SDP),this._failed("remote",r,ae.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(r,"UAC"))break;const n={originator:"remote",type:"answer",sdp:r.body};W.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,ae.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(ae.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(r,488,"Not Acceptable Here"),this._failed("remote",r,ae.causes.BAD_MEDIA_DESCRIPTION),W.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={}){W.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};W.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(ae.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===X.STATUS_TERMINATED||(this.sendRequest(ae.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};W.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),W.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',v),this.emit("peerconnection:setremotedescriptionfailed",v)})}function p(h){o.failed&&o.failed(h)}}_sendUpdate(r={}){W.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};W.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(ae.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(ae.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!==X.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};W.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),W.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){W.debug("acceptAndTerminate()");const a=[];n&&(o=o||ae.REASON_PHRASE[n]||"",a.push(`Reason: SIP ;cause=${n}; text="${o}"`)),(this._dialog||this._createDialog(r,"UAC"))&&(this.sendRequest(ae.ACK),this.sendRequest(ae.BYE,{extraHeaders:a})),this._status=X.STATUS_TERMINATED}_mangleOffer(r){if(!this._localHold&&!this._remoteHold)return r;if(r=Vc.parse(r),this._localHold&&!this._remoteHold){W.debug("mangleOffer() | me on hold, mangling offer");for(const n of r.media)Fl.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){W.debug("mangleOffer() | both on hold, mangling offer");for(const n of r.media)Fl.indexOf(n.type)!==-1&&(n.direction="inactive")}else if(this._remoteHold){W.debug("mangleOffer() | remote on hold, mangling offer");for(const n of r.media)Fl.indexOf(n.type)!==-1&&(n.direction?n.direction==="sendrecv"?n.direction="recvonly":n.direction==="recvonly"&&(n.direction="inactive"):n.direction="recvonly")}return Vc.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>=ae.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>=ae.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!==X.STATUS_TERMINATED&&this._isReadyToReOffer()&&(W.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===ae.UPDATE?this._sendUpdate():this._sendReinvite())},r*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==X.STATUS_TERMINATED&&(W.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:ae.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){W.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:r,session:this,request:n})}_connecting(r){W.debug("session connecting"),W.debug('emit "connecting"'),this.emit("connecting",{request:r})}_progress(r,n){W.debug("session progress"),W.debug('emit "progress"'),this.emit("progress",{originator:r,response:n||null})}_accepted(r,n){W.debug("session accepted"),this._start_time=new Date,W.debug('emit "accepted"'),this.emit("accepted",{originator:r,response:n||null})}_confirmed(r,n){W.debug("session confirmed"),this._is_confirmed=!0,W.debug('emit "confirmed"'),this.emit("confirmed",{originator:r,ack:n||null})}_ended(r,n,o){W.debug("session ended"),this._end_time=new Date,this._close(),W.debug('emit "ended"'),this.emit("ended",{originator:r,message:n||null,cause:o})}_failed(r,n,o){W.debug("session failed"),W.debug('emit "_failed"'),this.emit("_failed",{originator:r,message:n||null,cause:o}),this._close(),W.debug('emit "failed"'),this.emit("failed",{originator:r,message:n||null,cause:o})}_onhold(r){W.debug("session onhold"),this._setLocalMediaStatus(),W.debug('emit "hold"'),this.emit("hold",{originator:r})}_onunhold(r){W.debug("session onunhold"),this._setLocalMediaStatus(),W.debug('emit "unhold"'),this.emit("unhold",{originator:r})}_onmute({audio:r,video:n}){W.debug("session onmute"),this._setLocalMediaStatus(),W.debug('emit "muted"'),this.emit("muted",{audio:r,video:n})}_onunmute({audio:r,video:n}){W.debug("session onunmute"),this._setLocalMediaStatus(),W.debug('emit "unmuted"'),this.emit("unmuted",{audio:r,video:n})}};const ng=xt(Gf),rg=pt.EventEmitter,ig=lt,Ca=De,lg=ts,Oi=mt(),og=lr,Kc=ps,ag=ds(),ql=new ig("Message");var ug=class extends rg{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=Oi.cloneArray(o.extraHeaders),s=Oi.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",h={};o.fromUserName&&(h.from_uri=new ag("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 lg.OutgoingRequest(Ca.MESSAGE,r,this._ua,h,t),n&&(this._request.body=n);const d=new og(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=Oi.cloneArray(r.extraHeaders),o=r.body;if(this._direction!=="incoming")throw new Kc.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=Oi.cloneArray(r.extraHeaders),t=r.body;if(this._direction!=="incoming")throw new Kc.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=Oi.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Ca.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Ca.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){ql.debug("MESSAGE failed"),this._close(),ql.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){ql.debug("MESSAGE succeeded"),this._close(),ql.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}};const cg=pt.EventEmitter,fg=lt,Aa=De,hg=ts,Di=mt(),_g=lr,Wc=ps,Vl=new fg("Options");var dg=class extends cg{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=Di.cloneArray(o.extraHeaders),s=Di.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 hg.OutgoingRequest(Aa.OPTIONS,r,this._ua,null,t),n&&(this._request.body=n);const h=new _g(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=Di.cloneArray(r.extraHeaders),o=r.body;if(this._direction!=="incoming")throw new Wc.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=Di.cloneArray(r.extraHeaders),t=r.body;if(this._direction!=="incoming")throw new Wc.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=Di.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Aa.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Aa.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){Vl.debug("OPTIONS failed"),this._close(),Vl.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){Vl.debug("OPTIONS succeeded"),this._close(),Vl.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}},_u={};const pg=lt,Ra=mt(),mg=es(),Ni=new pg("Socket");_u.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return Ni.warn("undefined JsSIP.Socket instance"),!1;try{if(!Ra.isString(c.url))throw Ni.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!Ra.isString(c.via_transport))throw Ni.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(mg.parse(c.sip_uri,"SIP_URI")===-1)throw Ni.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(!Ra.isFunction(c[r]))throw Ni.warn(`missing or invalid JsSIP.Socket method: ${r}`),new Error(`Missing or invalid JsSIP.Socket method: ${r}`)})}catch{return!1}return!0};const gg=lt,vg=_u,Yc=De,Rt=new gg("Transport"),kt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Yc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Yc.CONNECTION_RECOVERY_MAX_INTERVAL}};var Tg=class{constructor(r,n=kt.recovery_options){Rt.debug("new()"),this.status=kt.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: ${o}`)}if(typeof r>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");r instanceof Array||(r=[r]),r.forEach(function(o){if(!vg.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:kt.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(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=kt.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(){Rt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=kt.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(Rt.debug("send()"),!this.isConnected())return Rt.warn("unable to send message, transport is not connected"),!1;const n=r.toString();return Rt.debug(`sending message:
|
116
|
-
|
117
|
-
${n}
|
118
|
-
`),this.socket.send(n)}isConnected(){return this.status===kt.STATUS_CONNECTED}isConnecting(){return this.status===kt.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),Rt.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!==kt.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=kt.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=kt.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(r,n,o){this.status=kt.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=kt.SOCKET_STATUS_ERROR)},this),this._reconnect(r))}_onData(r){if(r===`\r
|
119
|
-
`){Rt.debug("received message with CRLF Keep Alive response");return}else if(typeof r!="string"){try{this.textDecoder?r=this.textDecoder.decode(r):r=String.fromCharCode.apply(null,new Uint8Array(r))}catch{Rt.debug("received binary message failed to be converted into string, message discarded");return}Rt.debug(`received binary message:
|
112
|
+
`,this.transport.send(a)}}class Rm extends Zf{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var xt={OutgoingRequest:Po,InitialOutgoingInviteRequest:Cu,IncomingRequest:Cm,IncomingResponse:Rm};const Im=at,_s=Et(),Wt=new Im("DigestAuthentication");var e_=class{constructor(n){this._credentials=n,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(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:Wt.warn('get() | cannot get "%s" parameter',n);return}}authenticate({method:n,ruri:r,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 Wt.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Wt.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Wt.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Wt.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Wt.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 Wt.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=n,this._uri=r,this._cnonce=t||_s.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=_s.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,_;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,_=_s.calculateMD5(p),Wt.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=_s.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${_}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${_s.calculateMD5(o||"")}`,_=_s.calculateMD5(p),Wt.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=_s.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${_}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,_=_s.calculateMD5(p),Wt.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=_s.calculateMD5(`${this._ha1}:${this._nonce}:${_}`)),Wt.debug("authenticate() | response generated"),!0}toString(){const n=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return n.push(`algorithm=${this._algorithm}`),n.push(`username="${this._credentials.username}"`),n.push(`realm="${this._realm}"`),n.push(`nonce="${this._nonce}"`),n.push(`uri="${this._uri}"`),n.push(`response="${this._response}"`),this._opaque&&n.push(`opaque="${this._opaque}"`),this._qop&&(n.push(`qop=${this._qop}`),n.push(`cnonce="${this._cnonce}"`),n.push(`nc=${this._ncHex}`)),`Digest ${n.join(", ")}`}};const bm=ot(e_),hs=500,wm=4e3,Gc=5e3;var Ru={T1:hs,T2:wm,T4:Gc,TIMER_B:64*hs,TIMER_D:0*hs,TIMER_F:64*hs,TIMER_H:64*hs,TIMER_I:0*hs,TIMER_J:0*hs,TIMER_K:0*Gc,TIMER_L:64*hs,TIMER_M:64*hs,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Di=ot(Ru),rl=ct.EventEmitter,il=at,ji=Ue,Wc=xt,ns=Ru,Kc=new il("NonInviteClientTransaction"),Fl=new il("InviteClientTransaction"),Om=new il("AckClientTransaction"),Yc=new il("NonInviteServerTransaction"),Vl=new il("InviteServerTransaction"),he={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 Dm extends rl{constructor(n,r,o,a){super(),this.type=he.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=r,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${r.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return he}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(he.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},ns.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){Kc.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){Kc.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(n){const r=n.status_code;if(r<200)switch(this.state){case he.STATUS_TRYING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}else switch(this.state){case he.STATUS_TRYING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_COMPLETED),clearTimeout(this.F),r===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(n),this.K=setTimeout(()=>{this.timer_K()},ns.TIMER_K);break;case he.STATUS_COMPLETED:break}}}class Nm extends rl{constructor(n,r,o,a){super(),this.type=he.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=r,this.request=o,this.eventHandlers=a,o.transaction=this;let t=`SIP/2.0/${r.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return he}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(he.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},ns.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==he.STATUS_ACCEPTED&&(Fl.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){Fl.debug(`Timer M expired for transaction ${this.id}`),this.state===he.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){Fl.debug(`Timer B expired for transaction ${this.id}`),this.state===he.STATUS_CALLING&&(this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){Fl.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(n){const r=new Wc.OutgoingRequest(ji.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});r.setHeader("from",this.request.getHeader("from")),r.setHeader("via",this.request.getHeader("via")),r.setHeader("to",n.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},ns.TIMER_D),this.transport.send(r)}cancel(n){if(this.state!==he.STATUS_PROCEEDING)return;const r=new Wc.OutgoingRequest(ji.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});r.setHeader("from",this.request.getHeader("from")),r.setHeader("via",this.request.getHeader("via")),r.setHeader("to",this.request.getHeader("to")),n&&r.setHeader("reason",n),this.transport.send(r)}receiveResponse(n){const r=n.status_code;if(r>=100&&r<=199)switch(this.state){case he.STATUS_CALLING:this.stateChanged(he.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break;case he.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(n);break}else if(r>=200&&r<=299)switch(this.state){case he.STATUS_CALLING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},ns.TIMER_M),this.eventHandlers.onReceiveResponse(n);break;case he.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(n);break}else if(r>=300&&r<=699)switch(this.state){case he.STATUS_CALLING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_COMPLETED),this.sendACK(n),this.eventHandlers.onReceiveResponse(n);break;case he.STATUS_COMPLETED:this.sendACK(n);break}}}class Um extends rl{constructor(n,r,o,a){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=r,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${r.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return he}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Om.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class Pm extends rl{constructor(n,r,o){super(),this.type=he.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=r,this.request=o,this.last_response="",o.server_transaction=this,this.state=he.STATUS_TRYING,n.newTransaction(this)}get C(){return he}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_J(){Yc.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,Yc.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(n,r,o,a){if(n===100)switch(this.state){case he.STATUS_TRYING:this.stateChanged(he.STATUS_PROCEEDING),this.transport.send(r)||this.onTransportError();break;case he.STATUS_PROCEEDING:this.last_response=r,this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(n>=200&&n<=699)switch(this.state){case he.STATUS_TRYING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_COMPLETED),this.last_response=r,this.J=setTimeout(()=>{this.timer_J()},ns.TIMER_J),this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break;case he.STATUS_COMPLETED:break}}}class xm extends rl{constructor(n,r,o){super(),this.type=he.INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=r,this.request=o,this.last_response="",o.server_transaction=this,this.state=he.STATUS_PROCEEDING,n.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return he}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_H(){Vl.debug(`Timer H expired for transaction ${this.id}`),this.state===he.STATUS_COMPLETED&&Vl.debug("ACK not received, dialog will be terminated"),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){Vl.debug(`Timer L expired for transaction ${this.id}`),this.state===he.STATUS_ACCEPTED&&(this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,Vl.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(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(n,r,o,a){if(n>=100&&n<=199)switch(this.state){case he.STATUS_PROCEEDING:this.transport.send(r)||this.onTransportError(),this.last_response=r;break}if(n>100&&n<=199&&this.state===he.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},ns.PROVISIONAL_RESPONSE_INTERVAL));else if(n>=200&&n<=299)switch(this.state){case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_ACCEPTED),this.last_response=r,this.L=setTimeout(()=>{this.timer_L()},ns.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case he.STATUS_ACCEPTED:this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(n>=300&&n<=699)switch(this.state){case he.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(r)?(this.stateChanged(he.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},ns.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function Mm({_transactions:c},n){let r;switch(n.method){case ji.INVITE:if(r=c.ist[n.via_branch],r){switch(r.state){case he.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case he.STATUS_ACCEPTED:break}return!0}break;case ji.ACK:if(r=c.ist[n.via_branch],r){if(r.state===he.STATUS_ACCEPTED)return!1;if(r.state===he.STATUS_COMPLETED)return r.state=he.STATUS_CONFIRMED,r.I=setTimeout(()=>{r.timer_I()},ns.TIMER_I),!0}else return!1;break;case ji.CANCEL:return r=c.ist[n.via_branch],r?(n.reply_sl(200),r.state!==he.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:if(r=c.nist[n.via_branch],r){switch(r.state){case he.STATUS_TRYING:break;case he.STATUS_PROCEEDING:case he.STATUS_COMPLETED:r.transport.send(r.last_response);break}return!0}break}}var cr={C:he,NonInviteClientTransaction:Dm,InviteClientTransaction:Nm,AckClientTransaction:Um,NonInviteServerTransaction:Pm,InviteServerTransaction:xm,checkTransaction:Mm};const qt=ot(cr),km=at,zc=Ue,Lm=e_,Ca=cr,$m=new km("RequestSender"),Ra={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var fr=class{constructor(n,r,o){this._ua=n,this._eventHandlers=o,this._method=r.method,this._request=r,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]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==zc.BYE||this._method!==zc.ACK)&&this._eventHandlers.onTransportError()}send(){const n={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:r=>{this._receiveResponse(r)}};switch(this._method){case"INVITE":this.clientTransaction=new Ca.InviteClientTransaction(this._ua,this._ua.transport,this._request,n);break;case"ACK":this.clientTransaction=new Ca.AckClientTransaction(this._ua,this._ua.transport,this._request,n);break;default:this.clientTransaction=new Ca.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,n)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(n){let r,o;const a=n.status_code;if((a===401||a===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(r=n.parseHeader("www-authenticate"),o="authorization"):(r=n.parseHeader("proxy-authenticate"),o="proxy-authorization"),!r){$m.debug(`${n.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&r.stale===!0){if(this._auth||(this._auth=new Lm({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,r)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),r.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(n)}else this._eventHandlers.onReceiveResponse(n)}};const t_=ot(fr),Hm=at,Ia=Et(),_n=Ue,Jc=xt,Xc=fr,Ni=new Hm("Registrator"),jl=10;var Fm=class{constructor(n,r){this._reg_id=1,this._ua=n,this._transport=r,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=Ia.createRandomToken(22),this._cseq=0,this._to_uri=n.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(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const o=n[r];this._extraContactParams+=`;${r}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Ni.debug("Register request in progress...");return}const n=this._extraHeaders.slice();n.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),n.push(`Expires: ${this._expires}`);const r=new Jc.OutgoingRequest(_n.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n),o=new Xc(this._ua,r,{onRequestTimeout:()=>{this._registrationFailure(null,_n.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,_n.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")){Ni.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){Ni.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<jl&&(p=jl);const _=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")},_),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<jl&&(this._expires=jl),this.register()):(Ni.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,_n.causes.SIP_FAILURE_CODE));break}default:{const t=Ia.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(n={}){if(!this._registered){Ni.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const r=this._extraHeaders.slice();n.all?r.push(`Contact: *${this._extraContactParams}`):r.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),r.push("Expires: 0");const o=new Jc.OutgoingRequest(_n.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r);new Xc(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,_n.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,_n.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(n,r){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:r}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:r}))}_unregistered(n,r){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:r||null})}};class Vm extends Error{constructor(n,r){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=n,this.value=r,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class jm extends Error{constructor(n){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=n,this.message=`Invalid status: ${n}`}}class qm extends Error{constructor(n){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=n}}class Bm extends Error{constructor(n){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=n}}var vs={ConfigurationError:Vm,InvalidStateError:jm,NotSupportedError:qm,NotReadyError:Bm};const mn=ot(vs),ba=Ue,ql=cr,Gm=fr,wa={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var s_=class{constructor(n,r,o){this._dialog=n,this._ua=n._ua,this._request=r,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 n=new Gm(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:r=>{this._eventHandlers.onAuthenticated(r)},onReceiveResponse:r=>{this._receiveResponse(r)}});if(n.send(),(this._request.method===ba.INVITE||this._request.method===ba.UPDATE&&this._request.body)&&n.clientTransaction.state!==ql.C.STATUS_TERMINATED){console.log("this._request.body",this._request.body),this._dialog.uac_pending_reply=!0;const r=()=>{(n.clientTransaction.state===ql.C.STATUS_ACCEPTED||n.clientTransaction.state===ql.C.STATUS_COMPLETED||n.clientTransaction.state===ql.C.STATUS_TERMINATED)&&(n.clientTransaction.removeListener("stateChanged",r),this._dialog.uac_pending_reply=!1)};n.clientTransaction.on("stateChanged",r)}}_receiveResponse(n){n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===ba.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(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n)}};const Wm=ot(s_),Km=at,Qc=xt,xs=Ue,Ui=cr,Ym=s_,Oa=Et(),Da=new Km("Dialog"),Ms={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var n_=class{static get C(){return Ms}constructor(n,r,o,a=Ms.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!r.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};r instanceof Qc.IncomingResponse&&(a=r.status_code<200?Ms.STATUS_EARLY:Ms.STATUS_CONFIRMED);const t=r.parseHeader("contact");o==="UAS"?(this._id={call_id:r.call_id,local_tag:r.to_tag,remote_tag:r.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=r.cseq,this._local_uri=r.parseHeader("to").uri,this._remote_uri=r.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=r.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:r.call_id,local_tag:r.from_tag,remote_tag:r.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=r.cseq,this._local_uri=r.parseHeader("from").uri,this._remote_uri=r.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=r.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Da.debug(`new ${o} dialog created with status ${this._state===Ms.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(n){this._local_seqnum=n}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(n){this._uac_pending_reply=n}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Ms.STATUS_TERMINATED}update(n,r){this._state=Ms.STATUS_CONFIRMED,Da.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){Da.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Ms.STATUS_TERMINATED}sendRequest(n,r={}){const o=Oa.cloneArray(r.extraHeaders),a=Oa.cloneObject(r.eventHandlers),t=r.body||null,s=this._createRequest(n,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new Ym(this,s,a).send(),s}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===xs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===xs.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,r,o){r=Oa.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=n===xs.CANCEL||n===xs.ACK?this._local_seqnum:this._local_seqnum+=1;return new Qc.OutgoingRequest(n,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},r,o)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===xs.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===xs.INVITE||n.method===xs.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const r=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${r}`]),!1}else{this._uas_pending_reply=!0;const r=()=>{(n.server_transaction.state===Ui.C.STATUS_ACCEPTED||n.server_transaction.state===Ui.C.STATUS_COMPLETED||n.server_transaction.state===Ui.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",r),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",r)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Ui.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===xs.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Ui.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}};const Bl=ot(n_);var Iu={exports:{}};const zm=ct.EventEmitter,Jm=at,Xm=Ue,Qm=vs,Zc=Et(),Zm=new Jm("RTCSession:DTMF"),r_={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Iu.exports=class extends zm{constructor(n){super(),this._session=n,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(n,r={}){if(n===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 Qm.InvalidStateError(this._session.status);const o=Zc.cloneArray(r.extraHeaders);if(this.eventHandlers=Zc.cloneObject(r.eventHandlers),typeof n=="string")n=n.toUpperCase();else if(typeof n=="number")n=n.toString();else throw new TypeError(`Invalid tone: ${n}`);if(n.match(/^[0-9A-DR#*]$/))this._tone=n;else throw new TypeError(`Invalid tone: ${n}`);this._duration=r.duration,o.push("Content-Type: application/dtmf-relay");let a=`Signal=${this._tone}\r
|
113
|
+
`;a+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(Xm.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(n){const r=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,o=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=n,n.reply(200),n.body){const a=n.body.split(`
|
114
|
+
`);a.length>=1&&r.test(a[0])&&(this._tone=a[0].replace(r,"$2")),a.length>=2&&o.test(a[1])&&(this._duration=parseInt(a[1].replace(o,"$2"),10))}this._duration||(this._duration=r_.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:n}):Zm.debug("invalid INFO DTMF received, discarded")}};Iu.exports.C=r_;var i_=Iu.exports;const eg=ot(i_),tg=ct.EventEmitter,sg=Ue,ng=vs,rg=Et();var l_=class extends tg{constructor(n){super(),this._session=n,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(n,r,o={}){if(this._direction="outgoing",n===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 ng.InvalidStateError(this._session.status);this._contentType=n,this._body=r;const a=rg.cloneArray(o.extraHeaders);a.push(`Content-Type: ${n}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(sg.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:r})}init_incoming(n){this._direction="incoming",this.request=n,n.reply(200),this._contentType=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,this._body=n.body,this._session.newInfo({originator:"remote",info:this,request:n})}};const au=ot(l_),ig=at,ef=Ue,lg=new ig("RTCSession:ReferNotifier"),Na={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var o_=class{constructor(n,r,o){this._session=n,this._id=r,this._expires=o||Na.expires,this._active=!0,this.notify(100)}notify(n,r){if(lg.debug("notify()"),this._active===!1)return;r=r||ef.REASON_PHRASE[n]||"";let o;n>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(ef.NOTIFY,{extraHeaders:[`Event: ${Na.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${Na.body_type}`],body:`SIP/2.0 ${n} ${r}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const og=ot(o_),ag=ct.EventEmitter,ug=at,Pi=Ue,cg=is(),tf=Et(),hn=new ug("RTCSession:ReferSubscriber");var a_=class extends ag{constructor(n){super(),this._id=null,this._session=n}get id(){return this._id}sendRefer(n,r={}){hn.debug("sendRefer()");const o=tf.cloneArray(r.extraHeaders),a=tf.cloneObject(r.eventHandlers);for(const _ in a)Object.prototype.hasOwnProperty.call(a,_)&&this.on(_,a[_]);let t=null;r.replaces&&(t=r.replaces._request.call_id,t+=`;to-tag=${r.replaces._to_tag}`,t+=`;from-tag=${r.replaces._from_tag}`,t=encodeURIComponent(t));const s=`Refer-To: <${n}${t?`?Replaces=${t}`:""}>`;if(o.push(s),!o.some(_=>_.toLowerCase().startsWith("referred-by:"))){const _=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;o.push(_)}o.push(`Contact: ${this._session.contact}`);const p=this._session.sendRequest(Pi.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:_=>{this._requestSucceeded(_)},onErrorResponse:_=>{this._requestFailed(_,Pi.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Pi.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Pi.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Pi.causes.DIALOG_ERROR)}}});this._id=p.cseq}receiveNotify(n){if(hn.debug("receiveNotify()"),!n.body)return;const r=cg.parse(n.body.trim().split(`\r
|
115
|
+
`,1)[0],"Status_Line");if(r===-1){hn.debug(`receiveNotify() | error parsing NOTIFY body: "${n.body}"`);return}switch(!0){case/^100$/.test(r.status_code):this.emit("trying",{request:n,status_line:r});break;case/^1[0-9]{2}$/.test(r.status_code):this.emit("progress",{request:n,status_line:r});break;case/^2[0-9]{2}$/.test(r.status_code):this.emit("accepted",{request:n,status_line:r});break;default:this.emit("failed",{request:n,status_line:r});break}}_requestSucceeded(n){hn.debug("REFER succeeded"),hn.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:n})}_requestFailed(n,r){hn.debug("REFER failed"),hn.debug('emit "requestFailed"'),this.emit("requestFailed",{response:n||null,cause:r})}};const fg=ot(a_),_g=ct.EventEmitter,sf=Nt,hg=at,fe=Ue,dn=vs,nf=cr,Be=Et(),xi=Ru,dg=xt,Gl=n_,pg=fr,Pt=i_,rf=l_,mg=o_,gg=a_,lf=Ts(),Y=new hg("RTCSession"),Q={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"];var u_=class uu extends _g{static get C(){return Q}constructor(n){Y.debug("new"),super(),this._id=null,this._ua=n,this._status=Q.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:fe.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return Q}get causes(){return fe.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(n){this._data=n}get status(){return this._status}isInProgress(){switch(this._status){case Q.STATUS_NULL:case Q.STATUS_INVITE_SENT:case Q.STATUS_1XX_RECEIVED:case Q.STATUS_INVITE_RECEIVED:case Q.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case Q.STATUS_ANSWERED:case Q.STATUS_WAITING_FOR_ACK:case Q.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case Q.STATUS_CANCELED:case Q.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(n,r={},o){console.log("rtcOfferConstraints connect"),Y.debug("connect()");const a=n,t=Be.cloneObject(r.eventHandlers),s=Be.cloneArray(r.extraHeaders),p=Be.cloneObject(r.mediaConstraints,{audio:!0,video:!0}),_=r.mediaStream||null,d=Be.cloneObject(r.pcConfig,{iceServers:[]}),g=r.rtcConstraints||null,T=r.rtcOfferConstraints||null;if(this._rtcOfferConstraints=T,this._rtcAnswerConstraints=r.rtcAnswerConstraints||null,this._data=r.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==Q.STATUS_NULL)throw new dn.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new dn.NotSupportedError("WebRTC not supported");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&Be.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=fe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=fe.SESSION_EXPIRES);for(const A in t)Object.prototype.hasOwnProperty.call(t,A)&&this.on(A,t[A]);this._from_tag=Be.newTag();const E=r.anonymous||!1,y={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(y.from_display_name="Anonymous",y.from_uri=new lf("sip","anonymous","anonymous.invalid"),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),s.push("Privacy: id")):r.fromUserName&&(y.from_uri=new lf("sip",r.fromUserName,this._ua.configuration.uri.host),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),r.fromDisplayName&&(y.from_display_name=r.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 dg.InitialOutgoingInviteRequest(n,this._ua,y,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,T,_)}init_incoming(n,r){Y.debug("init_incoming()");let o;const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&a!=="application/sdp"){n.reply(415);return}if(this._status=Q.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(o=n.getHeader("expires")*1e3),n.to_tag=Be.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Q.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,fe.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Q.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,fe.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,r&&r(this),this._newRTCSession("remote",n),this._status!==Q.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){Y.debug("answer()");const r=this._request,o=Be.cloneArray(n.extraHeaders),a=Be.cloneObject(n.mediaConstraints),t=n.mediaStream||null,s=Be.cloneObject(n.pcConfig,{iceServers:[]}),p=n.rtcConstraints||null,_=n.rtcAnswerConstraints||null,d=Be.cloneObject(n.rtcOfferConstraints);let g,T=!1,E=!1,y=!1,A=!1;if(this._rtcAnswerConstraints=_,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new dn.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==Q.STATUS_WAITING_FOR_ANSWER)throw new dn.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Be.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=fe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=fe.SESSION_EXPIRES),this._status=Q.STATUS_ANSWERED,!this._createDialog(r,"UAS")){r.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const R=r.parseSDP();Array.isArray(R.media)||(R.media=[R.media]);for(const I of R.media)I.type==="audio"&&(T=!0,(!I.direction||I.direction==="sendrecv")&&(y=!0)),I.type==="video"&&(E=!0,(!I.direction||I.direction==="sendrecv")&&(A=!0));if(t&&a.audio===!1){g=t.getAudioTracks();for(const I of g)t.removeTrack(I)}if(t&&a.video===!1){g=t.getVideoTracks();for(const I of g)t.removeTrack(I)}!t&&a.audio===void 0&&(a.audio=y),!t&&a.video===void 0&&(a.video=A),!t&&!T&&!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(I=>{throw this._status===Q.STATUS_TERMINATED?new Error("terminated"):(r.reply(480),this._failed("local",null,fe.causes.USER_DENIED_MEDIA_ACCESS),Y.warn('emit "getusermediafailed" [error:%o]',I),this.emit("getusermediafailed",I),new Error("getUserMedia() failed"))})}).then(I=>{if(this._status===Q.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=I,I&&I.getTracks().forEach($=>{this._connection.addTrack($,I)})}).then(()=>{if(this._late_sdp)return;const I={originator:"remote",type:"offer",sdp:r.body};Y.debug('emit "sdp"'),this.emit("sdp",I);const $=new RTCSessionDescription({type:"offer",sdp:I.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription($)).catch(L=>{throw r.reply(488),this._failed("system",null,fe.causes.WEBRTC_ERROR),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===Q.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(r),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw r.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",_).catch(()=>{throw r.reply(500),new Error("_createLocalDescription() failed")})}).then(I=>{if(this._status===Q.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(r,o),r.reply(200,null,o,I,()=>{this._status=Q.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(r,I),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,fe.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==Q.STATUS_TERMINATED&&Y.warn(I)})}terminate(n={}){Y.debug("terminate()");const r=n.cause||fe.causes.BYE,o=Be.cloneArray(n.extraHeaders),a=n.body;let t,s=n.status_code,p=n.reason_phrase;if(this._status===Q.STATUS_TERMINATED)throw new dn.InvalidStateError(this._status);switch(this._status){case Q.STATUS_NULL:case Q.STATUS_INVITE_SENT:case Q.STATUS_1XX_RECEIVED:if(Y.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||fe.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===Q.STATUS_NULL||this._status===Q.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===Q.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=Q.STATUS_CANCELED,this._failed("local",null,fe.causes.CANCELED);break;case Q.STATUS_WAITING_FOR_ANSWER:case Q.STATUS_ANSWERED:if(Y.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,fe.causes.REJECTED);break;case Q.STATUS_WAITING_FOR_ACK:case Q.STATUS_CONFIRMED:if(Y.debug("terminating session"),p=n.reason_phrase||fe.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===Q.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==nf.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===fe.ACK&&(this.sendRequest(fe.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===nf.C.STATUS_TERMINATED&&(this.sendRequest(fe.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else this.sendRequest(fe.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendDTMF(n,r={}){Y.debug("sendDTMF() | tones: %s",n);let o=0,a=r.duration||null,t=r.interToneGap||null;const s=r.transportType||fe.DTMF_TRANSPORT.INFO;if(n===void 0)throw new TypeError("Not enough arguments");if(this._status!==Q.STATUS_CONFIRMED&&this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_1XX_RECEIVED)throw new dn.InvalidStateError(this._status);if(s!==fe.DTMF_TRANSPORT.INFO&&s!==fe.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${s}`);if(typeof n=="number"&&(n=n.toString()),!n||typeof n!="string"||!n.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${n}`);if(a&&!Be.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<Pt.C.MIN_DURATION?(Y.debug(`"duration" value is lower than the minimum allowed, setting it to ${Pt.C.MIN_DURATION} milliseconds`),a=Pt.C.MIN_DURATION):a>Pt.C.MAX_DURATION?(Y.debug(`"duration" value is greater than the maximum allowed, setting it to ${Pt.C.MAX_DURATION} milliseconds`),a=Pt.C.MAX_DURATION):a=Math.abs(a):a=Pt.C.DEFAULT_DURATION,r.duration=a,t&&!Be.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<Pt.C.MIN_INTER_TONE_GAP?(Y.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${Pt.C.MIN_INTER_TONE_GAP} milliseconds`),t=Pt.C.MIN_INTER_TONE_GAP):t=Math.abs(t):t=Pt.C.DEFAULT_INTER_TONE_GAP,s===fe.DTMF_TRANSPORT.RFC2833){const _=this._getDTMFRTPSender();_&&(n=_.toneBuffer+n,_.insertDTMF(n,a,t));return}if(this._tones){this._tones+=n;return}this._tones=n,p.call(this);function p(){let _;if(this._status===Q.STATUS_TERMINATED||!this._tones||o>=this._tones.length){this._tones=null;return}const d=this._tones[o];if(o+=1,d===",")_=2e3;else{const g=new Pt(this);r.eventHandlers={onFailed:()=>{this._tones=null}},g.send(d,r),_=a+t}setTimeout(p.bind(this),_)}}sendInfo(n,r,o={}){if(Y.debug("sendInfo()"),this._status!==Q.STATUS_CONFIRMED&&this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_1XX_RECEIVED)throw new dn.InvalidStateError(this._status);new rf(this).send(n,r,o)}mute(n={audio:!0,video:!1}){Y.debug("mute()");let r=!1,o=!1;this._audioMuted===!1&&n.audio&&(r=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(r===!0||o===!0)&&this._onmute({audio:r,video:o})}unmute(n={audio:!0,video:!0}){Y.debug("unmute()");let r=!1,o=!1;this._audioMuted===!0&&n.audio&&(r=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(r===!0||o===!0)&&this._onunmute({audio:r,video:o})}hold(n={},r){if(Y.debug("hold()"),this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:fe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}unhold(n={},r){if(Y.debug("unhold()"),this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:fe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},r){Y.debug("renegotiate()");const o=n.rtcOfferConstraints||null;if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:fe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}),!0}refer(n,r){Y.debug("refer()");const o=n;if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const a=new gg(this);a.sendRefer(n,r);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(n,r){return Y.debug("sendRequest()"),this._dialog.sendRequest(n,r)}receiveRequest(n){if(Y.debug("receiveRequest()"),n.method===fe.CANCEL)(this._status===Q.STATUS_WAITING_FOR_ANSWER||this._status===Q.STATUS_ANSWERED)&&(this._status=Q.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,fe.causes.CANCELED));else switch(n.method){case fe.ACK:if(this._status!==Q.STATUS_WAITING_FOR_ACK)return;if(this._status=Q.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:fe.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:n.body};Y.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(a=>{this.terminate({cause:fe.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",n);break;case fe.BYE:this._status===Q.STATUS_CONFIRMED||this._status===Q.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,fe.causes.BYE)):this._status===Q.STATUS_INVITE_RECEIVED||this._status===Q.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,fe.causes.BYE)):n.reply(403,"Wrong Status");break;case fe.INVITE:this._status===Q.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case fe.INFO:if(this._status===Q.STATUS_1XX_RECEIVED||this._status===Q.STATUS_WAITING_FOR_ANSWER||this._status===Q.STATUS_ANSWERED||this._status===Q.STATUS_WAITING_FOR_ACK||this._status===Q.STATUS_CONFIRMED){const r=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;r&&r.match(/^application\/dtmf-relay/i)?new Pt(this).init_incoming(n):r!==void 0?new rf(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break;case fe.UPDATE:this._status===Q.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case fe.REFER:this._status===Q.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case fe.NOTIFY:this._status===Q.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){Y.warn("onTransportError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:fe.causes.CONNECTION_ERROR,cause:fe.causes.CONNECTION_ERROR})}onRequestTimeout(){Y.warn("onRequestTimeout()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:fe.causes.REQUEST_TIMEOUT,cause:fe.causes.REQUEST_TIMEOUT})}onDialogError(){Y.warn("onDialogError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:fe.causes.DIALOG_ERROR,cause:fe.causes.DIALOG_ERROR})}newDTMF(n){Y.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){Y.debug("newInfo()"),this.emit("newInfo",n)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(Y.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(Y.debug("_isReadyToReOffer() | session not established yet"),!1):(Y.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(Y.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(Y.debug("close() | closing local MediaStream"),Be.closeMediaStream(this._localMediaStream)),this._status!==Q.STATUS_TERMINATED){if(this._status=Q.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){Y.warn("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(n,r){let o=xi.T1;function a(){this._status===Q.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],r),o<xi.T2&&(o=o*2,o>xi.T2&&(o=xi.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),o))}this._timers.invite2xxTimer=setTimeout(a.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===Q.STATUS_WAITING_FOR_ACK&&(Y.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(fe.BYE),this._ended("remote",null,fe.causes.NO_ACK))},xi.TIMER_H)}_createRTCConnection(n,r){this._connection=new RTCPeerConnection(n,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:fe.causes.RTP_TIMEOUT,status_code:408,reason_phrase:fe.causes.RTP_TIMEOUT})}),Y.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,r){if(Y.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?o.createOffer(r).catch(a=>(Y.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(r).catch(a=>(Y.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,Y.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=r&&r.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:n,sdp:o.localDescription.sdp};return Y.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let s=!1,p,_;this._iceReady=!1;const d=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",_),s=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:n,sdp:o.localDescription.sdp};Y.debug('emit "sdp"'),this.emit("sdp",g),t(g.sdp)};o.addEventListener("icecandidate",p=g=>{const T=g.candidate;T?this.emit("icecandidate",{candidate:T,ready:d}):s||d()}),o.addEventListener("icegatheringstatechange",_=()=>{o.iceGatheringState==="complete"&&!s&&d()})})})}_createDialog(n,r,o){const a=r==="UAS"?n.to_tag:n.from_tag,t=r==="UAS"?n.from_tag:n.to_tag,s=n.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Gl(this,n,r,Gl.C.STATUS_EARLY),p.error?(Y.debug(p.error),this._failed("remote",n,fe.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,p)return p.update(n,r),this._dialog=p,delete this._earlyDialogs[s],!0;const _=new Gl(this,n,r);return _.error?(Y.debug(_.error),this._failed("remote",n,fe.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_receiveReinvite(n){Y.debug("receiveReinvite()");const r=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,d=p.reason_phrase||"",g=Be.cloneArray(p.extraHeaders);if(this._status!==Q.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);n.reply(_,d,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!n.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(()=>{n.reply(500)});return}if(r!=="application/sdp"){Y.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==Q.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{Y.warn(p)});function s(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,_),this._late_sdp&&(p=this._mangleOffer(p)),n.reply(200,null,_,p,()=>{this._status=Q.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(n){Y.debug("receiveUpdate()");const r=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,d=p.reason_phrase||"",g=Be.cloneArray(p.extraHeaders);if(this._status!==Q.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);n.reply(_,d,g)}if(this.emit("update",o),a)return;if(!n.body){s.call(this,null);return}if(r!=="application/sdp"){Y.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==Q.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{Y.warn(p)});function s(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,_),n.reply(200,null,_,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(n){Y.debug("_processInDialogSdpOffer()");const r=n.parseSDP();let o=!1;for(const s of r.media){if(Wl.indexOf(s.type)===-1)continue;const p=s.direction||r.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:n.body};Y.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===Q.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(s=>{throw n.reply(488),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',s),this.emit("peerconnection:setremotedescriptionfailed",s),s})}).then(()=>{if(this._status===Q.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===Q.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(s=>{throw n.reply(500),Y.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',s),s})}).catch(s=>{Y.warn("_processInDialogSdpOffer() failed [error: %o]",s)}),this._connectionPromiseQueue}_receiveRefer(n){if(Y.debug("receiveRefer()"),!n.refer_to){Y.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==fe.SIP){Y.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const r=new mg(this,n.cseq);Y.debug('emit "refer"'),this.emit("refer",{request:n,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!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;const p=new uu(this._ua);if(p.on("progress",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),p.on("accepted",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),p.on("_failed",({message:_,cause:d})=>{_?r.notify(_.status_code,_.reason_phrase):r.notify(487,d)}),n.refer_to.uri.hasHeader("replaces")){const _=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));s.extraHeaders=Be.cloneArray(s.extraHeaders),s.extraHeaders.push(`Replaces: ${_}`)}p.connect(n.refer_to.uri.toAor(),s,t)}function a(){r.notify(603)}}_receiveNotify(n){switch(Y.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let r,o;if(n.event.params&&n.event.params.id)r=n.event.params.id,o=this._referSubscribers[r];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!o){n.reply(481,"Subscription does not exist");return}o.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){Y.debug("receiveReplaces()");function r(a){if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;const t=new uu(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(n,a)}function o(){Y.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:a=>{r.call(this,a)},reject:()=>{o.call(this)}})}_sendInitialRequest(n,r,o){const a=new pg(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(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(t=>{throw this._status===Q.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,fe.causes.USER_DENIED_MEDIA_ACCESS),Y.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===Q.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",r).catch(s=>{throw this._failed("local",null,fe.causes.WEBRTC_ERROR),s})}).then(t=>{if(this._is_canceled||this._status===Q.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=Q.STATUS_INVITE_SENT,Y.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==Q.STATUS_TERMINATED&&Y.warn(t)})}_getDTMFRTPSender(){const n=this._connection.getSenders().find(r=>r.track&&r.track.kind==="audio");if(!(n&&n.dtmf)){Y.warn("sendDTMF() | no local audio track to send DTMF with");return}return n.dtmf}_receiveInviteResponse(n){if(Y.debug("receiveInviteResponse()"),this._dialog&&n.status_code>=200&&n.status_code<=299)if(this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.sendRequest(fe.ACK);return}else{const r=new Gl(this,n,"UAC");if(r.error!==void 0){Y.debug(r.error);return}this.sendRequest(fe.ACK),this.sendRequest(fe.BYE);return}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==Q.STATUS_INVITE_SENT&&this._status!==Q.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):this._status=Q.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){Y.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=Q.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const r={originator:"remote",type:"answer",sdp:n.body};Y.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",n)).catch(a=>{Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=Q.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,fe.causes.MISSING_SDP),this._failed("remote",n,fe.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const r={originator:"remote",type:"answer",sdp:n.body};Y.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.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(n,500,a.toString()),this._failed("local",n,fe.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(fe.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(n,488,"Not Acceptable Here"),this._failed("remote",n,fe.causes.BAD_MEDIA_DESCRIPTION),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const r=Be.sipErrorCause(n.status_code);this._failed("remote",n,r)}}}_sendReinvite(n={}){Y.debug("sendReinvite()");const r=Be.cloneArray(n.extraHeaders),o=Be.cloneObject(n.eventHandlers),a=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;r.push(`Contact: ${this._contact}`),r.push("Content-Type: application/sdp"),this._sessionTimers.running&&r.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(_=>{_=this._mangleOffer(_);const d={originator:"local",type:"offer",sdp:_};Y.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(fe.INVITE,{extraHeaders:r,body:_,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(_){if(this._status===Q.STATUS_TERMINATED||(this.sendRequest(fe.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(_),_.body){if(!_.hasHeader("Content-Type")||_.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const d={originator:"remote",type:"answer",sdp:_.body};Y.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(_)}).catch(T=>{p.call(this),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',T),this.emit("peerconnection:setremotedescriptionfailed",T)})}function p(_){o.failed&&o.failed(_)}}_sendUpdate(n={}){Y.debug("sendUpdate()");const r=Be.cloneArray(n.extraHeaders),o=Be.cloneObject(n.eventHandlers),a=n.rtcOfferConstraints||this._rtcOfferConstraints||null,t=n.sdpOffer||!1;let s=!1;r.push(`Contact: ${this._contact}`),this._sessionTimers.running&&r.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(r.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};Y.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(fe.UPDATE,{extraHeaders:r,body:d,eventHandlers:{onSuccessResponse:T=>{p.call(this,T),s=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(fe.UPDATE,{extraHeaders:r,eventHandlers:{onSuccessResponse:d=>{p.call(this,d)},onErrorResponse:d=>{_.call(this,d)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(d){if(this._status!==Q.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(d),t){if(d.body){if(!d.hasHeader("Content-Type")||d.getHeader("Content-Type").toLowerCase()!=="application/sdp"){_.call(this);return}}else{_.call(this);return}const g={originator:"remote",type:"answer",sdp:d.body};Y.debug('emit "sdp"'),this.emit("sdp",g);const T=new RTCSessionDescription({type:"answer",sdp:g.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>{o.succeeded&&o.succeeded(d)}).catch(E=>{_.call(this),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else o.succeeded&&o.succeeded(d)}function _(d){o.failed&&o.failed(d)}}_acceptAndTerminate(n,r,o){Y.debug("acceptAndTerminate()");const a=[];r&&(o=o||fe.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(fe.ACK),this.sendRequest(fe.BYE,{extraHeaders:a})),this._status=Q.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=sf.parse(n),this._localHold&&!this._remoteHold){Y.debug("mangleOffer() | me on hold, mangling offer");for(const r of n.media)Wl.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="sendonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="sendonly")}else if(this._localHold&&this._remoteHold){Y.debug("mangleOffer() | both on hold, mangling offer");for(const r of n.media)Wl.indexOf(r.type)!==-1&&(r.direction="inactive")}else if(this._remoteHold){Y.debug("mangleOffer() | remote on hold, mangling offer");for(const r of n.media)Wl.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="recvonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="recvonly")}return sf.write(n)}_setLocalMediaStatus(){let n=!0,r=!0;(this._localHold||this._remoteHold)&&(n=!1,r=!1),this._audioMuted&&(n=!1),this._videoMuted&&(r=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!r)}_handleSessionTimersInIncomingRequest(n,r){if(!this._sessionTimers.enabled)return;let o;n.session_expires&&n.session_expires>=fe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,o=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),r.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let r;n.session_expires&&n.session_expires>=fe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,r=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}_runSessionTimer(){const n=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==Q.STATUS_TERMINATED&&this._isReadyToReOffer()&&(Y.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===fe.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==Q.STATUS_TERMINATED&&(Y.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:fe.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of r)o.track.enabled=!n}_toggleMuteVideo(n){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of r)o.track.enabled=!n}_newRTCSession(n,r){Y.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:n,session:this,request:r})}_connecting(n){Y.debug("session connecting"),Y.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,r){Y.debug("session progress"),Y.debug('emit "progress"'),this.emit("progress",{originator:n,response:r||null})}_accepted(n,r){Y.debug("session accepted"),this._start_time=new Date,Y.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:r||null})}_confirmed(n,r){Y.debug("session confirmed"),this._is_confirmed=!0,Y.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:r||null})}_ended(n,r,o){Y.debug("session ended"),this._end_time=new Date,this._close(),Y.debug('emit "ended"'),this.emit("ended",{originator:n,message:r||null,cause:o})}_failed(n,r,o){Y.debug("session failed"),Y.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:r||null,cause:o}),this._close(),Y.debug('emit "failed"'),this.emit("failed",{originator:n,message:r||null,cause:o})}_onhold(n){Y.debug("session onhold"),this._setLocalMediaStatus(),Y.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){Y.debug("session onunhold"),this._setLocalMediaStatus(),Y.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:r}){Y.debug("session onmute"),this._setLocalMediaStatus(),Y.debug('emit "muted"'),this.emit("muted",{audio:n,video:r})}_onunmute({audio:n,video:r}){Y.debug("session onunmute"),this._setLocalMediaStatus(),Y.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:r})}};const Tg=ot(u_),vg=ct.EventEmitter,Eg=at,Ua=Ue,Sg=xt,Mi=Et(),yg=fr,of=vs,Ag=Ts(),Kl=new Eg("Message");var Cg=class extends vg{constructor(n){super(),this._ua=n,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(n,r,o={}){const a=n;if(n===void 0||r===void 0)throw new TypeError("Not enough arguments");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${a}`);const t=Mi.cloneArray(o.extraHeaders),s=Mi.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",_={};o.fromUserName&&(_.from_uri=new Ag("sip",o.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(_.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 Sg.OutgoingRequest(Ua.MESSAGE,n,this._ua,_,t),r&&(this._request.body=r);const d=new yg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:g=>{this._receiveResponse(g)}});this._newMessage("local",this._request),d.send()}init_incoming(n){this._request=n,this._newMessage("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const r=Mi.cloneArray(n.extraHeaders),o=n.body;if(this._direction!=="incoming")throw new of.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,r,o)}reject(n={}){const r=n.status_code||480,o=n.reason_phrase,a=Mi.cloneArray(n.extraHeaders),t=n.body;if(this._direction!=="incoming")throw new of.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(r<300||r>=700)throw new TypeError(`Invalid status_code: ${r}`);this._is_replied=!0,this._request.reply(r,o,a,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):this._succeeded("remote",n);break;default:{const r=Mi.sipErrorCause(n.status_code);this._failed("remote",n,r);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Ua.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Ua.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(n,r){n==="remote"?(this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from):n==="local"&&(this._direction="outgoing",this._local_identity=r.from,this._remote_identity=r.to),this._ua.newMessage(this,{originator:n,message:this,request:r})}_failed(n,r,o){Kl.debug("MESSAGE failed"),this._close(),Kl.debug('emit "failed"'),this.emit("failed",{originator:n,response:r||null,cause:o})}_succeeded(n,r){Kl.debug("MESSAGE succeeded"),this._close(),Kl.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:r})}};const Rg=ct.EventEmitter,Ig=at,Pa=Ue,bg=xt,ki=Et(),wg=fr,af=vs,Yl=new Ig("Options");var Og=class extends Rg{constructor(n){super(),this._ua=n,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(n,r,o={}){const a=n;if(n===void 0)throw new TypeError("A target is required for OPTIONS");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${a}`);const t=ki.cloneArray(o.extraHeaders),s=ki.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 bg.OutgoingRequest(Pa.OPTIONS,n,this._ua,null,t),r&&(this._request.body=r);const _=new wg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:d=>{this._receiveResponse(d)}});this._newOptions("local",this._request),_.send()}init_incoming(n){this._request=n,this._newOptions("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const r=ki.cloneArray(n.extraHeaders),o=n.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,r,o)}reject(n={}){const r=n.status_code||480,o=n.reason_phrase,a=ki.cloneArray(n.extraHeaders),t=n.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(r<300||r>=700)throw new TypeError(`Invalid status_code: ${r}`);this._is_replied=!0,this._request.reply(r,o,a,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):this._succeeded("remote",n);break;default:{const r=ki.sipErrorCause(n.status_code);this._failed("remote",n,r);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)}_newOptions(n,r){n==="remote"?(this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from):n==="local"&&(this._direction="outgoing",this._local_identity=r.from,this._remote_identity=r.to),this._ua.newOptions(this,{originator:n,message:this,request:r})}_failed(n,r,o){Yl.debug("OPTIONS failed"),this._close(),Yl.debug('emit "failed"'),this.emit("failed",{originator:n,response:r||null,cause:o})}_succeeded(n,r){Yl.debug("OPTIONS succeeded"),this._close(),Yl.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:r})}},bu={};const Dg=at,xa=Et(),Ng=is(),Li=new Dg("Socket");bu.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return Li.warn("undefined JsSIP.Socket instance"),!1;try{if(!xa.isString(c.url))throw Li.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!xa.isString(c.via_transport))throw Li.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Ng.parse(c.sip_uri,"SIP_URI")===-1)throw Li.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(n=>{if(!xa.isFunction(c[n]))throw Li.warn(`missing or invalid JsSIP.Socket method: ${n}`),new Error(`Missing or invalid JsSIP.Socket method: ${n}`)})}catch{return!1}return!0};const Ug=at,Pg=bu,uf=Ue,Ot=new Ug("Transport"),Vt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:uf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:uf.CONNECTION_RECOVERY_MAX_INTERVAL}};var xg=class{constructor(n,r=Vt.recovery_options){Ot.debug("new()"),this.status=Vt.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=r,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){Ot.warn(`cannot use TextDecoder: ${o}`)}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(o){if(!Pg.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:Vt.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(Ot.debug("connect()"),this.isConnected()){Ot.debug("Transport is already connected");return}else if(this.isConnecting()){Ot.debug("Transport is connecting");return}this.close_requested=!1,this.status=Vt.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(){Ot.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Vt.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(n){if(Ot.debug("send()"),!this.isConnected())return Ot.warn("unable to send message, transport is not connected"),!1;const r=n.toString();return Ot.debug(`sending message:
|
120
116
|
|
121
117
|
${r}
|
122
|
-
`)}
|
118
|
+
`),this.socket.send(r)}isConnected(){return this.status===Vt.STATUS_CONNECTED}isConnecting(){return this.status===Vt.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let n=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);n<this.recovery_options.min_interval?n=this.recovery_options.min_interval:n>this.recovery_options.max_interval&&(n=this.recovery_options.max_interval),Ot.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${n} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},n*1e3)}_getSocket(){let n=[];if(this.sockets.forEach(o=>{o.status!==Vt.SOCKET_STATUS_ERROR&&(n.length===0?n.push(o):o.weight>n[0].weight?n=[o]:o.weight===n[0].weight&&n.push(o))}),n.length===0){this.sockets.forEach(o=>{o.status=Vt.SOCKET_STATUS_READY}),this._getSocket();return}const r=Math.floor(Math.random()*n.length);this.socket=n[r].socket}_onConnect(){this.recover_attempts=0,this.status=Vt.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(n,r,o){this.status=Vt.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:n,code:r,reason:o}),!this.close_requested&&(this.sockets.forEach(function(a){this.socket===a.socket&&(a.status=Vt.SOCKET_STATUS_ERROR)},this),this._reconnect(n))}_onData(n){if(n===`\r
|
119
|
+
`){Ot.debug("received message with CRLF Keep Alive response");return}else if(typeof n!="string"){try{this.textDecoder?n=this.textDecoder.decode(n):n=String.fromCharCode.apply(null,new Uint8Array(n))}catch{Ot.debug("received binary message failed to be converted into string, message discarded");return}Ot.debug(`received binary message:
|
123
120
|
|
124
|
-
${
|
125
|
-
`)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
`,o
|
131
|
-
|
132
|
-
|
121
|
+
${n}
|
122
|
+
`)}else Ot.debug(`received text message:
|
123
|
+
|
124
|
+
${n}
|
125
|
+
`);this.ondata({transport:this,message:n})}},c_={};const Mg=at,cu=is(),fu=xt,zl=new Mg("Parser");c_.parseMessage=(c,n)=>{let r,o,a=c.indexOf(`\r
|
126
|
+
`);if(a===-1){zl.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=c.substring(0,a);let s=cu.parse(t,"Request_Response");if(s===-1){zl.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else s.status_code?(r=new fu.IncomingResponse,r.status_code=s.status_code,r.reason_phrase=s.reason_phrase):(r=new fu.IncomingRequest(n),r.method=s.method,r.ruri=s.uri);r.data=c;let p=a+2;for(;;){if(a=kg(c,p),a===-2){o=p+2;break}else if(a===-1){zl.warn("parseMessage() | malformed message");return}if(s=Lg(r,c,p,a),s!==!0){zl.warn("parseMessage() |",s.error);return}p=a+2}if(r.hasHeader("content-length")){const _=r.getHeader("content-length");r.body=c.substr(o,_)}else r.body=c.substring(o);return r};function kg(c,n){let r=n,o=0,a=0;if(c.substring(r,r+2).match(/(^\r\n)/))return-2;for(;o===0;){if(a=c.indexOf(`\r
|
127
|
+
`,r),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?r=a+2:o=a}return o}function Lg(c,n,r,o){let a;const t=n.indexOf(":",r),s=n.substring(r,t).trim(),p=n.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=cu.parse(p,"Record_Route"),a===-1)a=void 0;else for(const _ of a)c.addHeader("record-route",p.substring(_.possition,_.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=_.parsed;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=cu.parse(p,"Contact"),a===-1)a=void 0;else for(const _ of a)c.addHeader("contact",p.substring(_.possition,_.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=_.parsed;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 fu.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 "${s}"`}:!0}const $g=at,f_=Ue,cf=xt,wu=Et(),Ou=new $g("sanityCheck"),Hg=[zg],Fg=[qg,Bg,Gg,Wg],Vg=[Kg,Yg];let Fe,Zt,__;var jg=(c,n,r)=>{Fe=c,Zt=n,__=r;for(const o of Hg)if(o()===!1)return!1;if(Fe instanceof cf.IncomingRequest){for(const o of Fg)if(o()===!1)return!1}else if(Fe instanceof cf.IncomingResponse){for(const o of Vg)if(o()===!1)return!1}return!0};function qg(){if(Fe.s("to").uri.scheme!=="sip")return Yi(416),!1}function Bg(){if(!Fe.to_tag&&Fe.call_id.substr(0,5)===Zt.configuration.jssip_id)return Yi(482),!1}function Gg(){const c=wu.str_utf8_length(Fe.body),n=Fe.getHeader("content-length");if(c<n)return Yi(400),!1}function Wg(){const c=Fe.from_tag,n=Fe.call_id,r=Fe.cseq;let o;if(!Fe.to_tag)if(Fe.method===f_.INVITE){if(Zt._transactions.ist[Fe.via_branch])return!1;for(const a in Zt._transactions.ist)if(Object.prototype.hasOwnProperty.call(Zt._transactions.ist,a)&&(o=Zt._transactions.ist[a],o.request.from_tag===c&&o.request.call_id===n&&o.request.cseq===r))return Yi(482),!1}else{if(Zt._transactions.nist[Fe.via_branch])return!1;for(const a in Zt._transactions.nist)if(Object.prototype.hasOwnProperty.call(Zt._transactions.nist,a)&&(o=Zt._transactions.nist[a],o.request.from_tag===c&&o.request.call_id===n&&o.request.cseq===r))return Yi(482),!1}}function Kg(){if(Fe.getHeaders("via").length>1)return Ou.debug("more than one Via header field present in the response, dropping the response"),!1}function Yg(){const c=wu.str_utf8_length(Fe.body),n=Fe.getHeader("content-length");if(c<n)return Ou.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function zg(){const c=["from","to","call_id","cseq","via"];for(const n of c)if(!Fe.hasHeader(n))return Ou.debug(`missing mandatory header field : ${n}, dropping the response`),!1}function Yi(c){const n=Fe.getHeaders("via");let r,o=`SIP/2.0 ${c} ${f_.REASON_PHRASE[c]}\r
|
128
|
+
`;for(const a of n)o+=`Via: ${a}\r
|
129
|
+
`;r=Fe.getHeader("To"),Fe.to_tag||(r+=`;tag=${wu.newTag()}`),o+=`To: ${r}\r
|
130
|
+
`,o+=`From: ${Fe.getHeader("From")}\r
|
131
|
+
`,o+=`Call-ID: ${Fe.call_id}\r
|
132
|
+
`,o+=`CSeq: ${Fe.cseq} ${Fe.method}\r
|
133
133
|
`,o+=`\r
|
134
|
-
`,Yf.send(o)}var mu={};const er=mt(),_n=De,Ia=es(),Jc=ds(),ba=_u,wa=ps;mu.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:_n.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:_n.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:_n.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${er.createRandomToken(12)}.invalid`};const Bl={mandatory:{sockets(c){const r=[];if(ba.isSocket(c))r.push({socket:c});else if(Array.isArray(c)&&c.length)for(const n of c)Object.prototype.hasOwnProperty.call(n,"socket")&&ba.isSocket(n.socket)?r.push(n):ba.isSocket(n)&&r.push({socket:n});else return;return r},uri(c){/^sip:/i.test(c)||(c=`${_n.SIP}:${c}`);const r=Jc.parse(c);if(r)return r.user?r:void 0}},optional:{authorization_user(c){if(Ia.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(er.isDecimal(c)){const r=Number(c);if(r>0)return r}},connection_recovery_min_interval(c){if(er.isDecimal(c)){const r=Number(c);if(r>0)return r}},contact_uri(c){if(typeof c=="string"){const r=Ia.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)),Ia.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(er.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===_n.INVITE||c===_n.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(er.isDecimal(c)){const r=Number(c);if(r>0)return r}},registrar_server(c){/^sip:/i.test(c)||(c=`${_n.SIP}:${c}`);const r=Jc.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}}};mu.load=(c,r)=>{for(const n in Bl.mandatory)if(r.hasOwnProperty(n)){const o=r[n],a=Bl.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new wa.ConfigurationError(n,o)}else throw new wa.ConfigurationError(n);for(const n in Bl.optional)if(r.hasOwnProperty(n)){const o=r[n];if(er.isEmpty(o))continue;const a=Bl.optional[n](o);if(a!==void 0)c[n]=a;else throw new wa.ConfigurationError(n,o)}};const Mg=pt.EventEmitter,xg=lt,ut=De,Lg=Cm,Xc=Gf,Qc=ug,Zc=dg,Oa=ir,$g=Tg,Gl=mt(),Hg=ps,Fg=ds(),qg=Kf,Da=ts,Vg=bg,Na=mu,He=new xg("UA"),ht={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var zf=class extends Mg{static get C(){return ht}constructor(r){if(He.debug("new() [configuration:%o]",r),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Na.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=ht.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=ht.STATUS_NOT_READY,this._error=ht.CONFIGURATION_ERROR,n}this._registrator=new Lg(this)}get C(){return ht}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===ht.STATUS_INIT?this._transport.connect():this._status===ht.STATUS_USER_CLOSED?(He.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ht.STATUS_INIT,this._transport.connect()):this._status===ht.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 Xc(this);return o.connect(r,n),o}sendMessage(r,n,o){He.debug("sendMessage()");const a=new Qc(this);return a.send(r,n,o),a}sendOptions(r,n,o){He.debug("sendOptions()");const a=new Zc(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===ht.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=ht.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 Gl.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!==ut.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===ut.SIPS){r.reply_sl(416);return}if(Oa.checkTransaction(this,r))return;if(n===ut.INVITE?new Oa.InviteServerTransaction(this,this._transport,r):n!==ut.ACK&&n!==ut.CANCEL&&new Oa.NonInviteServerTransaction(this,this._transport,r),n===ut.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new Zc(this).init_incoming(r)}else if(n===ut.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new Qc(this).init_incoming(r)}else if(n===ut.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===ut.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!==ut.ACK&&r.reply(481);else switch(n){case ut.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 Xc(this),a.init_incoming(r);else He.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case ut.BYE:r.reply(481);break;case ut.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):He.debug("received CANCEL request for a non existent session");break;case ut.ACK:break;case ut.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{Na.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=Gl.newUUID()),this._configuration.jssip_id=Gl.createRandomToken(5);const n=this._configuration.uri.clone();n.user=null,this._configuration.hostport_params=n.toString().replace(/^sip:/i,"");try{this._transport=new $g(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=jg.bind(this),this._transport.onconnect=Bg.bind(this),this._transport.ondisconnect=Gg.bind(this),this._transport.ondata=Kg.bind(this)}catch(a){throw He.warn(a),new Hg.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 Fg("sip",Gl.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(Na.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 jg(c){this.emit("connecting",c)}function Bg(c){this._status!==ht.STATUS_USER_CLOSED&&(this._status=ht.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Gg(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!==ht.STATUS_USER_CLOSED&&(this._status=ht.STATUS_NOT_READY,this._error=ht.NETWORK_ERROR)}function Kg(c){const r=c.transport;let n=c.message;if(n=qg.parseMessage(n,this),!!n&&!(this._status===ht.STATUS_USER_CLOSED&&n instanceof Da.IncomingRequest)&&Vg(n,this,r)){if(n instanceof Da.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof Da.IncomingResponse){let 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}}}}const Wg=xt(zf);var Ps=mt();class Qn{constructor(r){if(this.headers={},r.length>0){let n=!1;const o=r.split(`\r
|
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===""){
|
136
|
-
`;else{const s=t.split(": ");this.addHeader(s[0],s[1].trim())}}}else this.ident=
|
137
|
-
`;for(const
|
138
|
-
`;return this.body&&(
|
134
|
+
`,__.send(o)}var Du={};const ir=Et(),Tn=Ue,Ma=is(),ff=Ts(),ka=bu,La=vs;Du.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:Tn.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Tn.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Tn.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${ir.createRandomToken(12)}.invalid`};const Jl={mandatory:{sockets(c){const n=[];if(ka.isSocket(c))n.push({socket:c});else if(Array.isArray(c)&&c.length)for(const r of c)Object.prototype.hasOwnProperty.call(r,"socket")&&ka.isSocket(r.socket)?n.push(r):ka.isSocket(r)&&n.push({socket:r});else return;return n},uri(c){/^sip:/i.test(c)||(c=`${Tn.SIP}:${c}`);const n=ff.parse(c);if(n)return n.user?n:void 0}},optional:{authorization_user(c){if(Ma.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(ir.isDecimal(c)){const n=Number(c);if(n>0)return n}},connection_recovery_min_interval(c){if(ir.isDecimal(c)){const n=Number(c);if(n>0)return n}},contact_uri(c){if(typeof c=="string"){const n=Ma.parse(c,"SIP_URI");if(n!==-1)return n}},display_name(c){return c},instance_id(c){if(/^uuid:/i.test(c)&&(c=c.substr(5)),Ma.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(ir.isDecimal(c)){const n=Number(c);if(n>0)return n}},session_timers(c){if(typeof c=="boolean")return c},session_timers_refresh_method(c){if(typeof c=="string"&&(c=c.toUpperCase(),c===Tn.INVITE||c===Tn.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(ir.isDecimal(c)){const n=Number(c);if(n>0)return n}},registrar_server(c){/^sip:/i.test(c)||(c=`${Tn.SIP}:${c}`);const n=ff.parse(c);if(n)return n.user?void 0:n},use_preloaded_route(c){if(typeof c=="boolean")return c},extra_headers(c){const n=[];if(Array.isArray(c)&&c.length)for(const r of c)typeof r=="string"&&n.push(r);else return;return n}}};Du.load=(c,n)=>{for(const r in Jl.mandatory)if(n.hasOwnProperty(r)){const o=n[r],a=Jl.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new La.ConfigurationError(r,o)}else throw new La.ConfigurationError(r);for(const r in Jl.optional)if(n.hasOwnProperty(r)){const o=n[r];if(ir.isEmpty(o))continue;const a=Jl.optional[r](o);if(a!==void 0)c[r]=a;else throw new La.ConfigurationError(r,o)}};const Jg=ct.EventEmitter,Xg=at,dt=Ue,Qg=Fm,_f=u_,hf=Cg,df=Og,$a=cr,Zg=xg,Xl=Et(),eT=vs,tT=Ts(),sT=c_,Ha=xt,nT=jg,Fa=Du,je=new Xg("UA"),gt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var h_=class extends Jg{static get C(){return gt}constructor(n){if(je.debug("new() [configuration:%o]",n),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Fa.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=gt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,n===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(n)}catch(r){throw this._status=gt.STATUS_NOT_READY,this._error=gt.CONFIGURATION_ERROR,r}this._registrator=new Qg(this)}get C(){return gt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){je.debug("start()"),this._status===gt.STATUS_INIT?this._transport.connect():this._status===gt.STATUS_USER_CLOSED?(je.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=gt.STATUS_INIT,this._transport.connect()):this._status===gt.STATUS_READY?je.debug("UA is in READY status, not restarted"):je.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){je.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(n){je.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(n)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(n,r){je.debug("call()");const o=new _f(this);return o.connect(n,r),o}sendMessage(n,r,o){je.debug("sendMessage()");const a=new hf(this);return a.send(n,r,o),a}sendOptions(n,r,o){je.debug("sendOptions()");const a=new df(this);return a.send(n,r,o),a}terminateSessions(n){je.debug("terminateSessions()");for(const r in this._sessions)this._sessions[r].isEnded()||this._sessions[r].terminate(n)}stop(){if(je.debug("stop()"),this._dynConfiguration={},this._status===gt.STATUS_USER_CLOSED){je.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){je.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=gt.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&&n===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(n){return Xl.normalizeTarget(n,this._configuration.hostport_params)}get(n){switch(n){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:je.warn('get() | cannot get "%s" parameter in runtime',n);return}}set(n,r){switch(n){case"authorization_user":{this._configuration.authorization_user=String(r);break}case"password":{this._configuration.password=String(r);break}case"realm":{this._configuration.realm=String(r);break}case"ha1":{this._configuration.ha1=String(r),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(r);break}case"display_name":{this._configuration.display_name=r;break}default:return je.warn('set() | cannot set "%s" parameter in runtime',n),!1}return!0}newTransaction(n){this._transactions[n.type][n.id]=n,this.emit("newTransaction",{transaction:n})}destroyTransaction(n){delete this._transactions[n.type][n.id],this.emit("transactionDestroyed",{transaction:n})}newDialog(n){this._dialogs[n.id]=n}destroyDialog(n){delete this._dialogs[n.id]}newMessage(n,r){this._applicants[n]=n,this.emit("newMessage",r)}newOptions(n,r){this._applicants[n]=n,this.emit("newOptions",r)}destroyMessage(n){delete this._applicants[n]}newRTCSession(n,r){this._sessions[n.id]=n,this.emit("newRTCSession",r)}destroyRTCSession(n){delete this._sessions[n.id]}registered(n){this.emit("registered",n)}unregistered(n){this.emit("unregistered",n)}registrationFailed(n){this.emit("registrationFailed",n)}receiveRequest(n){const r=n.method;if(n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){je.debug("Request-URI does not point to us"),n.method!==dt.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===dt.SIPS){n.reply_sl(416);return}if($a.checkTransaction(this,n))return;if(r===dt.INVITE?new $a.InviteServerTransaction(this,this._transport,n):r!==dt.ACK&&r!==dt.CANCEL&&new $a.NonInviteServerTransaction(this,this._transport,n),r===dt.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new df(this).init_incoming(n)}else if(r===dt.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new hf(this).init_incoming(n)}else if(r===dt.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let o,a;if(n.to_tag)o=this._findDialog(n.call_id,n.from_tag,n.to_tag),o?o.receiveRequest(n):r===dt.NOTIFY?(a=this._findSession(n),a?a.receiveRequest(n):(je.debug("received NOTIFY request for a non existent subscription"),n.reply(481,"Subscription does not exist"))):r!==dt.ACK&&n.reply(481);else switch(r){case dt.INVITE:if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const t=n.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?n.reply(603):a.receiveRequest(n)):n.reply(481)}else a=new _f(this),a.init_incoming(n);else je.warn("INVITE received but WebRTC is not supported"),n.reply(488);break;case dt.BYE:n.reply(481);break;case dt.CANCEL:a=this._findSession(n),a?a.receiveRequest(n):je.debug("received CANCEL request for a non existent session");break;case dt.ACK:break;case dt.NOTIFY:this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break;default:n.reply(405);break}}_findSession({call_id:n,from_tag:r,to_tag:o}){const a=n+r,t=this._sessions[a],s=n+o,p=this._sessions[s];return t||p||null}_findDialog(n,r,o){let a=n+r+o,t=this._dialogs[a];return t||(a=n+o+r,t=this._dialogs[a],t||null)}_loadConfig(n){try{Fa.load(this._configuration,n)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Xl.newUUID()),this._configuration.jssip_id=Xl.createRandomToken(5);const r=this._configuration.uri.clone();r.user=null,this._configuration.hostport_params=r.toString().replace(/^sip:/i,"");try{this._transport=new Zg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=rT.bind(this),this._transport.onconnect=iT.bind(this),this._transport.ondisconnect=lT.bind(this),this._transport.ondata=oT.bind(this)}catch(a){throw je.warn(a),new eT.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 tT("sip",Xl.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}));je.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Fa.settings,a))switch(a){case"uri":case"registrar_server":je.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":je.debug(`- ${a}: NOT SHOWN`);break;default:je.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}};function rT(c){this.emit("connecting",c)}function iT(c){this._status!==gt.STATUS_USER_CLOSED&&(this._status=gt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function lT(c){const n=["nict","ict","nist","ist"];for(const r of n)for(const o in this._transactions[r])Object.prototype.hasOwnProperty.call(this._transactions[r],o)&&this._transactions[r][o].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==gt.STATUS_USER_CLOSED&&(this._status=gt.STATUS_NOT_READY,this._error=gt.NETWORK_ERROR)}function oT(c){const n=c.transport;let r=c.message;if(r=sT.parseMessage(r,this),!!r&&!(this._status===gt.STATUS_USER_CLOSED&&r instanceof Ha.IncomingRequest)&&nT(r,this,n)){if(r instanceof Ha.IncomingRequest)r.transport=n,this.receiveRequest(r);else if(r instanceof Ha.IncomingResponse){let o;switch(r.method){case dt.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case dt.ACK:break;default:o=this._transactions.nict[r.via_branch],o&&o.receiveResponse(r);break}}}}const aT=ot(h_);var Me=Et();const Va=ot(Me),ja=new zf("Dialog"),ks={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};class Ql{static get C(){return ks}constructor(n,r,o,a=ks.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,r instanceof xt.IncomingResponse&&(a=r.status_code<200?ks.STATUS_EARLY:ks.STATUS_CONFIRMED),o==="UAS"){this._id={call_id:r.call_id,local_tag:r.to_tag,remote_tag:r.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=r.cseq,this._local_uri=r.parseHeader("to").uri,this._remote_uri=r.parseHeader("from").uri;let t=r.getHeaders("to")[0].split(";")[0];t=t.match(/<([^>]*)>/)[1],this._remote_target=t,this._route_set=r.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum}else if(o==="UAC"){this._id={call_id:r.call_id,local_tag:r.from_tag,remote_tag:r.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=r.cseq,this._local_uri=r.parseHeader("from").uri,this._remote_uri=r.parseHeader("to").uri;let t=r.getHeaders("to")[0].split(";")[0];t=t.match(/<([^>]*)>/)[1],this._remote_target=t,this._route_set=r.getHeaders("record-route").reverse(),this._ack_seqnum=null}this._ua.newDialog(this),ja.debug(`new ${o} dialog created with status ${this._state===ks.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(n){this._local_seqnum=n}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(n){this._uac_pending_reply=n}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===ks.STATUS_TERMINATED}update(n,r){this._state=ks.STATUS_CONFIRMED,ja.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){ja.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=ks.STATUS_TERMINATED}sendRequest(n,r={}){const o=Va.cloneArray(r.extraHeaders),a=Va.cloneObject(r.eventHandlers),t=r.body||null,s=this._createRequest(n,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new Wm(this,s,a).send(),s}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===G.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===G.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,r,o){r=Va.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=n===G.CANCEL||n===G.ACK?this._local_seqnum:this._local_seqnum+=1;return new xt.OutgoingRequest(n,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},r,o)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===G.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===G.INVITE||n.method===G.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const r=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${r}`]),!1}else{this._uas_pending_reply=!0;const r=()=>{(n.server_transaction.state===qt.C.STATUS_ACCEPTED||n.server_transaction.state===qt.C.STATUS_COMPLETED||n.server_transaction.state===qt.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",r),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",r)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===qt.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===G.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===qt.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}}var uT=Ts();const qi=ot(uT);function cT(c){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let r="";for(let o=0;o<c;o++){const a=Math.floor(Math.random()*n.length);r+=n.substring(a,a+1)}return r}const Z=new zf("JanusSession"),te={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},Zl=["audio","video"];class Io extends ct.EventEmitter{static get C(){return te}constructor(n){Z.debug("new"),super(),console.log("constructor call"),this._id=null,this._ua=n,this._status=te.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this.lastTransaction=0,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._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:G.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return te}get causes(){return G.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(n){this._data=n}get status(){return this._status}isInProgress(){switch(this._status){case te.STATUS_NULL:case te.STATUS_INVITE_SENT:case te.STATUS_1XX_RECEIVED:case te.STATUS_INVITE_RECEIVED:case te.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case te.STATUS_ANSWERED:case te.STATUS_WAITING_FOR_ACK:case te.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case te.STATUS_CANCELED:case te.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(n,r={},o){Z.debug("connect()");const a=n,t=Me.cloneObject(r.eventHandlers),s=Me.cloneArray(r.extraHeaders),p=Me.cloneObject(r.mediaConstraints,{audio:!0,video:!0}),_=r.mediaStream||null,d=Me.cloneObject(r.pcConfig,{iceServers:[]}),g=r.rtcConstraints||null,T=r.rtcOfferConstraints||null;if(this._rtcOfferConstraints=T,this._rtcAnswerConstraints=r.rtcAnswerConstraints||null,this._data=r.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==te.STATUS_NULL)throw new mn.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new mn.NotSupportedError("WebRTC not supported");if(console.log("target",n),n=this._ua.normalizeTarget(n),console.log("normalizeTarget target",n),!n)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&Me.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=G.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=G.SESSION_EXPIRES);for(const A in t)Object.prototype.hasOwnProperty.call(t,A)&&this.on(A,t[A]);this._from_tag=Me.newTag();const E=r.anonymous||!1,y={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(y.from_display_name="Anonymous",y.from_uri=new qi("sip","anonymous","anonymous.invalid"),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),s.push("Privacy: id")):r.fromUserName&&(y.from_uri=new qi("sip",r.fromUserName,this._ua.configuration.uri.host),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),r.fromDisplayName&&(y.from_display_name=r.fromDisplayName),s.push(`Contact: ${this._contact}`),s.push("Content-Type: application/json"),this._sessionTimers.enabled&&s.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new xt.InitialOutgoingInviteRequest(n,this._ua,y,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,console.log("this._remote_identity",this._remote_identity),o&&o(this),this._newJanusSession("local",this._request),this._sendInitialRequest(p,T,_)}init_incoming(n,r){Z.debug("init_incoming()");let o;const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&a!=="application/sdp"){n.reply(415);return}if(this._status=te.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(o=n.getHeader("expires")*1e3),n.to_tag=Me.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=te.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,G.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===te.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,G.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,r&&r(this),this._newJanusSession("remote",n),this._status!==te.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){Z.debug("answer()");const r=this._request,o=Me.cloneArray(n.extraHeaders),a=Me.cloneObject(n.mediaConstraints),t=n.mediaStream||null,s=Me.cloneObject(n.pcConfig,{iceServers:[]}),p=n.rtcConstraints||null,_=n.rtcAnswerConstraints||null,d=Me.cloneObject(n.rtcOfferConstraints);let g,T=!1,E=!1,y=!1,A=!1;if(this._rtcAnswerConstraints=_,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new mn.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==te.STATUS_WAITING_FOR_ANSWER)throw new mn.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Me.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=G.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=G.SESSION_EXPIRES),this._status=te.STATUS_ANSWERED,!this._createDialog(r,"UAS")){r.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const R=r.parseSDP();Array.isArray(R.media)||(R.media=[R.media]);for(const I of R.media)I.type==="audio"&&(T=!0,(!I.direction||I.direction==="sendrecv")&&(y=!0)),I.type==="video"&&(E=!0,(!I.direction||I.direction==="sendrecv")&&(A=!0));if(t&&a.audio===!1){g=t.getAudioTracks();for(const I of g)t.removeTrack(I)}if(t&&a.video===!1){g=t.getVideoTracks();for(const I of g)t.removeTrack(I)}!t&&a.audio===void 0&&(a.audio=y),!t&&a.video===void 0&&(a.video=A),!t&&!T&&!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(I=>{throw this._status===te.STATUS_TERMINATED?new Error("terminated"):(r.reply(480),this._failed("local",null,G.causes.USER_DENIED_MEDIA_ACCESS),Z.warn('emit "getusermediafailed" [error:%o]',I),this.emit("getusermediafailed",I),new Error("getUserMedia() failed"))})}).then(I=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=I,I&&I.getTracks().forEach($=>{this._connection.addTrack($,I)})}).then(()=>{if(this._late_sdp)return;const I={originator:"remote",type:"offer",sdp:r.body};Z.debug('emit "sdp"'),this.emit("sdp",I);const $=new RTCSessionDescription({type:"offer",sdp:I.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription($)).catch(L=>{throw r.reply(488),this._failed("system",null,G.causes.WEBRTC_ERROR),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(r),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw r.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",_).catch(()=>{throw r.reply(500),new Error("_createLocalDescription() failed")})}).then(I=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(r,o),r.reply(200,null,o,I,()=>{this._status=te.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(r,I),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,G.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==te.STATUS_TERMINATED&&Z.warn(I)})}terminate(n={}){Z.debug("terminate()");const r=n.cause||G.causes.BYE,o=Me.cloneArray(n.extraHeaders),a=n.body;let t,s=n.status_code,p=n.reason_phrase;if(this._status===te.STATUS_TERMINATED)throw new mn.InvalidStateError(this._status);switch(this._status){case te.STATUS_NULL:case te.STATUS_INVITE_SENT:case te.STATUS_1XX_RECEIVED:if(Z.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||G.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===te.STATUS_NULL||this._status===te.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===te.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=te.STATUS_CANCELED,this._failed("local",null,G.causes.CANCELED);break;case te.STATUS_WAITING_FOR_ANSWER:case te.STATUS_ANSWERED:if(Z.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,G.causes.REJECTED);break;case te.STATUS_WAITING_FOR_ACK:case te.STATUS_CONFIRMED:if(Z.debug("terminating session"),p=n.reason_phrase||G.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===te.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==qt.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===G.ACK&&(this.sendRequest(G.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===qt.C.STATUS_TERMINATED&&(this.sendRequest(G.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,console.log("SET DIALOG terminate"),this._ua.newDialog(_)}else this.sendRequest(G.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendInfo(n,r,o={}){if(Z.debug("sendInfo()"),this._status!==te.STATUS_CONFIRMED&&this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_1XX_RECEIVED)throw new mn.InvalidStateError(this._status);new au(this).send(n,r,o)}mute(n={audio:!0,video:!1}){Z.debug("mute()");let r=!1,o=!1;this._audioMuted===!1&&n.audio&&(r=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(r===!0||o===!0)&&this._onmute({audio:r,video:o})}unmute(n={audio:!0,video:!0}){Z.debug("unmute()");let r=!1,o=!1;this._audioMuted===!0&&n.audio&&(r=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(r===!0||o===!0)&&this._onunmute({audio:r,video:o})}hold(n={},r){if(Z.debug("hold()"),this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:G.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}unhold(n={},r){if(Z.debug("unhold()"),this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:G.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},r){Z.debug("renegotiate()");const o=n.rtcOfferConstraints||null;if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:G.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}),!0}refer(n,r){Z.debug("refer()");const o=n;if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const a=new fg(this);a.sendRefer(n,r);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(n,r){return Z.debug("sendRequest()"),this._dialog.sendRequest(n,r)}receiveRequest(n){if(Z.debug("receiveRequest()"),n.method===G.CANCEL)(this._status===te.STATUS_WAITING_FOR_ANSWER||this._status===te.STATUS_ANSWERED)&&(this._status=te.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,G.causes.CANCELED));else switch(n.method){case G.ACK:if(this._status!==te.STATUS_WAITING_FOR_ACK)return;if(this._status=te.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:G.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:n.body};Z.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(a=>{this.terminate({cause:G.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",n);break;case G.BYE:this._status===te.STATUS_CONFIRMED||this._status===te.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,G.causes.BYE)):this._status===te.STATUS_INVITE_RECEIVED||this._status===te.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,G.causes.BYE)):n.reply(403,"Wrong Status");break;case G.INVITE:this._status===te.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case G.INFO:if(this._status===te.STATUS_1XX_RECEIVED||this._status===te.STATUS_WAITING_FOR_ANSWER||this._status===te.STATUS_ANSWERED||this._status===te.STATUS_WAITING_FOR_ACK||this._status===te.STATUS_CONFIRMED){const r=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;r&&r.match(/^application\/dtmf-relay/i)?new eg(this).init_incoming(n):r!==void 0?new au(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break;case G.UPDATE:this._status===te.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case G.REFER:this._status===te.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case G.NOTIFY:this._status===te.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){Z.warn("onTransportError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:G.causes.CONNECTION_ERROR,cause:G.causes.CONNECTION_ERROR})}onRequestTimeout(){Z.warn("onRequestTimeout()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:G.causes.REQUEST_TIMEOUT,cause:G.causes.REQUEST_TIMEOUT})}onDialogError(){Z.warn("onDialogError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:G.causes.DIALOG_ERROR,cause:G.causes.DIALOG_ERROR})}newDTMF(n){Z.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){Z.debug("newInfo()"),this.emit("newInfo",n)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(Z.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(Z.debug("_isReadyToReOffer() | session not established yet"),!1):(Z.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(Z.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(Z.debug("close() | closing local MediaStream"),Me.closeMediaStream(this._localMediaStream)),this._status!==te.STATUS_TERMINATED){if(this._status=te.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){Z.warn("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(n,r){let o=Di.T1;function a(){this._status===te.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],r),o<Di.T2&&(o=o*2,o>Di.T2&&(o=Di.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),o))}this._timers.invite2xxTimer=setTimeout(a.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===te.STATUS_WAITING_FOR_ACK&&(Z.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(G.BYE),this._ended("remote",null,G.causes.NO_ACK))},Di.TIMER_H)}_createRTCConnection(n,r){this._connection=new RTCPeerConnection(n,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:G.causes.RTP_TIMEOUT,status_code:408,reason_phrase:G.causes.RTP_TIMEOUT})}),Z.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,r){if(Z.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?o.createOffer(r).catch(a=>(Z.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(r).catch(a=>(Z.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,Z.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=r&&r.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:n,sdp:o.localDescription.sdp};return Z.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let s=!1,p,_;this._iceReady=!1;const d=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",_),s=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:n,sdp:o.localDescription.sdp};Z.debug('emit "sdp"'),this.emit("sdp",g),t(g.sdp)};o.addEventListener("icecandidate",p=g=>{const T=g.candidate;T?this.emit("icecandidate",{candidate:T,ready:d}):s||d()}),o.addEventListener("icegatheringstatechange",_=()=>{o.iceGatheringState==="complete"&&!s&&d()})})})}_createDialog(n,r,o){console.log("_createDialog",n);const a=r==="UAS"?n.to_tag:n.from_tag,t=r==="UAS"?n.from_tag:n.to_tag,s=n.call_id+a+t;console.log("remote_tag",t);let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Ql(this,n,r,Ql.C.STATUS_EARLY),console.log("SET DIALOG early"),p.error?(console.log("early_dialog error",p.error),Z.debug(p.error),this._failed("remote",n,G.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,p)return p.update(n,r),console.log("SET DIALOG 1"),this._dialog=p,delete this._earlyDialogs[s],!0;const _=new Ql(this,n,r);return _.error?(console.log("dialog.error",_.error),Z.debug(_.error),this._failed("remote",n,G.causes.INTERNAL_ERROR),!1):(console.log("AAA SET DIALOG 2"),this._dialog=_,!0)}}_receiveReinvite(n){Z.debug("receiveReinvite()");const r=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,d=p.reason_phrase||"",g=Me.cloneArray(p.extraHeaders);if(this._status!==te.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);n.reply(_,d,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!n.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(()=>{n.reply(500)});return}if(r!=="application/sdp"){Z.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==te.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{Z.warn(p)});function s(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,_),this._late_sdp&&(p=this._mangleOffer(p)),n.reply(200,null,_,p,()=>{this._status=te.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(n){Z.debug("receiveUpdate()");const r=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,d=p.reason_phrase||"",g=Me.cloneArray(p.extraHeaders);if(this._status!==te.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);n.reply(_,d,g)}if(this.emit("update",o),a)return;if(!n.body){s.call(this,null);return}if(r!=="application/sdp"){Z.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==te.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{Z.warn(p)});function s(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,_),n.reply(200,null,_,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(n){Z.debug("_processInDialogSdpOffer()");const r=n.parseSDP();let o=!1;for(const s of r.media){if(Zl.indexOf(s.type)===-1)continue;const p=s.direction||r.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:n.body};Z.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===te.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(s=>{throw n.reply(488),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',s),this.emit("peerconnection:setremotedescriptionfailed",s),s})}).then(()=>{if(this._status===te.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===te.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(s=>{throw n.reply(500),Z.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',s),s})}).catch(s=>{Z.warn("_processInDialogSdpOffer() failed [error: %o]",s)}),this._connectionPromiseQueue}_receiveRefer(n){if(Z.debug("receiveRefer()"),!n.refer_to){Z.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==G.SIP){Z.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const r=new og(this,n.cseq);Z.debug('emit "refer"'),this.emit("refer",{request:n,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!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const p=new Io(this._ua);if(p.on("progress",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),p.on("accepted",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),p.on("_failed",({message:_,cause:d})=>{_?r.notify(_.status_code,_.reason_phrase):r.notify(487,d)}),n.refer_to.uri.hasHeader("replaces")){const _=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));s.extraHeaders=Me.cloneArray(s.extraHeaders),s.extraHeaders.push(`Replaces: ${_}`)}p.connect(n.refer_to.uri.toAor(),s,t)}function a(){r.notify(603)}}_receiveNotify(n){switch(Z.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let r,o;if(n.event.params&&n.event.params.id)r=n.event.params.id,o=this._referSubscribers[r];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!o){n.reply(481,"Subscription does not exist");return}o.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){Z.debug("receiveReplaces()");function r(a){if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const t=new Io(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(n,a)}function o(){Z.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:a=>{r.call(this,a)},reject:()=>{o.call(this)}})}_getNextTransactionId(){return(this.lastTransaction+1).toString()}_sendInitialRequest(n,r,o){this.ackSent=!1;const a=new t_(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(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(t=>{throw this._status===te.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,G.causes.USER_DENIED_MEDIA_ACCESS),Z.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===te.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",r).catch(s=>{throw this._failed("local",null,G.causes.WEBRTC_ERROR),s})}).then(t=>{if(this._is_canceled||this._status===te.STATUS_TERMINATED)throw new Error("terminated");const p=JSON.stringify({janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:"videoroomtest-uzkIUidc1969"});this._request.body=p,this._status=te.STATUS_INVITE_SENT,Z.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==te.STATUS_TERMINATED&&Z.warn(t)})}_receiveInviteResponse(n){if(Z.debug("receiveInviteResponse()"),console.log("_receiveInviteResponse response",n),console.log("dialog",this._dialog),this._dialog&&n.status_code>=200&&n.status_code<=299&&!this.ackSent)if(console.log("IF 1 dialog"),this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){console.log("IF 1 SEND ACK"),this.ackSent=!0,this.sendRequest(G.ACK);return}else{const r=new Ql(this,n,"UAC");if(r.error!==void 0){Z.debug(r.error);return}this.sendRequest(G.ACK),this.sendRequest(G.BYE);return}if(this.ackSent){const r=JSON.parse(n.body);this.session_id=r.session_id,this.handle_id=r.data.id;const a={janus:"message",body:{request:"join",room:"abcd",ptype:"publisher",display:"User1",clientID:"dufgjb023gh4vr872v238ugf2y82g4",opaque_id:`videoroomtest-${cT(12)}`},handle_id:this.handle_id},t=["PTYPE: Publisher"];console.log("JOIN MESSAGE",a),this.sendRequest(G.SUBSCRIBE,{extraHeaders:t,body:JSON.stringify(a)})}if(this._is_canceled){console.log("IF 2 canceled"),n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&(console.log("IF 2 _acceptAndTerminate"),this._acceptAndTerminate(n));return}if(console.log("IF 2 this._status",this._status),this._status!==te.STATUS_INVITE_SENT&&this._status!==te.STATUS_1XX_RECEIVED){console.log("IF 3 not invite sent");return}switch(!0){case/^100$/.test(n.status_code):console.log("IF 4 SWITCH 1"),this._status=te.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(console.log("IF 5 SWITCH 2"),!n.to_tag){console.log("IF 5 break"),Z.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&(console.log("IF 5 contact"),!this._createDialog(n,"UAC",!0))){console.log("IF 5 _createDialog break");break}if(this._status=te.STATUS_1XX_RECEIVED,!n.body){console.log("IF 5 !response.body"),this._progress("remote",n);break}const r={originator:"remote",type:"answer",sdp:n.body};Z.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",n)).catch(a=>{Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(console.log("IF 6 SWITCH 3"),this._status=te.STATUS_CONFIRMED,!n.body){console.log("IF 6 !response.body"),this._acceptAndTerminate(n,400,G.causes.MISSING_SDP),this._failed("remote",n,G.causes.BAD_MEDIA_DESCRIPTION);break}if(console.log("AAA _createDialog"),!this._createDialog(n,"UAC"))break;break}default:{console.log("IF 7 SWITCH 4");const r=Me.sipErrorCause(n.status_code);this._failed("remote",n,r)}}}_sendReinvite(n={}){Z.debug("sendReinvite()");const r=Me.cloneArray(n.extraHeaders),o=Me.cloneObject(n.eventHandlers),a=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;r.push(`Contact: ${this._contact}`),r.push("Content-Type: application/sdp"),this._sessionTimers.running&&r.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(_=>{_=this._mangleOffer(_);const d={originator:"local",type:"offer",sdp:_};Z.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(G.INVITE,{extraHeaders:r,body:_,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(_){if(this._status===te.STATUS_TERMINATED||(this.sendRequest(G.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(_),_.body){if(!_.hasHeader("Content-Type")||_.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const d={originator:"remote",type:"answer",sdp:_.body};Z.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(_)}).catch(T=>{p.call(this),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',T),this.emit("peerconnection:setremotedescriptionfailed",T)})}function p(_){o.failed&&o.failed(_)}}_sendUpdate(n={}){Z.debug("sendUpdate()");const r=Me.cloneArray(n.extraHeaders),o=Me.cloneObject(n.eventHandlers),a=n.rtcOfferConstraints||this._rtcOfferConstraints||null,t=n.sdpOffer||!1;let s=!1;r.push(`Contact: ${this._contact}`),this._sessionTimers.running&&r.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(r.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};Z.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(G.UPDATE,{extraHeaders:r,body:d,eventHandlers:{onSuccessResponse:T=>{p.call(this,T),s=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(G.UPDATE,{extraHeaders:r,eventHandlers:{onSuccessResponse:d=>{p.call(this,d)},onErrorResponse:d=>{_.call(this,d)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(d){if(this._status!==te.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(d),t){if(d.body){if(!d.hasHeader("Content-Type")||d.getHeader("Content-Type").toLowerCase()!=="application/sdp"){_.call(this);return}}else{_.call(this);return}const g={originator:"remote",type:"answer",sdp:d.body};Z.debug('emit "sdp"'),this.emit("sdp",g);const T=new RTCSessionDescription({type:"answer",sdp:g.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>{o.succeeded&&o.succeeded(d)}).catch(E=>{_.call(this),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else o.succeeded&&o.succeeded(d)}function _(d){o.failed&&o.failed(d)}}_acceptAndTerminate(n,r,o){Z.debug("acceptAndTerminate()");const a=[];r&&(o=o||G.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(G.ACK),this.sendRequest(G.BYE,{extraHeaders:a})),this._status=te.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=Nt.parse(n),this._localHold&&!this._remoteHold){Z.debug("mangleOffer() | me on hold, mangling offer");for(const r of n.media)Zl.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="sendonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="sendonly")}else if(this._localHold&&this._remoteHold){Z.debug("mangleOffer() | both on hold, mangling offer");for(const r of n.media)Zl.indexOf(r.type)!==-1&&(r.direction="inactive")}else if(this._remoteHold){Z.debug("mangleOffer() | remote on hold, mangling offer");for(const r of n.media)Zl.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="recvonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="recvonly")}return Nt.write(n)}_setLocalMediaStatus(){let n=!0,r=!0;(this._localHold||this._remoteHold)&&(n=!1,r=!1),this._audioMuted&&(n=!1),this._videoMuted&&(r=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!r)}_handleSessionTimersInIncomingRequest(n,r){if(!this._sessionTimers.enabled)return;let o;n.session_expires&&n.session_expires>=G.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,o=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),r.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let r;n.session_expires&&n.session_expires>=G.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,r=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}_runSessionTimer(){const n=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==te.STATUS_TERMINATED&&this._isReadyToReOffer()&&(Z.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===G.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==te.STATUS_TERMINATED&&(Z.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:G.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of r)o.track.enabled=!n}_toggleMuteVideo(n){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of r)o.track.enabled=!n}_newJanusSession(n,r){Z.debug("newRTCSession()"),this._ua.newJanusSession(this,{originator:n,session:this,request:r})}_connecting(n){Z.debug("session connecting"),Z.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,r){Z.debug("session progress"),Z.debug('emit "progress"'),this.emit("progress",{originator:n,response:r||null})}_accepted(n,r){Z.debug("session accepted"),this._start_time=new Date,Z.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:r||null})}_confirmed(n,r){Z.debug("session confirmed"),this._is_confirmed=!0,Z.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:r||null})}_ended(n,r,o){Z.debug("session ended"),this._end_time=new Date,this._close(),Z.debug('emit "ended"'),this.emit("ended",{originator:n,message:r||null,cause:o})}_failed(n,r,o){Z.debug("session failed"),Z.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:r||null,cause:o}),this._close(),Z.debug('emit "failed"'),this.emit("failed",{originator:n,message:r||null,cause:o})}_onhold(n){Z.debug("session onhold"),this._setLocalMediaStatus(),Z.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){Z.debug("session onunhold"),this._setLocalMediaStatus(),Z.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:r}){Z.debug("session onmute"),this._setLocalMediaStatus(),Z.debug('emit "muted"'),this.emit("muted",{audio:n,video:r})}_onunmute({audio:n,video:r}){Z.debug("session onunmute"),this._setLocalMediaStatus(),Z.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:r})}}class nr{constructor(n){if(this.headers={},n.length>0){let r=!1;const o=n.split(`\r
|
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===""){r=!0;continue}if(t&&r)this.body+=`${t}\r
|
136
|
+
`;else{const s=t.split(": ");this.addHeader(s[0],s[1].trim())}}}else this.ident=Me.createRandomToken(12),this.protocol="MSRP"}addHeader(n,r){this.headers[n]=r}getHeader(n){return this.headers[n]}toString(){let n=`${this.protocol} ${this.ident} ${this.code} ${this.method}`.replaceAll(/null\s|undefined\s/ig,"")+`\r
|
137
|
+
`;for(const r in this.headers)n+=`${r}: ${this.headers[r]}\r
|
138
|
+
`;return this.body&&(n+=`\r
|
139
139
|
${this.body}\r
|
140
|
-
`),
|
141
|
-
`,
|
140
|
+
`),n+=`-------${this.ident}$\r
|
141
|
+
`,n}}const Re={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 qa extends ct.EventEmitter{constructor(n){super(),this._id=null,this.my_ip="127.0.0.1",this._ua=n,this.auth_id=Me.createRandomToken(10),this._status=Re.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:n._configuration.authorization_user,ha1:n._configuration.ha1,realm:n._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:G.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._msrpKeepAliveTimer=null}static get C(){return Re}get direction(){return this._direction}get connection(){return this._connection}get id(){return this._id}connect(n=""){n!==""&&(this._direction="outgoing"),this.target=n,this._connection=new WebSocket(`wss://${this._ua._configuration.realm}`,"msrp"),this._connection.binaryType="arraybuffer",this._connection.onopen=r=>{console.log("open",r),this.onopen()},this._connection.onclose=r=>{console.log("close",r),this.onclose()},this._connection.onmessage=r=>{console.log("msg",r),this.onmessage(r)},this._connection.onerror=r=>{console.log("error",r),this.onerror()}}_sendKeepAlive(){const n=new nr("");n.method="SEND",n.addHeader("To-Path",`${this.my_addr[1]}`),n.addHeader("From-Path",`${this.my_addr[0]}`),n.addHeader("Message-ID",Me.createRandomToken(10)),this._connection.send(n.toString())}answer(){if(!this._createDialog(this._request,"UAS")){this._request.reply(500,"Error creating dialog");return}this._status=Re.STATUS_ANSWERED,clearTimeout(this._timers.userNoAnswerTimer),this.connect()}acceptParty(n){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
|
145
145
|
m=message 2856 TCP/TLS/MSRP *
|
146
146
|
a=accept-types:text/plain text/html
|
147
|
-
a=path: ${
|
148
|
-
`)}inviteParty(
|
147
|
+
a=path: ${n.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
|
148
|
+
`)}inviteParty(n){const r={},o=[];r.to_uri=new qi("sip",this.target,this._ua._configuration.realm),r.from_uri=new qi("sip",this._ua._configuration.uri.user,this._ua._configuration.uri.host),o.push(`Contact: ${this._ua.contact.toString({outbound:!0})}`),o.push("Content-Type: application/sdp"),this._request=new xt.InitialOutgoingInviteRequest(new qi("sip",this.target,this._ua._configuration.realm).clone(),this._ua,r,o,`v=0
|
149
149
|
o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
|
150
150
|
c=IN IP4 ${this.my_ip}
|
151
151
|
t=0 0
|
152
152
|
m=message 2856 TCP/TLS/MSRP *
|
153
153
|
a=accept-types:text/plain text/html
|
154
|
-
a=path:${
|
155
|
-
`),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new ym(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=Se.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=Se.STATUS_INVITE_SENT}terminate(r={}){console.log("terminate",this);const n=r.cause||be.causes.BYE,o=Ps.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===Se.STATUS_TERMINATED)throw new wm.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Se.STATUS_NULL:case Se.STATUS_INVITE_SENT:case Se.STATUS_1XX_RECEIVED:if(s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||be.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===Se.STATUS_NULL||this._status===Se.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===Se.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=Se.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,be.causes.CANCELED);break;case Se.STATUS_WAITING_FOR_ANSWER:case Se.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,be.causes.REJECTED);break;case Se.STATUS_WAITING_FOR_ACK:case Se.STATUS_CONFIRMED:if(p=r.reason_phrase||be.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===Se.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Li.C.STATUS_TERMINATED){const h=this._dialog;this.receiveRequest=({method:d})=>{d===be.ACK&&(this.sendRequest(be.BYE,{extraHeaders:o,body:a}),h.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Li.C.STATUS_TERMINATED&&(this.sendRequest(be.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(be.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 Qn("");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 Qn(r.data);if(this.status==="auth"&&n.code===401){const o=this.parseAuth(n.getHeader("WWW-Authenticate")),a=new um(this.credentials);a.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},o,Ps.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(be.ACK);return}else{const n=new $l(this,r,"UAC");if(n.error!==void 0){console.log(n.error);return}this.sendRequest(be.ACK),this.sendRequest(be.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!==Se.STATUS_INVITE_SENT&&this._status!==Se.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(r.status_code):this._status=Se.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=Se.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=Se.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,be.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",r,be.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,be.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(be.ACK),this._confirmed("local",null)});break}default:{const n=Ps.sipErrorCause(r.status_code);console.log("failed 5"),this._failed("remote",r,n)}}}sendMSRP(r){const n=new Qn("");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",Ps.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 Qn("");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 Qn("");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=Se.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=Ps.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=Se.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),console.log("failed 6"),this._failed("local",null,be.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Se.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),console.log("failed 7"),this._failed("system",null,be.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!==Se.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!==Se.STATUS_TERMINATED){if(this._status=Se.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 $l(this,r,n,$l.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",r,be.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 $l(this,r,n);return h.error?(console.log("failed 9"),this._failed("remote",r,be.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 Se.STATUS_CANCELED:case Se.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>=be.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===be.CANCEL)(this._status===Se.STATUS_WAITING_FOR_ANSWER||this._status===Se.STATUS_ANSWERED)&&(this._status=Se.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",r,be.causes.CANCELED));else switch(r.method){case be.ACK:if(this._status!==Se.STATUS_WAITING_FOR_ACK)return;if(this._status=Se.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:be.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:be.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 be.BYE:this._status===Se.STATUS_CONFIRMED||this._status===Se.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,be.causes.BYE)):this._status===Se.STATUS_INVITE_RECEIVED||this._status===Se.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,be.causes.BYE)):r.reply(403,"Wrong Status");break;case be.INVITE:this._status===Se.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case be.INFO:this._status===Se.STATUS_1XX_RECEIVED||this._status===Se.STATUS_WAITING_FOR_ANSWER||this._status===Se.STATUS_ANSWERED||this._status===Se.STATUS_WAITING_FOR_ACK||this._status===Se.STATUS_CONFIRMED?(r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new jm(this).init_incoming(r):r.reply(415):r.reply(403,"Wrong Status");break;case be.UPDATE:this._status===Se.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case be.REFER:this._status===Se.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case be.NOTIFY:this._status===Se.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Se.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:be.causes.CONNECTION_ERROR,cause:be.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Se.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:be.causes.REQUEST_TIMEOUT,cause:be.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Se.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:be.causes.DIALOG_ERROR,cause:be.causes.DIALOG_ERROR})}}const Kt=console,tf={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},zg=Wg;class Jg extends zg{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){Kt.debug("Request-URI does not point to us"),r.method!==De.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===De.SIPS){r.reply_sl(416);return}if(Li.checkTransaction(this,r))return;if(n===De.INVITE?new Li.InviteServerTransaction(this,this._transport,r):n!==De.ACK&&n!==De.CANCEL&&new Li.NonInviteServerTransaction(this,this._transport,r),n===De.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new Ac.Options(this).init_incoming(r)}else if(n===De.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new Ac.Message(this).init_incoming(r)}else if(n===De.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===De.NOTIFY?(a=this._findSession(r),a?a.receiveRequest(r):(Kt.debug("received NOTIFY request for a non existent subscription"),r.reply(481,"Subscription does not exist"))):n!==De.ACK&&r.reply(481);else switch(n){case De.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 ef(this),a.init_incoming(r)):(a=new ng(this),a.init_incoming(r));else Kt.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case De.BYE:r.reply(481);break;case De.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):Kt.debug("received CANCEL request for a non existent session");break;case De.ACK:break;case De.NOTIFY:this.emit("sipEvent",{event:r.event,request:r}),r.reply(200);break;default:r.reply(405);break}}startMSRP(r,n){Kt.debug("startMSRP()",n);const o=new ef(this);return o.connect(r),o}terminateMSRPSessions(r){Kt.debug("terminateSessions()");for(const n in this._msrp_sessions)this._msrp_sessions[n].isEnded()||this._msrp_sessions[n].terminate(r)}stop(){if(Kt.debug("stop()"),this._dynConfiguration={},this._status===tf.STATUS_USER_CLOSED){Kt.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)){Kt.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)){Kt.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=tf.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 gt={};gt.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)};gt.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)};gt.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)};gt.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};gt.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)}});gt.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]};gt.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)}});gt.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};gt.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)}});gt.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};gt.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)}});gt.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};gt.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)});gt.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};gt.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 Jf={};(function(c){const r=gt;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)}})})(Jf);const Xg=gt,Qg=Jf;var sf=Object.assign(Xg,{instanceMethods:Qg});function Pa(c){return c<10?`0${c}`:`${c}`}function Zg(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=`${Pa(r)}:${Pa(n)}:${Pa(o)}`;return{seconds:o,minutes:n,hours:r,formatted:a}}function ev(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,tv=["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"],sv=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function nf(c){const r={};return tv.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r.localHold=c._localHold,r}function rf(c){const r={};return sv.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r}function lf(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 nv(c,r,n,o){const a=document.createElement("audio");a.id=r._id,a.className="audioTag",a.srcObject=c,a.setSinkId(n),a.volume=o,a.play(),r.audioTag=a}function rv(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}var iv={exports:{}};(function(c){var r=function(n){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(Q,G,B){Q[G]=B.value},s,p=typeof Symbol=="function"?Symbol:{},h=p.iterator||"@@iterator",d=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function v(Q,G,B){return Object.defineProperty(Q,G,{value:B,enumerable:!0,configurable:!0,writable:!0}),Q[G]}try{v({},"")}catch{v=function(G,B,te){return G[B]=te}}function E(Q,G,B,te){var de=G&&G.prototype instanceof ie?G: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,G,B){try{return{type:"normal",arg:Q.call(G,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(G){v(Q,G,function(B){return this._invoke(G,B)})})}n.isGeneratorFunction=function(Q){var G=typeof Q=="function"&&Q.constructor;return G?G===N||(G.displayName||G.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,G){function B(Ae,Ue,ye,ne){var Te=S(Q[Ae],Q,Ue);if(Te.type==="throw")ne(Te.arg);else{var Qe=Te.arg,st=Qe.value;return st&&typeof st=="object"&&a.call(st,"__await")?G.resolve(st.__await).then(function(ge){B("next",ge,ye,ne)},function(ge){B("throw",ge,ye,ne)}):G.resolve(st).then(function(ge){Qe.value=ge,ye(Qe)},function(ge){return B("throw",ge,ye,ne)})}}var te;function de(Ae,Ue){function ye(){return new G(function(ne,Te){B(Ae,Ue,ne,Te)})}return te=te?te.then(ye,ye):ye()}t(this,"_invoke",{value:de})}j(V.prototype),v(V.prototype,d,function(){return this}),n.AsyncIterator=V,n.async=function(Q,G,B,te,de){de===void 0&&(de=Promise);var Ae=new V(E(Q,G,B,te),de);return n.isGeneratorFunction(G)?Ae:Ae.next().then(function(Ue){return Ue.done?Ue.value:Ae.next()})};function Y(Q,G,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 Xe()}for(B.method=Ae,B.arg=Ue;;){var ye=B.delegate;if(ye){var ne=$(ye,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,G,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,G){var B=G.method,te=Q.iterator[B];if(te===s)return G.delegate=null,B==="throw"&&Q.iterator.return&&(G.method="return",G.arg=s,$(Q,G),G.method==="throw")||B!=="return"&&(G.method="throw",G.arg=new TypeError("The iterator does not provide a '"+B+"' method")),L;var de=S(te,Q.iterator,G.arg);if(de.type==="throw")return G.method="throw",G.arg=de.arg,G.delegate=null,L;var Ae=de.arg;if(!Ae)return G.method="throw",G.arg=new TypeError("iterator result is not an object"),G.delegate=null,L;if(Ae.done)G[Q.resultName]=Ae.value,G.next=Q.nextLoc,G.method!=="return"&&(G.method="next",G.arg=s);else return Ae;return G.delegate=null,L}j(D),v(D,g,"Generator"),v(D,h,function(){return this}),v(D,"toString",function(){return"[object Generator]"});function z(Q){var G={tryLoc:Q[0]};1 in Q&&(G.catchLoc=Q[1]),2 in Q&&(G.finallyLoc=Q[2],G.afterLoc=Q[3]),this.tryEntries.push(G)}function U(Q){var G=Q.completion||{};G.type="normal",delete G.arg,Q.completion=G}function P(Q){this.tryEntries=[{tryLoc:"root"}],Q.forEach(z,this),this.reset(!0)}n.keys=function(Q){var G=Object(Q),B=[];for(var te in G)B.push(te);return B.reverse(),function de(){for(;B.length;){var Ae=B.pop();if(Ae in G)return de.value=Ae,de.done=!1,de}return de.done=!0,de}};function Z(Q){if(Q){var G=Q[h];if(G)return G.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:Xe}}n.values=Z;function Xe(){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 G in this)G.charAt(0)==="t"&&a.call(this,G)&&!isNaN(+G.slice(1))&&(this[G]=s)},stop:function(){this.done=!0;var Q=this.tryEntries[0],G=Q.completion;if(G.type==="throw")throw G.arg;return this.rval},dispatchException:function(Q){if(this.done)throw Q;var G=this;function B(ne,Te){return Ae.type="throw",Ae.arg=Q,G.next=ne,Te&&(G.method="next",G.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"),ye=a.call(de,"finallyLoc");if(Ue&&ye){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(ye){if(this.prev<de.finallyLoc)return B(de.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(Q,G){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<=G&&G<=de.finallyLoc&&(de=null);var Ae=de?de.completion:{};return Ae.type=Q,Ae.arg=G,de?(this.method="next",this.next=de.finallyLoc,L):this.complete(Ae)},complete:function(Q,G){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"&&G&&(this.next=G),L},finish:function(Q){for(var G=this.tryEntries.length-1;G>=0;--G){var B=this.tryEntries[G];if(B.finallyLoc===Q)return this.complete(B.completion,B.afterLoc),U(B),L}},catch:function(Q){for(var G=this.tryEntries.length-1;G>=0;--G){var B=this.tryEntries[G];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,G,B){return this.delegate={iterator:Z(Q),resultName:G,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)}})(iv);var Xf={exports:{}};(function(c){(function(r,n){c.exports?c.exports=n():r.log=n()})(nh,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})})(Xf);var Tt=Xf.exports;const fs=()=>`${new Date().toISOString()} | metrics`,hs=(c,r,n)=>`${c} | ${r} | ${n}`;Tt.setDefaultLevel(Tt.levels.TRACE);const lv=c=>{Tt.info(hs(fs(),"log ",`set log level to ${c?"verbose":"info"}`)),Tt.setLevel(c?Tt.levels.TRACE:Tt.levels.INFO)},ov=c=>{const r=[...Object.keys(Tt.levels)];r.includes(c)?(Tt.info(hs(fs(),"log ",`update log level to ${c.toLowerCase()}`)),Tt.setLevel(c)):Tt.warn(hs(fs(),"log ","Incorrect log level please choose one of "),r)},Ne=(c,r,n)=>{n?Tt.debug(hs(fs(),c,r),n):Tt.debug(hs(fs(),c,r))},ka=(c,r)=>{Tt.info(hs(fs(),c,r))},dn=(c,r)=>{Tt.info(hs(fs(),c,r))},oo=(c,r)=>{Tt.warn(hs(fs(),c,r))},tr=(c,r)=>{Tt.error(hs(fs(),c,r))};function av(c){return Math.floor(Math.random()*c).toString()}function of(c,r){let n=r;return c.forEach(o=>{n=n.replace(o,"")}),n}function uv(c,r){let n="";for(let o=0;o<r;o+=1)n+=c[av(c.length)];return n}function cv({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=of(a,t)),h=t.split("")),n&&(a.length&&(s=of(a,s)),d=s.split("")),p=[...h,...d,...o],uv(p,c)}var fv=cv;const $i=xt(fv),hv=()=>"WebRTCMetrics",_v=()=>"5.0.3",Me={INBOUND:"inbound",OUTBOUND:"outbound"},cs={IDLE:"idle",RUNNING:"running",MUTED:"muted"},Ui={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},dv=()=>({...{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:[]}}),Qf={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:Me.INBOUND},Zf={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:Me.OUTBOUND},eh={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:Me.INBOUND},th={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:Me.OUTBOUND},pv=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}}},mv={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${$i()}`,cid:`c-${$i()}`,uid:`u-${$i()}`,record:!1,ticket:!0},qt={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"},Pi={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},Ma={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ee={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},xa="config ",gv=(c,r={},n)=>{const o={...n,...r};return r.pname||oo(xa,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${n.pname}'`),r.cid||oo(xa,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${n.cid}'`),r.uid||oo(xa,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${n.uid}'`),o.pc=c,o},vv=(c={})=>{const r={...mv,...c};return r.name=hv(),r.version=_v(),r},el=(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},Ms=c=>c.reduce((r,n)=>r+n,0)/c.length,Tv=()=>`probe-${$i()}`,Ev=()=>`coltr-${$i()}`,af=c=>new Promise(r=>setTimeout(r,c)),Za=(c,r,n)=>{r?c.call(r,n):c(n)},Be=(c,r,n,o)=>{const a=el(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=el(c,r,n,o,a);return t.length===0?null:t.reduce((s,p)=>s+p,0)/t.length},fn=(c,r,n)=>el(c,r,n).reduce((a,t)=>a+t,0),Ge=(c,r,n,o)=>{const a=el(c,r,n,!0,o);return a.length===0?null:Math.min(...a)},Ke=(c,r,n,o)=>{const a=el(c,r,n,!1,o);return a.length===0?null:Math.max(...a)},ct=(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},yv=c=>c.slice().pop(),rt=(c,r,n)=>{if(!r)return null;const o={};let a=r[k.AUDIO][c];a||(a=n===Me.INBOUND?{...Qf}:{...Zf}),o[k.AUDIO]=a;let t=r[k.VIDEO][c];return t||(t=n===Me.INBOUND?{...eh}:{...th}),o[k.VIDEO]=t,o},ki="exporter ",Sv="2.0",uf=(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},Cv=(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)},Av=c=>ct(c,"network","local_candidate_type")!=="relay"?`direct/${ct(c,"network","local_candidate_protocol")}`:`turn/${ct(c,"network","local_candidate_relay_protocol")}`,Rv=c=>{const r=ct(c,"network","remote_candidate_type"),n=ct(c,"network","remote_candidate_protocol");return r!=="relay"?`direct/${n}`:`turn/${n}`};class Iv{constructor(r){this._start=null,this._end=null,this._cfg=r,this._referenceReport=null,this._reports=[],this._events=[]}start(){ka(ki,"start() - start exporter...");const r=new Date;return this._start=r.toJSON(),r}stop(){ka(ki,"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(ki,`addReport() - add report to exporter at ${r.timestamp}`),this._reports.push(r))}addCustomEvent(r){this._events.push(r)}reset(){ka(ki,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Ne(ki,"ticket() - generate ticket");const r=ct(this._reports,"audio","total_packets_lost_in"),n=ct(this._reports,"audio","total_packets_in"),o=ct(this._reports,"video","total_packets_lost_in"),a=ct(this._reports,"video","total_packets_in"),t={},s=yv(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===Me.INBOUND){const d={avg:We(this._reports,k.AUDIO,"delta_jitter_ms_in",!1,p),min:Ge(this._reports,k.AUDIO,"delta_jitter_ms_in",p),max:Ke(this._reports,k.AUDIO,"delta_jitter_ms_in",p),volatility:Be(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:Ge(this._reports,k.AUDIO,"delta_kbs_in",p),max:Ke(this._reports,k.AUDIO,"delta_kbs_in",p),volatility:Be(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:Ge(this._reports,k.AUDIO,"delta_KBytes_in",p),max:Ke(this._reports,k.AUDIO,"delta_KBytes_in",p),volatility:Be(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:Ge(this._reports,k.AUDIO,"mos_emodel_in",p),max:Ke(this._reports,k.AUDIO,"mos_emodel_in",p),volatility:Be(this._reports,k.AUDIO,"mos_emodel_in",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_in",!1,p),min:Ge(this._reports,k.AUDIO,"mos_in",p),max:Ke(this._reports,k.AUDIO,"mos_in",p),volatility:Be(this._reports,k.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},S=ct(this._reports,k.AUDIO,"total_packets_lost_in",p),C=ct(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:Ge(this._reports,k.AUDIO,"delta_jitter_ms_out",p),max:Ke(this._reports,k.AUDIO,"delta_jitter_ms_out",p),volatility:Be(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:Ge(this._reports,k.AUDIO,"delta_kbs_out",p),max:Ke(this._reports,k.AUDIO,"delta_kbs_out",p),volatility:Be(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:Ge(this._reports,k.AUDIO,"delta_KBytes_out",p),max:Ke(this._reports,k.AUDIO,"delta_KBytes_out",p),volatility:Be(this._reports,k.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:uf(this._reports,k.AUDIO,p),min:Ge(this._reports,k.AUDIO,"delta_rtt_ms_out",p),max:Ke(this._reports,k.AUDIO,"delta_rtt_ms_out",p),volatility:Be(this._reports,k.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=ct(this._reports,k.AUDIO,"total_packets_lost_out",p),C=ct(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:Ge(this._reports,k.AUDIO,"mos_emodel_out",p),max:Ke(this._reports,k.AUDIO,"mos_emodel_out",p),volatility:Be(this._reports,k.AUDIO,"mos_emodel_out",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_out",!1,p),min:Ge(this._reports,k.AUDIO,"mos_out",p),max:Ke(this._reports,k.AUDIO,"mos_out",p),volatility:Be(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===Me.INBOUND){const d={avg:We(this._reports,k.VIDEO,"delta_jitter_ms_in",!1,p),min:Ge(this._reports,k.VIDEO,"delta_jitter_ms_in",p),max:Ke(this._reports,k.VIDEO,"delta_jitter_ms_in",p),volatility:Be(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:Ge(this._reports,k.VIDEO,"delta_kbs_in",p),max:Ke(this._reports,k.VIDEO,"delta_kbs_in",p),volatility:Be(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:Ge(this._reports,k.VIDEO,"delta_KBytes_in",p),max:Ke(this._reports,k.VIDEO,"delta_KBytes_in",p),volatility:Be(this._reports,k.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=ct(this._reports,k.VIDEO,"total_packets_lost_in",p),S=ct(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:Ge(this._reports,k.VIDEO,"delta_jitter_ms_out",p),max:Ke(this._reports,k.VIDEO,"delta_jitter_ms_out",p),volatility:Be(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:Ge(this._reports,k.VIDEO,"delta_kbs_out",p),max:Ke(this._reports,k.VIDEO,"delta_kbs_out",p),volatility:Be(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:Ge(this._reports,k.VIDEO,"delta_KBytes_out",p),max:Ke(this._reports,k.VIDEO,"delta_KBytes_out",p),volatility:Be(this._reports,k.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:uf(this._reports,k.VIDEO,p),min:Ge(this._reports,k.VIDEO,"delta_rtt_ms_out",p),max:Ke(this._reports,k.VIDEO,"delta_rtt_ms_out",p),volatility:Be(this._reports,k.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=ct(this._reports,k.VIDEO,"total_packets_lost_out",p),C=ct(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:Sv,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:Cv(this._reports,"data"),min:Ge(this._reports,"data","delta_rtt_connectivity_ms"),max:Ke(this._reports,"data","delta_rtt_connectivity_ms"),volatility:Be(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:Ge(this._reports,"data","delta_kbs_in"),max:Ke(this._reports,"data","delta_kbs_in"),volatility:Be(this._reports,"data","delta_kbs_in")},out:{avg:We(this._reports,"data","delta_kbs_out"),min:Ge(this._reports,"data","delta_kbs_out"),max:Ke(this._reports,"data","delta_kbs_out"),volatility:Be(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:Ge(this._reports,"data","delta_KBytes_in"),max:Ke(this._reports,"data","delta_KBytes_in"),volatility:Be(this._reports,"data","delta_KBytes_in")},out:{avg:We(this._reports,"data","delta_KBytes_out"),min:Ge(this._reports,"data","delta_KBytes_out"),max:Ke(this._reports,"data","delta_KBytes_out"),volatility:Be(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:Av(this._reports),remoteConnection:Rv(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 Us="extractor ",cf=(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}},bv=(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}},Kl=(c,r,n)=>c[q.TIMESTAMP]===n[r].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.JITTER)?null:1e3*(Number(c[q.JITTER])||0),wv=(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}},Ov=(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}},ff=(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}},hf=(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}},_f=(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}},Dv=c=>c[q.CANDIDATE_TYPE]!=="relay"?"":c[q.RELAY_PROTOCOL]||"",Nv=c=>{if(!Object.prototype.hasOwnProperty.call(c,q.NETWORK_TYPE))return Pi.WIFI;switch(c[q.NETWORK_TYPE]){case Ma.ETHERNET:return Pi.ETHERNET;case Ma.CELLULAR_4G:return Pi.CELLULAR_4G;case Ma.WIFI:return Pi.WIFI;default:return Pi.CELLULAR}},df=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]},Uv=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}},kv=(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}},Mv=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}),xv=c=>({clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null}),Lv=(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}},$v=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}},Hv=(c,r,n,o)=>{if(!c)return[];switch(c[q.TYPE]){case qt.CANDIDATE_PAIR:let a=!1;if(c[q.NOMINATED]&&c[q.STATE]===k.SUCCEEDED&&(a=!0,Ne(Us,`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=Lv(c,r,o),d=$v(c),g=bv(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 qt.LOCAL_CANDIDATE:if(c[q.ID]===r.network.local_candidate_id)return[{type:ee.NETWORK,value:{infrastructure:Nv(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:Dv(c)}}];break;case qt.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 qt.INBOUND_RTP:{Ne(Us,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=rt(s,r,Me.INBOUND);p&&(p.timestamp=r.timestamp);const h=rt(s,o,Me.INBOUND);if(h&&(h.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=_f(c,k.AUDIO,p,h),g=Kl(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=wv(c,p),g=_f(c,k.VIDEO,p,h),v=Kl(c,k.VIDEO,p),E=c[q.DECODER_IMPLEMENTATION]||null,S=c[q.CODEC_ID]||null,C=df(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 qt.OUTBOUND_RTP:{Ne(Us,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=rt(s,r,Me.OUTBOUND);p&&(p.timestamp=r.timestamp);const h=rt(s,o,Me.OUTBOUND);if(h&&(h.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=c[q.CODEC_ID]||null,g=ff(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=Ov(c,p),E=df(c),S=Uv(c),C=kv(c,p,h),I=ff(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 qt.MEDIA_SOURCE:{Ne(Us,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case qt.TRACK:{Ne(Us,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case qt.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(Us,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const h=Mv(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(Us,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const h=xv(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 qt.REMOTE_INBOUND_RTP:{Ne(Us,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=rt(s,r,Me.OUTBOUND),h=rt(s,o,Me.OUTBOUND);if(c[q.KIND]===k.AUDIO){const d=cf(c,k.AUDIO,h,p),g=Kl(c,k.AUDIO,p),v=hf(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=cf(c,k.VIDEO,h,p),g=Kl(c,k.VIDEO,p),v=hf(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[]},Ro=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Fv=(c,r=k.AUDIO,n,o,a)=>{const t=rt(a,c,Me.INBOUND),s=rt(a,n,Me.INBOUND),p=rt(a,o,Me.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?Ms(h):100,L=d.length>0?Ms(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 Ro(M)},qv=(c,r=k.AUDIO,n,o,a)=>{const t=rt(a,c,Me.OUTBOUND),s=rt(a,n,Me.OUTBOUND),p=rt(a,o,Me.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?Ms(h):100,H=d.length>0?Ms(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 Ro(V)},Vv=(c,r=k.AUDIO,n,o,a)=>{const t=rt(a,c,Me.INBOUND),s=rt(a,n,Me.INBOUND),p=rt(a,o,Me.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?Ms(h):100,L=d.length>0?Ms(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 Ro(V)},jv=(c,r=k.AUDIO,n,o,a)=>{const t=rt(a,c,Me.OUTBOUND),s=rt(a,n,Me.OUTBOUND),p=rt(a,o,Me.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?Ms(h):100,H=d.length>0?Ms(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,z=93.2-(ve+me*Math.log(1+M*g)+Y);return Ro(z)};class Bv{constructor(r,n){this._callbacks={onreport:null,onticket:null},this._id=Ev(),this._moduleName=this._id,this._probeId=n,this._config=r,this._exporter=new Iv(r),this._state=cs.IDLE,this.registerToPCEvents(),dn(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(r,n,o,a){const t=(h,d)=>h===k.AUDIO?d===qt.INBOUND_RTP?{...Qf}:{...Zf}:d===qt.INBOUND_RTP?{...eh}:{...th},s=pv(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),Hv(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===Me.INBOUND?(d.mos_emodel_in=Fv(s,k.AUDIO,n,o,d.ssrc),d.mos_in=Vv(s,k.AUDIO,n,o,d.ssrc)):(d.mos_emodel_out=qv(s,k.AUDIO,n,o,d.ssrc),d.mos_out=jv(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!==cs.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 tr(this._moduleName,`got error ${r}`),null}}async start(){Ne(this._moduleName,"starting"),this.state=cs.RUNNING,this._startedTime=this._exporter.start(),Ne(this._moduleName,"started")}async mute(){this.state=cs.MUTED,Ne(this._moduleName,"muted")}async unmute(){this.state=cs.RUNNING,Ne(this._moduleName,"unmuted")}async stop(r){if(Ne(this._moduleName,`stopping${r?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=cs.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}'`)):tr(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}'`)):tr(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{tr(this._moduleName,"can't get devices")}},r){r.oniceconnectionstatechange=()=>{const o=r.iceConnectionState;o===Ui.CONNECTED||o===Ui.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Ui.DISCONNECTED||o===Ui.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Ui.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 Gv{constructor(r){this._id=r.pname&&r.pname.substr(0,12).padEnd(12," ")||Tv(),this._moduleName=this._id,dn(this._moduleName,"probe created"),this._config=r,this._collector=new Bv(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===cs.RUNNING}get isIdle(){return this._collector.state===cs.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){oo(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 vt="engine ";class Kv{constructor(r){this._config=r,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},dn(vt,`configured for probing every ${this._config.refreshEvery}ms`),dn(vt,`configured for starting after ${this._config.startAfter}ms`),dn(vt,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Ne(vt,"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=gv(r,n,this._config),a=new Gv(o);return this._probes.push(a),Ne(vt,`${this._probes.length} probes registered`),a}removeExistingProbe(r){if(!r)throw new Error("undefined probe");r.state===cs.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=dv(),s=this._probes.filter(p=>p.isRunning);for(const p of s){const h=await p.collectStats();h&&t.probes.push(h),Ne(vt,`got probe ${p.id}`),await af(0)}return t.delta_time_to_measure_probes_ms=fn(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=fn(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=fn(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=fn(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=fn(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=fn(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=fn(t.probes,"video","total_time_encoded_out"),t};for(Ne(vt,"starting to collect"),r(),Ne(vt,"generating reference reports..."),await n(),Ne(vt,"reference reports generated"),this._startedTime=Date.now();o();)if(Ne(vt,`wait ${this._config.refreshEvery}ms before collecting`),await af(this._config.refreshEvery),o()){Ne(vt,"collecting...");const t=Date.now(),s=await a(),p=Date.now();s.delta_time_consumed_to_measure_ms=p-t,this.fireOnReports(s),Ne(vt,"collected")}Ne(vt,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(r){const n=o=>{this._probes.forEach(a=>{a.stop(o)})};dn(vt,"stop collecting"),n(r)}registerCallback(r,n,o){r in this._callbacks?(this._callbacks[r]={callback:n,context:o},Ne(vt,`registered callback '${r}'`)):tr(vt,`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}'`)):tr(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 Wv="interface ";class Yv{constructor(r){this._config=vv(r),dn(Wv,`welcome to ${this._config.name} version ${this._config.version}`),lv(this._config.verbose||!1),this._engine=new Kv(this._config)}setupLogLevel(r){ov(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 zv{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 Jv=lt,Xv=es(),Ct=new Jv("WebSocketInterface");var Qv=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=Xv.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=vo,Zv=De,eT=ps,tT=mt(),sT=zf,nT=ds(),rT=cu(),iT=es(),lT=Qv,oT=rr("JsSIP");oT("version %s",eu.version);var aT={C:Zv,Exceptions:eT,Utils:tT,UA:sT,URI:nT,NameAddrHeader:rT,WebSocketInterface:lT,Grammar:iT,debug:rr,get name(){return eu.title},get version(){return eu.version}};const uT=xt(aT),cT=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"],Wt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"},fT=0,Wl={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"};class hT extends Jg{constructor(r,n){const o={...r.configuration,sockets:r.socketInterfaces.map(a=>new uT.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 zv({onChangeFunction:this.emitVolumeChange.bind(this)}),n&&rv(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(Wl.SELECTED_INPUT_DEVICE)||"default",n=localStorage.getItem(Wl.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===fT).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("track",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]=nf(r),this.emit("changeActiveCalls",this.activeCalls)}updateMSRPSession(r){this.activeMessages[r._id]=rf(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]:nf(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]:rf(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=lf(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 sf.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 sf.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=Zg(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(Wt.CALL_CONFIRMED,v=>{n.id===v.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(n.id))}),this.subscribe(Wt.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:Wt.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:Wt.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:Wt.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:Wt.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:Wt.CALL_ENDED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("failed",o=>{this.triggerMSRPListener({listenerType:Wt.CALL_FAILED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("confirmed",o=>{this.triggerMSRPListener({listenerType:Wt.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(Wl.SELECTED_INPUT_DEVICE,r),this.selectedMediaDevices.input=r,this.emit("changeActiveInputMediaDevice",r)}setSelectedOutputDevice(r){localStorage.setItem(Wl.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 Yv(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=ev(p,cT);h.callId=r._id,this.setCallMetrics(n)},this.subscribe(Wt.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=lf(this.initialStreamValue,this.microphoneInputLevel*2),a=this.isMuted||this.muteWhenJoin;o.getTracks().forEach(s=>s.enabled=!a),this.setActiveStream(o),await n.connection.getSenders()[0].replaceTrack(o.getTracks()[0]);const t=new MediaStream([r.track]);nv(t,n,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(t,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("track",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)})}}module.exports=hT;
|
154
|
+
a=path:${n.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 t_(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=Re.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=Re.STATUS_INVITE_SENT}terminate(n={}){console.log("terminate",this);const r=n.cause||G.causes.BYE,o=Me.cloneArray(n.extraHeaders),a=n.body;let t,s=n.status_code,p=n.reason_phrase;if(this._status===Re.STATUS_TERMINATED)throw new mn.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Re.STATUS_NULL:case Re.STATUS_INVITE_SENT:case Re.STATUS_1XX_RECEIVED:if(s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||G.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===Re.STATUS_NULL||this._status===Re.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===Re.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=Re.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,G.causes.CANCELED);break;case Re.STATUS_WAITING_FOR_ANSWER:case Re.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,G.causes.REJECTED);break;case Re.STATUS_WAITING_FOR_ACK:case Re.STATUS_CONFIRMED:if(p=n.reason_phrase||G.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===Re.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==qt.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===G.ACK&&(this.sendRequest(G.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===qt.C.STATUS_TERMINATED&&(this.sendRequest(G.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else console.log("here it is"),this.sendRequest(G.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendRequest(n,r){return this._dialog.sendRequest(n,r)}authenticate(n){this.status="auth";let r=new nr("");r.method="AUTH",r.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),r.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),n&&r.addHeader("Authorization",n.toString());let o=r.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(r.toString())}onmessage(n){console.log("onmessage",n);const r=new nr(n.data);if(this.status==="auth"&&r.code===401){const o=this.parseAuth(r.getHeader("WWW-Authenticate")),a=new bm(this.credentials);a.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},o,Me.createRandomToken(12)),this.authenticate(a)}this.status==="auth"&&r.code===200&&this._direction==="outgoing"?(this.my_addr.push(r.getHeader("To-Path")),this.my_addr.push(r.getHeader("Use-Path")),this.status="active",this.inviteParty(r)):this.status==="auth"&&r.code===200&&this._direction==="incoming"?(this.my_addr.push(r.getHeader("To-Path")),this.my_addr.push(r.getHeader("Use-Path")),this.status="active",this.acceptParty(r),this.emit("confirmed")):r.method==="SEND"&&(this._sendOk(r),this._sendReport(r),r.direction="incoming",this.emit("newMessage",r),this._msgHistory.push(r),this.emit("msgHistoryUpdate",this._msgHistory),console.log("======================================================================")),r.code===480&&this._close()}onclose(){console.log("close")}onopen(){const n=new RTCPeerConnection({iceServers:[]});n.createDataChannel(""),n.createOffer().then(n.setLocalDescription.bind(n)),n.onicecandidate=r=>{if(!r||!r.candidate||!r.candidate.candidate)return;const o=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,a=r.candidate.candidate.match(o);this.my_ip=a&&a[1],n.onicecandidate=()=>{},this.authenticate(null)}}onerror(n){console.log(n)}_receiveInviteResponse(n){if(console.log("resp0000000000000",n),this._dialog&&n.status_code>=200&&n.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.sendRequest(G.ACK);return}else{const r=new Bl(this,n,"UAC");if(r.error!==void 0){console.log(r.error);return}this.sendRequest(G.ACK),this.sendRequest(G.BYE);return}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==Re.STATUS_INVITE_SENT&&this._status!==Re.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(n.status_code):this._status=Re.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){console.log("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=Re.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const r={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",n)).catch(a=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(console.log("maybe here???"),this._status=Re.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,G.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",n,G.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const r={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",r),new RTCSessionDescription({type:"answer",sdp:r.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(n,500,o.toString()),console.log("failed 4"),this._failed("local",n,G.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(G.ACK),this._confirmed("local",null)});break}default:{const r=Me.sipErrorCause(n.status_code);console.log("failed 5"),this._failed("remote",n,r)}}}sendMSRP(n){const r=new nr("");r.method="SEND",r.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),r.addHeader("From-Path",`${this.my_addr[0]}`),r.addHeader("Message-ID",Me.createRandomToken(10)),r.addHeader("Byte-Range","1-25/25"),r.addHeader("Content-Type","text/plain"),r.addHeader("Success-Report","yes"),r.addHeader("Failure-Report","yes"),r.body=n;let o=r.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(r.toString()),r.direction="outgoing",this.emit("newMessage",r),this._msgHistory.push(r),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(n){let r=n.ident,o=n.getHeader("Message-ID"),a=new nr("");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=r;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(n){let r=n.ident,o=n.getHeader("Message-ID"),a=new nr("");a.method="REPORT",a.addHeader("To-Path",`${n.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=r;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(n){const r={},o=n.replace("Digest","").split(",");for(const a of o){const t=a.trim().split("=");r[t[0]]=t[1].match('^"(.+)"$')[1]}return r}init_incoming(n,r){let o;const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&a!=="application/sdp"){n.reply(415);return}if(this._status=Re.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(o=n.getHeader("expires")*1e3),n.to_tag=Me.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Re.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),console.log("failed 6"),this._failed("local",null,G.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Re.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),console.log("failed 7"),this._failed("system",null,G.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,r&&r(this),n.parseSDP(!0),this.target_addr=n.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",n),this._status!==Re.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(n,r,o){this.emit("_failed",{originator:n,message:r||null,cause:o}),this._close(),this.emit("failed",{originator:n,message:r||null,cause:o})}_close(){if(console.log("CLOSE SESSION"),this._status!==Re.STATUS_TERMINATED){if(this._status=Re.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){console.log("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyMSRPSession(this)}}_createDialog(n,r,o){const a=r==="UAS"?n.to_tag:n.from_tag,t=r==="UAS"?n.from_tag:n.to_tag,s=n.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Bl(this,n,r,Bl.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",n,G.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,p)return p.update(n,r),this._dialog=p,delete this._earlyDialogs[s],!0;const _=new Bl(this,n,r);return _.error?(console.log("failed 9"),this._failed("remote",n,G.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_newMSRPSession(n,r){this._ua.newMSRPSession(this,{originator:n,session:this,request:r})}_progress(n,r){this.emit("progress",{originator:n,response:r||null})}isEnded(){switch(this._status){case Re.STATUS_CANCELED:case Re.STATUS_TERMINATED:return!0;default:return!1}}_accepted(n,r){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:n,response:r||null})}_confirmed(n,r){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:r||null})}_ended(n,r,o){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:n,message:r||null,cause:o})}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let r;n.session_expires&&n.session_expires>=G.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,r=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}receiveRequest(n){if(console.log("receiveRequest()"),n.method===G.CANCEL)(this._status===Re.STATUS_WAITING_FOR_ANSWER||this._status===Re.STATUS_ANSWERED)&&(this._status=Re.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",n,G.causes.CANCELED));else switch(n.method){case G.ACK:if(this._status!==Re.STATUS_WAITING_FOR_ACK)return;if(this._status=Re.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:G.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(a=>{this.terminate({cause:G.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",n);break;case G.BYE:this._status===Re.STATUS_CONFIRMED||this._status===Re.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,G.causes.BYE)):this._status===Re.STATUS_INVITE_RECEIVED||this._status===Re.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,G.causes.BYE)):n.reply(403,"Wrong Status");break;case G.INVITE:this._status===Re.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case G.INFO:this._status===Re.STATUS_1XX_RECEIVED||this._status===Re.STATUS_WAITING_FOR_ANSWER||this._status===Re.STATUS_ANSWERED||this._status===Re.STATUS_WAITING_FOR_ACK||this._status===Re.STATUS_CONFIRMED?(n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new au(this).init_incoming(n):n.reply(415):n.reply(403,"Wrong Status");break;case G.UPDATE:this._status===Re.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case G.REFER:this._status===Re.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case G.NOTIFY:this._status===Re.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:G.causes.CONNECTION_ERROR,cause:G.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Re.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:G.causes.REQUEST_TIMEOUT,cause:G.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:G.causes.DIALOG_ERROR,cause:G.causes.DIALOG_ERROR})}}const Dt=console,pf={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},fT=aT;class _T extends fT{constructor(n){super(n),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[]}call(n,r){return super.call(n,r)}joinVideoCall(n,r){Dt.debug("call()");const o=new Io(this);return o.connect(n,r),o}newMSRPSession(n,r){n.on("msgHistoryUpdate",o=>{console.log(o)}),this._msrp_sessions[n.id]=n,this.emit("newMSRPSession",r)}newJanusSession(n,r){this._janus_sessions[n.id]=n,this.emit("newJanusSession",r)}destroyMSRPSession(n){delete this._msrp_sessions[n.id]}destroyJanusSession(n){delete this._janus_sessions[n.id]}receiveRequest(n){const r=n.method;if(console.log("-----------"),n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){Dt.debug("Request-URI does not point to us"),n.method!==Ue.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===Ue.SIPS){n.reply_sl(416);return}if(qt.checkTransaction(this,n))return;if(r===Ue.INVITE?new qt.InviteServerTransaction(this,this._transport,n):r!==Ue.ACK&&r!==Ue.CANCEL&&new qt.NonInviteServerTransaction(this,this._transport,n),r===Ue.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new $c.Options(this).init_incoming(n)}else if(r===Ue.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new $c.Message(this).init_incoming(n)}else if(r===Ue.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let o,a;if(n.to_tag)o=this._findDialog(n.call_id,n.from_tag,n.to_tag),o?o.receiveRequest(n):r===Ue.NOTIFY?(a=this._findSession(n),a?a.receiveRequest(n):(Dt.debug("received NOTIFY request for a non existent subscription"),n.reply(481,"Subscription does not exist"))):r!==Ue.ACK&&n.reply(481);else switch(r){case Ue.INVITE:if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const t=n.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?n.reply(603):a.receiveRequest(n)):n.reply(481)}else n.body.search(/MSRP/ig)>-1?(a=new qa(this),a.init_incoming(n)):n.body.search(/JANUS/ig)>-1||(a=new Tg(this),a.init_incoming(n));else Dt.warn("INVITE received but WebRTC is not supported"),n.reply(488);break;case Ue.BYE:n.reply(481);break;case Ue.CANCEL:a=this._findSession(n),a?a.receiveRequest(n):Dt.debug("received CANCEL request for a non existent session");break;case Ue.ACK:break;case Ue.NOTIFY:this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break;default:n.reply(405);break}}startMSRP(n,r){Dt.debug("startMSRP()",r);const o=new qa(this);return o.connect(n),o}startJanus(n,r){Dt.debug("startJanus()",r);const o=new qa(this);return o.connect(n),o}terminateMSRPSessions(n){Dt.debug("terminateSessions()");for(const r in this._msrp_sessions)this._msrp_sessions[r].isEnded()||this._msrp_sessions[r].terminate(n)}terminateJanusSessions(n){Dt.debug("terminateSessions()");for(const r in this._janus_sessions)this._janus_sessions[r].isEnded()||this._janus_sessions[r].terminate(n)}stop(){if(Dt.debug("stop()"),this._dynConfiguration={},this._status===pf.STATUS_USER_CLOSED){Dt.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){Dt.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)){Dt.debug(`closing session ${o}`);try{this._msrp_sessions[o].terminate()}catch(a){console.error(a)}}for(const o in this._janus_sessions)if(Object.prototype.hasOwnProperty.call(this._janus_sessions,o)){Dt.debug(`closing session ${o}`);try{this._janus_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=pf.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&&n===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}const ts=new AudioContext,hT=["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"],dT=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function mf(c){const n={};return hT.forEach(r=>{c[r]!==void 0&&(n[r]=c[r])}),n.localHold=c._localHold,n}function gf(c){const n={};return dT.forEach(r=>{c[r]!==void 0&&(n[r]=c[r])}),n}function Tf(c,n){const r=ts.createMediaStreamSource(c),o=ts.createMediaStreamDestination(),a=ts.createGain();return r.connect(a),a.connect(o),a.gain.value=n,o.stream}function pT(c,n,r,o){const a=document.createElement("audio");a.id=n._id,a.className="audioTag",a.srcObject=c,a.setSinkId(r),a.volume=o,a.play(),n.audioTag=a}function mT(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}const gT=at,TT=is(),bt=new gT("WebSocketInterface");var vT=class{constructor(n){bt.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;const r=TT.parse(n,"absoluteURI");if(r===-1)throw bt.warn(`invalid WebSocket URI: ${n}`),new TypeError(`Invalid argument: ${n}`);if(r.scheme!=="wss"&&r.scheme!=="ws")throw bt.warn(`invalid WebSocket URI scheme: ${r.scheme}`),new TypeError(`Invalid argument: ${n}`);this._sip_uri=`sip:${r.host}${r.port?`:${r.port}`:""};transport=ws`,this._via_transport=r.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(n){this._via_transport=n.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(bt.debug("connect()"),this.isConnected()){bt.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){bt.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),bt.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(n){this._onError(n)}}disconnect(){bt.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(n){return bt.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(bt.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(){bt.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:n,code:r,reason:o}){bt.debug(`WebSocket ${this._url} closed`),n===!1&&bt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!n,r,o)}_onMessage({data:n}){bt.debug("received WebSocket message"),this.ondata(n)}_onError(n){bt.warn(`WebSocket ${this._url} error: `,n)}};const _u=bo,ET=Ue,ST=vs,yT=Et(),AT=h_,CT=Ts(),RT=Au(),IT=is(),bT=vT,wT=ur("JsSIP");wT("version %s",_u.version);var OT={C:ET,Exceptions:ST,Utils:yT,UA:AT,URI:CT,NameAddrHeader:RT,WebSocketInterface:bT,Grammar:IT,debug:ur,get name(){return _u.title},get version(){return _u.version}};const DT=ot(OT);function Ba(c){return c<10?`0${c}`:`${c}`}function NT(c){let n=c.hours||0,r=c.minutes||0,o=c.seconds||0;o++,o===60&&(o=0,r++,r===60&&(r=0,n++));const a=`${Ba(n)}:${Ba(r)}:${Ba(o)}`;return{seconds:o,minutes:r,hours:n,formatted:a}}var St={};St.forEach=async(c,n,r)=>{const o=[];for(let a=0;a<c.length;a++)if(a in c){const t=Promise.resolve(c[a]).then(s=>n.call(r||globalThis,s,a,c));o.push(t)}await Promise.all(o)};St.forEachSeries=async(c,n,r)=>{for(let o=0;o<c.length;o++)o in c&&await n.call(r||globalThis,await c[o],o,c)};St.map=async(c,n,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=Promise.resolve(c[a]).then(t=>n.call(r||globalThis,t,a,c)));return Promise.all(o)};St.mapSeries=async(c,n,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=await n.call(r||globalThis,await c[a],a,c));return o};St.find=(c,n,r)=>new Promise((o,a)=>{if(c.length===0)return o();let t=1;for(let s=0;s<c.length;s++){const p=_=>{_?o(c[s]):t===c.length&&o(),t++};Promise.resolve(c[s]).then(_=>n.call(r||globalThis,_,s,c)).then(p).catch(a)}});St.findSeries=async(c,n,r)=>{for(let o=0;o<c.length;o++)if(await n.call(r||globalThis,await c[o],o,c))return c[o]};St.findIndex=(c,n,r)=>new Promise((o,a)=>{if(c.length===0)return o(-1);let t=1;for(let s=0;s<c.length;s++){const p=_=>{_?o(s):t===c.length&&o(-1),t++};Promise.resolve(c[s]).then(_=>n.call(r||globalThis,_,s,c)).then(p).catch(a)}});St.findIndexSeries=async(c,n,r)=>{for(let o=0;o<c.length;o++)if(await n.call(r||globalThis,await c[o],o,c))return o};St.some=(c,n,r)=>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=_=>{_?o(!0):t===c.length&&o(!1),t++};Promise.resolve(c[s]).then(_=>n.call(r||globalThis,_,s,c)).then(p).catch(a)}});St.someSeries=async(c,n,r)=>{for(let o=0;o<c.length;o++)if(o in c&&await n.call(r||globalThis,await c[o],o,c))return!0;return!1};St.every=(c,n,r)=>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=_=>{_?t===c.length&&o(!0):o(!1),t++};Promise.resolve(c[s]).then(_=>n.call(r||globalThis,_,s,c)).then(p).catch(a)}});St.everySeries=async(c,n,r)=>{for(let o=0;o<c.length;o++)if(o in c&&!await n.call(r||globalThis,await c[o],o,c))return!1;return!0};St.filter=(c,n,r)=>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(_=>n.call(r||globalThis,_,p,c)).catch(a));const s=[];for(let p=0;p<t.length;p++)await t[p]&&s.push(await c[p]);o(s)});St.filterSeries=async(c,n,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&await n.call(r||globalThis,await c[a],a,c)&&o.push(await c[a]);return o};St.reduce=async(c,n,r)=>{if(c.length===0&&r===void 0)throw TypeError("Reduce of empty array with no initial value");let o,a;for(r!==void 0?(a=r,o=0):(a=c[0],o=1),o;o<c.length;o++)o in c&&(a=await n(await a,await c[o],o,c));return a};var d_={};(function(c){const n=St;Object.keys(n).forEach(r=>{const o=r.charAt(0).toUpperCase()+r.slice(1);c[`async${o}`]=async function(...a){return n[r](this,...a)}})})(d_);const UT=St,PT=d_;var vf=Object.assign(UT,{instanceMethods:PT});const es={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var xT={exports:{}};(function(c){var n=function(r){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(ee,W,B){ee[W]=B.value},s,p=typeof Symbol=="function"?Symbol:{},_=p.iterator||"@@iterator",d=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function T(ee,W,B){return Object.defineProperty(ee,W,{value:B,enumerable:!0,configurable:!0,writable:!0}),ee[W]}try{T({},"")}catch{T=function(W,B,re){return W[B]=re}}function E(ee,W,B,re){var ge=W&&W.prototype instanceof ae?W:ae,be=Object.create(ge.prototype),xe=new P(re||[]);return t(be,"_invoke",{value:z(ee,B,xe)}),be}r.wrap=E;function y(ee,W,B){try{return{type:"normal",arg:ee.call(W,B)}}catch(re){return{type:"throw",arg:re}}}var A="suspendedStart",R="suspendedYield",I="executing",$="completed",L={};function ae(){}function N(){}function F(){}var Se={};T(Se,_,function(){return this});var ve=Object.getPrototypeOf,M=ve&&ve(ve(se([])));M&&M!==o&&a.call(M,_)&&(Se=M);var D=F.prototype=ae.prototype=Object.create(Se);N.prototype=F,t(D,"constructor",{value:F,configurable:!0}),t(F,"constructor",{value:N,configurable:!0}),N.displayName=T(F,g,"GeneratorFunction");function q(ee){["next","throw","return"].forEach(function(W){T(ee,W,function(B){return this._invoke(W,B)})})}r.isGeneratorFunction=function(ee){var W=typeof ee=="function"&&ee.constructor;return W?W===N||(W.displayName||W.name)==="GeneratorFunction":!1},r.mark=function(ee){return Object.setPrototypeOf?Object.setPrototypeOf(ee,F):(ee.__proto__=F,T(ee,g,"GeneratorFunction")),ee.prototype=Object.create(D),ee},r.awrap=function(ee){return{__await:ee}};function j(ee,W){function B(be,xe,Ce,le){var ye=y(ee[be],ee,xe);if(ye.type==="throw")le(ye.arg);else{var tt=ye.arg,it=tt.value;return it&&typeof it=="object"&&a.call(it,"__await")?W.resolve(it.__await).then(function(Ee){B("next",Ee,Ce,le)},function(Ee){B("throw",Ee,Ce,le)}):W.resolve(it).then(function(Ee){tt.value=Ee,Ce(tt)},function(Ee){return B("throw",Ee,Ce,le)})}}var re;function ge(be,xe){function Ce(){return new W(function(le,ye){B(be,xe,le,ye)})}return re=re?re.then(Ce,Ce):Ce()}t(this,"_invoke",{value:ge})}q(j.prototype),T(j.prototype,d,function(){return this}),r.AsyncIterator=j,r.async=function(ee,W,B,re,ge){ge===void 0&&(ge=Promise);var be=new j(E(ee,W,B,re),ge);return r.isGeneratorFunction(W)?be:be.next().then(function(xe){return xe.done?xe.value:be.next()})};function z(ee,W,B){var re=A;return function(be,xe){if(re===I)throw new Error("Generator is already running");if(re===$){if(be==="throw")throw xe;return et()}for(B.method=be,B.arg=xe;;){var Ce=B.delegate;if(Ce){var le=H(Ce,B);if(le){if(le===L)continue;return le}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(re===A)throw re=$,B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);re=I;var ye=y(ee,W,B);if(ye.type==="normal"){if(re=B.done?$:R,ye.arg===L)continue;return{value:ye.arg,done:B.done}}else ye.type==="throw"&&(re=$,B.method="throw",B.arg=ye.arg)}}}function H(ee,W){var B=W.method,re=ee.iterator[B];if(re===s)return W.delegate=null,B==="throw"&&ee.iterator.return&&(W.method="return",W.arg=s,H(ee,W),W.method==="throw")||B!=="return"&&(W.method="throw",W.arg=new TypeError("The iterator does not provide a '"+B+"' method")),L;var ge=y(re,ee.iterator,W.arg);if(ge.type==="throw")return W.method="throw",W.arg=ge.arg,W.delegate=null,L;var be=ge.arg;if(!be)return W.method="throw",W.arg=new TypeError("iterator result is not an object"),W.delegate=null,L;if(be.done)W[ee.resultName]=be.value,W.next=ee.nextLoc,W.method!=="return"&&(W.method="next",W.arg=s);else return be;return W.delegate=null,L}q(D),T(D,g,"Generator"),T(D,_,function(){return this}),T(D,"toString",function(){return"[object Generator]"});function J(ee){var W={tryLoc:ee[0]};1 in ee&&(W.catchLoc=ee[1]),2 in ee&&(W.finallyLoc=ee[2],W.afterLoc=ee[3]),this.tryEntries.push(W)}function U(ee){var W=ee.completion||{};W.type="normal",delete W.arg,ee.completion=W}function P(ee){this.tryEntries=[{tryLoc:"root"}],ee.forEach(J,this),this.reset(!0)}r.keys=function(ee){var W=Object(ee),B=[];for(var re in W)B.push(re);return B.reverse(),function ge(){for(;B.length;){var be=B.pop();if(be in W)return ge.value=be,ge.done=!1,ge}return ge.done=!0,ge}};function se(ee){if(ee){var W=ee[_];if(W)return W.call(ee);if(typeof ee.next=="function")return ee;if(!isNaN(ee.length)){var B=-1,re=function ge(){for(;++B<ee.length;)if(a.call(ee,B))return ge.value=ee[B],ge.done=!1,ge;return ge.value=s,ge.done=!0,ge};return re.next=re}}return{next:et}}r.values=se;function et(){return{value:s,done:!0}}return P.prototype={constructor:P,reset:function(ee){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),!ee)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 ee=this.tryEntries[0],W=ee.completion;if(W.type==="throw")throw W.arg;return this.rval},dispatchException:function(ee){if(this.done)throw ee;var W=this;function B(le,ye){return be.type="throw",be.arg=ee,W.next=le,ye&&(W.method="next",W.arg=s),!!ye}for(var re=this.tryEntries.length-1;re>=0;--re){var ge=this.tryEntries[re],be=ge.completion;if(ge.tryLoc==="root")return B("end");if(ge.tryLoc<=this.prev){var xe=a.call(ge,"catchLoc"),Ce=a.call(ge,"finallyLoc");if(xe&&Ce){if(this.prev<ge.catchLoc)return B(ge.catchLoc,!0);if(this.prev<ge.finallyLoc)return B(ge.finallyLoc)}else if(xe){if(this.prev<ge.catchLoc)return B(ge.catchLoc,!0)}else if(Ce){if(this.prev<ge.finallyLoc)return B(ge.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(ee,W){for(var B=this.tryEntries.length-1;B>=0;--B){var re=this.tryEntries[B];if(re.tryLoc<=this.prev&&a.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var ge=re;break}}ge&&(ee==="break"||ee==="continue")&&ge.tryLoc<=W&&W<=ge.finallyLoc&&(ge=null);var be=ge?ge.completion:{};return be.type=ee,be.arg=W,ge?(this.method="next",this.next=ge.finallyLoc,L):this.complete(be)},complete:function(ee,W){if(ee.type==="throw")throw ee.arg;return ee.type==="break"||ee.type==="continue"?this.next=ee.arg:ee.type==="return"?(this.rval=this.arg=ee.arg,this.method="return",this.next="end"):ee.type==="normal"&&W&&(this.next=W),L},finish:function(ee){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.finallyLoc===ee)return this.complete(B.completion,B.afterLoc),U(B),L}},catch:function(ee){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.tryLoc===ee){var re=B.completion;if(re.type==="throw"){var ge=re.arg;U(B)}return ge}}throw new Error("illegal catch attempt")},delegateYield:function(ee,W,B){return this.delegate={iterator:se(ee),resultName:W,nextLoc:B},this.method==="next"&&(this.arg=s),L}},r}(c.exports);try{regeneratorRuntime=n}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}})(xT);var p_={exports:{}};(function(c){(function(n,r){c.exports?c.exports=r():n.log=r()})(S_,function(){var n=function(){},r="undefined",o=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"];function t(R,I){var $=R[I];if(typeof $.bind=="function")return $.bind(R);try{return Function.prototype.bind.call($,R)}catch{return function(){return Function.prototype.apply.apply($,[R,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(R){return R==="debug"&&(R="log"),typeof console===r?!1:R==="trace"&&o?s:console[R]!==void 0?t(console,R):console.log!==void 0?t(console,"log"):n}function _(R,I){for(var $=0;$<a.length;$++){var L=a[$];this[L]=$<R?n:this.methodFactory(L,R,I)}this.log=this.debug}function d(R,I,$){return function(){typeof console!==r&&(_.call(this,I,$),this[R].apply(this,arguments))}}function g(R,I,$){return p(R)||d.apply(this,arguments)}function T(R,I,$){var L=this,ae;I=I??"WARN";var N="loglevel";typeof R=="string"?N+=":"+R:typeof R=="symbol"&&(N=void 0);function F(D){var q=(a[D]||"silent").toUpperCase();if(!(typeof window===r||!N)){try{window.localStorage[N]=q;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+q+";"}catch{}}}function Se(){var D;if(!(typeof window===r||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===r)try{var q=window.document.cookie,j=q.indexOf(encodeURIComponent(N)+"=");j!==-1&&(D=/^([^;]+)/.exec(q.slice(j))[1])}catch{}return L.levels[D]===void 0&&(D=void 0),D}}function ve(){if(!(typeof window===r||!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=R,L.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},L.methodFactory=$||g,L.getLevel=function(){return ae},L.setLevel=function(D,q){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(ae=D,q!==!1&&F(D),_.call(L,D,R),typeof console===r&&D<L.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+D},L.setDefaultLevel=function(D){I=D,Se()||L.setLevel(D,!1)},L.resetLevel=function(){L.setLevel(I,!1),ve()},L.enableAll=function(D){L.setLevel(L.levels.TRACE,D)},L.disableAll=function(D){L.setLevel(L.levels.SILENT,D)};var M=Se();M==null&&(M=I),L.setLevel(M,!1)}var E=new T,y={};E.getLogger=function(I){if(typeof I!="symbol"&&typeof I!="string"||I==="")throw new TypeError("You must supply a name when creating a logger.");var $=y[I];return $||($=y[I]=new T(I,E.getLevel(),E.methodFactory)),$};var A=typeof window!==r?window.log:void 0;return E.noConflict=function(){return typeof window!==r&&window.log===E&&(window.log=A),E},E.getLoggers=function(){return y},E.default=E,E})})(p_);var At=p_.exports;const ps=()=>`${new Date().toISOString()} | metrics`,ms=(c,n,r)=>`${c} | ${n} | ${r}`;At.setDefaultLevel(At.levels.TRACE);const MT=c=>{At.info(ms(ps(),"log ",`set log level to ${c?"verbose":"info"}`)),At.setLevel(c?At.levels.TRACE:At.levels.INFO)},kT=c=>{const n=[...Object.keys(At.levels)];n.includes(c)?(At.info(ms(ps(),"log ",`update log level to ${c.toLowerCase()}`)),At.setLevel(c)):At.warn(ms(ps(),"log ","Incorrect log level please choose one of "),n)},Pe=(c,n,r)=>{r?At.debug(ms(ps(),c,n),r):At.debug(ms(ps(),c,n))},Ga=(c,n)=>{At.info(ms(ps(),c,n))},vn=(c,n)=>{At.info(ms(ps(),c,n))},mo=(c,n)=>{At.warn(ms(ps(),c,n))},lr=(c,n)=>{At.error(ms(ps(),c,n))};function LT(c){return Math.floor(Math.random()*c).toString()}function Ef(c,n){let r=n;return c.forEach(o=>{r=r.replace(o,"")}),r}function $T(c,n){let r="";for(let o=0;o<n;o+=1)r+=c[LT(c.length)];return r}function HT({length:c=20,useLetters:n=!0,useNumbers:r=!0,includeSymbols:o=[],excludeSymbols:a=[]}={}){let t="abcdefghijklmnopqrstuvwxyz",s="0123456789",p=[],_=[],d=[];return n&&(a.length&&(t=Ef(a,t)),_=t.split("")),r&&(a.length&&(s=Ef(a,s)),d=s.split("")),p=[..._,...d,...o],$T(p,c)}var FT=HT;const Bi=ot(FT),VT=()=>"WebRTCMetrics",jT=()=>"5.0.3",$e={INBOUND:"inbound",OUTBOUND:"outbound"},ds={IDLE:"idle",RUNNING:"running",MUTED:"muted"},$i={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},qT=()=>({...{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:[]}}),m_={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:$e.INBOUND},g_={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:$e.OUTBOUND},T_={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:$e.INBOUND},v_={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:$e.OUTBOUND},BT=c=>{const n={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 r={...c,audio:{},video:{},data:{...c.data},network:{...c.network},experimental:{...c.experimental}};return Object.keys(c.audio).forEach(o=>{r.audio[o]={...c.audio[o]}}),Object.keys(c.video).forEach(o=>{r.video[o]={...c.video[o]}}),r}return{...n,audio:{},video:{},data:{...n.data},network:{...n.network},experimental:{...n.experimental}}},GT={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${Bi()}`,cid:`c-${Bi()}`,uid:`u-${Bi()}`,record:!1,ticket:!0},Kt={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"},V={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"},x={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},Hi={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},Wa={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ne={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},Ka="config ",WT=(c,n={},r)=>{const o={...r,...n};return n.pname||mo(Ka,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${r.pname}'`),n.cid||mo(Ka,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${r.cid}'`),n.uid||mo(Ka,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${r.uid}'`),o.pc=c,o},KT=(c={})=>{const n={...GT,...c};return n.name=VT(),n.version=jT(),n},ll=(c,n,r,o=!1,a)=>{let t=c.map(s=>{if(!r)return s[n];if(!a)return s[n][r];const p=s[n][a];return p?p[r]:null});return t=t.filter(s=>o?Number.isFinite(s)&&s>0:Number.isFinite(s)),t.length===0?[]:t},Hs=c=>c.reduce((n,r)=>n+r,0)/c.length,YT=()=>`probe-${Bi()}`,zT=()=>`coltr-${Bi()}`,Sf=c=>new Promise(n=>setTimeout(n,c)),hu=(c,n,r)=>{n?c.call(n,r):c(r)},Ke=(c,n,r,o)=>{const a=ll(c,n,r,!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},Je=(c,n,r,o=!1,a)=>{const t=ll(c,n,r,o,a);return t.length===0?null:t.reduce((s,p)=>s+p,0)/t.length},pn=(c,n,r)=>ll(c,n,r).reduce((a,t)=>a+t,0),Ye=(c,n,r,o)=>{const a=ll(c,n,r,!0,o);return a.length===0?null:Math.min(...a)},ze=(c,n,r,o)=>{const a=ll(c,n,r,!1,o);return a.length===0?null:Math.max(...a)},pt=(c,n,r,o)=>{const a=c.slice().pop();if(!a)return null;if(!r)return a[n];if(!o)return a[n][r];const t=a[n][o];return t?t[r]:null},JT=c=>c.slice().pop(),ut=(c,n,r)=>{if(!n)return null;const o={};let a=n[x.AUDIO][c];a||(a=r===$e.INBOUND?{...m_}:{...g_}),o[x.AUDIO]=a;let t=n[x.VIDEO][c];return t||(t=r===$e.INBOUND?{...T_}:{...v_}),o[x.VIDEO]=t,o},Fi="exporter ",XT="2.0",yf=(c,n,r)=>{if(!c||c.length===0)return 0;const o=c[c.length-1];if(!o)return 0;const a=o[n][r];if(a){const t=a.total_rtt_ms_out,s=a.total_rtt_measure_out;return!s||!t?Je(c,n,"delta_rtt_ms_out",!1,r):Number(t/s)}return null},QT=(c,n)=>{if(!c||c.length===0)return 0;const r=c[c.length-1];if(!r)return 0;const o=r[n].total_rtt_connectivity_ms,a=r[n].total_rtt_connectivity_measure;return!a||!o?Je(c,n,"delta_rtt_connectivity_ms"):Number(o/a)},ZT=c=>pt(c,"network","local_candidate_type")!=="relay"?`direct/${pt(c,"network","local_candidate_protocol")}`:`turn/${pt(c,"network","local_candidate_relay_protocol")}`,ev=c=>{const n=pt(c,"network","remote_candidate_type"),r=pt(c,"network","remote_candidate_protocol");return n!=="relay"?`direct/${r}`:`turn/${r}`};class tv{constructor(n){this._start=null,this._end=null,this._cfg=n,this._referenceReport=null,this._reports=[],this._events=[]}start(){Ga(Fi,"start() - start exporter...");const n=new Date;return this._start=n.toJSON(),n}stop(){Ga(Fi,"stop() - stop exporter...");const n=new Date;return this._end=n.toJSON(),n}saveReferenceReport(n){this._referenceReport=n}getReferenceReport(){return this._referenceReport}addReport(n){this._cfg.ticket&&(Pe(Fi,`addReport() - add report to exporter at ${n.timestamp}`),this._reports.push(n))}addCustomEvent(n){this._events.push(n)}reset(){Ga(Fi,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Pe(Fi,"ticket() - generate ticket");const n=pt(this._reports,"audio","total_packets_lost_in"),r=pt(this._reports,"audio","total_packets_in"),o=pt(this._reports,"video","total_packets_lost_in"),a=pt(this._reports,"video","total_packets_in"),t={},s=JT(this._reports);return s&&(Object.keys(s[x.AUDIO]).forEach(p=>{const _=s[x.AUDIO][p];if(t[_.ssrc]={type:x.AUDIO,direction:_.direction},_.direction===$e.INBOUND){const d={avg:Je(this._reports,x.AUDIO,"delta_jitter_ms_in",!1,p),min:Ye(this._reports,x.AUDIO,"delta_jitter_ms_in",p),max:ze(this._reports,x.AUDIO,"delta_jitter_ms_in",p),volatility:Ke(this._reports,x.AUDIO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Je(this._reports,x.AUDIO,"delta_kbs_in",!1,p),min:Ye(this._reports,x.AUDIO,"delta_kbs_in",p),max:ze(this._reports,x.AUDIO,"delta_kbs_in",p),volatility:Ke(this._reports,x.AUDIO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Je(this._reports,x.AUDIO,"delta_KBytes_in",!1,p),min:Ye(this._reports,x.AUDIO,"delta_KBytes_in",p),max:ze(this._reports,x.AUDIO,"delta_KBytes_in",p),volatility:Ke(this._reports,x.AUDIO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:Je(this._reports,x.AUDIO,"mos_emodel_in",!1,p),min:Ye(this._reports,x.AUDIO,"mos_emodel_in",p),max:ze(this._reports,x.AUDIO,"mos_emodel_in",p),volatility:Ke(this._reports,x.AUDIO,"mos_emodel_in",p)},effective:{avg:Je(this._reports,x.AUDIO,"mos_in",!1,p),min:Ye(this._reports,x.AUDIO,"mos_in",p),max:ze(this._reports,x.AUDIO,"mos_in",p),volatility:Ke(this._reports,x.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},y=pt(this._reports,x.AUDIO,"total_packets_lost_in",p),A=pt(this._reports,x.AUDIO,"total_packets_in",p),R={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].mos=E,t[p].traffic=T,t[p].bitrate=g,t[p].loss=R}else{const d={avg:Je(this._reports,x.AUDIO,"delta_jitter_ms_out",!1,p),min:Ye(this._reports,x.AUDIO,"delta_jitter_ms_out",p),max:ze(this._reports,x.AUDIO,"delta_jitter_ms_out",p),volatility:Ke(this._reports,x.AUDIO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Je(this._reports,x.AUDIO,"delta_kbs_out",!1,p),min:Ye(this._reports,x.AUDIO,"delta_kbs_out",p),max:ze(this._reports,x.AUDIO,"delta_kbs_out",p),volatility:Ke(this._reports,x.AUDIO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Je(this._reports,x.AUDIO,"delta_KBytes_out",!1,p),min:Ye(this._reports,x.AUDIO,"delta_KBytes_out",p),max:ze(this._reports,x.AUDIO,"delta_KBytes_out",p),volatility:Ke(this._reports,x.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:yf(this._reports,x.AUDIO,p),min:Ye(this._reports,x.AUDIO,"delta_rtt_ms_out",p),max:ze(this._reports,x.AUDIO,"delta_rtt_ms_out",p),volatility:Ke(this._reports,x.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=pt(this._reports,x.AUDIO,"total_packets_lost_out",p),A=pt(this._reports,x.AUDIO,"total_packets_out",p),R={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},I={emodel:{avg:Je(this._reports,x.AUDIO,"mos_emodel_out",!1,p),min:Ye(this._reports,x.AUDIO,"mos_emodel_out",p),max:ze(this._reports,x.AUDIO,"mos_emodel_out",p),volatility:Ke(this._reports,x.AUDIO,"mos_emodel_out",p)},effective:{avg:Je(this._reports,x.AUDIO,"mos_out",!1,p),min:Ye(this._reports,x.AUDIO,"mos_out",p),max:ze(this._reports,x.AUDIO,"mos_out",p),volatility:Ke(this._reports,x.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=T,t[p].bitrate=g,t[p].loss=R,t[p].mos=I}}),Object.keys(s[x.VIDEO]).forEach(p=>{const _=s[x.VIDEO][p];if(t[p]={type:x.VIDEO,direction:_.direction},_.direction===$e.INBOUND){const d={avg:Je(this._reports,x.VIDEO,"delta_jitter_ms_in",!1,p),min:Ye(this._reports,x.VIDEO,"delta_jitter_ms_in",p),max:ze(this._reports,x.VIDEO,"delta_jitter_ms_in",p),volatility:Ke(this._reports,x.VIDEO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Je(this._reports,x.VIDEO,"delta_kbs_in",!1,p),min:Ye(this._reports,x.VIDEO,"delta_kbs_in",p),max:ze(this._reports,x.VIDEO,"delta_kbs_in",p),volatility:Ke(this._reports,x.VIDEO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Je(this._reports,x.VIDEO,"delta_KBytes_in",!1,p),min:Ye(this._reports,x.VIDEO,"delta_KBytes_in",p),max:ze(this._reports,x.VIDEO,"delta_KBytes_in",p),volatility:Ke(this._reports,x.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=pt(this._reports,x.VIDEO,"total_packets_lost_in",p),y=pt(this._reports,x.VIDEO,"total_packets_in",p),A={lost:E,avg:Math.round((E/(E+y)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].traffic=T,t[p].bitrate=g,t[p].loss=A}else{const d={avg:Je(this._reports,x.VIDEO,"delta_jitter_ms_out",!1,p),min:Ye(this._reports,x.VIDEO,"delta_jitter_ms_out",p),max:ze(this._reports,x.VIDEO,"delta_jitter_ms_out",p),volatility:Ke(this._reports,x.VIDEO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Je(this._reports,x.VIDEO,"delta_kbs_out",!1,p),min:Ye(this._reports,x.VIDEO,"delta_kbs_out",p),max:ze(this._reports,x.VIDEO,"delta_kbs_out",p),volatility:Ke(this._reports,x.VIDEO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Je(this._reports,x.VIDEO,"delta_KBytes_out",!1,p),min:Ye(this._reports,x.VIDEO,"delta_KBytes_out",p),max:ze(this._reports,x.VIDEO,"delta_KBytes_out",p),volatility:Ke(this._reports,x.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:yf(this._reports,x.VIDEO,p),min:Ye(this._reports,x.VIDEO,"delta_rtt_ms_out",p),max:ze(this._reports,x.VIDEO,"delta_rtt_ms_out",p),volatility:Ke(this._reports,x.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=pt(this._reports,x.VIDEO,"total_packets_lost_out",p),A=pt(this._reports,x.VIDEO,"total_packets_out",p),R={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].rtt=E,t[p].traffic=T,t[p].bitrate=g,t[p].loss=R}})),{version:XT,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:QT(this._reports,"data"),min:Ye(this._reports,"data","delta_rtt_connectivity_ms"),max:ze(this._reports,"data","delta_rtt_connectivity_ms"),volatility:Ke(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((n/(n+r)*100||0)*100)/100}},video:{in:{avg:Math.round((o/(o+a)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:Je(this._reports,"data","delta_kbs_in"),min:Ye(this._reports,"data","delta_kbs_in"),max:ze(this._reports,"data","delta_kbs_in"),volatility:Ke(this._reports,"data","delta_kbs_in")},out:{avg:Je(this._reports,"data","delta_kbs_out"),min:Ye(this._reports,"data","delta_kbs_out"),max:ze(this._reports,"data","delta_kbs_out"),volatility:Ke(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:Je(this._reports,"data","delta_KBytes_in"),min:Ye(this._reports,"data","delta_KBytes_in"),max:ze(this._reports,"data","delta_KBytes_in"),volatility:Ke(this._reports,"data","delta_KBytes_in")},out:{avg:Je(this._reports,"data","delta_KBytes_out"),min:Ye(this._reports,"data","delta_KBytes_out"),max:ze(this._reports,"data","delta_KBytes_out"),volatility:Ke(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:ZT(this._reports),remoteConnection:ev(this._reports)}}}}updateConfig(n){this._cfg=n}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const n=this._reports.slice();return n.pop(),n.pop()||null}getReportsNumber(){return this._reports.length}}const Ls="extractor ",Af=(c,n,r,o)=>{let a=!1;const t=o[n].total_rtt_ms_out,s=o[n].total_rtt_measure_out,p=r?r[n].total_rtt_ms_out:0,_=r?r[n].total_rtt_measure_out:0,d={rtt:null,totalRTT:t,totalRTTMeasurements:s};if(c[V.TIMESTAMP]===o[n].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(a=!0,Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-_===s))return d;const g=1e3*Number(c[V.ROUND_TRIP_TIME]);let T=t+g,E=s+1;return a&&(T=1e3*Number(c[V.TOTAL_ROUND_TRIP_TIME])-p,E=Number(c[V.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-_),{rtt:g,totalRTT:T,totalRTTMeasurements:E}},sv=(c,n,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,V.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:o[n].total_rtt_connectivity_ms,totalRTTMeasurements:o[n].total_rtt_connectivity_measure};const a=1e3*Number(c[V.CURRENT_ROUND_TRIP_TIME]);let t=o[n].total_rtt_connectivity_ms+a,s=o[n].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(c,V.TOTAL_ROUND_TRIP_TIME)&&(t=1e3*Number(c[V.TOTAL_ROUND_TRIP_TIME])-(r?r[n].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,V.RESPONSES_RECEIVED)&&(s=Number(c[V.RESPONSES_RECEIVED])-(r?r[n].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:t,totalRTTMeasurements:s}},eo=(c,n,r)=>c[V.TIMESTAMP]===r[n].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.JITTER)?null:1e3*(Number(c[V.JITTER])||0),nv=(c,n)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:n[x.VIDEO].delta_ms_decode_frame_in,frames_decoded:n[x.VIDEO].total_frames_decoded_in,total_decode_time:n[x.VIDEO].total_time_decoded_in};const r=c[V.FRAMES_DECODED],o=c[V.TOTAL_DECODE_TIME],a=o-n[x.VIDEO].total_time_decoded_in,t=r-n[x.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:t>0?a*1e3/t:0,frames_decoded:r,total_decode_time:o}},rv=(c,n)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:n[x.VIDEO].delta_ms_encode_frame_out,frames_encoded:n[x.VIDEO].total_frames_encoded_out,total_encode_time:n[x.VIDEO].total_time_encoded_out};const r=c[V.FRAMES_ENCODED],o=c[V.TOTAL_ENCODE_TIME],a=o-n[x.VIDEO].total_time_encoded_out,t=r-n[x.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:t>0&&a?a*1e3/t:0,frames_encoded:r,total_encode_time:o}},Cf=(c,n,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_SENT))return{packetsSent:r[n].total_packets_out,packetsLost:r[n].total_packets_lost_out,bytesSent:r[n].total_KBytes_out};const a=Number(c[V.PACKETS_SENT])||0-(o?o[n].total_packets_out:0),t=a-r[n].total_packets_out,s=Number(c[V.BYTES_SENT])/1024-(o?o[n].total_KBytes_out:0),p=s-r[n].total_KBytes_out,_=c[V.TIMESTAMP]||Date.now(),d=o?o.timestamp:null;let g=r.timestamp;!g&&d&&(g=d);const T=g?_-g:0,E=T>0?p*.008*1024/T*1e3:0;return{packetsSent:a,deltaPacketsSent:t,KBytesSent:s,deltaKBytesSent:p,kbsSent:E}},Rf=(c,n,r,o)=>{let a=r[n].total_packets_lost_out,t=0,s=0;return Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)&&(a=Number(c[V.PACKETS_LOST])||0-(o?o[n].total_packets_lost_out:0),t=a-r[n].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,V.FRACTION_LOST)&&(s=Number(100*c[V.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:t,fractionLost:s}},If=(c,n,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_RECEIVED))return{percent_packets_lost:r[n].percent_packets_lost_in,packetsReceived:r[n].total_packets_in,packetsLost:r[n].total_packets_lost_in,bytesReceived:r[n].total_KBytes_in};const a=Number(c[V.PACKETS_RECEIVED])||0-(o?o[n].total_packets_in:0),t=Number(c[V.PACKETS_LOST])||0-(o?o[n].total_packets_lost_in:0),s=t-r[n].total_packets_lost_in,p=a-r[n].total_packets_in,_=a!==r[n].total_packets_in?s*100/(s+p):0,d=Number(c[V.BYTES_RECEIVED])/1024-(o?o[n].total_KBytes_in:0),g=d-r[n].total_KBytes_in,T=c[V.TIMESTAMP]||Date.now(),E=o?o.timestamp:null;let y=r.timestamp;!y&&E&&(y=E);const A=y?T-y:0,R=A>0?g*.008*1024/A*1e3:0;return{percentPacketsLost:_,packetsReceived:a,deltaPacketsReceived:p,packetsLost:t,deltaPacketsLost:s,KBytesReceived:d,deltaKBytesReceived:g,kbsReceived:R}},iv=c=>c[V.CANDIDATE_TYPE]!=="relay"?"":c[V.RELAY_PROTOCOL]||"",lv=c=>{if(!Object.prototype.hasOwnProperty.call(c,V.NETWORK_TYPE))return Hi.WIFI;switch(c[V.NETWORK_TYPE]){case Wa.ETHERNET:return Hi.ETHERNET;case Wa.CELLULAR_4G:return Hi.CELLULAR_4G;case Wa.WIFI:return Hi.WIFI;default:return Hi.CELLULAR}},bf=c=>!Object.prototype.hasOwnProperty.call(c,V.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,V.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[V.FRAME_WIDTH]||null,height:c[V.FRAME_HEIGHT]||null,framerate:c[V.FRAMES_PER_SECOND]},ov=c=>{const n=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_REASON)?c[V.QUALITY_LIMITATION_REASON]:null,r=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[V.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,o=Object.prototype.hasOwnProperty.call(c,V.QUALITY_LIMITATION_DURATIONS)?c[V.QUALITY_LIMITATION_DURATIONS]:null;return o&&Object.keys(o).forEach(a=>{o[a]>1e3&&(o[a]=Number(o[a]/1e3))}),{reason:n,durations:o,resolutionChanges:r}},av=(c,n,r)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:n.total_pli_sent_in,nackCount:n.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const o=(c[V.PLI]||0)-(r?r[x.VIDEO].total_pli_sent_in:0),a=(c[V.NACK]||0)-(r?r[x.VIDEO].total_nack_sent_in:0);return{pliCount:o,nackCount:a,deltaPliCount:o-n[x.VIDEO].total_pli_sent_in,deltaNackCount:a-n[x.VIDEO].total_nack_sent_in}},uv=(c,n,r)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:n.total_pli_received_out,nackCount:n.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const o=(c[V.PLI]||0)-(r?r[x.VIDEO].total_pli_received_out:0),a=(c[V.NACK]||0)-(r?r[x.VIDEO].total_nack_received_out:0);return{pliCount:o,nackCount:a,deltaPliCount:o-n[x.VIDEO].total_pli_received_out,deltaNackCount:a-n[x.VIDEO].total_nack_received_out}},cv=c=>({channels:c[V.CHANNELS]||null,clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null,sdp_fmtp_line:c[V.SDP_FMTP_LINE]||null}),fv=c=>({clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null}),_v=(c,n,r)=>{const o=(c[V.BYTES_RECEIVED]||0)/1024-(r?r.data.total_KBytes_in:0),a=(c[V.BYTES_SENT]||0)/1024-(r?r.data.total_KBytes_out:0),t=c[V.TIMESTAMP]||Date.now(),s=o-n.data.total_KBytes_in,p=a-n.data.total_KBytes_out,_=r?r.timestamp:null;let d=n.timestamp;!d&&_&&(d=_);const g=d?t-d:0,T=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:T,kbs_speed_sent:E}},hv=c=>{const n=c[V.AVAILABLE_INCOMING_BITRATE]/1024||0,r=c[V.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:n,kbs_outgoing_bandwidth:r}},dv=(c,n,r,o)=>{if(!c)return[];switch(c[V.TYPE]){case Kt.CANDIDATE_PAIR:let a=!1;if(c[V.NOMINATED]&&c[V.STATE]===x.SUCCEEDED&&(a=!0,Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c),V.SELECTED in c&&!c[V.SELECTED]&&(a=!1)),a){const s=c[V.LOCAL_CANDIDATE_ID],p=c[V.REMOTE_CANDIDATE_ID],_=_v(c,n,o),d=hv(c),g=sv(c,"data",o,n);return[{type:ne.NETWORK,value:{local_candidate_id:s}},{type:ne.NETWORK,value:{remote_candidate_id:p}},{type:ne.DATA,value:{total_KBytes_in:_.total_KBytes_received}},{type:ne.DATA,value:{total_KBytes_out:_.total_KBytes_sent}},{type:ne.DATA,value:{delta_KBytes_in:_.delta_KBytes_received}},{type:ne.DATA,value:{delta_KBytes_out:_.delta_KBytes_sent}},{type:ne.DATA,value:{delta_kbs_in:_.kbs_speed_received}},{type:ne.DATA,value:{delta_kbs_out:_.kbs_speed_sent}},{type:ne.DATA,value:{delta_kbs_bandwidth_in:d.kbs_incoming_bandwidth}},{type:ne.DATA,value:{delta_kbs_bandwidth_out:d.kbs_outgoing_bandwidth}},{type:ne.DATA,value:{delta_rtt_connectivity_ms:g.rtt}},{type:ne.DATA,value:{total_rtt_connectivity_ms:g.totalRTT}},{type:ne.DATA,value:{total_rtt_connectivity_measure:g.totalRTTMeasurements}}]}break;case Kt.LOCAL_CANDIDATE:if(c[V.ID]===n.network.local_candidate_id)return[{type:ne.NETWORK,value:{infrastructure:lv(c)}},{type:ne.NETWORK,value:{local_candidate_type:c[V.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{local_candidate_protocol:c[V.PROTOCOL]||""}},{type:ne.NETWORK,value:{local_candidate_relay_protocol:iv(c)}}];break;case Kt.REMOTE_CANDIDATE:if(c[V.ID]===n.network.remote_candidate_id)return[{type:ne.NETWORK,value:{remote_candidate_type:c[V.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{remote_candidate_protocol:c[V.PROTOCOL]||""}}];break;case Kt.INBOUND_RTP:{Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const s=c[V.SSRC],p=ut(s,n,$e.INBOUND);p&&(p.timestamp=n.timestamp);const _=ut(s,o,$e.INBOUND);if(_&&(_.timestamp=o.timestamp),c[V.MEDIA_TYPE]===x.AUDIO){const d=If(c,x.AUDIO,p,_),g=eo(c,x.AUDIO,p),T=c[V.CODEC_ID]||"";return[{ssrc:s,type:ne.AUDIO,value:{codec_id_in:T}},{ssrc:s,type:ne.AUDIO,value:{total_packets_in:d.packetsReceived}},{ssrc:s,type:ne.AUDIO,value:{delta_packets_in:d.deltaPacketsReceived}},{ssrc:s,type:ne.AUDIO,value:{total_packets_lost_in:d.packetsLost}},{ssrc:s,type:ne.AUDIO,value:{delta_packets_lost_in:d.deltaPacketsLost}},{ssrc:s,type:ne.AUDIO,value:{percent_packets_lost_in:d.percentPacketsLost}},{ssrc:s,type:ne.AUDIO,value:{total_KBytes_in:d.KBytesReceived}},{ssrc:s,type:ne.AUDIO,value:{delta_KBytes_in:d.deltaKBytesReceived}},{ssrc:s,type:ne.AUDIO,value:{delta_kbs_in:d.kbsReceived}},{ssrc:s,type:ne.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[V.MEDIA_TYPE]===x.VIDEO){const d=nv(c,p),g=If(c,x.VIDEO,p,_),T=eo(c,x.VIDEO,p),E=c[V.DECODER_IMPLEMENTATION]||null,y=c[V.CODEC_ID]||null,A=bf(c),R=av(c,p,_);return[{ssrc:s,type:ne.VIDEO,value:{codec_id_in:y}},{ssrc:s,type:ne.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:s,type:ne.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:s,type:ne.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:s,type:ne.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:s,type:ne.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:s,type:ne.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:s,type:ne.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:s,type:ne.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:s,type:ne.VIDEO,value:{delta_jitter_ms_in:T}},{ssrc:s,type:ne.VIDEO,value:{decoder_in:E}},{ssrc:s,type:ne.VIDEO,value:{delta_ms_decode_frame_in:d.delta_ms_decode_frame}},{ssrc:s,type:ne.VIDEO,value:{total_frames_decoded_in:d.frames_decoded}},{ssrc:s,type:ne.VIDEO,value:{total_time_decoded_in:d.total_decode_time}},{ssrc:s,type:ne.VIDEO,value:{total_nack_sent_in:R.nackCount}},{ssrc:s,type:ne.VIDEO,value:{delta_nack_sent_in:R.deltaNackCount}},{ssrc:s,type:ne.VIDEO,value:{total_pli_sent_in:R.pliCount}},{ssrc:s,type:ne.VIDEO,value:{delta_pli_sent_in:R.deltaPliCount}},{ssrc:s,type:ne.VIDEO,value:{size_in:A}}]}break}case Kt.OUTBOUND_RTP:{Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const s=c[V.SSRC],p=ut(s,n,$e.OUTBOUND);p&&(p.timestamp=n.timestamp);const _=ut(s,o,$e.OUTBOUND);if(_&&(_.timestamp=o.timestamp),c[V.MEDIA_TYPE]===x.AUDIO){const d=c[V.CODEC_ID]||null,g=Cf(c,x.AUDIO,p,_);return[{ssrc:s,type:ne.AUDIO,value:{codec_id_out:d}},{ssrc:s,type:ne.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:s,type:ne.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:s,type:ne.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:s,type:ne.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:s,type:ne.AUDIO,value:{delta_kbs_out:g.kbsSent}}]}if(c[V.MEDIA_TYPE]===x.VIDEO){const d=c[V.ENCODER_IMPLEMENTATION]||null,g=c[V.CODEC_ID]||null,T=rv(c,p),E=bf(c),y=ov(c),A=uv(c,p,_),R=Cf(c,x.VIDEO,p,_);return[{ssrc:s,type:ne.VIDEO,value:{codec_id_out:g}},{ssrc:s,type:ne.VIDEO,value:{total_packets_out:R.packetsSent}},{ssrc:s,type:ne.VIDEO,value:{delta_packets_out:R.deltaPacketsSent}},{ssrc:s,type:ne.VIDEO,value:{total_KBytes_out:R.KBytesSent}},{ssrc:s,type:ne.VIDEO,value:{delta_KBytes_out:R.deltaKBytesSent}},{ssrc:s,type:ne.VIDEO,value:{delta_kbs_out:R.kbsSent}},{ssrc:s,type:ne.VIDEO,value:{encoder_out:d}},{ssrc:s,type:ne.VIDEO,value:{delta_ms_encode_frame_out:T.delta_ms_encode_frame}},{ssrc:s,type:ne.VIDEO,value:{total_frames_encoded_out:T.frames_encoded}},{ssrc:s,type:ne.VIDEO,value:{total_time_encoded_out:T.total_encode_time}},{ssrc:s,type:ne.VIDEO,value:{total_nack_received_out:A.nackCount}},{ssrc:s,type:ne.VIDEO,value:{delta_nack_received_out:A.deltaNackCount}},{ssrc:s,type:ne.VIDEO,value:{total_pli_received_out:A.pliCount}},{ssrc:s,type:ne.VIDEO,value:{delta_pli_received_out:A.deltaPliCount}},{ssrc:s,type:ne.VIDEO,value:{size_out:E}},{ssrc:s,type:ne.VIDEO,value:{limitation_out:y}}]}break}case Kt.MEDIA_SOURCE:{Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);break}case Kt.TRACK:{Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);break}case Kt.CODEC:const t=[];return Object.keys(n[x.AUDIO]).forEach(s=>{const p=n[x.AUDIO][s];if(p.codec_id_in===c[V.ID]||p.codec_id_out===c[V.ID]){Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const _=cv(c);c[V.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ne.AUDIO,value:{codec_in:_}}):t.push({ssrc:p.ssrc,type:ne.AUDIO,value:{codec_out:_}})}}),Object.keys(n[x.VIDEO]).forEach(s=>{const p=n[x.VIDEO][s];if(p.codec_id_in===c[V.ID]||p.codec_id_out===c[V.ID]){Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const _=fv(c);c[V.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ne.VIDEO,value:{codec_in:_}}):t.push({ssrc:p.ssrc,type:ne.VIDEO,value:{codec_out:_}})}}),t;case Kt.REMOTE_INBOUND_RTP:{Pe(Ls,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const s=c[V.SSRC],p=ut(s,n,$e.OUTBOUND),_=ut(s,o,$e.OUTBOUND);if(c[V.KIND]===x.AUDIO){const d=Af(c,x.AUDIO,_,p),g=eo(c,x.AUDIO,p),T=Rf(c,x.AUDIO,p,_);return[{ssrc:s,type:ne.AUDIO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ne.AUDIO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ne.AUDIO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ne.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ne.AUDIO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:s,type:ne.AUDIO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:s,type:ne.AUDIO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:s,type:ne.AUDIO,value:{percent_packets_lost_out:T.fractionLost}}]}if(c[V.KIND]===x.VIDEO){const d=Af(c,x.VIDEO,_,p),g=eo(c,x.VIDEO,p),T=Rf(c,x.VIDEO,p,_);return[{ssrc:s,type:ne.VIDEO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ne.VIDEO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ne.VIDEO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ne.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ne.VIDEO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:s,type:ne.VIDEO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:s,type:ne.VIDEO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:s,type:ne.VIDEO,value:{percent_packets_lost_out:T.fractionLost}}]}break}}return[]},xo=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),pv=(c,n=x.AUDIO,r,o,a)=>{const t=ut(a,c,$e.INBOUND),s=ut(a,r,$e.INBOUND),p=ut(a,o,$e.INBOUND),_=[],d=[],g=t[n].percent_packets_lost_in,T=t[n].delta_jitter_ms_in,E=s&&s[n].delta_jitter_ms_in||null,y=p&&p[n].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,R=r&&r.data.delta_rtt_connectivity_ms||null,I=o&&o.data.delta_rtt_connectivity_ms||null;A&&_.push(A),R&&_.push(R),I&&_.push(I),T&&d.push(T),r&&E&&d.push(E),o&&y&&d.push(y);const $=_.length>0?Hs(_):100,L=d.length>0?Hs(d):10,ae=93.2-g,N=.18*ae*ae-27.9*ae+1126.62,F=($+L)/2,Se=F-177.3<0?0:1,ve=.024*F+.11*(F-177.3)*Se,M=N-ve;return xo(M)},mv=(c,n=x.AUDIO,r,o,a)=>{const t=ut(a,c,$e.OUTBOUND),s=ut(a,r,$e.OUTBOUND),p=ut(a,o,$e.OUTBOUND),_=[],d=[],g=t[n].percent_packets_lost_out,T=t[n].delta_rtt_ms_out,E=s&&s[n].delta_rtt_ms_out||null,y=p&&p[n].delta_rtt_ms_out||null,A=t[n].delta_jitter_ms_out,R=s&&s[n].delta_jitter_ms_out||null,I=p&&p[n].delta_jitter_ms_out||null,$=c.data.delta_rtt_connectivity_ms,L=r&&r.data.delta_rtt_connectivity_ms||null,ae=o&&o.data.delta_rtt_connectivity_ms||null;T?_.push(T):$&&_.push($),E?_.push(E):L&&_.push(L),y?_.push(y):ae&&_.push(ae),A&&d.push(A),r&&R&&d.push(R),o&&I&&d.push(I);const N=_.length>0?Hs(_):100,F=d.length>0?Hs(d):10,Se=93.2-g,ve=.18*Se*Se-27.9*Se+1126.62,M=(N+F)/2,D=M-177.3<0?0:1,q=.024*M+.11*(M-177.3)*D,j=ve-q;return xo(j)},gv=(c,n=x.AUDIO,r,o,a)=>{const t=ut(a,c,$e.INBOUND),s=ut(a,r,$e.INBOUND),p=ut(a,o,$e.INBOUND),_=[],d=[],g=t[n].percent_packets_lost_in/100,T=t[n].delta_jitter_ms_in,E=s&&s[n].delta_jitter_ms_in||null,y=p&&p[n].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,R=r&&r.data.delta_rtt_connectivity_ms||null,I=o&&o.data.delta_rtt_connectivity_ms||null;A&&_.push(A),R&&_.push(R),I&&_.push(I),T&&d.push(T),s&&E&&d.push(E),p&&y&&d.push(y);const $=_.length>0?Hs(_):100,L=d.length>0?Hs(d):10,ae=0,N=19.8,F=29.7,Se=30,ve=($+L)/2+Se,M=ve-177.3<0?0:1,D=.024*ve+.11*(ve-177.3)*M,j=93.2-(ae+N*Math.log(1+F*g)+D);return xo(j)},Tv=(c,n=x.AUDIO,r,o,a)=>{const t=ut(a,c,$e.OUTBOUND),s=ut(a,r,$e.OUTBOUND),p=ut(a,o,$e.OUTBOUND),_=[],d=[],g=t[n].percent_packets_lost_out/100,T=t[n].delta_rtt_ms_out,E=s&&s[n].delta_rtt_ms_out||null,y=p&&p[n].delta_rtt_ms_out||null,A=t[n].delta_jitter_ms_out,R=s&&s[n].delta_jitter_ms_out||null,I=p&&p[n].delta_jitter_ms_out||null,$=c.data.delta_rtt_connectivity_ms,L=r&&r.data.delta_rtt_connectivity_ms||null,ae=o&&o.data.delta_rtt_connectivity_ms||null;T?_.push(T):$&&_.push($),E?_.push(E):L&&_.push(L),y?_.push(y):ae&&_.push(ae),A&&d.push(A),s&&R&&d.push(R),p&&I&&d.push(I);const N=_.length>0?Hs(_):100,F=d.length>0?Hs(d):10,Se=0,ve=19.8,M=29.7,D=30,q=(N+F)/2+D,j=q-177.3<0?0:1,z=.024*q+.11*(q-177.3)*j,J=93.2-(Se+ve*Math.log(1+M*g)+z);return xo(J)};class vv{constructor(n,r){this._callbacks={onreport:null,onticket:null},this._id=zT(),this._moduleName=this._id,this._probeId=r,this._config=n,this._exporter=new tv(n),this._state=ds.IDLE,this.registerToPCEvents(),vn(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(n,r,o,a){const t=(_,d)=>_===x.AUDIO?d===Kt.INBOUND_RTP?{...m_}:{...g_}:d===Kt.INBOUND_RTP?{...T_}:{...v_},s=BT(r);s.pname=this._config.pname,s.call_id=this._config.cid,s.user_id=this._config.uid,s.count=r?r.count+1:1;let p=null;return n.forEach(_=>{!p&&_.timestamp&&(p=_.timestamp),dv(_,s,s.pname,a).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let T=s[g.type][g.ssrc];T||(T=t(g.type,_.type),T.ssrc=g.ssrc,s[g.type][g.ssrc]=T),Object.keys(g.value).forEach(E=>{T[E]=g.value[E]})}else Object.keys(g.value).forEach(T=>{s[g.type][T]=g.value[T]})})}),s.timestamp=p,Object.keys(s[x.AUDIO]).forEach(_=>{const d=s[x.AUDIO][_];d.direction===$e.INBOUND?(d.mos_emodel_in=pv(s,x.AUDIO,r,o,d.ssrc),d.mos_in=gv(s,x.AUDIO,r,o,d.ssrc)):(d.mos_emodel_out=mv(s,x.AUDIO,r,o,d.ssrc),d.mos_out=Tv(s,x.AUDIO,r,o,d.ssrc))}),s}async takeReferenceStats(){return new Promise((n,r)=>{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),_=Date.now();p.experimental.time_to_measure_ms=_-t,p.experimental.time_to_wait_ms=a,this._exporter.saveReferenceReport(p),Pe(this._moduleName,`got reference report for probe ${this._probeId}`),n()}catch(a){r(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==ds.RUNNING||!this._config.pc)return Pe(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const n=Date.now(),r=await this._config.pc.getStats(),o=this.analyze(r,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),a=Date.now();return o.experimental.time_to_measure_ms=a-n,this._exporter.addReport(o),Pe(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(o),o}catch(n){return lr(this._moduleName,`got error ${n}`),null}}async start(){Pe(this._moduleName,"starting"),this.state=ds.RUNNING,this._startedTime=this._exporter.start(),Pe(this._moduleName,"started")}async mute(){this.state=ds.MUTED,Pe(this._moduleName,"muted")}async unmute(){this.state=ds.RUNNING,Pe(this._moduleName,"unmuted")}async stop(n){if(Pe(this._moduleName,`stopping${n?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=ds.IDLE,this._config.ticket){const{ticket:r}=this._exporter;this.fireOnTicket(r)}this._exporter.reset(),Pe(this._moduleName,"stopped")}registerCallback(n,r,o){n in this._callbacks?(this._callbacks[n]={callback:r,context:o},Pe(this._moduleName,`registered callback '${n}'`)):lr(this._moduleName,`can't register callback for '${n}' - not found`)}unregisterCallback(n){n in this._callbacks?(this._callbacks[n]=null,delete this._callbacks[n],Pe(this._moduleName,`unregistered callback '${n}'`)):lr(this._moduleName,`can't unregister callback for '${n}' - not found`)}fireOnReport(n){this._callbacks.onreport&&hu(this._callbacks.onreport.callback,this._callbacks.onreport.context,n)}fireOnTicket(n){this._callbacks.onticket&&hu(this._callbacks.onticket.callback,this._callbacks.onticket.context,n)}updateConfig(n){this._config=n,this._exporter.updateConfig(n)}get state(){return this._state}set state(n){this._state=n,Pe(this._moduleName,`state changed to ${n}`)}addCustomEvent(n,r,o,a){this._exporter.addCustomEvent({at:typeof n=="object"?n.toJSON():n,category:r,name:o,description:a})}async registerToPCEvents(){const{pc:n}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const r=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${r.length} devices found`,"Media Devices state")}catch{lr(this._moduleName,"can't get devices")}},n){n.oniceconnectionstatechange=()=>{const o=n.iceConnectionState;o===$i.CONNECTED||o===$i.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===$i.DISCONNECTED||o===$i.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===$i.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},n.onicegatheringstatechange=()=>{const o=n.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",o,"ICE gathering state")},n.ontrack=o=>{this.addCustomEvent(new Date().toJSON(),"call",`${o.track.kind}track`,"MediaStreamTrack received")},n.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const r=n.getReceivers();if(r&&r.length>0){const o=r[0],{transport:a}=o;if(a){const{iceTransport:t}=a;t&&(t.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class Ev{constructor(n){this._id=n.pname&&n.pname.substr(0,12).padEnd(12," ")||YT(),this._moduleName=this._id,vn(this._moduleName,"probe created"),this._config=n,this._collector=new vv(this._config,this._id)}set onreport(n){n?this._collector.registerCallback("onreport",n):this._collector.unregisterCallback("onreport")}set onticket(n){n?this._collector.registerCallback("onticket",n):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(n){this._collector.state=n}addCustomEvent(n,r,o,a=new Date().toJSON()){this._collector.addCustomEvent(a,r,n,o)}get isRunning(){return this._collector.state===ds.RUNNING}get isIdle(){return this._collector.state===ds.IDLE}updateUserId(n){this._config.uid=n,this._collector.updateConfig(this._config)}updateCallId(n){this._config.cid=n,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){mo(this._moduleName,"probe is already running");return}this._collector.start()}stop(n=!1){this.isRunning&&this._collector.stop(n)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const yt="engine ";class Sv{constructor(n){this._config=n,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},vn(yt,`configured for probing every ${this._config.refreshEvery}ms`),vn(yt,`configured for starting after ${this._config.startAfter}ms`),vn(yt,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Pe(yt,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(n=>n.isRunning)}get isIdle(){return this._probes.every(n=>n.isIdle)}addNewProbe(n,r){if(!n)throw new Error("undefined peer connection");const o=WT(n,r,this._config),a=new Ev(o);return this._probes.push(a),Pe(yt,`${this._probes.length} probes registered`),a}removeExistingProbe(n){if(!n)throw new Error("undefined probe");n.state===ds.RUNNING&&n.stop(),this._probes=this._probes.filter(r=>n.id!==r.id)}async start(){const n=()=>{this._probes.forEach(t=>t.start())},r=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=qT(),s=this._probes.filter(p=>p.isRunning);for(const p of s){const _=await p.collectStats();_&&t.probes.push(_),Pe(yt,`got probe ${p.id}`),await Sf(0)}return t.delta_time_to_measure_probes_ms=pn(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=pn(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=pn(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=pn(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=pn(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=pn(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=pn(t.probes,"video","total_time_encoded_out"),t};for(Pe(yt,"starting to collect"),n(),Pe(yt,"generating reference reports..."),await r(),Pe(yt,"reference reports generated"),this._startedTime=Date.now();o();)if(Pe(yt,`wait ${this._config.refreshEvery}ms before collecting`),await Sf(this._config.refreshEvery),o()){Pe(yt,"collecting...");const t=Date.now(),s=await a(),p=Date.now();s.delta_time_consumed_to_measure_ms=p-t,this.fireOnReports(s),Pe(yt,"collected")}Pe(yt,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(n){const r=o=>{this._probes.forEach(a=>{a.stop(o)})};vn(yt,"stop collecting"),r(n)}registerCallback(n,r,o){n in this._callbacks?(this._callbacks[n]={callback:r,context:o},Pe(yt,`registered callback '${n}'`)):lr(yt,`can't register callback for '${n}' - not found`)}unregisterCallback(n){n in this._callbacks?(this._callbacks[n]=null,delete this._callbacks[n],Pe(this._moduleName,`unregistered callback '${n}'`)):lr(this._moduleName,`can't unregister callback for '${n}' - not found`)}fireOnReports(n){this._callbacks.onresult&&n.probes.length>0&&hu(this._callbacks.onresult.callback,this._callbacks.onresult.context,n)}}const yv="interface ";class Av{constructor(n){this._config=KT(n),vn(yv,`welcome to ${this._config.name} version ${this._config.version}`),MT(this._config.verbose||!1),this._engine=new Sv(this._config)}setupLogLevel(n){kT(n)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(n,r){return this._engine.addNewProbe(n,r)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(n){this._engine.removeExistingProbe(n)}set onresult(n){n?this._engine.registerCallback("onresult",n):this._engine.unregisterCallback("onresult")}}function Cv(c,n){return Object.keys(c).filter(r=>n.includes(r)).reduce((r,o)=>{const a=o;return{...r,[a]:c[a]}},{})}const Rv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"];class Iv{constructor(n){this.intervals={},this.emitInterval=n.emitInterval||200,this.onChangeFunction=n.onChangeFunction}start(n,r){n&&n.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(n,r))}stop(n){this.clearVolumeInterval(n)}clearVolumeInterval(n){console.log("clearVolumeInterval",n),clearInterval(this.intervals[n]),delete this.intervals[n]}clearAllIntervals(){Object.keys(this.intervals).forEach(n=>{clearInterval(this.intervals[n])}),this.intervals={}}beginCalculation(n,r){this.clearVolumeInterval(r);const o=ts.createAnalyser(),a=ts.createMediaStreamSource(n),t=ts.createScriptProcessor(2048,1,1);o.smoothingTimeConstant=.8,o.fftSize=1024,a.connect(o),o.connect(t),t.connect(ts.destination),this.intervals[r]=setInterval(()=>{const s=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(s);let p=0;const _=s.length;for(let g=0;g<_;g++)p+=s[g];const d=p/_;this.onChangeFunction(r,d)},this.emitInterval)}}const to={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},bv=0;class wv{constructor(n){this.isAutoAnswer=!1,this.muteWhenJoinEnabled=!1,this.isDNDEnabled=!1,this.muted=!1,this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},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.context=n,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new Iv({onChangeFunction:this.emitVolumeChange.bind(this)}),this.initializeMediaDevices()}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(n){this.currentActiveRoomIdValue=n,this.context.emit("currentActiveRoomChanged",n)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(n){this.isCallAddingInProgress=n,this.context.emit("callAddingInProgressChanged",n)}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 getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(n=>n.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(n=>n.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(n){this.availableMediaDevices=n,this.context.emit("changeAvailableDeviceList",n)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const n=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(n)}async initializeMediaDevices(){const n=localStorage.getItem(to.SELECTED_INPUT_DEVICE)||"default",r=localStorage.getItem(to.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(n),await this.setSpeaker(r),navigator.mediaDevices.addEventListener("devicechange",async()=>{const t=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(t)})}setCallTime(n){const r={...n};delete r.callId,this.callTime={...this.callTime,[n.callId]:r},this.context.emit("changeCallTime",this.callTime)}removeCallTime(n){const r={...this.callTime};delete r[n],this.callTime={...r},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(n,r){this.timeIntervals={...this.timeIntervals,[n]:r}}removeTimeInterval(n){const r={...this.timeIntervals};r[n]&&(clearInterval(r[n]),delete r[n],this.timeIntervals={...r})}stopCallTimer(n){this.removeTimeInterval(n),this.removeCallTime(n)}emitVolumeChange(n,r){this.context.emit("changeCallVolume",{callId:n,volume:r})}setMetricsConfig(n){this.metricConfig={...this.metricConfig,...n}}sendDTMF(n,r){if(!/^[A-D0-9]+$/g.test(r))throw new Error("Not allowed character in DTMF input");this.extendedCalls[n].sendDTMF(r)}setIsMuted(n){this.muted=n,this.context.emit("changeIsMuted",n)}processMute(n){const r=this.currentActiveRoomId;this.setIsMuted(n),this.initialStreamValue.getTracks().forEach(o=>o.enabled=!n),this.roomReconfigure(r)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:n,toHold:r,automatic:o}){const a=this.extendedCalls[n];a._automaticHold=o??!1,await new Promise(p=>{const _=()=>{p()};r?a.hold({},_):a.unhold({},_)}),this.updateCall(a);const s=Object.values(this.extendedCalls).filter(p=>p.roomId===this.currentActiveRoomId&&(r?n!==p._id:!0));s.length>1&&await this.doConference(s)}holdCall(n,r=!1){return this.processHold({callId:n,automatic:r,toHold:!0})}unholdCall(n){return this.processHold({callId:n,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(n=>n.direction==="outgoing"&&n.status===bv).forEach(n=>this.terminateCall(n._id))}answerCall(n){const r=this.extendedCalls[n];this.cancelAllOutgoingUnanswered(),r.answer(this.sipOptions),this.updateCall(r),this.setActiveRoom(r.roomId),r.connection.addEventListener("track",o=>{this.triggerAddStream(o,r)})}async moveCall(n,r){this.updateCallStatus({callId:n,isMoving:!0}),await this.processRoomChange({callId:n,roomId:r}),this.updateCallStatus({callId:n,isMoving:!1})}updateCall(n){this.activeCalls[n._id]=mf(n),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(n){const o={...this.activeRooms[n.roomId],...n};this.activeRooms={...this.activeRooms,[n.roomId]:{...o}},this.context.emit("updateRoom",{room:o,roomList:this.activeRooms})}hasAutoAnswerHeaders(n){const r=/answer-after=0/,a=n.request.getHeader("Call-Info");return a&&r.test(a)}addCall(n,r=!0){this.activeCalls={...this.activeCalls,[n._id]:mf(n)},this.extendedCalls[n._id]=n,r&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(n){this.callStatus={...this.callStatus,[n]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(n){const o={...{...this.callStatus[n.callId]}};n.isMoving!==void 0&&(o.isMoving=n.isMoving),n.isTransferring!==void 0&&(o.isTransferring=n.isTransferring),n.isMerging!==void 0&&(o.isMerging=n.isMerging),this.callStatus={...this.callStatus,[n.callId]:{...o}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(n){const r={...this.callStatus};delete r[n],this.callStatus={...r},this.context.emit("changeCallStatus",this.callStatus)}addRoom(n){this.activeRooms={...this.activeRooms,[n.roomId]:n},this.context.emit("addRoom",{room:n,roomList:this.activeRooms})}getActiveStream(){const n=Tf(this.initialStreamValue,this.microphoneInputLevel*2);return n.getTracks().forEach(r=>r.enabled=!this.isMuted),this.setActiveStream(n),n}async setMicrophone(n){if(!this.getInputDeviceList.find(({deviceId:o})=>o===n)||(this.setSelectedInputDevice(n),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const r=Object.values(this.extendedCalls).filter(o=>o.roomId===this.currentActiveRoomId);r.length===1?Object.values(r).forEach(async o=>{const a=this.getActiveStream();o.connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.updateCall(o)}):await this.doConference(r)}setActiveStream(n){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(n,"origin"),this.activeStreamValue=n,this.context.emit("changeActiveStream",n)}async setSpeaker(n){if(!this.getOutputDeviceList.find(({deviceId:a})=>a===n))return;this.setSelectedOutputDevice(n);const r=Object.values(this.extendedCalls);if(r.length===0)return;const o=r.filter(a=>a.roomId===this.currentActiveRoomId);o.length===1?r.forEach(a=>{var t;(t=a.audioTag)==null||t.setSinkId(n),this.updateCall(a)}):await this.doConference(o)}removeRoom(n){const r={...this.activeRooms},o={...r[n]};delete r[n],this.activeRooms={...r},this.context.emit("removeRoom",{room:o,roomList:this.activeRooms})}deleteRoomIfEmpty(n){n!==void 0&&Object.values(this.extendedCalls).filter(r=>r.roomId===n).length===0&&(this.removeRoom(n),this.currentActiveRoomId===n&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(n){this.muted?n.mute({audio:!0}):n.unmute({audio:!0})}async roomReconfigure(n){if(n===void 0)return;const r=Object.values(this.extendedCalls).filter(o=>o.roomId===n);if(this.currentActiveRoomId===n?r.forEach(o=>{o.audioTag&&(this.muteReconfigure(o),o.audioTag.muted=!1,this.updateCall(o))}):r.forEach(o=>{o.audioTag&&(o.audioTag.muted=!0,this.updateCall(o))}),r.length===0)this.deleteRoomIfEmpty(n);else if(r.length===1&&this.currentActiveRoomId!==n)r[0].isOnHold().local||await this.holdCall(r[0].id,!0);else if(r.length===1&&this.currentActiveRoomId===n){if(r[0].isOnHold().local&&r[0]._automaticHold&&await this.unholdCall(r[0].id),r[0].connection&&r[0].connection.getSenders()[0]){const o=this.getActiveStream();await r[0].connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.muteReconfigure(r[0])}}else r.length>1&&await this.doConference(r)}async doConference(n){await vf.forEach(n,async o=>{o._localHold&&await this.unholdCall(o._id)});const r=[];n.forEach(o=>{o!=null&&o.connection.getReceivers().forEach(a=>{r.push(a.track)})}),await vf.forEach(n,async o=>{if(o==null)return;const a=new MediaStream,t=ts.createMediaStreamDestination();if(o.connection.getReceivers().forEach(s=>{r.forEach(p=>{a.addTrack(s.track),s.track.id!==p.id&&ts.createMediaStreamSource(new MediaStream([p])).connect(t)})}),n[0].roomId===this.currentActiveRoomId){const s=this.getActiveStream();ts.createMediaStreamSource(s).connect(t)}o.connection.getSenders()[0]&&(await o.connection.getSenders()[0].replaceTrack(t.stream.getTracks()[0]),this.muteReconfigure(o))})}processCallerMute(n,r){const o=this.extendedCalls[n];o&&o.connection.getReceivers().length&&(o.localMuted=r,o.connection.getReceivers().forEach(a=>{a.track.enabled=!r}),this.updateCall(o))}muteCaller(n){this.processCallerMute(n,!0)}unmuteCaller(n){this.processCallerMute(n,!1)}terminateCall(n){const r=this.extendedCalls[n];r._status!==8&&r.terminate()}transferCall(n,r){if(r.toString().length===0)return new Error("Target must be passed");const o=this.extendedCalls[n];if(!o._is_confirmed&&!o._is_canceled){const a=`sip:${r}@${this.context.sipDomain}`;o.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${a}`]});return}this.updateCallStatus({callId:n,isTransferring:!0}),o.refer(`sip:${r}@${this.context.sipDomain}`),this.updateCall(o)}mergeCall(n){const r=Object.values(this.extendedCalls).filter(t=>t.roomId===n);if(r.length!==2)return;const o=r[0],a=r[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(n){this.isDNDEnabled=n,this.context.emit("changeIsDND",n)}startCallTimer(n){this.removeTimeInterval(n);const r={callId:n,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(r);const o=setInterval(()=>{const a={...this.callTime[n]},t=NT(a);this.setCallTime({callId:n,...t})},1e3);this.setTimeInterval(n,o)}async setActiveRoom(n){const r=this.currentActiveRoomId;n!==r&&(this.currentActiveRoomId=n,await this.roomReconfigure(r),await this.roomReconfigure(n))}getNewRoomId(){const n=Object.keys(this.activeRooms);return n.length===0?1:parseInt(n.sort()[n.length-1])+1}async setupCall(n){var d,g;const r=n.session;if(this.getActiveCalls[r.id]!==void 0)return;const a=this.getNewRoomId(),t={started:new Date,incomingInProgress:!1,roomId:a};r.direction==="incoming"?(this.context.logger.log("New incoming call from",(g=(d=r._remote_identity)==null?void 0:d._uri)==null?void 0:g._user),t.incomingInProgress=!0,this.context.subscribe(es.CALL_CONFIRMED,T=>{r.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(r.id))}),this.context.subscribe(es.CALL_FAILED,T=>{r.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.deleteRoomIfEmpty(a))})):r.direction==="outgoing"&&(r.once("confirmed",()=>{this.startCallTimer(r.id)}),this.startCallTimer(r.id));const s=r,p=this.hasAutoAnswerHeaders(n),_=s.direction==="incoming"&&!this.hasActiveCalls&&(p||this.autoAnswer);s.roomId=a,s.localMuted=!1,s.autoAnswer=_,_?this.addCall(s,!1):this.addCall(s),this.addCallStatus(r.id),this.addRoom(t),_&&this.answerCall(s._id)}removeCall(n){const r={...this.activeCalls};delete r[n],this.activeCalls={...r};const o={...this.extendedCalls};delete o[n],this.extendedCalls={...o},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(n){const r=this.extendedCalls[n._id];this.stopVUMeter("origin"),r.connection.getSenders().forEach(a=>{a.track.stop()});const o=r.roomId;this.removeCall(n._id),this.roomReconfigure(o)}async newRTCSessionCallback(n){const r=n.session;if(this.isDND){r.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(r.on("ended",o=>{var t,s;this.stopVUMeter(r.id),this.context.logger.log("Session ended for",(s=(t=r._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.context.triggerListener({listenerType:es.CALL_ENDED,session:r,event:o});const a=this.getActiveCalls[r.id];a&&this.activeCallListRemove(a),this.stopCallTimer(r.id),this.removeCallStatus(r.id),this.removeCallMetrics(r.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),this.initialStreamValue.getTracks().forEach(p=>p.stop()),this.initialStreamValue=null)}),r.on("progress",o=>{var a,t;this.context.logger.log("Session in progress for",(t=(a=r._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.context.triggerListener({listenerType:es.CALL_PROGRESS,session:r,event:o})}),r.on("failed",o=>{var t,s;this.stopVUMeter(r.id),this.context.logger.log("Session failed for",(s=(t=r._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.context.triggerListener({listenerType:es.CALL_FAILED,session:r,event:o}),r.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const a=this.getActiveCalls[r.id];a&&this.activeCallListRemove(a),this.stopCallTimer(r.id),this.removeCallStatus(r.id),this.removeCallMetrics(r.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),this.initialStreamValue.getTracks().forEach(p=>p.stop()),this.initialStreamValue=null)}),r.on("confirmed",o=>{var a,t;this.context.logger.log("Session confirmed for",(t=(a=r._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.context.triggerListener({listenerType:es.CALL_CONFIRMED,session:r,event:o}),this.updateCall(r),r.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(n),r.direction==="outgoing"){const o=this.getActiveCalls[r.id].roomId;this.setActiveRoom(o)}}setMuteWhenJoin(n){this.muteWhenJoinEnabled=n,this.context.emit("changeMuteWhenJoin",n)}setMicrophoneSensitivity(n){if(n<0||n>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=n,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(n){this.speakerVolumeValue=n,Object.values(this.extendedCalls).forEach(r=>{r.audioTag&&(r.audioTag.volume=n,this.updateCall(r))})}setAutoAnswer(n){this.isAutoAnswer=n}setSelectedInputDevice(n){localStorage.setItem(to.SELECTED_INPUT_DEVICE,n),this.selectedMediaDevices.input=n,this.context.emit("changeActiveInputMediaDevice",n)}setSelectedOutputDevice(n){localStorage.setItem(to.SELECTED_OUTPUT_DEVICE,n),this.selectedMediaDevices.output=n,this.context.emit("changeActiveOutputMediaDevice",n)}setCallMetrics(n){const r={...n};delete r.callId,this.callMetrics={...this.callMetrics,[n.callId]:r},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(n){const r={...this.callMetrics};delete r[n],this.callMetrics={...r},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(n){const r=new Av(this.metricConfig),o=r.createProbe(n.connection,{cid:n._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],_=Cv(p,Rv);_.callId=n._id,this.setCallMetrics(r)},this.context.subscribe(es.CALL_ENDED,s=>{s._id===n._id&&r.stopAllProbes()}),r.startAllProbes()}setupVUMeter(n,r){this.VUMeter.start(n,r)}stopVUMeter(n){this.VUMeter.stop(n)}async setupStream(){const n=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(r=>r.stop()),this.initialStreamValue=null),this.initialStreamValue=n}async triggerAddStream(n,r){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const o=Tf(this.initialStreamValue,this.microphoneInputLevel*2),a=this.isMuted||this.muteWhenJoin;o.getTracks().forEach(s=>s.enabled=!a),this.setActiveStream(o),await r.connection.getSenders()[0].replaceTrack(o.getTracks()[0]);const t=new MediaStream([n.track]);pT(t,r,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(t,r._id),this.getCallQuality(r),this.updateCall(r)}initCall(n,r){if(this.checkInitialized(),n.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${n}@${this.context.sipDomain}...`);const o=this.context.call(`sip:${n}@${this.context.sipDomain}`,this.sipOptions);this.callAddingInProgress=o.id,r&&this.currentActiveRoomId!==void 0&&this.processRoomChange({callId:o.id,roomId:this.currentActiveRoomId}),o.connection.addEventListener("track",a=>{this.triggerAddStream(a,o)})}async processRoomChange({callId:n,roomId:r}){const o=this.extendedCalls[n].roomId;this.extendedCalls[n].roomId=r;const a=this.extendedCalls[n];return this.updateCall(a),await this.setActiveRoom(r),Promise.all([this.roomReconfigure(o),this.roomReconfigure(r)]).then(()=>{this.deleteRoomIfEmpty(o),this.deleteRoomIfEmpty(r)})}}class Ov{constructor(n){this.context=n}get sipOptions(){return{...this.context.options.sipOptions}}initCall(n){if(n.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${n}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${n}@${this.context.sipDomain}`,this.sipOptions),console.log("video call")}}class Dv{constructor(n){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=n,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(n){const r=this.extendedMessages[n];this.updateMSRPSession(r)}updateMSRPSession(n){this.activeMessages[n._id]=gf(n),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(n){this.activeMessages={...this.activeMessages,[n._id]:gf(n)},this.extendedMessages[n._id]=n,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(n,r){const o=this.msrpHistory[r.id]||[];o.push(n),this.msrpHistory={...this.msrpHistory,[r.id]:[...o]},this.context.emit("newMSRPMessage",{message:n,session:r})}messageTerminate(n){const r=this.extendedMessages[n];r._status!==8&&r.terminate()}addMessageSession(n){if(!n._id||this.getActiveMessages[n._id]!==void 0)return;const o=n;this.addMMSRPSession(o)}triggerMSRPListener({listenerType:n,session:r,event:o}){const a=this.context.listenersList[n];!a||!a.length||a.forEach(t=>{t(r,o)})}removeMMSRPSession(n){const r={...this.activeMessages};delete r[n],this.activeMessages={...r};const o={...this.extendedMessages};delete o[n],this.extendedMessages={...o},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(n){this.removeMMSRPSession(n._id)}newMSRPSessionCallback(n){const r=n.session;r.on("ended",o=>{this.triggerMSRPListener({listenerType:es.CALL_ENDED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("failed",o=>{this.triggerMSRPListener({listenerType:es.CALL_FAILED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("confirmed",o=>{this.triggerMSRPListener({listenerType:es.CALL_CONFIRMED,session:r,event:o}),this.updateMSRPSession(r)}),r.on("newMessage",o=>{this.addMSRPMessage(o,r)}),this.addMessageSession(r)}setIsMSRPInitializing(n){this.isMSRPInitializingValue=n,this.context.emit("isMSRPInitializingChanged",n)}initMSRP(n,r,o){if(n.length===0)return console.error("Target must be a valid string");const a=this.context.startMSRP(n,o);a.on("active",()=>{this.addMessageSession(a),a.sendMSRP(r),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(n,r){const o=this.extendedMessages[n];if(!o)throw new Error(`MSRP session with id ${n} doesn't exist!`);o.sendMSRP(r)}}const Ya={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class Nv extends _T{constructor(n,r){if(!n.modules.length)throw new Error("options.modules should include at least 1 module");const o={...n.configuration,sockets:n.socketInterfaces.map(a=>new DT.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.isReconnecting=!1,this.audio=null,this.msrp=null,this.video=null,this.listenersList={},this.modules=[],this.options=n,this.modules=n.modules,r&&mT(r)&&(this.logger=r)}on(n,r){return super.on(n,r)}off(n,r){return super.off(n,r)}emit(n,r){return super.emit(n,r)}get sipDomain(){return this.options.sipDomain}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(Ya.AUDIO)&&(this.audio=new wv(this)),this.modules.includes(Ya.MSRP)&&(this.msrp=new Dv(this)),this.modules.includes(Ya.VIDEO)&&(this.video=new Ov(this)),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.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.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this}subscribe(n,r){const a=!this.listenersList[n]||!this.listenersList[n].length?[r]:[...this.listenersList[n],r];this.listenersList={...this.listenersList,[n]:a}}removeIListener(n){const r={...this.listenersList};delete r[n],this.listenersList={...r}}triggerListener({listenerType:n,session:r,event:o}){const a=this.listenersList[n];!a||!a.length||a.forEach(t=>{t(r,o)})}setInitialized(n){this.initialized=n,this.emit("ready",n)}}module.exports=Nv;
|