@voicenter-team/opensips-js 1.0.87 → 1.0.89
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/opensips-js.cjs.js +52 -52
- package/dist/opensips-js.es.js +1696 -1662
- package/dist/opensips-js.iife.js +52 -52
- package/dist/opensips-js.umd.js +52 -52
- package/package.json +1 -1
- package/src/types/listeners.d.ts +2 -0
package/dist/opensips-js.iife.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
var OpensipsJS=function(){"use strict";var xv=Object.defineProperty;var Mv=(Gs,ke,Rn)=>ke in Gs?xv(Gs,ke,{enumerable:!0,configurable:!0,writable:!0,value:Rn}):Gs[ke]=Rn;var Jt=(Gs,ke,Rn)=>(Mv(Gs,typeof ke!="symbol"?ke+"":ke,Rn),Rn);var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ke(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const dl={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.10.0",homepage:"https://jssip.net",contributors:["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],types:"lib/JsSIP.d.ts",main:"lib-es5/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},devDependencies:{"@babel/core":"^7.19.6","@babel/preset-env":"^7.19.4","ansi-colors":"^3.2.4",browserify:"^16.5.1",eslint:"^5.16.0","fancy-log":"^1.3.3",gulp:"^4.0.2","gulp-babel":"^8.0.0","gulp-eslint":"^5.0.0","gulp-expect-file":"^1.0.2","gulp-header":"^2.0.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.1","gulp-rename":"^1.4.0","gulp-uglify-es":"^1.0.4",pegjs:"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},scripts:{lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"}};var Fu=dl,tt={USER_AGENT:"".concat(Fu.title," ").concat(Fu.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 pl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?pl=function(r){return typeof r}:pl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},pl(c)}function ml(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function gl(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&vr(c,s)}function Tl(c){var s=ju();return function(){var o=Er(c),a;if(s){var t=Er(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return U_(this,a)}}function U_(c,s){return s&&(pl(s)==="object"||typeof s=="function")?s: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 In(c){var s=typeof Map=="function"?new Map:void 0;return In=function(o){if(o===null||!x_(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof s<"u"){if(s.has(o))return s.get(o);s.set(o,a)}function a(){return vl(o,arguments,Er(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),vr(a,o)},In(c)}function vl(c,s,r){return ju()?vl=Reflect.construct:vl=function(a,t,n){var p=[null];p.push.apply(p,t);var _=Function.bind.apply(a,p),d=new _;return n&&vr(d,n.prototype),d},vl.apply(null,arguments)}function ju(){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 x_(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function vr(c,s){return vr=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},vr(c,s)}function Er(c){return Er=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Er(c)}var M_=function(c){gl(r,c);var s=Tl(r);function r(o,a){var t;return ml(this,r),t=s.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}(In(Error)),k_=function(c){gl(r,c);var s=Tl(r);function r(o){var a;return ml(this,r),a=s.call(this),a.code=2,a.name="INVALID_STATE_ERROR",a.status=o,a.message="Invalid status: ".concat(o),a}return r}(In(Error)),L_=function(c){gl(r,c);var s=Tl(r);function r(o){var a;return ml(this,r),a=s.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return r}(In(Error)),$_=function(c){gl(r,c);var s=Tl(r);function r(o){var a;return ml(this,r),a=s.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return r}(In(Error)),Ss={ConfigurationError:M_,InvalidStateError:k_,NotSupportedError:L_,NotReadyError:$_},Qe={},Bo,Vu;function Go(){if(Vu)return Bo;Vu=1;function c(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function s(t,n){for(var p=0;p<n.length;p++){var _=n[p];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(t,_.key,_)}}function r(t,n,p){return n&&s(t.prototype,n),p&&s(t,p),t}var o=ys(),a=Xt();return Bo=function(){r(t,null,[{key:"parse",value:function(p){if(p=a.parse(p,"Name_Addr_Header"),p!==-1)return p}}]);function t(n,p,_){if(c(this,t),!n||!(n instanceof o))throw new TypeError('missing or invalid "uri" parameter');this._uri=n,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}(),Bo}var Wo,qu;function Xt(){return qu||(qu=1,Wo=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 s={parse:function(o,a){var t={CRLF:g,DIGIT:T,ALPHA:E,HEXDIG:y,WSP:A,OCTET:C,DQUOTE:I,SP:$,HTAB:L,alphanum:ae,reserved:N,unreserved:F,mark:Se,escaped:ve,LWS:M,SWS:D,HCOLON:B,TEXT_UTF8_TRIM:q,TEXT_UTF8char:z,UTF8_NONASCII:H,UTF8_CONT:Z,LHEX:U,token:P,token_nodot:se,separators:rt,word:ee,STAR:Y,SLASH:G,EQUAL:re,LPAREN:ge,RPAREN:be,RAQUOT:xe,LAQUOT:Re,COMMA:le,SEMI:ye,COLON:it,LDQUOT:ot,RDQUOT:Ee,comment:Ae,ctext:Ie,quoted_string:Oe,quoted_string_clean:pe,qdtext:he,quoted_pair:de,SIP_URI_noparams:we,SIP_URI:Ne,uri_scheme:et,uri_scheme_sips:He,uri_scheme_sip:Ft,userinfo:At,user:jn,user_unreserved:Vn,password:rn,hostport:ns,host:Ts,hostname:ln,domainlabel:qn,toplabel:Bn,IPv6reference:on,IPv6address:me,h16:oe,ls32:at,IPv4address:zt,dec_octet:Ps,port:ri,uri_parameters:Gn,uri_parameter:Wn,transport_param:ii,user_param:li,method_param:oi,ttl_param:ai,maddr_param:ui,lr_param:ci,other_param:fi,pname:_i,pvalue:xs,paramchar:Ms,param_unreserved:hi,headers:an,header:un,hname:di,hvalue:ks,hnv_unreserved:cn,Request_Response:yo,Request_Line:pi,Request_URI:Kn,absoluteURI:Yn,hier_part:mi,net_path:fn,abs_path:_n,opaque_part:Ls,uric:$s,uric_no_slash:gi,path_segments:hn,segment:Hs,param:vs,pchar:Fs,scheme:Ti,authority:vi,srvr:Ei,reg_name:Si,query:zn,SIP_Version:Jn,INVITEm:yi,ACKm:Ai,OPTIONSm:Ci,BYEm:Ri,CANCELm:Ii,REGISTERm:bi,SUBSCRIBEm:wi,NOTIFYm:Oi,REFERm:dn,Method:pn,Status_Line:Di,Status_Code:Ni,extension_code:Ui,Reason_Phrase:Ao,Allow_Events:Au,Call_ID:Cu,Contact:Xn,contact_param:jt,name_addr:Vt,display_name:js,contact_params:Qn,c_p_q:Pi,c_p_expires:rs,delta_seconds:is,qvalue:ze,generic_param:Je,gen_value:Co,Content_Disposition:Ro,disp_type:Zn,disp_param:er,handling_param:Io,Content_Encoding:Ru,Content_Length:Iu,Content_Type:bo,media_type:xi,m_type:Mi,discrete_type:ki,composite_type:mn,extension_token:gn,x_token:Li,m_subtype:tr,m_parameter:sr,m_value:wo,CSeq:Oo,CSeq_value:Do,Expires:bu,Event:Tn,event_type:vn,From:$i,from_param:En,tag_param:Hi,Max_Forwards:wu,Min_Expires:Ou,Name_Addr_Header:Du,Proxy_Authenticate:Fi,challenge:nr,other_challenge:Vs,auth_param:ls,digest_cln:Sn,realm:ji,realm_value:Vi,domain:yn,URI:An,nonce:qi,nonce_value:Bi,opaque:Gi,stale:Wi,algorithm:Ki,qop_options:Cn,qop_value:rr,Proxy_Require:Nu,Record_Route:ir,rec_route:lr,Reason:Yi,reason_param:or,reason_cause:No,Require:Uu,Route:ar,route_param:ur,Subscription_State:Uo,substate_value:cr,subexp_params:fr,event_reason_value:Po,Subject:Pu,Supported:xu,To:zi,to_param:Ji,Via:_r,via_param:qs,via_params:hr,via_ttl:Xi,via_maddr:Qi,via_received:Zi,via_branch:el,response_port:tl,rport:sl,sent_protocol:nl,protocol_name:rl,transport:il,sent_by:ll,via_host:ol,via_port:dr,ttl:al,WWW_Authenticate:Mu,Session_Expires:xo,s_e_expires:pr,s_e_params:mr,s_e_refresher:Mo,extension_header:ko,header_value:Lo,message_body:ku,uuid_URI:$o,uuid:qt,hex4:Bt,hex8:ul,hex12:Ho,Refer_To:Lu,Replaces:Fo,call_id:gr,replaces_param:Tr,to_tag:cl,from_tag:fl,early_flag:jo};if(a!==void 0){if(t[a]===void 0)throw new Error("Invalid rule name: "+c(a)+".")}else a="CRLF";var n=0,p=0,_=[];function d(e){n<p||(n>p&&(p=n,_=[]),_.push(e))}function g(){var e;return o.substr(n,2)===`\r
|
1
|
+
var OpensipsJS=function(){"use strict";var xv=Object.defineProperty;var Mv=(Gs,ke,Rn)=>ke in Gs?xv(Gs,ke,{enumerable:!0,configurable:!0,writable:!0,value:Rn}):Gs[ke]=Rn;var zt=(Gs,ke,Rn)=>(Mv(Gs,typeof ke!="symbol"?ke+"":ke,Rn),Rn);var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ke(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const dl={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.10.0",homepage:"https://jssip.net",contributors:["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],types:"lib/JsSIP.d.ts",main:"lib-es5/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},devDependencies:{"@babel/core":"^7.19.6","@babel/preset-env":"^7.19.4","ansi-colors":"^3.2.4",browserify:"^16.5.1",eslint:"^5.16.0","fancy-log":"^1.3.3",gulp:"^4.0.2","gulp-babel":"^8.0.0","gulp-eslint":"^5.0.0","gulp-expect-file":"^1.0.2","gulp-header":"^2.0.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.1","gulp-rename":"^1.4.0","gulp-uglify-es":"^1.0.4",pegjs:"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},scripts:{lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"}};var Fu=dl,tt={USER_AGENT:"".concat(Fu.title," ").concat(Fu.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 pl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?pl=function(r){return typeof r}:pl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},pl(c)}function ml(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function gl(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&vr(c,s)}function Tl(c){var s=ju();return function(){var o=Er(c),a;if(s){var t=Er(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return N_(this,a)}}function N_(c,s){return s&&(pl(s)==="object"||typeof s=="function")?s:U_(c)}function U_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function In(c){var s=typeof Map=="function"?new Map:void 0;return In=function(o){if(o===null||!P_(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof s<"u"){if(s.has(o))return s.get(o);s.set(o,a)}function a(){return vl(o,arguments,Er(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),vr(a,o)},In(c)}function vl(c,s,r){return ju()?vl=Reflect.construct:vl=function(a,t,n){var p=[null];p.push.apply(p,t);var _=Function.bind.apply(a,p),h=new _;return n&&vr(h,n.prototype),h},vl.apply(null,arguments)}function ju(){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 P_(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function vr(c,s){return vr=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},vr(c,s)}function Er(c){return Er=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Er(c)}var x_=function(c){gl(r,c);var s=Tl(r);function r(o,a){var t;return ml(this,r),t=s.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}(In(Error)),M_=function(c){gl(r,c);var s=Tl(r);function r(o){var a;return ml(this,r),a=s.call(this),a.code=2,a.name="INVALID_STATE_ERROR",a.status=o,a.message="Invalid status: ".concat(o),a}return r}(In(Error)),k_=function(c){gl(r,c);var s=Tl(r);function r(o){var a;return ml(this,r),a=s.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return r}(In(Error)),L_=function(c){gl(r,c);var s=Tl(r);function r(o){var a;return ml(this,r),a=s.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return r}(In(Error)),Ss={ConfigurationError:x_,InvalidStateError:M_,NotSupportedError:k_,NotReadyError:L_},Qe={},Bo,Vu;function Go(){if(Vu)return Bo;Vu=1;function c(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function s(t,n){for(var p=0;p<n.length;p++){var _=n[p];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(t,_.key,_)}}function r(t,n,p){return n&&s(t.prototype,n),p&&s(t,p),t}var o=ys(),a=Xt();return Bo=function(){r(t,null,[{key:"parse",value:function(p){if(p=a.parse(p,"Name_Addr_Header"),p!==-1)return p}}]);function t(n,p,_){if(c(this,t),!n||!(n instanceof o))throw new TypeError('missing or invalid "uri" parameter');this._uri=n,this._parameters={},this.display_name=p;for(var h in _)Object.prototype.hasOwnProperty.call(_,h)&&this.setParam(h,_[h])}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}(),Bo}var Wo,qu;function Xt(){return qu||(qu=1,Wo=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 s={parse:function(o,a){var t={CRLF:g,DIGIT:T,ALPHA:E,HEXDIG:y,WSP:A,OCTET:C,DQUOTE:I,SP:$,HTAB:L,alphanum:ae,reserved:N,unreserved:F,mark:Se,escaped:ve,LWS:M,SWS:D,HCOLON:B,TEXT_UTF8_TRIM:q,TEXT_UTF8char:J,UTF8_NONASCII:H,UTF8_CONT:Z,LHEX:U,token:P,token_nodot:se,separators:rt,word:ee,STAR:Y,SLASH:G,EQUAL:re,LPAREN:ge,RPAREN:be,RAQUOT:xe,LAQUOT:Re,COMMA:le,SEMI:ye,COLON:it,LDQUOT:ot,RDQUOT:Ee,comment:Ae,ctext:Ie,quoted_string:Oe,quoted_string_clean:pe,qdtext:he,quoted_pair:de,SIP_URI_noparams:we,SIP_URI:Ne,uri_scheme:et,uri_scheme_sips:He,uri_scheme_sip:Ft,userinfo:At,user:jn,user_unreserved:Vn,password:rn,hostport:ns,host:Ts,hostname:ln,domainlabel:qn,toplabel:Bn,IPv6reference:on,IPv6address:me,h16:oe,ls32:at,IPv4address:Jt,dec_octet:Ps,port:ri,uri_parameters:Gn,uri_parameter:Wn,transport_param:ii,user_param:li,method_param:oi,ttl_param:ai,maddr_param:ui,lr_param:ci,other_param:fi,pname:_i,pvalue:xs,paramchar:Ms,param_unreserved:hi,headers:an,header:un,hname:di,hvalue:ks,hnv_unreserved:cn,Request_Response:yo,Request_Line:pi,Request_URI:Kn,absoluteURI:Yn,hier_part:mi,net_path:fn,abs_path:_n,opaque_part:Ls,uric:$s,uric_no_slash:gi,path_segments:hn,segment:Hs,param:vs,pchar:Fs,scheme:Ti,authority:vi,srvr:Ei,reg_name:Si,query:Jn,SIP_Version:zn,INVITEm:yi,ACKm:Ai,OPTIONSm:Ci,BYEm:Ri,CANCELm:Ii,REGISTERm:bi,SUBSCRIBEm:wi,NOTIFYm:Oi,REFERm:dn,Method:pn,Status_Line:Di,Status_Code:Ni,extension_code:Ui,Reason_Phrase:Ao,Allow_Events:Au,Call_ID:Cu,Contact:Xn,contact_param:jt,name_addr:Vt,display_name:js,contact_params:Qn,c_p_q:Pi,c_p_expires:rs,delta_seconds:is,qvalue:Je,generic_param:ze,gen_value:Co,Content_Disposition:Ro,disp_type:Zn,disp_param:er,handling_param:Io,Content_Encoding:Ru,Content_Length:Iu,Content_Type:bo,media_type:xi,m_type:Mi,discrete_type:ki,composite_type:mn,extension_token:gn,x_token:Li,m_subtype:tr,m_parameter:sr,m_value:wo,CSeq:Oo,CSeq_value:Do,Expires:bu,Event:Tn,event_type:vn,From:$i,from_param:En,tag_param:Hi,Max_Forwards:wu,Min_Expires:Ou,Name_Addr_Header:Du,Proxy_Authenticate:Fi,challenge:nr,other_challenge:Vs,auth_param:ls,digest_cln:Sn,realm:ji,realm_value:Vi,domain:yn,URI:An,nonce:qi,nonce_value:Bi,opaque:Gi,stale:Wi,algorithm:Ki,qop_options:Cn,qop_value:rr,Proxy_Require:Nu,Record_Route:ir,rec_route:lr,Reason:Yi,reason_param:or,reason_cause:No,Require:Uu,Route:ar,route_param:ur,Subscription_State:Uo,substate_value:cr,subexp_params:fr,event_reason_value:Po,Subject:Pu,Supported:xu,To:Ji,to_param:zi,Via:_r,via_param:qs,via_params:hr,via_ttl:Xi,via_maddr:Qi,via_received:Zi,via_branch:el,response_port:tl,rport:sl,sent_protocol:nl,protocol_name:rl,transport:il,sent_by:ll,via_host:ol,via_port:dr,ttl:al,WWW_Authenticate:Mu,Session_Expires:xo,s_e_expires:pr,s_e_params:mr,s_e_refresher:Mo,extension_header:ko,header_value:Lo,message_body:ku,uuid_URI:$o,uuid:qt,hex4:Bt,hex8:ul,hex12:Ho,Refer_To:Lu,Replaces:Fo,call_id:gr,replaces_param:Tr,to_tag:cl,from_tag:fl,early_flag:jo};if(a!==void 0){if(t[a]===void 0)throw new Error("Invalid rule name: "+c(a)+".")}else a="CRLF";var n=0,p=0,_=[];function h(e){n<p||(n>p&&(p=n,_=[]),_.push(e))}function g(){var e;return o.substr(n,2)===`\r
|
2
2
|
`?(e=`\r
|
3
|
-
`,n+=2):(e=null,d('"\\r\\n"')),e}function T(){var e;return/^[0-9]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[0-9]")),e}function E(){var e;return/^[a-zA-Z]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[a-zA-Z]")),e}function y(){var e;return/^[0-9a-fA-F]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[0-9a-fA-F]")),e}function A(){var e;return e=$(),e===null&&(e=L()),e}function C(){var e;return/^[\0-\xFF]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[\\0-\\xFF]")),e}function I(){var e;return/^["]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d('["]')),e}function $(){var e;return o.charCodeAt(n)===32?(e=" ",n++):(e=null,d('" "')),e}function L(){var e;return o.charCodeAt(n)===9?(e=" ",n++):(e=null,d('"\\t"')),e}function ae(){var e;return/^[a-zA-Z0-9]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[a-zA-Z0-9]")),e}function N(){var e;return o.charCodeAt(n)===59?(e=";",n++):(e=null,d('";"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,d('"/"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,d('"?"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,d('":"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,d('"@"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,d('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,d('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,d('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,d('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,d('","'))))))))))),e}function F(){var e;return e=ae(),e===null&&(e=Se()),e}function Se(){var e;return o.charCodeAt(n)===45?(e="-",n++):(e=null,d('"-"')),e===null&&(o.charCodeAt(n)===95?(e="_",n++):(e=null,d('"_"')),e===null&&(o.charCodeAt(n)===46?(e=".",n++):(e=null,d('"."')),e===null&&(o.charCodeAt(n)===33?(e="!",n++):(e=null,d('"!"')),e===null&&(o.charCodeAt(n)===126?(e="~",n++):(e=null,d('"~"')),e===null&&(o.charCodeAt(n)===42?(e="*",n++):(e=null,d('"*"')),e===null&&(o.charCodeAt(n)===39?(e="'",n++):(e=null,d(`"'"`)),e===null&&(o.charCodeAt(n)===40?(e="(",n++):(e=null,d('"("')),e===null&&(o.charCodeAt(n)===41?(e=")",n++):(e=null,d('")"')))))))))),e}function ve(){var e,l,u,f,h;return f=n,h=n,o.charCodeAt(n)===37?(e="%",n++):(e=null,d('"%"')),e!==null?(l=y(),l!==null?(u=y(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){return v.join("")}(f,e)),e===null&&(n=f),e}function M(){var e,l,u,f,h,m;for(f=n,h=n,m=n,e=[],l=A();l!==null;)e.push(l),l=A();if(e!==null?(l=g(),l!==null?e=[e,l]:(e=null,n=m)):(e=null,n=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,n=h)}else e=null,n=h;return e!==null&&(e=function(v){return" "}()),e===null&&(n=f),e}function D(){var e;return e=M(),e=e!==null?e:"",e}function B(){var e,l,u,f,h;for(f=n,h=n,e=[],l=$(),l===null&&(l=L());l!==null;)e.push(l),l=$(),l===null&&(l=L());return e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return":"}()),e===null&&(n=f),e}function q(){var e,l,u,f,h,m,v;if(h=n,m=n,l=z(),l!==null)for(e=[];l!==null;)e.push(l),l=z();else e=null;if(e!==null){for(l=[],v=n,u=[],f=M();f!==null;)u.push(f),f=M();for(u!==null?(f=z(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;){for(l.push(u),v=n,u=[],f=M();f!==null;)u.push(f),f=M();u!==null?(f=z(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v)}l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=m;return e!==null&&(e=function(S){return o.substring(n,S)}(h)),e===null&&(n=h),e}function z(){var e;return/^[!-~]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[!-~]")),e===null&&(e=H()),e}function H(){var e;return/^[\x80-\uFFFF]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[\\x80-\\uFFFF]")),e}function Z(){var e;return/^[\x80-\xBF]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[\\x80-\\xBF]")),e}function U(){var e;return e=T(),e===null&&(/^[a-f]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[a-f]"))),e}function P(){var e,l,u;if(u=n,l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,d('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,d('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,d('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,d('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,d('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,d('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,d('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,d('"~"')))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,d('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,d('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,d('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,d('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,d('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,d('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,d('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,d('"~"'))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(n,f)}(u)),e===null&&(n=u),e}function se(){var e,l,u;if(u=n,l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,d('"-"')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,d('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,d('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,d('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,d('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,d('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,d('"~"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,d('"-"')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,d('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,d('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,d('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,d('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,d('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,d('"~"')))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(n,f)}(u)),e===null&&(n=u),e}function rt(){var e;return o.charCodeAt(n)===40?(e="(",n++):(e=null,d('"("')),e===null&&(o.charCodeAt(n)===41?(e=")",n++):(e=null,d('")"')),e===null&&(o.charCodeAt(n)===60?(e="<",n++):(e=null,d('"<"')),e===null&&(o.charCodeAt(n)===62?(e=">",n++):(e=null,d('">"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,d('"@"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,d('","')),e===null&&(o.charCodeAt(n)===59?(e=";",n++):(e=null,d('";"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,d('":"')),e===null&&(o.charCodeAt(n)===92?(e="\\",n++):(e=null,d('"\\\\"')),e===null&&(e=I(),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,d('"/"')),e===null&&(o.charCodeAt(n)===91?(e="[",n++):(e=null,d('"["')),e===null&&(o.charCodeAt(n)===93?(e="]",n++):(e=null,d('"]"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,d('"?"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,d('"="')),e===null&&(o.charCodeAt(n)===123?(e="{",n++):(e=null,d('"{"')),e===null&&(o.charCodeAt(n)===125?(e="}",n++):(e=null,d('"}"')),e===null&&(e=$(),e===null&&(e=L())))))))))))))))))),e}function ee(){var e,l,u;if(u=n,l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,d('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,d('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,d('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,d('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,d('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,d('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,d('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,d('"~"')),l===null&&(o.charCodeAt(n)===40?(l="(",n++):(l=null,d('"("')),l===null&&(o.charCodeAt(n)===41?(l=")",n++):(l=null,d('")"')),l===null&&(o.charCodeAt(n)===60?(l="<",n++):(l=null,d('"<"')),l===null&&(o.charCodeAt(n)===62?(l=">",n++):(l=null,d('">"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l===null&&(o.charCodeAt(n)===92?(l="\\",n++):(l=null,d('"\\\\"')),l===null&&(l=I(),l===null&&(o.charCodeAt(n)===47?(l="/",n++):(l=null,d('"/"')),l===null&&(o.charCodeAt(n)===91?(l="[",n++):(l=null,d('"["')),l===null&&(o.charCodeAt(n)===93?(l="]",n++):(l=null,d('"]"')),l===null&&(o.charCodeAt(n)===63?(l="?",n++):(l=null,d('"?"')),l===null&&(o.charCodeAt(n)===123?(l="{",n++):(l=null,d('"{"')),l===null&&(o.charCodeAt(n)===125?(l="}",n++):(l=null,d('"}"'))))))))))))))))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,d('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,d('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,d('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,d('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,d('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,d('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,d('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,d('"~"')),l===null&&(o.charCodeAt(n)===40?(l="(",n++):(l=null,d('"("')),l===null&&(o.charCodeAt(n)===41?(l=")",n++):(l=null,d('")"')),l===null&&(o.charCodeAt(n)===60?(l="<",n++):(l=null,d('"<"')),l===null&&(o.charCodeAt(n)===62?(l=">",n++):(l=null,d('">"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l===null&&(o.charCodeAt(n)===92?(l="\\",n++):(l=null,d('"\\\\"')),l===null&&(l=I(),l===null&&(o.charCodeAt(n)===47?(l="/",n++):(l=null,d('"/"')),l===null&&(o.charCodeAt(n)===91?(l="[",n++):(l=null,d('"["')),l===null&&(o.charCodeAt(n)===93?(l="]",n++):(l=null,d('"]"')),l===null&&(o.charCodeAt(n)===63?(l="?",n++):(l=null,d('"?"')),l===null&&(o.charCodeAt(n)===123?(l="{",n++):(l=null,d('"{"')),l===null&&(o.charCodeAt(n)===125?(l="}",n++):(l=null,d('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(n,f)}(u)),e===null&&(n=u),e}function Y(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===42?(l="*",n++):(l=null,d('"*"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return"*"}()),e===null&&(n=f),e}function G(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===47?(l="/",n++):(l=null,d('"/"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return"/"}()),e===null&&(n=f),e}function re(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return"="}()),e===null&&(n=f),e}function ge(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===40?(l="(",n++):(l=null,d('"("')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return"("}()),e===null&&(n=f),e}function be(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===41?(l=")",n++):(l=null,d('")"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return")"}()),e===null&&(n=f),e}function xe(){var e,l,u,f;return u=n,f=n,o.charCodeAt(n)===62?(e=">",n++):(e=null,d('">"')),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h){return">"}()),e===null&&(n=u),e}function Re(){var e,l,u,f;return u=n,f=n,e=D(),e!==null?(o.charCodeAt(n)===60?(l="<",n++):(l=null,d('"<"')),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h){return"<"}()),e===null&&(n=u),e}function le(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===44?(l=",",n++):(l=null,d('","')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return","}()),e===null&&(n=f),e}function ye(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===59?(l=";",n++):(l=null,d('";"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return";"}()),e===null&&(n=f),e}function it(){var e,l,u,f,h;return f=n,h=n,e=D(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return":"}()),e===null&&(n=f),e}function ot(){var e,l,u,f;return u=n,f=n,e=D(),e!==null?(l=I(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h){return'"'}()),e===null&&(n=u),e}function Ee(){var e,l,u,f;return u=n,f=n,e=I(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h){return'"'}()),e===null&&(n=u),e}function Ae(){var e,l,u,f;if(f=n,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,n=f)):(e=null,n=f)}else e=null,n=f;return e}function Ie(){var e;return/^[!-']/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[!-']")),e===null&&(/^[*-[]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[*-[]")),e===null&&(/^[\]-~]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[\\]-~]")),e===null&&(e=H(),e===null&&(e=M())))),e}function Oe(){var e,l,u,f,h,m;if(h=n,m=n,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=he(),f===null&&(f=de());f!==null;)u.push(f),f=he(),f===null&&(f=de());u!==null?(f=I(),f!==null?e=[e,l,u,f]:(e=null,n=m)):(e=null,n=m)}else e=null,n=m;else e=null,n=m;return e!==null&&(e=function(v){return o.substring(n,v)}(h)),e===null&&(n=h),e}function pe(){var e,l,u,f,h,m;if(h=n,m=n,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=he(),f===null&&(f=de());f!==null;)u.push(f),f=he(),f===null&&(f=de());u!==null?(f=I(),f!==null?e=[e,l,u,f]:(e=null,n=m)):(e=null,n=m)}else e=null,n=m;else e=null,n=m;return e!==null&&(e=function(v){var S=o.substring(n,v).trim();return S.substring(1,S.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(h)),e===null&&(n=h),e}function he(){var e;return e=M(),e===null&&(o.charCodeAt(n)===33?(e="!",n++):(e=null,d('"!"')),e===null&&(/^[#-[]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[#-[]")),e===null&&(/^[\]-~]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[\\]-~]")),e===null&&(e=H())))),e}function de(){var e,l,u;return u=n,o.charCodeAt(n)===92?(e="\\",n++):(e=null,d('"\\\\"')),e!==null?(/^[\0-\t]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,d("[\\0-\\t]")),l===null&&(/^[\x0B-\f]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,d("[\\x0B-\\f]")),l===null&&(/^[\x0E-]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,d("[\\x0E-]")))),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function we(){var e,l,u,f,h,m;return h=n,m=n,e=et(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=ns(),f!==null?e=[e,l,u,f]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e!==null&&(e=function(v){try{w.uri=new Es(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&&(n=h),e}function Ne(){var e,l,u,f,h,m,v,S;return v=n,S=n,e=et(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=ns(),f!==null?(h=Gn(),h!==null?(m=an(),m=m!==null?m:"",m!==null?e=[e,l,u,f,h,m]:(e=null,n=S)):(e=null,n=S)):(e=null,n=S)):(e=null,n=S)):(e=null,n=S)):(e=null,n=S),e!==null&&(e=function(O){try{w.uri=new Es(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&&(n=v),e}function et(){var e;return e=He(),e===null&&(e=Ft()),e}function He(){var e,l;return l=n,o.substr(n,4).toLowerCase()==="sips"?(e=o.substr(n,4),n+=4):(e=null,d('"sips"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(n=l),e}function Ft(){var e,l;return l=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,d('"sip"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(n=l),e}function At(){var e,l,u,f,h,m;return f=n,h=n,e=jn(),e!==null?(m=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=rn(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?(o.charCodeAt(n)===64?(u="@",n++):(u=null,d('"@"')),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(v){w.user=decodeURIComponent(o.substring(n-1,v))}(f)),e===null&&(n=f),e}function jn(){var e,l;if(l=F(),l===null&&(l=ve(),l===null&&(l=Vn())),l!==null)for(e=[];l!==null;)e.push(l),l=F(),l===null&&(l=ve(),l===null&&(l=Vn()));else e=null;return e}function Vn(){var e;return o.charCodeAt(n)===38?(e="&",n++):(e=null,d('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,d('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,d('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,d('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,d('","')),e===null&&(o.charCodeAt(n)===59?(e=";",n++):(e=null,d('";"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,d('"?"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,d('"/"'))))))))),e}function rn(){var e,l,u;for(u=n,e=[],l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,d('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,d('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,d('","'))))))));l!==null;)e.push(l),l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,d('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,d('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,d('","'))))))));return e!==null&&(e=function(f){w.password=o.substring(n,f)}(u)),e===null&&(n=u),e}function ns(){var e,l,u,f,h;return f=n,e=Ts(),e!==null?(h=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=ri(),u!==null?l=[l,u]:(l=null,n=h)):(l=null,n=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function Ts(){var e,l;return l=n,e=ln(),e===null&&(e=zt(),e===null&&(e=on())),e!==null&&(e=function(u){return w.host=o.substring(n,u).toLowerCase(),w.host}(l)),e===null&&(n=l),e}function ln(){var e,l,u,f,h,m;for(f=n,h=n,e=[],m=n,l=qn(),l!==null?(o.charCodeAt(n)===46?(u=".",n++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m);l!==null;)e.push(l),m=n,l=qn(),l!==null?(o.charCodeAt(n)===46?(u=".",n++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m);return e!==null?(l=Bn(),l!==null?(o.charCodeAt(n)===46?(u=".",n++):(u=null,d('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(v){return w.host_type="domain",o.substring(n,v)}(f)),e===null&&(n=f),e}function qn(){var e,l,u,f;if(f=n,e=ae(),e!==null){for(l=[],u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,d('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,d('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,n=f)}else e=null,n=f;return e}function Bn(){var e,l,u,f;if(f=n,e=E(),e!==null){for(l=[],u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,d('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,d('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,n=f)}else e=null,n=f;return e}function on(){var e,l,u,f,h;return f=n,h=n,o.charCodeAt(n)===91?(e="[",n++):(e=null,d('"["')),e!==null?(l=me(),l!==null?(o.charCodeAt(n)===93?(u="]",n++):(u=null,d('"]"')),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m){return w.host_type="IPv6",o.substring(n,m)}(f)),e===null&&(n=f),e}function me(){var e,l,u,f,h,m,v,S,O,ie,Ue,Ot,Bs,k,R,Te;return k=n,R=n,e=oe(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?(o.charCodeAt(n)===58?(f=":",n++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?(o.charCodeAt(n)===58?(m=":",n++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(n)===58?(S=":",n++):(S=null,d('":"')),S!==null?(O=oe(),O!==null?(o.charCodeAt(n)===58?(ie=":",n++):(ie=null,d('":"')),ie!==null?(Ue=oe(),Ue!==null?(o.charCodeAt(n)===58?(Ot=":",n++):(Ot=null,d('":"')),Ot!==null?(Bs=at(),Bs!==null?e=[e,l,u,f,h,m,v,S,O,ie,Ue,Ot,Bs]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(n)===58?(O=":",n++):(O=null,d('":"')),O!==null?(ie=oe(),ie!==null?(o.charCodeAt(n)===58?(Ue=":",n++):(Ue=null,d('":"')),Ue!==null?(Ot=at(),Ot!==null?e=[e,l,u,f,h,m,v,S,O,ie,Ue,Ot]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(n)===58?(O=":",n++):(O=null,d('":"')),O!==null?(ie=at(),ie!==null?e=[e,l,u,f,h,m,v,S,O,ie]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,d('":"')),v!==null?(S=at(),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=at(),m!==null?e=[e,l,u,f,h,m]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=at(),f!==null?e=[e,l,u,f]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,d('"::"')),e!==null?(l=at(),l!==null?e=[e,l]:(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,d('"::"')),e!==null?(l=oe(),l!==null?e=[e,l]:(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(o.substr(n,2)==="::"?(l="::",n+=2):(l=null,d('"::"')),l!==null?(u=oe(),u!==null?(o.charCodeAt(n)===58?(f=":",n++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?(o.charCodeAt(n)===58?(m=":",n++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(n)===58?(S=":",n++):(S=null,d('":"')),S!==null?(O=oe(),O!==null?(o.charCodeAt(n)===58?(ie=":",n++):(ie=null,d('":"')),ie!==null?(Ue=at(),Ue!==null?e=[e,l,u,f,h,m,v,S,O,ie,Ue]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(o.substr(n,2)==="::"?(u="::",n+=2):(u=null,d('"::"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(n)===58?(O=":",n++):(O=null,d('":"')),O!==null?(ie=at(),ie!==null?e=[e,l,u,f,h,m,v,S,O,ie]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(o.substr(n,2)==="::"?(f="::",n+=2):(f=null,d('"::"')),f!==null?(h=oe(),h!==null?(o.charCodeAt(n)===58?(m=":",n++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(n)===58?(S=":",n++):(S=null,d('":"')),S!==null?(O=at(),O!==null?e=[e,l,u,f,h,m,v,S,O]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(o.substr(n,2)==="::"?(h="::",n+=2):(h=null,d('"::"')),h!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,d('":"')),v!==null?(S=at(),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?h=[h,m]:(h=null,n=Te)):(h=null,n=Te),h=h!==null?h:"",h!==null?(o.substr(n,2)==="::"?(m="::",n+=2):(m=null,d('"::"')),m!==null?(v=at(),v!==null?e=[e,l,u,f,h,m,v]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?h=[h,m]:(h=null,n=Te)):(h=null,n=Te),h=h!==null?h:"",h!==null?(Te=n,o.charCodeAt(n)===58?(m=":",n++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,n=Te)):(m=null,n=Te),m=m!==null?m:"",m!==null?(o.substr(n,2)==="::"?(v="::",n+=2):(v=null,d('"::"')),v!==null?(S=oe(),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,d('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,d('":"')),f!==null?(h=oe(),h!==null?f=[f,h]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(h=":",n++):(h=null,d('":"')),h!==null?(m=oe(),m!==null?h=[h,m]:(h=null,n=Te)):(h=null,n=Te),h=h!==null?h:"",h!==null?(Te=n,o.charCodeAt(n)===58?(m=":",n++):(m=null,d('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,n=Te)):(m=null,n=Te),m=m!==null?m:"",m!==null?(Te=n,o.charCodeAt(n)===58?(v=":",n++):(v=null,d('":"')),v!==null?(S=oe(),S!==null?v=[v,S]:(v=null,n=Te)):(v=null,n=Te),v=v!==null?v:"",v!==null?(o.substr(n,2)==="::"?(S="::",n+=2):(S=null,d('"::"')),S!==null?e=[e,l,u,f,h,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R))))))))))))))),e!==null&&(e=function(Pv){return w.host_type="IPv6",o.substring(n,Pv)}(k)),e===null&&(n=k),e}function oe(){var e,l,u,f,h;return h=n,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,n=h)):(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e}function at(){var e,l,u,f;return f=n,e=oe(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=oe(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e===null&&(e=zt()),e}function zt(){var e,l,u,f,h,m,v,S,O;return S=n,O=n,e=Ps(),e!==null?(o.charCodeAt(n)===46?(l=".",n++):(l=null,d('"."')),l!==null?(u=Ps(),u!==null?(o.charCodeAt(n)===46?(f=".",n++):(f=null,d('"."')),f!==null?(h=Ps(),h!==null?(o.charCodeAt(n)===46?(m=".",n++):(m=null,d('"."')),m!==null?(v=Ps(),v!==null?e=[e,l,u,f,h,m,v]:(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O),e!==null&&(e=function(ie){return w.host_type="IPv4",o.substring(n,ie)}(S)),e===null&&(n=S),e}function Ps(){var e,l,u,f;return f=n,o.substr(n,2)==="25"?(e="25",n+=2):(e=null,d('"25"')),e!==null?(/^[0-5]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,d("[0-5]")),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e===null&&(f=n,o.charCodeAt(n)===50?(e="2",n++):(e=null,d('"2"')),e!==null?(/^[0-4]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,d("[0-4]")),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e===null&&(f=n,o.charCodeAt(n)===49?(e="1",n++):(e=null,d('"1"')),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e===null&&(f=n,/^[1-9]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,d("[1-9]")),e!==null?(l=T(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e===null&&(e=T())))),e}function ri(){var e,l,u,f,h,m,v;return m=n,v=n,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,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(S,O){return O=parseInt(O.join("")),w.port=O,O}(m,e)),e===null&&(n=m),e}function Gn(){var e,l,u,f;for(e=[],f=n,o.charCodeAt(n)===59?(l=";",n++):(l=null,d('";"')),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,n=f)):(l=null,n=f);l!==null;)e.push(l),f=n,o.charCodeAt(n)===59?(l=";",n++):(l=null,d('";"')),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,n=f)):(l=null,n=f);return e}function Wn(){var e;return e=ii(),e===null&&(e=li(),e===null&&(e=oi(),e===null&&(e=ai(),e===null&&(e=ui(),e===null&&(e=ci(),e===null&&(e=fi())))))),e}function ii(){var e,l,u,f;return u=n,f=n,o.substr(n,10).toLowerCase()==="transport="?(e=o.substr(n,10),n+=10):(e=null,d('"transport="')),e!==null?(o.substr(n,3).toLowerCase()==="udp"?(l=o.substr(n,3),n+=3):(l=null,d('"udp"')),l===null&&(o.substr(n,3).toLowerCase()==="tcp"?(l=o.substr(n,3),n+=3):(l=null,d('"tcp"')),l===null&&(o.substr(n,4).toLowerCase()==="sctp"?(l=o.substr(n,4),n+=4):(l=null,d('"sctp"')),l===null&&(o.substr(n,3).toLowerCase()==="tls"?(l=o.substr(n,3),n+=3):(l=null,d('"tls"')),l===null&&(l=P())))),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h,m){w.uri_params||(w.uri_params={}),w.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(n=u),e}function li(){var e,l,u,f;return u=n,f=n,o.substr(n,5).toLowerCase()==="user="?(e=o.substr(n,5),n+=5):(e=null,d('"user="')),e!==null?(o.substr(n,5).toLowerCase()==="phone"?(l=o.substr(n,5),n+=5):(l=null,d('"phone"')),l===null&&(o.substr(n,2).toLowerCase()==="ip"?(l=o.substr(n,2),n+=2):(l=null,d('"ip"')),l===null&&(l=P())),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h,m){w.uri_params||(w.uri_params={}),w.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(n=u),e}function oi(){var e,l,u,f;return u=n,f=n,o.substr(n,7).toLowerCase()==="method="?(e=o.substr(n,7),n+=7):(e=null,d('"method="')),e!==null?(l=pn(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h,m){w.uri_params||(w.uri_params={}),w.uri_params.method=m}(u,e[1])),e===null&&(n=u),e}function ai(){var e,l,u,f;return u=n,f=n,o.substr(n,4).toLowerCase()==="ttl="?(e=o.substr(n,4),n+=4):(e=null,d('"ttl="')),e!==null?(l=al(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h,m){w.params||(w.params={}),w.params.ttl=m}(u,e[1])),e===null&&(n=u),e}function ui(){var e,l,u,f;return u=n,f=n,o.substr(n,6).toLowerCase()==="maddr="?(e=o.substr(n,6),n+=6):(e=null,d('"maddr="')),e!==null?(l=Ts(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(h,m){w.uri_params||(w.uri_params={}),w.uri_params.maddr=m}(u,e[1])),e===null&&(n=u),e}function ci(){var e,l,u,f,h,m;return f=n,h=n,o.substr(n,2).toLowerCase()==="lr"?(e=o.substr(n,2),n+=2):(e=null,d('"lr"')),e!==null?(m=n,o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(v){w.uri_params||(w.uri_params={}),w.uri_params.lr=void 0}()),e===null&&(n=f),e}function fi(){var e,l,u,f,h,m;return f=n,h=n,e=_i(),e!==null?(m=n,o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l!==null?(u=xs(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=h)):(e=null,n=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&&(n=f),e}function _i(){var e,l,u;if(u=n,l=Ms(),l!==null)for(e=[];l!==null;)e.push(l),l=Ms();else e=null;return e!==null&&(e=function(f,h){return h.join("")}(u,e)),e===null&&(n=u),e}function xs(){var e,l,u;if(u=n,l=Ms(),l!==null)for(e=[];l!==null;)e.push(l),l=Ms();else e=null;return e!==null&&(e=function(f,h){return h.join("")}(u,e)),e===null&&(n=u),e}function Ms(){var e;return e=hi(),e===null&&(e=F(),e===null&&(e=ve())),e}function hi(){var e;return o.charCodeAt(n)===91?(e="[",n++):(e=null,d('"["')),e===null&&(o.charCodeAt(n)===93?(e="]",n++):(e=null,d('"]"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,d('"/"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,d('":"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,d('"&"')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,d('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,d('"$"')))))))),e}function an(){var e,l,u,f,h,m,v;if(m=n,o.charCodeAt(n)===63?(e="?",n++):(e=null,d('"?"')),e!==null)if(l=un(),l!==null){for(u=[],v=n,o.charCodeAt(n)===38?(f="&",n++):(f=null,d('"&"')),f!==null?(h=un(),h!==null?f=[f,h]:(f=null,n=v)):(f=null,n=v);f!==null;)u.push(f),v=n,o.charCodeAt(n)===38?(f="&",n++):(f=null,d('"&"')),f!==null?(h=un(),h!==null?f=[f,h]:(f=null,n=v)):(f=null,n=v);u!==null?e=[e,l,u]:(e=null,n=m)}else e=null,n=m;else e=null,n=m;return e}function un(){var e,l,u,f,h;return f=n,h=n,e=di(),e!==null?(o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l!==null?(u=ks(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=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&&(n=f),e}function di(){var e,l;if(l=cn(),l===null&&(l=F(),l===null&&(l=ve())),l!==null)for(e=[];l!==null;)e.push(l),l=cn(),l===null&&(l=F(),l===null&&(l=ve()));else e=null;return e}function ks(){var e,l;for(e=[],l=cn(),l===null&&(l=F(),l===null&&(l=ve()));l!==null;)e.push(l),l=cn(),l===null&&(l=F(),l===null&&(l=ve()));return e}function cn(){var e;return o.charCodeAt(n)===91?(e="[",n++):(e=null,d('"["')),e===null&&(o.charCodeAt(n)===93?(e="]",n++):(e=null,d('"]"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,d('"/"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,d('"?"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,d('":"')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,d('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,d('"$"')))))))),e}function yo(){var e;return e=Di(),e===null&&(e=pi()),e}function pi(){var e,l,u,f,h,m;return m=n,e=pn(),e!==null?(l=$(),l!==null?(u=Kn(),u!==null?(f=$(),f!==null?(h=Jn(),h!==null?e=[e,l,u,f,h]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function Kn(){var e;return e=Ne(),e===null&&(e=Yn()),e}function Yn(){var e,l,u,f;return f=n,e=Ti(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l!==null?(u=mi(),u===null&&(u=Ls()),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function mi(){var e,l,u,f,h;return f=n,e=fn(),e===null&&(e=_n()),e!==null?(h=n,o.charCodeAt(n)===63?(l="?",n++):(l=null,d('"?"')),l!==null?(u=zn(),u!==null?l=[l,u]:(l=null,n=h)):(l=null,n=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function fn(){var e,l,u,f;return f=n,o.substr(n,2)==="//"?(e="//",n+=2):(e=null,d('"//"')),e!==null?(l=vi(),l!==null?(u=_n(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function _n(){var e,l,u;return u=n,o.charCodeAt(n)===47?(e="/",n++):(e=null,d('"/"')),e!==null?(l=hn(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function Ls(){var e,l,u,f;if(f=n,e=gi(),e!==null){for(l=[],u=$s();u!==null;)l.push(u),u=$s();l!==null?e=[e,l]:(e=null,n=f)}else e=null,n=f;return e}function $s(){var e;return e=N(),e===null&&(e=F(),e===null&&(e=ve())),e}function gi(){var e;return e=F(),e===null&&(e=ve(),e===null&&(o.charCodeAt(n)===59?(e=";",n++):(e=null,d('";"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,d('"?"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,d('":"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,d('"@"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,d('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,d('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,d('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,d('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,d('","')))))))))))),e}function hn(){var e,l,u,f,h,m;if(h=n,e=Hs(),e!==null){for(l=[],m=n,o.charCodeAt(n)===47?(u="/",n++):(u=null,d('"/"')),u!==null?(f=Hs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,o.charCodeAt(n)===47?(u="/",n++):(u=null,d('"/"')),u!==null?(f=Hs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function Hs(){var e,l,u,f,h,m;for(h=n,e=[],l=Fs();l!==null;)e.push(l),l=Fs();if(e!==null){for(l=[],m=n,o.charCodeAt(n)===59?(u=";",n++):(u=null,d('";"')),u!==null?(f=vs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,o.charCodeAt(n)===59?(u=";",n++):(u=null,d('";"')),u!==null?(f=vs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function vs(){var e,l;for(e=[],l=Fs();l!==null;)e.push(l),l=Fs();return e}function Fs(){var e;return e=F(),e===null&&(e=ve(),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,d('":"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,d('"@"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,d('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,d('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,d('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,d('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,d('","')))))))))),e}function Ti(){var e,l,u,f,h;if(f=n,h=n,e=E(),e!==null){for(l=[],u=E(),u===null&&(u=T(),u===null&&(o.charCodeAt(n)===43?(u="+",n++):(u=null,d('"+"')),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,d('"-"')),u===null&&(o.charCodeAt(n)===46?(u=".",n++):(u=null,d('"."'))))));u!==null;)l.push(u),u=E(),u===null&&(u=T(),u===null&&(o.charCodeAt(n)===43?(u="+",n++):(u=null,d('"+"')),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,d('"-"')),u===null&&(o.charCodeAt(n)===46?(u=".",n++):(u=null,d('"."'))))));l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e!==null&&(e=function(m){w.scheme=o.substring(n,m)}(f)),e===null&&(n=f),e}function vi(){var e;return e=Ei(),e===null&&(e=Si()),e}function Ei(){var e,l,u,f;return u=n,f=n,e=At(),e!==null?(o.charCodeAt(n)===64?(l="@",n++):(l=null,d('"@"')),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e=e!==null?e:"",e!==null?(l=ns(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e=e!==null?e:"",e}function Si(){var e,l;if(l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,d('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,d('","')),l===null&&(o.charCodeAt(n)===59?(l=";",n++):(l=null,d('";"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l===null&&(o.charCodeAt(n)===64?(l="@",n++):(l=null,d('"@"')),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,d('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,d('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,d('","')),l===null&&(o.charCodeAt(n)===59?(l=";",n++):(l=null,d('";"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,d('":"')),l===null&&(o.charCodeAt(n)===64?(l="@",n++):(l=null,d('"@"')),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,d('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,d('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,d('"+"')))))))))));else e=null;return e}function zn(){var e,l;for(e=[],l=$s();l!==null;)e.push(l),l=$s();return e}function Jn(){var e,l,u,f,h,m,v,S;if(v=n,S=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,d('"SIP"')),e!==null)if(o.charCodeAt(n)===47?(l="/",n++):(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(n)===46?(f=".",n++):(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,n=S)}else e=null,n=S;else e=null,n=S}else e=null,n=S;else e=null,n=S;return e!==null&&(e=function(O){w.sip_version=o.substring(n,O)}(v)),e===null&&(n=v),e}function yi(){var e;return o.substr(n,6)==="INVITE"?(e="INVITE",n+=6):(e=null,d('"INVITE"')),e}function Ai(){var e;return o.substr(n,3)==="ACK"?(e="ACK",n+=3):(e=null,d('"ACK"')),e}function Ci(){var e;return o.substr(n,7)==="OPTIONS"?(e="OPTIONS",n+=7):(e=null,d('"OPTIONS"')),e}function Ri(){var e;return o.substr(n,3)==="BYE"?(e="BYE",n+=3):(e=null,d('"BYE"')),e}function Ii(){var e;return o.substr(n,6)==="CANCEL"?(e="CANCEL",n+=6):(e=null,d('"CANCEL"')),e}function bi(){var e;return o.substr(n,8)==="REGISTER"?(e="REGISTER",n+=8):(e=null,d('"REGISTER"')),e}function wi(){var e;return o.substr(n,9)==="SUBSCRIBE"?(e="SUBSCRIBE",n+=9):(e=null,d('"SUBSCRIBE"')),e}function Oi(){var e;return o.substr(n,6)==="NOTIFY"?(e="NOTIFY",n+=6):(e=null,d('"NOTIFY"')),e}function dn(){var e;return o.substr(n,5)==="REFER"?(e="REFER",n+=5):(e=null,d('"REFER"')),e}function pn(){var e,l;return l=n,e=yi(),e===null&&(e=Ai(),e===null&&(e=Ci(),e===null&&(e=Ri(),e===null&&(e=Ii(),e===null&&(e=bi(),e===null&&(e=wi(),e===null&&(e=Oi(),e===null&&(e=dn(),e===null&&(e=P()))))))))),e!==null&&(e=function(u){return w.method=o.substring(n,u),w.method}(l)),e===null&&(n=l),e}function Di(){var e,l,u,f,h,m;return m=n,e=Jn(),e!==null?(l=$(),l!==null?(u=Ni(),u!==null?(f=$(),f!==null?(h=Ao(),h!==null?e=[e,l,u,f,h]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function Ni(){var e,l;return l=n,e=Ui(),e!==null&&(e=function(u,f){w.status_code=parseInt(f.join(""))}(l,e)),e===null&&(n=l),e}function Ui(){var e,l,u,f;return f=n,e=T(),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Ao(){var e,l,u;for(u=n,e=[],l=N(),l===null&&(l=F(),l===null&&(l=ve(),l===null&&(l=H(),l===null&&(l=Z(),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=Z(),l===null&&(l=$(),l===null&&(l=L()))))));return e!==null&&(e=function(f){w.reason_phrase=o.substring(n,f)}(u)),e===null&&(n=u),e}function Au(){var e,l,u,f,h,m;if(h=n,e=vn(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=vn(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=vn(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function Cu(){var e,l,u,f,h,m;return f=n,h=n,e=ee(),e!==null?(m=n,o.charCodeAt(n)===64?(l="@",n++):(l=null,d('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(v){w=o.substring(n,v)}(f)),e===null&&(n=f),e}function Xn(){var e,l,u,f,h,m,v;if(h=n,e=Y(),e===null)if(m=n,e=jt(),e!==null){for(l=[],v=n,u=le(),u!==null?(f=jt(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=le(),u!==null?(f=jt(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=h),e}function jt(){var e,l,u,f,h,m,v;if(h=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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:n,offset:S,parsed:O})}(h)),e===null&&(n=h),e}function Vt(){var e,l,u,f,h;return h=n,e=js(),e=e!==null?e:"",e!==null?(l=Re(),l!==null?(u=Ne(),u!==null?(f=xe(),f!==null?e=[e,l,u,f]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e}function js(){var e,l,u,f,h,m,v;if(h=n,m=n,e=P(),e!==null){for(l=[],v=n,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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,Ue){return ie+Ue[0]+Ue[1]},O[0])}(h,e)),e===null&&(n=h),e}function Qn(){var e;return e=Pi(),e===null&&(e=rs(),e===null&&(e=Je())),e}function Pi(){var e,l,u,f,h;return f=n,h=n,o.substr(n,1).toLowerCase()==="q"?(e=o.substr(n,1),n++):(e=null,d('"q"')),e!==null?(l=re(),l!==null?(u=ze(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.q=v}(f,e[2])),e===null&&(n=f),e}function rs(){var e,l,u,f,h;return f=n,h=n,o.substr(n,7).toLowerCase()==="expires"?(e=o.substr(n,7),n+=7):(e=null,d('"expires"')),e!==null?(l=re(),l!==null?(u=is(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.expires=v}(f,e[2])),e===null&&(n=f),e}function is(){var e,l,u;if(u=n,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&&(n=u),e}function ze(){var e,l,u,f,h,m,v,S;return m=n,v=n,o.charCodeAt(n)===48?(e="0",n++):(e=null,d('"0"')),e!==null?(S=n,o.charCodeAt(n)===46?(l=".",n++):(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,n=S)):(l=null,n=S)):(l=null,n=S)):(l=null,n=S),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(O){return parseFloat(o.substring(n,O))}(m)),e===null&&(n=m),e}function Je(){var e,l,u,f,h,m;return f=n,h=n,e=P(),e!==null?(m=n,l=re(),l!==null?(u=Co(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=h)):(e=null,n=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&&(n=f),e}function Co(){var e;return e=P(),e===null&&(e=Ts(),e===null&&(e=Oe())),e}function Ro(){var e,l,u,f,h,m;if(h=n,e=Zn(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function Zn(){var e;return o.substr(n,6).toLowerCase()==="render"?(e=o.substr(n,6),n+=6):(e=null,d('"render"')),e===null&&(o.substr(n,7).toLowerCase()==="session"?(e=o.substr(n,7),n+=7):(e=null,d('"session"')),e===null&&(o.substr(n,4).toLowerCase()==="icon"?(e=o.substr(n,4),n+=4):(e=null,d('"icon"')),e===null&&(o.substr(n,5).toLowerCase()==="alert"?(e=o.substr(n,5),n+=5):(e=null,d('"alert"')),e===null&&(e=P())))),e}function er(){var e;return e=Io(),e===null&&(e=Je()),e}function Io(){var e,l,u,f;return f=n,o.substr(n,8).toLowerCase()==="handling"?(e=o.substr(n,8),n+=8):(e=null,d('"handling"')),e!==null?(l=re(),l!==null?(o.substr(n,8).toLowerCase()==="optional"?(u=o.substr(n,8),n+=8):(u=null,d('"optional"')),u===null&&(o.substr(n,8).toLowerCase()==="required"?(u=o.substr(n,8),n+=8):(u=null,d('"required"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Ru(){var e,l,u,f,h,m;if(h=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function Iu(){var e,l,u;if(u=n,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&&(n=u),e}function bo(){var e,l;return l=n,e=xi(),e!==null&&(e=function(u){w=o.substring(n,u)}(l)),e===null&&(n=l),e}function xi(){var e,l,u,f,h,m,v,S;if(v=n,e=Mi(),e!==null)if(l=G(),l!==null)if(u=tr(),u!==null){for(f=[],S=n,h=ye(),h!==null?(m=sr(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);h!==null;)f.push(h),S=n,h=ye(),h!==null?(m=sr(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e}function Mi(){var e;return e=ki(),e===null&&(e=mn()),e}function ki(){var e;return o.substr(n,4).toLowerCase()==="text"?(e=o.substr(n,4),n+=4):(e=null,d('"text"')),e===null&&(o.substr(n,5).toLowerCase()==="image"?(e=o.substr(n,5),n+=5):(e=null,d('"image"')),e===null&&(o.substr(n,5).toLowerCase()==="audio"?(e=o.substr(n,5),n+=5):(e=null,d('"audio"')),e===null&&(o.substr(n,5).toLowerCase()==="video"?(e=o.substr(n,5),n+=5):(e=null,d('"video"')),e===null&&(o.substr(n,11).toLowerCase()==="application"?(e=o.substr(n,11),n+=11):(e=null,d('"application"')),e===null&&(e=gn()))))),e}function mn(){var e;return o.substr(n,7).toLowerCase()==="message"?(e=o.substr(n,7),n+=7):(e=null,d('"message"')),e===null&&(o.substr(n,9).toLowerCase()==="multipart"?(e=o.substr(n,9),n+=9):(e=null,d('"multipart"')),e===null&&(e=gn())),e}function gn(){var e;return e=P(),e===null&&(e=Li()),e}function Li(){var e,l,u;return u=n,o.substr(n,2).toLowerCase()==="x-"?(e=o.substr(n,2),n+=2):(e=null,d('"x-"')),e!==null?(l=P(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function tr(){var e;return e=gn(),e===null&&(e=P()),e}function sr(){var e,l,u,f;return f=n,e=P(),e!==null?(l=re(),l!==null?(u=wo(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function wo(){var e;return e=P(),e===null&&(e=Oe()),e}function Oo(){var e,l,u,f;return f=n,e=Do(),e!==null?(l=M(),l!==null?(u=pn(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Do(){var e,l,u;if(u=n,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&&(n=u),e}function bu(){var e,l;return l=n,e=is(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(n=l),e}function Tn(){var e,l,u,f,h,m,v;if(h=n,m=n,e=vn(),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=m;return e!==null&&(e=function(S,O){w.event=O.join("").toLowerCase()}(h,e[0])),e===null&&(n=h),e}function vn(){var e,l,u,f,h,m;if(h=n,e=se(),e!==null){for(l=[],m=n,o.charCodeAt(n)===46?(u=".",n++):(u=null,d('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,o.charCodeAt(n)===46?(u=".",n++):(u=null,d('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function $i(){var e,l,u,f,h,m,v;if(h=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=En(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=En(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=h),e}function En(){var e;return e=Hi(),e===null&&(e=Je()),e}function Hi(){var e,l,u,f,h;return f=n,h=n,o.substr(n,3).toLowerCase()==="tag"?(e=o.substr(n,3),n+=3):(e=null,d('"tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.tag=v}(f,e[2])),e===null&&(n=f),e}function wu(){var e,l,u;if(u=n,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&&(n=u),e}function Ou(){var e,l;return l=n,e=is(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(n=l),e}function Du(){var e,l,u,f,h,m,v,S,O,ie;for(S=n,O=n,e=[],l=js();l!==null;)e.push(l),l=js();if(e!==null)if(l=Re(),l!==null)if(u=Ne(),u!==null)if(f=xe(),f!==null){for(h=[],ie=n,m=ye(),m!==null?(v=Je(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);m!==null;)h.push(m),ie=n,m=ye(),m!==null?(v=Je(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);h!==null?e=[e,l,u,f,h]:(e=null,n=O)}else e=null,n=O;else e=null,n=O;else e=null,n=O;else e=null,n=O;return e!==null&&(e=function(Ue){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(n=S),e}function Fi(){var e;return e=nr(),e}function nr(){var e,l,u,f,h,m,v,S;if(v=n,o.substr(n,6).toLowerCase()==="digest"?(e=o.substr(n,6),n+=6):(e=null,d('"Digest"')),e!==null)if(l=M(),l!==null)if(u=Sn(),u!==null){for(f=[],S=n,h=le(),h!==null?(m=Sn(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);h!==null;)f.push(h),S=n,h=le(),h!==null?(m=Sn(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e===null&&(e=Vs()),e}function Vs(){var e,l,u,f,h,m,v,S;if(v=n,e=P(),e!==null)if(l=M(),l!==null)if(u=ls(),u!==null){for(f=[],S=n,h=le(),h!==null?(m=ls(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);h!==null;)f.push(h),S=n,h=le(),h!==null?(m=ls(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e}function ls(){var e,l,u,f;return f=n,e=P(),e!==null?(l=re(),l!==null?(u=P(),u===null&&(u=Oe()),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Sn(){var e;return e=ji(),e===null&&(e=yn(),e===null&&(e=qi(),e===null&&(e=Gi(),e===null&&(e=Wi(),e===null&&(e=Ki(),e===null&&(e=Cn(),e===null&&(e=ls()))))))),e}function ji(){var e,l,u,f;return f=n,o.substr(n,5).toLowerCase()==="realm"?(e=o.substr(n,5),n+=5):(e=null,d('"realm"')),e!==null?(l=re(),l!==null?(u=Vi(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Vi(){var e,l;return l=n,e=pe(),e!==null&&(e=function(u,f){w.realm=f}(l,e)),e===null&&(n=l),e}function yn(){var e,l,u,f,h,m,v,S,O;if(S=n,o.substr(n,6).toLowerCase()==="domain"?(e=o.substr(n,6),n+=6):(e=null,d('"domain"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null)if(f=An(),f!==null){if(h=[],O=n,v=$(),v!==null)for(m=[];v!==null;)m.push(v),v=$();else m=null;for(m!==null?(v=An(),v!==null?m=[m,v]:(m=null,n=O)):(m=null,n=O);m!==null;){if(h.push(m),O=n,v=$(),v!==null)for(m=[];v!==null;)m.push(v),v=$();else m=null;m!==null?(v=An(),v!==null?m=[m,v]:(m=null,n=O)):(m=null,n=O)}h!==null?(m=Ee(),m!==null?e=[e,l,u,f,h,m]:(e=null,n=S)):(e=null,n=S)}else e=null,n=S;else e=null,n=S;else e=null,n=S;else e=null,n=S;return e}function An(){var e;return e=Yn(),e===null&&(e=_n()),e}function qi(){var e,l,u,f;return f=n,o.substr(n,5).toLowerCase()==="nonce"?(e=o.substr(n,5),n+=5):(e=null,d('"nonce"')),e!==null?(l=re(),l!==null?(u=Bi(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Bi(){var e,l;return l=n,e=pe(),e!==null&&(e=function(u,f){w.nonce=f}(l,e)),e===null&&(n=l),e}function Gi(){var e,l,u,f,h;return f=n,h=n,o.substr(n,6).toLowerCase()==="opaque"?(e=o.substr(n,6),n+=6):(e=null,d('"opaque"')),e!==null?(l=re(),l!==null?(u=pe(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.opaque=v}(f,e[2])),e===null&&(n=f),e}function Wi(){var e,l,u,f,h;return f=n,o.substr(n,5).toLowerCase()==="stale"?(e=o.substr(n,5),n+=5):(e=null,d('"stale"')),e!==null?(l=re(),l!==null?(h=n,o.substr(n,4).toLowerCase()==="true"?(u=o.substr(n,4),n+=4):(u=null,d('"true"')),u!==null&&(u=function(m){w.stale=!0}()),u===null&&(n=h),u===null&&(h=n,o.substr(n,5).toLowerCase()==="false"?(u=o.substr(n,5),n+=5):(u=null,d('"false"')),u!==null&&(u=function(m){w.stale=!1}()),u===null&&(n=h)),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Ki(){var e,l,u,f,h;return f=n,h=n,o.substr(n,9).toLowerCase()==="algorithm"?(e=o.substr(n,9),n+=9):(e=null,d('"algorithm"')),e!==null?(l=re(),l!==null?(o.substr(n,3).toLowerCase()==="md5"?(u=o.substr(n,3),n+=3):(u=null,d('"MD5"')),u===null&&(o.substr(n,8).toLowerCase()==="md5-sess"?(u=o.substr(n,8),n+=8):(u=null,d('"MD5-sess"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.algorithm=v.toUpperCase()}(f,e[2])),e===null&&(n=f),e}function Cn(){var e,l,u,f,h,m,v,S,O,ie;if(S=n,o.substr(n,3).toLowerCase()==="qop"?(e=o.substr(n,3),n+=3):(e=null,d('"qop"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null){if(O=n,f=rr(),f!==null){for(h=[],ie=n,o.charCodeAt(n)===44?(m=",",n++):(m=null,d('","')),m!==null?(v=rr(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);m!==null;)h.push(m),ie=n,o.charCodeAt(n)===44?(m=",",n++):(m=null,d('","')),m!==null?(v=rr(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);h!==null?f=[f,h]:(f=null,n=O)}else f=null,n=O;f!==null?(h=Ee(),h!==null?e=[e,l,u,f,h]:(e=null,n=S)):(e=null,n=S)}else e=null,n=S;else e=null,n=S;else e=null,n=S;return e}function rr(){var e,l;return l=n,o.substr(n,8).toLowerCase()==="auth-int"?(e=o.substr(n,8),n+=8):(e=null,d('"auth-int"')),e===null&&(o.substr(n,4).toLowerCase()==="auth"?(e=o.substr(n,4),n+=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&&(n=l),e}function Nu(){var e,l,u,f,h,m;if(h=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function ir(){var e,l,u,f,h,m,v;if(h=n,m=n,e=lr(),e!==null){for(l=[],v=n,u=le(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=le(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=h),e}function lr(){var e,l,u,f,h,m,v;if(h=n,m=n,e=Vt(),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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:n,offset:S,parsed:O})}(h)),e===null&&(n=h),e}function Yi(){var e,l,u,f,h,m,v;if(h=n,m=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=h),e}function or(){var e;return e=No(),e===null&&(e=Je()),e}function No(){var e,l,u,f,h,m;if(h=n,m=n,o.substr(n,5).toLowerCase()==="cause"?(e=o.substr(n,5),n+=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,n=m)}else e=null,n=m;else e=null,n=m;return e!==null&&(e=function(v,S){w.cause=parseInt(S.join(""))}(h,e[2])),e===null&&(n=h),e}function Uu(){var e,l,u,f,h,m;if(h=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function ar(){var e,l,u,f,h,m;if(h=n,e=ur(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function ur(){var e,l,u,f,h,m;if(h=n,e=Vt(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function Uo(){var e,l,u,f,h,m;if(h=n,e=cr(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function cr(){var e,l;return l=n,o.substr(n,6).toLowerCase()==="active"?(e=o.substr(n,6),n+=6):(e=null,d('"active"')),e===null&&(o.substr(n,7).toLowerCase()==="pending"?(e=o.substr(n,7),n+=7):(e=null,d('"pending"')),e===null&&(o.substr(n,10).toLowerCase()==="terminated"?(e=o.substr(n,10),n+=10):(e=null,d('"terminated"')),e===null&&(e=P()))),e!==null&&(e=function(u){w.state=o.substring(n,u)}(l)),e===null&&(n=l),e}function fr(){var e,l,u,f,h;return f=n,h=n,o.substr(n,6).toLowerCase()==="reason"?(e=o.substr(n,6),n+=6):(e=null,d('"reason"')),e!==null?(l=re(),l!==null?(u=Po(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){typeof v<"u"&&(w.reason=v)}(f,e[2])),e===null&&(n=f),e===null&&(f=n,h=n,o.substr(n,7).toLowerCase()==="expires"?(e=o.substr(n,7),n+=7):(e=null,d('"expires"')),e!==null?(l=re(),l!==null?(u=is(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){typeof v<"u"&&(w.expires=v)}(f,e[2])),e===null&&(n=f),e===null&&(f=n,h=n,o.substr(n,11).toLowerCase()==="retry_after"?(e=o.substr(n,11),n+=11):(e=null,d('"retry_after"')),e!==null?(l=re(),l!==null?(u=is(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){typeof v<"u"&&(w.retry_after=v)}(f,e[2])),e===null&&(n=f),e===null&&(e=Je()))),e}function Po(){var e;return o.substr(n,11).toLowerCase()==="deactivated"?(e=o.substr(n,11),n+=11):(e=null,d('"deactivated"')),e===null&&(o.substr(n,9).toLowerCase()==="probation"?(e=o.substr(n,9),n+=9):(e=null,d('"probation"')),e===null&&(o.substr(n,8).toLowerCase()==="rejected"?(e=o.substr(n,8),n+=8):(e=null,d('"rejected"')),e===null&&(o.substr(n,7).toLowerCase()==="timeout"?(e=o.substr(n,7),n+=7):(e=null,d('"timeout"')),e===null&&(o.substr(n,6).toLowerCase()==="giveup"?(e=o.substr(n,6),n+=6):(e=null,d('"giveup"')),e===null&&(o.substr(n,10).toLowerCase()==="noresource"?(e=o.substr(n,10),n+=10):(e=null,d('"noresource"')),e===null&&(o.substr(n,9).toLowerCase()==="invariant"?(e=o.substr(n,9),n+=9):(e=null,d('"invariant"')),e===null&&(e=P()))))))),e}function Pu(){var e;return e=q(),e=e!==null?e:"",e}function xu(){var e,l,u,f,h,m;if(h=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e=e!==null?e:"",e}function zi(){var e,l,u,f,h,m,v;if(h=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=Ji(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=Ji(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=h),e}function Ji(){var e;return e=Hi(),e===null&&(e=Je()),e}function _r(){var e,l,u,f,h,m;if(h=n,e=qs(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=qs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=qs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function qs(){var e,l,u,f,h,m,v,S;if(v=n,e=nl(),e!==null)if(l=M(),l!==null)if(u=ll(),u!==null){for(f=[],S=n,h=ye(),h!==null?(m=hr(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);h!==null;)f.push(h),S=n,h=ye(),h!==null?(m=hr(),m!==null?h=[h,m]:(h=null,n=S)):(h=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e}function hr(){var e;return e=Xi(),e===null&&(e=Qi(),e===null&&(e=Zi(),e===null&&(e=el(),e===null&&(e=tl(),e===null&&(e=Je()))))),e}function Xi(){var e,l,u,f,h;return f=n,h=n,o.substr(n,3).toLowerCase()==="ttl"?(e=o.substr(n,3),n+=3):(e=null,d('"ttl"')),e!==null?(l=re(),l!==null?(u=al(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.ttl=v}(f,e[2])),e===null&&(n=f),e}function Qi(){var e,l,u,f,h;return f=n,h=n,o.substr(n,5).toLowerCase()==="maddr"?(e=o.substr(n,5),n+=5):(e=null,d('"maddr"')),e!==null?(l=re(),l!==null?(u=Ts(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.maddr=v}(f,e[2])),e===null&&(n=f),e}function Zi(){var e,l,u,f,h;return f=n,h=n,o.substr(n,8).toLowerCase()==="received"?(e=o.substr(n,8),n+=8):(e=null,d('"received"')),e!==null?(l=re(),l!==null?(u=zt(),u===null&&(u=me()),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.received=v}(f,e[2])),e===null&&(n=f),e}function el(){var e,l,u,f,h;return f=n,h=n,o.substr(n,6).toLowerCase()==="branch"?(e=o.substr(n,6),n+=6):(e=null,d('"branch"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.branch=v}(f,e[2])),e===null&&(n=f),e}function tl(){var e,l,u,f,h;return f=n,o.substr(n,5).toLowerCase()==="rport"?(e=o.substr(n,5),n+=5):(e=null,d('"rport"')),e!==null?(h=n,l=re(),l!==null?(u=sl(),u!==null?l=[l,u]:(l=null,n=h)):(l=null,n=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function sl(){var e,l,u,f,h,m,v;return m=n,v=n,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,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(S,O){w.rport=parseInt(O.join(""))}(m,e)),e===null&&(n=m),e}function nl(){var e,l,u,f,h,m;return m=n,e=rl(),e!==null?(l=G(),l!==null?(u=P(),u!==null?(f=G(),f!==null?(h=il(),h!==null?e=[e,l,u,f,h]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function rl(){var e,l;return l=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null&&(e=function(u,f){w.protocol=f}(l,e)),e===null&&(n=l),e}function il(){var e,l;return l=n,o.substr(n,3).toLowerCase()==="udp"?(e=o.substr(n,3),n+=3):(e=null,d('"UDP"')),e===null&&(o.substr(n,3).toLowerCase()==="tcp"?(e=o.substr(n,3),n+=3):(e=null,d('"TCP"')),e===null&&(o.substr(n,3).toLowerCase()==="tls"?(e=o.substr(n,3),n+=3):(e=null,d('"TLS"')),e===null&&(o.substr(n,4).toLowerCase()==="sctp"?(e=o.substr(n,4),n+=4):(e=null,d('"SCTP"')),e===null&&(e=P())))),e!==null&&(e=function(u,f){w.transport=f}(l,e)),e===null&&(n=l),e}function ll(){var e,l,u,f,h;return f=n,e=ol(),e!==null?(h=n,l=it(),l!==null?(u=dr(),u!==null?l=[l,u]:(l=null,n=h)):(l=null,n=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function ol(){var e,l;return l=n,e=zt(),e===null&&(e=on(),e===null&&(e=ln())),e!==null&&(e=function(u){w.host=o.substring(n,u)}(l)),e===null&&(n=l),e}function dr(){var e,l,u,f,h,m,v;return m=n,v=n,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,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(S,O){w.port=parseInt(O.join(""))}(m,e)),e===null&&(n=m),e}function al(){var e,l,u,f,h;return f=n,h=n,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,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){return parseInt(v.join(""))}(f,e)),e===null&&(n=f),e}function Mu(){var e;return e=nr(),e}function xo(){var e,l,u,f,h,m;if(h=n,e=pr(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=mr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=mr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function pr(){var e,l;return l=n,e=is(),e!==null&&(e=function(u,f){w.expires=f}(l,e)),e===null&&(n=l),e}function mr(){var e;return e=Mo(),e===null&&(e=Je()),e}function Mo(){var e,l,u,f,h;return f=n,h=n,o.substr(n,9).toLowerCase()==="refresher"?(e=o.substr(n,9),n+=9):(e=null,d('"refresher"')),e!==null?(l=re(),l!==null?(o.substr(n,3).toLowerCase()==="uac"?(u=o.substr(n,3),n+=3):(u=null,d('"uac"')),u===null&&(o.substr(n,3).toLowerCase()==="uas"?(u=o.substr(n,3),n+=3):(u=null,d('"uas"'))),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.refresher=v.toLowerCase()}(f,e[2])),e===null&&(n=f),e}function ko(){var e,l,u,f;return f=n,e=P(),e!==null?(l=B(),l!==null?(u=Lo(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Lo(){var e,l;for(e=[],l=z(),l===null&&(l=Z(),l===null&&(l=M()));l!==null;)e.push(l),l=z(),l===null&&(l=Z(),l===null&&(l=M()));return e}function ku(){var e,l;for(e=[],l=C();l!==null;)e.push(l),l=C();return e}function $o(){var e,l,u;return u=n,o.substr(n,5)==="uuid:"?(e="uuid:",n+=5):(e=null,d('"uuid:"')),e!==null?(l=qt(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function qt(){var e,l,u,f,h,m,v,S,O,ie,Ue;return ie=n,Ue=n,e=ul(),e!==null?(o.charCodeAt(n)===45?(l="-",n++):(l=null,d('"-"')),l!==null?(u=Bt(),u!==null?(o.charCodeAt(n)===45?(f="-",n++):(f=null,d('"-"')),f!==null?(h=Bt(),h!==null?(o.charCodeAt(n)===45?(m="-",n++):(m=null,d('"-"')),m!==null?(v=Bt(),v!==null?(o.charCodeAt(n)===45?(S="-",n++):(S=null,d('"-"')),S!==null?(O=Ho(),O!==null?e=[e,l,u,f,h,m,v,S,O]:(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue),e!==null&&(e=function(Ot,Bs){w=o.substring(n+5,Ot)}(ie,e[0])),e===null&&(n=ie),e}function Bt(){var e,l,u,f,h;return h=n,e=y(),e!==null?(l=y(),l!==null?(u=y(),u!==null?(f=y(),f!==null?e=[e,l,u,f]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e}function ul(){var e,l,u;return u=n,e=Bt(),e!==null?(l=Bt(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function Ho(){var e,l,u,f;return f=n,e=Bt(),e!==null?(l=Bt(),l!==null?(u=Bt(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Lu(){var e,l,u,f,h,m,v;if(h=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=Je(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=m;return e!==null&&(e=function(S){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(n=h),e}function Fo(){var e,l,u,f,h,m;if(h=n,e=gr(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=h)}else e=null,n=h;return e}function gr(){var e,l,u,f,h,m;return f=n,h=n,e=ee(),e!==null?(m=n,o.charCodeAt(n)===64?(l="@",n++):(l=null,d('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(v){w.call_id=o.substring(n,v)}(f)),e===null&&(n=f),e}function Tr(){var e;return e=cl(),e===null&&(e=fl(),e===null&&(e=jo(),e===null&&(e=Je()))),e}function cl(){var e,l,u,f,h;return f=n,h=n,o.substr(n,6)==="to-tag"?(e="to-tag",n+=6):(e=null,d('"to-tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.to_tag=v}(f,e[2])),e===null&&(n=f),e}function fl(){var e,l,u,f,h;return f=n,h=n,o.substr(n,8)==="from-tag"?(e="from-tag",n+=8):(e=null,d('"from-tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=h)):(e=null,n=h)):(e=null,n=h),e!==null&&(e=function(m,v){w.from_tag=v}(f,e[2])),e===null&&(n=f),e}function jo(){var e,l;return l=n,o.substr(n,10)==="early-only"?(e="early-only",n+=10):(e=null,d('"early-only"')),e!==null&&(e=function(u){w.early_only=!0}()),e===null&&(n=l),e}function $u(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 Vo(){for(var e=1,l=1,u=!1,f=0;f<Math.max(n,p);f++){var h=o.charAt(f);h===`
|
4
|
-
`?(u||e++,l=1,u=!1):
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var A=!0,C=!1,I;return{s:function(){T=
|
6
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var C=!0,I=!1,$;return{s:function(){E=g[Symbol.iterator]()},n:function(){var ae=E.next();return C=ae.done,ae},e:function(ae){I=!0,$=ae},f:function(){try{!C&&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=tt,t=ys(),n=Xt();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,C=E;A<C.length;A++){var I=C[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=n.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 C;return(C=t.parse(g))?C: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,C;for(C=0;C<A;C++)C!==0&&(y+="-"),y+=E[C].charAt(0).toUpperCase()+E[C].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,he){return pe<<he|pe>>>32-he}function E(pe,he){var de=pe&2147483648,we=he&2147483648,Ne=pe&1073741824,et=he&1073741824,He=(pe&1073741823)+(he&1073741823);return Ne&et?He^2147483648^de^we:Ne|et?He&1073741824?He^3221225472^de^we:He^1073741824^de^we:He^de^we}function y(pe,he,de){return pe&he|~pe&de}function A(pe,he,de){return pe&de|he&~de}function C(pe,he,de){return pe^he^de}function I(pe,he,de){return he^(pe|~de)}function $(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(y(he,de,we),Ne),He)),E(T(pe,et),he)}function L(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(A(he,de,we),Ne),He)),E(T(pe,et),he)}function ae(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(C(he,de,we),Ne),He)),E(T(pe,et),he)}function N(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(I(he,de,we),Ne),He)),E(T(pe,et),he)}function F(pe){for(var he,de=pe.length,we=de+8,Ne=(we-we%64)/64,et=(Ne+1)*16,He=new Array(et-1),Ft=0,At=0;At<de;)he=(At-At%4)/4,Ft=At%4*8,He[he]=He[he]|pe.charCodeAt(At)<<Ft,At++;return he=(At-At%4)/4,Ft=At%4*8,He[he]=He[he]|128<<Ft,He[et-2]=de<<3,He[et-1]=de>>>29,He}function Se(pe){var he="",de="",we,Ne;for(Ne=0;Ne<=3;Ne++)we=pe>>>Ne*8&255,de="0".concat(we.toString(16)),he=he+de.substr(de.length-2,2);return he}function ve(pe){for(var he="",de=0;de<pe.length;de++){var we=pe.charCodeAt(de);we<128?he+=String.fromCharCode(we):we>127&&we<2048?(he+=String.fromCharCode(we>>6|192),he+=String.fromCharCode(we&63|128)):(he+=String.fromCharCode(we>>12|224),he+=String.fromCharCode(we>>6&63|128),he+=String.fromCharCode(we&63|128))}return he}var M=[],D,B,q,z,H,Z,U,P,se,rt=7,ee=12,Y=17,G=22,re=5,ge=9,be=14,xe=20,Re=4,le=11,ye=16,it=23,ot=6,Ee=10,Ae=15,Ie=21;for(g=ve(g),M=F(g),Z=1732584193,U=4023233417,P=2562383102,se=271733878,D=0;D<M.length;D+=16)B=Z,q=U,z=P,H=se,Z=$(Z,U,P,se,M[D+0],rt,3614090360),se=$(se,Z,U,P,M[D+1],ee,3905402710),P=$(P,se,Z,U,M[D+2],Y,606105819),U=$(U,P,se,Z,M[D+3],G,3250441966),Z=$(Z,U,P,se,M[D+4],rt,4118548399),se=$(se,Z,U,P,M[D+5],ee,1200080426),P=$(P,se,Z,U,M[D+6],Y,2821735955),U=$(U,P,se,Z,M[D+7],G,4249261313),Z=$(Z,U,P,se,M[D+8],rt,1770035416),se=$(se,Z,U,P,M[D+9],ee,2336552879),P=$(P,se,Z,U,M[D+10],Y,4294925233),U=$(U,P,se,Z,M[D+11],G,2304563134),Z=$(Z,U,P,se,M[D+12],rt,1804603682),se=$(se,Z,U,P,M[D+13],ee,4254626195),P=$(P,se,Z,U,M[D+14],Y,2792965006),U=$(U,P,se,Z,M[D+15],G,1236535329),Z=L(Z,U,P,se,M[D+1],re,4129170786),se=L(se,Z,U,P,M[D+6],ge,3225465664),P=L(P,se,Z,U,M[D+11],be,643717713),U=L(U,P,se,Z,M[D+0],xe,3921069994),Z=L(Z,U,P,se,M[D+5],re,3593408605),se=L(se,Z,U,P,M[D+10],ge,38016083),P=L(P,se,Z,U,M[D+15],be,3634488961),U=L(U,P,se,Z,M[D+4],xe,3889429448),Z=L(Z,U,P,se,M[D+9],re,568446438),se=L(se,Z,U,P,M[D+14],ge,3275163606),P=L(P,se,Z,U,M[D+3],be,4107603335),U=L(U,P,se,Z,M[D+8],xe,1163531501),Z=L(Z,U,P,se,M[D+13],re,2850285829),se=L(se,Z,U,P,M[D+2],ge,4243563512),P=L(P,se,Z,U,M[D+7],be,1735328473),U=L(U,P,se,Z,M[D+12],xe,2368359562),Z=ae(Z,U,P,se,M[D+5],Re,4294588738),se=ae(se,Z,U,P,M[D+8],le,2272392833),P=ae(P,se,Z,U,M[D+11],ye,1839030562),U=ae(U,P,se,Z,M[D+14],it,4259657740),Z=ae(Z,U,P,se,M[D+1],Re,2763975236),se=ae(se,Z,U,P,M[D+4],le,1272893353),P=ae(P,se,Z,U,M[D+7],ye,4139469664),U=ae(U,P,se,Z,M[D+10],it,3200236656),Z=ae(Z,U,P,se,M[D+13],Re,681279174),se=ae(se,Z,U,P,M[D+0],le,3936430074),P=ae(P,se,Z,U,M[D+3],ye,3572445317),U=ae(U,P,se,Z,M[D+6],it,76029189),Z=ae(Z,U,P,se,M[D+9],Re,3654602809),se=ae(se,Z,U,P,M[D+12],le,3873151461),P=ae(P,se,Z,U,M[D+15],ye,530742520),U=ae(U,P,se,Z,M[D+2],it,3299628645),Z=N(Z,U,P,se,M[D+0],ot,4096336452),se=N(se,Z,U,P,M[D+7],Ee,1126891415),P=N(P,se,Z,U,M[D+14],Ae,2878612391),U=N(U,P,se,Z,M[D+5],Ie,4237533241),Z=N(Z,U,P,se,M[D+12],ot,1700485571),se=N(se,Z,U,P,M[D+3],Ee,2399980690),P=N(P,se,Z,U,M[D+10],Ae,4293915773),U=N(U,P,se,Z,M[D+1],Ie,2240044497),Z=N(Z,U,P,se,M[D+8],ot,1873313359),se=N(se,Z,U,P,M[D+15],Ee,4264355552),P=N(P,se,Z,U,M[D+6],Ae,2734768916),U=N(U,P,se,Z,M[D+13],Ie,1309151649),Z=N(Z,U,P,se,M[D+4],ot,4149444226),se=N(se,Z,U,P,M[D+11],Ee,3174756917),P=N(P,se,Z,U,M[D+2],Ae,718787259),U=N(U,P,se,Z,M[D+9],Ie,3951481745),Z=E(Z,B),U=E(U,q),P=E(P,z),se=E(se,H);var Oe=Se(Z)+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=s(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 C=s(T),I;try{for(C.s();!(I=C.n()).done;){var $=I.value;$.stop()}}catch(F){C.e(F)}finally{C.f()}T=g.getVideoTracks();var L=s(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 Yo={exports:{}},bn=typeof Reflect=="object"?Reflect:null,Wu=bn&&typeof bn.apply=="function"?bn.apply:function(s,r,o){return Function.prototype.apply.call(s,r,o)},El;bn&&typeof bn.ownKeys=="function"?El=bn.ownKeys:Object.getOwnPropertySymbols?El=function(s){return Object.getOwnPropertyNames(s).concat(Object.getOwnPropertySymbols(s))}:El=function(s){return Object.getOwnPropertyNames(s)};function H_(c){console&&console.warn&&console.warn(c)}var Ku=Number.isNaN||function(s){return s!==s};function Le(){Le.init.call(this)}Yo.exports=Le,Yo.exports.once=q_,Le.EventEmitter=Le,Le.prototype._events=void 0,Le.prototype._eventsCount=0,Le.prototype._maxListeners=void 0;var Yu=10;function Sl(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(Le,"defaultMaxListeners",{enumerable:!0,get:function(){return Yu},set:function(c){if(typeof c!="number"||c<0||Ku(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Yu=c}}),Le.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},Le.prototype.setMaxListeners=function(s){if(typeof s!="number"||s<0||Ku(s))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+s+".");return this._maxListeners=s,this};function zu(c){return c._maxListeners===void 0?Le.defaultMaxListeners:c._maxListeners}Le.prototype.getMaxListeners=function(){return zu(this)},Le.prototype.emit=function(s){for(var r=[],o=1;o<arguments.length;o++)r.push(arguments[o]);var a=s==="error",t=this._events;if(t!==void 0)a=a&&t.error===void 0;else if(!a)return!1;if(a){var n;if(r.length>0&&(n=r[0]),n instanceof Error)throw n;var p=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw p.context=n,p}var _=t[s];if(_===void 0)return!1;if(typeof _=="function")Wu(_,this,r);else for(var d=_.length,g=ec(_,d),o=0;o<d;++o)Wu(g[o],this,r);return!0};function Ju(c,s,r,o){var a,t,n;if(Sl(r),t=c._events,t===void 0?(t=c._events=Object.create(null),c._eventsCount=0):(t.newListener!==void 0&&(c.emit("newListener",s,r.listener?r.listener:r),t=c._events),n=t[s]),n===void 0)n=t[s]=r,++c._eventsCount;else if(typeof n=="function"?n=t[s]=o?[r,n]:[n,r]:o?n.unshift(r):n.push(r),a=zu(c),a>0&&n.length>a&&!n.warned){n.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(s)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=c,p.type=s,p.count=n.length,H_(p)}return c}Le.prototype.addListener=function(s,r){return Ju(this,s,r,!1)},Le.prototype.on=Le.prototype.addListener,Le.prototype.prependListener=function(s,r){return Ju(this,s,r,!0)};function F_(){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 Xu(c,s,r){var o={fired:!1,wrapFn:void 0,target:c,type:s,listener:r},a=F_.bind(o);return a.listener=r,o.wrapFn=a,a}Le.prototype.once=function(s,r){return Sl(r),this.on(s,Xu(this,s,r)),this},Le.prototype.prependOnceListener=function(s,r){return Sl(r),this.prependListener(s,Xu(this,s,r)),this},Le.prototype.removeListener=function(s,r){var o,a,t,n,p;if(Sl(r),a=this._events,a===void 0)return this;if(o=a[s],o===void 0)return this;if(o===r||o.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete a[s],a.removeListener&&this.emit("removeListener",s,o.listener||r));else if(typeof o!="function"){for(t=-1,n=o.length-1;n>=0;n--)if(o[n]===r||o[n].listener===r){p=o[n].listener,t=n;break}if(t<0)return this;t===0?o.shift():j_(o,t),o.length===1&&(a[s]=o[0]),a.removeListener!==void 0&&this.emit("removeListener",s,p||r)}return this},Le.prototype.off=Le.prototype.removeListener,Le.prototype.removeAllListeners=function(s){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[s]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[s]),this;if(arguments.length===0){var t=Object.keys(o),n;for(a=0;a<t.length;++a)n=t[a],n!=="removeListener"&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=o[s],typeof r=="function")this.removeListener(s,r);else if(r!==void 0)for(a=r.length-1;a>=0;a--)this.removeListener(s,r[a]);return this};function Qu(c,s,r){var o=c._events;if(o===void 0)return[];var a=o[s];return a===void 0?[]:typeof a=="function"?r?[a.listener||a]:[a]:r?V_(a):ec(a,a.length)}Le.prototype.listeners=function(s){return Qu(this,s,!0)},Le.prototype.rawListeners=function(s){return Qu(this,s,!1)},Le.listenerCount=function(c,s){return typeof c.listenerCount=="function"?c.listenerCount(s):Zu.call(c,s)},Le.prototype.listenerCount=Zu;function Zu(c){var s=this._events;if(s!==void 0){var r=s[c];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Le.prototype.eventNames=function(){return this._eventsCount>0?El(this._events):[]};function ec(c,s){for(var r=new Array(s),o=0;o<s;++o)r[o]=c[o];return r}function j_(c,s){for(;s+1<c.length;s++)c[s]=c[s+1];c.pop()}function V_(c){for(var s=new Array(c.length),r=0;r<s.length;++r)s[r]=c[r].listener||c[r];return s}function q_(c,s){return new Promise(function(r,o){function a(n){c.removeListener(s,t),o(n)}function t(){typeof c.removeListener=="function"&&c.removeListener("error",a),r([].slice.call(arguments))}tc(c,s,t,{once:!0}),s!=="error"&&B_(c,a,{once:!0})})}function B_(c,s,r){typeof c.on=="function"&&tc(c,"error",s,r)}function tc(c,s,r,o){if(typeof c.on=="function")o.once?c.once(s,r):c.on(s,r);else if(typeof c.addEventListener=="function")c.addEventListener(s,function a(t){o.once&&c.removeEventListener(s,a),r(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ut=Yo.exports,zo={exports:{}},Jo,sc;function G_(){if(sc)return Jo;sc=1;var c=1e3,s=c*60,r=s*60,o=r*24,a=o*7,t=o*365.25;Jo=function(g,T){T=T||{};var E=typeof g;if(E==="string"&&g.length>0)return n(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 n(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*s;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>=s?Math.round(g/s)+"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>=s?d(g,T,s,"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 Jo}function W_(c){r.debug=r,r.default=r,r.coerce=_,r.disable=t,r.enable=a,r.enabled=n,r.humanize=G_(),r.destroy=d,Object.keys(c).forEach(g=>{r[g]=c[g]}),r.names=[],r.skips=[],r.formatters={};function s(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=s;function r(g){let T,E=null,y,A;function C(...I){if(!C.enabled)return;const $=C,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 C.namespace=g,C.useColors=r.useColors(),C.color=r.selectColor(g),C.extend=o,C.destroy=r.destroy,Object.defineProperty(C,"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(C),C}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 n(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 K_=W_;(function(c,s){s.formatArgs=o,s.save=a,s.load=t,s.useColors=r,s.storage=n(),s.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`."))}})(),s.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)}s.log=console.debug||console.log||(()=>{});function a(_){try{_?s.storage.setItem("debug",_):s.storage.removeItem("debug")}catch{}}function t(){let _;try{_=s.storage.getItem("debug")}catch{}return!_&&typeof process<"u"&&"env"in process&&(_=process.env.DEBUG),_}function n(){try{return localStorage}catch{}}c.exports=K_(s);const{formatters:p}=c.exports;p.j=function(_){try{return JSON.stringify(_)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(zo,zo.exports);var wn=zo.exports;function Y_(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function nc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function z_(c,s,r){return s&&nc(c.prototype,s),r&&nc(c,r),c}var On=wn,Dn="JsSIP",ct=function(){function c(s){Y_(this,c),s?(this._debug=On.default("".concat(Dn,":").concat(s)),this._warn=On.default("".concat(Dn,":WARN:").concat(s)),this._error=On.default("".concat(Dn,":ERROR:").concat(s))):(this._debug=On.default(Dn),this._warn=On.default("".concat(Dn,":WARN")),this._error=On.default("".concat(Dn,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return z_(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),Dt={},rc={},ic={exports:{}},lc=ic.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 s="candidate:%s %d %s %d %s %d typ %s";return s+=c.raddr!=null?" raddr %s rport %d":"%v%v",s+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(s+=" generation %d"),s+=c["network-id"]!=null?" network-id %d":"%v",s+=c["network-cost"]!=null?" network-cost %d":"%v",s}},{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 s="ssrc:%d";return c.attribute!=null&&(s+=" %s",c.value!=null&&(s+=":%s")),s}},{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 s="mediaclk:";return s+=c.id!=null?"id=%s %s":"%v%s",s+=c.mediaClockValue!=null?"=%s":"",s+=c.rateNumerator!=null?" rate=%s":"",s+=c.rateDenominator!=null?"/%s":"",s}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(lc).forEach(function(c){var s=lc[c];s.forEach(function(r){r.reg||(r.reg=/(.*)/),r.format||(r.format="%s")})});var oc=ic.exports;(function(c){var s=function(p){return String(Number(p))===p?Number(p):p},r=function(p,_,d,g){if(g&&!d)_[g]=s(p[1]);else for(var T=0;T<d.length;T+=1)p[T+1]!=null&&(_[d[T]]=s(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=oc,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 C=a[E][A];if(C.reg.test(y))return o(C,g,y)}}),_.media=d,_};var n=function(p,_){var d=_.split(/=(.+)/,2);return d.length===2?p[d[0]]=s(d[1]):d.length===1&&_.length>1&&(p[d[0]]=void 0),p};c.parseParams=function(p){return p.split(/;\s?/).reduce(n,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(p){return p.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(p){for(var _=[],d=p.split(" ").map(s),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(n,{})})},c.parseSimulcastStreamList=function(p){return p.split(";").map(function(_){return _.split(",").map(function(d){var g,T=!1;return d[0]!=="~"?g=s(d):(g=s(d.substring(1,d.length)),T=!0),{scid:g,paused:T}})})}})(rc);var Xo=oc,J_=/%[sdv%]/g,X_=function(c){var s=1,r=arguments,o=r.length;return c.replace(J_,function(a){if(s>=o)return a;var t=r[s];switch(s+=1,a){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},Sr=function(c,s,r){var o=s.format instanceof Function?s.format(s.push?r:r[s.name]):s.format,a=[c+"="+o];if(s.names)for(var t=0;t<s.names.length;t+=1){var n=s.names[t];s.name?a.push(r[s.name][n]):a.push(r[s.names[t]])}else a.push(r[s.name]);return X_.apply(null,a)},Q_=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Z_=["i","c","b","a"],eh=function(c,s){s=s||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var r=s.outerOrder||Q_,o=s.innerOrder||Z_,a=[];return r.forEach(function(t){Xo[t].forEach(function(n){n.name in c&&c[n.name]!=null?a.push(Sr(t,n,c)):n.push in c&&c[n.push]!=null&&c[n.push].forEach(function(p){a.push(Sr(t,n,p))})})}),c.media.forEach(function(t){a.push(Sr("m",Xo.m[0],t)),o.forEach(function(n){Xo[n].forEach(function(p){p.name in t&&t[p.name]!=null?a.push(Sr(n,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(_){a.push(Sr(n,p,_))})})})}),a.join(`\r
|
3
|
+
`,n+=2):(e=null,h('"\\r\\n"')),e}function T(){var e;return/^[0-9]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[0-9]")),e}function E(){var e;return/^[a-zA-Z]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[a-zA-Z]")),e}function y(){var e;return/^[0-9a-fA-F]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[0-9a-fA-F]")),e}function A(){var e;return e=$(),e===null&&(e=L()),e}function C(){var e;return/^[\0-\xFF]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[\\0-\\xFF]")),e}function I(){var e;return/^["]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h('["]')),e}function $(){var e;return o.charCodeAt(n)===32?(e=" ",n++):(e=null,h('" "')),e}function L(){var e;return o.charCodeAt(n)===9?(e=" ",n++):(e=null,h('"\\t"')),e}function ae(){var e;return/^[a-zA-Z0-9]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[a-zA-Z0-9]")),e}function N(){var e;return o.charCodeAt(n)===59?(e=";",n++):(e=null,h('";"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,h('"/"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,h('"?"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,h('":"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,h('"@"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,h('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,h('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,h('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,h('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,h('","'))))))))))),e}function F(){var e;return e=ae(),e===null&&(e=Se()),e}function Se(){var e;return o.charCodeAt(n)===45?(e="-",n++):(e=null,h('"-"')),e===null&&(o.charCodeAt(n)===95?(e="_",n++):(e=null,h('"_"')),e===null&&(o.charCodeAt(n)===46?(e=".",n++):(e=null,h('"."')),e===null&&(o.charCodeAt(n)===33?(e="!",n++):(e=null,h('"!"')),e===null&&(o.charCodeAt(n)===126?(e="~",n++):(e=null,h('"~"')),e===null&&(o.charCodeAt(n)===42?(e="*",n++):(e=null,h('"*"')),e===null&&(o.charCodeAt(n)===39?(e="'",n++):(e=null,h(`"'"`)),e===null&&(o.charCodeAt(n)===40?(e="(",n++):(e=null,h('"("')),e===null&&(o.charCodeAt(n)===41?(e=")",n++):(e=null,h('")"')))))))))),e}function ve(){var e,l,u,f,d;return f=n,d=n,o.charCodeAt(n)===37?(e="%",n++):(e=null,h('"%"')),e!==null?(l=y(),l!==null?(u=y(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){return v.join("")}(f,e)),e===null&&(n=f),e}function M(){var e,l,u,f,d,m;for(f=n,d=n,m=n,e=[],l=A();l!==null;)e.push(l),l=A();if(e!==null?(l=g(),l!==null?e=[e,l]:(e=null,n=m)):(e=null,n=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,n=d)}else e=null,n=d;return e!==null&&(e=function(v){return" "}()),e===null&&(n=f),e}function D(){var e;return e=M(),e=e!==null?e:"",e}function B(){var e,l,u,f,d;for(f=n,d=n,e=[],l=$(),l===null&&(l=L());l!==null;)e.push(l),l=$(),l===null&&(l=L());return e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return":"}()),e===null&&(n=f),e}function q(){var e,l,u,f,d,m,v;if(d=n,m=n,l=J(),l!==null)for(e=[];l!==null;)e.push(l),l=J();else e=null;if(e!==null){for(l=[],v=n,u=[],f=M();f!==null;)u.push(f),f=M();for(u!==null?(f=J(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;){for(l.push(u),v=n,u=[],f=M();f!==null;)u.push(f),f=M();u!==null?(f=J(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v)}l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=m;return e!==null&&(e=function(S){return o.substring(n,S)}(d)),e===null&&(n=d),e}function J(){var e;return/^[!-~]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[!-~]")),e===null&&(e=H()),e}function H(){var e;return/^[\x80-\uFFFF]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[\\x80-\\uFFFF]")),e}function Z(){var e;return/^[\x80-\xBF]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[\\x80-\\xBF]")),e}function U(){var e;return e=T(),e===null&&(/^[a-f]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[a-f]"))),e}function P(){var e,l,u;if(u=n,l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,h('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,h('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,h('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,h('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,h('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,h('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,h(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,h('"~"')))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,h('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,h('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,h('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,h('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,h('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,h('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,h(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,h('"~"'))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(n,f)}(u)),e===null&&(n=u),e}function se(){var e,l,u;if(u=n,l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,h('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,h('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,h('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,h('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,h('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,h(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,h('"~"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,h('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,h('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,h('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,h('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,h('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,h(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,h('"~"')))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(n,f)}(u)),e===null&&(n=u),e}function rt(){var e;return o.charCodeAt(n)===40?(e="(",n++):(e=null,h('"("')),e===null&&(o.charCodeAt(n)===41?(e=")",n++):(e=null,h('")"')),e===null&&(o.charCodeAt(n)===60?(e="<",n++):(e=null,h('"<"')),e===null&&(o.charCodeAt(n)===62?(e=">",n++):(e=null,h('">"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,h('"@"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,h('","')),e===null&&(o.charCodeAt(n)===59?(e=";",n++):(e=null,h('";"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,h('":"')),e===null&&(o.charCodeAt(n)===92?(e="\\",n++):(e=null,h('"\\\\"')),e===null&&(e=I(),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,h('"/"')),e===null&&(o.charCodeAt(n)===91?(e="[",n++):(e=null,h('"["')),e===null&&(o.charCodeAt(n)===93?(e="]",n++):(e=null,h('"]"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,h('"?"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,h('"="')),e===null&&(o.charCodeAt(n)===123?(e="{",n++):(e=null,h('"{"')),e===null&&(o.charCodeAt(n)===125?(e="}",n++):(e=null,h('"}"')),e===null&&(e=$(),e===null&&(e=L())))))))))))))))))),e}function ee(){var e,l,u;if(u=n,l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,h('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,h('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,h('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,h('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,h('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,h('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,h(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,h('"~"')),l===null&&(o.charCodeAt(n)===40?(l="(",n++):(l=null,h('"("')),l===null&&(o.charCodeAt(n)===41?(l=")",n++):(l=null,h('")"')),l===null&&(o.charCodeAt(n)===60?(l="<",n++):(l=null,h('"<"')),l===null&&(o.charCodeAt(n)===62?(l=">",n++):(l=null,h('">"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l===null&&(o.charCodeAt(n)===92?(l="\\",n++):(l=null,h('"\\\\"')),l===null&&(l=I(),l===null&&(o.charCodeAt(n)===47?(l="/",n++):(l=null,h('"/"')),l===null&&(o.charCodeAt(n)===91?(l="[",n++):(l=null,h('"["')),l===null&&(o.charCodeAt(n)===93?(l="]",n++):(l=null,h('"]"')),l===null&&(o.charCodeAt(n)===63?(l="?",n++):(l=null,h('"?"')),l===null&&(o.charCodeAt(n)===123?(l="{",n++):(l=null,h('"{"')),l===null&&(o.charCodeAt(n)===125?(l="}",n++):(l=null,h('"}"'))))))))))))))))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ae(),l===null&&(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l===null&&(o.charCodeAt(n)===46?(l=".",n++):(l=null,h('"."')),l===null&&(o.charCodeAt(n)===33?(l="!",n++):(l=null,h('"!"')),l===null&&(o.charCodeAt(n)===37?(l="%",n++):(l=null,h('"%"')),l===null&&(o.charCodeAt(n)===42?(l="*",n++):(l=null,h('"*"')),l===null&&(o.charCodeAt(n)===95?(l="_",n++):(l=null,h('"_"')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===96?(l="`",n++):(l=null,h('"`"')),l===null&&(o.charCodeAt(n)===39?(l="'",n++):(l=null,h(`"'"`)),l===null&&(o.charCodeAt(n)===126?(l="~",n++):(l=null,h('"~"')),l===null&&(o.charCodeAt(n)===40?(l="(",n++):(l=null,h('"("')),l===null&&(o.charCodeAt(n)===41?(l=")",n++):(l=null,h('")"')),l===null&&(o.charCodeAt(n)===60?(l="<",n++):(l=null,h('"<"')),l===null&&(o.charCodeAt(n)===62?(l=">",n++):(l=null,h('">"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l===null&&(o.charCodeAt(n)===92?(l="\\",n++):(l=null,h('"\\\\"')),l===null&&(l=I(),l===null&&(o.charCodeAt(n)===47?(l="/",n++):(l=null,h('"/"')),l===null&&(o.charCodeAt(n)===91?(l="[",n++):(l=null,h('"["')),l===null&&(o.charCodeAt(n)===93?(l="]",n++):(l=null,h('"]"')),l===null&&(o.charCodeAt(n)===63?(l="?",n++):(l=null,h('"?"')),l===null&&(o.charCodeAt(n)===123?(l="{",n++):(l=null,h('"{"')),l===null&&(o.charCodeAt(n)===125?(l="}",n++):(l=null,h('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(n,f)}(u)),e===null&&(n=u),e}function Y(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===42?(l="*",n++):(l=null,h('"*"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return"*"}()),e===null&&(n=f),e}function G(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===47?(l="/",n++):(l=null,h('"/"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return"/"}()),e===null&&(n=f),e}function re(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return"="}()),e===null&&(n=f),e}function ge(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===40?(l="(",n++):(l=null,h('"("')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return"("}()),e===null&&(n=f),e}function be(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===41?(l=")",n++):(l=null,h('")"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return")"}()),e===null&&(n=f),e}function xe(){var e,l,u,f;return u=n,f=n,o.charCodeAt(n)===62?(e=">",n++):(e=null,h('">"')),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d){return">"}()),e===null&&(n=u),e}function Re(){var e,l,u,f;return u=n,f=n,e=D(),e!==null?(o.charCodeAt(n)===60?(l="<",n++):(l=null,h('"<"')),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d){return"<"}()),e===null&&(n=u),e}function le(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===44?(l=",",n++):(l=null,h('","')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return","}()),e===null&&(n=f),e}function ye(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===59?(l=";",n++):(l=null,h('";"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return";"}()),e===null&&(n=f),e}function it(){var e,l,u,f,d;return f=n,d=n,e=D(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return":"}()),e===null&&(n=f),e}function ot(){var e,l,u,f;return u=n,f=n,e=D(),e!==null?(l=I(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d){return'"'}()),e===null&&(n=u),e}function Ee(){var e,l,u,f;return u=n,f=n,e=I(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d){return'"'}()),e===null&&(n=u),e}function Ae(){var e,l,u,f;if(f=n,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,n=f)):(e=null,n=f)}else e=null,n=f;return e}function Ie(){var e;return/^[!-']/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[!-']")),e===null&&(/^[*-[]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[*-[]")),e===null&&(/^[\]-~]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[\\]-~]")),e===null&&(e=H(),e===null&&(e=M())))),e}function Oe(){var e,l,u,f,d,m;if(d=n,m=n,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=he(),f===null&&(f=de());f!==null;)u.push(f),f=he(),f===null&&(f=de());u!==null?(f=I(),f!==null?e=[e,l,u,f]:(e=null,n=m)):(e=null,n=m)}else e=null,n=m;else e=null,n=m;return e!==null&&(e=function(v){return o.substring(n,v)}(d)),e===null&&(n=d),e}function pe(){var e,l,u,f,d,m;if(d=n,m=n,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=he(),f===null&&(f=de());f!==null;)u.push(f),f=he(),f===null&&(f=de());u!==null?(f=I(),f!==null?e=[e,l,u,f]:(e=null,n=m)):(e=null,n=m)}else e=null,n=m;else e=null,n=m;return e!==null&&(e=function(v){var S=o.substring(n,v).trim();return S.substring(1,S.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(d)),e===null&&(n=d),e}function he(){var e;return e=M(),e===null&&(o.charCodeAt(n)===33?(e="!",n++):(e=null,h('"!"')),e===null&&(/^[#-[]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[#-[]")),e===null&&(/^[\]-~]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[\\]-~]")),e===null&&(e=H())))),e}function de(){var e,l,u;return u=n,o.charCodeAt(n)===92?(e="\\",n++):(e=null,h('"\\\\"')),e!==null?(/^[\0-\t]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,h("[\\0-\\t]")),l===null&&(/^[\x0B-\f]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,h("[\\x0B-\\f]")),l===null&&(/^[\x0E-]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,h("[\\x0E-]")))),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function we(){var e,l,u,f,d,m;return d=n,m=n,e=et(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=ns(),f!==null?e=[e,l,u,f]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e!==null&&(e=function(v){try{w.uri=new Es(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&&(n=d),e}function Ne(){var e,l,u,f,d,m,v,S;return v=n,S=n,e=et(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=At(),u=u!==null?u:"",u!==null?(f=ns(),f!==null?(d=Gn(),d!==null?(m=an(),m=m!==null?m:"",m!==null?e=[e,l,u,f,d,m]:(e=null,n=S)):(e=null,n=S)):(e=null,n=S)):(e=null,n=S)):(e=null,n=S)):(e=null,n=S),e!==null&&(e=function(O){try{w.uri=new Es(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&&(n=v),e}function et(){var e;return e=He(),e===null&&(e=Ft()),e}function He(){var e,l;return l=n,o.substr(n,4).toLowerCase()==="sips"?(e=o.substr(n,4),n+=4):(e=null,h('"sips"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(n=l),e}function Ft(){var e,l;return l=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,h('"sip"')),e!==null&&(e=function(u,f){w.scheme=f.toLowerCase()}(l,e)),e===null&&(n=l),e}function At(){var e,l,u,f,d,m;return f=n,d=n,e=jn(),e!==null?(m=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=rn(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?(o.charCodeAt(n)===64?(u="@",n++):(u=null,h('"@"')),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(v){w.user=decodeURIComponent(o.substring(n-1,v))}(f)),e===null&&(n=f),e}function jn(){var e,l;if(l=F(),l===null&&(l=ve(),l===null&&(l=Vn())),l!==null)for(e=[];l!==null;)e.push(l),l=F(),l===null&&(l=ve(),l===null&&(l=Vn()));else e=null;return e}function Vn(){var e;return o.charCodeAt(n)===38?(e="&",n++):(e=null,h('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,h('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,h('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,h('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,h('","')),e===null&&(o.charCodeAt(n)===59?(e=";",n++):(e=null,h('";"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,h('"?"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,h('"/"'))))))))),e}function rn(){var e,l,u;for(u=n,e=[],l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,h('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,h('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,h('","'))))))));l!==null;)e.push(l),l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,h('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,h('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,h('","'))))))));return e!==null&&(e=function(f){w.password=o.substring(n,f)}(u)),e===null&&(n=u),e}function ns(){var e,l,u,f,d;return f=n,e=Ts(),e!==null?(d=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=ri(),u!==null?l=[l,u]:(l=null,n=d)):(l=null,n=d),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function Ts(){var e,l;return l=n,e=ln(),e===null&&(e=Jt(),e===null&&(e=on())),e!==null&&(e=function(u){return w.host=o.substring(n,u).toLowerCase(),w.host}(l)),e===null&&(n=l),e}function ln(){var e,l,u,f,d,m;for(f=n,d=n,e=[],m=n,l=qn(),l!==null?(o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."')),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m);l!==null;)e.push(l),m=n,l=qn(),l!==null?(o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."')),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m);return e!==null?(l=Bn(),l!==null?(o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(v){return w.host_type="domain",o.substring(n,v)}(f)),e===null&&(n=f),e}function qn(){var e,l,u,f;if(f=n,e=ae(),e!==null){for(l=[],u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,h('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,h('"_"'))));u!==null;)l.push(u),u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,h('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,h('"_"'))));l!==null?e=[e,l]:(e=null,n=f)}else e=null,n=f;return e}function Bn(){var e,l,u,f;if(f=n,e=E(),e!==null){for(l=[],u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,h('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,h('"_"'))));u!==null;)l.push(u),u=ae(),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,h('"-"')),u===null&&(o.charCodeAt(n)===95?(u="_",n++):(u=null,h('"_"'))));l!==null?e=[e,l]:(e=null,n=f)}else e=null,n=f;return e}function on(){var e,l,u,f,d;return f=n,d=n,o.charCodeAt(n)===91?(e="[",n++):(e=null,h('"["')),e!==null?(l=me(),l!==null?(o.charCodeAt(n)===93?(u="]",n++):(u=null,h('"]"')),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m){return w.host_type="IPv6",o.substring(n,m)}(f)),e===null&&(n=f),e}function me(){var e,l,u,f,d,m,v,S,O,ie,Ue,Ot,Bs,k,R,Te;return k=n,R=n,e=oe(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?(o.charCodeAt(n)===58?(f=":",n++):(f=null,h('":"')),f!==null?(d=oe(),d!==null?(o.charCodeAt(n)===58?(m=":",n++):(m=null,h('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(n)===58?(S=":",n++):(S=null,h('":"')),S!==null?(O=oe(),O!==null?(o.charCodeAt(n)===58?(ie=":",n++):(ie=null,h('":"')),ie!==null?(Ue=oe(),Ue!==null?(o.charCodeAt(n)===58?(Ot=":",n++):(Ot=null,h('":"')),Ot!==null?(Bs=at(),Bs!==null?e=[e,l,u,f,d,m,v,S,O,ie,Ue,Ot,Bs]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,h('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(n)===58?(O=":",n++):(O=null,h('":"')),O!==null?(ie=oe(),ie!==null?(o.charCodeAt(n)===58?(Ue=":",n++):(Ue=null,h('":"')),Ue!==null?(Ot=at(),Ot!==null?e=[e,l,u,f,d,m,v,S,O,ie,Ue,Ot]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,h('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(n)===58?(O=":",n++):(O=null,h('":"')),O!==null?(ie=at(),ie!==null?e=[e,l,u,f,d,m,v,S,O,ie]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,h('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=at(),S!==null?e=[e,l,u,f,d,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,h('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=at(),m!==null?e=[e,l,u,f,d,m]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,h('"::"')),e!==null?(l=oe(),l!==null?(o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=at(),f!==null?e=[e,l,u,f]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,h('"::"')),e!==null?(l=at(),l!==null?e=[e,l]:(e=null,n=R)):(e=null,n=R),e===null&&(R=n,o.substr(n,2)==="::"?(e="::",n+=2):(e=null,h('"::"')),e!==null?(l=oe(),l!==null?e=[e,l]:(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(o.substr(n,2)==="::"?(l="::",n+=2):(l=null,h('"::"')),l!==null?(u=oe(),u!==null?(o.charCodeAt(n)===58?(f=":",n++):(f=null,h('":"')),f!==null?(d=oe(),d!==null?(o.charCodeAt(n)===58?(m=":",n++):(m=null,h('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(n)===58?(S=":",n++):(S=null,h('":"')),S!==null?(O=oe(),O!==null?(o.charCodeAt(n)===58?(ie=":",n++):(ie=null,h('":"')),ie!==null?(Ue=at(),Ue!==null?e=[e,l,u,f,d,m,v,S,O,ie,Ue]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(o.substr(n,2)==="::"?(u="::",n+=2):(u=null,h('"::"')),u!==null?(f=oe(),f!==null?(o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=oe(),S!==null?(o.charCodeAt(n)===58?(O=":",n++):(O=null,h('":"')),O!==null?(ie=at(),ie!==null?e=[e,l,u,f,d,m,v,S,O,ie]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(o.substr(n,2)==="::"?(f="::",n+=2):(f=null,h('"::"')),f!==null?(d=oe(),d!==null?(o.charCodeAt(n)===58?(m=":",n++):(m=null,h('":"')),m!==null?(v=oe(),v!==null?(o.charCodeAt(n)===58?(S=":",n++):(S=null,h('":"')),S!==null?(O=at(),O!==null?e=[e,l,u,f,d,m,v,S,O]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,h('":"')),f!==null?(d=oe(),d!==null?f=[f,d]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(o.substr(n,2)==="::"?(d="::",n+=2):(d=null,h('"::"')),d!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=at(),S!==null?e=[e,l,u,f,d,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,h('":"')),f!==null?(d=oe(),d!==null?f=[f,d]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=oe(),m!==null?d=[d,m]:(d=null,n=Te)):(d=null,n=Te),d=d!==null?d:"",d!==null?(o.substr(n,2)==="::"?(m="::",n+=2):(m=null,h('"::"')),m!==null?(v=at(),v!==null?e=[e,l,u,f,d,m,v]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,h('":"')),f!==null?(d=oe(),d!==null?f=[f,d]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=oe(),m!==null?d=[d,m]:(d=null,n=Te)):(d=null,n=Te),d=d!==null?d:"",d!==null?(Te=n,o.charCodeAt(n)===58?(m=":",n++):(m=null,h('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,n=Te)):(m=null,n=Te),m=m!==null?m:"",m!==null?(o.substr(n,2)==="::"?(v="::",n+=2):(v=null,h('"::"')),v!==null?(S=oe(),S!==null?e=[e,l,u,f,d,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R),e===null&&(R=n,e=oe(),e!==null?(Te=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?l=[l,u]:(l=null,n=Te)):(l=null,n=Te),l=l!==null?l:"",l!==null?(Te=n,o.charCodeAt(n)===58?(u=":",n++):(u=null,h('":"')),u!==null?(f=oe(),f!==null?u=[u,f]:(u=null,n=Te)):(u=null,n=Te),u=u!==null?u:"",u!==null?(Te=n,o.charCodeAt(n)===58?(f=":",n++):(f=null,h('":"')),f!==null?(d=oe(),d!==null?f=[f,d]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(d=":",n++):(d=null,h('":"')),d!==null?(m=oe(),m!==null?d=[d,m]:(d=null,n=Te)):(d=null,n=Te),d=d!==null?d:"",d!==null?(Te=n,o.charCodeAt(n)===58?(m=":",n++):(m=null,h('":"')),m!==null?(v=oe(),v!==null?m=[m,v]:(m=null,n=Te)):(m=null,n=Te),m=m!==null?m:"",m!==null?(Te=n,o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=oe(),S!==null?v=[v,S]:(v=null,n=Te)):(v=null,n=Te),v=v!==null?v:"",v!==null?(o.substr(n,2)==="::"?(S="::",n+=2):(S=null,h('"::"')),S!==null?e=[e,l,u,f,d,m,v,S]:(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R)):(e=null,n=R))))))))))))))),e!==null&&(e=function(Pv){return w.host_type="IPv6",o.substring(n,Pv)}(k)),e===null&&(n=k),e}function oe(){var e,l,u,f,d;return d=n,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,n=d)):(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e}function at(){var e,l,u,f;return f=n,e=oe(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=oe(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e===null&&(e=Jt()),e}function Jt(){var e,l,u,f,d,m,v,S,O;return S=n,O=n,e=Ps(),e!==null?(o.charCodeAt(n)===46?(l=".",n++):(l=null,h('"."')),l!==null?(u=Ps(),u!==null?(o.charCodeAt(n)===46?(f=".",n++):(f=null,h('"."')),f!==null?(d=Ps(),d!==null?(o.charCodeAt(n)===46?(m=".",n++):(m=null,h('"."')),m!==null?(v=Ps(),v!==null?e=[e,l,u,f,d,m,v]:(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O)):(e=null,n=O),e!==null&&(e=function(ie){return w.host_type="IPv4",o.substring(n,ie)}(S)),e===null&&(n=S),e}function Ps(){var e,l,u,f;return f=n,o.substr(n,2)==="25"?(e="25",n+=2):(e=null,h('"25"')),e!==null?(/^[0-5]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,h("[0-5]")),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e===null&&(f=n,o.charCodeAt(n)===50?(e="2",n++):(e=null,h('"2"')),e!==null?(/^[0-4]/.test(o.charAt(n))?(l=o.charAt(n),n++):(l=null,h("[0-4]")),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e===null&&(f=n,o.charCodeAt(n)===49?(e="1",n++):(e=null,h('"1"')),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e===null&&(f=n,/^[1-9]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[1-9]")),e!==null?(l=T(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e===null&&(e=T())))),e}function ri(){var e,l,u,f,d,m,v;return m=n,v=n,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?(d=T(),d=d!==null?d:"",d!==null?e=[e,l,u,f,d]:(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(S,O){return O=parseInt(O.join("")),w.port=O,O}(m,e)),e===null&&(n=m),e}function Gn(){var e,l,u,f;for(e=[],f=n,o.charCodeAt(n)===59?(l=";",n++):(l=null,h('";"')),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,n=f)):(l=null,n=f);l!==null;)e.push(l),f=n,o.charCodeAt(n)===59?(l=";",n++):(l=null,h('";"')),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,n=f)):(l=null,n=f);return e}function Wn(){var e;return e=ii(),e===null&&(e=li(),e===null&&(e=oi(),e===null&&(e=ai(),e===null&&(e=ui(),e===null&&(e=ci(),e===null&&(e=fi())))))),e}function ii(){var e,l,u,f;return u=n,f=n,o.substr(n,10).toLowerCase()==="transport="?(e=o.substr(n,10),n+=10):(e=null,h('"transport="')),e!==null?(o.substr(n,3).toLowerCase()==="udp"?(l=o.substr(n,3),n+=3):(l=null,h('"udp"')),l===null&&(o.substr(n,3).toLowerCase()==="tcp"?(l=o.substr(n,3),n+=3):(l=null,h('"tcp"')),l===null&&(o.substr(n,4).toLowerCase()==="sctp"?(l=o.substr(n,4),n+=4):(l=null,h('"sctp"')),l===null&&(o.substr(n,3).toLowerCase()==="tls"?(l=o.substr(n,3),n+=3):(l=null,h('"tls"')),l===null&&(l=P())))),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d,m){w.uri_params||(w.uri_params={}),w.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(n=u),e}function li(){var e,l,u,f;return u=n,f=n,o.substr(n,5).toLowerCase()==="user="?(e=o.substr(n,5),n+=5):(e=null,h('"user="')),e!==null?(o.substr(n,5).toLowerCase()==="phone"?(l=o.substr(n,5),n+=5):(l=null,h('"phone"')),l===null&&(o.substr(n,2).toLowerCase()==="ip"?(l=o.substr(n,2),n+=2):(l=null,h('"ip"')),l===null&&(l=P())),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d,m){w.uri_params||(w.uri_params={}),w.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(n=u),e}function oi(){var e,l,u,f;return u=n,f=n,o.substr(n,7).toLowerCase()==="method="?(e=o.substr(n,7),n+=7):(e=null,h('"method="')),e!==null?(l=pn(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d,m){w.uri_params||(w.uri_params={}),w.uri_params.method=m}(u,e[1])),e===null&&(n=u),e}function ai(){var e,l,u,f;return u=n,f=n,o.substr(n,4).toLowerCase()==="ttl="?(e=o.substr(n,4),n+=4):(e=null,h('"ttl="')),e!==null?(l=al(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d,m){w.params||(w.params={}),w.params.ttl=m}(u,e[1])),e===null&&(n=u),e}function ui(){var e,l,u,f;return u=n,f=n,o.substr(n,6).toLowerCase()==="maddr="?(e=o.substr(n,6),n+=6):(e=null,h('"maddr="')),e!==null?(l=Ts(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(d,m){w.uri_params||(w.uri_params={}),w.uri_params.maddr=m}(u,e[1])),e===null&&(n=u),e}function ci(){var e,l,u,f,d,m;return f=n,d=n,o.substr(n,2).toLowerCase()==="lr"?(e=o.substr(n,2),n+=2):(e=null,h('"lr"')),e!==null?(m=n,o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(v){w.uri_params||(w.uri_params={}),w.uri_params.lr=void 0}()),e===null&&(n=f),e}function fi(){var e,l,u,f,d,m;return f=n,d=n,e=_i(),e!==null?(m=n,o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l!==null?(u=xs(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=d)):(e=null,n=d),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&&(n=f),e}function _i(){var e,l,u;if(u=n,l=Ms(),l!==null)for(e=[];l!==null;)e.push(l),l=Ms();else e=null;return e!==null&&(e=function(f,d){return d.join("")}(u,e)),e===null&&(n=u),e}function xs(){var e,l,u;if(u=n,l=Ms(),l!==null)for(e=[];l!==null;)e.push(l),l=Ms();else e=null;return e!==null&&(e=function(f,d){return d.join("")}(u,e)),e===null&&(n=u),e}function Ms(){var e;return e=hi(),e===null&&(e=F(),e===null&&(e=ve())),e}function hi(){var e;return o.charCodeAt(n)===91?(e="[",n++):(e=null,h('"["')),e===null&&(o.charCodeAt(n)===93?(e="]",n++):(e=null,h('"]"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,h('"/"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,h('":"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,h('"&"')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,h('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,h('"$"')))))))),e}function an(){var e,l,u,f,d,m,v;if(m=n,o.charCodeAt(n)===63?(e="?",n++):(e=null,h('"?"')),e!==null)if(l=un(),l!==null){for(u=[],v=n,o.charCodeAt(n)===38?(f="&",n++):(f=null,h('"&"')),f!==null?(d=un(),d!==null?f=[f,d]:(f=null,n=v)):(f=null,n=v);f!==null;)u.push(f),v=n,o.charCodeAt(n)===38?(f="&",n++):(f=null,h('"&"')),f!==null?(d=un(),d!==null?f=[f,d]:(f=null,n=v)):(f=null,n=v);u!==null?e=[e,l,u]:(e=null,n=m)}else e=null,n=m;else e=null,n=m;return e}function un(){var e,l,u,f,d;return f=n,d=n,e=di(),e!==null?(o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l!==null?(u=ks(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),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&&(n=f),e}function di(){var e,l;if(l=cn(),l===null&&(l=F(),l===null&&(l=ve())),l!==null)for(e=[];l!==null;)e.push(l),l=cn(),l===null&&(l=F(),l===null&&(l=ve()));else e=null;return e}function ks(){var e,l;for(e=[],l=cn(),l===null&&(l=F(),l===null&&(l=ve()));l!==null;)e.push(l),l=cn(),l===null&&(l=F(),l===null&&(l=ve()));return e}function cn(){var e;return o.charCodeAt(n)===91?(e="[",n++):(e=null,h('"["')),e===null&&(o.charCodeAt(n)===93?(e="]",n++):(e=null,h('"]"')),e===null&&(o.charCodeAt(n)===47?(e="/",n++):(e=null,h('"/"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,h('"?"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,h('":"')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,h('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,h('"$"')))))))),e}function yo(){var e;return e=Di(),e===null&&(e=pi()),e}function pi(){var e,l,u,f,d,m;return m=n,e=pn(),e!==null?(l=$(),l!==null?(u=Kn(),u!==null?(f=$(),f!==null?(d=zn(),d!==null?e=[e,l,u,f,d]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function Kn(){var e;return e=Ne(),e===null&&(e=Yn()),e}function Yn(){var e,l,u,f;return f=n,e=Ti(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=mi(),u===null&&(u=Ls()),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function mi(){var e,l,u,f,d;return f=n,e=fn(),e===null&&(e=_n()),e!==null?(d=n,o.charCodeAt(n)===63?(l="?",n++):(l=null,h('"?"')),l!==null?(u=Jn(),u!==null?l=[l,u]:(l=null,n=d)):(l=null,n=d),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function fn(){var e,l,u,f;return f=n,o.substr(n,2)==="//"?(e="//",n+=2):(e=null,h('"//"')),e!==null?(l=vi(),l!==null?(u=_n(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function _n(){var e,l,u;return u=n,o.charCodeAt(n)===47?(e="/",n++):(e=null,h('"/"')),e!==null?(l=hn(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function Ls(){var e,l,u,f;if(f=n,e=gi(),e!==null){for(l=[],u=$s();u!==null;)l.push(u),u=$s();l!==null?e=[e,l]:(e=null,n=f)}else e=null,n=f;return e}function $s(){var e;return e=N(),e===null&&(e=F(),e===null&&(e=ve())),e}function gi(){var e;return e=F(),e===null&&(e=ve(),e===null&&(o.charCodeAt(n)===59?(e=";",n++):(e=null,h('";"')),e===null&&(o.charCodeAt(n)===63?(e="?",n++):(e=null,h('"?"')),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,h('":"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,h('"@"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,h('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,h('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,h('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,h('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,h('","')))))))))))),e}function hn(){var e,l,u,f,d,m;if(d=n,e=Hs(),e!==null){for(l=[],m=n,o.charCodeAt(n)===47?(u="/",n++):(u=null,h('"/"')),u!==null?(f=Hs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,o.charCodeAt(n)===47?(u="/",n++):(u=null,h('"/"')),u!==null?(f=Hs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function Hs(){var e,l,u,f,d,m;for(d=n,e=[],l=Fs();l!==null;)e.push(l),l=Fs();if(e!==null){for(l=[],m=n,o.charCodeAt(n)===59?(u=";",n++):(u=null,h('";"')),u!==null?(f=vs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,o.charCodeAt(n)===59?(u=";",n++):(u=null,h('";"')),u!==null?(f=vs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function vs(){var e,l;for(e=[],l=Fs();l!==null;)e.push(l),l=Fs();return e}function Fs(){var e;return e=F(),e===null&&(e=ve(),e===null&&(o.charCodeAt(n)===58?(e=":",n++):(e=null,h('":"')),e===null&&(o.charCodeAt(n)===64?(e="@",n++):(e=null,h('"@"')),e===null&&(o.charCodeAt(n)===38?(e="&",n++):(e=null,h('"&"')),e===null&&(o.charCodeAt(n)===61?(e="=",n++):(e=null,h('"="')),e===null&&(o.charCodeAt(n)===43?(e="+",n++):(e=null,h('"+"')),e===null&&(o.charCodeAt(n)===36?(e="$",n++):(e=null,h('"$"')),e===null&&(o.charCodeAt(n)===44?(e=",",n++):(e=null,h('","')))))))))),e}function Ti(){var e,l,u,f,d;if(f=n,d=n,e=E(),e!==null){for(l=[],u=E(),u===null&&(u=T(),u===null&&(o.charCodeAt(n)===43?(u="+",n++):(u=null,h('"+"')),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,h('"-"')),u===null&&(o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."'))))));u!==null;)l.push(u),u=E(),u===null&&(u=T(),u===null&&(o.charCodeAt(n)===43?(u="+",n++):(u=null,h('"+"')),u===null&&(o.charCodeAt(n)===45?(u="-",n++):(u=null,h('"-"')),u===null&&(o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."'))))));l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e!==null&&(e=function(m){w.scheme=o.substring(n,m)}(f)),e===null&&(n=f),e}function vi(){var e;return e=Ei(),e===null&&(e=Si()),e}function Ei(){var e,l,u,f;return u=n,f=n,e=At(),e!==null?(o.charCodeAt(n)===64?(l="@",n++):(l=null,h('"@"')),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e=e!==null?e:"",e!==null?(l=ns(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e=e!==null?e:"",e}function Si(){var e,l;if(l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,h('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,h('","')),l===null&&(o.charCodeAt(n)===59?(l=";",n++):(l=null,h('";"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l===null&&(o.charCodeAt(n)===64?(l="@",n++):(l=null,h('"@"')),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,h('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=F(),l===null&&(l=ve(),l===null&&(o.charCodeAt(n)===36?(l="$",n++):(l=null,h('"$"')),l===null&&(o.charCodeAt(n)===44?(l=",",n++):(l=null,h('","')),l===null&&(o.charCodeAt(n)===59?(l=";",n++):(l=null,h('";"')),l===null&&(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l===null&&(o.charCodeAt(n)===64?(l="@",n++):(l=null,h('"@"')),l===null&&(o.charCodeAt(n)===38?(l="&",n++):(l=null,h('"&"')),l===null&&(o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l===null&&(o.charCodeAt(n)===43?(l="+",n++):(l=null,h('"+"')))))))))));else e=null;return e}function Jn(){var e,l;for(e=[],l=$s();l!==null;)e.push(l),l=$s();return e}function zn(){var e,l,u,f,d,m,v,S;if(v=n,S=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,h('"SIP"')),e!==null)if(o.charCodeAt(n)===47?(l="/",n++):(l=null,h('"/"')),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(n)===46?(f=".",n++):(f=null,h('"."')),f!==null){if(m=T(),m!==null)for(d=[];m!==null;)d.push(m),m=T();else d=null;d!==null?e=[e,l,u,f,d]:(e=null,n=S)}else e=null,n=S;else e=null,n=S}else e=null,n=S;else e=null,n=S;return e!==null&&(e=function(O){w.sip_version=o.substring(n,O)}(v)),e===null&&(n=v),e}function yi(){var e;return o.substr(n,6)==="INVITE"?(e="INVITE",n+=6):(e=null,h('"INVITE"')),e}function Ai(){var e;return o.substr(n,3)==="ACK"?(e="ACK",n+=3):(e=null,h('"ACK"')),e}function Ci(){var e;return o.substr(n,7)==="OPTIONS"?(e="OPTIONS",n+=7):(e=null,h('"OPTIONS"')),e}function Ri(){var e;return o.substr(n,3)==="BYE"?(e="BYE",n+=3):(e=null,h('"BYE"')),e}function Ii(){var e;return o.substr(n,6)==="CANCEL"?(e="CANCEL",n+=6):(e=null,h('"CANCEL"')),e}function bi(){var e;return o.substr(n,8)==="REGISTER"?(e="REGISTER",n+=8):(e=null,h('"REGISTER"')),e}function wi(){var e;return o.substr(n,9)==="SUBSCRIBE"?(e="SUBSCRIBE",n+=9):(e=null,h('"SUBSCRIBE"')),e}function Oi(){var e;return o.substr(n,6)==="NOTIFY"?(e="NOTIFY",n+=6):(e=null,h('"NOTIFY"')),e}function dn(){var e;return o.substr(n,5)==="REFER"?(e="REFER",n+=5):(e=null,h('"REFER"')),e}function pn(){var e,l;return l=n,e=yi(),e===null&&(e=Ai(),e===null&&(e=Ci(),e===null&&(e=Ri(),e===null&&(e=Ii(),e===null&&(e=bi(),e===null&&(e=wi(),e===null&&(e=Oi(),e===null&&(e=dn(),e===null&&(e=P()))))))))),e!==null&&(e=function(u){return w.method=o.substring(n,u),w.method}(l)),e===null&&(n=l),e}function Di(){var e,l,u,f,d,m;return m=n,e=zn(),e!==null?(l=$(),l!==null?(u=Ni(),u!==null?(f=$(),f!==null?(d=Ao(),d!==null?e=[e,l,u,f,d]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function Ni(){var e,l;return l=n,e=Ui(),e!==null&&(e=function(u,f){w.status_code=parseInt(f.join(""))}(l,e)),e===null&&(n=l),e}function Ui(){var e,l,u,f;return f=n,e=T(),e!==null?(l=T(),l!==null?(u=T(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Ao(){var e,l,u;for(u=n,e=[],l=N(),l===null&&(l=F(),l===null&&(l=ve(),l===null&&(l=H(),l===null&&(l=Z(),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=Z(),l===null&&(l=$(),l===null&&(l=L()))))));return e!==null&&(e=function(f){w.reason_phrase=o.substring(n,f)}(u)),e===null&&(n=u),e}function Au(){var e,l,u,f,d,m;if(d=n,e=vn(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=vn(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=vn(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function Cu(){var e,l,u,f,d,m;return f=n,d=n,e=ee(),e!==null?(m=n,o.charCodeAt(n)===64?(l="@",n++):(l=null,h('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(v){w=o.substring(n,v)}(f)),e===null&&(n=f),e}function Xn(){var e,l,u,f,d,m,v;if(d=n,e=Y(),e===null)if(m=n,e=jt(),e!==null){for(l=[],v=n,u=le(),u!==null?(f=jt(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=le(),u!==null?(f=jt(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=d),e}function jt(){var e,l,u,f,d,m,v;if(d=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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:n,offset:S,parsed:O})}(d)),e===null&&(n=d),e}function Vt(){var e,l,u,f,d;return d=n,e=js(),e=e!==null?e:"",e!==null?(l=Re(),l!==null?(u=Ne(),u!==null?(f=xe(),f!==null?e=[e,l,u,f]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e}function js(){var e,l,u,f,d,m,v;if(d=n,m=n,e=P(),e!==null){for(l=[],v=n,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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,Ue){return ie+Ue[0]+Ue[1]},O[0])}(d,e)),e===null&&(n=d),e}function Qn(){var e;return e=Pi(),e===null&&(e=rs(),e===null&&(e=ze())),e}function Pi(){var e,l,u,f,d;return f=n,d=n,o.substr(n,1).toLowerCase()==="q"?(e=o.substr(n,1),n++):(e=null,h('"q"')),e!==null?(l=re(),l!==null?(u=Je(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.q=v}(f,e[2])),e===null&&(n=f),e}function rs(){var e,l,u,f,d;return f=n,d=n,o.substr(n,7).toLowerCase()==="expires"?(e=o.substr(n,7),n+=7):(e=null,h('"expires"')),e!==null?(l=re(),l!==null?(u=is(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.expires=v}(f,e[2])),e===null&&(n=f),e}function is(){var e,l,u;if(u=n,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,d){return parseInt(d.join(""))}(u,e)),e===null&&(n=u),e}function Je(){var e,l,u,f,d,m,v,S;return m=n,v=n,o.charCodeAt(n)===48?(e="0",n++):(e=null,h('"0"')),e!==null?(S=n,o.charCodeAt(n)===46?(l=".",n++):(l=null,h('"."')),l!==null?(u=T(),u=u!==null?u:"",u!==null?(f=T(),f=f!==null?f:"",f!==null?(d=T(),d=d!==null?d:"",d!==null?l=[l,u,f,d]:(l=null,n=S)):(l=null,n=S)):(l=null,n=S)):(l=null,n=S),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(O){return parseFloat(o.substring(n,O))}(m)),e===null&&(n=m),e}function ze(){var e,l,u,f,d,m;return f=n,d=n,e=P(),e!==null?(m=n,l=re(),l!==null?(u=Co(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=d)):(e=null,n=d),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&&(n=f),e}function Co(){var e;return e=P(),e===null&&(e=Ts(),e===null&&(e=Oe())),e}function Ro(){var e,l,u,f,d,m;if(d=n,e=Zn(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=er(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function Zn(){var e;return o.substr(n,6).toLowerCase()==="render"?(e=o.substr(n,6),n+=6):(e=null,h('"render"')),e===null&&(o.substr(n,7).toLowerCase()==="session"?(e=o.substr(n,7),n+=7):(e=null,h('"session"')),e===null&&(o.substr(n,4).toLowerCase()==="icon"?(e=o.substr(n,4),n+=4):(e=null,h('"icon"')),e===null&&(o.substr(n,5).toLowerCase()==="alert"?(e=o.substr(n,5),n+=5):(e=null,h('"alert"')),e===null&&(e=P())))),e}function er(){var e;return e=Io(),e===null&&(e=ze()),e}function Io(){var e,l,u,f;return f=n,o.substr(n,8).toLowerCase()==="handling"?(e=o.substr(n,8),n+=8):(e=null,h('"handling"')),e!==null?(l=re(),l!==null?(o.substr(n,8).toLowerCase()==="optional"?(u=o.substr(n,8),n+=8):(u=null,h('"optional"')),u===null&&(o.substr(n,8).toLowerCase()==="required"?(u=o.substr(n,8),n+=8):(u=null,h('"required"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Ru(){var e,l,u,f,d,m;if(d=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function Iu(){var e,l,u;if(u=n,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,d){w=parseInt(d.join(""))}(u,e)),e===null&&(n=u),e}function bo(){var e,l;return l=n,e=xi(),e!==null&&(e=function(u){w=o.substring(n,u)}(l)),e===null&&(n=l),e}function xi(){var e,l,u,f,d,m,v,S;if(v=n,e=Mi(),e!==null)if(l=G(),l!==null)if(u=tr(),u!==null){for(f=[],S=n,d=ye(),d!==null?(m=sr(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);d!==null;)f.push(d),S=n,d=ye(),d!==null?(m=sr(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e}function Mi(){var e;return e=ki(),e===null&&(e=mn()),e}function ki(){var e;return o.substr(n,4).toLowerCase()==="text"?(e=o.substr(n,4),n+=4):(e=null,h('"text"')),e===null&&(o.substr(n,5).toLowerCase()==="image"?(e=o.substr(n,5),n+=5):(e=null,h('"image"')),e===null&&(o.substr(n,5).toLowerCase()==="audio"?(e=o.substr(n,5),n+=5):(e=null,h('"audio"')),e===null&&(o.substr(n,5).toLowerCase()==="video"?(e=o.substr(n,5),n+=5):(e=null,h('"video"')),e===null&&(o.substr(n,11).toLowerCase()==="application"?(e=o.substr(n,11),n+=11):(e=null,h('"application"')),e===null&&(e=gn()))))),e}function mn(){var e;return o.substr(n,7).toLowerCase()==="message"?(e=o.substr(n,7),n+=7):(e=null,h('"message"')),e===null&&(o.substr(n,9).toLowerCase()==="multipart"?(e=o.substr(n,9),n+=9):(e=null,h('"multipart"')),e===null&&(e=gn())),e}function gn(){var e;return e=P(),e===null&&(e=Li()),e}function Li(){var e,l,u;return u=n,o.substr(n,2).toLowerCase()==="x-"?(e=o.substr(n,2),n+=2):(e=null,h('"x-"')),e!==null?(l=P(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function tr(){var e;return e=gn(),e===null&&(e=P()),e}function sr(){var e,l,u,f;return f=n,e=P(),e!==null?(l=re(),l!==null?(u=wo(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function wo(){var e;return e=P(),e===null&&(e=Oe()),e}function Oo(){var e,l,u,f;return f=n,e=Do(),e!==null?(l=M(),l!==null?(u=pn(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Do(){var e,l,u;if(u=n,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,d){w.value=parseInt(d.join(""))}(u,e)),e===null&&(n=u),e}function bu(){var e,l;return l=n,e=is(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(n=l),e}function Tn(){var e,l,u,f,d,m,v;if(d=n,m=n,e=vn(),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=m;return e!==null&&(e=function(S,O){w.event=O.join("").toLowerCase()}(d,e[0])),e===null&&(n=d),e}function vn(){var e,l,u,f,d,m;if(d=n,e=se(),e!==null){for(l=[],m=n,o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."')),u!==null?(f=se(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function $i(){var e,l,u,f,d,m,v;if(d=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=En(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=En(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=d),e}function En(){var e;return e=Hi(),e===null&&(e=ze()),e}function Hi(){var e,l,u,f,d;return f=n,d=n,o.substr(n,3).toLowerCase()==="tag"?(e=o.substr(n,3),n+=3):(e=null,h('"tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.tag=v}(f,e[2])),e===null&&(n=f),e}function wu(){var e,l,u;if(u=n,l=T(),l!==null)for(e=[];l!==null;)e.push(l),l=T();else e=null;return e!==null&&(e=function(f,d){w=parseInt(d.join(""))}(u,e)),e===null&&(n=u),e}function Ou(){var e,l;return l=n,e=is(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(n=l),e}function Du(){var e,l,u,f,d,m,v,S,O,ie;for(S=n,O=n,e=[],l=js();l!==null;)e.push(l),l=js();if(e!==null)if(l=Re(),l!==null)if(u=Ne(),u!==null)if(f=xe(),f!==null){for(d=[],ie=n,m=ye(),m!==null?(v=ze(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);m!==null;)d.push(m),ie=n,m=ye(),m!==null?(v=ze(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);d!==null?e=[e,l,u,f,d]:(e=null,n=O)}else e=null,n=O;else e=null,n=O;else e=null,n=O;else e=null,n=O;return e!==null&&(e=function(Ue){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(n=S),e}function Fi(){var e;return e=nr(),e}function nr(){var e,l,u,f,d,m,v,S;if(v=n,o.substr(n,6).toLowerCase()==="digest"?(e=o.substr(n,6),n+=6):(e=null,h('"Digest"')),e!==null)if(l=M(),l!==null)if(u=Sn(),u!==null){for(f=[],S=n,d=le(),d!==null?(m=Sn(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);d!==null;)f.push(d),S=n,d=le(),d!==null?(m=Sn(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e===null&&(e=Vs()),e}function Vs(){var e,l,u,f,d,m,v,S;if(v=n,e=P(),e!==null)if(l=M(),l!==null)if(u=ls(),u!==null){for(f=[],S=n,d=le(),d!==null?(m=ls(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);d!==null;)f.push(d),S=n,d=le(),d!==null?(m=ls(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e}function ls(){var e,l,u,f;return f=n,e=P(),e!==null?(l=re(),l!==null?(u=P(),u===null&&(u=Oe()),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Sn(){var e;return e=ji(),e===null&&(e=yn(),e===null&&(e=qi(),e===null&&(e=Gi(),e===null&&(e=Wi(),e===null&&(e=Ki(),e===null&&(e=Cn(),e===null&&(e=ls()))))))),e}function ji(){var e,l,u,f;return f=n,o.substr(n,5).toLowerCase()==="realm"?(e=o.substr(n,5),n+=5):(e=null,h('"realm"')),e!==null?(l=re(),l!==null?(u=Vi(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Vi(){var e,l;return l=n,e=pe(),e!==null&&(e=function(u,f){w.realm=f}(l,e)),e===null&&(n=l),e}function yn(){var e,l,u,f,d,m,v,S,O;if(S=n,o.substr(n,6).toLowerCase()==="domain"?(e=o.substr(n,6),n+=6):(e=null,h('"domain"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null)if(f=An(),f!==null){if(d=[],O=n,v=$(),v!==null)for(m=[];v!==null;)m.push(v),v=$();else m=null;for(m!==null?(v=An(),v!==null?m=[m,v]:(m=null,n=O)):(m=null,n=O);m!==null;){if(d.push(m),O=n,v=$(),v!==null)for(m=[];v!==null;)m.push(v),v=$();else m=null;m!==null?(v=An(),v!==null?m=[m,v]:(m=null,n=O)):(m=null,n=O)}d!==null?(m=Ee(),m!==null?e=[e,l,u,f,d,m]:(e=null,n=S)):(e=null,n=S)}else e=null,n=S;else e=null,n=S;else e=null,n=S;else e=null,n=S;return e}function An(){var e;return e=Yn(),e===null&&(e=_n()),e}function qi(){var e,l,u,f;return f=n,o.substr(n,5).toLowerCase()==="nonce"?(e=o.substr(n,5),n+=5):(e=null,h('"nonce"')),e!==null?(l=re(),l!==null?(u=Bi(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Bi(){var e,l;return l=n,e=pe(),e!==null&&(e=function(u,f){w.nonce=f}(l,e)),e===null&&(n=l),e}function Gi(){var e,l,u,f,d;return f=n,d=n,o.substr(n,6).toLowerCase()==="opaque"?(e=o.substr(n,6),n+=6):(e=null,h('"opaque"')),e!==null?(l=re(),l!==null?(u=pe(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.opaque=v}(f,e[2])),e===null&&(n=f),e}function Wi(){var e,l,u,f,d;return f=n,o.substr(n,5).toLowerCase()==="stale"?(e=o.substr(n,5),n+=5):(e=null,h('"stale"')),e!==null?(l=re(),l!==null?(d=n,o.substr(n,4).toLowerCase()==="true"?(u=o.substr(n,4),n+=4):(u=null,h('"true"')),u!==null&&(u=function(m){w.stale=!0}()),u===null&&(n=d),u===null&&(d=n,o.substr(n,5).toLowerCase()==="false"?(u=o.substr(n,5),n+=5):(u=null,h('"false"')),u!==null&&(u=function(m){w.stale=!1}()),u===null&&(n=d)),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Ki(){var e,l,u,f,d;return f=n,d=n,o.substr(n,9).toLowerCase()==="algorithm"?(e=o.substr(n,9),n+=9):(e=null,h('"algorithm"')),e!==null?(l=re(),l!==null?(o.substr(n,3).toLowerCase()==="md5"?(u=o.substr(n,3),n+=3):(u=null,h('"MD5"')),u===null&&(o.substr(n,8).toLowerCase()==="md5-sess"?(u=o.substr(n,8),n+=8):(u=null,h('"MD5-sess"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.algorithm=v.toUpperCase()}(f,e[2])),e===null&&(n=f),e}function Cn(){var e,l,u,f,d,m,v,S,O,ie;if(S=n,o.substr(n,3).toLowerCase()==="qop"?(e=o.substr(n,3),n+=3):(e=null,h('"qop"')),e!==null)if(l=re(),l!==null)if(u=ot(),u!==null){if(O=n,f=rr(),f!==null){for(d=[],ie=n,o.charCodeAt(n)===44?(m=",",n++):(m=null,h('","')),m!==null?(v=rr(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);m!==null;)d.push(m),ie=n,o.charCodeAt(n)===44?(m=",",n++):(m=null,h('","')),m!==null?(v=rr(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);d!==null?f=[f,d]:(f=null,n=O)}else f=null,n=O;f!==null?(d=Ee(),d!==null?e=[e,l,u,f,d]:(e=null,n=S)):(e=null,n=S)}else e=null,n=S;else e=null,n=S;else e=null,n=S;return e}function rr(){var e,l;return l=n,o.substr(n,8).toLowerCase()==="auth-int"?(e=o.substr(n,8),n+=8):(e=null,h('"auth-int"')),e===null&&(o.substr(n,4).toLowerCase()==="auth"?(e=o.substr(n,4),n+=4):(e=null,h('"auth"')),e===null&&(e=P())),e!==null&&(e=function(u,f){w.qop||(w.qop=[]),w.qop.push(f.toLowerCase())}(l,e)),e===null&&(n=l),e}function Nu(){var e,l,u,f,d,m;if(d=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function ir(){var e,l,u,f,d,m,v;if(d=n,m=n,e=lr(),e!==null){for(l=[],v=n,u=le(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=le(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=d),e}function lr(){var e,l,u,f,d,m,v;if(d=n,m=n,e=Vt(),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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:n,offset:S,parsed:O})}(d)),e===null&&(n=d),e}function Yi(){var e,l,u,f,d,m,v;if(d=n,m=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,h('"SIP"')),e===null&&(e=P()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=or(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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}}(d,e[0])),e===null&&(n=d),e}function or(){var e;return e=No(),e===null&&(e=ze()),e}function No(){var e,l,u,f,d,m;if(d=n,m=n,o.substr(n,5).toLowerCase()==="cause"?(e=o.substr(n,5),n+=5):(e=null,h('"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,n=m)}else e=null,n=m;else e=null,n=m;return e!==null&&(e=function(v,S){w.cause=parseInt(S.join(""))}(d,e[2])),e===null&&(n=d),e}function Uu(){var e,l,u,f,d,m;if(d=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function ar(){var e,l,u,f,d,m;if(d=n,e=ur(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=ur(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function ur(){var e,l,u,f,d,m;if(d=n,e=Vt(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function Uo(){var e,l,u,f,d,m;if(d=n,e=cr(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=fr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function cr(){var e,l;return l=n,o.substr(n,6).toLowerCase()==="active"?(e=o.substr(n,6),n+=6):(e=null,h('"active"')),e===null&&(o.substr(n,7).toLowerCase()==="pending"?(e=o.substr(n,7),n+=7):(e=null,h('"pending"')),e===null&&(o.substr(n,10).toLowerCase()==="terminated"?(e=o.substr(n,10),n+=10):(e=null,h('"terminated"')),e===null&&(e=P()))),e!==null&&(e=function(u){w.state=o.substring(n,u)}(l)),e===null&&(n=l),e}function fr(){var e,l,u,f,d;return f=n,d=n,o.substr(n,6).toLowerCase()==="reason"?(e=o.substr(n,6),n+=6):(e=null,h('"reason"')),e!==null?(l=re(),l!==null?(u=Po(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){typeof v<"u"&&(w.reason=v)}(f,e[2])),e===null&&(n=f),e===null&&(f=n,d=n,o.substr(n,7).toLowerCase()==="expires"?(e=o.substr(n,7),n+=7):(e=null,h('"expires"')),e!==null?(l=re(),l!==null?(u=is(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){typeof v<"u"&&(w.expires=v)}(f,e[2])),e===null&&(n=f),e===null&&(f=n,d=n,o.substr(n,11).toLowerCase()==="retry_after"?(e=o.substr(n,11),n+=11):(e=null,h('"retry_after"')),e!==null?(l=re(),l!==null?(u=is(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){typeof v<"u"&&(w.retry_after=v)}(f,e[2])),e===null&&(n=f),e===null&&(e=ze()))),e}function Po(){var e;return o.substr(n,11).toLowerCase()==="deactivated"?(e=o.substr(n,11),n+=11):(e=null,h('"deactivated"')),e===null&&(o.substr(n,9).toLowerCase()==="probation"?(e=o.substr(n,9),n+=9):(e=null,h('"probation"')),e===null&&(o.substr(n,8).toLowerCase()==="rejected"?(e=o.substr(n,8),n+=8):(e=null,h('"rejected"')),e===null&&(o.substr(n,7).toLowerCase()==="timeout"?(e=o.substr(n,7),n+=7):(e=null,h('"timeout"')),e===null&&(o.substr(n,6).toLowerCase()==="giveup"?(e=o.substr(n,6),n+=6):(e=null,h('"giveup"')),e===null&&(o.substr(n,10).toLowerCase()==="noresource"?(e=o.substr(n,10),n+=10):(e=null,h('"noresource"')),e===null&&(o.substr(n,9).toLowerCase()==="invariant"?(e=o.substr(n,9),n+=9):(e=null,h('"invariant"')),e===null&&(e=P()))))))),e}function Pu(){var e;return e=q(),e=e!==null?e:"",e}function xu(){var e,l,u,f,d,m;if(d=n,e=P(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e=e!==null?e:"",e}function Ji(){var e,l,u,f,d,m,v;if(d=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=zi(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=zi(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=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&&(n=d),e}function zi(){var e;return e=Hi(),e===null&&(e=ze()),e}function _r(){var e,l,u,f,d,m;if(d=n,e=qs(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=qs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=le(),u!==null?(f=qs(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function qs(){var e,l,u,f,d,m,v,S;if(v=n,e=nl(),e!==null)if(l=M(),l!==null)if(u=ll(),u!==null){for(f=[],S=n,d=ye(),d!==null?(m=hr(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);d!==null;)f.push(d),S=n,d=ye(),d!==null?(m=hr(),m!==null?d=[d,m]:(d=null,n=S)):(d=null,n=S);f!==null?e=[e,l,u,f]:(e=null,n=v)}else e=null,n=v;else e=null,n=v;else e=null,n=v;return e}function hr(){var e;return e=Xi(),e===null&&(e=Qi(),e===null&&(e=Zi(),e===null&&(e=el(),e===null&&(e=tl(),e===null&&(e=ze()))))),e}function Xi(){var e,l,u,f,d;return f=n,d=n,o.substr(n,3).toLowerCase()==="ttl"?(e=o.substr(n,3),n+=3):(e=null,h('"ttl"')),e!==null?(l=re(),l!==null?(u=al(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.ttl=v}(f,e[2])),e===null&&(n=f),e}function Qi(){var e,l,u,f,d;return f=n,d=n,o.substr(n,5).toLowerCase()==="maddr"?(e=o.substr(n,5),n+=5):(e=null,h('"maddr"')),e!==null?(l=re(),l!==null?(u=Ts(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.maddr=v}(f,e[2])),e===null&&(n=f),e}function Zi(){var e,l,u,f,d;return f=n,d=n,o.substr(n,8).toLowerCase()==="received"?(e=o.substr(n,8),n+=8):(e=null,h('"received"')),e!==null?(l=re(),l!==null?(u=Jt(),u===null&&(u=me()),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.received=v}(f,e[2])),e===null&&(n=f),e}function el(){var e,l,u,f,d;return f=n,d=n,o.substr(n,6).toLowerCase()==="branch"?(e=o.substr(n,6),n+=6):(e=null,h('"branch"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.branch=v}(f,e[2])),e===null&&(n=f),e}function tl(){var e,l,u,f,d;return f=n,o.substr(n,5).toLowerCase()==="rport"?(e=o.substr(n,5),n+=5):(e=null,h('"rport"')),e!==null?(d=n,l=re(),l!==null?(u=sl(),u!==null?l=[l,u]:(l=null,n=d)):(l=null,n=d),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function sl(){var e,l,u,f,d,m,v;return m=n,v=n,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?(d=T(),d=d!==null?d:"",d!==null?e=[e,l,u,f,d]:(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(S,O){w.rport=parseInt(O.join(""))}(m,e)),e===null&&(n=m),e}function nl(){var e,l,u,f,d,m;return m=n,e=rl(),e!==null?(l=G(),l!==null?(u=P(),u!==null?(f=G(),f!==null?(d=il(),d!==null?e=[e,l,u,f,d]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function rl(){var e,l;return l=n,o.substr(n,3).toLowerCase()==="sip"?(e=o.substr(n,3),n+=3):(e=null,h('"SIP"')),e===null&&(e=P()),e!==null&&(e=function(u,f){w.protocol=f}(l,e)),e===null&&(n=l),e}function il(){var e,l;return l=n,o.substr(n,3).toLowerCase()==="udp"?(e=o.substr(n,3),n+=3):(e=null,h('"UDP"')),e===null&&(o.substr(n,3).toLowerCase()==="tcp"?(e=o.substr(n,3),n+=3):(e=null,h('"TCP"')),e===null&&(o.substr(n,3).toLowerCase()==="tls"?(e=o.substr(n,3),n+=3):(e=null,h('"TLS"')),e===null&&(o.substr(n,4).toLowerCase()==="sctp"?(e=o.substr(n,4),n+=4):(e=null,h('"SCTP"')),e===null&&(e=P())))),e!==null&&(e=function(u,f){w.transport=f}(l,e)),e===null&&(n=l),e}function ll(){var e,l,u,f,d;return f=n,e=ol(),e!==null?(d=n,l=it(),l!==null?(u=dr(),u!==null?l=[l,u]:(l=null,n=d)):(l=null,n=d),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function ol(){var e,l;return l=n,e=Jt(),e===null&&(e=on(),e===null&&(e=ln())),e!==null&&(e=function(u){w.host=o.substring(n,u)}(l)),e===null&&(n=l),e}function dr(){var e,l,u,f,d,m,v;return m=n,v=n,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?(d=T(),d=d!==null?d:"",d!==null?e=[e,l,u,f,d]:(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v)):(e=null,n=v),e!==null&&(e=function(S,O){w.port=parseInt(O.join(""))}(m,e)),e===null&&(n=m),e}function al(){var e,l,u,f,d;return f=n,d=n,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,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){return parseInt(v.join(""))}(f,e)),e===null&&(n=f),e}function Mu(){var e;return e=nr(),e}function xo(){var e,l,u,f,d,m;if(d=n,e=pr(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=mr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=mr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function pr(){var e,l;return l=n,e=is(),e!==null&&(e=function(u,f){w.expires=f}(l,e)),e===null&&(n=l),e}function mr(){var e;return e=Mo(),e===null&&(e=ze()),e}function Mo(){var e,l,u,f,d;return f=n,d=n,o.substr(n,9).toLowerCase()==="refresher"?(e=o.substr(n,9),n+=9):(e=null,h('"refresher"')),e!==null?(l=re(),l!==null?(o.substr(n,3).toLowerCase()==="uac"?(u=o.substr(n,3),n+=3):(u=null,h('"uac"')),u===null&&(o.substr(n,3).toLowerCase()==="uas"?(u=o.substr(n,3),n+=3):(u=null,h('"uas"'))),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.refresher=v.toLowerCase()}(f,e[2])),e===null&&(n=f),e}function ko(){var e,l,u,f;return f=n,e=P(),e!==null?(l=B(),l!==null?(u=Lo(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Lo(){var e,l;for(e=[],l=J(),l===null&&(l=Z(),l===null&&(l=M()));l!==null;)e.push(l),l=J(),l===null&&(l=Z(),l===null&&(l=M()));return e}function ku(){var e,l;for(e=[],l=C();l!==null;)e.push(l),l=C();return e}function $o(){var e,l,u;return u=n,o.substr(n,5)==="uuid:"?(e="uuid:",n+=5):(e=null,h('"uuid:"')),e!==null?(l=qt(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function qt(){var e,l,u,f,d,m,v,S,O,ie,Ue;return ie=n,Ue=n,e=ul(),e!==null?(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l!==null?(u=Bt(),u!==null?(o.charCodeAt(n)===45?(f="-",n++):(f=null,h('"-"')),f!==null?(d=Bt(),d!==null?(o.charCodeAt(n)===45?(m="-",n++):(m=null,h('"-"')),m!==null?(v=Bt(),v!==null?(o.charCodeAt(n)===45?(S="-",n++):(S=null,h('"-"')),S!==null?(O=Ho(),O!==null?e=[e,l,u,f,d,m,v,S,O]:(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue)):(e=null,n=Ue),e!==null&&(e=function(Ot,Bs){w=o.substring(n+5,Ot)}(ie,e[0])),e===null&&(n=ie),e}function Bt(){var e,l,u,f,d;return d=n,e=y(),e!==null?(l=y(),l!==null?(u=y(),u!==null?(f=y(),f!==null?e=[e,l,u,f]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e}function ul(){var e,l,u;return u=n,e=Bt(),e!==null?(l=Bt(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function Ho(){var e,l,u,f;return f=n,e=Bt(),e!==null?(l=Bt(),l!==null?(u=Bt(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Lu(){var e,l,u,f,d,m,v;if(d=n,m=n,e=we(),e===null&&(e=Vt()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);u!==null;)l.push(u),v=n,u=ye(),u!==null?(f=ze(),f!==null?u=[u,f]:(u=null,n=v)):(u=null,n=v);l!==null?e=[e,l]:(e=null,n=m)}else e=null,n=m;return e!==null&&(e=function(S){try{w=new b(w.uri,w.display_name,w.params)}catch{w=-1}}()),e===null&&(n=d),e}function Fo(){var e,l,u,f,d,m;if(d=n,e=gr(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);u!==null;)l.push(u),m=n,u=ye(),u!==null?(f=Tr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=d)}else e=null,n=d;return e}function gr(){var e,l,u,f,d,m;return f=n,d=n,e=ee(),e!==null?(m=n,o.charCodeAt(n)===64?(l="@",n++):(l=null,h('"@"')),l!==null?(u=ee(),u!==null?l=[l,u]:(l=null,n=m)):(l=null,n=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(v){w.call_id=o.substring(n,v)}(f)),e===null&&(n=f),e}function Tr(){var e;return e=cl(),e===null&&(e=fl(),e===null&&(e=jo(),e===null&&(e=ze()))),e}function cl(){var e,l,u,f,d;return f=n,d=n,o.substr(n,6)==="to-tag"?(e="to-tag",n+=6):(e=null,h('"to-tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.to_tag=v}(f,e[2])),e===null&&(n=f),e}function fl(){var e,l,u,f,d;return f=n,d=n,o.substr(n,8)==="from-tag"?(e="from-tag",n+=8):(e=null,h('"from-tag"')),e!==null?(l=re(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,n=d)):(e=null,n=d)):(e=null,n=d),e!==null&&(e=function(m,v){w.from_tag=v}(f,e[2])),e===null&&(n=f),e}function jo(){var e,l;return l=n,o.substr(n,10)==="early-only"?(e="early-only",n+=10):(e=null,h('"early-only"')),e!==null&&(e=function(u){w.early_only=!0}()),e===null&&(n=l),e}function $u(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 Vo(){for(var e=1,l=1,u=!1,f=0;f<Math.max(n,p);f++){var d=o.charAt(f);d===`
|
4
|
+
`?(u||e++,l=1,u=!1):d==="\r"||d==="\u2028"||d==="\u2029"?(e++,l=1,u=!0):(l++,u=!1)}return{line:e,column:l}}var Es=ys(),b=Go(),w={},_l=t[a]();if(_l===null||n!==o.length){var hl=Math.max(n,p),qo=hl<o.length?o.charAt(hl):null,i=Vo();return new this.SyntaxError($u(_),qo,hl,i.line,i.column),-1}return w},toSource:function(){return this._source}};return s.SyntaxError=function(r,o,a,t,n){function p(_,h){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=h?c(h):"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=n},s.SyntaxError.prototype=Error.prototype,s}()),Wo}var Ko,Bu;function ys(){if(Bu)return Ko;Bu=1;function c(h,g){var T;if(typeof Symbol>"u"||h[Symbol.iterator]==null){if(Array.isArray(h)||(T=s(h))||g&&h&&typeof h.length=="number"){T&&(h=T);var E=0,y=function(){};return{s:y,n:function(){return E>=h.length?{done:!0}:{done:!1,value:h[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,C=!1,I;return{s:function(){T=h[Symbol.iterator]()},n:function(){var L=T.next();return A=L.done,L},e:function(L){C=!0,I=L},f:function(){try{!A&&T.return!=null&&T.return()}finally{if(C)throw I}}}}function s(h,g){if(h){if(typeof h=="string")return r(h,g);var T=Object.prototype.toString.call(h).slice(8,-1);if(T==="Object"&&h.constructor&&(T=h.constructor.name),T==="Map"||T==="Set")return Array.from(h);if(T==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(T))return r(h,g)}}function r(h,g){(g==null||g>h.length)&&(g=h.length);for(var T=0,E=new Array(g);T<g;T++)E[T]=h[T];return E}function o(h,g){if(!(h instanceof g))throw new TypeError("Cannot call a class as a function")}function a(h,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(h,E.key,E)}}function t(h,g,T){return g&&a(h.prototype,g),T&&a(h,T),h}var n=tt,p=Ct(),_=Xt();return Ko=function(){t(h,null,[{key:"parse",value:function(T){if(T=_.parse(T,"SIP_URI"),T!==-1)return T}}]);function h(g,T,E,y){var A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},C=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(o(this,h),!E)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=g||n.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 C)Object.prototype.hasOwnProperty.call(C,$)&&this.setHeader($,C[$])}return t(h,[{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 h(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 C=c(this._headers[A]),I;try{for(C.s();!(I=C.n()).done;){var $=I.value;T.push("".concat(A,"=").concat($))}}catch(L){C.e(L)}finally{C.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}}]),h}(),Ko}var Gu;function Ct(){if(Gu)return Qe;Gu=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 s(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 C=!0,I=!1,$;return{s:function(){E=g[Symbol.iterator]()},n:function(){var ae=E.next();return C=ae.done,ae},e:function(ae){I=!0,$=ae},f:function(){try{!C&&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=tt,t=ys(),n=Xt();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,C=E;A<C.length;A++){var I=C[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=n.parse(g,"host"),g!==-1)return g.host_type}else return};var h=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(h(y),"@").concat(A);var C;return(C=t.parse(g))?C: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,C;for(C=0;C<A;C++)C!==0&&(y+="-"),y+=E[C].charAt(0).toUpperCase()+E[C].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,he){return pe<<he|pe>>>32-he}function E(pe,he){var de=pe&2147483648,we=he&2147483648,Ne=pe&1073741824,et=he&1073741824,He=(pe&1073741823)+(he&1073741823);return Ne&et?He^2147483648^de^we:Ne|et?He&1073741824?He^3221225472^de^we:He^1073741824^de^we:He^de^we}function y(pe,he,de){return pe&he|~pe&de}function A(pe,he,de){return pe&de|he&~de}function C(pe,he,de){return pe^he^de}function I(pe,he,de){return he^(pe|~de)}function $(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(y(he,de,we),Ne),He)),E(T(pe,et),he)}function L(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(A(he,de,we),Ne),He)),E(T(pe,et),he)}function ae(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(C(he,de,we),Ne),He)),E(T(pe,et),he)}function N(pe,he,de,we,Ne,et,He){return pe=E(pe,E(E(I(he,de,we),Ne),He)),E(T(pe,et),he)}function F(pe){for(var he,de=pe.length,we=de+8,Ne=(we-we%64)/64,et=(Ne+1)*16,He=new Array(et-1),Ft=0,At=0;At<de;)he=(At-At%4)/4,Ft=At%4*8,He[he]=He[he]|pe.charCodeAt(At)<<Ft,At++;return he=(At-At%4)/4,Ft=At%4*8,He[he]=He[he]|128<<Ft,He[et-2]=de<<3,He[et-1]=de>>>29,He}function Se(pe){var he="",de="",we,Ne;for(Ne=0;Ne<=3;Ne++)we=pe>>>Ne*8&255,de="0".concat(we.toString(16)),he=he+de.substr(de.length-2,2);return he}function ve(pe){for(var he="",de=0;de<pe.length;de++){var we=pe.charCodeAt(de);we<128?he+=String.fromCharCode(we):we>127&&we<2048?(he+=String.fromCharCode(we>>6|192),he+=String.fromCharCode(we&63|128)):(he+=String.fromCharCode(we>>12|224),he+=String.fromCharCode(we>>6&63|128),he+=String.fromCharCode(we&63|128))}return he}var M=[],D,B,q,J,H,Z,U,P,se,rt=7,ee=12,Y=17,G=22,re=5,ge=9,be=14,xe=20,Re=4,le=11,ye=16,it=23,ot=6,Ee=10,Ae=15,Ie=21;for(g=ve(g),M=F(g),Z=1732584193,U=4023233417,P=2562383102,se=271733878,D=0;D<M.length;D+=16)B=Z,q=U,J=P,H=se,Z=$(Z,U,P,se,M[D+0],rt,3614090360),se=$(se,Z,U,P,M[D+1],ee,3905402710),P=$(P,se,Z,U,M[D+2],Y,606105819),U=$(U,P,se,Z,M[D+3],G,3250441966),Z=$(Z,U,P,se,M[D+4],rt,4118548399),se=$(se,Z,U,P,M[D+5],ee,1200080426),P=$(P,se,Z,U,M[D+6],Y,2821735955),U=$(U,P,se,Z,M[D+7],G,4249261313),Z=$(Z,U,P,se,M[D+8],rt,1770035416),se=$(se,Z,U,P,M[D+9],ee,2336552879),P=$(P,se,Z,U,M[D+10],Y,4294925233),U=$(U,P,se,Z,M[D+11],G,2304563134),Z=$(Z,U,P,se,M[D+12],rt,1804603682),se=$(se,Z,U,P,M[D+13],ee,4254626195),P=$(P,se,Z,U,M[D+14],Y,2792965006),U=$(U,P,se,Z,M[D+15],G,1236535329),Z=L(Z,U,P,se,M[D+1],re,4129170786),se=L(se,Z,U,P,M[D+6],ge,3225465664),P=L(P,se,Z,U,M[D+11],be,643717713),U=L(U,P,se,Z,M[D+0],xe,3921069994),Z=L(Z,U,P,se,M[D+5],re,3593408605),se=L(se,Z,U,P,M[D+10],ge,38016083),P=L(P,se,Z,U,M[D+15],be,3634488961),U=L(U,P,se,Z,M[D+4],xe,3889429448),Z=L(Z,U,P,se,M[D+9],re,568446438),se=L(se,Z,U,P,M[D+14],ge,3275163606),P=L(P,se,Z,U,M[D+3],be,4107603335),U=L(U,P,se,Z,M[D+8],xe,1163531501),Z=L(Z,U,P,se,M[D+13],re,2850285829),se=L(se,Z,U,P,M[D+2],ge,4243563512),P=L(P,se,Z,U,M[D+7],be,1735328473),U=L(U,P,se,Z,M[D+12],xe,2368359562),Z=ae(Z,U,P,se,M[D+5],Re,4294588738),se=ae(se,Z,U,P,M[D+8],le,2272392833),P=ae(P,se,Z,U,M[D+11],ye,1839030562),U=ae(U,P,se,Z,M[D+14],it,4259657740),Z=ae(Z,U,P,se,M[D+1],Re,2763975236),se=ae(se,Z,U,P,M[D+4],le,1272893353),P=ae(P,se,Z,U,M[D+7],ye,4139469664),U=ae(U,P,se,Z,M[D+10],it,3200236656),Z=ae(Z,U,P,se,M[D+13],Re,681279174),se=ae(se,Z,U,P,M[D+0],le,3936430074),P=ae(P,se,Z,U,M[D+3],ye,3572445317),U=ae(U,P,se,Z,M[D+6],it,76029189),Z=ae(Z,U,P,se,M[D+9],Re,3654602809),se=ae(se,Z,U,P,M[D+12],le,3873151461),P=ae(P,se,Z,U,M[D+15],ye,530742520),U=ae(U,P,se,Z,M[D+2],it,3299628645),Z=N(Z,U,P,se,M[D+0],ot,4096336452),se=N(se,Z,U,P,M[D+7],Ee,1126891415),P=N(P,se,Z,U,M[D+14],Ae,2878612391),U=N(U,P,se,Z,M[D+5],Ie,4237533241),Z=N(Z,U,P,se,M[D+12],ot,1700485571),se=N(se,Z,U,P,M[D+3],Ee,2399980690),P=N(P,se,Z,U,M[D+10],Ae,4293915773),U=N(U,P,se,Z,M[D+1],Ie,2240044497),Z=N(Z,U,P,se,M[D+8],ot,1873313359),se=N(se,Z,U,P,M[D+15],Ee,4264355552),P=N(P,se,Z,U,M[D+6],Ae,2734768916),U=N(U,P,se,Z,M[D+13],Ie,1309151649),Z=N(Z,U,P,se,M[D+4],ot,4149444226),se=N(se,Z,U,P,M[D+11],Ee,3174756917),P=N(P,se,Z,U,M[D+2],Ae,718787259),U=N(U,P,se,Z,M[D+9],Ie,3951481745),Z=E(Z,B),U=E(U,q),P=E(P,J),se=E(se,H);var Oe=Se(Z)+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=s(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 C=s(T),I;try{for(C.s();!(I=C.n()).done;){var $=I.value;$.stop()}}catch(F){C.e(F)}finally{C.f()}T=g.getVideoTracks();var L=s(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 Yo={exports:{}},bn=typeof Reflect=="object"?Reflect:null,Wu=bn&&typeof bn.apply=="function"?bn.apply:function(s,r,o){return Function.prototype.apply.call(s,r,o)},El;bn&&typeof bn.ownKeys=="function"?El=bn.ownKeys:Object.getOwnPropertySymbols?El=function(s){return Object.getOwnPropertyNames(s).concat(Object.getOwnPropertySymbols(s))}:El=function(s){return Object.getOwnPropertyNames(s)};function $_(c){console&&console.warn&&console.warn(c)}var Ku=Number.isNaN||function(s){return s!==s};function Le(){Le.init.call(this)}Yo.exports=Le,Yo.exports.once=V_,Le.EventEmitter=Le,Le.prototype._events=void 0,Le.prototype._eventsCount=0,Le.prototype._maxListeners=void 0;var Yu=10;function Sl(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(Le,"defaultMaxListeners",{enumerable:!0,get:function(){return Yu},set:function(c){if(typeof c!="number"||c<0||Ku(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Yu=c}}),Le.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},Le.prototype.setMaxListeners=function(s){if(typeof s!="number"||s<0||Ku(s))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+s+".");return this._maxListeners=s,this};function Ju(c){return c._maxListeners===void 0?Le.defaultMaxListeners:c._maxListeners}Le.prototype.getMaxListeners=function(){return Ju(this)},Le.prototype.emit=function(s){for(var r=[],o=1;o<arguments.length;o++)r.push(arguments[o]);var a=s==="error",t=this._events;if(t!==void 0)a=a&&t.error===void 0;else if(!a)return!1;if(a){var n;if(r.length>0&&(n=r[0]),n instanceof Error)throw n;var p=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw p.context=n,p}var _=t[s];if(_===void 0)return!1;if(typeof _=="function")Wu(_,this,r);else for(var h=_.length,g=ec(_,h),o=0;o<h;++o)Wu(g[o],this,r);return!0};function zu(c,s,r,o){var a,t,n;if(Sl(r),t=c._events,t===void 0?(t=c._events=Object.create(null),c._eventsCount=0):(t.newListener!==void 0&&(c.emit("newListener",s,r.listener?r.listener:r),t=c._events),n=t[s]),n===void 0)n=t[s]=r,++c._eventsCount;else if(typeof n=="function"?n=t[s]=o?[r,n]:[n,r]:o?n.unshift(r):n.push(r),a=Ju(c),a>0&&n.length>a&&!n.warned){n.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(s)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=c,p.type=s,p.count=n.length,$_(p)}return c}Le.prototype.addListener=function(s,r){return zu(this,s,r,!1)},Le.prototype.on=Le.prototype.addListener,Le.prototype.prependListener=function(s,r){return zu(this,s,r,!0)};function H_(){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 Xu(c,s,r){var o={fired:!1,wrapFn:void 0,target:c,type:s,listener:r},a=H_.bind(o);return a.listener=r,o.wrapFn=a,a}Le.prototype.once=function(s,r){return Sl(r),this.on(s,Xu(this,s,r)),this},Le.prototype.prependOnceListener=function(s,r){return Sl(r),this.prependListener(s,Xu(this,s,r)),this},Le.prototype.removeListener=function(s,r){var o,a,t,n,p;if(Sl(r),a=this._events,a===void 0)return this;if(o=a[s],o===void 0)return this;if(o===r||o.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete a[s],a.removeListener&&this.emit("removeListener",s,o.listener||r));else if(typeof o!="function"){for(t=-1,n=o.length-1;n>=0;n--)if(o[n]===r||o[n].listener===r){p=o[n].listener,t=n;break}if(t<0)return this;t===0?o.shift():F_(o,t),o.length===1&&(a[s]=o[0]),a.removeListener!==void 0&&this.emit("removeListener",s,p||r)}return this},Le.prototype.off=Le.prototype.removeListener,Le.prototype.removeAllListeners=function(s){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[s]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[s]),this;if(arguments.length===0){var t=Object.keys(o),n;for(a=0;a<t.length;++a)n=t[a],n!=="removeListener"&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=o[s],typeof r=="function")this.removeListener(s,r);else if(r!==void 0)for(a=r.length-1;a>=0;a--)this.removeListener(s,r[a]);return this};function Qu(c,s,r){var o=c._events;if(o===void 0)return[];var a=o[s];return a===void 0?[]:typeof a=="function"?r?[a.listener||a]:[a]:r?j_(a):ec(a,a.length)}Le.prototype.listeners=function(s){return Qu(this,s,!0)},Le.prototype.rawListeners=function(s){return Qu(this,s,!1)},Le.listenerCount=function(c,s){return typeof c.listenerCount=="function"?c.listenerCount(s):Zu.call(c,s)},Le.prototype.listenerCount=Zu;function Zu(c){var s=this._events;if(s!==void 0){var r=s[c];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Le.prototype.eventNames=function(){return this._eventsCount>0?El(this._events):[]};function ec(c,s){for(var r=new Array(s),o=0;o<s;++o)r[o]=c[o];return r}function F_(c,s){for(;s+1<c.length;s++)c[s]=c[s+1];c.pop()}function j_(c){for(var s=new Array(c.length),r=0;r<s.length;++r)s[r]=c[r].listener||c[r];return s}function V_(c,s){return new Promise(function(r,o){function a(n){c.removeListener(s,t),o(n)}function t(){typeof c.removeListener=="function"&&c.removeListener("error",a),r([].slice.call(arguments))}tc(c,s,t,{once:!0}),s!=="error"&&q_(c,a,{once:!0})})}function q_(c,s,r){typeof c.on=="function"&&tc(c,"error",s,r)}function tc(c,s,r,o){if(typeof c.on=="function")o.once?c.once(s,r):c.on(s,r);else if(typeof c.addEventListener=="function")c.addEventListener(s,function a(t){o.once&&c.removeEventListener(s,a),r(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ut=Yo.exports,Jo={exports:{}},zo,sc;function B_(){if(sc)return zo;sc=1;var c=1e3,s=c*60,r=s*60,o=r*24,a=o*7,t=o*365.25;zo=function(g,T){T=T||{};var E=typeof g;if(E==="string"&&g.length>0)return n(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 n(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*s;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>=s?Math.round(g/s)+"m":T>=c?Math.round(g/c)+"s":g+"ms"}function _(g){var T=Math.abs(g);return T>=o?h(g,T,o,"day"):T>=r?h(g,T,r,"hour"):T>=s?h(g,T,s,"minute"):T>=c?h(g,T,c,"second"):g+" ms"}function h(g,T,E,y){var A=T>=E*1.5;return Math.round(g/E)+" "+y+(A?"s":"")}return zo}function G_(c){r.debug=r,r.default=r,r.coerce=_,r.disable=t,r.enable=a,r.enabled=n,r.humanize=B_(),r.destroy=h,Object.keys(c).forEach(g=>{r[g]=c[g]}),r.names=[],r.skips=[],r.formatters={};function s(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=s;function r(g){let T,E=null,y,A;function C(...I){if(!C.enabled)return;const $=C,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 C.namespace=g,C.useColors=r.useColors(),C.color=r.selectColor(g),C.extend=o,C.destroy=r.destroy,Object.defineProperty(C,"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(C),C}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 n(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 h(){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 W_=G_;(function(c,s){s.formatArgs=o,s.save=a,s.load=t,s.useColors=r,s.storage=n(),s.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`."))}})(),s.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 h="color: "+this.color;_.splice(1,0,h,"color: inherit");let g=0,T=0;_[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(g++,E==="%c"&&(T=g))}),_.splice(T,0,h)}s.log=console.debug||console.log||(()=>{});function a(_){try{_?s.storage.setItem("debug",_):s.storage.removeItem("debug")}catch{}}function t(){let _;try{_=s.storage.getItem("debug")}catch{}return!_&&typeof process<"u"&&"env"in process&&(_=process.env.DEBUG),_}function n(){try{return localStorage}catch{}}c.exports=W_(s);const{formatters:p}=c.exports;p.j=function(_){try{return JSON.stringify(_)}catch(h){return"[UnexpectedJSONParseError]: "+h.message}}})(Jo,Jo.exports);var wn=Jo.exports;function K_(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function nc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Y_(c,s,r){return s&&nc(c.prototype,s),r&&nc(c,r),c}var On=wn,Dn="JsSIP",ct=function(){function c(s){K_(this,c),s?(this._debug=On.default("".concat(Dn,":").concat(s)),this._warn=On.default("".concat(Dn,":WARN:").concat(s)),this._error=On.default("".concat(Dn,":ERROR:").concat(s))):(this._debug=On.default(Dn),this._warn=On.default("".concat(Dn,":WARN")),this._error=On.default("".concat(Dn,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return Y_(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),Dt={},rc={},ic={exports:{}},lc=ic.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 s="candidate:%s %d %s %d %s %d typ %s";return s+=c.raddr!=null?" raddr %s rport %d":"%v%v",s+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(s+=" generation %d"),s+=c["network-id"]!=null?" network-id %d":"%v",s+=c["network-cost"]!=null?" network-cost %d":"%v",s}},{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 s="ssrc:%d";return c.attribute!=null&&(s+=" %s",c.value!=null&&(s+=":%s")),s}},{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 s="mediaclk:";return s+=c.id!=null?"id=%s %s":"%v%s",s+=c.mediaClockValue!=null?"=%s":"",s+=c.rateNumerator!=null?" rate=%s":"",s+=c.rateDenominator!=null?"/%s":"",s}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(lc).forEach(function(c){var s=lc[c];s.forEach(function(r){r.reg||(r.reg=/(.*)/),r.format||(r.format="%s")})});var oc=ic.exports;(function(c){var s=function(p){return String(Number(p))===p?Number(p):p},r=function(p,_,h,g){if(g&&!h)_[g]=s(p[1]);else for(var T=0;T<h.length;T+=1)p[T+1]!=null&&(_[h[T]]=s(p[T+1]))},o=function(p,_,h){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(h.match(p.reg),T,p.names,p.name),p.push&&_[p.push].push(T)},a=oc,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(p){var _={},h=[],g=_;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(T){var E=T[0],y=T.slice(2);E==="m"&&(h.push({rtp:[],fmtp:[]}),g=h[h.length-1]);for(var A=0;A<(a[E]||[]).length;A+=1){var C=a[E][A];if(C.reg.test(y))return o(C,g,y)}}),_.media=h,_};var n=function(p,_){var h=_.split(/=(.+)/,2);return h.length===2?p[h[0]]=s(h[1]):h.length===1&&_.length>1&&(p[h[0]]=void 0),p};c.parseParams=function(p){return p.split(/;\s?/).reduce(n,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(p){return p.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(p){for(var _=[],h=p.split(" ").map(s),g=0;g<h.length;g+=3)_.push({component:h[g],ip:h[g+1],port:h[g+2]});return _},c.parseImageAttributes=function(p){return p.split(" ").map(function(_){return _.substring(1,_.length-1).split(",").reduce(n,{})})},c.parseSimulcastStreamList=function(p){return p.split(";").map(function(_){return _.split(",").map(function(h){var g,T=!1;return h[0]!=="~"?g=s(h):(g=s(h.substring(1,h.length)),T=!0),{scid:g,paused:T}})})}})(rc);var Xo=oc,J_=/%[sdv%]/g,z_=function(c){var s=1,r=arguments,o=r.length;return c.replace(J_,function(a){if(s>=o)return a;var t=r[s];switch(s+=1,a){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},Sr=function(c,s,r){var o=s.format instanceof Function?s.format(s.push?r:r[s.name]):s.format,a=[c+"="+o];if(s.names)for(var t=0;t<s.names.length;t+=1){var n=s.names[t];s.name?a.push(r[s.name][n]):a.push(r[s.names[t]])}else a.push(r[s.name]);return z_.apply(null,a)},X_=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Q_=["i","c","b","a"],Z_=function(c,s){s=s||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var r=s.outerOrder||X_,o=s.innerOrder||Q_,a=[];return r.forEach(function(t){Xo[t].forEach(function(n){n.name in c&&c[n.name]!=null?a.push(Sr(t,n,c)):n.push in c&&c[n.push]!=null&&c[n.push].forEach(function(p){a.push(Sr(t,n,p))})})}),c.media.forEach(function(t){a.push(Sr("m",Xo.m[0],t)),o.forEach(function(n){Xo[n].forEach(function(p){p.name in t&&t[p.name]!=null?a.push(Sr(n,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(_){a.push(Sr(n,p,_))})})})}),a.join(`\r
|
7
7
|
`)+`\r
|
8
|
-
`},Ws=rc,
|
9
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var
|
8
|
+
`},Ws=rc,eh=Z_;Dt.write=eh,Dt.parse=Ws.parse,Dt.parseParams=Ws.parseParams,Dt.parseFmtpConfig=Ws.parseFmtpConfig,Dt.parsePayloads=Ws.parsePayloads,Dt.parseRemoteCandidates=Ws.parseRemoteCandidates,Dt.parseImageAttributes=Ws.parseImageAttributes,Dt.parseSimulcastStreamList=Ws.parseSimulcastStreamList;function yl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?yl=function(r){return typeof r}:yl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},yl(c)}function Qo(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Zo(c,s)}function Zo(c,s){return Zo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Zo(c,s)}function ea(c){var s=nh();return function(){var o=Al(c),a;if(s){var t=Al(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return th(this,a)}}function th(c,s){return s&&(yl(s)==="object"||typeof s=="function")?s:sh(c)}function sh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function nh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Al(c){return Al=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Al(c)}function kt(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=rh(c))||s&&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(h){throw h},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,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,p=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw p}}}}function rh(c,s){if(c){if(typeof c=="string")return ac(c,s);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 ac(c,s)}}function ac(c,s){(s==null||s>c.length)&&(s=c.length);for(var r=0,o=new Array(s);r<s;r++)o[r]=c[r];return o}function yr(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function uc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Cl(c,s,r){return s&&uc(c.prototype,s),r&&uc(c,r),c}var cc=Dt,ih=ct,ht=tt,st=Ct(),fc=Go(),lh=Xt(),ta=new ih("SIPMessage"),_c=function(){function c(s,r,o,a,t,n){if(yr(this,c),!s||!r||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=s,this.ruri=r,this.body=n,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",ht.MAX_FORWARDS);var p=a.to_uri||r,_=a.to_tag?{tag:a.to_tag}:null,h=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new fc(p,h,_),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 fc(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(s))}return Cl(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=kt(this.extraHeaders),n;try{for(t.s();!(n=t.n()).done;){var p=n.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=kt(o),n;try{for(t.s();!(n=t.n()).done;){var p=n.value;a.push(p)}}catch(E){t.e(E)}finally{t.f()}return a}else{var _=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),h=kt(this.extraHeaders),g;try{for(h.s();!(g=h.n()).done;){var T=g.value;_.test(T)&&a.push(T.substring(T.indexOf(":")+1).trim())}}catch(E){h.e(E)}finally{h.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=kt(this.extraHeaders),t;try{for(a.s();!(t=a.n()).done;){var n=t.value;if(o.test(n))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=cc.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var r="".concat(this.method," ").concat(this.ruri,` SIP/2.0\r
|
10
10
|
`);for(var o in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,o)){var a=kt(this.headers[o]),t;try{for(a.s();!(t=a.n()).done;){var n=t.value;r+="".concat(o,": ").concat(n,`\r
|
11
|
-
`)}}catch(y){a.e(y)}finally{a.f()}}var p=kt(this.extraHeaders),_;try{for(p.s();!(_=p.n()).done;){var
|
11
|
+
`)}}catch(y){a.e(y)}finally{a.f()}}var p=kt(this.extraHeaders),_;try{for(p.s();!(_=p.n()).done;){var h=_.value;r+="".concat(h.trim(),`\r
|
12
12
|
`)}}catch(y){p.e(y)}finally{p.f()}var g=[];switch(this.method){case ht.REGISTER:g.push("path","gruu");break;case ht.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 ht.UPDATE:this.ua.configuration.session_timers&&g.push("timer"),g.push("ice");break}g.push("outbound");var T=this.ua.configuration.user_agent||ht.USER_AGENT;if(r+="Allow: ".concat(ht.ALLOWED_METHODS,`\r
|
13
13
|
`),r+="Supported: ".concat(g,`\r
|
14
14
|
`),r+="User-Agent: ".concat(T,`\r
|
@@ -16,7 +16,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
16
16
|
\r
|
17
17
|
`),r+=this.body}else r+=`Content-Length: 0\r
|
18
18
|
\r
|
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}(),
|
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}(),oh=function(c){Qo(r,c);var s=ea(r);function r(o,a,t,n,p){var _;return yr(this,r),_=s.call(this,ht.INVITE,o,a,t,n,p),_.transaction=null,_}return Cl(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}(_c),hc=function(){function c(){yr(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 Cl(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=kt(o),n;try{for(t.s();!(n=t.n()).done;){var p=n.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){ta.debug('not so many "'.concat(r,'" headers present'));return}}else{ta.debug('header "'.concat(r,'" not present'));return}var a=this.headers[r][o],t=a.raw;if(a.parsed)return a.parsed;var n=lh.parse(t,r.replace(/-/g,"_"));if(n===-1){this.headers[r].splice(o,1),ta.debug('error parsing "'.concat(r,'" header field with value "').concat(t,'"'));return}else return a.parsed=n,n}},{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=cc.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),c}(),ah=function(c){Qo(r,c);var s=ea(r);function r(o){var a;return yr(this,r),a=s.call(this),a.ua=o,a.headers={},a.ruri=null,a.transport=null,a.server_transaction=null,a}return Cl(r,[{key:"reply",value:function(a,t,n,p,_,h){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||ht.REASON_PHRASE[a]||"",n=st.cloneArray(n),this.ua.configuration.extra_headers&&(n=n.concat(this.ua.configuration.extra_headers));var E="SIP/2.0 ".concat(a," ").concat(t,`\r
|
20
20
|
`);if(this.method===ht.INVITE&&a>100&&a<=200){var y=this.getHeaders("record-route"),A=kt(y),C;try{for(A.s();!(C=A.n()).done;){var I=C.value;E+="Record-Route: ".concat(I,`\r
|
21
21
|
`)}}catch(D){A.e(D)}finally{A.f()}}var $=this.getHeaders("via"),L=kt($),ae;try{for(L.s();!(ae=L.n()).done;){var N=ae.value;E+="Via: ".concat(N,`\r
|
22
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
|
@@ -34,8 +34,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
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
|
-
`),_=kt(n),
|
37
|
+
`);this.server_transaction.receiveResponse(a,E,_,h)}},{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,n=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||ht.REASON_PHRASE[a]||"";var p="SIP/2.0 ".concat(a," ").concat(t,`\r
|
38
|
+
`),_=kt(n),h;try{for(_.s();!(h=_.n()).done;){var g=h.value;p+="Via: ".concat(g,`\r
|
39
39
|
`)}}catch(C){_.e(C)}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
|
@@ -43,11 +43,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
43
43
|
`),this.ua.configuration.extra_headers){var E=kt(this.ua.configuration.extra_headers),y;try{for(E.s();!(y=E.n()).done;){var A=y.value;p+="".concat(A.trim(),`\r
|
44
44
|
`)}}catch(C){E.e(C)}finally{E.f()}}p+="Content-Length: ".concat(0,`\r
|
45
45
|
\r
|
46
|
-
`),this.transport.send(p)}}]),r}(hc),ch=function(c){Qo(r,c);var s=ea(r);function r(){var o;return yr(this,r),o=s.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return r}(hc),os={OutgoingRequest:_c,InitialOutgoingInviteRequest:ah,IncomingRequest:uh,IncomingResponse:ch};function fh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function dc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function _h(c,s,r){return s&&dc(c.prototype,s),r&&dc(c,r),c}var hh=ct,as=Ct(),Gt=new hh("DigestAuthentication"),dh=function(){function c(s){fh(this,c),this._credentials=s,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 _h(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,n=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||as.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=as.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=as.calculateMD5(d),Gt.debug('authenticate() | using qop=auth [a2:"%s"]',d),this._response=as.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(as.calculateMD5(n||"")),g=as.calculateMD5(d),Gt.debug('authenticate() | using qop=auth-int [a2:"%s"]',d),this._response=as.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=as.calculateMD5(d),Gt.debug('authenticate() | using qop=null [a2:"%s"]',d),this._response=as.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}(),us=500,ph=4e3,pc=5e3,mc={T1:us,T2:ph,T4:pc,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*pc,TIMER_L:64*us,TIMER_M:64*us,PROVISIONAL_RESPONSE_INTERVAL:6e4};function Rl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Rl=function(r){return typeof r}:Rl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Rl(c)}function Ar(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function gc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Cr(c,s,r){return s&&gc(c.prototype,s),r&&gc(c,r),c}function Rr(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&sa(c,s)}function sa(c,s){return sa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},sa(c,s)}function Ir(c){var s=gh();return function(){var o=Il(c),a;if(s){var t=Il(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return mh(this,a)}}function mh(c,s){return s&&(Rl(s)==="object"||typeof s=="function")?s:As(c)}function As(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function gh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Il(c){return Il=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Il(c)}var br=ut.EventEmitter,wr=ct,Or=tt,Tc=os,Qt=mc,vc=new wr("NonInviteClientTransaction"),bl=new wr("InviteClientTransaction"),Th=new wr("AckClientTransaction"),Ec=new wr("NonInviteServerTransaction"),wl=new wr("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"},vh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t,n){var p;Ar(this,r),p=s.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=n;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(As(p)),p}return Cr(r,[{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()},Qt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){vc.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(){vc.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,n=a.status_code;if(n<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),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},Qt.TIMER_K);break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),r}(br),Eh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t,n){var p;Ar(this,r),p=s.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=n,t.transaction=As(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(As(p)),p}return Cr(r,[{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()},Qt.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&&(bl.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(){bl.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(){bl.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(){bl.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,n=new Tc.OutgoingRequest(Or.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",a.getHeader("to")),this.D=setTimeout(function(){t.timer_D()},Qt.TIMER_D),this.transport.send(n)}},{key:"cancel",value:function(a){if(this.state===ue.STATUS_PROCEEDING){var t=new Tc.OutgoingRequest(Or.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,n=a.status_code;if(n>=100&&n<=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(n>=200&&n<=299)switch(this.state){case ue.STATUS_CALLING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},Qt.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(n>=300&&n<=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}}]),r}(br),Sh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t,n){var p;Ar(this,r),p=s.call(this),p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.transport=a,p.request=t,p.eventHandlers=n;var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p}return Cr(r,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Th.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return ue}}]),r}(br),yh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t){var n;return Ar(this,r),n=s.call(this),n.type=ue.NON_INVITE_SERVER,n.id=t.via_branch,n.ua=o,n.transport=a,n.request=t,n.last_response="",t.server_transaction=As(n),n.state=ue.STATUS_TRYING,o.newTransaction(As(n)),n}return Cr(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){Ec.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,Ec.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,n,p){var _=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)?n&&n():(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(){_.timer_J()},Qt.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),p&&p());break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),r}(br),Ah=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t){var n;return Ar(this,r),n=s.call(this),n.type=ue.INVITE_SERVER,n.id=t.via_branch,n.ua=o,n.transport=a,n.request=t,n.last_response="",t.server_transaction=As(n),n.state=ue.STATUS_PROCEEDING,o.newTransaction(As(n)),n.resendProvisionalTimer=null,t.reply(100),n}return Cr(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){wl.debug("Timer H expired for transaction ".concat(this.id)),this.state===ue.STATUS_COMPLETED&&wl.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(){wl.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,wl.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,n,p){var _=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(){_.resend_provisional()},Qt.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(){_.timer_L()},Qt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ue.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(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(){_.timer_H()},Qt.TIMER_H),n&&n()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return ue}}]),r}(br);function Ch(c,s){var r=c._transactions,o;switch(s.method){case Or.INVITE:if(o=r.ist[s.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 Or.ACK:if(o=r.ist[s.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()},Qt.TIMER_I),!0}else return!1;break;case Or.CANCEL:return o=r.ist[s.via_branch],o?(s.reply_sl(200),o.state!==ue.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(o=r.nist[s.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 Dr={C:ue,NonInviteClientTransaction:vh,InviteClientTransaction:Eh,AckClientTransaction:Sh,NonInviteServerTransaction:yh,InviteServerTransaction:Ah,checkTransaction:Ch};function Rh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Sc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Ih(c,s,r){return s&&Sc(c.prototype,s),r&&Sc(c,r),c}var bh=ct,yc=tt,wh=dh,na=Dr,Oh=new bh("RequestSender"),ra={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Nr=function(){function c(s,r,o){Rh(this,c),this._ua=s,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]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==yc.BYE||this._method!==yc.ACK)&&this._eventHandlers.onTransportError()}return Ih(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){Oh.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 wh({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 Dh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Ac(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Nh(c,s,r){return s&&Ac(c.prototype,s),r&&Ac(c,r),c}var Uh=ct,ia=Ct(),Ks=tt,Cc=os,Rc=Nr,Ur=new Uh("Registrator"),Ol=10,Ph=function(){function c(s,r){Dh(this,c),this._reg_id=1,this._ua=s,this._transport=r,this._registrar=s.configuration.registrar_server,this._expires=s.configuration.register_expires,this._call_id=ia.createRandomToken(22),this._cseq=0,this._to_uri=s.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 Nh(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){Ur.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 Cc.OutgoingRequest(Ks.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new Rc(this._ua,a,{onRequestTimeout:function(){r._registrationFailure(null,Ks.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._registrationFailure(null,Ks.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")){Ur.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){Ur.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<Ol&&(g=Ol);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<Ol&&(r._expires=Ol),r.register()):(Ur.debug("423 response received for REGISTER without Min-Expires"),r._registrationFailure(p,Ks.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){Ur.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 Cc.OutgoingRequest(Ks.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),n=new Rc(this._ua,t,{onRequestTimeout:function(){r._unregistered(null,Ks.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._unregistered(null,Ks.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)}}}});n.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 xh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Ic(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Mh(c,s,r){return s&&Ic(c.prototype,s),r&&Ic(c,r),c}var la=tt,Dl=Dr,kh=Nr,oa={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},Lh=function(){function c(s,r,o){xh(this,c),this._dialog=s,this._ua=s._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 Mh(c,[{key:"send",value:function(){var r=this,o=new kh(this._ua,this._request,{onRequestTimeout:function(){r._eventHandlers.onRequestTimeout()},onTransportError:function(){r._eventHandlers.onTransportError()},onAuthenticated:function(n){r._eventHandlers.onAuthenticated(n)},onReceiveResponse:function(n){r._receiveResponse(n)}});if(o.send(),(this._request.method===la.INVITE||this._request.method===la.UPDATE&&this._request.body)&&o.clientTransaction.state!==Dl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===Dl.C.STATUS_ACCEPTED||o.clientTransaction.state===Dl.C.STATUS_COMPLETED||o.clientTransaction.state===Dl.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 $h(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function bc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function wc(c,s,r){return s&&bc(c.prototype,s),r&&bc(c,r),c}var Hh=ct,Oc=os,Cs=tt,Pr=Dr,Fh=Lh,aa=Ct(),ua=new Hh("Dialog"),Rs={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},jh=function(){wc(c,null,[{key:"C",get:function(){return Rs}}]);function c(s,r,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Rs.STATUS_CONFIRMED;if($h(this,c),this._owner=s,this._ua=s._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 Oc.IncomingResponse&&(a=r.status_code<200?Rs.STATUS_EARLY:Rs.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===Rs.STATUS_EARLY?"EARLY":"CONFIRMED"))}return wc(c,[{key:"isTerminated",value:function(){return this._status===Rs.STATUS_TERMINATED}},{key:"update",value:function(r,o){this._state=Rs.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=Rs.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),n=aa.cloneObject(a.eventHandlers),p=a.body||null,_=this._createRequest(r,t,p);n.onAuthenticated=function(){o._local_seqnum+=1};var d=new Fh(this,_,n);return d.send(),_}},{key:"receiveRequest",value:function(r){this._checkInDialogRequest(r)&&(r.method===Cs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===Cs.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===Cs.CANCEL||r===Cs.ACK?this._local_seqnum:this._local_seqnum+=1,n=new Oc.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 n}},{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===Cs.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===Cs.INVITE||r.method===Cs.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 n(){(r.server_transaction.state===Pr.C.STATUS_ACCEPTED||r.server_transaction.state===Pr.C.STATUS_COMPLETED||r.server_transaction.state===Pr.C.STATUS_TERMINATED)&&(r.server_transaction.removeListener("stateChanged",n),o._uas_pending_reply=!1)};r.server_transaction.on("stateChanged",t)}r.hasHeader("contact")&&r.server_transaction.on("stateChanged",function(){r.server_transaction.state===Pr.C.STATUS_ACCEPTED&&(o._remote_target=r.parseHeader("contact").uri)})}else r.method===Cs.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",function(){r.server_transaction.state===Pr.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}(),ca={exports:{}};function Nl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Nl=function(r){return typeof r}:Nl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Nl(c)}function Vh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Dc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function qh(c,s,r){return s&&Dc(c.prototype,s),r&&Dc(c,r),c}function Bh(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&fa(c,s)}function fa(c,s){return fa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},fa(c,s)}function Gh(c){var s=Yh();return function(){var o=Ul(c),a;if(s){var t=Ul(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Wh(this,a)}}function Wh(c,s){return s&&(Nl(s)==="object"||typeof s=="function")?s:Kh(c)}function Kh(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 Ul(c){return Ul=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ul(c)}var zh=ut.EventEmitter,Jh=ct,Xh=tt,Qh=Ss,Nc=Ct(),Zh=new Jh("RTCSession:DTMF"),Uc={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};ca.exports=function(c){Bh(r,c);var s=Gh(r);function r(o){var a;return Vh(this,r),a=s.call(this),a._session=o,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return qh(r,[{key:"send",value:function(a){var t=this,n=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 Qh.InvalidStateError(this._session.status);var p=Nc.cloneArray(n.extraHeaders);if(this.eventHandlers=Nc.cloneObject(n.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=n.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(
|
48
|
-
`);p.length>=1&&t.test(p[0])&&(this._tone=p[0].replace(t,"$2")),p.length>=2&&n.test(p[1])&&(this._duration=parseInt(p[1].replace(n,"$2"),10))}this._duration||(this._duration=Uc.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):
|
49
|
-
`,1)[0],"Status_Line");if(t===-1){Ys.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){Ys.debug("REFER succeeded"),Ys.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:a})}},{key:"_requestFailed",value:function(a,t){Ys.debug("REFER failed"),Ys.debug('emit "requestFailed"'),this.emit("requestFailed",{response:a||null,cause:t})}},{key:"id",get:function(){return this._id}}]),r}(
|
50
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var d=r.next();return t=d.done,d},e:function(d){n=!0,p=d},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw p}}}}function Od(c,s){if(c){if(typeof c=="string")return $c(c,s);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,s)}}function $c(c,s){(s==null||s>c.length)&&(s=c.length);for(var r=0,o=new Array(s);r<s;r++)o[r]=c[r];return o}function Dd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Hc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Fc(c,s,r){return s&&Hc(c.prototype,s),r&&Hc(c,r),c}function Nd(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&pa(c,s)}function pa(c,s){return pa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},pa(c,s)}function Ud(c){var s=Md();return function(){var o=$l(c),a;if(s){var t=$l(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Pd(this,a)}}function Pd(c,s){return s&&(Ll(s)==="object"||typeof s=="function")?s:xd(c)}function xd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Md(){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 $l(c){return $l=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},$l(c)}var kd=ut.EventEmitter,jc=Dt,Ld=ct,ce=tt,zs=Ss,Vc=Dr,Be=Ct(),Mr=mc,$d=os,Hl=jh,Hd=Nr,xt=ed,qc=_d,Fd=gd,jd=wd,Bc=ys(),W=new Ld("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"],Vd=function(c){Nd(r,c);var s=Ud(r);Fc(r,null,[{key:"C",get:function(){return X}}]);function r(o){var a;return Dd(this,r),W.debug("new"),a=s.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 Fc(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){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;W.debug("connect()");var p=a,_=Be.cloneObject(t.eventHandlers),d=Be.cloneArray(t.extraHeaders),g=Be.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),T=t.mediaStream||null,E=Be.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 zs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new zs.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));this._sessionTimers.enabled&&Be.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=ce.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=ce.SESSION_EXPIRES);for(var C in _)Object.prototype.hasOwnProperty.call(_,C)&&this.on(C,_[C]);this._from_tag=Be.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 Bc("sip","anonymous","anonymous.invalid"),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),d.push("Privacy: id")):t.fromUserName&&($.from_uri=new Bc("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 $d.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,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(g,A,T)}},{key:"init_incoming",value:function(a,t){var n=this;W.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=Be.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),n._failed("local",null,ce.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),p&&(this._timers.expiresTimer=setTimeout(function(){n._status===X.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),n._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]:{};W.debug("answer()");var n=this._request,p=Be.cloneArray(t.extraHeaders),_=Be.cloneObject(t.mediaConstraints),d=t.mediaStream||null,g=Be.cloneObject(t.pcConfig,{iceServers:[]}),T=t.rtcConstraints||null,E=t.rtcAnswerConstraints||null,y=Be.cloneObject(t.rtcOfferConstraints),A,C=!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 zs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==X.STATUS_WAITING_FOR_ANSWER)throw new zs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Be.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(n,"UAS")){n.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),p.unshift("Contact: ".concat(this._contact));var ae=n.parseSDP();Array.isArray(ae.media)||(ae.media=[ae.media]);var N=cs(ae.media),F;try{for(N.s();!(F=N.n()).done;){var Se=F.value;Se.type==="audio"&&(C=!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=cs(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 B=cs(A),q;try{for(B.s();!(q=B.n()).done;){var z=q.value;d.removeTrack(z)}}catch(H){B.e(H)}finally{B.f()}}!d&&_.audio===void 0&&(_.audio=$),!d&&_.video===void 0&&(_.video=L),!d&&!C&&!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"):(n.reply(480),a._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),W.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(Z){a._connection.addTrack(Z,H)})}).then(function(){if(!a._late_sdp){var H={originator:"remote",type:"offer",sdp:n.body};W.debug('emit "sdp"'),a.emit("sdp",H);var Z=new RTCSessionDescription({type:"offer",sdp:H.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(Z)}).catch(function(U){throw n.reply(488),a._failed("system",null,ce.causes.WEBRTC_ERROR),W.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(n),a._late_sdp?a._createLocalDescription("offer",a._rtcOfferConstraints).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")}):a._createLocalDescription("answer",E).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(function(H){if(a._status===X.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(n,p),n.reply(200,null,p,H,function(){a._status=X.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(n,H),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,ce.causes.CONNECTION_ERROR)})}).catch(function(H){a._status!==X.STATUS_TERMINATED&&W.warn(H)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};W.debug("terminate()");var n=t.cause||ce.causes.BYE,p=Be.cloneArray(t.extraHeaders),_=t.body,d,g=t.status_code,T=t.reason_phrase;if(this._status===X.STATUS_TERMINATED)throw new zs.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"),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(W.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(W.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!==Vc.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===Vc.C.STATUS_TERMINATED&&(a.sendRequest(ce.BYE,{extraHeaders:p,body:_}),E.terminate())}),this._ended("local",null,n),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(ce.BYE,{extraHeaders:p,body:_}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};W.debug("sendDTMF() | tones: %s",a);var n=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 zs.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&&!Be.isDecimal(p))throw new TypeError("Invalid tone duration: ".concat(p));if(p?p<xt.C.MIN_DURATION?(W.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(xt.C.MIN_DURATION," milliseconds")),p=xt.C.MIN_DURATION):p>xt.C.MAX_DURATION?(W.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(xt.C.MAX_DURATION," milliseconds")),p=xt.C.MAX_DURATION):p=Math.abs(p):p=xt.C.DEFAULT_DURATION,t.duration=p,_&&!Be.isDecimal(_))throw new TypeError("Invalid interToneGap: ".concat(_));if(_?_<xt.C.MIN_INTER_TONE_GAP?(W.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(xt.C.MIN_INTER_TONE_GAP," milliseconds")),_=xt.C.MIN_INTER_TONE_GAP):_=Math.abs(_):_=xt.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||n>=this._tones.length){this._tones=null;return}var A=this._tones[n];if(n+=1,A===",")y=2e3;else{var C=new xt(this);t.eventHandlers={onFailed:function(){E._tones=null}},C.send(A,t),y=p+_}setTimeout(T.bind(this),y)}}},{key:"sendInfo",value:function(a,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(W.debug("sendInfo()"),this._status!==X.STATUS_CONFIRMED&&this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_1XX_RECEIVED)throw new zs.InvalidStateError(this._status);var p=new qc(this);p.send(a,t,n)}},{key:"mute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};W.debug("mute()");var t=!1,n=!1;this._audioMuted===!1&&a.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&a.video&&(n=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(t===!0||n===!0)&&this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};W.debug("unmute()");var t=!1,n=!1;this._audioMuted===!0&&a.audio&&(t=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&a.video&&(n=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(t===!0||n===!0)&&this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;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");var p={succeeded:function(){n&&n()},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]:{},n=arguments.length>1?arguments[1]:void 0;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");var p={succeeded:function(){n&&n()},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]:{},n=arguments.length>1?arguments[1]:void 0;W.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(){n&&n()},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 n=this;W.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 jd(this);_.sendRefer(a,t);var d=_.id;return this._referSubscribers[d]=_,_.on("requestFailed",function(){delete n._referSubscribers[d]}),_.on("accepted",function(){delete n._referSubscribers[d]}),_.on("failed",function(){delete n._referSubscribers[d]}),_}},{key:"sendRequest",value:function(a,t){return W.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(W.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 n={originator:"remote",type:"answer",sdp:a.body};W.debug('emit "sdp"'),this.emit("sdp",n);var p=new RTCSessionDescription({type:"answer",sdp:n.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}),W.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 xt(this).init_incoming(a):_!==void 0?new qc(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(){W.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(){W.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(){W.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){W.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){W.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?(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)}},{key:"_close",value:function(){if(W.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(W.debug("close() | closing local MediaStream"),Be.closeMediaStream(this._localMediaStream)),this._status!==X.STATUS_TERMINATED){if(this._status=X.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){W.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 n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(a,t){var n=Mr.T1;function p(){this._status===X.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),n<Mr.T2&&(n=n*2,n>Mr.T2&&(n=Mr.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),n))}this._timers.invite2xxTimer=setTimeout(p.bind(this),n)}},{key:"_setACKTimer",value:function(){var a=this;this._timers.ackTimer=setTimeout(function(){a._status===X.STATUS_WAITING_FOR_ACK&&(W.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(ce.BYE),a._ended("remote",null,ce.causes.NO_ACK))},Mr.TIMER_H)}},{key:"_createRTCConnection",value:function(a,t){var n=this;this._connection=new RTCPeerConnection(a,t),this._connection.addEventListener("iceconnectionstatechange",function(){var p=n._connection.iceConnectionState;p==="failed"&&n.terminate({cause:ce.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ce.causes.RTP_TIMEOUT})}),W.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var n=this;if(W.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 W.warn('emit "peerconnection:createofferfailed" [error:%o]',_),n.emit("peerconnection:createofferfailed",_),Promise.reject(_)}):p.createAnswer(t).catch(function(_){return W.warn('emit "peerconnection:createanswerfailed" [error:%o]',_),n.emit("peerconnection:createanswerfailed",_),Promise.reject(_)})}).then(function(_){return p.setLocalDescription(_).catch(function(d){return n._rtcReady=!0,W.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',d),n.emit("peerconnection:setlocaldescriptionfailed",d),Promise.reject(d)})}).then(function(){var _=t&&t.iceRestart;if(p.iceGatheringState==="complete"&&!_||p.iceGatheringState==="gathering"&&n._iceReady){n._rtcReady=!0;var d={originator:"local",type:a,sdp:p.localDescription.sdp};return W.debug('emit "sdp"'),n.emit("sdp",d),Promise.resolve(d.sdp)}return new Promise(function(g){var T=!1,E,y;n._iceReady=!1;var A=function(){p.removeEventListener("icecandidate",E),p.removeEventListener("icegatheringstatechange",y),T=!0,n._rtcReady=!0,n._iceReady=!0;var I={originator:"local",type:a,sdp:p.localDescription.sdp};W.debug('emit "sdp"'),n.emit("sdp",I),g(I.sdp)};p.addEventListener("icecandidate",E=function(I){var $=I.candidate;$?n.emit("icecandidate",{candidate:$,ready:A}):T||A()}),p.addEventListener("icegatheringstatechange",y=function(){p.iceGatheringState==="complete"&&!T&&A()})})})}},{key:"_createDialog",value:function(a,t,n){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(n)return g?!0:(g=new Hl(this,a,t,Hl.C.STATUS_EARLY),g.error?(W.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 Hl(this,a,t);return T.error?(W.debug(T.error),this._failed("remote",a,ce.causes.INTERNAL_ERROR),!1):(this._dialog=T,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;W.debug("receiveReinvite()");var n=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=Be.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(n!=="application/sdp"){W.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){W.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;W.debug("receiveUpdate()");var n=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=Be.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(n!=="application/sdp"){W.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){W.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;W.debug("_processInDialogSdpOffer()");var n=a.parseSDP(),p=!1,_=cs(n.media),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;if(Fl.indexOf(g.type)!==-1){var T=g.direction||n.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};W.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),W.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),W.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',A),A})}).catch(function(A){W.warn("_processInDialogSdpOffer() failed [error: %o]",A)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(W.debug("receiveRefer()"),!a.refer_to){W.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==ce.SIP){W.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var n=new Fd(this,a.cseq);W.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;n.notify(A.status_code,A.reason_phrase)}),T.on("accepted",function(y){var A=y.response;n.notify(A.status_code,A.reason_phrase)}),T.on("_failed",function(y){var A=y.message,C=y.cause;A?n.notify(A.status_code,A.reason_phrase):n.notify(487,C)}),a.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(a.refer_to.uri.getHeader("replaces"));g.extraHeaders=Be.cloneArray(g.extraHeaders),g.extraHeaders.push("Replaces: ".concat(E))}T.connect(a.refer_to.uri.toAor(),g,d)}function _(){n.notify(603)}}},{key:"_receiveNotify",value:function(a){switch(W.debug("receiveNotify()"),a.event||a.reply(400),a.event.event){case"refer":{var t,n;if(a.event.params&&a.event.params.id)t=a.event.params.id,n=this._referSubscribers[t];else if(Object.keys(this._referSubscribers).length===1)n=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{a.reply(400,"Missing event id parameter");return}if(!n){a.reply(481,"Subscription does not exist");return}n.receiveNotify(a),a.reply(200);break}default:a.reply(489)}}},{key:"_receiveReplaces",value:function(a){var t=this;W.debug("receiveReplaces()");function n(_){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(){W.debug("Replaced INVITE rejected by the user"),a.reply(486)}this.emit("replaces",{request:a,accept:function(d){n.call(t,d)},reject:function(){p.call(t)}})}},{key:"_sendInitialRequest",value:function(a,t,n){var p=this,_=new Hd(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(n)return n;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),W.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,W.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),_.send()}).catch(function(d){p._status!==X.STATUS_TERMINATED&&W.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)){W.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(W.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 n=new Hl(this,a,"UAC");if(n.error!==void 0){W.debug(n.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){W.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};W.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){W.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};W.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),W.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var T=Be.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]:{};W.debug("sendReinvite()");var n=Be.cloneArray(t.extraHeaders),p=Be.cloneObject(t.eventHandlers),_=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=!1;n.push("Contact: ".concat(this._contact)),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",_)}).then(function(E){E=a._mangleOffer(E);var y={originator:"local",type:"offer",sdp:E};W.debug('emit "sdp"'),a.emit("sdp",y),a.sendRequest(ce.INVITE,{extraHeaders:n,body:E,eventHandlers:{onSuccessResponse:function(C){g.call(a,C),d=!0},onErrorResponse:function(C){T.call(a,C)},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};W.debug('emit "sdp"'),this.emit("sdp",A);var C=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return y._connection.setRemoteDescription(C)}).then(function(){p.succeeded&&p.succeeded(E)}).catch(function(I){T.call(y),W.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]:{};W.debug("sendUpdate()");var n=Be.cloneArray(t.extraHeaders),p=Be.cloneObject(t.eventHandlers),_=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=t.sdpOffer||!1,g=!1;n.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),d?(n.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};W.debug('emit "sdp"'),a.emit("sdp",A),a.sendRequest(ce.UPDATE,{extraHeaders:n,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:n,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 C={originator:"remote",type:"answer",sdp:y.body};W.debug('emit "sdp"'),this.emit("sdp",C);var I=new RTCSessionDescription({type:"answer",sdp:C.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return A._connection.setRemoteDescription(I)}).then(function(){p.succeeded&&p.succeeded(y)}).catch(function($){E.call(A),W.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,n){W.debug("acceptAndTerminate()");var p=[];t&&(n=n||ce.REASON_PHRASE[t]||"",p.push("Reason: SIP ;cause=".concat(t,'; text="').concat(n,'"'))),(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=jc.parse(a),this._localHold&&!this._remoteHold){W.debug("mangleOffer() | me on hold, mangling offer");var t=cs(a.media),n;try{for(t.s();!(n=t.n()).done;){var p=n.value;Fl.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){W.debug("mangleOffer() | both on hold, mangling offer");var _=cs(a.media),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;Fl.indexOf(g.type)!==-1&&(g.direction="inactive")}}catch(A){_.e(A)}finally{_.f()}}else if(this._remoteHold){W.debug("mangleOffer() | remote on hold, mangling offer");var T=cs(a.media),E;try{for(T.s();!(E=T.n()).done;){var y=E.value;Fl.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 jc.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 n;a.session_expires&&a.session_expires>=ce.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,n=a.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(n)),this._sessionTimers.refresher=n==="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()&&(W.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&&(W.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"}),n=cs(t),p;try{for(n.s();!(p=n.n()).done;){var _=p.value;_.track.enabled=!a}}catch(d){n.e(d)}finally{n.f()}}},{key:"_toggleMuteVideo",value:function(a){var t=this._connection.getSenders().filter(function(d){return d.track&&d.track.kind==="video"}),n=cs(t),p;try{for(n.s();!(p=n.n()).done;){var _=p.value;_.track.enabled=!a}}catch(d){n.e(d)}finally{n.f()}}},{key:"_newRTCSession",value:function(a,t){W.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){W.debug("session connecting"),W.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){W.debug("session progress"),W.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){W.debug("session accepted"),this._start_time=new Date,W.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){W.debug("session confirmed"),this._is_confirmed=!0,W.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,n){W.debug("session ended"),this._end_time=new Date,this._close(),W.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:n})}},{key:"_failed",value:function(a,t,n){W.debug("session failed"),W.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:n}),this._close(),W.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:n})}},{key:"_onhold",value:function(a){W.debug("session onhold"),this._setLocalMediaStatus(),W.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){W.debug("session onunhold"),this._setLocalMediaStatus(),W.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,n=a.video;W.debug("session onmute"),this._setLocalMediaStatus(),W.debug('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(a){var t=a.audio,n=a.video;W.debug("session onunmute"),this._setLocalMediaStatus(),W.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{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}(kd);function jl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jl=function(r){return typeof r}:jl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},jl(c)}function qd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Gc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Bd(c,s,r){return s&&Gc(c.prototype,s),r&&Gc(c,r),c}function Gd(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&ma(c,s)}function ma(c,s){return ma=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ma(c,s)}function Wd(c){var s=zd();return function(){var o=Vl(c),a;if(s){var t=Vl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Kd(this,a)}}function Kd(c,s){return s&&(jl(s)==="object"||typeof s=="function")?s: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 Vl(c){return Vl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Vl(c)}var Jd=ut.EventEmitter,Xd=ct,ga=tt,Qd=os,kr=Ct(),Zd=Nr,Wc=Ss,ep=ys(),ql=new Xd("Message"),tp=function(c){Gd(r,c);var s=Wd(r);function r(o){var a;return qd(this,r),a=s.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(r,[{key:"send",value:function(a,t){var n=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=kr.cloneArray(p.extraHeaders),g=kr.cloneObject(p.eventHandlers),T=p.contentType||"text/plain",E={};p.fromUserName&&(E.from_uri=new ep("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 Qd.OutgoingRequest(ga.MESSAGE,a,this._ua,E,d),t&&(this._request.body=t);var A=new Zd(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(I){n._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=kr.cloneArray(a.extraHeaders),n=a.body;if(this._direction!=="incoming")throw new Wc.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,n=a.reason_phrase,p=kr.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new Wc.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: ".concat(t));this._is_replied=!0,this._request.reply(t,n,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=kr.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,ga.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,ga.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,n){ql.debug("MESSAGE failed"),this._close(),ql.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:n})}},{key:"_succeeded",value:function(a,t){ql.debug("MESSAGE succeeded"),this._close(),ql.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}(Jd);function Bl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Bl=function(r){return typeof r}:Bl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Bl(c)}function sp(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Kc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function np(c,s,r){return s&&Kc(c.prototype,s),r&&Kc(c,r),c}function rp(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Ta(c,s)}function Ta(c,s){return Ta=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ta(c,s)}function ip(c){var s=ap();return function(){var o=Gl(c),a;if(s){var t=Gl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return lp(this,a)}}function lp(c,s){return s&&(Bl(s)==="object"||typeof s=="function")?s:op(c)}function op(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ap(){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 Gl(c){return Gl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Gl(c)}var up=ut.EventEmitter,cp=ct,va=tt,fp=os,Lr=Ct(),_p=Nr,Yc=Ss,Wl=new cp("Options"),hp=function(c){rp(r,c);var s=ip(r);function r(o){var a;return sp(this,r),a=s.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 np(r,[{key:"send",value:function(a,t){var n=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=Lr.cloneArray(p.extraHeaders),g=Lr.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 fp.OutgoingRequest(va.OPTIONS,a,this._ua,null,d),t&&(this._request.body=t);var y=new _p(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(C){n._receiveResponse(C)}});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=Lr.cloneArray(a.extraHeaders),n=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,n)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,n=a.reason_phrase,p=Lr.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,n,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=Lr.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,va.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,va.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,n){Wl.debug("OPTIONS failed"),this._close(),Wl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:n})}},{key:"_succeeded",value:function(a,t){Wl.debug("OPTIONS succeeded"),this._close(),Wl.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}(up),Ea={},dp=ct,Sa=Ct(),pp=Xt(),$r=new dp("Socket");Ea.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return $r.warn("undefined JsSIP.Socket instance"),!1;try{if(!Sa.isString(c.url))throw $r.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!Sa.isString(c.via_transport))throw $r.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(pp.parse(c.sip_uri,"SIP_URI")===-1)throw $r.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(s){if(!Sa.isFunction(c[s]))throw $r.warn("missing or invalid JsSIP.Socket method: ".concat(s)),new Error("Missing or invalid JsSIP.Socket method: ".concat(s))})}catch{return!1}return!0};function mp(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function zc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function gp(c,s,r){return s&&zc(c.prototype,s),r&&zc(c,r),c}var Tp=ct,vp=Ea,Jc=tt,Nt=new Tp("Transport"),Lt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Jc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Jc.CONNECTION_RECOVERY_MAX_INTERVAL}},Ep=function(){function c(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lt.recovery_options;mp(this,c),Nt.debug("new()"),this.status=Lt.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){Nt.warn("cannot use TextDecoder: ".concat(o))}if(typeof s>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");s instanceof Array||(s=[s]),s.forEach(function(o){if(!vp.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:Lt.SOCKET_STATUS_READY})},this),this._getSocket()}return gp(c,[{key:"connect",value:function(){if(Nt.debug("connect()"),this.isConnected()){Nt.debug("Transport is already connected");return}else if(this.isConnecting()){Nt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Lt.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(){Nt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Lt.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(Nt.debug("send()"),!this.isConnected())return Nt.warn("unable to send message, transport is not connected"),!1;var o=r.toString();return Nt.debug(`sending message:
|
46
|
+
`),this.transport.send(p)}}]),r}(hc),uh=function(c){Qo(r,c);var s=ea(r);function r(){var o;return yr(this,r),o=s.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return r}(hc),os={OutgoingRequest:_c,InitialOutgoingInviteRequest:oh,IncomingRequest:ah,IncomingResponse:uh};function ch(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function dc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function fh(c,s,r){return s&&dc(c.prototype,s),r&&dc(c,r),c}var _h=ct,as=Ct(),Gt=new _h("DigestAuthentication"),hh=function(){function c(s){ch(this,c),this._credentials=s,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 fh(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,n=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||as.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=as.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1;var h,g;return this._qop==="auth"?(h="".concat(this._method,":").concat(this._uri),g=as.calculateMD5(h),Gt.debug('authenticate() | using qop=auth [a2:"%s"]',h),this._response=as.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(g))):this._qop==="auth-int"?(h="".concat(this._method,":").concat(this._uri,":").concat(as.calculateMD5(n||"")),g=as.calculateMD5(h),Gt.debug('authenticate() | using qop=auth-int [a2:"%s"]',h),this._response=as.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(g))):this._qop===null&&(h="".concat(this._method,":").concat(this._uri),g=as.calculateMD5(h),Gt.debug('authenticate() | using qop=null [a2:"%s"]',h),this._response=as.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}(),us=500,dh=4e3,pc=5e3,mc={T1:us,T2:dh,T4:pc,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*pc,TIMER_L:64*us,TIMER_M:64*us,PROVISIONAL_RESPONSE_INTERVAL:6e4};function Rl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Rl=function(r){return typeof r}:Rl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Rl(c)}function Ar(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function gc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Cr(c,s,r){return s&&gc(c.prototype,s),r&&gc(c,r),c}function Rr(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&sa(c,s)}function sa(c,s){return sa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},sa(c,s)}function Ir(c){var s=mh();return function(){var o=Il(c),a;if(s){var t=Il(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return ph(this,a)}}function ph(c,s){return s&&(Rl(s)==="object"||typeof s=="function")?s:As(c)}function As(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function mh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Il(c){return Il=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Il(c)}var br=ut.EventEmitter,wr=ct,Or=tt,Tc=os,Qt=mc,vc=new wr("NonInviteClientTransaction"),bl=new wr("InviteClientTransaction"),gh=new wr("AckClientTransaction"),Ec=new wr("NonInviteServerTransaction"),wl=new wr("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"},Th=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t,n){var p;Ar(this,r),p=s.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=n;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(As(p)),p}return Cr(r,[{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()},Qt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){vc.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(){vc.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,n=a.status_code;if(n<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),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},Qt.TIMER_K);break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),r}(br),vh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t,n){var p;Ar(this,r),p=s.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=n,t.transaction=As(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(As(p)),p}return Cr(r,[{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()},Qt.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&&(bl.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(){bl.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(){bl.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(){bl.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,n=new Tc.OutgoingRequest(Or.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",a.getHeader("to")),this.D=setTimeout(function(){t.timer_D()},Qt.TIMER_D),this.transport.send(n)}},{key:"cancel",value:function(a){if(this.state===ue.STATUS_PROCEEDING){var t=new Tc.OutgoingRequest(Or.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,n=a.status_code;if(n>=100&&n<=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(n>=200&&n<=299)switch(this.state){case ue.STATUS_CALLING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},Qt.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(n>=300&&n<=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}}]),r}(br),Eh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t,n){var p;Ar(this,r),p=s.call(this),p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.transport=a,p.request=t,p.eventHandlers=n;var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p}return Cr(r,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){gh.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return ue}}]),r}(br),Sh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t){var n;return Ar(this,r),n=s.call(this),n.type=ue.NON_INVITE_SERVER,n.id=t.via_branch,n.ua=o,n.transport=a,n.request=t,n.last_response="",t.server_transaction=As(n),n.state=ue.STATUS_TRYING,o.newTransaction(As(n)),n}return Cr(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){Ec.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,Ec.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,n,p){var _=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)?n&&n():(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(){_.timer_J()},Qt.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),p&&p());break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),r}(br),yh=function(c){Rr(r,c);var s=Ir(r);function r(o,a,t){var n;return Ar(this,r),n=s.call(this),n.type=ue.INVITE_SERVER,n.id=t.via_branch,n.ua=o,n.transport=a,n.request=t,n.last_response="",t.server_transaction=As(n),n.state=ue.STATUS_PROCEEDING,o.newTransaction(As(n)),n.resendProvisionalTimer=null,t.reply(100),n}return Cr(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){wl.debug("Timer H expired for transaction ".concat(this.id)),this.state===ue.STATUS_COMPLETED&&wl.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(){wl.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,wl.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,n,p){var _=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(){_.resend_provisional()},Qt.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(){_.timer_L()},Qt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ue.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(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(){_.timer_H()},Qt.TIMER_H),n&&n()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return ue}}]),r}(br);function Ah(c,s){var r=c._transactions,o;switch(s.method){case Or.INVITE:if(o=r.ist[s.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 Or.ACK:if(o=r.ist[s.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()},Qt.TIMER_I),!0}else return!1;break;case Or.CANCEL:return o=r.ist[s.via_branch],o?(s.reply_sl(200),o.state!==ue.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(o=r.nist[s.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 Dr={C:ue,NonInviteClientTransaction:Th,InviteClientTransaction:vh,AckClientTransaction:Eh,NonInviteServerTransaction:Sh,InviteServerTransaction:yh,checkTransaction:Ah};function Ch(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Sc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Rh(c,s,r){return s&&Sc(c.prototype,s),r&&Sc(c,r),c}var Ih=ct,yc=tt,bh=hh,na=Dr,wh=new Ih("RequestSender"),ra={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Nr=function(){function c(s,r,o){Ch(this,c),this._ua=s,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]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==yc.BYE||this._method!==yc.ACK)&&this._eventHandlers.onTransportError()}return Rh(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){wh.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 bh({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 Oh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Ac(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Dh(c,s,r){return s&&Ac(c.prototype,s),r&&Ac(c,r),c}var Nh=ct,ia=Ct(),Ks=tt,Cc=os,Rc=Nr,Ur=new Nh("Registrator"),Ol=10,Uh=function(){function c(s,r){Oh(this,c),this._reg_id=1,this._ua=s,this._transport=r,this._registrar=s.configuration.registrar_server,this._expires=s.configuration.register_expires,this._call_id=ia.createRandomToken(22),this._cseq=0,this._to_uri=s.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 Dh(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){Ur.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 Cc.OutgoingRequest(Ks.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new Rc(this._ua,a,{onRequestTimeout:function(){r._registrationFailure(null,Ks.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._registrationFailure(null,Ks.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")){Ur.debug("no Contact header in response to REGISTER, response ignored");break}var _=p.headers.Contact.reduce(function(y,A){return y.concat(A.parsed)},[]),h=_.find(function(y){return r._sipInstance===y.getParam("+sip.instance")&&r._reg_id===parseInt(y.getParam("reg-id"))});if(h||(h=_.find(function(y){return y.uri.user===r._ua.contact.uri.user})),!h){Ur.debug("no Contact header pointing to us, response ignored");break}var g=h.getParam("expires");!g&&p.hasHeader("expires")&&(g=p.getHeader("expires")),g||(g=r._expires),g=Number(g),g<Ol&&(g=Ol);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),h.hasParam("temp-gruu")&&(r._ua.contact.temp_gruu=h.getParam("temp-gruu").replace(/"/g,"")),h.hasParam("pub-gruu")&&(r._ua.contact.pub_gruu=h.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<Ol&&(r._expires=Ol),r.register()):(Ur.debug("423 response received for REGISTER without Min-Expires"),r._registrationFailure(p,Ks.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){Ur.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 Cc.OutgoingRequest(Ks.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),n=new Rc(this._ua,t,{onRequestTimeout:function(){r._unregistered(null,Ks.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._unregistered(null,Ks.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 h=ia.sipErrorCause(_.status_code);r._unregistered(_,h)}}}});n.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 Ph(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Ic(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function xh(c,s,r){return s&&Ic(c.prototype,s),r&&Ic(c,r),c}var la=tt,Dl=Dr,Mh=Nr,oa={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},kh=function(){function c(s,r,o){Ph(this,c),this._dialog=s,this._ua=s._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 xh(c,[{key:"send",value:function(){var r=this,o=new Mh(this._ua,this._request,{onRequestTimeout:function(){r._eventHandlers.onRequestTimeout()},onTransportError:function(){r._eventHandlers.onTransportError()},onAuthenticated:function(n){r._eventHandlers.onAuthenticated(n)},onReceiveResponse:function(n){r._receiveResponse(n)}});if(o.send(),(this._request.method===la.INVITE||this._request.method===la.UPDATE&&this._request.body)&&o.clientTransaction.state!==Dl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===Dl.C.STATUS_ACCEPTED||o.clientTransaction.state===Dl.C.STATUS_COMPLETED||o.clientTransaction.state===Dl.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 Lh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function bc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function wc(c,s,r){return s&&bc(c.prototype,s),r&&bc(c,r),c}var $h=ct,Oc=os,Cs=tt,Pr=Dr,Hh=kh,aa=Ct(),ua=new $h("Dialog"),Rs={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},Fh=function(){wc(c,null,[{key:"C",get:function(){return Rs}}]);function c(s,r,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Rs.STATUS_CONFIRMED;if(Lh(this,c),this._owner=s,this._ua=s._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 Oc.IncomingResponse&&(a=r.status_code<200?Rs.STATUS_EARLY:Rs.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===Rs.STATUS_EARLY?"EARLY":"CONFIRMED"))}return wc(c,[{key:"isTerminated",value:function(){return this._status===Rs.STATUS_TERMINATED}},{key:"update",value:function(r,o){this._state=Rs.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=Rs.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),n=aa.cloneObject(a.eventHandlers),p=a.body||null,_=this._createRequest(r,t,p);n.onAuthenticated=function(){o._local_seqnum+=1};var h=new Hh(this,_,n);return h.send(),_}},{key:"receiveRequest",value:function(r){this._checkInDialogRequest(r)&&(r.method===Cs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===Cs.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===Cs.CANCEL||r===Cs.ACK?this._local_seqnum:this._local_seqnum+=1,n=new Oc.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 n}},{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===Cs.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===Cs.INVITE||r.method===Cs.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 n(){(r.server_transaction.state===Pr.C.STATUS_ACCEPTED||r.server_transaction.state===Pr.C.STATUS_COMPLETED||r.server_transaction.state===Pr.C.STATUS_TERMINATED)&&(r.server_transaction.removeListener("stateChanged",n),o._uas_pending_reply=!1)};r.server_transaction.on("stateChanged",t)}r.hasHeader("contact")&&r.server_transaction.on("stateChanged",function(){r.server_transaction.state===Pr.C.STATUS_ACCEPTED&&(o._remote_target=r.parseHeader("contact").uri)})}else r.method===Cs.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",function(){r.server_transaction.state===Pr.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}(),ca={exports:{}};function Nl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Nl=function(r){return typeof r}:Nl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Nl(c)}function jh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Dc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Vh(c,s,r){return s&&Dc(c.prototype,s),r&&Dc(c,r),c}function qh(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&fa(c,s)}function fa(c,s){return fa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},fa(c,s)}function Bh(c){var s=Kh();return function(){var o=Ul(c),a;if(s){var t=Ul(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Gh(this,a)}}function Gh(c,s){return s&&(Nl(s)==="object"||typeof s=="function")?s:Wh(c)}function Wh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Kh(){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 Ul(c){return Ul=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ul(c)}var Yh=ut.EventEmitter,Jh=ct,zh=tt,Xh=Ss,Nc=Ct(),Qh=new Jh("RTCSession:DTMF"),Uc={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};ca.exports=function(c){qh(r,c);var s=Bh(r);function r(o){var a;return jh(this,r),a=s.call(this),a._session=o,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return Vh(r,[{key:"send",value:function(a){var t=this,n=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 Xh.InvalidStateError(this._session.status);var p=Nc.cloneArray(n.extraHeaders);if(this.eventHandlers=Nc.cloneObject(n.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=n.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(zh.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)?.*/,n=/^(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&&n.test(p[1])&&(this._duration=parseInt(p[1].replace(n,"$2"),10))}this._duration||(this._duration=Uc.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):Qh.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),r}(Yh),ca.exports.C=Uc;var Zh=ca.exports;function Pl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Pl=function(r){return typeof r}:Pl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Pl(c)}function ed(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Pc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function td(c,s,r){return s&&Pc(c.prototype,s),r&&Pc(c,r),c}function sd(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&_a(c,s)}function _a(c,s){return _a=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},_a(c,s)}function nd(c){var s=ld();return function(){var o=xl(c),a;if(s){var t=xl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return rd(this,a)}}function rd(c,s){return s&&(Pl(s)==="object"||typeof s=="function")?s:id(c)}function id(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ld(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function xl(c){return xl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},xl(c)}var od=ut.EventEmitter,ad=tt,ud=Ss,cd=Ct(),fd=function(c){sd(r,c);var s=nd(r);function r(o){var a;return ed(this,r),a=s.call(this),a._session=o,a._direction=null,a._contentType=null,a._body=null,a}return td(r,[{key:"send",value:function(a,t){var n=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 ud.InvalidStateError(this._session.status);this._contentType=a,this._body=t;var _=cd.cloneArray(p.extraHeaders);_.push("Content-Type: ".concat(a)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(ad.INFO,{extraHeaders:_,eventHandlers:{onSuccessResponse:function(g){n.emit("succeeded",{originator:"remote",response:g})},onErrorResponse:function(g){n.emit("failed",{originator:"remote",response:g})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._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}(od);function _d(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function xc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function hd(c,s,r){return s&&xc(c.prototype,s),r&&xc(c,r),c}var dd=ct,Mc=tt,pd=new dd("RTCSession:ReferNotifier"),ha={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300},md=function(){function c(s,r,o){_d(this,c),this._session=s,this._id=r,this._expires=o||ha.expires,this._active=!0,this.notify(100)}return hd(c,[{key:"notify",value:function(r,o){if(pd.debug("notify()"),this._active!==!1){o=o||Mc.REASON_PHRASE[r]||"";var a;r>=200?a="terminated;reason=noresource":a="active;expires=".concat(this._expires),this._session.sendRequest(Mc.NOTIFY,{extraHeaders:["Event: ".concat(ha.event_type,";id=").concat(this._id),"Subscription-State: ".concat(a),"Content-Type: ".concat(ha.body_type)],body:"SIP/2.0 ".concat(r," ").concat(o),eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),c}();function Ml(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ml=function(r){return typeof r}:Ml=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ml(c)}function gd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function kc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Td(c,s,r){return s&&kc(c.prototype,s),r&&kc(c,r),c}function vd(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&da(c,s)}function da(c,s){return da=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},da(c,s)}function Ed(c){var s=Ad();return function(){var o=kl(c),a;if(s){var t=kl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Sd(this,a)}}function Sd(c,s){return s&&(Ml(s)==="object"||typeof s=="function")?s: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 Ad(){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 kl(c){return kl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},kl(c)}var Cd=ut.EventEmitter,Rd=ct,xr=tt,Id=Xt(),Lc=Ct(),Ys=new Rd("RTCSession:ReferSubscriber"),bd=function(c){vd(r,c);var s=Ed(r);function r(o){var a;return gd(this,r),a=s.call(this),a._id=null,a._session=o,a}return Td(r,[{key:"sendRefer",value:function(a){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ys.debug("sendRefer()");var p=Lc.cloneArray(n.extraHeaders),_=Lc.cloneObject(n.eventHandlers);for(var h in _)Object.prototype.hasOwnProperty.call(_,h)&&this.on(h,_[h]);var g=null;n.replaces&&(g=n.replaces._request.call_id,g+=";to-tag=".concat(n.replaces._to_tag),g+=";from-tag=".concat(n.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(xr.REFER,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(C){t._requestSucceeded(C)},onErrorResponse:function(C){t._requestFailed(C,xr.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,xr.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,xr.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,xr.causes.DIALOG_ERROR)}}});this._id=y.cseq}},{key:"receiveNotify",value:function(a){if(Ys.debug("receiveNotify()"),!!a.body){var t=Id.parse(a.body.trim().split(`\r
|
49
|
+
`,1)[0],"Status_Line");if(t===-1){Ys.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){Ys.debug("REFER succeeded"),Ys.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:a})}},{key:"_requestFailed",value:function(a,t){Ys.debug("REFER failed"),Ys.debug('emit "requestFailed"'),this.emit("requestFailed",{response:a||null,cause:t})}},{key:"id",get:function(){return this._id}}]),r}(Cd);function Ll(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ll=function(r){return typeof r}:Ll=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ll(c)}function cs(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=wd(c))||s&&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(h){throw h},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,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,p=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw p}}}}function wd(c,s){if(c){if(typeof c=="string")return $c(c,s);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,s)}}function $c(c,s){(s==null||s>c.length)&&(s=c.length);for(var r=0,o=new Array(s);r<s;r++)o[r]=c[r];return o}function Od(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Hc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Fc(c,s,r){return s&&Hc(c.prototype,s),r&&Hc(c,r),c}function Dd(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&pa(c,s)}function pa(c,s){return pa=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},pa(c,s)}function Nd(c){var s=xd();return function(){var o=$l(c),a;if(s){var t=$l(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Ud(this,a)}}function Ud(c,s){return s&&(Ll(s)==="object"||typeof s=="function")?s:Pd(c)}function Pd(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 $l(c){return $l=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},$l(c)}var Md=ut.EventEmitter,jc=Dt,kd=ct,ce=tt,Js=Ss,Vc=Dr,Be=Ct(),Mr=mc,Ld=os,Hl=Fh,$d=Nr,xt=Zh,qc=fd,Hd=md,Fd=bd,Bc=ys(),W=new kd("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"],jd=function(c){Dd(r,c);var s=Nd(r);Fc(r,null,[{key:"C",get:function(){return X}}]);function r(o){var a;return Od(this,r),W.debug("new"),a=s.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 Fc(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){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;W.debug("connect()");var p=a,_=Be.cloneObject(t.eventHandlers),h=Be.cloneArray(t.extraHeaders),g=Be.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),T=t.mediaStream||null,E=Be.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 Js.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Js.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));this._sessionTimers.enabled&&Be.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=ce.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=ce.SESSION_EXPIRES);for(var C in _)Object.prototype.hasOwnProperty.call(_,C)&&this.on(C,_[C]);this._from_tag=Be.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 Bc("sip","anonymous","anonymous.invalid"),h.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),h.push("Privacy: id")):t.fromUserName&&($.from_uri=new Bc("sip",t.fromUserName,this._ua.configuration.uri.host),h.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&($.from_display_name=t.fromDisplayName),h.push("Contact: ".concat(this._contact)),h.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&h.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new Ld.InitialOutgoingInviteRequest(a,this._ua,$,h),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,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(g,A,T)}},{key:"init_incoming",value:function(a,t){var n=this;W.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=Be.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),n._failed("local",null,ce.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),p&&(this._timers.expiresTimer=setTimeout(function(){n._status===X.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),n._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]:{};W.debug("answer()");var n=this._request,p=Be.cloneArray(t.extraHeaders),_=Be.cloneObject(t.mediaConstraints),h=t.mediaStream||null,g=Be.cloneObject(t.pcConfig,{iceServers:[]}),T=t.rtcConstraints||null,E=t.rtcAnswerConstraints||null,y=Be.cloneObject(t.rtcOfferConstraints),A,C=!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 Js.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==X.STATUS_WAITING_FOR_ANSWER)throw new Js.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Be.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(n,"UAS")){n.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),p.unshift("Contact: ".concat(this._contact));var ae=n.parseSDP();Array.isArray(ae.media)||(ae.media=[ae.media]);var N=cs(ae.media),F;try{for(N.s();!(F=N.n()).done;){var Se=F.value;Se.type==="audio"&&(C=!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(h&&_.audio===!1){A=h.getAudioTracks();var ve=cs(A),M;try{for(ve.s();!(M=ve.n()).done;){var D=M.value;h.removeTrack(D)}}catch(H){ve.e(H)}finally{ve.f()}}if(h&&_.video===!1){A=h.getVideoTracks();var B=cs(A),q;try{for(B.s();!(q=B.n()).done;){var J=q.value;h.removeTrack(J)}}catch(H){B.e(H)}finally{B.f()}}!h&&_.audio===void 0&&(_.audio=$),!h&&_.video===void 0&&(_.video=L),!h&&!C&&!y.offerToReceiveAudio&&(_.audio=!1),!h&&!I&&!y.offerToReceiveVideo&&(_.video=!1),this._createRTCConnection(g,T),Promise.resolve().then(function(){if(h)return h;if(_.audio||_.video)return a._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(_).catch(function(H){throw a._status===X.STATUS_TERMINATED?new Error("terminated"):(n.reply(480),a._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),W.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(Z){a._connection.addTrack(Z,H)})}).then(function(){if(!a._late_sdp){var H={originator:"remote",type:"offer",sdp:n.body};W.debug('emit "sdp"'),a.emit("sdp",H);var Z=new RTCSessionDescription({type:"offer",sdp:H.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(Z)}).catch(function(U){throw n.reply(488),a._failed("system",null,ce.causes.WEBRTC_ERROR),W.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(n),a._late_sdp?a._createLocalDescription("offer",a._rtcOfferConstraints).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")}):a._createLocalDescription("answer",E).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(function(H){if(a._status===X.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(n,p),n.reply(200,null,p,H,function(){a._status=X.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(n,H),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,ce.causes.CONNECTION_ERROR)})}).catch(function(H){a._status!==X.STATUS_TERMINATED&&W.warn(H)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};W.debug("terminate()");var n=t.cause||ce.causes.BYE,p=Be.cloneArray(t.extraHeaders),_=t.body,h,g=t.status_code,T=t.reason_phrase;if(this._status===X.STATUS_TERMINATED)throw new Js.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"),g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));g&&(T=T||ce.REASON_PHRASE[g]||"",h="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=h):this._status===X.STATUS_1XX_RECEIVED&&this._request.cancel(h),this._status=X.STATUS_CANCELED,this._failed("local",null,ce.causes.CANCELED);break;case X.STATUS_WAITING_FOR_ANSWER:case X.STATUS_ANSWERED:if(W.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(W.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!==Vc.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===Vc.C.STATUS_TERMINATED&&(a.sendRequest(ce.BYE,{extraHeaders:p,body:_}),E.terminate())}),this._ended("local",null,n),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(ce.BYE,{extraHeaders:p,body:_}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};W.debug("sendDTMF() | tones: %s",a);var n=0,p=t.duration||null,_=t.interToneGap||null,h=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 Js.InvalidStateError(this._status);if(h!==ce.DTMF_TRANSPORT.INFO&&h!==ce.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(h));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&&!Be.isDecimal(p))throw new TypeError("Invalid tone duration: ".concat(p));if(p?p<xt.C.MIN_DURATION?(W.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(xt.C.MIN_DURATION," milliseconds")),p=xt.C.MIN_DURATION):p>xt.C.MAX_DURATION?(W.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(xt.C.MAX_DURATION," milliseconds")),p=xt.C.MAX_DURATION):p=Math.abs(p):p=xt.C.DEFAULT_DURATION,t.duration=p,_&&!Be.isDecimal(_))throw new TypeError("Invalid interToneGap: ".concat(_));if(_?_<xt.C.MIN_INTER_TONE_GAP?(W.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(xt.C.MIN_INTER_TONE_GAP," milliseconds")),_=xt.C.MIN_INTER_TONE_GAP):_=Math.abs(_):_=xt.C.DEFAULT_INTER_TONE_GAP,h===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||n>=this._tones.length){this._tones=null;return}var A=this._tones[n];if(n+=1,A===",")y=2e3;else{var C=new xt(this);t.eventHandlers={onFailed:function(){E._tones=null}},C.send(A,t),y=p+_}setTimeout(T.bind(this),y)}}},{key:"sendInfo",value:function(a,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(W.debug("sendInfo()"),this._status!==X.STATUS_CONFIRMED&&this._status!==X.STATUS_WAITING_FOR_ACK&&this._status!==X.STATUS_1XX_RECEIVED)throw new Js.InvalidStateError(this._status);var p=new qc(this);p.send(a,t,n)}},{key:"mute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};W.debug("mute()");var t=!1,n=!1;this._audioMuted===!1&&a.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&a.video&&(n=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(t===!0||n===!0)&&this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};W.debug("unmute()");var t=!1,n=!1;this._audioMuted===!0&&a.audio&&(t=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&a.video&&(n=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(t===!0||n===!0)&&this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;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");var p={succeeded:function(){n&&n()},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]:{},n=arguments.length>1?arguments[1]:void 0;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");var p={succeeded:function(){n&&n()},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]:{},n=arguments.length>1?arguments[1]:void 0;W.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(){n&&n()},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 n=this;W.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 Fd(this);_.sendRefer(a,t);var h=_.id;return this._referSubscribers[h]=_,_.on("requestFailed",function(){delete n._referSubscribers[h]}),_.on("accepted",function(){delete n._referSubscribers[h]}),_.on("failed",function(){delete n._referSubscribers[h]}),_}},{key:"sendRequest",value:function(a,t){return W.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(W.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 n={originator:"remote",type:"answer",sdp:a.body};W.debug('emit "sdp"'),this.emit("sdp",n);var p=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(p)}).then(function(){t._is_confirmed||t._confirmed("remote",a)}).catch(function(h){t.terminate({cause:ce.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),W.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',h),t.emit("peerconnection:setremotedescriptionfailed",h)})}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 xt(this).init_incoming(a):_!==void 0?new qc(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(){W.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(){W.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(){W.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){W.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){W.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?(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)}},{key:"_close",value:function(){if(W.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(W.debug("close() | closing local MediaStream"),Be.closeMediaStream(this._localMediaStream)),this._status!==X.STATUS_TERMINATED){if(this._status=X.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){W.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 n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(a,t){var n=Mr.T1;function p(){this._status===X.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),n<Mr.T2&&(n=n*2,n>Mr.T2&&(n=Mr.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),n))}this._timers.invite2xxTimer=setTimeout(p.bind(this),n)}},{key:"_setACKTimer",value:function(){var a=this;this._timers.ackTimer=setTimeout(function(){a._status===X.STATUS_WAITING_FOR_ACK&&(W.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(ce.BYE),a._ended("remote",null,ce.causes.NO_ACK))},Mr.TIMER_H)}},{key:"_createRTCConnection",value:function(a,t){var n=this;this._connection=new RTCPeerConnection(a,t),this._connection.addEventListener("iceconnectionstatechange",function(){var p=n._connection.iceConnectionState;p==="failed"&&n.terminate({cause:ce.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ce.causes.RTP_TIMEOUT})}),W.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var n=this;if(W.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 W.warn('emit "peerconnection:createofferfailed" [error:%o]',_),n.emit("peerconnection:createofferfailed",_),Promise.reject(_)}):p.createAnswer(t).catch(function(_){return W.warn('emit "peerconnection:createanswerfailed" [error:%o]',_),n.emit("peerconnection:createanswerfailed",_),Promise.reject(_)})}).then(function(_){return p.setLocalDescription(_).catch(function(h){return n._rtcReady=!0,W.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',h),n.emit("peerconnection:setlocaldescriptionfailed",h),Promise.reject(h)})}).then(function(){var _=t&&t.iceRestart;if(p.iceGatheringState==="complete"&&!_||p.iceGatheringState==="gathering"&&n._iceReady){n._rtcReady=!0;var h={originator:"local",type:a,sdp:p.localDescription.sdp};return W.debug('emit "sdp"'),n.emit("sdp",h),Promise.resolve(h.sdp)}return new Promise(function(g){var T=!1,E,y;n._iceReady=!1;var A=function(){p.removeEventListener("icecandidate",E),p.removeEventListener("icegatheringstatechange",y),T=!0,n._rtcReady=!0,n._iceReady=!0;var I={originator:"local",type:a,sdp:p.localDescription.sdp};W.debug('emit "sdp"'),n.emit("sdp",I),g(I.sdp)};p.addEventListener("icecandidate",E=function(I){var $=I.candidate;$?n.emit("icecandidate",{candidate:$,ready:A}):T||A()}),p.addEventListener("icegatheringstatechange",y=function(){p.iceGatheringState==="complete"&&!T&&A()})})})}},{key:"_createDialog",value:function(a,t,n){var p=t==="UAS"?a.to_tag:a.from_tag,_=t==="UAS"?a.from_tag:a.to_tag,h=a.call_id+p+_,g=this._earlyDialogs[h];if(n)return g?!0:(g=new Hl(this,a,t,Hl.C.STATUS_EARLY),g.error?(W.debug(g.error),this._failed("remote",a,ce.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[h]=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[h],!0;var T=new Hl(this,a,t);return T.error?(W.debug(T.error),this._failed("remote",a,ce.causes.INTERNAL_ERROR),!1):(this._dialog=T,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;W.debug("receiveReinvite()");var n=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:h.bind(this)},_=!1;function h(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_=!0;var E=T.status_code||403,y=T.reason_phrase||"",A=Be.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(n!=="application/sdp"){W.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){W.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;W.debug("receiveUpdate()");var n=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:h.bind(this)},_=!1;function h(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_=!0;var E=T.status_code||403,y=T.reason_phrase||"",A=Be.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(n!=="application/sdp"){W.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){W.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;W.debug("_processInDialogSdpOffer()");var n=a.parseSDP(),p=!1,_=cs(n.media),h;try{for(_.s();!(h=_.n()).done;){var g=h.value;if(Fl.indexOf(g.type)!==-1){var T=g.direction||n.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};W.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),W.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),W.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',A),A})}).catch(function(A){W.warn("_processInDialogSdpOffer() failed [error: %o]",A)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(W.debug("receiveRefer()"),!a.refer_to){W.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==ce.SIP){W.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var n=new Hd(this,a.cseq);W.debug('emit "refer"'),this.emit("refer",{request:a,accept:function(g,T){p.call(t,g,T)},reject:function(){_.call(t)}});function p(h){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(h=typeof h=="function"?h: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;n.notify(A.status_code,A.reason_phrase)}),T.on("accepted",function(y){var A=y.response;n.notify(A.status_code,A.reason_phrase)}),T.on("_failed",function(y){var A=y.message,C=y.cause;A?n.notify(A.status_code,A.reason_phrase):n.notify(487,C)}),a.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(a.refer_to.uri.getHeader("replaces"));g.extraHeaders=Be.cloneArray(g.extraHeaders),g.extraHeaders.push("Replaces: ".concat(E))}T.connect(a.refer_to.uri.toAor(),g,h)}function _(){n.notify(603)}}},{key:"_receiveNotify",value:function(a){switch(W.debug("receiveNotify()"),a.event||a.reply(400),a.event.event){case"refer":{var t,n;if(a.event.params&&a.event.params.id)t=a.event.params.id,n=this._referSubscribers[t];else if(Object.keys(this._referSubscribers).length===1)n=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{a.reply(400,"Missing event id parameter");return}if(!n){a.reply(481,"Subscription does not exist");return}n.receiveNotify(a),a.reply(200);break}default:a.reply(489)}}},{key:"_receiveReplaces",value:function(a){var t=this;W.debug("receiveReplaces()");function n(_){var h=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(){h.terminate()}),g.init_incoming(a,_)}function p(){W.debug("Replaced INVITE rejected by the user"),a.reply(486)}this.emit("replaces",{request:a,accept:function(h){n.call(t,h)},reject:function(){p.call(t)}})}},{key:"_sendInitialRequest",value:function(a,t,n){var p=this,_=new $d(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(n)return n;if(a.audio||a.video)return p._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(function(h){throw p._status===X.STATUS_TERMINATED?new Error("terminated"):(p._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),W.warn('emit "getusermediafailed" [error:%o]',h),p.emit("getusermediafailed",h),h)})}).then(function(h){if(p._status===X.STATUS_TERMINATED)throw new Error("terminated");return p._localMediaStream=h,h&&h.getTracks().forEach(function(g){p._connection.addTrack(g,h)}),p._connecting(p._request),p._createLocalDescription("offer",t).catch(function(g){throw p._failed("local",null,ce.causes.WEBRTC_ERROR),g})}).then(function(h){if(p._is_canceled||p._status===X.STATUS_TERMINATED)throw new Error("terminated");p._request.body=h,p._status=X.STATUS_INVITE_SENT,W.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),_.send()}).catch(function(h){p._status!==X.STATUS_TERMINATED&&W.warn(h)})}},{key:"_getDTMFRTPSender",value:function(){var a=this._connection.getSenders().find(function(t){return t.track&&t.track.kind==="audio"});if(!(a&&a.dtmf)){W.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(W.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 n=new Hl(this,a,"UAC");if(n.error!==void 0){W.debug(n.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){W.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};W.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){W.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 h={originator:"remote",type:"answer",sdp:a.body};W.debug('emit "sdp"'),this.emit("sdp",h);var g=new RTCSessionDescription({type:"answer",sdp:h.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),W.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var T=Be.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]:{};W.debug("sendReinvite()");var n=Be.cloneArray(t.extraHeaders),p=Be.cloneObject(t.eventHandlers),_=t.rtcOfferConstraints||this._rtcOfferConstraints||null,h=!1;n.push("Contact: ".concat(this._contact)),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",_)}).then(function(E){E=a._mangleOffer(E);var y={originator:"local",type:"offer",sdp:E};W.debug('emit "sdp"'),a.emit("sdp",y),a.sendRequest(ce.INVITE,{extraHeaders:n,body:E,eventHandlers:{onSuccessResponse:function(C){g.call(a,C),h=!0},onErrorResponse:function(C){T.call(a,C)},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),!h)){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};W.debug('emit "sdp"'),this.emit("sdp",A);var C=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return y._connection.setRemoteDescription(C)}).then(function(){p.succeeded&&p.succeeded(E)}).catch(function(I){T.call(y),W.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]:{};W.debug("sendUpdate()");var n=Be.cloneArray(t.extraHeaders),p=Be.cloneObject(t.eventHandlers),_=t.rtcOfferConstraints||this._rtcOfferConstraints||null,h=t.sdpOffer||!1,g=!1;n.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),h?(n.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};W.debug('emit "sdp"'),a.emit("sdp",A),a.sendRequest(ce.UPDATE,{extraHeaders:n,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:n,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),h){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 C={originator:"remote",type:"answer",sdp:y.body};W.debug('emit "sdp"'),this.emit("sdp",C);var I=new RTCSessionDescription({type:"answer",sdp:C.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return A._connection.setRemoteDescription(I)}).then(function(){p.succeeded&&p.succeeded(y)}).catch(function($){E.call(A),W.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,n){W.debug("acceptAndTerminate()");var p=[];t&&(n=n||ce.REASON_PHRASE[t]||"",p.push("Reason: SIP ;cause=".concat(t,'; text="').concat(n,'"'))),(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=jc.parse(a),this._localHold&&!this._remoteHold){W.debug("mangleOffer() | me on hold, mangling offer");var t=cs(a.media),n;try{for(t.s();!(n=t.n()).done;){var p=n.value;Fl.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){W.debug("mangleOffer() | both on hold, mangling offer");var _=cs(a.media),h;try{for(_.s();!(h=_.n()).done;){var g=h.value;Fl.indexOf(g.type)!==-1&&(g.direction="inactive")}}catch(A){_.e(A)}finally{_.f()}}else if(this._remoteHold){W.debug("mangleOffer() | remote on hold, mangling offer");var T=cs(a.media),E;try{for(T.s();!(E=T.n()).done;){var y=E.value;Fl.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 jc.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 n;a.session_expires&&a.session_expires>=ce.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,n=a.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(n)),this._sessionTimers.refresher=n==="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()&&(W.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&&(W.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(h){return h.track&&h.track.kind==="audio"}),n=cs(t),p;try{for(n.s();!(p=n.n()).done;){var _=p.value;_.track.enabled=!a}}catch(h){n.e(h)}finally{n.f()}}},{key:"_toggleMuteVideo",value:function(a){var t=this._connection.getSenders().filter(function(h){return h.track&&h.track.kind==="video"}),n=cs(t),p;try{for(n.s();!(p=n.n()).done;){var _=p.value;_.track.enabled=!a}}catch(h){n.e(h)}finally{n.f()}}},{key:"_newRTCSession",value:function(a,t){W.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){W.debug("session connecting"),W.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){W.debug("session progress"),W.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){W.debug("session accepted"),this._start_time=new Date,W.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){W.debug("session confirmed"),this._is_confirmed=!0,W.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,n){W.debug("session ended"),this._end_time=new Date,this._close(),W.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:n})}},{key:"_failed",value:function(a,t,n){W.debug("session failed"),W.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:n}),this._close(),W.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:n})}},{key:"_onhold",value:function(a){W.debug("session onhold"),this._setLocalMediaStatus(),W.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){W.debug("session onunhold"),this._setLocalMediaStatus(),W.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,n=a.video;W.debug("session onmute"),this._setLocalMediaStatus(),W.debug('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(a){var t=a.audio,n=a.video;W.debug("session onunmute"),this._setLocalMediaStatus(),W.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{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}(Md);function jl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jl=function(r){return typeof r}:jl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},jl(c)}function Vd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Gc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function qd(c,s,r){return s&&Gc(c.prototype,s),r&&Gc(c,r),c}function Bd(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&ma(c,s)}function ma(c,s){return ma=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ma(c,s)}function Gd(c){var s=Yd();return function(){var o=Vl(c),a;if(s){var t=Vl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Wd(this,a)}}function Wd(c,s){return s&&(jl(s)==="object"||typeof s=="function")?s:Kd(c)}function Kd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Yd(){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 Vl(c){return Vl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Vl(c)}var Jd=ut.EventEmitter,zd=ct,ga=tt,Xd=os,kr=Ct(),Qd=Nr,Wc=Ss,Zd=ys(),ql=new zd("Message"),ep=function(c){Bd(r,c);var s=Gd(r);function r(o){var a;return Vd(this,r),a=s.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 qd(r,[{key:"send",value:function(a,t){var n=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 h=kr.cloneArray(p.extraHeaders),g=kr.cloneObject(p.eventHandlers),T=p.contentType||"text/plain",E={};p.fromUserName&&(E.from_uri=new Zd("sip",p.fromUserName,this._ua.configuration.uri.host),h.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]);h.push("Content-Type: ".concat(T)),this._request=new Xd.OutgoingRequest(ga.MESSAGE,a,this._ua,E,h),t&&(this._request.body=t);var A=new Qd(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(I){n._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=kr.cloneArray(a.extraHeaders),n=a.body;if(this._direction!=="incoming")throw new Wc.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,n=a.reason_phrase,p=kr.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new Wc.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: ".concat(t));this._is_replied=!0,this._request.reply(t,n,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=kr.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,ga.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,ga.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,n){ql.debug("MESSAGE failed"),this._close(),ql.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:n})}},{key:"_succeeded",value:function(a,t){ql.debug("MESSAGE succeeded"),this._close(),ql.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}(Jd);function Bl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Bl=function(r){return typeof r}:Bl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Bl(c)}function tp(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Kc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function sp(c,s,r){return s&&Kc(c.prototype,s),r&&Kc(c,r),c}function np(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Ta(c,s)}function Ta(c,s){return Ta=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ta(c,s)}function rp(c){var s=op();return function(){var o=Gl(c),a;if(s){var t=Gl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return ip(this,a)}}function ip(c,s){return s&&(Bl(s)==="object"||typeof s=="function")?s:lp(c)}function lp(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function op(){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 Gl(c){return Gl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Gl(c)}var ap=ut.EventEmitter,up=ct,va=tt,cp=os,Lr=Ct(),fp=Nr,Yc=Ss,Wl=new up("Options"),_p=function(c){np(r,c);var s=rp(r);function r(o){var a;return tp(this,r),a=s.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 sp(r,[{key:"send",value:function(a,t){var n=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 h=Lr.cloneArray(p.extraHeaders),g=Lr.cloneObject(p.eventHandlers),T=p.contentType||"application/sdp";for(var E in g)Object.prototype.hasOwnProperty.call(g,E)&&this.on(E,g[E]);h.push("Content-Type: ".concat(T)),this._request=new cp.OutgoingRequest(va.OPTIONS,a,this._ua,null,h),t&&(this._request.body=t);var y=new fp(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(C){n._receiveResponse(C)}});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=Lr.cloneArray(a.extraHeaders),n=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,n)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,n=a.reason_phrase,p=Lr.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,n,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=Lr.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,va.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,va.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,n){Wl.debug("OPTIONS failed"),this._close(),Wl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:n})}},{key:"_succeeded",value:function(a,t){Wl.debug("OPTIONS succeeded"),this._close(),Wl.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}(ap),Ea={},hp=ct,Sa=Ct(),dp=Xt(),$r=new hp("Socket");Ea.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return $r.warn("undefined JsSIP.Socket instance"),!1;try{if(!Sa.isString(c.url))throw $r.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!Sa.isString(c.via_transport))throw $r.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(dp.parse(c.sip_uri,"SIP_URI")===-1)throw $r.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(s){if(!Sa.isFunction(c[s]))throw $r.warn("missing or invalid JsSIP.Socket method: ".concat(s)),new Error("Missing or invalid JsSIP.Socket method: ".concat(s))})}catch{return!1}return!0};function pp(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Jc(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function mp(c,s,r){return s&&Jc(c.prototype,s),r&&Jc(c,r),c}var gp=ct,Tp=Ea,zc=tt,Nt=new gp("Transport"),Lt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:zc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:zc.CONNECTION_RECOVERY_MAX_INTERVAL}},vp=function(){function c(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lt.recovery_options;pp(this,c),Nt.debug("new()"),this.status=Lt.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){Nt.warn("cannot use TextDecoder: ".concat(o))}if(typeof s>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");s instanceof Array||(s=[s]),s.forEach(function(o){if(!Tp.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:Lt.SOCKET_STATUS_READY})},this),this._getSocket()}return mp(c,[{key:"connect",value:function(){if(Nt.debug("connect()"),this.isConnected()){Nt.debug("Transport is already connected");return}else if(this.isConnecting()){Nt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Lt.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(){Nt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Lt.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(Nt.debug("send()"),!this.isConnected())return Nt.warn("unable to send message, transport is not connected"),!1;var o=r.toString();return Nt.debug(`sending message:
|
51
51
|
|
52
52
|
`.concat(o,`
|
53
53
|
`)),this.socket.send(o)}},{key:"isConnected",value:function(){return this.status===Lt.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===Lt.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),Nt.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!==Lt.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=Lt.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=Lt.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=Lt.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=Lt.SOCKET_STATUS_ERROR)},this),this._reconnect(r))}},{key:"_onData",value:function(r){if(r===`\r
|
@@ -57,22 +57,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
57
57
|
`))}else Nt.debug(`received text message:
|
58
58
|
|
59
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}(),Xc={};function Qc(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=
|
61
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var
|
62
|
-
`);if(a===-1){Kl.warn("parseMessage() | no CRLF found, not a SIP message");return}var t=c.substring(0,a),n=ya.parse(t,"Request_Response");if(n===-1){Kl.warn('parseMessage() | error parsing first line of SIP message: "'.concat(t,'"'));return}else n.status_code?(r=new Aa.IncomingResponse,r.status_code=n.status_code,r.reason_phrase=n.reason_phrase):(r=new Aa.IncomingRequest(s),r.method=n.method,r.ruri=n.uri);r.data=c;for(var p=a+2;;){if(a=
|
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
|
64
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var
|
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}(),Xc={};function Qc(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Ep(c))||s&&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(h){throw h},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,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,p=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw p}}}}function Ep(c,s){if(c){if(typeof c=="string")return Zc(c,s);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 Zc(c,s)}}function Zc(c,s){(s==null||s>c.length)&&(s=c.length);for(var r=0,o=new Array(s);r<s;r++)o[r]=c[r];return o}var Sp=ct,ya=Xt(),Aa=os,Kl=new Sp("Parser");Xc.parseMessage=function(c,s){var r,o,a=c.indexOf(`\r
|
62
|
+
`);if(a===-1){Kl.warn("parseMessage() | no CRLF found, not a SIP message");return}var t=c.substring(0,a),n=ya.parse(t,"Request_Response");if(n===-1){Kl.warn('parseMessage() | error parsing first line of SIP message: "'.concat(t,'"'));return}else n.status_code?(r=new Aa.IncomingResponse,r.status_code=n.status_code,r.reason_phrase=n.reason_phrase):(r=new Aa.IncomingRequest(s),r.method=n.method,r.ruri=n.uri);r.data=c;for(var p=a+2;;){if(a=yp(c,p),a===-2){o=p+2;break}else if(a===-1){Kl.warn("parseMessage() | malformed message");return}if(n=Ap(r,c,p,a),n!==!0){Kl.warn("parseMessage() |",n.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 yp(c,s){var r=s,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 Ap(c,s,r,o){var a,t=s.indexOf(":",r),n=s.substring(r,t).trim(),p=s.substring(t+1,o).trim();switch(n.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=ya.parse(p,"Record_Route"),a===-1)a=void 0;else{var _=Qc(a),h;try{for(_.s();!(h=_.n()).done;){var g=h.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=ya.parse(p,"Contact"),a===-1)a=void 0;else{var T=Qc(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 Aa.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(n,p),a=0}return a===void 0?{error:'error parsing header "'.concat(n,'"')}:!0}function Yl(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Cp(c))||s&&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(h){throw h},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,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,p=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw p}}}}function Cp(c,s){if(c){if(typeof c=="string")return ef(c,s);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 ef(c,s)}}function ef(c,s){(s==null||s>c.length)&&(s=c.length);for(var r=0,o=new Array(s);r<s;r++)o[r]=c[r];return o}var Rp=ct,tf=tt,sf=os,Ca=Ct(),Ra=new Rp("sanityCheck"),Ip=[kp],bp=[Dp,Np,Up,Pp],wp=[xp,Mp],Fe,Zt,nf,Op=function(c,s,r){Fe=c,Zt=s,nf=r;var o=Yl(Ip),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(Fe instanceof sf.IncomingRequest){var n=Yl(bp),p;try{for(n.s();!(p=n.n()).done;){var _=p.value;if(_()===!1)return!1}}catch(E){n.e(E)}finally{n.f()}}else if(Fe instanceof sf.IncomingResponse){var h=Yl(wp),g;try{for(h.s();!(g=h.n()).done;){var T=g.value;if(T()===!1)return!1}}catch(E){h.e(E)}finally{h.f()}}return!0};function Dp(){if(Fe.s("to").uri.scheme!=="sip")return Hr(416),!1}function Np(){if(!Fe.to_tag&&Fe.call_id.substr(0,5)===Zt.configuration.jssip_id)return Hr(482),!1}function Up(){var c=Ca.str_utf8_length(Fe.body),s=Fe.getHeader("content-length");if(c<s)return Hr(400),!1}function Pp(){var c=Fe.from_tag,s=Fe.call_id,r=Fe.cseq,o;if(!Fe.to_tag)if(Fe.method===tf.INVITE){if(Zt._transactions.ist[Fe.via_branch])return!1;for(var 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===s&&o.request.cseq===r))return Hr(482),!1}else{if(Zt._transactions.nist[Fe.via_branch])return!1;for(var t in Zt._transactions.nist)if(Object.prototype.hasOwnProperty.call(Zt._transactions.nist,t)&&(o=Zt._transactions.nist[t],o.request.from_tag===c&&o.request.call_id===s&&o.request.cseq===r))return Hr(482),!1}}function xp(){if(Fe.getHeaders("via").length>1)return Ra.debug("more than one Via header field present in the response, dropping the response"),!1}function Mp(){var c=Ca.str_utf8_length(Fe.body),s=Fe.getHeader("content-length");if(c<s)return Ra.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function kp(){for(var c=["from","to","call_id","cseq","via"],s=0,r=c;s<r.length;s++){var o=r[s];if(!Fe.hasHeader(o))return Ra.debug("missing mandatory header field : ".concat(o,", dropping the response")),!1}}function Hr(c){var s=Fe.getHeaders("via"),r,o="SIP/2.0 ".concat(c," ").concat(tf.REASON_PHRASE[c],`\r
|
65
65
|
`),a=Yl(s),t;try{for(a.s();!(t=a.n()).done;){var n=t.value;o+="Via: ".concat(n,`\r
|
66
66
|
`)}}catch(p){a.e(p)}finally{a.f()}r=Fe.getHeader("To"),Fe.to_tag||(r+=";tag=".concat(Ca.newTag())),o+="To: ".concat(r,`\r
|
67
67
|
`),o+="From: ".concat(Fe.getHeader("From"),`\r
|
68
68
|
`),o+="Call-ID: ".concat(Fe.call_id,`\r
|
69
69
|
`),o+="CSeq: ".concat(Fe.cseq," ").concat(Fe.method,`\r
|
70
70
|
`),o+=`\r
|
71
|
-
`,nf.send(o)}var Ia={};function rf(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r
|
72
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var d=r.next();return t=d.done,d},e:function(d){n=!0,p=d},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw p}}}}function $p(c,s){if(c){if(typeof c=="string")return lf(c,s);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 lf(c,s)}}function lf(c,s){(s==null||s>c.length)&&(s=c.length);for(var r=0,o=new Array(s);r<s;r++)o[r]=c[r];return o}var Nn=Ct(),Js=tt,ba=Xt(),of=ys(),wa=Ea,Oa=Ss;Ia.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:Js.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Js.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Js.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(Nn.createRandomToken(12),".invalid")};var zl={mandatory:{sockets:function(s){var r=[];if(wa.isSocket(s))r.push({socket:s});else if(Array.isArray(s)&&s.length){var o=rf(s),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&wa.isSocket(t.socket)?r.push(t):wa.isSocket(t)&&r.push({socket:t})}}catch(n){o.e(n)}finally{o.f()}}else return;return r},uri:function(s){/^sip:/i.test(s)||(s="".concat(Js.SIP,":").concat(s));var r=of.parse(s);if(r)return r.user?r:void 0}},optional:{authorization_user:function(s){if(ba.parse('"'.concat(s,'"'),"quoted_string")!==-1)return s},authorization_jwt:function(s){if(typeof s=="string")return s},user_agent:function(s){if(typeof s=="string")return s},connection_recovery_max_interval:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},connection_recovery_min_interval:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},contact_uri:function(s){if(typeof s=="string"){var r=ba.parse(s,"SIP_URI");if(r!==-1)return r}},display_name:function(s){return s},instance_id:function(s){if(/^uuid:/i.test(s)&&(s=s.substr(5)),ba.parse(s,"uuid")!==-1)return s},no_answer_timeout:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},session_timers:function(s){if(typeof s=="boolean")return s},session_timers_refresh_method:function(s){if(typeof s=="string"&&(s=s.toUpperCase(),s===Js.INVITE||s===Js.UPDATE))return s},session_timers_force_refresher:function(s){if(typeof s=="boolean")return s},password:function(s){return String(s)},realm:function(s){return String(s)},ha1:function(s){return String(s)},register:function(s){if(typeof s=="boolean")return s},register_expires:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},registrar_server:function(s){/^sip:/i.test(s)||(s="".concat(Js.SIP,":").concat(s));var r=of.parse(s);if(r)return r.user?void 0:r},use_preloaded_route:function(s){if(typeof s=="boolean")return s},extra_headers:function(s){var r=[];if(Array.isArray(s)&&s.length){var o=rf(s),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;typeof t=="string"&&r.push(t)}}catch(n){o.e(n)}finally{o.f()}}else return;return r}}};Ia.load=function(c,s){for(var r in zl.mandatory)if(s.hasOwnProperty(r)){var o=s[r],a=zl.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new Oa.ConfigurationError(r,o)}else throw new Oa.ConfigurationError(r);for(var t in zl.optional)if(s.hasOwnProperty(t)){var n=s[t];if(Nn.isEmpty(n))continue;var p=zl.optional[t](n);if(p!==void 0)c[t]=p;else throw new Oa.ConfigurationError(t,n)}};function Jl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Jl=function(r){return typeof r}:Jl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Jl(c)}function Hp(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function af(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function uf(c,s,r){return s&&af(c.prototype,s),r&&af(c,r),c}function Fp(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Da(c,s)}function Da(c,s){return Da=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Da(c,s)}function jp(c){var s=qp();return function(){var o=Xl(c),a;if(s){var t=Xl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Vp(this,a)}}function Vp(c,s){return s&&(Jl(s)==="object"||typeof s=="function")?s:cf(c)}function cf(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function qp(){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 Xl(c){return Xl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Xl(c)}var Bp=ut.EventEmitter,Gp=ct,dt=tt,Wp=Ph,ff=Vd,_f=tp,hf=hp,Na=Dr,Kp=Ep,Ql=Ct(),Yp=Ss,zp=ys(),Jp=Xc,Ua=os,Xp=Dp,Pa=Ia,Ve=new Gp("UA"),pt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Qp=function(c){Fp(r,c);var s=jp(r);uf(r,null,[{key:"C",get:function(){return pt}}]);function r(o){var a;if(Hp(this,r),Ve.debug("new() [configuration:%o]",o),a=s.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},Pa.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=pt.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=pt.STATUS_NOT_READY,a._error=pt.CONFIGURATION_ERROR,t}return a._registrator=new Wp(cf(a)),a}return uf(r,[{key:"start",value:function(){Ve.debug("start()"),this._status===pt.STATUS_INIT?this._transport.connect():this._status===pt.STATUS_USER_CLOSED?(Ve.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=pt.STATUS_INIT,this._transport.connect()):this._status===pt.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 n=new ff(this);return n.connect(a,t),n}},{key:"sendMessage",value:function(a,t,n){Ve.debug("sendMessage()");var p=new _f(this);return p.send(a,t,n),p}},{key:"sendOptions",value:function(a,t,n){Ve.debug("sendOptions()");var p=new hf(this);return p.send(a,t,n),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===pt.STATUS_USER_CLOSED){Ve.debug("UA already closed");return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var n in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,n)){Ve.debug("closing session ".concat(n));try{this._sessions[n].terminate()}catch{}}for(var p in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,p))try{this._applicants[p].close()}catch{}this._status=pt.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 Ql.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!==dt.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===dt.SIPS){a.reply_sl(416);return}if(!Na.checkTransaction(this,a)){if(t===dt.INVITE?new Na.InviteServerTransaction(this,this._transport,a):t!==dt.ACK&&t!==dt.CANCEL&&new Na.NonInviteServerTransaction(this,this._transport,a),t===dt.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var n=new hf(this);n.init_incoming(a)}else if(t===dt.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new _f(this);p.init_incoming(a)}else if(t===dt.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===dt.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!==dt.ACK&&a.reply(481);else switch(t){case dt.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 ff(this),d.init_incoming(a);else Ve.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case dt.BYE:a.reply(481);break;case dt.CANCEL:d=this._findSession(a),d?d.receiveRequest(a):Ve.debug("received CANCEL request for a non existent session");break;case dt.ACK:break;case dt.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,n=a.from_tag,p=a.to_tag,_=t+n,d=this._sessions[_],g=t+p,T=this._sessions[g];return d||T||null}},{key:"_findDialog",value:function(a,t,n){var p=a+t+n,_=this._dialogs[p];return _||(p=a+n+t,_=this._dialogs[p],_||null)}},{key:"_loadConfig",value:function(a){try{Pa.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=Ql.newUUID()),this._configuration.jssip_id=Ql.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=Zp.bind(this),this._transport.onconnect=em.bind(this),this._transport.ondisconnect=tm.bind(this),this._transport.ondata=sm.bind(this)}catch(g){throw Ve.warn(g),new Yp.ConfigurationError("sockets",this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){var n=this._configuration.uri.clone();n.user=null,n.clearParams(),n.clearHeaders(),this._configuration.registrar_server=n}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new zp("sip",Ql.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(Pa.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 pt}},{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}(Bp);function Zp(c){this.emit("connecting",c)}function em(c){this._status!==pt.STATUS_USER_CLOSED&&(this._status=pt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function tm(c){for(var s=["nict","ict","nist","ist"],r=0,o=s;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!==pt.STATUS_USER_CLOSED&&(this._status=pt.STATUS_NOT_READY,this._error=pt.NETWORK_ERROR)}function sm(c){var s=c.transport,r=c.message;if(r=Jp.parseMessage(r,this),!!r&&!(this._status===pt.STATUS_USER_CLOSED&&r instanceof Ua.IncomingRequest)&&Xp(r,this,s)){if(r instanceof Ua.IncomingRequest)r.transport=s,this.receiveRequest(r);else if(r instanceof Ua.IncomingResponse){var 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}}}}function nm(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function df(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function rm(c,s,r){return s&&df(c.prototype,s),r&&df(c,r),c}var im=ct,lm=Xt(),bt=new im("WebSocketInterface"),om=function(){function c(s){nm(this,c),bt.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;var r=lm.parse(s,"absoluteURI");if(r===-1)throw bt.warn("invalid WebSocket URI: ".concat(s)),new TypeError("Invalid argument: ".concat(s));if(r.scheme!=="wss"&&r.scheme!=="ws")throw bt.warn("invalid WebSocket URI scheme: ".concat(r.scheme)),new TypeError("Invalid argument: ".concat(s));this._sip_uri="sip:".concat(r.host).concat(r.port?":".concat(r.port):"",";transport=ws"),this._via_transport=r.scheme.toUpperCase()}return rm(c,[{key:"connect",value:function(){if(bt.debug("connect()"),this.isConnected()){bt.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){bt.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),bt.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(){bt.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 bt.debug("send()"),this.isConnected()?(this._ws.send(r),!0):(bt.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(){bt.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(r){var o=r.wasClean,a=r.code,t=r.reason;bt.debug("WebSocket ".concat(this._url," closed")),o===!1&&bt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!o,a,t)}},{key:"_onMessage",value:function(r){var o=r.data;bt.debug("received WebSocket message"),this.ondata(o)}},{key:"_onError",value:function(r){bt.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}(),xa=dl,am=tt,um=Ss,cm=Ct(),fm=Qp,_m=ys(),hm=Go(),dm=Xt(),pm=om,mm=wn("JsSIP");mm("version %s",xa.version);var pf={C:am,Exceptions:um,Utils:cm,UA:fm,URI:_m,NameAddrHeader:hm,WebSocketInterface:pm,Grammar:dm,debug:wn,get name(){return xa.title},get version(){return xa.version}};const Un=wn,Pn="JsSIP";var lt=class{constructor(s){s?(this._debug=Un.default(`${Pn}:${s}`),this._warn=Un.default(`${Pn}:WARN:${s}`),this._error=Un.default(`${Pn}:ERROR:${s}`)):(this._debug=Un.default(Pn),this._warn=Un.default(`${Pn}:WARN`),this._error=Un.default(`${Pn}: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 mf=ke(lt),gf=dl;var De={USER_AGENT:`${gf.title} ${gf.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 j=ke(De);var Ze={},Ma,Tf;function ka(){if(Tf)return Ma;Tf=1;const c=fs(),s=es();return Ma=class D_{static parse(o){if(o=s.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 n in t)Object.prototype.hasOwnProperty.call(t,n)&&this.setParam(n,t[n])}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 D_(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}},Ma}var La,vf;function es(){return vf||(vf=1,La=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 s={parse:function(r,o){var a={CRLF:d,DIGIT:g,ALPHA:T,HEXDIG:E,WSP:y,OCTET:A,DQUOTE:C,SP:I,HTAB:$,alphanum:L,reserved:ae,unreserved:N,mark:F,escaped:Se,LWS:ve,SWS:M,HCOLON:D,TEXT_UTF8_TRIM:B,TEXT_UTF8char:q,UTF8_NONASCII:z,UTF8_CONT:H,LHEX:Z,token:U,token_nodot:P,separators:se,word:rt,STAR:ee,SLASH:Y,EQUAL:G,LPAREN:re,RPAREN:ge,RAQUOT:be,LAQUOT:xe,COMMA:Re,SEMI:le,COLON:ye,LDQUOT:it,RDQUOT:ot,comment:Ee,ctext:Ae,quoted_string:Ie,quoted_string_clean:Oe,qdtext:pe,quoted_pair:he,SIP_URI_noparams:de,SIP_URI:we,uri_scheme:Ne,uri_scheme_sips:et,uri_scheme_sip:He,userinfo:Ft,user:At,user_unreserved:jn,password:Vn,hostport:rn,host:ns,hostname:Ts,domainlabel:ln,toplabel:qn,IPv6reference:Bn,IPv6address:on,h16:me,ls32:oe,IPv4address:at,dec_octet:zt,port:Ps,uri_parameters:ri,uri_parameter:Gn,transport_param:Wn,user_param:ii,method_param:li,ttl_param:oi,maddr_param:ai,lr_param:ui,other_param:ci,pname:fi,pvalue:_i,paramchar:xs,param_unreserved:Ms,headers:hi,header:an,hname:un,hvalue:di,hnv_unreserved:ks,Request_Response:cn,Request_Line:yo,Request_URI:pi,absoluteURI:Kn,hier_part:Yn,net_path:mi,abs_path:fn,opaque_part:_n,uric:Ls,uric_no_slash:$s,path_segments:gi,segment:hn,param:Hs,pchar:vs,scheme:Fs,authority:Ti,srvr:vi,reg_name:Ei,query:Si,SIP_Version:zn,INVITEm:Jn,ACKm:yi,OPTIONSm:Ai,BYEm:Ci,CANCELm:Ri,REGISTERm:Ii,SUBSCRIBEm:bi,NOTIFYm:wi,REFERm:Oi,Method:dn,Status_Line:pn,Status_Code:Di,extension_code:Ni,Reason_Phrase:Ui,Allow_Events:Ao,Call_ID:Au,Contact:Cu,contact_param:Xn,name_addr:jt,display_name:Vt,contact_params:js,c_p_q:Qn,c_p_expires:Pi,delta_seconds:rs,qvalue:is,generic_param:ze,gen_value:Je,Content_Disposition:Co,disp_type:Ro,disp_param:Zn,handling_param:er,Content_Encoding:Io,Content_Length:Ru,Content_Type:Iu,media_type:bo,m_type:xi,discrete_type:Mi,composite_type:ki,extension_token:mn,x_token:gn,m_subtype:Li,m_parameter:tr,m_value:sr,CSeq:wo,CSeq_value:Oo,Expires:Do,Event:bu,event_type:Tn,From:vn,from_param:$i,tag_param:En,Max_Forwards:Hi,Min_Expires:wu,Name_Addr_Header:Ou,Proxy_Authenticate:Du,challenge:Fi,other_challenge:nr,auth_param:Vs,digest_cln:ls,realm:Sn,realm_value:ji,domain:Vi,URI:yn,nonce:An,nonce_value:qi,opaque:Bi,stale:Gi,algorithm:Wi,qop_options:Ki,qop_value:Cn,Proxy_Require:rr,Record_Route:Nu,rec_route:ir,Reason:lr,reason_param:Yi,reason_cause:or,Require:No,Route:Uu,route_param:ar,Subscription_State:ur,substate_value:Uo,subexp_params:cr,event_reason_value:fr,Subject:Po,Supported:Pu,To:xu,to_param:zi,Via:Ji,via_param:_r,via_params:qs,via_ttl:hr,via_maddr:Xi,via_received:Qi,via_branch:Zi,response_port:el,rport:tl,sent_protocol:sl,protocol_name:nl,transport:rl,sent_by:il,via_host:ll,via_port:ol,ttl:dr,WWW_Authenticate:al,Session_Expires:Mu,s_e_expires:xo,s_e_params:pr,s_e_refresher:mr,extension_header:Mo,header_value:ko,message_body:Lo,uuid_URI:ku,uuid:$o,hex4:qt,hex8:Bt,hex12:ul,Refer_To:Ho,Replaces:Lu,call_id:Fo,replaces_param:gr,to_tag:Tr,from_tag:cl,early_flag:fl};if(o!==void 0){if(a[o]===void 0)throw new Error("Invalid rule name: "+c(o)+".")}else o="CRLF";var t=0,n=0,p=[];function _(i){t<n||(t>n&&(n=t,p=[]),p.push(i))}function d(){var i;return r.substr(t,2)===`\r
|
71
|
+
`,nf.send(o)}var Ia={};function rf(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Lp(c))||s&&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(h){throw h},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,n=!1,p;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,p=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw p}}}}function Lp(c,s){if(c){if(typeof c=="string")return lf(c,s);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 lf(c,s)}}function lf(c,s){(s==null||s>c.length)&&(s=c.length);for(var r=0,o=new Array(s);r<s;r++)o[r]=c[r];return o}var Nn=Ct(),zs=tt,ba=Xt(),of=ys(),wa=Ea,Oa=Ss;Ia.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:zs.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:zs.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:zs.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(Nn.createRandomToken(12),".invalid")};var Jl={mandatory:{sockets:function(s){var r=[];if(wa.isSocket(s))r.push({socket:s});else if(Array.isArray(s)&&s.length){var o=rf(s),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&wa.isSocket(t.socket)?r.push(t):wa.isSocket(t)&&r.push({socket:t})}}catch(n){o.e(n)}finally{o.f()}}else return;return r},uri:function(s){/^sip:/i.test(s)||(s="".concat(zs.SIP,":").concat(s));var r=of.parse(s);if(r)return r.user?r:void 0}},optional:{authorization_user:function(s){if(ba.parse('"'.concat(s,'"'),"quoted_string")!==-1)return s},authorization_jwt:function(s){if(typeof s=="string")return s},user_agent:function(s){if(typeof s=="string")return s},connection_recovery_max_interval:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},connection_recovery_min_interval:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},contact_uri:function(s){if(typeof s=="string"){var r=ba.parse(s,"SIP_URI");if(r!==-1)return r}},display_name:function(s){return s},instance_id:function(s){if(/^uuid:/i.test(s)&&(s=s.substr(5)),ba.parse(s,"uuid")!==-1)return s},no_answer_timeout:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},session_timers:function(s){if(typeof s=="boolean")return s},session_timers_refresh_method:function(s){if(typeof s=="string"&&(s=s.toUpperCase(),s===zs.INVITE||s===zs.UPDATE))return s},session_timers_force_refresher:function(s){if(typeof s=="boolean")return s},password:function(s){return String(s)},realm:function(s){return String(s)},ha1:function(s){return String(s)},register:function(s){if(typeof s=="boolean")return s},register_expires:function(s){if(Nn.isDecimal(s)){var r=Number(s);if(r>0)return r}},registrar_server:function(s){/^sip:/i.test(s)||(s="".concat(zs.SIP,":").concat(s));var r=of.parse(s);if(r)return r.user?void 0:r},use_preloaded_route:function(s){if(typeof s=="boolean")return s},extra_headers:function(s){var r=[];if(Array.isArray(s)&&s.length){var o=rf(s),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;typeof t=="string"&&r.push(t)}}catch(n){o.e(n)}finally{o.f()}}else return;return r}}};Ia.load=function(c,s){for(var r in Jl.mandatory)if(s.hasOwnProperty(r)){var o=s[r],a=Jl.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new Oa.ConfigurationError(r,o)}else throw new Oa.ConfigurationError(r);for(var t in Jl.optional)if(s.hasOwnProperty(t)){var n=s[t];if(Nn.isEmpty(n))continue;var p=Jl.optional[t](n);if(p!==void 0)c[t]=p;else throw new Oa.ConfigurationError(t,n)}};function zl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?zl=function(r){return typeof r}:zl=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},zl(c)}function $p(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function af(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function uf(c,s,r){return s&&af(c.prototype,s),r&&af(c,r),c}function Hp(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Da(c,s)}function Da(c,s){return Da=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Da(c,s)}function Fp(c){var s=Vp();return function(){var o=Xl(c),a;if(s){var t=Xl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return jp(this,a)}}function jp(c,s){return s&&(zl(s)==="object"||typeof s=="function")?s:cf(c)}function cf(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Vp(){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 Xl(c){return Xl=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Xl(c)}var qp=ut.EventEmitter,Bp=ct,dt=tt,Gp=Uh,ff=jd,_f=ep,hf=_p,Na=Dr,Wp=vp,Ql=Ct(),Kp=Ss,Yp=ys(),Jp=Xc,Ua=os,zp=Op,Pa=Ia,Ve=new Bp("UA"),pt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Xp=function(c){Hp(r,c);var s=Fp(r);uf(r,null,[{key:"C",get:function(){return pt}}]);function r(o){var a;if($p(this,r),Ve.debug("new() [configuration:%o]",o),a=s.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},Pa.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=pt.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=pt.STATUS_NOT_READY,a._error=pt.CONFIGURATION_ERROR,t}return a._registrator=new Gp(cf(a)),a}return uf(r,[{key:"start",value:function(){Ve.debug("start()"),this._status===pt.STATUS_INIT?this._transport.connect():this._status===pt.STATUS_USER_CLOSED?(Ve.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=pt.STATUS_INIT,this._transport.connect()):this._status===pt.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 n=new ff(this);return n.connect(a,t),n}},{key:"sendMessage",value:function(a,t,n){Ve.debug("sendMessage()");var p=new _f(this);return p.send(a,t,n),p}},{key:"sendOptions",value:function(a,t,n){Ve.debug("sendOptions()");var p=new hf(this);return p.send(a,t,n),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===pt.STATUS_USER_CLOSED){Ve.debug("UA already closed");return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var n in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,n)){Ve.debug("closing session ".concat(n));try{this._sessions[n].terminate()}catch{}}for(var p in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,p))try{this._applicants[p].close()}catch{}this._status=pt.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 Ql.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!==dt.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===dt.SIPS){a.reply_sl(416);return}if(!Na.checkTransaction(this,a)){if(t===dt.INVITE?new Na.InviteServerTransaction(this,this._transport,a):t!==dt.ACK&&t!==dt.CANCEL&&new Na.NonInviteServerTransaction(this,this._transport,a),t===dt.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var n=new hf(this);n.init_incoming(a)}else if(t===dt.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new _f(this);p.init_incoming(a)}else if(t===dt.INVITE&&!a.to_tag&&this.listeners("newRTCSession").length===0){a.reply(405);return}var _,h;if(a.to_tag)_=this._findDialog(a.call_id,a.from_tag,a.to_tag),_?_.receiveRequest(a):t===dt.NOTIFY?(h=this._findSession(a),h?h.receiveRequest(a):(Ve.debug("received NOTIFY request for a non existent subscription"),a.reply(481,"Subscription does not exist"))):t!==dt.ACK&&a.reply(481);else switch(t){case dt.INVITE:if(window.RTCPeerConnection)if(a.hasHeader("replaces")){var g=a.replaces;_=this._findDialog(g.call_id,g.from_tag,g.to_tag),_?(h=_.owner,h.isEnded()?a.reply(603):h.receiveRequest(a)):a.reply(481)}else h=new ff(this),h.init_incoming(a);else Ve.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case dt.BYE:a.reply(481);break;case dt.CANCEL:h=this._findSession(a),h?h.receiveRequest(a):Ve.debug("received CANCEL request for a non existent session");break;case dt.ACK:break;case dt.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,n=a.from_tag,p=a.to_tag,_=t+n,h=this._sessions[_],g=t+p,T=this._sessions[g];return h||T||null}},{key:"_findDialog",value:function(a,t,n){var p=a+t+n,_=this._dialogs[p];return _||(p=a+n+t,_=this._dialogs[p],_||null)}},{key:"_loadConfig",value:function(a){try{Pa.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=Ql.newUUID()),this._configuration.jssip_id=Ql.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new Wp(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Qp.bind(this),this._transport.onconnect=Zp.bind(this),this._transport.ondisconnect=em.bind(this),this._transport.ondata=tm.bind(this)}catch(g){throw Ve.warn(g),new Kp.ConfigurationError("sockets",this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){var n=this._configuration.uri.clone();n.user=null,n.clearParams(),n.clearHeaders(),this._configuration.registrar_server=n}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Yp("sip",Ql.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 h in this._configuration)if(Object.prototype.hasOwnProperty.call(Pa.settings,h))switch(h){case"uri":case"registrar_server":Ve.debug("- ".concat(h,": ").concat(this._configuration[h]));break;case"password":case"ha1":case"authorization_jwt":Ve.debug("- ".concat(h,": NOT SHOWN"));break;default:Ve.debug("- ".concat(h,": ").concat(JSON.stringify(this._configuration[h])))}}},{key:"C",get:function(){return pt}},{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}(qp);function Qp(c){this.emit("connecting",c)}function Zp(c){this._status!==pt.STATUS_USER_CLOSED&&(this._status=pt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function em(c){for(var s=["nict","ict","nist","ist"],r=0,o=s;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!==pt.STATUS_USER_CLOSED&&(this._status=pt.STATUS_NOT_READY,this._error=pt.NETWORK_ERROR)}function tm(c){var s=c.transport,r=c.message;if(r=Jp.parseMessage(r,this),!!r&&!(this._status===pt.STATUS_USER_CLOSED&&r instanceof Ua.IncomingRequest)&&zp(r,this,s)){if(r instanceof Ua.IncomingRequest)r.transport=s,this.receiveRequest(r);else if(r instanceof Ua.IncomingResponse){var 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}}}}function sm(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function df(c,s){for(var r=0;r<s.length;r++){var o=s[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function nm(c,s,r){return s&&df(c.prototype,s),r&&df(c,r),c}var rm=ct,im=Xt(),bt=new rm("WebSocketInterface"),lm=function(){function c(s){sm(this,c),bt.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;var r=im.parse(s,"absoluteURI");if(r===-1)throw bt.warn("invalid WebSocket URI: ".concat(s)),new TypeError("Invalid argument: ".concat(s));if(r.scheme!=="wss"&&r.scheme!=="ws")throw bt.warn("invalid WebSocket URI scheme: ".concat(r.scheme)),new TypeError("Invalid argument: ".concat(s));this._sip_uri="sip:".concat(r.host).concat(r.port?":".concat(r.port):"",";transport=ws"),this._via_transport=r.scheme.toUpperCase()}return nm(c,[{key:"connect",value:function(){if(bt.debug("connect()"),this.isConnected()){bt.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){bt.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),bt.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(){bt.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 bt.debug("send()"),this.isConnected()?(this._ws.send(r),!0):(bt.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(){bt.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(r){var o=r.wasClean,a=r.code,t=r.reason;bt.debug("WebSocket ".concat(this._url," closed")),o===!1&&bt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!o,a,t)}},{key:"_onMessage",value:function(r){var o=r.data;bt.debug("received WebSocket message"),this.ondata(o)}},{key:"_onError",value:function(r){bt.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}(),xa=dl,om=tt,am=Ss,um=Ct(),cm=Xp,fm=ys(),_m=Go(),hm=Xt(),dm=lm,pm=wn("JsSIP");pm("version %s",xa.version);var pf={C:om,Exceptions:am,Utils:um,UA:cm,URI:fm,NameAddrHeader:_m,WebSocketInterface:dm,Grammar:hm,debug:wn,get name(){return xa.title},get version(){return xa.version}};const Un=wn,Pn="JsSIP";var lt=class{constructor(s){s?(this._debug=Un.default(`${Pn}:${s}`),this._warn=Un.default(`${Pn}:WARN:${s}`),this._error=Un.default(`${Pn}:ERROR:${s}`)):(this._debug=Un.default(Pn),this._warn=Un.default(`${Pn}:WARN`),this._error=Un.default(`${Pn}: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 mf=ke(lt),gf=dl;var De={USER_AGENT:`${gf.title} ${gf.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 j=ke(De);var Ze={},Ma,Tf;function ka(){if(Tf)return Ma;Tf=1;const c=fs(),s=es();return Ma=class O_{static parse(o){if(o=s.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 n in t)Object.prototype.hasOwnProperty.call(t,n)&&this.setParam(n,t[n])}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 O_(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}},Ma}var La,vf;function es(){return vf||(vf=1,La=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 s={parse:function(r,o){var a={CRLF:h,DIGIT:g,ALPHA:T,HEXDIG:E,WSP:y,OCTET:A,DQUOTE:C,SP:I,HTAB:$,alphanum:L,reserved:ae,unreserved:N,mark:F,escaped:Se,LWS:ve,SWS:M,HCOLON:D,TEXT_UTF8_TRIM:B,TEXT_UTF8char:q,UTF8_NONASCII:J,UTF8_CONT:H,LHEX:Z,token:U,token_nodot:P,separators:se,word:rt,STAR:ee,SLASH:Y,EQUAL:G,LPAREN:re,RPAREN:ge,RAQUOT:be,LAQUOT:xe,COMMA:Re,SEMI:le,COLON:ye,LDQUOT:it,RDQUOT:ot,comment:Ee,ctext:Ae,quoted_string:Ie,quoted_string_clean:Oe,qdtext:pe,quoted_pair:he,SIP_URI_noparams:de,SIP_URI:we,uri_scheme:Ne,uri_scheme_sips:et,uri_scheme_sip:He,userinfo:Ft,user:At,user_unreserved:jn,password:Vn,hostport:rn,host:ns,hostname:Ts,domainlabel:ln,toplabel:qn,IPv6reference:Bn,IPv6address:on,h16:me,ls32:oe,IPv4address:at,dec_octet:Jt,port:Ps,uri_parameters:ri,uri_parameter:Gn,transport_param:Wn,user_param:ii,method_param:li,ttl_param:oi,maddr_param:ai,lr_param:ui,other_param:ci,pname:fi,pvalue:_i,paramchar:xs,param_unreserved:Ms,headers:hi,header:an,hname:un,hvalue:di,hnv_unreserved:ks,Request_Response:cn,Request_Line:yo,Request_URI:pi,absoluteURI:Kn,hier_part:Yn,net_path:mi,abs_path:fn,opaque_part:_n,uric:Ls,uric_no_slash:$s,path_segments:gi,segment:hn,param:Hs,pchar:vs,scheme:Fs,authority:Ti,srvr:vi,reg_name:Ei,query:Si,SIP_Version:Jn,INVITEm:zn,ACKm:yi,OPTIONSm:Ai,BYEm:Ci,CANCELm:Ri,REGISTERm:Ii,SUBSCRIBEm:bi,NOTIFYm:wi,REFERm:Oi,Method:dn,Status_Line:pn,Status_Code:Di,extension_code:Ni,Reason_Phrase:Ui,Allow_Events:Ao,Call_ID:Au,Contact:Cu,contact_param:Xn,name_addr:jt,display_name:Vt,contact_params:js,c_p_q:Qn,c_p_expires:Pi,delta_seconds:rs,qvalue:is,generic_param:Je,gen_value:ze,Content_Disposition:Co,disp_type:Ro,disp_param:Zn,handling_param:er,Content_Encoding:Io,Content_Length:Ru,Content_Type:Iu,media_type:bo,m_type:xi,discrete_type:Mi,composite_type:ki,extension_token:mn,x_token:gn,m_subtype:Li,m_parameter:tr,m_value:sr,CSeq:wo,CSeq_value:Oo,Expires:Do,Event:bu,event_type:Tn,From:vn,from_param:$i,tag_param:En,Max_Forwards:Hi,Min_Expires:wu,Name_Addr_Header:Ou,Proxy_Authenticate:Du,challenge:Fi,other_challenge:nr,auth_param:Vs,digest_cln:ls,realm:Sn,realm_value:ji,domain:Vi,URI:yn,nonce:An,nonce_value:qi,opaque:Bi,stale:Gi,algorithm:Wi,qop_options:Ki,qop_value:Cn,Proxy_Require:rr,Record_Route:Nu,rec_route:ir,Reason:lr,reason_param:Yi,reason_cause:or,Require:No,Route:Uu,route_param:ar,Subscription_State:ur,substate_value:Uo,subexp_params:cr,event_reason_value:fr,Subject:Po,Supported:Pu,To:xu,to_param:Ji,Via:zi,via_param:_r,via_params:qs,via_ttl:hr,via_maddr:Xi,via_received:Qi,via_branch:Zi,response_port:el,rport:tl,sent_protocol:sl,protocol_name:nl,transport:rl,sent_by:il,via_host:ll,via_port:ol,ttl:dr,WWW_Authenticate:al,Session_Expires:Mu,s_e_expires:xo,s_e_params:pr,s_e_refresher:mr,extension_header:Mo,header_value:ko,message_body:Lo,uuid_URI:ku,uuid:$o,hex4:qt,hex8:Bt,hex12:ul,Refer_To:Ho,Replaces:Lu,call_id:Fo,replaces_param:gr,to_tag:Tr,from_tag:cl,early_flag:fl};if(o!==void 0){if(a[o]===void 0)throw new Error("Invalid rule name: "+c(o)+".")}else o="CRLF";var t=0,n=0,p=[];function _(i){t<n||(t>n&&(n=t,p=[]),p.push(i))}function h(){var i;return r.substr(t,2)===`\r
|
73
73
|
`?(i=`\r
|
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 C(){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 B(){var i,e,l,u,f,h,m;if(f=t,h=t,e=q(),e!==null)for(i=[];e!==null;)i.push(e),e=q();else i=null;if(i!==null){for(e=[],m=t,l=[],u=ve();u!==null;)l.push(u),u=ve();for(l!==null?(u=q(),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=q(),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 q(){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 Z(){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=C(),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 rt(){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=C(),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=C(),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 Y(){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 G(){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 Re(){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 it(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(e=C(),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 ot(){var i,e,l,u;return l=t,u=t,i=C(),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=he(),l===null&&(l=Ee()));l!==null;)e.push(l),l=Ae(),l===null&&(l=he(),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=C(),e!==null){for(l=[],u=pe(),u===null&&(u=he());u!==null;)l.push(u),u=pe(),u===null&&(u=he());l!==null?(u=C(),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=C(),e!==null){for(l=[],u=pe(),u===null&&(u=he());u!==null;)l.push(u),u=pe(),u===null&&(u=he());l!==null?(u=C(),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 he(){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=Ne(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ft(),l=l!==null?l:"",l!==null?(u=rn(),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 Vo(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=Ne(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ft(),l=l!==null?l:"",l!==null?(u=rn(),u!==null?(f=ri(),f!==null?(h=hi(),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 Vo(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 Ne(){var i;return i=et(),i===null&&(i=He()),i}function et(){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 He(){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 Ft(){var i,e,l,u,f,h;return u=t,f=t,i=At(),i!==null?(h=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Vn(),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 At(){var i,e;if(e=N(),e===null&&(e=Se(),e===null&&(e=jn())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=Se(),e===null&&(e=jn()));else i=null;return i}function jn(){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 Vn(){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 rn(){var i,e,l,u,f;return u=t,i=ns(),i!==null?(f=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ps(),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 ns(){var i,e;return e=t,i=Ts(),i===null&&(i=at(),i===null&&(i=Bn())),i!==null&&(i=function(l){return b.host=r.substring(t,l).toLowerCase(),b.host}(e)),i===null&&(t=e),i}function Ts(){var i,e,l,u,f,h;for(u=t,f=t,i=[],h=t,e=ln(),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=ln(),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=qn(),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 ln(){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 qn(){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 Bn(){var i,e,l,u,f;return u=t,f=t,r.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i!==null?(e=on(),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 on(){var i,e,l,u,f,h,m,v,S,O,ie,Ue,Ot,Bs,k,R;return Bs=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?(Ue=":",t++):(Ue=null,_('":"')),Ue!==null?(Ot=oe(),Ot!==null?i=[i,e,l,u,f,h,m,v,S,O,ie,Ue,Ot]:(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?(Ue=oe(),Ue!==null?i=[i,e,l,u,f,h,m,v,S,O,ie,Ue]:(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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),u=u!==null?u:"",u!==null?(R=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?f=[f,h]:(f=null,t=R)):(f=null,t=R),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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),u=u!==null?u:"",u!==null?(R=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?f=[f,h]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(R=t,r.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=me(),m!==null?h=[h,m]:(h=null,t=R)):(h=null,t=R),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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),u=u!==null?u:"",u!==null?(R=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=me(),h!==null?f=[f,h]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(R=t,r.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=me(),m!==null?h=[h,m]:(h=null,t=R)):(h=null,t=R),h=h!==null?h:"",h!==null?(R=t,r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=me(),v!==null?m=[m,v]:(m=null,t=R)):(m=null,t=R),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)}(Bs)),i===null&&(t=Bs),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=at()),i}function at(){var i,e,l,u,f,h,m,v,S;return v=t,S=t,i=zt(),i!==null?(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e!==null?(l=zt(),l!==null?(r.charCodeAt(t)===46?(u=".",t++):(u=null,_('"."')),u!==null?(f=zt(),f!==null?(r.charCodeAt(t)===46?(h=".",t++):(h=null,_('"."')),h!==null?(m=zt(),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 zt(){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 Ps(){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 ri(){var i,e,l,u;for(i=[],u=t,r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=Gn(),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=Gn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function Gn(){var i;return i=Wn(),i===null&&(i=ii(),i===null&&(i=li(),i===null&&(i=oi(),i===null&&(i=ai(),i===null&&(i=ui(),i===null&&(i=ci())))))),i}function Wn(){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 ii(){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 li(){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=dn(),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 oi(){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=dr(),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 ai(){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=ns(),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 ui(){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 ci(){var i,e,l,u,f,h;return u=t,f=t,i=fi(),i!==null?(h=t,r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=_i(),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 fi(){var i,e,l;if(l=t,e=xs(),e!==null)for(i=[];e!==null;)i.push(e),e=xs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function _i(){var i,e,l;if(l=t,e=xs(),e!==null)for(i=[];e!==null;)i.push(e),e=xs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function xs(){var i;return i=Ms(),i===null&&(i=N(),i===null&&(i=Se())),i}function Ms(){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 hi(){var i,e,l,u,f,h,m;if(h=t,r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i!==null)if(e=an(),e!==null){for(l=[],m=t,r.charCodeAt(t)===38?(u="&",t++):(u=null,_('"&"')),u!==null?(f=an(),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=an(),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 an(){var i,e,l,u,f;return u=t,f=t,i=un(),i!==null?(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=di(),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 un(){var i,e;if(e=ks(),e===null&&(e=N(),e===null&&(e=Se())),e!==null)for(i=[];e!==null;)i.push(e),e=ks(),e===null&&(e=N(),e===null&&(e=Se()));else i=null;return i}function di(){var i,e;for(i=[],e=ks(),e===null&&(e=N(),e===null&&(e=Se()));e!==null;)i.push(e),e=ks(),e===null&&(e=N(),e===null&&(e=Se()));return i}function ks(){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 cn(){var i;return i=pn(),i===null&&(i=yo()),i}function yo(){var i,e,l,u,f,h;return h=t,i=dn(),i!==null?(e=I(),e!==null?(l=pi(),l!==null?(u=I(),u!==null?(f=zn(),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 pi(){var i;return i=we(),i===null&&(i=Kn()),i}function Kn(){var i,e,l,u;return u=t,i=Fs(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Yn(),l===null&&(l=_n()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Yn(){var i,e,l,u,f;return u=t,i=mi(),i===null&&(i=fn()),i!==null?(f=t,r.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e!==null?(l=Si(),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 mi(){var i,e,l,u;return u=t,r.substr(t,2)==="//"?(i="//",t+=2):(i=null,_('"//"')),i!==null?(e=Ti(),e!==null?(l=fn(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function fn(){var i,e,l;return l=t,r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i!==null?(e=gi(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function _n(){var i,e,l,u;if(u=t,i=$s(),i!==null){for(e=[],l=Ls();l!==null;)e.push(l),l=Ls();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Ls(){var i;return i=ae(),i===null&&(i=N(),i===null&&(i=Se())),i}function $s(){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 gi(){var i,e,l,u,f,h;if(f=t,i=hn(),i!==null){for(e=[],h=t,r.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=hn(),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=hn(),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 hn(){var i,e,l,u,f,h;for(f=t,i=[],e=vs();e!==null;)i.push(e),e=vs();if(i!==null){for(e=[],h=t,r.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=Hs(),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=Hs(),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 Hs(){var i,e;for(i=[],e=vs();e!==null;)i.push(e),e=vs();return i}function vs(){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 Fs(){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 Ti(){var i;return i=vi(),i===null&&(i=Ei()),i}function vi(){var i,e,l,u;return l=t,u=t,i=Ft(),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=rn(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function Ei(){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 Si(){var i,e;for(i=[],e=Ls();e!==null;)i.push(e),e=Ls();return i}function zn(){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 Jn(){var i;return r.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,_('"INVITE"')),i}function yi(){var i;return r.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,_('"ACK"')),i}function Ai(){var i;return r.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,_('"OPTIONS"')),i}function Ci(){var i;return r.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,_('"BYE"')),i}function Ri(){var i;return r.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,_('"CANCEL"')),i}function Ii(){var i;return r.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,_('"REGISTER"')),i}function bi(){var i;return r.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,_('"SUBSCRIBE"')),i}function wi(){var i;return r.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,_('"NOTIFY"')),i}function Oi(){var i;return r.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,_('"REFER"')),i}function dn(){var i,e;return e=t,i=Jn(),i===null&&(i=yi(),i===null&&(i=Ai(),i===null&&(i=Ci(),i===null&&(i=Ri(),i===null&&(i=Ii(),i===null&&(i=bi(),i===null&&(i=wi(),i===null&&(i=Oi(),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 pn(){var i,e,l,u,f,h;return h=t,i=zn(),i!==null?(e=I(),e!==null?(l=Di(),l!==null?(u=I(),u!==null?(f=Ui(),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 Di(){var i,e;return e=t,i=Ni(),i!==null&&(i=function(l,u){b.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function Ni(){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 Ui(){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 Ao(){var i,e,l,u,f,h;if(f=t,i=Tn(),i!==null){for(e=[],h=t,l=Re(),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=Re(),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 Au(){var i,e,l,u,f,h;return u=t,f=t,i=rt(),i!==null?(h=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=rt(),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 Cu(){var i,e,l,u,f,h,m;if(f=t,i=ee(),i===null)if(h=t,i=Xn(),i!==null){for(e=[],m=t,l=Re(),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Re(),l!==null?(u=Xn(),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 Xn(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=js(),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=js(),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 Es(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 jt(){var i,e,l,u,f;return f=t,i=Vt(),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 Vt(){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 js(){var i;return i=Qn(),i===null&&(i=Pi(),i===null&&(i=ze())),i}function Qn(){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=G(),e!==null?(l=is(),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 Pi(){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=G(),e!==null?(l=rs(),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 rs(){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 is(){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 ze(){var i,e,l,u,f,h;return u=t,f=t,i=U(),i!==null?(h=t,e=G(),e!==null?(l=Je(),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 Je(){var i;return i=U(),i===null&&(i=ns(),i===null&&(i=Ie())),i}function Co(){var i,e,l,u,f,h;if(f=t,i=Ro(),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 Ro(){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 Zn(){var i;return i=er(),i===null&&(i=ze()),i}function er(){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=G(),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 Io(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Re(),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=Re(),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 Ru(){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 Iu(){var i,e;return e=t,i=bo(),i!==null&&(i=function(l){b=r.substring(t,l)}(e)),i===null&&(t=e),i}function bo(){var i,e,l,u,f,h,m,v;if(m=t,i=xi(),i!==null)if(e=Y(),e!==null)if(l=Li(),l!==null){for(u=[],v=t,f=le(),f!==null?(h=tr(),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=tr(),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 xi(){var i;return i=Mi(),i===null&&(i=ki()),i}function Mi(){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=mn()))))),i}function ki(){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=mn())),i}function mn(){var i;return i=U(),i===null&&(i=gn()),i}function gn(){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 Li(){var i;return i=mn(),i===null&&(i=U()),i}function tr(){var i,e,l,u;return u=t,i=U(),i!==null?(e=G(),e!==null?(l=sr(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function sr(){var i;return i=U(),i===null&&(i=Ie()),i}function wo(){var i,e,l,u;return u=t,i=Oo(),i!==null?(e=ve(),e!==null?(l=dn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Oo(){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 Do(){var i,e;return e=t,i=rs(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function bu(){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=ze(),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=ze(),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 vn(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=$i(),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=$i(),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 Es(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function $i(){var i;return i=En(),i===null&&(i=ze()),i}function En(){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=G(),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 Hi(){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 wu(){var i,e;return e=t,i=rs(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function Ou(){var i,e,l,u,f,h,m,v,S,O;for(v=t,S=t,i=[],e=Vt();e!==null;)i.push(e),e=Vt();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=ze(),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=ze(),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 Es(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=v),i}function Du(){var i;return i=Fi(),i}function Fi(){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=ls(),l!==null){for(u=[],v=t,f=Re(),f!==null?(h=ls(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Re(),f!==null?(h=ls(),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=nr()),i}function nr(){var i,e,l,u,f,h,m,v;if(m=t,i=U(),i!==null)if(e=ve(),e!==null)if(l=Vs(),l!==null){for(u=[],v=t,f=Re(),f!==null?(h=Vs(),h!==null?f=[f,h]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Re(),f!==null?(h=Vs(),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 Vs(){var i,e,l,u;return u=t,i=U(),i!==null?(e=G(),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 ls(){var i;return i=Sn(),i===null&&(i=Vi(),i===null&&(i=An(),i===null&&(i=Bi(),i===null&&(i=Gi(),i===null&&(i=Wi(),i===null&&(i=Ki(),i===null&&(i=Vs()))))))),i}function Sn(){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=G(),e!==null?(l=ji(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ji(){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 Vi(){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=G(),e!==null)if(l=it(),l!==null)if(u=yn(),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=yn(),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=yn(),m!==null?h=[h,m]:(h=null,t=S)):(h=null,t=S)}f!==null?(h=ot(),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 yn(){var i;return i=Kn(),i===null&&(i=fn()),i}function An(){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=G(),e!==null?(l=qi(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function qi(){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 Bi(){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=G(),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 Gi(){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=G(),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 Wi(){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=G(),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 Ki(){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=G(),e!==null)if(l=it(),l!==null){if(S=t,u=Cn(),u!==null){for(f=[],O=t,r.charCodeAt(t)===44?(h=",",t++):(h=null,_('","')),h!==null?(m=Cn(),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=Cn(),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=ot(),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 Cn(){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 rr(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Re(),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=Re(),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 Nu(){var i,e,l,u,f,h,m;if(f=t,h=t,i=ir(),i!==null){for(e=[],m=t,l=Re(),l!==null?(u=ir(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Re(),l!==null?(u=ir(),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 ir(){var i,e,l,u,f,h,m;if(f=t,h=t,i=jt(),i!==null){for(e=[],m=t,l=le(),l!==null?(u=ze(),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=ze(),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 Es(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 lr(){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=Yi(),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=Yi(),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 Yi(){var i;return i=or(),i===null&&(i=ze()),i}function or(){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=G(),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 No(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Re(),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=Re(),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 Uu(){var i,e,l,u,f,h;if(f=t,i=ar(),i!==null){for(e=[],h=t,l=Re(),l!==null?(u=ar(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Re(),l!==null?(u=ar(),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 ar(){var i,e,l,u,f,h;if(f=t,i=jt(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=ze(),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=ze(),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 ur(){var i,e,l,u,f,h;if(f=t,i=Uo(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=cr(),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=cr(),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 Uo(){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 cr(){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=G(),e!==null?(l=fr(),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=G(),e!==null?(l=rs(),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=G(),e!==null?(l=rs(),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=ze()))),i}function fr(){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 Po(){var i;return i=B(),i=i!==null?i:"",i}function Pu(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Re(),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=Re(),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 xu(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=zi(),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=zi(),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 Es(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function zi(){var i;return i=En(),i===null&&(i=ze()),i}function Ji(){var i,e,l,u,f,h;if(f=t,i=_r(),i!==null){for(e=[],h=t,l=Re(),l!==null?(u=_r(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Re(),l!==null?(u=_r(),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 _r(){var i,e,l,u,f,h,m,v;if(m=t,i=sl(),i!==null)if(e=ve(),e!==null)if(l=il(),l!==null){for(u=[],v=t,f=le(),f!==null?(h=qs(),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=qs(),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 qs(){var i;return i=hr(),i===null&&(i=Xi(),i===null&&(i=Qi(),i===null&&(i=Zi(),i===null&&(i=el(),i===null&&(i=ze()))))),i}function hr(){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=G(),e!==null?(l=dr(),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 Xi(){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=G(),e!==null?(l=ns(),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 Qi(){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=G(),e!==null?(l=at(),l===null&&(l=on()),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 Zi(){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=G(),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 el(){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=G(),e!==null?(l=tl(),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 tl(){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 sl(){var i,e,l,u,f,h;return h=t,i=nl(),i!==null?(e=Y(),e!==null?(l=U(),l!==null?(u=Y(),u!==null?(f=rl(),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 nl(){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 rl(){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 il(){var i,e,l,u,f;return u=t,i=ll(),i!==null?(f=t,e=ye(),e!==null?(l=ol(),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 ll(){var i,e;return e=t,i=at(),i===null&&(i=Bn(),i===null&&(i=Ts())),i!==null&&(i=function(l){b.host=r.substring(t,l)}(e)),i===null&&(t=e),i}function ol(){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 dr(){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 al(){var i;return i=Fi(),i}function Mu(){var i,e,l,u,f,h;if(f=t,i=xo(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=pr(),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=pr(),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 xo(){var i,e;return e=t,i=rs(),i!==null&&(i=function(l,u){b.expires=u}(e,i)),i===null&&(t=e),i}function pr(){var i;return i=mr(),i===null&&(i=ze()),i}function mr(){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=G(),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 Mo(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=ko(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ko(){var i,e;for(i=[],e=q(),e===null&&(e=H(),e===null&&(e=ve()));e!==null;)i.push(e),e=q(),e===null&&(e=H(),e===null&&(e=ve()));return i}function Lo(){var i,e;for(i=[],e=A();e!==null;)i.push(e),e=A();return i}function ku(){var i,e,l;return l=t,r.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,_('"uuid:"')),i!==null?(e=$o(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function $o(){var i,e,l,u,f,h,m,v,S,O,ie;return O=t,ie=t,i=Bt(),i!==null?(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e!==null?(l=qt(),l!==null?(r.charCodeAt(t)===45?(u="-",t++):(u=null,_('"-"')),u!==null?(f=qt(),f!==null?(r.charCodeAt(t)===45?(h="-",t++):(h=null,_('"-"')),h!==null?(m=qt(),m!==null?(r.charCodeAt(t)===45?(v="-",t++):(v=null,_('"-"')),v!==null?(S=ul(),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(Ue,Ot){b=r.substring(t+5,Ue)}(O,i[0])),i===null&&(t=O),i}function qt(){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 Bt(){var i,e,l;return l=t,i=qt(),i!==null?(e=qt(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function ul(){var i,e,l,u;return u=t,i=qt(),i!==null?(e=qt(),e!==null?(l=qt(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ho(){var i,e,l,u,f,h,m;if(f=t,h=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=ze(),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=ze(),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 Es(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=f),i}function Lu(){var i,e,l,u,f,h;if(f=t,i=Fo(),i!==null){for(e=[],h=t,l=le(),l!==null?(u=gr(),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=gr(),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 Fo(){var i,e,l,u,f,h;return u=t,f=t,i=rt(),i!==null?(h=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=rt(),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 gr(){var i;return i=Tr(),i===null&&(i=cl(),i===null&&(i=fl(),i===null&&(i=ze()))),i}function Tr(){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=G(),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 cl(){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=G(),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 fl(){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 jo(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 $u(){for(var i=1,e=1,l=!1,u=0;u<Math.max(t,n);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 Vo=fs(),Es=ka(),b={},w=a[o]();if(w===null||t!==r.length){var _l=Math.max(t,n),hl=_l<r.length?r.charAt(_l):null,qo=$u();return new this.SyntaxError(jo(p),hl,_l,qo.line,qo.column),-1}return b},toSource:function(){return this._source}};return s.SyntaxError=function(r,o,a,t,n){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=n},s.SyntaxError.prototype=Error.prototype,s}()),La}var $a,Ef;function fs(){if(Ef)return $a;Ef=1;const c=De,s=mt(),r=es();return $a=class N_{static parse(a){if(a=r.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,t,n,p,_={},d={}){if(!n)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=a||c.SIP,this._user=t,this._host=n,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[s.headerize(a)]=Array.isArray(t)?t:[t]}getHeader(a){if(a)return this._headers[s.headerize(a)]}hasHeader(a){if(a)return this._headers.hasOwnProperty(s.headerize(a))&&!0||!1}deleteHeader(a){if(a=s.headerize(a),this._headers.hasOwnProperty(a)){const t=this._headers[a];return delete this._headers[a],t}}clearHeaders(){this._headers={}}clone(){return new N_(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+=`${s.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const n in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=`;${n}`,this._parameters[n]!==null&&(t+=`=${this._parameters[n]}`));for(const n in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,n))for(const p of this._headers[n])a.push(`${n}=${p}`);return a.length>0&&(t+=`?${a.join("&")}`),t}toAor(a){let t=`${this._scheme}:`;return this._user&&(t+=`${s.escapeUser(this._user)}@`),t+=this._host,a&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},$a}var Sf;function mt(){if(Sf)return Ze;Sf=1;const c=De,s=fs(),r=es();Ze.str_utf8_length=n=>unescape(encodeURIComponent(n)).length;const o=Ze.isFunction=n=>n!==void 0?Object.prototype.toString.call(n)==="[object Function]":!1;Ze.isString=n=>n!==void 0?Object.prototype.toString.call(n)==="[object String]":!1,Ze.isDecimal=n=>!isNaN(n)&&parseFloat(n)===parseInt(n,10),Ze.isEmpty=n=>n===null||n===""||n===void 0||Array.isArray(n)&&n.length===0||typeof n=="number"&&isNaN(n),Ze.hasMethods=function(n,...p){for(const _ of p)if(o(n[_]))return!1;return!0};const a=Ze.createRandomToken=(n,p=32)=>{let _,d,g="";for(_=0;_<n;_++)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=n=>{if(n){if(n=r.parse(n,"host"),n!==-1)return n.host_type}else return};const t=Ze.escapeUser=n=>encodeURIComponent(decodeURIComponent(n)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return Ze.normalizeTarget=(n,p)=>{if(n){if(n instanceof s)return n;if(typeof n=="string"){const _=n.split("@");let d,g;switch(_.length){case 1:if(!p)return;d=n,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,"")),n=`${c.SIP}:${t(d)}@${g}`;let T;return(T=s.parse(n))?T:void 0}else return}else return},Ze.headerize=n=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},_=n.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=n=>{for(const p in c.SIP_ERROR_CAUSES)if(c.SIP_ERROR_CAUSES[p].indexOf(n)!==-1)return c.causes[p];return c.causes.SIP_FAILURE_CODE},Ze.getRandomTestNetIP=()=>{function n(p,_){return Math.floor(Math.random()*(_-p+1)+p)}return`192.0.2.${n(1,254)}`},Ze.calculateMD5=n=>{function p(Ee,Ae){return Ee<<Ae|Ee>>>32-Ae}function _(Ee,Ae){const Ie=Ee&2147483648,Oe=Ae&2147483648,pe=Ee&1073741824,he=Ae&1073741824,de=(Ee&1073741823)+(Ae&1073741823);return pe&he?de^2147483648^Ie^Oe:pe|he?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,he,de){return Ee=_(Ee,_(_(d(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function A(Ee,Ae,Ie,Oe,pe,he,de){return Ee=_(Ee,_(_(g(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function C(Ee,Ae,Ie,Oe,pe,he,de){return Ee=_(Ee,_(_(T(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function I(Ee,Ae,Ie,Oe,pe,he,de){return Ee=_(Ee,_(_(E(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function $(Ee){let Ae;const Ie=Ee.length,Oe=Ie+8,he=((Oe-Oe%64)/64+1)*16,de=new Array(he-1);let we=0,Ne=0;for(;Ne<Ie;)Ae=(Ne-Ne%4)/4,we=Ne%4*8,de[Ae]=de[Ae]|Ee.charCodeAt(Ne)<<we,Ne++;return Ae=(Ne-Ne%4)/4,we=Ne%4*8,de[Ae]=de[Ae]|128<<we,de[he-2]=Ie<<3,de[he-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,B,q,z,H;const Z=7,U=12,P=17,se=22,rt=5,ee=9,Y=14,G=20,re=4,ge=11,be=16,xe=23,Re=6,le=10,ye=15,it=21;for(n=ae(n),N=$(n),B=1732584193,q=4023233417,z=2562383102,H=271733878,F=0;F<N.length;F+=16)Se=B,ve=q,M=z,D=H,B=y(B,q,z,H,N[F+0],Z,3614090360),H=y(H,B,q,z,N[F+1],U,3905402710),z=y(z,H,B,q,N[F+2],P,606105819),q=y(q,z,H,B,N[F+3],se,3250441966),B=y(B,q,z,H,N[F+4],Z,4118548399),H=y(H,B,q,z,N[F+5],U,1200080426),z=y(z,H,B,q,N[F+6],P,2821735955),q=y(q,z,H,B,N[F+7],se,4249261313),B=y(B,q,z,H,N[F+8],Z,1770035416),H=y(H,B,q,z,N[F+9],U,2336552879),z=y(z,H,B,q,N[F+10],P,4294925233),q=y(q,z,H,B,N[F+11],se,2304563134),B=y(B,q,z,H,N[F+12],Z,1804603682),H=y(H,B,q,z,N[F+13],U,4254626195),z=y(z,H,B,q,N[F+14],P,2792965006),q=y(q,z,H,B,N[F+15],se,1236535329),B=A(B,q,z,H,N[F+1],rt,4129170786),H=A(H,B,q,z,N[F+6],ee,3225465664),z=A(z,H,B,q,N[F+11],Y,643717713),q=A(q,z,H,B,N[F+0],G,3921069994),B=A(B,q,z,H,N[F+5],rt,3593408605),H=A(H,B,q,z,N[F+10],ee,38016083),z=A(z,H,B,q,N[F+15],Y,3634488961),q=A(q,z,H,B,N[F+4],G,3889429448),B=A(B,q,z,H,N[F+9],rt,568446438),H=A(H,B,q,z,N[F+14],ee,3275163606),z=A(z,H,B,q,N[F+3],Y,4107603335),q=A(q,z,H,B,N[F+8],G,1163531501),B=A(B,q,z,H,N[F+13],rt,2850285829),H=A(H,B,q,z,N[F+2],ee,4243563512),z=A(z,H,B,q,N[F+7],Y,1735328473),q=A(q,z,H,B,N[F+12],G,2368359562),B=C(B,q,z,H,N[F+5],re,4294588738),H=C(H,B,q,z,N[F+8],ge,2272392833),z=C(z,H,B,q,N[F+11],be,1839030562),q=C(q,z,H,B,N[F+14],xe,4259657740),B=C(B,q,z,H,N[F+1],re,2763975236),H=C(H,B,q,z,N[F+4],ge,1272893353),z=C(z,H,B,q,N[F+7],be,4139469664),q=C(q,z,H,B,N[F+10],xe,3200236656),B=C(B,q,z,H,N[F+13],re,681279174),H=C(H,B,q,z,N[F+0],ge,3936430074),z=C(z,H,B,q,N[F+3],be,3572445317),q=C(q,z,H,B,N[F+6],xe,76029189),B=C(B,q,z,H,N[F+9],re,3654602809),H=C(H,B,q,z,N[F+12],ge,3873151461),z=C(z,H,B,q,N[F+15],be,530742520),q=C(q,z,H,B,N[F+2],xe,3299628645),B=I(B,q,z,H,N[F+0],Re,4096336452),H=I(H,B,q,z,N[F+7],le,1126891415),z=I(z,H,B,q,N[F+14],ye,2878612391),q=I(q,z,H,B,N[F+5],it,4237533241),B=I(B,q,z,H,N[F+12],Re,1700485571),H=I(H,B,q,z,N[F+3],le,2399980690),z=I(z,H,B,q,N[F+10],ye,4293915773),q=I(q,z,H,B,N[F+1],it,2240044497),B=I(B,q,z,H,N[F+8],Re,1873313359),H=I(H,B,q,z,N[F+15],le,4264355552),z=I(z,H,B,q,N[F+6],ye,2734768916),q=I(q,z,H,B,N[F+13],it,1309151649),B=I(B,q,z,H,N[F+4],Re,4149444226),H=I(H,B,q,z,N[F+11],le,3174756917),z=I(z,H,B,q,N[F+2],ye,718787259),q=I(q,z,H,B,N[F+9],it,3951481745),B=_(B,Se),q=_(q,ve),z=_(z,M),H=_(H,D);return(L(B)+L(q)+L(z)+L(H)).toLowerCase()},Ze.closeMediaStream=n=>{if(n)try{let p;if(n.getTracks){p=n.getTracks();for(const _ of p)_.stop()}else{p=n.getAudioTracks();for(const _ of p)_.stop();p=n.getVideoTracks();for(const _ of p)_.stop()}}catch{(typeof n.stop=="function"||typeof n.stop=="object")&&n.stop()}},Ze.cloneArray=n=>n&&n.slice()||[],Ze.cloneObject=(n,p={})=>n&&Object.assign({},n)||p,Ze}const yf=Dt,gm=lt,gt=De,nt=mt(),Af=ka(),Tm=es(),Ha=new gm("SIPMessage");class Zl{constructor(s,r,o,a,t,n){if(!s||!r||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=s,this.ruri=r,this.body=n,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",gt.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 Af(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 Af(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} ${s}`)}setHeader(s,r){const o=new RegExp(`^\\s*${s}\\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(s)]=Array.isArray(r)?r:[r]}getHeader(s){const r=this.headers[nt.headerize(s)];if(r){if(r[0])return r[0]}else{const o=new RegExp(`^\\s*${s}\\s*:`,"i");for(const a of this.extraHeaders)if(o.test(a))return a.substring(a.indexOf(":")+1).trim()}}getHeaders(s){const r=this.headers[nt.headerize(s)],o=[];if(r){for(const a of r)o.push(a);return o}else{const a=new RegExp(`^\\s*${s}\\s*:`,"i");for(const t of this.extraHeaders)a.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(s){if(this.headers[nt.headerize(s)])return!0;{const r=new RegExp(`^\\s*${s}\\s*:`,"i");for(const o of this.extraHeaders)if(r.test(o))return!0}return!1}parseSDP(s){return!s&&this.sdp?this.sdp:(this.sdp=yf.parse(this.body||""),this.sdp)}toString(){let s=`${this.method} ${this.ruri} SIP/2.0\r
|
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 C(){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(d,m){return m.join("")}(u,i)),i===null&&(t=u),i}function ve(){var i,e,l,u,f,d;for(u=t,f=t,d=t,i=[],e=y();e!==null;)i.push(e),e=y();if(i!==null?(e=h(),e!==null?i=[i,e]:(i=null,t=d)):(i=null,t=d),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(d){return":"}()),i===null&&(t=u),i}function B(){var i,e,l,u,f,d,m;if(f=t,d=t,e=q(),e!==null)for(i=[];e!==null;)i.push(e),e=q();else i=null;if(i!==null){for(e=[],m=t,l=[],u=ve();u!==null;)l.push(u),u=ve();for(l!==null?(u=q(),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=q(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m)}e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;return i!==null&&(i=function(v){return r.substring(t,v)}(f)),i===null&&(t=f),i}function q(){var i;return/^[!-~]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[!-~]")),i===null&&(i=J()),i}function J(){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 Z(){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=C(),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 rt(){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=C(),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=C(),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(d){return"*"}()),i===null&&(t=u),i}function Y(){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(d){return"/"}()),i===null&&(t=u),i}function G(){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(d){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(d){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(d){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 Re(){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(d){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(d){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(d){return":"}()),i===null&&(t=u),i}function it(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(e=C(),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 ot(){var i,e,l,u;return l=t,u=t,i=C(),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=he(),l===null&&(l=Ee()));l!==null;)e.push(l),l=Ae(),l===null&&(l=he(),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=J(),i===null&&(i=ve())))),i}function Ie(){var i,e,l,u,f,d;if(f=t,d=t,i=M(),i!==null)if(e=C(),e!==null){for(l=[],u=pe(),u===null&&(u=he());u!==null;)l.push(u),u=pe(),u===null&&(u=he());l!==null?(u=C(),u!==null?i=[i,e,l,u]:(i=null,t=d)):(i=null,t=d)}else i=null,t=d;else i=null,t=d;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,d;if(f=t,d=t,i=M(),i!==null)if(e=C(),e!==null){for(l=[],u=pe(),u===null&&(u=he());u!==null;)l.push(u),u=pe(),u===null&&(u=he());l!==null?(u=C(),u!==null?i=[i,e,l,u]:(i=null,t=d)):(i=null,t=d)}else i=null,t=d;else i=null,t=d;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=J())))),i}function he(){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,d;return f=t,d=t,i=Ne(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ft(),l=l!==null?l:"",l!==null?(u=rn(),u!==null?i=[i,e,l,u]:(i=null,t=d)):(i=null,t=d)):(i=null,t=d)):(i=null,t=d),i!==null&&(i=function(m){try{b.uri=new Vo(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,d,m,v;return m=t,v=t,i=Ne(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ft(),l=l!==null?l:"",l!==null?(u=rn(),u!==null?(f=ri(),f!==null?(d=hi(),d=d!==null?d:"",d!==null?i=[i,e,l,u,f,d]:(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 Vo(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 Ne(){var i;return i=et(),i===null&&(i=He()),i}function et(){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 He(){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 Ft(){var i,e,l,u,f,d;return u=t,f=t,i=At(),i!==null?(d=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Vn(),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d),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 At(){var i,e;if(e=N(),e===null&&(e=Se(),e===null&&(e=jn())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=Se(),e===null&&(e=jn()));else i=null;return i}function jn(){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 Vn(){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 rn(){var i,e,l,u,f;return u=t,i=ns(),i!==null?(f=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ps(),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 ns(){var i,e;return e=t,i=Ts(),i===null&&(i=at(),i===null&&(i=Bn())),i!==null&&(i=function(l){return b.host=r.substring(t,l).toLowerCase(),b.host}(e)),i===null&&(t=e),i}function Ts(){var i,e,l,u,f,d;for(u=t,f=t,i=[],d=t,e=ln(),e!==null?(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d);e!==null;)i.push(e),d=t,e=ln(),e!==null?(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d);return i!==null?(e=qn(),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 ln(){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 qn(){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 Bn(){var i,e,l,u,f;return u=t,f=t,r.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i!==null?(e=on(),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(d){return b.host_type="IPv6",r.substring(t,d)}(u)),i===null&&(t=u),i}function on(){var i,e,l,u,f,d,m,v,S,O,ie,Ue,Ot,Bs,k,R;return Bs=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?(d=":",t++):(d=null,_('":"')),d!==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?(Ue=":",t++):(Ue=null,_('":"')),Ue!==null?(Ot=oe(),Ot!==null?i=[i,e,l,u,f,d,m,v,S,O,ie,Ue,Ot]:(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?(d=me(),d!==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?(Ue=oe(),Ue!==null?i=[i,e,l,u,f,d,m,v,S,O,ie,Ue]:(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?(d=me(),d!==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,d,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?(d=me(),d!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?i=[i,e,l,u,f,d,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?(d=oe(),d!==null?i=[i,e,l,u,f,d]:(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?(d=":",t++):(d=null,_('":"')),d!==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,d,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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),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?(d=me(),d!==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,d,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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),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?(d=":",t++):(d=null,_('":"')),d!==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,d,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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),u=u!==null?u:"",u!==null?(r.substr(t,2)==="::"?(f="::",t+=2):(f=null,_('"::"')),f!==null?(d=me(),d!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?i=[i,e,l,u,f,d,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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),u=u!==null?u:"",u!==null?(R=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(d=me(),d!==null?f=[f,d]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(r.substr(t,2)==="::"?(d="::",t+=2):(d=null,_('"::"')),d!==null?(m=oe(),m!==null?i=[i,e,l,u,f,d,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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),u=u!==null?u:"",u!==null?(R=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(d=me(),d!==null?f=[f,d]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(R=t,r.charCodeAt(t)===58?(d=":",t++):(d=null,_('":"')),d!==null?(m=me(),m!==null?d=[d,m]:(d=null,t=R)):(d=null,t=R),d=d!==null?d:"",d!==null?(r.substr(t,2)==="::"?(m="::",t+=2):(m=null,_('"::"')),m!==null?(v=me(),v!==null?i=[i,e,l,u,f,d,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?(R=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=me(),l!==null?e=[e,l]:(e=null,t=R)):(e=null,t=R),e=e!==null?e:"",e!==null?(R=t,r.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=me(),u!==null?l=[l,u]:(l=null,t=R)):(l=null,t=R),l=l!==null?l:"",l!==null?(R=t,r.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=me(),f!==null?u=[u,f]:(u=null,t=R)):(u=null,t=R),u=u!==null?u:"",u!==null?(R=t,r.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(d=me(),d!==null?f=[f,d]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(R=t,r.charCodeAt(t)===58?(d=":",t++):(d=null,_('":"')),d!==null?(m=me(),m!==null?d=[d,m]:(d=null,t=R)):(d=null,t=R),d=d!==null?d:"",d!==null?(R=t,r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=me(),v!==null?m=[m,v]:(m=null,t=R)):(m=null,t=R),m=m!==null?m:"",m!==null?(r.substr(t,2)==="::"?(v="::",t+=2):(v=null,_('"::"')),v!==null?i=[i,e,l,u,f,d,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)}(Bs)),i===null&&(t=Bs),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=at()),i}function at(){var i,e,l,u,f,d,m,v,S;return v=t,S=t,i=Jt(),i!==null?(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e!==null?(l=Jt(),l!==null?(r.charCodeAt(t)===46?(u=".",t++):(u=null,_('"."')),u!==null?(f=Jt(),f!==null?(r.charCodeAt(t)===46?(d=".",t++):(d=null,_('"."')),d!==null?(m=Jt(),m!==null?i=[i,e,l,u,f,d,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 Jt(){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 Ps(){var i,e,l,u,f,d,m;return d=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}(d,i)),i===null&&(t=d),i}function ri(){var i,e,l,u;for(i=[],u=t,r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=Gn(),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=Gn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function Gn(){var i;return i=Wn(),i===null&&(i=ii(),i===null&&(i=li(),i===null&&(i=oi(),i===null&&(i=ai(),i===null&&(i=ui(),i===null&&(i=ci())))))),i}function Wn(){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,d){b.uri_params||(b.uri_params={}),b.uri_params.transport=d.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function ii(){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,d){b.uri_params||(b.uri_params={}),b.uri_params.user=d.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function li(){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=dn(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,d){b.uri_params||(b.uri_params={}),b.uri_params.method=d}(l,i[1])),i===null&&(t=l),i}function oi(){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=dr(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,d){b.params||(b.params={}),b.params.ttl=d}(l,i[1])),i===null&&(t=l),i}function ai(){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=ns(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,d){b.uri_params||(b.uri_params={}),b.uri_params.maddr=d}(l,i[1])),i===null&&(t=l),i}function ui(){var i,e,l,u,f,d;return u=t,f=t,r.substr(t,2).toLowerCase()==="lr"?(i=r.substr(t,2),t+=2):(i=null,_('"lr"')),i!==null?(d=t,r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=U(),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d),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 ci(){var i,e,l,u,f,d;return u=t,f=t,i=fi(),i!==null?(d=t,r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=_i(),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d),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 fi(){var i,e,l;if(l=t,e=xs(),e!==null)for(i=[];e!==null;)i.push(e),e=xs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function _i(){var i,e,l;if(l=t,e=xs(),e!==null)for(i=[];e!==null;)i.push(e),e=xs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function xs(){var i;return i=Ms(),i===null&&(i=N(),i===null&&(i=Se())),i}function Ms(){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 hi(){var i,e,l,u,f,d,m;if(d=t,r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i!==null)if(e=an(),e!==null){for(l=[],m=t,r.charCodeAt(t)===38?(u="&",t++):(u=null,_('"&"')),u!==null?(f=an(),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=an(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);l!==null?i=[i,e,l]:(i=null,t=d)}else i=null,t=d;else i=null,t=d;return i}function an(){var i,e,l,u,f;return u=t,f=t,i=un(),i!==null?(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=di(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,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 un(){var i,e;if(e=ks(),e===null&&(e=N(),e===null&&(e=Se())),e!==null)for(i=[];e!==null;)i.push(e),e=ks(),e===null&&(e=N(),e===null&&(e=Se()));else i=null;return i}function di(){var i,e;for(i=[],e=ks(),e===null&&(e=N(),e===null&&(e=Se()));e!==null;)i.push(e),e=ks(),e===null&&(e=N(),e===null&&(e=Se()));return i}function ks(){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 cn(){var i;return i=pn(),i===null&&(i=yo()),i}function yo(){var i,e,l,u,f,d;return d=t,i=dn(),i!==null?(e=I(),e!==null?(l=pi(),l!==null?(u=I(),u!==null?(f=Jn(),f!==null?i=[i,e,l,u,f]:(i=null,t=d)):(i=null,t=d)):(i=null,t=d)):(i=null,t=d)):(i=null,t=d),i}function pi(){var i;return i=we(),i===null&&(i=Kn()),i}function Kn(){var i,e,l,u;return u=t,i=Fs(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Yn(),l===null&&(l=_n()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Yn(){var i,e,l,u,f;return u=t,i=mi(),i===null&&(i=fn()),i!==null?(f=t,r.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e!==null?(l=Si(),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 mi(){var i,e,l,u;return u=t,r.substr(t,2)==="//"?(i="//",t+=2):(i=null,_('"//"')),i!==null?(e=Ti(),e!==null?(l=fn(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function fn(){var i,e,l;return l=t,r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i!==null?(e=gi(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function _n(){var i,e,l,u;if(u=t,i=$s(),i!==null){for(e=[],l=Ls();l!==null;)e.push(l),l=Ls();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Ls(){var i;return i=ae(),i===null&&(i=N(),i===null&&(i=Se())),i}function $s(){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 gi(){var i,e,l,u,f,d;if(f=t,i=hn(),i!==null){for(e=[],d=t,r.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=hn(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,r.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=hn(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function hn(){var i,e,l,u,f,d;for(f=t,i=[],e=vs();e!==null;)i.push(e),e=vs();if(i!==null){for(e=[],d=t,r.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=Hs(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,r.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=Hs(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Hs(){var i,e;for(i=[],e=vs();e!==null;)i.push(e),e=vs();return i}function vs(){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 Fs(){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(d){b.scheme=r.substring(t,d)}(u)),i===null&&(t=u),i}function Ti(){var i;return i=vi(),i===null&&(i=Ei()),i}function vi(){var i,e,l,u;return l=t,u=t,i=Ft(),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=rn(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function Ei(){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 Si(){var i,e;for(i=[],e=Ls();e!==null;)i.push(e),e=Ls();return i}function Jn(){var i,e,l,u,f,d,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(d=g(),d!==null)for(f=[];d!==null;)f.push(d),d=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 zn(){var i;return r.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,_('"INVITE"')),i}function yi(){var i;return r.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,_('"ACK"')),i}function Ai(){var i;return r.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,_('"OPTIONS"')),i}function Ci(){var i;return r.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,_('"BYE"')),i}function Ri(){var i;return r.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,_('"CANCEL"')),i}function Ii(){var i;return r.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,_('"REGISTER"')),i}function bi(){var i;return r.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,_('"SUBSCRIBE"')),i}function wi(){var i;return r.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,_('"NOTIFY"')),i}function Oi(){var i;return r.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,_('"REFER"')),i}function dn(){var i,e;return e=t,i=zn(),i===null&&(i=yi(),i===null&&(i=Ai(),i===null&&(i=Ci(),i===null&&(i=Ri(),i===null&&(i=Ii(),i===null&&(i=bi(),i===null&&(i=wi(),i===null&&(i=Oi(),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 pn(){var i,e,l,u,f,d;return d=t,i=Jn(),i!==null?(e=I(),e!==null?(l=Di(),l!==null?(u=I(),u!==null?(f=Ui(),f!==null?i=[i,e,l,u,f]:(i=null,t=d)):(i=null,t=d)):(i=null,t=d)):(i=null,t=d)):(i=null,t=d),i}function Di(){var i,e;return e=t,i=Ni(),i!==null&&(i=function(l,u){b.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function Ni(){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 Ui(){var i,e,l;for(l=t,i=[],e=ae(),e===null&&(e=N(),e===null&&(e=Se(),e===null&&(e=J(),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=J(),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 Ao(){var i,e,l,u,f,d;if(f=t,i=Tn(),i!==null){for(e=[],d=t,l=Re(),l!==null?(u=Tn(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=Re(),l!==null?(u=Tn(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Au(){var i,e,l,u,f,d;return u=t,f=t,i=rt(),i!==null?(d=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=rt(),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d),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 Cu(){var i,e,l,u,f,d,m;if(f=t,i=ee(),i===null)if(d=t,i=Xn(),i!==null){for(e=[],m=t,l=Re(),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Re(),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;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 Xn(){var i,e,l,u,f,d,m;if(f=t,d=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=js(),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=js(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;return i!==null&&(i=function(v){var S;b.multi_header||(b.multi_header=[]);try{S=new Es(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 jt(){var i,e,l,u,f;return f=t,i=Vt(),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 Vt(){var i,e,l,u,f,d,m;if(f=t,d=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=d)}else i=null,t=d;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 js(){var i;return i=Qn(),i===null&&(i=Pi(),i===null&&(i=Je())),i}function Qn(){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=G(),e!==null?(l=is(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,m){b.params||(b.params={}),b.params.q=m}(u,i[2])),i===null&&(t=u),i}function Pi(){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=G(),e!==null?(l=rs(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,m){b.params||(b.params={}),b.params.expires=m}(u,i[2])),i===null&&(t=u),i}function rs(){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 is(){var i,e,l,u,f,d,m,v;return d=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))}(d)),i===null&&(t=d),i}function Je(){var i,e,l,u,f,d;return u=t,f=t,i=U(),i!==null?(d=t,e=G(),e!==null?(l=ze(),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d),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 ze(){var i;return i=U(),i===null&&(i=ns(),i===null&&(i=Ie())),i}function Co(){var i,e,l,u,f,d;if(f=t,i=Ro(),i!==null){for(e=[],d=t,l=le(),l!==null?(u=Zn(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=le(),l!==null?(u=Zn(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Ro(){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 Zn(){var i;return i=er(),i===null&&(i=Je()),i}function er(){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=G(),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 Io(){var i,e,l,u,f,d;if(f=t,i=U(),i!==null){for(e=[],d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Ru(){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 Iu(){var i,e;return e=t,i=bo(),i!==null&&(i=function(l){b=r.substring(t,l)}(e)),i===null&&(t=e),i}function bo(){var i,e,l,u,f,d,m,v;if(m=t,i=xi(),i!==null)if(e=Y(),e!==null)if(l=Li(),l!==null){for(u=[],v=t,f=le(),f!==null?(d=tr(),d!==null?f=[f,d]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=le(),f!==null?(d=tr(),d!==null?f=[f,d]:(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 xi(){var i;return i=Mi(),i===null&&(i=ki()),i}function Mi(){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=mn()))))),i}function ki(){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=mn())),i}function mn(){var i;return i=U(),i===null&&(i=gn()),i}function gn(){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 Li(){var i;return i=mn(),i===null&&(i=U()),i}function tr(){var i,e,l,u;return u=t,i=U(),i!==null?(e=G(),e!==null?(l=sr(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function sr(){var i;return i=U(),i===null&&(i=Ie()),i}function wo(){var i,e,l,u;return u=t,i=Oo(),i!==null?(e=ve(),e!==null?(l=dn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Oo(){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 Do(){var i,e;return e=t,i=rs(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function bu(){var i,e,l,u,f,d,m;if(f=t,d=t,i=Tn(),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Je(),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=Je(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;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,d;if(f=t,i=P(),i!==null){for(e=[],d=t,r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function vn(){var i,e,l,u,f,d,m;if(f=t,d=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=$i(),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=$i(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;return i!==null&&(i=function(v){var S=b.tag;try{b=new Es(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function $i(){var i;return i=En(),i===null&&(i=Je()),i}function En(){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=G(),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(d,m){b.tag=m}(u,i[2])),i===null&&(t=u),i}function Hi(){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 wu(){var i,e;return e=t,i=rs(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function Ou(){var i,e,l,u,f,d,m,v,S,O;for(v=t,S=t,i=[],e=Vt();e!==null;)i.push(e),e=Vt();if(i!==null)if(e=xe(),e!==null)if(l=we(),l!==null)if(u=be(),u!==null){for(f=[],O=t,d=le(),d!==null?(m=Je(),m!==null?d=[d,m]:(d=null,t=O)):(d=null,t=O);d!==null;)f.push(d),O=t,d=le(),d!==null?(m=Je(),m!==null?d=[d,m]:(d=null,t=O)):(d=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 Es(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=v),i}function Du(){var i;return i=Fi(),i}function Fi(){var i,e,l,u,f,d,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=ls(),l!==null){for(u=[],v=t,f=Re(),f!==null?(d=ls(),d!==null?f=[f,d]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Re(),f!==null?(d=ls(),d!==null?f=[f,d]:(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=nr()),i}function nr(){var i,e,l,u,f,d,m,v;if(m=t,i=U(),i!==null)if(e=ve(),e!==null)if(l=Vs(),l!==null){for(u=[],v=t,f=Re(),f!==null?(d=Vs(),d!==null?f=[f,d]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Re(),f!==null?(d=Vs(),d!==null?f=[f,d]:(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 Vs(){var i,e,l,u;return u=t,i=U(),i!==null?(e=G(),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 ls(){var i;return i=Sn(),i===null&&(i=Vi(),i===null&&(i=An(),i===null&&(i=Bi(),i===null&&(i=Gi(),i===null&&(i=Wi(),i===null&&(i=Ki(),i===null&&(i=Vs()))))))),i}function Sn(){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=G(),e!==null?(l=ji(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ji(){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 Vi(){var i,e,l,u,f,d,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=G(),e!==null)if(l=it(),l!==null)if(u=yn(),u!==null){if(f=[],S=t,m=I(),m!==null)for(d=[];m!==null;)d.push(m),m=I();else d=null;for(d!==null?(m=yn(),m!==null?d=[d,m]:(d=null,t=S)):(d=null,t=S);d!==null;){if(f.push(d),S=t,m=I(),m!==null)for(d=[];m!==null;)d.push(m),m=I();else d=null;d!==null?(m=yn(),m!==null?d=[d,m]:(d=null,t=S)):(d=null,t=S)}f!==null?(d=ot(),d!==null?i=[i,e,l,u,f,d]:(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 yn(){var i;return i=Kn(),i===null&&(i=fn()),i}function An(){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=G(),e!==null?(l=qi(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function qi(){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 Bi(){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=G(),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(d,m){b.opaque=m}(u,i[2])),i===null&&(t=u),i}function Gi(){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=G(),e!==null?(f=t,r.substr(t,4).toLowerCase()==="true"?(l=r.substr(t,4),t+=4):(l=null,_('"true"')),l!==null&&(l=function(d){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(d){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 Wi(){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=G(),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(d,m){b.algorithm=m.toUpperCase()}(u,i[2])),i===null&&(t=u),i}function Ki(){var i,e,l,u,f,d,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=G(),e!==null)if(l=it(),l!==null){if(S=t,u=Cn(),u!==null){for(f=[],O=t,r.charCodeAt(t)===44?(d=",",t++):(d=null,_('","')),d!==null?(m=Cn(),m!==null?d=[d,m]:(d=null,t=O)):(d=null,t=O);d!==null;)f.push(d),O=t,r.charCodeAt(t)===44?(d=",",t++):(d=null,_('","')),d!==null?(m=Cn(),m!==null?d=[d,m]:(d=null,t=O)):(d=null,t=O);f!==null?u=[u,f]:(u=null,t=S)}else u=null,t=S;u!==null?(f=ot(),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 Cn(){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 rr(){var i,e,l,u,f,d;if(f=t,i=U(),i!==null){for(e=[],d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Nu(){var i,e,l,u,f,d,m;if(f=t,d=t,i=ir(),i!==null){for(e=[],m=t,l=Re(),l!==null?(u=ir(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Re(),l!==null?(u=ir(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;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 ir(){var i,e,l,u,f,d,m;if(f=t,d=t,i=jt(),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Je(),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=Je(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;return i!==null&&(i=function(v){var S;b.multi_header||(b.multi_header=[]);try{S=new Es(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 lr(){var i,e,l,u,f,d,m;if(f=t,d=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=Yi(),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=Yi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;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 Yi(){var i;return i=or(),i===null&&(i=Je()),i}function or(){var i,e,l,u,f,d;if(f=t,d=t,r.substr(t,5).toLowerCase()==="cause"?(i=r.substr(t,5),t+=5):(i=null,_('"cause"')),i!==null)if(e=G(),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=d)}else i=null,t=d;else i=null,t=d;return i!==null&&(i=function(m,v){b.cause=parseInt(v.join(""))}(f,i[2])),i===null&&(t=f),i}function No(){var i,e,l,u,f,d;if(f=t,i=U(),i!==null){for(e=[],d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Uu(){var i,e,l,u,f,d;if(f=t,i=ar(),i!==null){for(e=[],d=t,l=Re(),l!==null?(u=ar(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=Re(),l!==null?(u=ar(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function ar(){var i,e,l,u,f,d;if(f=t,i=jt(),i!==null){for(e=[],d=t,l=le(),l!==null?(u=Je(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=le(),l!==null?(u=Je(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function ur(){var i,e,l,u,f,d;if(f=t,i=Uo(),i!==null){for(e=[],d=t,l=le(),l!==null?(u=cr(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=le(),l!==null?(u=cr(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Uo(){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 cr(){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=G(),e!==null?(l=fr(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,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=G(),e!==null?(l=rs(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,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=G(),e!==null?(l=rs(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,m){typeof m<"u"&&(b.retry_after=m)}(u,i[2])),i===null&&(t=u),i===null&&(i=Je()))),i}function fr(){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 Po(){var i;return i=B(),i=i!==null?i:"",i}function Pu(){var i,e,l,u,f,d;if(f=t,i=U(),i!==null){for(e=[],d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=Re(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i=i!==null?i:"",i}function xu(){var i,e,l,u,f,d,m;if(f=t,d=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Ji(),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=Ji(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;return i!==null&&(i=function(v){var S=b.tag;try{b=new Es(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function Ji(){var i;return i=En(),i===null&&(i=Je()),i}function zi(){var i,e,l,u,f,d;if(f=t,i=_r(),i!==null){for(e=[],d=t,l=Re(),l!==null?(u=_r(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=Re(),l!==null?(u=_r(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function _r(){var i,e,l,u,f,d,m,v;if(m=t,i=sl(),i!==null)if(e=ve(),e!==null)if(l=il(),l!==null){for(u=[],v=t,f=le(),f!==null?(d=qs(),d!==null?f=[f,d]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=le(),f!==null?(d=qs(),d!==null?f=[f,d]:(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 qs(){var i;return i=hr(),i===null&&(i=Xi(),i===null&&(i=Qi(),i===null&&(i=Zi(),i===null&&(i=el(),i===null&&(i=Je()))))),i}function hr(){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=G(),e!==null?(l=dr(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,m){b.ttl=m}(u,i[2])),i===null&&(t=u),i}function Xi(){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=G(),e!==null?(l=ns(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,m){b.maddr=m}(u,i[2])),i===null&&(t=u),i}function Qi(){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=G(),e!==null?(l=at(),l===null&&(l=on()),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(d,m){b.received=m}(u,i[2])),i===null&&(t=u),i}function Zi(){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=G(),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(d,m){b.branch=m}(u,i[2])),i===null&&(t=u),i}function el(){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=G(),e!==null?(l=tl(),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 tl(){var i,e,l,u,f,d,m;return d=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(""))}(d,i)),i===null&&(t=d),i}function sl(){var i,e,l,u,f,d;return d=t,i=nl(),i!==null?(e=Y(),e!==null?(l=U(),l!==null?(u=Y(),u!==null?(f=rl(),f!==null?i=[i,e,l,u,f]:(i=null,t=d)):(i=null,t=d)):(i=null,t=d)):(i=null,t=d)):(i=null,t=d),i}function nl(){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 rl(){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 il(){var i,e,l,u,f;return u=t,i=ll(),i!==null?(f=t,e=ye(),e!==null?(l=ol(),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 ll(){var i,e;return e=t,i=at(),i===null&&(i=Bn(),i===null&&(i=Ts())),i!==null&&(i=function(l){b.host=r.substring(t,l)}(e)),i===null&&(t=e),i}function ol(){var i,e,l,u,f,d,m;return d=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(""))}(d,i)),i===null&&(t=d),i}function dr(){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(d,m){return parseInt(m.join(""))}(u,i)),i===null&&(t=u),i}function al(){var i;return i=Fi(),i}function Mu(){var i,e,l,u,f,d;if(f=t,i=xo(),i!==null){for(e=[],d=t,l=le(),l!==null?(u=pr(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=le(),l!==null?(u=pr(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function xo(){var i,e;return e=t,i=rs(),i!==null&&(i=function(l,u){b.expires=u}(e,i)),i===null&&(t=e),i}function pr(){var i;return i=mr(),i===null&&(i=Je()),i}function mr(){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=G(),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(d,m){b.refresher=m.toLowerCase()}(u,i[2])),i===null&&(t=u),i}function Mo(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=ko(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ko(){var i,e;for(i=[],e=q(),e===null&&(e=H(),e===null&&(e=ve()));e!==null;)i.push(e),e=q(),e===null&&(e=H(),e===null&&(e=ve()));return i}function Lo(){var i,e;for(i=[],e=A();e!==null;)i.push(e),e=A();return i}function ku(){var i,e,l;return l=t,r.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,_('"uuid:"')),i!==null?(e=$o(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function $o(){var i,e,l,u,f,d,m,v,S,O,ie;return O=t,ie=t,i=Bt(),i!==null?(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e!==null?(l=qt(),l!==null?(r.charCodeAt(t)===45?(u="-",t++):(u=null,_('"-"')),u!==null?(f=qt(),f!==null?(r.charCodeAt(t)===45?(d="-",t++):(d=null,_('"-"')),d!==null?(m=qt(),m!==null?(r.charCodeAt(t)===45?(v="-",t++):(v=null,_('"-"')),v!==null?(S=ul(),S!==null?i=[i,e,l,u,f,d,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(Ue,Ot){b=r.substring(t+5,Ue)}(O,i[0])),i===null&&(t=O),i}function qt(){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 Bt(){var i,e,l;return l=t,i=qt(),i!==null?(e=qt(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function ul(){var i,e,l,u;return u=t,i=qt(),i!==null?(e=qt(),e!==null?(l=qt(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ho(){var i,e,l,u,f,d,m;if(f=t,d=t,i=de(),i===null&&(i=jt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Je(),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=Je(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=d)}else i=null,t=d;return i!==null&&(i=function(v){try{b=new Es(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=f),i}function Lu(){var i,e,l,u,f,d;if(f=t,i=Fo(),i!==null){for(e=[],d=t,l=le(),l!==null?(u=gr(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);l!==null;)e.push(l),d=t,l=le(),l!==null?(u=gr(),u!==null?l=[l,u]:(l=null,t=d)):(l=null,t=d);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Fo(){var i,e,l,u,f,d;return u=t,f=t,i=rt(),i!==null?(d=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=rt(),l!==null?e=[e,l]:(e=null,t=d)):(e=null,t=d),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 gr(){var i;return i=Tr(),i===null&&(i=cl(),i===null&&(i=fl(),i===null&&(i=Je()))),i}function Tr(){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=G(),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(d,m){b.to_tag=m}(u,i[2])),i===null&&(t=u),i}function cl(){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=G(),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(d,m){b.from_tag=m}(u,i[2])),i===null&&(t=u),i}function fl(){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 jo(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 $u(){for(var i=1,e=1,l=!1,u=0;u<Math.max(t,n);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 Vo=fs(),Es=ka(),b={},w=a[o]();if(w===null||t!==r.length){var _l=Math.max(t,n),hl=_l<r.length?r.charAt(_l):null,qo=$u();return new this.SyntaxError(jo(p),hl,_l,qo.line,qo.column),-1}return b},toSource:function(){return this._source}};return s.SyntaxError=function(r,o,a,t,n){function p(_,h){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=h?c(h):"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=n},s.SyntaxError.prototype=Error.prototype,s}()),La}var $a,Ef;function fs(){if(Ef)return $a;Ef=1;const c=De,s=mt(),r=es();return $a=class D_{static parse(a){if(a=r.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,t,n,p,_={},h={}){if(!n)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=a||c.SIP,this._user=t,this._host=n,this._port=p;for(const g in _)Object.prototype.hasOwnProperty.call(_,g)&&this.setParam(g,_[g]);for(const g in h)Object.prototype.hasOwnProperty.call(h,g)&&this.setHeader(g,h[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[s.headerize(a)]=Array.isArray(t)?t:[t]}getHeader(a){if(a)return this._headers[s.headerize(a)]}hasHeader(a){if(a)return this._headers.hasOwnProperty(s.headerize(a))&&!0||!1}deleteHeader(a){if(a=s.headerize(a),this._headers.hasOwnProperty(a)){const t=this._headers[a];return delete this._headers[a],t}}clearHeaders(){this._headers={}}clone(){return new D_(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+=`${s.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const n in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=`;${n}`,this._parameters[n]!==null&&(t+=`=${this._parameters[n]}`));for(const n in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,n))for(const p of this._headers[n])a.push(`${n}=${p}`);return a.length>0&&(t+=`?${a.join("&")}`),t}toAor(a){let t=`${this._scheme}:`;return this._user&&(t+=`${s.escapeUser(this._user)}@`),t+=this._host,a&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},$a}var Sf;function mt(){if(Sf)return Ze;Sf=1;const c=De,s=fs(),r=es();Ze.str_utf8_length=n=>unescape(encodeURIComponent(n)).length;const o=Ze.isFunction=n=>n!==void 0?Object.prototype.toString.call(n)==="[object Function]":!1;Ze.isString=n=>n!==void 0?Object.prototype.toString.call(n)==="[object String]":!1,Ze.isDecimal=n=>!isNaN(n)&&parseFloat(n)===parseInt(n,10),Ze.isEmpty=n=>n===null||n===""||n===void 0||Array.isArray(n)&&n.length===0||typeof n=="number"&&isNaN(n),Ze.hasMethods=function(n,...p){for(const _ of p)if(o(n[_]))return!1;return!0};const a=Ze.createRandomToken=(n,p=32)=>{let _,h,g="";for(_=0;_<n;_++)h=Math.random()*p|0,g+=h.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=n=>{if(n){if(n=r.parse(n,"host"),n!==-1)return n.host_type}else return};const t=Ze.escapeUser=n=>encodeURIComponent(decodeURIComponent(n)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return Ze.normalizeTarget=(n,p)=>{if(n){if(n instanceof s)return n;if(typeof n=="string"){const _=n.split("@");let h,g;switch(_.length){case 1:if(!p)return;h=n,g=p;break;case 2:h=_[0],g=_[1];break;default:h=_.slice(0,_.length-1).join("@"),g=_[_.length-1]}h=h.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(h)&&(h=h.replace(/[-.()]/g,"")),n=`${c.SIP}:${t(h)}@${g}`;let T;return(T=s.parse(n))?T:void 0}else return}else return},Ze.headerize=n=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},_=n.toLowerCase().replace(/_/g,"-").split("-");let h="";const g=_.length;let T;for(T=0;T<g;T++)T!==0&&(h+="-"),h+=_[T].charAt(0).toUpperCase()+_[T].substring(1);return p[h]&&(h=p[h]),h},Ze.sipErrorCause=n=>{for(const p in c.SIP_ERROR_CAUSES)if(c.SIP_ERROR_CAUSES[p].indexOf(n)!==-1)return c.causes[p];return c.causes.SIP_FAILURE_CODE},Ze.getRandomTestNetIP=()=>{function n(p,_){return Math.floor(Math.random()*(_-p+1)+p)}return`192.0.2.${n(1,254)}`},Ze.calculateMD5=n=>{function p(Ee,Ae){return Ee<<Ae|Ee>>>32-Ae}function _(Ee,Ae){const Ie=Ee&2147483648,Oe=Ae&2147483648,pe=Ee&1073741824,he=Ae&1073741824,de=(Ee&1073741823)+(Ae&1073741823);return pe&he?de^2147483648^Ie^Oe:pe|he?de&1073741824?de^3221225472^Ie^Oe:de^1073741824^Ie^Oe:de^Ie^Oe}function h(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,he,de){return Ee=_(Ee,_(_(h(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function A(Ee,Ae,Ie,Oe,pe,he,de){return Ee=_(Ee,_(_(g(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function C(Ee,Ae,Ie,Oe,pe,he,de){return Ee=_(Ee,_(_(T(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function I(Ee,Ae,Ie,Oe,pe,he,de){return Ee=_(Ee,_(_(E(Ae,Ie,Oe),pe),de)),_(p(Ee,he),Ae)}function $(Ee){let Ae;const Ie=Ee.length,Oe=Ie+8,he=((Oe-Oe%64)/64+1)*16,de=new Array(he-1);let we=0,Ne=0;for(;Ne<Ie;)Ae=(Ne-Ne%4)/4,we=Ne%4*8,de[Ae]=de[Ae]|Ee.charCodeAt(Ne)<<we,Ne++;return Ae=(Ne-Ne%4)/4,we=Ne%4*8,de[Ae]=de[Ae]|128<<we,de[he-2]=Ie<<3,de[he-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,B,q,J,H;const Z=7,U=12,P=17,se=22,rt=5,ee=9,Y=14,G=20,re=4,ge=11,be=16,xe=23,Re=6,le=10,ye=15,it=21;for(n=ae(n),N=$(n),B=1732584193,q=4023233417,J=2562383102,H=271733878,F=0;F<N.length;F+=16)Se=B,ve=q,M=J,D=H,B=y(B,q,J,H,N[F+0],Z,3614090360),H=y(H,B,q,J,N[F+1],U,3905402710),J=y(J,H,B,q,N[F+2],P,606105819),q=y(q,J,H,B,N[F+3],se,3250441966),B=y(B,q,J,H,N[F+4],Z,4118548399),H=y(H,B,q,J,N[F+5],U,1200080426),J=y(J,H,B,q,N[F+6],P,2821735955),q=y(q,J,H,B,N[F+7],se,4249261313),B=y(B,q,J,H,N[F+8],Z,1770035416),H=y(H,B,q,J,N[F+9],U,2336552879),J=y(J,H,B,q,N[F+10],P,4294925233),q=y(q,J,H,B,N[F+11],se,2304563134),B=y(B,q,J,H,N[F+12],Z,1804603682),H=y(H,B,q,J,N[F+13],U,4254626195),J=y(J,H,B,q,N[F+14],P,2792965006),q=y(q,J,H,B,N[F+15],se,1236535329),B=A(B,q,J,H,N[F+1],rt,4129170786),H=A(H,B,q,J,N[F+6],ee,3225465664),J=A(J,H,B,q,N[F+11],Y,643717713),q=A(q,J,H,B,N[F+0],G,3921069994),B=A(B,q,J,H,N[F+5],rt,3593408605),H=A(H,B,q,J,N[F+10],ee,38016083),J=A(J,H,B,q,N[F+15],Y,3634488961),q=A(q,J,H,B,N[F+4],G,3889429448),B=A(B,q,J,H,N[F+9],rt,568446438),H=A(H,B,q,J,N[F+14],ee,3275163606),J=A(J,H,B,q,N[F+3],Y,4107603335),q=A(q,J,H,B,N[F+8],G,1163531501),B=A(B,q,J,H,N[F+13],rt,2850285829),H=A(H,B,q,J,N[F+2],ee,4243563512),J=A(J,H,B,q,N[F+7],Y,1735328473),q=A(q,J,H,B,N[F+12],G,2368359562),B=C(B,q,J,H,N[F+5],re,4294588738),H=C(H,B,q,J,N[F+8],ge,2272392833),J=C(J,H,B,q,N[F+11],be,1839030562),q=C(q,J,H,B,N[F+14],xe,4259657740),B=C(B,q,J,H,N[F+1],re,2763975236),H=C(H,B,q,J,N[F+4],ge,1272893353),J=C(J,H,B,q,N[F+7],be,4139469664),q=C(q,J,H,B,N[F+10],xe,3200236656),B=C(B,q,J,H,N[F+13],re,681279174),H=C(H,B,q,J,N[F+0],ge,3936430074),J=C(J,H,B,q,N[F+3],be,3572445317),q=C(q,J,H,B,N[F+6],xe,76029189),B=C(B,q,J,H,N[F+9],re,3654602809),H=C(H,B,q,J,N[F+12],ge,3873151461),J=C(J,H,B,q,N[F+15],be,530742520),q=C(q,J,H,B,N[F+2],xe,3299628645),B=I(B,q,J,H,N[F+0],Re,4096336452),H=I(H,B,q,J,N[F+7],le,1126891415),J=I(J,H,B,q,N[F+14],ye,2878612391),q=I(q,J,H,B,N[F+5],it,4237533241),B=I(B,q,J,H,N[F+12],Re,1700485571),H=I(H,B,q,J,N[F+3],le,2399980690),J=I(J,H,B,q,N[F+10],ye,4293915773),q=I(q,J,H,B,N[F+1],it,2240044497),B=I(B,q,J,H,N[F+8],Re,1873313359),H=I(H,B,q,J,N[F+15],le,4264355552),J=I(J,H,B,q,N[F+6],ye,2734768916),q=I(q,J,H,B,N[F+13],it,1309151649),B=I(B,q,J,H,N[F+4],Re,4149444226),H=I(H,B,q,J,N[F+11],le,3174756917),J=I(J,H,B,q,N[F+2],ye,718787259),q=I(q,J,H,B,N[F+9],it,3951481745),B=_(B,Se),q=_(q,ve),J=_(J,M),H=_(H,D);return(L(B)+L(q)+L(J)+L(H)).toLowerCase()},Ze.closeMediaStream=n=>{if(n)try{let p;if(n.getTracks){p=n.getTracks();for(const _ of p)_.stop()}else{p=n.getAudioTracks();for(const _ of p)_.stop();p=n.getVideoTracks();for(const _ of p)_.stop()}}catch{(typeof n.stop=="function"||typeof n.stop=="object")&&n.stop()}},Ze.cloneArray=n=>n&&n.slice()||[],Ze.cloneObject=(n,p={})=>n&&Object.assign({},n)||p,Ze}const yf=Dt,mm=lt,gt=De,nt=mt(),Af=ka(),gm=es(),Ha=new mm("SIPMessage");class Zl{constructor(s,r,o,a,t,n){if(!s||!r||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=s,this.ruri=r,this.body=n,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",gt.MAX_FORWARDS);const p=a.to_uri||r,_=a.to_tag?{tag:a.to_tag}:null,h=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Af(p,h,_),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 Af(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} ${s}`)}setHeader(s,r){const o=new RegExp(`^\\s*${s}\\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(s)]=Array.isArray(r)?r:[r]}getHeader(s){const r=this.headers[nt.headerize(s)];if(r){if(r[0])return r[0]}else{const o=new RegExp(`^\\s*${s}\\s*:`,"i");for(const a of this.extraHeaders)if(o.test(a))return a.substring(a.indexOf(":")+1).trim()}}getHeaders(s){const r=this.headers[nt.headerize(s)],o=[];if(r){for(const a of r)o.push(a);return o}else{const a=new RegExp(`^\\s*${s}\\s*:`,"i");for(const t of this.extraHeaders)a.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(s){if(this.headers[nt.headerize(s)])return!0;{const r=new RegExp(`^\\s*${s}\\s*:`,"i");for(const o of this.extraHeaders)if(r.test(o))return!0}return!1}parseSDP(s){return!s&&this.sdp?this.sdp:(this.sdp=yf.parse(this.body||""),this.sdp)}toString(){let s=`${this.method} ${this.ruri} SIP/2.0\r
|
76
76
|
`;for(const a in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,a))for(const t of this.headers[a])s+=`${a}: ${t}\r
|
77
77
|
`;for(const a of this.extraHeaders)s+=`${a.trim()}\r
|
78
78
|
`;const r=[];switch(this.method){case gt.REGISTER:r.push("path","gruu");break;case gt.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 gt.UPDATE:this.ua.configuration.session_timers&&r.push("timer"),r.push("ice");break}r.push("outbound");const o=this.ua.configuration.user_agent||gt.USER_AGENT;if(s+=`Allow: ${gt.ALLOWED_METHODS}\r
|
@@ -82,25 +82,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
82
82
|
\r
|
83
83
|
`,s+=this.body}else s+=`Content-Length: 0\r
|
84
84
|
\r
|
85
|
-
`;return s}clone(){const s=new Zl(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(r){s.headers[r]=this.headers[r].slice()},this),s.body=this.body,s.extraHeaders=nt.cloneArray(this.extraHeaders),s.to=this.to,s.from=this.from,s.call_id=this.call_id,s.cseq=this.cseq,s}}class Fa extends Zl{constructor(s,r,o,a,t){super(gt.INVITE,s,r,o,a,t),this.transaction=null}cancel(s){this.transaction.cancel(s)}clone(){const s=new Fa(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(r){s.headers[r]=this.headers[r].slice()},this),s.body=this.body,s.extraHeaders=nt.cloneArray(this.extraHeaders),s.to=this.to,s.from=this.from,s.call_id=this.call_id,s.cseq=this.cseq,s.transaction=this.transaction,s}}class Cf{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(s,r){const o={raw:r};s=nt.headerize(s),this.headers[s]?this.headers[s].push(o):this.headers[s]=[o]}getHeader(s){const r=this.headers[nt.headerize(s)];if(r){if(r[0])return r[0].raw}else return}getHeaders(s){const r=this.headers[nt.headerize(s)],o=[];if(!r)return[];for(const a of r)o.push(a.raw);return o}hasHeader(s){return!!this.headers[nt.headerize(s)]}parseHeader(s,r=0){if(s=nt.headerize(s),this.headers[s]){if(r>=this.headers[s].length){Ha.debug(`not so many "${s}" headers present`);return}}else{Ha.debug(`header "${s}" not present`);return}const o=this.headers[s][r],a=o.raw;if(o.parsed)return o.parsed;const t=
|
86
|
-
`;if(this.method===gt.INVITE&&s>100&&s<=200){const T=this.getHeaders("record-route");for(const E of T)
|
87
|
-
`}const g=this.getHeaders("via");for(const T of g)
|
88
|
-
`;!this.to_tag&&s>100?_+=`;tag=${nt.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(_+=`;tag=${this.to_tag}`),
|
89
|
-
`,
|
90
|
-
`,
|
91
|
-
`,
|
92
|
-
`;for(const T of o)
|
93
|
-
`;switch(this.method){case gt.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 gt.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),a&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===gt.OPTIONS?(
|
94
|
-
`,
|
95
|
-
`):s===405?
|
96
|
-
`:s===415&&(
|
97
|
-
`),
|
98
|
-
`,a){const T=nt.str_utf8_length(a);
|
99
|
-
`,
|
85
|
+
`;return s}clone(){const s=new Zl(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(r){s.headers[r]=this.headers[r].slice()},this),s.body=this.body,s.extraHeaders=nt.cloneArray(this.extraHeaders),s.to=this.to,s.from=this.from,s.call_id=this.call_id,s.cseq=this.cseq,s}}class Fa extends Zl{constructor(s,r,o,a,t){super(gt.INVITE,s,r,o,a,t),this.transaction=null}cancel(s){this.transaction.cancel(s)}clone(){const s=new Fa(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(r){s.headers[r]=this.headers[r].slice()},this),s.body=this.body,s.extraHeaders=nt.cloneArray(this.extraHeaders),s.to=this.to,s.from=this.from,s.call_id=this.call_id,s.cseq=this.cseq,s.transaction=this.transaction,s}}class Cf{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(s,r){const o={raw:r};s=nt.headerize(s),this.headers[s]?this.headers[s].push(o):this.headers[s]=[o]}getHeader(s){const r=this.headers[nt.headerize(s)];if(r){if(r[0])return r[0].raw}else return}getHeaders(s){const r=this.headers[nt.headerize(s)],o=[];if(!r)return[];for(const a of r)o.push(a.raw);return o}hasHeader(s){return!!this.headers[nt.headerize(s)]}parseHeader(s,r=0){if(s=nt.headerize(s),this.headers[s]){if(r>=this.headers[s].length){Ha.debug(`not so many "${s}" headers present`);return}}else{Ha.debug(`header "${s}" not present`);return}const o=this.headers[s][r],a=o.raw;if(o.parsed)return o.parsed;const t=gm.parse(a,s.replace(/-/g,"_"));if(t===-1){this.headers[s].splice(r,1),Ha.debug(`error parsing "${s}" header field with value "${a}"`);return}else return o.parsed=t,t}s(s,r){return this.parseHeader(s,r)}setHeader(s,r){const o={raw:r};this.headers[nt.headerize(s)]=[o]}parseSDP(s){return!s&&this.sdp?this.sdp:(this.sdp=yf.parse(this.body||""),this.sdp)}toString(){return this.data}}class Tm extends Cf{constructor(s){super(),this.ua=s,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(s,r,o,a,t,n){const p=[];let _=this.getHeader("To");if(s=s||null,r=r||null,!s||s<100||s>699)throw new TypeError(`Invalid status_code: ${s}`);if(r&&typeof r!="string"&&!(r instanceof String))throw new TypeError(`Invalid reason_phrase: ${r}`);r=r||gt.REASON_PHRASE[s]||"",o=nt.cloneArray(o),this.ua.configuration.extra_headers&&(o=o.concat(this.ua.configuration.extra_headers));let h=`SIP/2.0 ${s} ${r}\r
|
86
|
+
`;if(this.method===gt.INVITE&&s>100&&s<=200){const T=this.getHeaders("record-route");for(const E of T)h+=`Record-Route: ${E}\r
|
87
|
+
`}const g=this.getHeaders("via");for(const T of g)h+=`Via: ${T}\r
|
88
|
+
`;!this.to_tag&&s>100?_+=`;tag=${nt.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(_+=`;tag=${this.to_tag}`),h+=`To: ${_}\r
|
89
|
+
`,h+=`From: ${this.getHeader("From")}\r
|
90
|
+
`,h+=`Call-ID: ${this.call_id}\r
|
91
|
+
`,h+=`CSeq: ${this.cseq} ${this.method}\r
|
92
|
+
`;for(const T of o)h+=`${T.trim()}\r
|
93
|
+
`;switch(this.method){case gt.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 gt.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),a&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===gt.OPTIONS?(h+=`Allow: ${gt.ALLOWED_METHODS}\r
|
94
|
+
`,h+=`Accept: ${gt.ACCEPTED_BODY_TYPES}\r
|
95
|
+
`):s===405?h+=`Allow: ${gt.ALLOWED_METHODS}\r
|
96
|
+
`:s===415&&(h+=`Accept: ${gt.ACCEPTED_BODY_TYPES}\r
|
97
|
+
`),h+=`Supported: ${p}\r
|
98
|
+
`,a){const T=nt.str_utf8_length(a);h+=`Content-Type: application/sdp\r
|
99
|
+
`,h+=`Content-Length: ${T}\r
|
100
100
|
\r
|
101
|
-
`,
|
101
|
+
`,h+=a}else h+=`Content-Length: 0\r
|
102
102
|
\r
|
103
|
-
`;this.server_transaction.receiveResponse(s,
|
103
|
+
`;this.server_transaction.receiveResponse(s,h,t,n)}reply_sl(s=null,r=null){const o=this.getHeaders("via");if(!s||s<100||s>699)throw new TypeError(`Invalid status_code: ${s}`);if(r&&typeof r!="string"&&!(r instanceof String))throw new TypeError(`Invalid reason_phrase: ${r}`);r=r||gt.REASON_PHRASE[s]||"";let a=`SIP/2.0 ${s} ${r}\r
|
104
104
|
`;for(const n of o)a+=`Via: ${n}\r
|
105
105
|
`;let t=this.getHeader("To");if(!this.to_tag&&s>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
|
@@ -109,10 +109,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
109
109
|
`,this.ua.configuration.extra_headers)for(const n of this.ua.configuration.extra_headers)a+=`${n.trim()}\r
|
110
110
|
`;a+=`Content-Length: 0\r
|
111
111
|
\r
|
112
|
-
`,this.transport.send(a)}}class Em extends Cf{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var Ut={OutgoingRequest:Zl,InitialOutgoingInviteRequest:Fa,IncomingRequest:vm,IncomingResponse:Em};const eo=ke(Ut),Sm=lt,_s=mt(),Wt=new Sm("DigestAuthentication");var Rf=class{constructor(s){this._credentials=s,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(s){switch(s){case"realm":return this._realm;case"ha1":return this._ha1;default:Wt.warn('get() | cannot get "%s" parameter',s);return}}authenticate({method:s,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=s,this._uri=r,this._cnonce=t||_s.createRandomToken(12),this._nc+=1;const n=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-n.length)+n,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 s=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return s.push(`algorithm=${this._algorithm}`),s.push(`username="${this._credentials.username}"`),s.push(`realm="${this._realm}"`),s.push(`nonce="${this._nonce}"`),s.push(`uri="${this._uri}"`),s.push(`response="${this._response}"`),this._opaque&&s.push(`opaque="${this._opaque}"`),this._qop&&(s.push(`qop=${this._qop}`),s.push(`cnonce="${this._cnonce}"`),s.push(`nc=${this._ncHex}`)),`Digest ${s.join(", ")}`}};const ym=ke(Rf),hs=500,Am=4e3,If=5e3;var ja={T1:hs,T2:Am,T4:If,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*If,TIMER_L:64*hs,TIMER_M:64*hs,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Fr=ke(ja),jr=ut.EventEmitter,Vr=lt,qr=De,bf=Ut,ts=ja,wf=new Vr("NonInviteClientTransaction"),to=new Vr("InviteClientTransaction"),Cm=new Vr("AckClientTransaction"),Of=new Vr("NonInviteServerTransaction"),so=new Vr("InviteServerTransaction"),fe={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 Rm extends jr{constructor(s,r,o,a){super(),this.type=fe.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=s,this.transport=r,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${r.via_transport}`;t+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(fe.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},ts.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){wf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){wf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(s){const r=s.status_code;if(r<200)switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break}else switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),clearTimeout(this.F),r===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(s),this.K=setTimeout(()=>{this.timer_K()},ts.TIMER_K);break;case fe.STATUS_COMPLETED:break}}}class Im extends jr{constructor(s,r,o,a){super(),this.type=fe.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=s,this.transport=r,this.request=o,this.eventHandlers=a,o.transaction=this;let t=`SIP/2.0/${r.via_transport}`;t+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(fe.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},ts.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==fe.STATUS_ACCEPTED&&(to.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){to.debug(`Timer M expired for transaction ${this.id}`),this.state===fe.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){to.debug(`Timer B expired for transaction ${this.id}`),this.state===fe.STATUS_CALLING&&(this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){to.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(s){const r=new bf.OutgoingRequest(qr.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",s.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},ts.TIMER_D),this.transport.send(r)}cancel(s){if(this.state!==fe.STATUS_PROCEEDING)return;const r=new bf.OutgoingRequest(qr.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")),s&&r.setHeader("reason",s),this.transport.send(r)}receiveResponse(s){const r=s.status_code;if(r>=100&&r<=199)switch(this.state){case fe.STATUS_CALLING:this.stateChanged(fe.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(s);break}else if(r>=200&&r<=299)switch(this.state){case fe.STATUS_CALLING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},ts.TIMER_M),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(s);break}else if(r>=300&&r<=699)switch(this.state){case fe.STATUS_CALLING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),this.sendACK(s),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_COMPLETED:this.sendACK(s);break}}}class bm extends jr{constructor(s,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+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return fe}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Cm.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class wm extends jr{constructor(s,r,o){super(),this.type=fe.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=s,this.transport=r,this.request=o,this.last_response="",o.server_transaction=this,this.state=fe.STATUS_TRYING,s.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_J(){Of.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,Of.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(s,r,o,a){if(s===100)switch(this.state){case fe.STATUS_TRYING:this.stateChanged(fe.STATUS_PROCEEDING),this.transport.send(r)||this.onTransportError();break;case fe.STATUS_PROCEEDING:this.last_response=r,this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(s>=200&&s<=699)switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),this.last_response=r,this.J=setTimeout(()=>{this.timer_J()},ts.TIMER_J),this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break;case fe.STATUS_COMPLETED:break}}}class Om extends jr{constructor(s,r,o){super(),this.type=fe.INVITE_SERVER,this.id=o.via_branch,this.ua=s,this.transport=r,this.request=o,this.last_response="",o.server_transaction=this,this.state=fe.STATUS_PROCEEDING,s.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_H(){so.debug(`Timer H expired for transaction ${this.id}`),this.state===fe.STATUS_COMPLETED&&so.debug("ACK not received, dialog will be terminated"),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){so.debug(`Timer L expired for transaction ${this.id}`),this.state===fe.STATUS_ACCEPTED&&(this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,so.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(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(s,r,o,a){if(s>=100&&s<=199)switch(this.state){case fe.STATUS_PROCEEDING:this.transport.send(r)||this.onTransportError(),this.last_response=r;break}if(s>100&&s<=199&&this.state===fe.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},ts.PROVISIONAL_RESPONSE_INTERVAL));else if(s>=200&&s<=299)switch(this.state){case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_ACCEPTED),this.last_response=r,this.L=setTimeout(()=>{this.timer_L()},ts.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case fe.STATUS_ACCEPTED:this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(s>=300&&s<=699)switch(this.state){case fe.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(r)?(this.stateChanged(fe.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},ts.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function Dm({_transactions:c},s){let r;switch(s.method){case qr.INVITE:if(r=c.ist[s.via_branch],r){switch(r.state){case fe.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case fe.STATUS_ACCEPTED:break}return!0}break;case qr.ACK:if(r=c.ist[s.via_branch],r){if(r.state===fe.STATUS_ACCEPTED)return!1;if(r.state===fe.STATUS_COMPLETED)return r.state=fe.STATUS_CONFIRMED,r.I=setTimeout(()=>{r.timer_I()},ts.TIMER_I),!0}else return!1;break;case qr.CANCEL:return r=c.ist[s.via_branch],r?(s.reply_sl(200),r.state!==fe.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(r=c.nist[s.via_branch],r){switch(r.state){case fe.STATUS_TRYING:break;case fe.STATUS_PROCEEDING:case fe.STATUS_COMPLETED:r.transport.send(r.last_response);break}return!0}break}}var xn={C:fe,NonInviteClientTransaction:Rm,InviteClientTransaction:Im,AckClientTransaction:bm,NonInviteServerTransaction:wm,InviteServerTransaction:Om,checkTransaction:Dm};const $t=ke(xn),Nm=lt,Df=De,Um=Rf,Va=xn,Pm=new Nm("RequestSender"),qa={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var Mn=class{constructor(s,r,o){this._ua=s,this._eventHandlers=o,this._method=r.method,this._request=r,this._auth=null,this._challenged=!1,this._staled=!1;for(const a in qa)Object.prototype.hasOwnProperty.call(qa,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=qa[a]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==Df.BYE||this._method!==Df.ACK)&&this._eventHandlers.onTransportError()}send(){const s={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:r=>{this._receiveResponse(r)}};switch(this._method){case"INVITE":this.clientTransaction=new Va.InviteClientTransaction(this._ua,this._ua.transport,this._request,s);break;case"ACK":this.clientTransaction=new Va.AckClientTransaction(this._ua,this._ua.transport,this._request,s);break;default:this.clientTransaction=new Va.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,s)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(s){let r,o;const a=s.status_code;if((a===401||a===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(s.status_code===401?(r=s.parseHeader("www-authenticate"),o="authorization"):(r=s.parseHeader("proxy-authenticate"),o="proxy-authorization"),!r){Pm.debug(`${s.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(s);return}if(!this._challenged||!this._staled&&r.stale===!0){if(this._auth||(this._auth=new Um({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(s);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(s)}else this._eventHandlers.onReceiveResponse(s)}};const Nf=ke(Mn),xm=lt,Ba=mt(),Xs=De,Uf=Ut,Pf=Mn,Br=new xm("Registrator"),no=10;var Mm=class{constructor(s,r){this._reg_id=1,this._ua=s,this._transport=r,this._registrar=s.configuration.registrar_server,this._expires=s.configuration.register_expires,this._call_id=Ba.createRandomToken(22),this._cseq=0,this._to_uri=s.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(s){Array.isArray(s)||(s=[]),this._extraHeaders=s.slice()}setExtraContactParams(s){s instanceof Object||(s={}),this._extraContactParams="";for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const o=s[r];this._extraContactParams+=`;${r}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Br.debug("Register request in progress...");return}const s=this._extraHeaders.slice();s.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),s.push(`Expires: ${this._expires}`);const r=new Uf.OutgoingRequest(Xs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s),o=new Pf(this._ua,r,{onRequestTimeout:()=>{this._registrationFailure(null,Xs.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,Xs.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")){Br.debug("no Contact header in response to REGISTER, response ignored");break}const t=a.headers.Contact.reduce((d,g)=>d.concat(g.parsed),[]);let n=t.find(d=>this._sipInstance===d.getParam("+sip.instance")&&this._reg_id===parseInt(d.getParam("reg-id")));if(n||(n=t.find(d=>d.uri.user===this._ua.contact.uri.user)),!n){Br.debug("no Contact header pointing to us, response ignored");break}let p=n.getParam("expires");!p&&a.hasHeader("expires")&&(p=a.getHeader("expires")),p||(p=this._expires),p=Number(p),p<no&&(p=no);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")},_),n.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=n.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<no&&(this._expires=no),this.register()):(Br.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,Xs.causes.SIP_FAILURE_CODE));break}default:{const t=Ba.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(s={}){if(!this._registered){Br.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const r=this._extraHeaders.slice();s.all?r.push(`Contact: *${this._extraContactParams}`):r.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),r.push("Expires: 0");const o=new Uf.OutgoingRequest(Xs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r);new Pf(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,Xs.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,Xs.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 n=Ba.sipErrorCause(t.status_code);this._unregistered(t,n)}}}}).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(s,r){this._registering=!1,this._ua.registrationFailed({response:s||null,cause:r}),this._registered&&(this._registered=!1,this._ua.unregistered({response:s||null,cause:r}))}_unregistered(s,r){this._registering=!1,this._registered=!1,this._ua.unregistered({response:s||null,cause:r||null})}};class km extends Error{constructor(s,r){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=s,this.value=r,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class Lm extends Error{constructor(s){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=s,this.message=`Invalid status: ${s}`}}class $m extends Error{constructor(s){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=s}}class Hm extends Error{constructor(s){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=s}}var ds={ConfigurationError:km,InvalidStateError:Lm,NotSupportedError:$m,NotReadyError:Hm};const Is=ke(ds),Ga=De,ro=xn,Fm=Mn,Wa={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var xf=class{constructor(s,r,o){this._dialog=s,this._ua=s._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 s=new Fm(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:r=>{this._eventHandlers.onAuthenticated(r)},onReceiveResponse:r=>{this._receiveResponse(r)}});if(s.send(),(this._request.method===Ga.INVITE||this._request.method===Ga.UPDATE&&this._request.body)&&s.clientTransaction.state!==ro.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const r=()=>{(s.clientTransaction.state===ro.C.STATUS_ACCEPTED||s.clientTransaction.state===ro.C.STATUS_COMPLETED||s.clientTransaction.state===ro.C.STATUS_TERMINATED)&&(s.clientTransaction.removeListener("stateChanged",r),this._dialog.uac_pending_reply=!1)};s.clientTransaction.on("stateChanged",r)}}_receiveResponse(s){s.status_code===408||s.status_code===481?this._eventHandlers.onDialogError(s):s.method===Ga.INVITE&&s.status_code===491?this._reattempt?s.status_code>=200&&s.status_code<300?this._eventHandlers.onSuccessResponse(s):s.status_code>=300&&this._eventHandlers.onErrorResponse(s):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):s.status_code>=200&&s.status_code<300?this._eventHandlers.onSuccessResponse(s):s.status_code>=300&&this._eventHandlers.onErrorResponse(s)}};const jm=ke(xf),Vm=lt,Mf=Ut,bs=De,Gr=xn,qm=xf,Ka=mt(),Ya=new Vm("Dialog"),ws={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var kf=class{static get C(){return ws}constructor(s,r,o,a=ws.STATUS_CONFIRMED){if(this._owner=s,this._ua=s._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 Mf.IncomingResponse&&(a=r.status_code<200?ws.STATUS_EARLY:ws.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),Ya.debug(`new ${o} dialog created with status ${this._state===ws.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(s){this._local_seqnum=s}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(s){this._uac_pending_reply=s}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===ws.STATUS_TERMINATED}update(s,r){this._state=ws.STATUS_CONFIRMED,Ya.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){Ya.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=ws.STATUS_TERMINATED}sendRequest(s,r={}){const o=Ka.cloneArray(r.extraHeaders),a=Ka.cloneObject(r.eventHandlers),t=r.body||null,n=this._createRequest(s,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new qm(this,n,a).send(),n}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===bs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===bs.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,r,o){r=Ka.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===bs.CANCEL||s===bs.ACK?this._local_seqnum:this._local_seqnum+=1;return new Mf.OutgoingRequest(s,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(s){if(!this._remote_seqnum)this._remote_seqnum=s.cseq;else if(s.cseq<this._remote_seqnum)if(s.method===bs.ACK){if(this._ack_seqnum===null||s.cseq!==this._ack_seqnum)return!1}else return s.reply(500),!1;else s.cseq>this._remote_seqnum&&(this._remote_seqnum=s.cseq);if(s.method===bs.INVITE||s.method===bs.UPDATE&&s.body){if(this._uac_pending_reply===!0)s.reply(491);else if(this._uas_pending_reply===!0){const r=(Math.random()*10|0)+1;return s.reply(500,null,[`Retry-After:${r}`]),!1}else{this._uas_pending_reply=!0;const r=()=>{(s.server_transaction.state===Gr.C.STATUS_ACCEPTED||s.server_transaction.state===Gr.C.STATUS_COMPLETED||s.server_transaction.state===Gr.C.STATUS_TERMINATED)&&(s.server_transaction.removeListener("stateChanged",r),this._uas_pending_reply=!1)};s.server_transaction.on("stateChanged",r)}s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Gr.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===bs.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Gr.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}};const io=ke(kf);var za={exports:{}};const Bm=ut.EventEmitter,Gm=lt,Wm=De,Km=ds,Lf=mt(),Ym=new Gm("RTCSession:DTMF"),$f={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};za.exports=class extends Bm{constructor(s){super(),this._session=s,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(s,r={}){if(s===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 Km.InvalidStateError(this._session.status);const o=Lf.cloneArray(r.extraHeaders);if(this.eventHandlers=Lf.cloneObject(r.eventHandlers),typeof s=="string")s=s.toUpperCase();else if(typeof s=="number")s=s.toString();else throw new TypeError(`Invalid tone: ${s}`);if(s.match(/^[0-9A-DR#*]$/))this._tone=s;else throw new TypeError(`Invalid tone: ${s}`);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(
|
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=$f.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:s}):
|
115
|
-
`,1)[0],"Status_Line");if(r===-1){Qs.debug(`receiveNotify() | error parsing NOTIFY body: "${s.body}"`);return}switch(!0){case/^100$/.test(r.status_code):this.emit("trying",{request:s,status_line:r});break;case/^1[0-9]{2}$/.test(r.status_code):this.emit("progress",{request:s,status_line:r});break;case/^2[0-9]{2}$/.test(r.status_code):this.emit("accepted",{request:s,status_line:r});break;default:this.emit("failed",{request:s,status_line:r});break}}_requestSucceeded(s){Qs.debug("REFER succeeded"),Qs.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:s})}_requestFailed(s,r){Qs.debug("REFER failed"),Qs.debug('emit "requestFailed"'),this.emit("requestFailed",{response:s||null,cause:r})}};const lg=ke(Bf),og=ut.EventEmitter,Gf=Dt,ag=lt,_e=De,Zs=ds,Wf=xn,Ge=mt(),Kr=ja,ug=Ut,lo=kf,cg=Mn,Mt=Hf,Kf=Ff,fg=Vf,_g=Bf,Yf=fs(),K=new ag("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},oo=["audio","video"];var zf=class Hu extends og{static get C(){return Q}constructor(s){K.debug("new"),super(),this._id=null,this._ua=s,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:_e.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return Q}get causes(){return _e.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(s){this._data=s}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(s,r={},o){K.debug("connect()");const a=s,t=Ge.cloneObject(r.eventHandlers),n=Ge.cloneArray(r.extraHeaders),p=Ge.cloneObject(r.mediaConstraints,{audio:!0,video:!0}),_=r.mediaStream||null,d=Ge.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,s===void 0)throw new TypeError("Not enough arguments");if(this._status!==Q.STATUS_NULL)throw new Zs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Zs.NotSupportedError("WebRTC not supported");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&Ge.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=_e.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=_e.SESSION_EXPIRES);for(const A in t)Object.prototype.hasOwnProperty.call(t,A)&&this.on(A,t[A]);this._from_tag=Ge.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 Yf("sip","anonymous","anonymous.invalid"),n.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),n.push("Privacy: id")):r.fromUserName&&(y.from_uri=new Yf("sip",r.fromUserName,this._ua.configuration.uri.host),n.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),r.fromDisplayName&&(y.from_display_name=r.fromDisplayName),n.push(`Contact: ${this._contact}`),n.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&n.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new ug.InitialOutgoingInviteRequest(s,this._ua,y,n),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(s,r){K.debug("init_incoming()");let o;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=Q.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(o=s.getHeader("expires")*1e3),s.to_tag=Ge.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Q.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),this._failed("local",null,_e.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Q.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),this._failed("system",null,_e.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,r&&r(this),this._newRTCSession("remote",s),this._status!==Q.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(s={}){K.debug("answer()");const r=this._request,o=Ge.cloneArray(s.extraHeaders),a=Ge.cloneObject(s.mediaConstraints),t=s.mediaStream||null,n=Ge.cloneObject(s.pcConfig,{iceServers:[]}),p=s.rtcConstraints||null,_=s.rtcAnswerConstraints||null,d=Ge.cloneObject(s.rtcOfferConstraints);let g,T=!1,E=!1,y=!1,A=!1;if(this._rtcAnswerConstraints=_,this._rtcOfferConstraints=s.rtcOfferConstraints||null,this._data=s.data||this._data,this._direction!=="incoming")throw new Zs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==Q.STATUS_WAITING_FOR_ANSWER)throw new Zs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Ge.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=_e.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=_e.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 C=r.parseSDP();Array.isArray(C.media)||(C.media=[C.media]);for(const I of C.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(n,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,_e.causes.USER_DENIED_MEDIA_ACCESS),K.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};K.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,_e.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===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,_e.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==Q.STATUS_TERMINATED&&K.warn(I)})}terminate(s={}){K.debug("terminate()");const r=s.cause||_e.causes.BYE,o=Ge.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,p=s.reason_phrase;if(this._status===Q.STATUS_TERMINATED)throw new Zs.InvalidStateError(this._status);switch(this._status){case Q.STATUS_NULL:case Q.STATUS_INVITE_SENT:case Q.STATUS_1XX_RECEIVED:if(K.debug("canceling session"),n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(p=p||_e.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;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,_e.causes.CANCELED);break;case Q.STATUS_WAITING_FOR_ANSWER:case Q.STATUS_ANSWERED:if(K.debug("rejecting session"),n=n||480,n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._request.reply(n,p,o,a),this._failed("local",null,_e.causes.REJECTED);break;case Q.STATUS_WAITING_FOR_ACK:case Q.STATUS_CONFIRMED:if(K.debug("terminating session"),p=s.reason_phrase||_e.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${p}"`),this._status===Q.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Wf.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===_e.ACK&&(this.sendRequest(_e.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Wf.C.STATUS_TERMINATED&&(this.sendRequest(_e.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else this.sendRequest(_e.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendDTMF(s,r={}){K.debug("sendDTMF() | tones: %s",s);let o=0,a=r.duration||null,t=r.interToneGap||null;const n=r.transportType||_e.DTMF_TRANSPORT.INFO;if(s===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 Zs.InvalidStateError(this._status);if(n!==_e.DTMF_TRANSPORT.INFO&&n!==_e.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${n}`);if(typeof s=="number"&&(s=s.toString()),!s||typeof s!="string"||!s.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${s}`);if(a&&!Ge.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<Mt.C.MIN_DURATION?(K.debug(`"duration" value is lower than the minimum allowed, setting it to ${Mt.C.MIN_DURATION} milliseconds`),a=Mt.C.MIN_DURATION):a>Mt.C.MAX_DURATION?(K.debug(`"duration" value is greater than the maximum allowed, setting it to ${Mt.C.MAX_DURATION} milliseconds`),a=Mt.C.MAX_DURATION):a=Math.abs(a):a=Mt.C.DEFAULT_DURATION,r.duration=a,t&&!Ge.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<Mt.C.MIN_INTER_TONE_GAP?(K.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${Mt.C.MIN_INTER_TONE_GAP} milliseconds`),t=Mt.C.MIN_INTER_TONE_GAP):t=Math.abs(t):t=Mt.C.DEFAULT_INTER_TONE_GAP,n===_e.DTMF_TRANSPORT.RFC2833){const _=this._getDTMFRTPSender();_&&(s=_.toneBuffer+s,_.insertDTMF(s,a,t));return}if(this._tones){this._tones+=s;return}this._tones=s,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 Mt(this);r.eventHandlers={onFailed:()=>{this._tones=null}},g.send(d,r),_=a+t}setTimeout(p.bind(this),_)}}sendInfo(s,r,o={}){if(K.debug("sendInfo()"),this._status!==Q.STATUS_CONFIRMED&&this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_1XX_RECEIVED)throw new Zs.InvalidStateError(this._status);new Kf(this).send(s,r,o)}mute(s={audio:!0,video:!1}){K.debug("mute()");let r=!1,o=!1;this._audioMuted===!1&&s.audio&&(r=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&s.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(r===!0||o===!0)&&this._onmute({audio:r,video:o})}unmute(s={audio:!0,video:!0}){K.debug("unmute()");let r=!1,o=!1;this._audioMuted===!0&&s.audio&&(r=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&s.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(r===!0||o===!0)&&this._onunmute({audio:r,video:o})}hold(s={},r){if(K.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:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}unhold(s={},r){if(K.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:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}renegotiate(s={},r){K.debug("renegotiate()");const o=s.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:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}),!0}refer(s,r){K.debug("refer()");const o=s;if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${o}`);const a=new _g(this);a.sendRefer(s,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(s,r){return K.debug("sendRequest()"),this._dialog.sendRequest(s,r)}receiveRequest(s){if(K.debug("receiveRequest()"),s.method===_e.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",s,_e.causes.CANCELED));else switch(s.method){case _e.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(!s.body){this.terminate({cause:_e.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:s.body};K.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",s)}).catch(a=>{this.terminate({cause:_e.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",s);break;case _e.BYE:this._status===Q.STATUS_CONFIRMED||this._status===Q.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,_e.causes.BYE)):this._status===Q.STATUS_INVITE_RECEIVED||this._status===Q.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,_e.causes.BYE)):s.reply(403,"Wrong Status");break;case _e.INVITE:this._status===Q.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case _e.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=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;r&&r.match(/^application\/dtmf-relay/i)?new Mt(this).init_incoming(s):r!==void 0?new Kf(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case _e.UPDATE:this._status===Q.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case _e.REFER:this._status===Q.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case _e.NOTIFY:this._status===Q.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){K.warn("onTransportError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_e.causes.CONNECTION_ERROR,cause:_e.causes.CONNECTION_ERROR})}onRequestTimeout(){K.warn("onRequestTimeout()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:_e.causes.REQUEST_TIMEOUT,cause:_e.causes.REQUEST_TIMEOUT})}onDialogError(){K.warn("onDialogError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_e.causes.DIALOG_ERROR,cause:_e.causes.DIALOG_ERROR})}newDTMF(s){K.debug("newDTMF()"),this.emit("newDTMF",s)}newInfo(s){K.debug("newInfo()"),this.emit("newInfo",s)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(K.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(K.debug("_isReadyToReOffer() | session not established yet"),!1):(K.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),Ge.closeMediaStream(this._localMediaStream)),this._status!==Q.STATUS_TERMINATED){if(this._status=Q.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){K.warn("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(s,r){let o=Kr.T1;function a(){this._status===Q.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],r),o<Kr.T2&&(o=o*2,o>Kr.T2&&(o=Kr.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&&(K.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(_e.BYE),this._ended("remote",null,_e.causes.NO_ACK))},Kr.TIMER_H)}_createRTCConnection(s,r){this._connection=new RTCPeerConnection(s,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:_e.causes.RTP_TIMEOUT,status_code:408,reason_phrase:_e.causes.RTP_TIMEOUT})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(s,r){if(K.debug("createLocalDescription()"),s!=="offer"&&s!=="answer")throw new Error(`createLocalDescription() | invalid type "${s}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>s==="offer"?o.createOffer(r).catch(a=>(K.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(r).catch(a=>(K.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>o.setLocalDescription(a).catch(t=>(this._rtcReady=!0,K.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=r&&r.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:s,sdp:o.localDescription.sdp};return K.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let n=!1,p,_;this._iceReady=!1;const d=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",_),n=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:s,sdp:o.localDescription.sdp};K.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}):n||d()}),o.addEventListener("icegatheringstatechange",_=()=>{o.iceGatheringState==="complete"&&!n&&d()})})})}_createDialog(s,r,o){const a=r==="UAS"?s.to_tag:s.from_tag,t=r==="UAS"?s.from_tag:s.to_tag,n=s.call_id+a+t;let p=this._earlyDialogs[n];if(o)return p?!0:(p=new lo(this,s,r,lo.C.STATUS_EARLY),p.error?(K.debug(p.error),this._failed("remote",s,_e.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,r),this._dialog=p,delete this._earlyDialogs[n],!0;const _=new lo(this,s,r);return _.error?(K.debug(_.error),this._failed("remote",s,_e.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_receiveReinvite(s){K.debug("receiveReinvite()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,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=Ge.cloneArray(p.extraHeaders);if(this._status!==Q.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);s.reply(_,d,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!s.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=>{n.call(this,p)}).catch(()=>{s.reply(500)});return}if(r!=="application/sdp"){K.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==Q.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{K.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),this._late_sdp&&(p=this._mangleOffer(p)),s.reply(200,null,_,p,()=>{this._status=Q.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(s){K.debug("receiveUpdate()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,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=Ge.cloneArray(p.extraHeaders);if(this._status!==Q.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);s.reply(_,d,g)}if(this.emit("update",o),a)return;if(!s.body){n.call(this,null);return}if(r!=="application/sdp"){K.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==Q.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{K.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),s.reply(200,null,_,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(s){K.debug("_processInDialogSdpOffer()");const r=s.parseSDP();let o=!1;for(const n of r.media){if(oo.indexOf(n.type)===-1)continue;const p=n.direction||r.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:s.body};K.debug('emit "sdp"'),this.emit("sdp",a);const t=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===Q.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(n=>{throw s.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),this.emit("peerconnection:setremotedescriptionfailed",n),n})}).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(n=>{throw s.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',n),n})}).catch(n=>{K.warn("_processInDialogSdpOffer() failed [error: %o]",n)}),this._connectionPromiseQueue}_receiveRefer(s){if(K.debug("receiveRefer()"),!s.refer_to){K.debug("no Refer-To header field present in REFER"),s.reply(400);return}if(s.refer_to.uri.scheme!==_e.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const r=new fg(this,s.cseq);K.debug('emit "refer"'),this.emit("refer",{request:s,accept:(t,n)=>{o.call(this,t,n)},reject:()=>{a.call(this)}});function o(t,n={}){if(t=typeof t=="function"?t:null,this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;const p=new Hu(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)}),s.refer_to.uri.hasHeader("replaces")){const _=decodeURIComponent(s.refer_to.uri.getHeader("replaces"));n.extraHeaders=Ge.cloneArray(n.extraHeaders),n.extraHeaders.push(`Replaces: ${_}`)}p.connect(s.refer_to.uri.toAor(),n,t)}function a(){r.notify(603)}}_receiveNotify(s){switch(K.debug("receiveNotify()"),s.event||s.reply(400),s.event.event){case"refer":{let r,o;if(s.event.params&&s.event.params.id)r=s.event.params.id,o=this._referSubscribers[r];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{s.reply(400,"Missing event id parameter");return}if(!o){s.reply(481,"Subscription does not exist");return}o.receiveNotify(s),s.reply(200);break}default:s.reply(489)}}_receiveReplaces(s){K.debug("receiveReplaces()");function r(a){if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;const t=new Hu(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(s,a)}function o(){K.debug("Replaced INVITE rejected by the user"),s.reply(486)}this.emit("replaces",{request:s,accept:a=>{r.call(this,a)},reject:()=>{o.call(this)}})}_sendInitialRequest(s,r,o){const a=new cg(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(s.audio||s.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(s).catch(t=>{throw this._status===Q.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,_e.causes.USER_DENIED_MEDIA_ACCESS),K.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(n=>{this._connection.addTrack(n,t)}),this._connecting(this._request),this._createLocalDescription("offer",r).catch(n=>{throw this._failed("local",null,_e.causes.WEBRTC_ERROR),n})}).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,K.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==Q.STATUS_TERMINATED&&K.warn(t)})}_getDTMFRTPSender(){const s=this._connection.getSenders().find(r=>r.track&&r.track.kind==="audio");if(!(s&&s.dtmf)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return s.dtmf}_receiveInviteResponse(s){if(K.debug("receiveInviteResponse()"),this._dialog&&s.status_code>=200&&s.status_code<=299)if(this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.sendRequest(_e.ACK);return}else{const r=new lo(this,s,"UAC");if(r.error!==void 0){K.debug(r.error);return}this.sendRequest(_e.ACK),this.sendRequest(_e.BYE);return}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==Q.STATUS_INVITE_SENT&&this._status!==Q.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(s.status_code):this._status=Q.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){K.debug("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=Q.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const r={originator:"remote",type:"answer",sdp:s.body};K.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",s)).catch(a=>{K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(this._status=Q.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,_e.causes.MISSING_SDP),this._failed("remote",s,_e.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;const r={originator:"remote",type:"answer",sdp:s.body};K.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(s,500,a.toString()),this._failed("local",s,_e.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest(_e.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(s,488,"Not Acceptable Here"),this._failed("remote",s,_e.causes.BAD_MEDIA_DESCRIPTION),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const r=Ge.sipErrorCause(s.status_code);this._failed("remote",s,r)}}}_sendReinvite(s={}){K.debug("sendReinvite()");const r=Ge.cloneArray(s.extraHeaders),o=Ge.cloneObject(s.eventHandlers),a=s.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:_};K.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(_e.INVITE,{extraHeaders:r,body:_,eventHandlers:{onSuccessResponse:g=>{n.call(this,g),t=!0},onErrorResponse:g=>{p.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function n(_){if(this._status===Q.STATUS_TERMINATED||(this.sendRequest(_e.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};K.debug('emit "sdp"'),this.emit("sdp",d);const g=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(g)).then(()=>{o.succeeded&&o.succeeded(_)}).catch(T=>{p.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',T),this.emit("peerconnection:setremotedescriptionfailed",T)})}function p(_){o.failed&&o.failed(_)}}_sendUpdate(s={}){K.debug("sendUpdate()");const r=Ge.cloneArray(s.extraHeaders),o=Ge.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null,t=s.sdpOffer||!1;let n=!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};K.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(_e.UPDATE,{extraHeaders:r,body:d,eventHandlers:{onSuccessResponse:T=>{p.call(this,T),n=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(_e.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&&!n)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};K.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),K.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(s,r,o){K.debug("acceptAndTerminate()");const a=[];r&&(o=o||_e.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest(_e.ACK),this.sendRequest(_e.BYE,{extraHeaders:a})),this._status=Q.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=Gf.parse(s),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");for(const r of s.media)oo.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){K.debug("mangleOffer() | both on hold, mangling offer");for(const r of s.media)oo.indexOf(r.type)!==-1&&(r.direction="inactive")}else if(this._remoteHold){K.debug("mangleOffer() | remote on hold, mangling offer");for(const r of s.media)oo.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="recvonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="recvonly")}return Gf.write(s)}_setLocalMediaStatus(){let s=!0,r=!0;(this._localHold||this._remoteHold)&&(s=!1,r=!1),this._audioMuted&&(s=!1),this._videoMuted&&(r=!1),this._toggleMuteAudio(!s),this._toggleMuteVideo(!r)}_handleSessionTimersInIncomingRequest(s,r){if(!this._sessionTimers.enabled)return;let o;s.session_expires&&s.session_expires>=_e.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,o=s.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(s){if(!this._sessionTimers.enabled)return;let r;s.session_expires&&s.session_expires>=_e.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,r=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}_runSessionTimer(){const s=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()&&(K.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===_e.UPDATE?this._sendUpdate():this._sendReinvite())},s*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==Q.STATUS_TERMINATED&&(K.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:_e.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},s*1100)}_toggleMuteAudio(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of r)o.track.enabled=!s}_toggleMuteVideo(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of r)o.track.enabled=!s}_newRTCSession(s,r){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:s,session:this,request:r})}_connecting(s){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:s})}_progress(s,r){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:s,response:r||null})}_accepted(s,r){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:s,response:r||null})}_confirmed(s,r){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:r||null})}_ended(s,r,o){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:s,message:r||null,cause:o})}_failed(s,r,o){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:s,message:r||null,cause:o}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:s,message:r||null,cause:o})}_onhold(s){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:s})}_onunhold(s){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:s})}_onmute({audio:s,video:r}){K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:s,video:r})}_onunmute({audio:s,video:r}){K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:s,video:r})}};const hg=ke(zf),dg=ut.EventEmitter,pg=lt,Qa=De,mg=Ut,Yr=mt(),gg=Mn,Jf=ds,Tg=fs(),ao=new pg("Message");var vg=class extends dg{constructor(s){super(),this._ua=s,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(s,r,o={}){const a=s;if(s===void 0||r===void 0)throw new TypeError("Not enough arguments");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);const t=Yr.cloneArray(o.extraHeaders),n=Yr.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",_={};o.fromUserName&&(_.from_uri=new Tg("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 n)Object.prototype.hasOwnProperty.call(n,g)&&this.on(g,n[g]);t.push(`Content-Type: ${p}`),this._request=new mg.OutgoingRequest(Qa.MESSAGE,s,this._ua,_,t),r&&(this._request.body=r);const d=new gg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:g=>{this._receiveResponse(g)}});this._newMessage("local",this._request),d.send()}init_incoming(s){this._request=s,this._newMessage("remote",s),this._is_replied||(this._is_replied=!0,s.reply(200)),this._close()}accept(s={}){const r=Yr.cloneArray(s.extraHeaders),o=s.body;if(this._direction!=="incoming")throw new Jf.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(s={}){const r=s.status_code||480,o=s.reason_phrase,a=Yr.cloneArray(s.extraHeaders),t=s.body;if(this._direction!=="incoming")throw new Jf.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(s){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._succeeded("remote",s);break;default:{const r=Yr.sipErrorCause(s.status_code);this._failed("remote",s,r);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Qa.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Qa.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(s,r){s==="remote"?(this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from):s==="local"&&(this._direction="outgoing",this._local_identity=r.from,this._remote_identity=r.to),this._ua.newMessage(this,{originator:s,message:this,request:r})}_failed(s,r,o){ao.debug("MESSAGE failed"),this._close(),ao.debug('emit "failed"'),this.emit("failed",{originator:s,response:r||null,cause:o})}_succeeded(s,r){ao.debug("MESSAGE succeeded"),this._close(),ao.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:r})}};const Eg=ut.EventEmitter,Sg=lt,Za=De,yg=Ut,zr=mt(),Ag=Mn,Xf=ds,uo=new Sg("Options");var Cg=class extends Eg{constructor(s){super(),this._ua=s,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(s,r,o={}){const a=s;if(s===void 0)throw new TypeError("A target is required for OPTIONS");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);const t=zr.cloneArray(o.extraHeaders),n=zr.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const d in n)Object.prototype.hasOwnProperty.call(n,d)&&this.on(d,n[d]);t.push(`Content-Type: ${p}`),this._request=new yg.OutgoingRequest(Za.OPTIONS,s,this._ua,null,t),r&&(this._request.body=r);const _=new Ag(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:d=>{this._receiveResponse(d)}});this._newOptions("local",this._request),_.send()}init_incoming(s){this._request=s,this._newOptions("remote",s),this._is_replied||(this._is_replied=!0,s.reply(200)),this._close()}accept(s={}){const r=zr.cloneArray(s.extraHeaders),o=s.body;if(this._direction!=="incoming")throw new Xf.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(s={}){const r=s.status_code||480,o=s.reason_phrase,a=zr.cloneArray(s.extraHeaders),t=s.body;if(this._direction!=="incoming")throw new Xf.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(s){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._succeeded("remote",s);break;default:{const r=zr.sipErrorCause(s.status_code);this._failed("remote",s,r);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Za.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Za.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(s,r){s==="remote"?(this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from):s==="local"&&(this._direction="outgoing",this._local_identity=r.from,this._remote_identity=r.to),this._ua.newOptions(this,{originator:s,message:this,request:r})}_failed(s,r,o){uo.debug("OPTIONS failed"),this._close(),uo.debug('emit "failed"'),this.emit("failed",{originator:s,response:r||null,cause:o})}_succeeded(s,r){uo.debug("OPTIONS succeeded"),this._close(),uo.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:r})}},eu={};const Rg=lt,tu=mt(),Ig=es(),Jr=new Rg("Socket");eu.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return Jr.warn("undefined JsSIP.Socket instance"),!1;try{if(!tu.isString(c.url))throw Jr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!tu.isString(c.via_transport))throw Jr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Ig.parse(c.sip_uri,"SIP_URI")===-1)throw Jr.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(s=>{if(!tu.isFunction(c[s]))throw Jr.warn(`missing or invalid JsSIP.Socket method: ${s}`),new Error(`Missing or invalid JsSIP.Socket method: ${s}`)})}catch{return!1}return!0};const bg=lt,wg=eu,Qf=De,Pt=new bg("Transport"),Ht={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Qf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Qf.CONNECTION_RECOVERY_MAX_INTERVAL}};var Zf=class{constructor(s,r=Ht.recovery_options){Pt.debug("new()"),this.status=Ht.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){Pt.warn(`cannot use TextDecoder: ${o}`)}if(typeof s>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");s instanceof Array||(s=[s]),s.forEach(function(o){if(!wg.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:Ht.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(Pt.debug("connect()"),this.isConnected()){Pt.debug("Transport is already connected");return}else if(this.isConnecting()){Pt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ht.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(){Pt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ht.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(s){if(Pt.debug("send()"),!this.isConnected())return Pt.warn("unable to send message, transport is not connected"),!1;const r=s.toString();return Pt.debug(`sending message:
|
112
|
+
`,this.transport.send(a)}}class vm extends Cf{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var Ut={OutgoingRequest:Zl,InitialOutgoingInviteRequest:Fa,IncomingRequest:Tm,IncomingResponse:vm};const eo=ke(Ut),Em=lt,_s=mt(),Wt=new Em("DigestAuthentication");var Rf=class{constructor(s){this._credentials=s,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(s){switch(s){case"realm":return this._realm;case"ha1":return this._ha1;default:Wt.warn('get() | cannot get "%s" parameter',s);return}}authenticate({method:s,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=s,this._uri=r,this._cnonce=t||_s.createRandomToken(12),this._nc+=1;const n=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-n.length)+n,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 s=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return s.push(`algorithm=${this._algorithm}`),s.push(`username="${this._credentials.username}"`),s.push(`realm="${this._realm}"`),s.push(`nonce="${this._nonce}"`),s.push(`uri="${this._uri}"`),s.push(`response="${this._response}"`),this._opaque&&s.push(`opaque="${this._opaque}"`),this._qop&&(s.push(`qop=${this._qop}`),s.push(`cnonce="${this._cnonce}"`),s.push(`nc=${this._ncHex}`)),`Digest ${s.join(", ")}`}};const Sm=ke(Rf),hs=500,ym=4e3,If=5e3;var ja={T1:hs,T2:ym,T4:If,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*If,TIMER_L:64*hs,TIMER_M:64*hs,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Fr=ke(ja),jr=ut.EventEmitter,Vr=lt,qr=De,bf=Ut,ts=ja,wf=new Vr("NonInviteClientTransaction"),to=new Vr("InviteClientTransaction"),Am=new Vr("AckClientTransaction"),Of=new Vr("NonInviteServerTransaction"),so=new Vr("InviteServerTransaction"),fe={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 Cm extends jr{constructor(s,r,o,a){super(),this.type=fe.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=s,this.transport=r,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${r.via_transport}`;t+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(fe.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},ts.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){wf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){wf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(s){const r=s.status_code;if(r<200)switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break}else switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),clearTimeout(this.F),r===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(s),this.K=setTimeout(()=>{this.timer_K()},ts.TIMER_K);break;case fe.STATUS_COMPLETED:break}}}class Rm extends jr{constructor(s,r,o,a){super(),this.type=fe.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=s,this.transport=r,this.request=o,this.eventHandlers=a,o.transaction=this;let t=`SIP/2.0/${r.via_transport}`;t+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(fe.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},ts.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==fe.STATUS_ACCEPTED&&(to.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){to.debug(`Timer M expired for transaction ${this.id}`),this.state===fe.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){to.debug(`Timer B expired for transaction ${this.id}`),this.state===fe.STATUS_CALLING&&(this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){to.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(s){const r=new bf.OutgoingRequest(qr.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",s.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},ts.TIMER_D),this.transport.send(r)}cancel(s){if(this.state!==fe.STATUS_PROCEEDING)return;const r=new bf.OutgoingRequest(qr.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")),s&&r.setHeader("reason",s),this.transport.send(r)}receiveResponse(s){const r=s.status_code;if(r>=100&&r<=199)switch(this.state){case fe.STATUS_CALLING:this.stateChanged(fe.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(s);break}else if(r>=200&&r<=299)switch(this.state){case fe.STATUS_CALLING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},ts.TIMER_M),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(s);break}else if(r>=300&&r<=699)switch(this.state){case fe.STATUS_CALLING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),this.sendACK(s),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_COMPLETED:this.sendACK(s);break}}}class Im extends jr{constructor(s,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+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return fe}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Am.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class bm extends jr{constructor(s,r,o){super(),this.type=fe.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=s,this.transport=r,this.request=o,this.last_response="",o.server_transaction=this,this.state=fe.STATUS_TRYING,s.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_J(){Of.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,Of.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(s,r,o,a){if(s===100)switch(this.state){case fe.STATUS_TRYING:this.stateChanged(fe.STATUS_PROCEEDING),this.transport.send(r)||this.onTransportError();break;case fe.STATUS_PROCEEDING:this.last_response=r,this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(s>=200&&s<=699)switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),this.last_response=r,this.J=setTimeout(()=>{this.timer_J()},ts.TIMER_J),this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break;case fe.STATUS_COMPLETED:break}}}class wm extends jr{constructor(s,r,o){super(),this.type=fe.INVITE_SERVER,this.id=o.via_branch,this.ua=s,this.transport=r,this.request=o,this.last_response="",o.server_transaction=this,this.state=fe.STATUS_PROCEEDING,s.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_H(){so.debug(`Timer H expired for transaction ${this.id}`),this.state===fe.STATUS_COMPLETED&&so.debug("ACK not received, dialog will be terminated"),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){so.debug(`Timer L expired for transaction ${this.id}`),this.state===fe.STATUS_ACCEPTED&&(this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,so.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(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(s,r,o,a){if(s>=100&&s<=199)switch(this.state){case fe.STATUS_PROCEEDING:this.transport.send(r)||this.onTransportError(),this.last_response=r;break}if(s>100&&s<=199&&this.state===fe.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},ts.PROVISIONAL_RESPONSE_INTERVAL));else if(s>=200&&s<=299)switch(this.state){case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_ACCEPTED),this.last_response=r,this.L=setTimeout(()=>{this.timer_L()},ts.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case fe.STATUS_ACCEPTED:this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(s>=300&&s<=699)switch(this.state){case fe.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(r)?(this.stateChanged(fe.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},ts.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function Om({_transactions:c},s){let r;switch(s.method){case qr.INVITE:if(r=c.ist[s.via_branch],r){switch(r.state){case fe.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case fe.STATUS_ACCEPTED:break}return!0}break;case qr.ACK:if(r=c.ist[s.via_branch],r){if(r.state===fe.STATUS_ACCEPTED)return!1;if(r.state===fe.STATUS_COMPLETED)return r.state=fe.STATUS_CONFIRMED,r.I=setTimeout(()=>{r.timer_I()},ts.TIMER_I),!0}else return!1;break;case qr.CANCEL:return r=c.ist[s.via_branch],r?(s.reply_sl(200),r.state!==fe.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(r=c.nist[s.via_branch],r){switch(r.state){case fe.STATUS_TRYING:break;case fe.STATUS_PROCEEDING:case fe.STATUS_COMPLETED:r.transport.send(r.last_response);break}return!0}break}}var xn={C:fe,NonInviteClientTransaction:Cm,InviteClientTransaction:Rm,AckClientTransaction:Im,NonInviteServerTransaction:bm,InviteServerTransaction:wm,checkTransaction:Om};const $t=ke(xn),Dm=lt,Df=De,Nm=Rf,Va=xn,Um=new Dm("RequestSender"),qa={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var Mn=class{constructor(s,r,o){this._ua=s,this._eventHandlers=o,this._method=r.method,this._request=r,this._auth=null,this._challenged=!1,this._staled=!1;for(const a in qa)Object.prototype.hasOwnProperty.call(qa,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=qa[a]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==Df.BYE||this._method!==Df.ACK)&&this._eventHandlers.onTransportError()}send(){const s={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:r=>{this._receiveResponse(r)}};switch(this._method){case"INVITE":this.clientTransaction=new Va.InviteClientTransaction(this._ua,this._ua.transport,this._request,s);break;case"ACK":this.clientTransaction=new Va.AckClientTransaction(this._ua,this._ua.transport,this._request,s);break;default:this.clientTransaction=new Va.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,s)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(s){let r,o;const a=s.status_code;if((a===401||a===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(s.status_code===401?(r=s.parseHeader("www-authenticate"),o="authorization"):(r=s.parseHeader("proxy-authenticate"),o="proxy-authorization"),!r){Um.debug(`${s.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(s);return}if(!this._challenged||!this._staled&&r.stale===!0){if(this._auth||(this._auth=new Nm({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,r)){this._eventHandlers.onReceiveResponse(s);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(s)}else this._eventHandlers.onReceiveResponse(s)}};const Nf=ke(Mn),Pm=lt,Ba=mt(),Xs=De,Uf=Ut,Pf=Mn,Br=new Pm("Registrator"),no=10;var xm=class{constructor(s,r){this._reg_id=1,this._ua=s,this._transport=r,this._registrar=s.configuration.registrar_server,this._expires=s.configuration.register_expires,this._call_id=Ba.createRandomToken(22),this._cseq=0,this._to_uri=s.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(s){Array.isArray(s)||(s=[]),this._extraHeaders=s.slice()}setExtraContactParams(s){s instanceof Object||(s={}),this._extraContactParams="";for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const o=s[r];this._extraContactParams+=`;${r}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Br.debug("Register request in progress...");return}const s=this._extraHeaders.slice();s.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),s.push(`Expires: ${this._expires}`);const r=new Uf.OutgoingRequest(Xs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s),o=new Pf(this._ua,r,{onRequestTimeout:()=>{this._registrationFailure(null,Xs.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,Xs.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")){Br.debug("no Contact header in response to REGISTER, response ignored");break}const t=a.headers.Contact.reduce((h,g)=>h.concat(g.parsed),[]);let n=t.find(h=>this._sipInstance===h.getParam("+sip.instance")&&this._reg_id===parseInt(h.getParam("reg-id")));if(n||(n=t.find(h=>h.uri.user===this._ua.contact.uri.user)),!n){Br.debug("no Contact header pointing to us, response ignored");break}let p=n.getParam("expires");!p&&a.hasHeader("expires")&&(p=a.getHeader("expires")),p||(p=this._expires),p=Number(p),p<no&&(p=no);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")},_),n.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=n.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<no&&(this._expires=no),this.register()):(Br.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,Xs.causes.SIP_FAILURE_CODE));break}default:{const t=Ba.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(s={}){if(!this._registered){Br.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const r=this._extraHeaders.slice();s.all?r.push(`Contact: *${this._extraContactParams}`):r.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),r.push("Expires: 0");const o=new Uf.OutgoingRequest(Xs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r);new Pf(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,Xs.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,Xs.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 n=Ba.sipErrorCause(t.status_code);this._unregistered(t,n)}}}}).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(s,r){this._registering=!1,this._ua.registrationFailed({response:s||null,cause:r}),this._registered&&(this._registered=!1,this._ua.unregistered({response:s||null,cause:r}))}_unregistered(s,r){this._registering=!1,this._registered=!1,this._ua.unregistered({response:s||null,cause:r||null})}};class Mm extends Error{constructor(s,r){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=s,this.value=r,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class km extends Error{constructor(s){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=s,this.message=`Invalid status: ${s}`}}class Lm extends Error{constructor(s){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=s}}class $m extends Error{constructor(s){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=s}}var ds={ConfigurationError:Mm,InvalidStateError:km,NotSupportedError:Lm,NotReadyError:$m};const Is=ke(ds),Ga=De,ro=xn,Hm=Mn,Wa={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var xf=class{constructor(s,r,o){this._dialog=s,this._ua=s._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 s=new Hm(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:r=>{this._eventHandlers.onAuthenticated(r)},onReceiveResponse:r=>{this._receiveResponse(r)}});if(s.send(),(this._request.method===Ga.INVITE||this._request.method===Ga.UPDATE&&this._request.body)&&s.clientTransaction.state!==ro.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const r=()=>{(s.clientTransaction.state===ro.C.STATUS_ACCEPTED||s.clientTransaction.state===ro.C.STATUS_COMPLETED||s.clientTransaction.state===ro.C.STATUS_TERMINATED)&&(s.clientTransaction.removeListener("stateChanged",r),this._dialog.uac_pending_reply=!1)};s.clientTransaction.on("stateChanged",r)}}_receiveResponse(s){s.status_code===408||s.status_code===481?this._eventHandlers.onDialogError(s):s.method===Ga.INVITE&&s.status_code===491?this._reattempt?s.status_code>=200&&s.status_code<300?this._eventHandlers.onSuccessResponse(s):s.status_code>=300&&this._eventHandlers.onErrorResponse(s):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):s.status_code>=200&&s.status_code<300?this._eventHandlers.onSuccessResponse(s):s.status_code>=300&&this._eventHandlers.onErrorResponse(s)}};const Fm=ke(xf),jm=lt,Mf=Ut,bs=De,Gr=xn,Vm=xf,Ka=mt(),Ya=new jm("Dialog"),ws={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var kf=class{static get C(){return ws}constructor(s,r,o,a=ws.STATUS_CONFIRMED){if(this._owner=s,this._ua=s._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 Mf.IncomingResponse&&(a=r.status_code<200?ws.STATUS_EARLY:ws.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),Ya.debug(`new ${o} dialog created with status ${this._state===ws.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(s){this._local_seqnum=s}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(s){this._uac_pending_reply=s}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===ws.STATUS_TERMINATED}update(s,r){this._state=ws.STATUS_CONFIRMED,Ya.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){Ya.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=ws.STATUS_TERMINATED}sendRequest(s,r={}){const o=Ka.cloneArray(r.extraHeaders),a=Ka.cloneObject(r.eventHandlers),t=r.body||null,n=this._createRequest(s,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new Vm(this,n,a).send(),n}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===bs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===bs.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,r,o){r=Ka.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===bs.CANCEL||s===bs.ACK?this._local_seqnum:this._local_seqnum+=1;return new Mf.OutgoingRequest(s,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(s){if(!this._remote_seqnum)this._remote_seqnum=s.cseq;else if(s.cseq<this._remote_seqnum)if(s.method===bs.ACK){if(this._ack_seqnum===null||s.cseq!==this._ack_seqnum)return!1}else return s.reply(500),!1;else s.cseq>this._remote_seqnum&&(this._remote_seqnum=s.cseq);if(s.method===bs.INVITE||s.method===bs.UPDATE&&s.body){if(this._uac_pending_reply===!0)s.reply(491);else if(this._uas_pending_reply===!0){const r=(Math.random()*10|0)+1;return s.reply(500,null,[`Retry-After:${r}`]),!1}else{this._uas_pending_reply=!0;const r=()=>{(s.server_transaction.state===Gr.C.STATUS_ACCEPTED||s.server_transaction.state===Gr.C.STATUS_COMPLETED||s.server_transaction.state===Gr.C.STATUS_TERMINATED)&&(s.server_transaction.removeListener("stateChanged",r),this._uas_pending_reply=!1)};s.server_transaction.on("stateChanged",r)}s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Gr.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===bs.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Gr.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}};const io=ke(kf);var Ja={exports:{}};const qm=ut.EventEmitter,Bm=lt,Gm=De,Wm=ds,Lf=mt(),Km=new Bm("RTCSession:DTMF"),$f={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Ja.exports=class extends qm{constructor(s){super(),this._session=s,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(s,r={}){if(s===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 Wm.InvalidStateError(this._session.status);const o=Lf.cloneArray(r.extraHeaders);if(this.eventHandlers=Lf.cloneObject(r.eventHandlers),typeof s=="string")s=s.toUpperCase();else if(typeof s=="number")s=s.toString();else throw new TypeError(`Invalid tone: ${s}`);if(s.match(/^[0-9A-DR#*]$/))this._tone=s;else throw new TypeError(`Invalid tone: ${s}`);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(Gm.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(s){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=s,s.reply(200),s.body){const a=s.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=$f.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:s}):Km.debug("invalid INFO DTMF received, discarded")}},Ja.exports.C=$f;var Hf=Ja.exports;const Ym=ke(Hf),Jm=ut.EventEmitter,zm=De,Xm=ds,Qm=mt();var Ff=class extends Jm{constructor(s){super(),this._session=s,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(s,r,o={}){if(this._direction="outgoing",s===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 Xm.InvalidStateError(this._session.status);this._contentType=s,this._body=r;const a=Qm.cloneArray(o.extraHeaders);a.push(`Content-Type: ${s}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(zm.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(s){this._direction="incoming",this.request=s,s.reply(200),this._contentType=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,this._body=s.body,this._session.newInfo({originator:"remote",info:this,request:s})}};const za=ke(Ff),Zm=lt,jf=De,eg=new Zm("RTCSession:ReferNotifier"),Xa={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var Vf=class{constructor(s,r,o){this._session=s,this._id=r,this._expires=o||Xa.expires,this._active=!0,this.notify(100)}notify(s,r){if(eg.debug("notify()"),this._active===!1)return;r=r||jf.REASON_PHRASE[s]||"";let o;s>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(jf.NOTIFY,{extraHeaders:[`Event: ${Xa.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${Xa.body_type}`],body:`SIP/2.0 ${s} ${r}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const tg=ke(Vf),sg=ut.EventEmitter,ng=lt,Wr=De,rg=es(),qf=mt(),Qs=new ng("RTCSession:ReferSubscriber");var Bf=class extends sg{constructor(s){super(),this._id=null,this._session=s}get id(){return this._id}sendRefer(s,r={}){Qs.debug("sendRefer()");const o=qf.cloneArray(r.extraHeaders),a=qf.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 n=`Refer-To: <${s}${t?`?Replaces=${t}`:""}>`;if(o.push(n),!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(Wr.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:_=>{this._requestSucceeded(_)},onErrorResponse:_=>{this._requestFailed(_,Wr.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Wr.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Wr.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Wr.causes.DIALOG_ERROR)}}});this._id=p.cseq}receiveNotify(s){if(Qs.debug("receiveNotify()"),!s.body)return;const r=rg.parse(s.body.trim().split(`\r
|
115
|
+
`,1)[0],"Status_Line");if(r===-1){Qs.debug(`receiveNotify() | error parsing NOTIFY body: "${s.body}"`);return}switch(!0){case/^100$/.test(r.status_code):this.emit("trying",{request:s,status_line:r});break;case/^1[0-9]{2}$/.test(r.status_code):this.emit("progress",{request:s,status_line:r});break;case/^2[0-9]{2}$/.test(r.status_code):this.emit("accepted",{request:s,status_line:r});break;default:this.emit("failed",{request:s,status_line:r});break}}_requestSucceeded(s){Qs.debug("REFER succeeded"),Qs.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:s})}_requestFailed(s,r){Qs.debug("REFER failed"),Qs.debug('emit "requestFailed"'),this.emit("requestFailed",{response:s||null,cause:r})}};const ig=ke(Bf),lg=ut.EventEmitter,Gf=Dt,og=lt,_e=De,Zs=ds,Wf=xn,Ge=mt(),Kr=ja,ag=Ut,lo=kf,ug=Mn,Mt=Hf,Kf=Ff,cg=Vf,fg=Bf,Yf=fs(),K=new og("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},oo=["audio","video"];var Jf=class Hu extends lg{static get C(){return Q}constructor(s){K.debug("new"),super(),this._id=null,this._ua=s,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:_e.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return Q}get causes(){return _e.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(s){this._data=s}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(s,r={},o){K.debug("connect()");const a=s,t=Ge.cloneObject(r.eventHandlers),n=Ge.cloneArray(r.extraHeaders),p=Ge.cloneObject(r.mediaConstraints,{audio:!0,video:!0}),_=r.mediaStream||null,h=Ge.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,s===void 0)throw new TypeError("Not enough arguments");if(this._status!==Q.STATUS_NULL)throw new Zs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Zs.NotSupportedError("WebRTC not supported");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&Ge.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=_e.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=_e.SESSION_EXPIRES);for(const A in t)Object.prototype.hasOwnProperty.call(t,A)&&this.on(A,t[A]);this._from_tag=Ge.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 Yf("sip","anonymous","anonymous.invalid"),n.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),n.push("Privacy: id")):r.fromUserName&&(y.from_uri=new Yf("sip",r.fromUserName,this._ua.configuration.uri.host),n.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),r.fromDisplayName&&(y.from_display_name=r.fromDisplayName),n.push(`Contact: ${this._contact}`),n.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&n.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new ag.InitialOutgoingInviteRequest(s,this._ua,y,n),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(h,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(s,r){K.debug("init_incoming()");let o;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=Q.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(o=s.getHeader("expires")*1e3),s.to_tag=Ge.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Q.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),this._failed("local",null,_e.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Q.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),this._failed("system",null,_e.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,r&&r(this),this._newRTCSession("remote",s),this._status!==Q.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(s={}){K.debug("answer()");const r=this._request,o=Ge.cloneArray(s.extraHeaders),a=Ge.cloneObject(s.mediaConstraints),t=s.mediaStream||null,n=Ge.cloneObject(s.pcConfig,{iceServers:[]}),p=s.rtcConstraints||null,_=s.rtcAnswerConstraints||null,h=Ge.cloneObject(s.rtcOfferConstraints);let g,T=!1,E=!1,y=!1,A=!1;if(this._rtcAnswerConstraints=_,this._rtcOfferConstraints=s.rtcOfferConstraints||null,this._data=s.data||this._data,this._direction!=="incoming")throw new Zs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==Q.STATUS_WAITING_FOR_ANSWER)throw new Zs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Ge.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=_e.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=_e.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 C=r.parseSDP();Array.isArray(C.media)||(C.media=[C.media]);for(const I of C.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&&!h.offerToReceiveAudio&&(a.audio=!1),!t&&!E&&!h.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(n,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,_e.causes.USER_DENIED_MEDIA_ACCESS),K.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};K.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,_e.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===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,_e.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==Q.STATUS_TERMINATED&&K.warn(I)})}terminate(s={}){K.debug("terminate()");const r=s.cause||_e.causes.BYE,o=Ge.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,p=s.reason_phrase;if(this._status===Q.STATUS_TERMINATED)throw new Zs.InvalidStateError(this._status);switch(this._status){case Q.STATUS_NULL:case Q.STATUS_INVITE_SENT:case Q.STATUS_1XX_RECEIVED:if(K.debug("canceling session"),n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(p=p||_e.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;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,_e.causes.CANCELED);break;case Q.STATUS_WAITING_FOR_ANSWER:case Q.STATUS_ANSWERED:if(K.debug("rejecting session"),n=n||480,n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._request.reply(n,p,o,a),this._failed("local",null,_e.causes.REJECTED);break;case Q.STATUS_WAITING_FOR_ACK:case Q.STATUS_CONFIRMED:if(K.debug("terminating session"),p=s.reason_phrase||_e.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${p}"`),this._status===Q.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Wf.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:h})=>{h===_e.ACK&&(this.sendRequest(_e.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Wf.C.STATUS_TERMINATED&&(this.sendRequest(_e.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else this.sendRequest(_e.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendDTMF(s,r={}){K.debug("sendDTMF() | tones: %s",s);let o=0,a=r.duration||null,t=r.interToneGap||null;const n=r.transportType||_e.DTMF_TRANSPORT.INFO;if(s===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 Zs.InvalidStateError(this._status);if(n!==_e.DTMF_TRANSPORT.INFO&&n!==_e.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${n}`);if(typeof s=="number"&&(s=s.toString()),!s||typeof s!="string"||!s.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${s}`);if(a&&!Ge.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<Mt.C.MIN_DURATION?(K.debug(`"duration" value is lower than the minimum allowed, setting it to ${Mt.C.MIN_DURATION} milliseconds`),a=Mt.C.MIN_DURATION):a>Mt.C.MAX_DURATION?(K.debug(`"duration" value is greater than the maximum allowed, setting it to ${Mt.C.MAX_DURATION} milliseconds`),a=Mt.C.MAX_DURATION):a=Math.abs(a):a=Mt.C.DEFAULT_DURATION,r.duration=a,t&&!Ge.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<Mt.C.MIN_INTER_TONE_GAP?(K.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${Mt.C.MIN_INTER_TONE_GAP} milliseconds`),t=Mt.C.MIN_INTER_TONE_GAP):t=Math.abs(t):t=Mt.C.DEFAULT_INTER_TONE_GAP,n===_e.DTMF_TRANSPORT.RFC2833){const _=this._getDTMFRTPSender();_&&(s=_.toneBuffer+s,_.insertDTMF(s,a,t));return}if(this._tones){this._tones+=s;return}this._tones=s,p.call(this);function p(){let _;if(this._status===Q.STATUS_TERMINATED||!this._tones||o>=this._tones.length){this._tones=null;return}const h=this._tones[o];if(o+=1,h===",")_=2e3;else{const g=new Mt(this);r.eventHandlers={onFailed:()=>{this._tones=null}},g.send(h,r),_=a+t}setTimeout(p.bind(this),_)}}sendInfo(s,r,o={}){if(K.debug("sendInfo()"),this._status!==Q.STATUS_CONFIRMED&&this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_1XX_RECEIVED)throw new Zs.InvalidStateError(this._status);new Kf(this).send(s,r,o)}mute(s={audio:!0,video:!1}){K.debug("mute()");let r=!1,o=!1;this._audioMuted===!1&&s.audio&&(r=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&s.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(r===!0||o===!0)&&this._onmute({audio:r,video:o})}unmute(s={audio:!0,video:!0}){K.debug("unmute()");let r=!1,o=!1;this._audioMuted===!0&&s.audio&&(r=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&s.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(r===!0||o===!0)&&this._onunmute({audio:r,video:o})}hold(s={},r){if(K.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:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}unhold(s={},r){if(K.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:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}renegotiate(s={},r){K.debug("renegotiate()");const o=s.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:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}),!0}refer(s,r){K.debug("refer()");const o=s;if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${o}`);const a=new fg(this);a.sendRefer(s,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(s,r){return K.debug("sendRequest()"),this._dialog.sendRequest(s,r)}receiveRequest(s){if(K.debug("receiveRequest()"),s.method===_e.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",s,_e.causes.CANCELED));else switch(s.method){case _e.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(!s.body){this.terminate({cause:_e.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:s.body};K.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",s)}).catch(a=>{this.terminate({cause:_e.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",s);break;case _e.BYE:this._status===Q.STATUS_CONFIRMED||this._status===Q.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,_e.causes.BYE)):this._status===Q.STATUS_INVITE_RECEIVED||this._status===Q.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,_e.causes.BYE)):s.reply(403,"Wrong Status");break;case _e.INVITE:this._status===Q.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case _e.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=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;r&&r.match(/^application\/dtmf-relay/i)?new Mt(this).init_incoming(s):r!==void 0?new Kf(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case _e.UPDATE:this._status===Q.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case _e.REFER:this._status===Q.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case _e.NOTIFY:this._status===Q.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){K.warn("onTransportError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_e.causes.CONNECTION_ERROR,cause:_e.causes.CONNECTION_ERROR})}onRequestTimeout(){K.warn("onRequestTimeout()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:_e.causes.REQUEST_TIMEOUT,cause:_e.causes.REQUEST_TIMEOUT})}onDialogError(){K.warn("onDialogError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_e.causes.DIALOG_ERROR,cause:_e.causes.DIALOG_ERROR})}newDTMF(s){K.debug("newDTMF()"),this.emit("newDTMF",s)}newInfo(s){K.debug("newInfo()"),this.emit("newInfo",s)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(K.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(K.debug("_isReadyToReOffer() | session not established yet"),!1):(K.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),Ge.closeMediaStream(this._localMediaStream)),this._status!==Q.STATUS_TERMINATED){if(this._status=Q.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){K.warn("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(s,r){let o=Kr.T1;function a(){this._status===Q.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],r),o<Kr.T2&&(o=o*2,o>Kr.T2&&(o=Kr.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&&(K.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(_e.BYE),this._ended("remote",null,_e.causes.NO_ACK))},Kr.TIMER_H)}_createRTCConnection(s,r){this._connection=new RTCPeerConnection(s,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:_e.causes.RTP_TIMEOUT,status_code:408,reason_phrase:_e.causes.RTP_TIMEOUT})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(s,r){if(K.debug("createLocalDescription()"),s!=="offer"&&s!=="answer")throw new Error(`createLocalDescription() | invalid type "${s}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>s==="offer"?o.createOffer(r).catch(a=>(K.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(r).catch(a=>(K.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>o.setLocalDescription(a).catch(t=>(this._rtcReady=!0,K.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=r&&r.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:s,sdp:o.localDescription.sdp};return K.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let n=!1,p,_;this._iceReady=!1;const h=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",_),n=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:s,sdp:o.localDescription.sdp};K.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:h}):n||h()}),o.addEventListener("icegatheringstatechange",_=()=>{o.iceGatheringState==="complete"&&!n&&h()})})})}_createDialog(s,r,o){const a=r==="UAS"?s.to_tag:s.from_tag,t=r==="UAS"?s.from_tag:s.to_tag,n=s.call_id+a+t;let p=this._earlyDialogs[n];if(o)return p?!0:(p=new lo(this,s,r,lo.C.STATUS_EARLY),p.error?(K.debug(p.error),this._failed("remote",s,_e.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,r),this._dialog=p,delete this._earlyDialogs[n],!0;const _=new lo(this,s,r);return _.error?(K.debug(_.error),this._failed("remote",s,_e.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_receiveReinvite(s){K.debug("receiveReinvite()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,h=p.reason_phrase||"",g=Ge.cloneArray(p.extraHeaders);if(this._status!==Q.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);s.reply(_,h,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!s.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=>{n.call(this,p)}).catch(()=>{s.reply(500)});return}if(r!=="application/sdp"){K.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==Q.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{K.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),this._late_sdp&&(p=this._mangleOffer(p)),s.reply(200,null,_,p,()=>{this._status=Q.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(s){K.debug("receiveUpdate()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,h=p.reason_phrase||"",g=Ge.cloneArray(p.extraHeaders);if(this._status!==Q.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);s.reply(_,h,g)}if(this.emit("update",o),a)return;if(!s.body){n.call(this,null);return}if(r!=="application/sdp"){K.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==Q.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{K.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),s.reply(200,null,_,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(s){K.debug("_processInDialogSdpOffer()");const r=s.parseSDP();let o=!1;for(const n of r.media){if(oo.indexOf(n.type)===-1)continue;const p=n.direction||r.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:s.body};K.debug('emit "sdp"'),this.emit("sdp",a);const t=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===Q.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(n=>{throw s.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),this.emit("peerconnection:setremotedescriptionfailed",n),n})}).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(n=>{throw s.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',n),n})}).catch(n=>{K.warn("_processInDialogSdpOffer() failed [error: %o]",n)}),this._connectionPromiseQueue}_receiveRefer(s){if(K.debug("receiveRefer()"),!s.refer_to){K.debug("no Refer-To header field present in REFER"),s.reply(400);return}if(s.refer_to.uri.scheme!==_e.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const r=new cg(this,s.cseq);K.debug('emit "refer"'),this.emit("refer",{request:s,accept:(t,n)=>{o.call(this,t,n)},reject:()=>{a.call(this)}});function o(t,n={}){if(t=typeof t=="function"?t:null,this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;const p=new Hu(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:h})=>{_?r.notify(_.status_code,_.reason_phrase):r.notify(487,h)}),s.refer_to.uri.hasHeader("replaces")){const _=decodeURIComponent(s.refer_to.uri.getHeader("replaces"));n.extraHeaders=Ge.cloneArray(n.extraHeaders),n.extraHeaders.push(`Replaces: ${_}`)}p.connect(s.refer_to.uri.toAor(),n,t)}function a(){r.notify(603)}}_receiveNotify(s){switch(K.debug("receiveNotify()"),s.event||s.reply(400),s.event.event){case"refer":{let r,o;if(s.event.params&&s.event.params.id)r=s.event.params.id,o=this._referSubscribers[r];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{s.reply(400,"Missing event id parameter");return}if(!o){s.reply(481,"Subscription does not exist");return}o.receiveNotify(s),s.reply(200);break}default:s.reply(489)}}_receiveReplaces(s){K.debug("receiveReplaces()");function r(a){if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;const t=new Hu(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(s,a)}function o(){K.debug("Replaced INVITE rejected by the user"),s.reply(486)}this.emit("replaces",{request:s,accept:a=>{r.call(this,a)},reject:()=>{o.call(this)}})}_sendInitialRequest(s,r,o){const a=new ug(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(s.audio||s.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(s).catch(t=>{throw this._status===Q.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,_e.causes.USER_DENIED_MEDIA_ACCESS),K.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(n=>{this._connection.addTrack(n,t)}),this._connecting(this._request),this._createLocalDescription("offer",r).catch(n=>{throw this._failed("local",null,_e.causes.WEBRTC_ERROR),n})}).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,K.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==Q.STATUS_TERMINATED&&K.warn(t)})}_getDTMFRTPSender(){const s=this._connection.getSenders().find(r=>r.track&&r.track.kind==="audio");if(!(s&&s.dtmf)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return s.dtmf}_receiveInviteResponse(s){if(K.debug("receiveInviteResponse()"),this._dialog&&s.status_code>=200&&s.status_code<=299)if(this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.sendRequest(_e.ACK);return}else{const r=new lo(this,s,"UAC");if(r.error!==void 0){K.debug(r.error);return}this.sendRequest(_e.ACK),this.sendRequest(_e.BYE);return}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==Q.STATUS_INVITE_SENT&&this._status!==Q.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(s.status_code):this._status=Q.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){K.debug("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=Q.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const r={originator:"remote",type:"answer",sdp:s.body};K.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",s)).catch(a=>{K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(this._status=Q.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,_e.causes.MISSING_SDP),this._failed("remote",s,_e.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;const r={originator:"remote",type:"answer",sdp:s.body};K.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(s,500,a.toString()),this._failed("local",s,_e.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest(_e.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(s,488,"Not Acceptable Here"),this._failed("remote",s,_e.causes.BAD_MEDIA_DESCRIPTION),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const r=Ge.sipErrorCause(s.status_code);this._failed("remote",s,r)}}}_sendReinvite(s={}){K.debug("sendReinvite()");const r=Ge.cloneArray(s.extraHeaders),o=Ge.cloneObject(s.eventHandlers),a=s.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 h={originator:"local",type:"offer",sdp:_};K.debug('emit "sdp"'),this.emit("sdp",h),this.sendRequest(_e.INVITE,{extraHeaders:r,body:_,eventHandlers:{onSuccessResponse:g=>{n.call(this,g),t=!0},onErrorResponse:g=>{p.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function n(_){if(this._status===Q.STATUS_TERMINATED||(this.sendRequest(_e.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 h={originator:"remote",type:"answer",sdp:_.body};K.debug('emit "sdp"'),this.emit("sdp",h);const g=new RTCSessionDescription({type:"answer",sdp:h.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(g)).then(()=>{o.succeeded&&o.succeeded(_)}).catch(T=>{p.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',T),this.emit("peerconnection:setremotedescriptionfailed",T)})}function p(_){o.failed&&o.failed(_)}}_sendUpdate(s={}){K.debug("sendUpdate()");const r=Ge.cloneArray(s.extraHeaders),o=Ge.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null,t=s.sdpOffer||!1;let n=!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(h=>{h=this._mangleOffer(h);const g={originator:"local",type:"offer",sdp:h};K.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(_e.UPDATE,{extraHeaders:r,body:h,eventHandlers:{onSuccessResponse:T=>{p.call(this,T),n=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(_e.UPDATE,{extraHeaders:r,eventHandlers:{onSuccessResponse:h=>{p.call(this,h)},onErrorResponse:h=>{_.call(this,h)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(h){if(this._status!==Q.STATUS_TERMINATED&&!n)if(this._handleSessionTimersInIncomingResponse(h),t){if(h.body){if(!h.hasHeader("Content-Type")||h.getHeader("Content-Type").toLowerCase()!=="application/sdp"){_.call(this);return}}else{_.call(this);return}const g={originator:"remote",type:"answer",sdp:h.body};K.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(h)}).catch(E=>{_.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else o.succeeded&&o.succeeded(h)}function _(h){o.failed&&o.failed(h)}}_acceptAndTerminate(s,r,o){K.debug("acceptAndTerminate()");const a=[];r&&(o=o||_e.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest(_e.ACK),this.sendRequest(_e.BYE,{extraHeaders:a})),this._status=Q.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=Gf.parse(s),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");for(const r of s.media)oo.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){K.debug("mangleOffer() | both on hold, mangling offer");for(const r of s.media)oo.indexOf(r.type)!==-1&&(r.direction="inactive")}else if(this._remoteHold){K.debug("mangleOffer() | remote on hold, mangling offer");for(const r of s.media)oo.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="recvonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="recvonly")}return Gf.write(s)}_setLocalMediaStatus(){let s=!0,r=!0;(this._localHold||this._remoteHold)&&(s=!1,r=!1),this._audioMuted&&(s=!1),this._videoMuted&&(r=!1),this._toggleMuteAudio(!s),this._toggleMuteVideo(!r)}_handleSessionTimersInIncomingRequest(s,r){if(!this._sessionTimers.enabled)return;let o;s.session_expires&&s.session_expires>=_e.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,o=s.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(s){if(!this._sessionTimers.enabled)return;let r;s.session_expires&&s.session_expires>=_e.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,r=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}_runSessionTimer(){const s=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()&&(K.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===_e.UPDATE?this._sendUpdate():this._sendReinvite())},s*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==Q.STATUS_TERMINATED&&(K.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:_e.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},s*1100)}_toggleMuteAudio(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of r)o.track.enabled=!s}_toggleMuteVideo(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of r)o.track.enabled=!s}_newRTCSession(s,r){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:s,session:this,request:r})}_connecting(s){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:s})}_progress(s,r){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:s,response:r||null})}_accepted(s,r){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:s,response:r||null})}_confirmed(s,r){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:r||null})}_ended(s,r,o){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:s,message:r||null,cause:o})}_failed(s,r,o){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:s,message:r||null,cause:o}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:s,message:r||null,cause:o})}_onhold(s){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:s})}_onunhold(s){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:s})}_onmute({audio:s,video:r}){K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:s,video:r})}_onunmute({audio:s,video:r}){K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:s,video:r})}};const _g=ke(Jf),hg=ut.EventEmitter,dg=lt,Qa=De,pg=Ut,Yr=mt(),mg=Mn,zf=ds,gg=fs(),ao=new dg("Message");var Tg=class extends hg{constructor(s){super(),this._ua=s,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(s,r,o={}){const a=s;if(s===void 0||r===void 0)throw new TypeError("Not enough arguments");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);const t=Yr.cloneArray(o.extraHeaders),n=Yr.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",_={};o.fromUserName&&(_.from_uri=new gg("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 n)Object.prototype.hasOwnProperty.call(n,g)&&this.on(g,n[g]);t.push(`Content-Type: ${p}`),this._request=new pg.OutgoingRequest(Qa.MESSAGE,s,this._ua,_,t),r&&(this._request.body=r);const h=new mg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:g=>{this._receiveResponse(g)}});this._newMessage("local",this._request),h.send()}init_incoming(s){this._request=s,this._newMessage("remote",s),this._is_replied||(this._is_replied=!0,s.reply(200)),this._close()}accept(s={}){const r=Yr.cloneArray(s.extraHeaders),o=s.body;if(this._direction!=="incoming")throw new zf.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(s={}){const r=s.status_code||480,o=s.reason_phrase,a=Yr.cloneArray(s.extraHeaders),t=s.body;if(this._direction!=="incoming")throw new zf.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(s){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._succeeded("remote",s);break;default:{const r=Yr.sipErrorCause(s.status_code);this._failed("remote",s,r);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Qa.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Qa.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(s,r){s==="remote"?(this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from):s==="local"&&(this._direction="outgoing",this._local_identity=r.from,this._remote_identity=r.to),this._ua.newMessage(this,{originator:s,message:this,request:r})}_failed(s,r,o){ao.debug("MESSAGE failed"),this._close(),ao.debug('emit "failed"'),this.emit("failed",{originator:s,response:r||null,cause:o})}_succeeded(s,r){ao.debug("MESSAGE succeeded"),this._close(),ao.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:r})}};const vg=ut.EventEmitter,Eg=lt,Za=De,Sg=Ut,Jr=mt(),yg=Mn,Xf=ds,uo=new Eg("Options");var Ag=class extends vg{constructor(s){super(),this._ua=s,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(s,r,o={}){const a=s;if(s===void 0)throw new TypeError("A target is required for OPTIONS");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);const t=Jr.cloneArray(o.extraHeaders),n=Jr.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const h in n)Object.prototype.hasOwnProperty.call(n,h)&&this.on(h,n[h]);t.push(`Content-Type: ${p}`),this._request=new Sg.OutgoingRequest(Za.OPTIONS,s,this._ua,null,t),r&&(this._request.body=r);const _=new yg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:h=>{this._receiveResponse(h)}});this._newOptions("local",this._request),_.send()}init_incoming(s){this._request=s,this._newOptions("remote",s),this._is_replied||(this._is_replied=!0,s.reply(200)),this._close()}accept(s={}){const r=Jr.cloneArray(s.extraHeaders),o=s.body;if(this._direction!=="incoming")throw new Xf.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(s={}){const r=s.status_code||480,o=s.reason_phrase,a=Jr.cloneArray(s.extraHeaders),t=s.body;if(this._direction!=="incoming")throw new Xf.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(s){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._succeeded("remote",s);break;default:{const r=Jr.sipErrorCause(s.status_code);this._failed("remote",s,r);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Za.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Za.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(s,r){s==="remote"?(this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from):s==="local"&&(this._direction="outgoing",this._local_identity=r.from,this._remote_identity=r.to),this._ua.newOptions(this,{originator:s,message:this,request:r})}_failed(s,r,o){uo.debug("OPTIONS failed"),this._close(),uo.debug('emit "failed"'),this.emit("failed",{originator:s,response:r||null,cause:o})}_succeeded(s,r){uo.debug("OPTIONS succeeded"),this._close(),uo.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:r})}},eu={};const Cg=lt,tu=mt(),Rg=es(),zr=new Cg("Socket");eu.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return zr.warn("undefined JsSIP.Socket instance"),!1;try{if(!tu.isString(c.url))throw zr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!tu.isString(c.via_transport))throw zr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Rg.parse(c.sip_uri,"SIP_URI")===-1)throw zr.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(s=>{if(!tu.isFunction(c[s]))throw zr.warn(`missing or invalid JsSIP.Socket method: ${s}`),new Error(`Missing or invalid JsSIP.Socket method: ${s}`)})}catch{return!1}return!0};const Ig=lt,bg=eu,Qf=De,Pt=new Ig("Transport"),Ht={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Qf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Qf.CONNECTION_RECOVERY_MAX_INTERVAL}};var Zf=class{constructor(s,r=Ht.recovery_options){Pt.debug("new()"),this.status=Ht.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){Pt.warn(`cannot use TextDecoder: ${o}`)}if(typeof s>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");s instanceof Array||(s=[s]),s.forEach(function(o){if(!bg.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:Ht.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(Pt.debug("connect()"),this.isConnected()){Pt.debug("Transport is already connected");return}else if(this.isConnecting()){Pt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ht.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(){Pt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ht.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(s){if(Pt.debug("send()"),!this.isConnected())return Pt.warn("unable to send message, transport is not connected"),!1;const r=s.toString();return Pt.debug(`sending message:
|
116
116
|
|
117
117
|
${r}
|
118
118
|
`),this.socket.send(r)}isConnected(){return this.status===Ht.STATUS_CONNECTED}isConnecting(){return this.status===Ht.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let s=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);s<this.recovery_options.min_interval?s=this.recovery_options.min_interval:s>this.recovery_options.max_interval&&(s=this.recovery_options.max_interval),Pt.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${s} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},s*1e3)}_getSocket(){let s=[];if(this.sockets.forEach(o=>{o.status!==Ht.SOCKET_STATUS_ERROR&&(s.length===0?s.push(o):o.weight>s[0].weight?s=[o]:o.weight===s[0].weight&&s.push(o))}),s.length===0){this.sockets.forEach(o=>{o.status=Ht.SOCKET_STATUS_READY}),this._getSocket();return}const r=Math.floor(Math.random()*s.length);this.socket=s[r].socket}_onConnect(){this.recover_attempts=0,this.status=Ht.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(s,r,o){this.status=Ht.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:s,code:r,reason:o}),!this.close_requested&&(this.sockets.forEach(function(a){this.socket===a.socket&&(a.status=Ht.SOCKET_STATUS_ERROR)},this),this._reconnect(s))}_onData(s){if(s===`\r
|
@@ -122,17 +122,17 @@ ${s}
|
|
122
122
|
`)}else Pt.debug(`received text message:
|
123
123
|
|
124
124
|
${s}
|
125
|
-
`);this.ondata({transport:this,message:s})}};const
|
126
|
-
`);if(a===-1){co.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=c.substring(0,a);let n=nu.parse(t,"Request_Response");if(n===-1){co.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else n.status_code?(r=new ru.IncomingResponse,r.status_code=n.status_code,r.reason_phrase=n.reason_phrase):(r=new ru.IncomingRequest(s),r.method=n.method,r.ruri=n.uri);r.data=c;let p=a+2;for(;;){if(a=
|
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
|
125
|
+
`);this.ondata({transport:this,message:s})}};const wg=ke(Zf);var su={};const Og=lt,nu=es(),ru=Ut,co=new Og("Parser");su.parseMessage=(c,s)=>{let r,o,a=c.indexOf(`\r
|
126
|
+
`);if(a===-1){co.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=c.substring(0,a);let n=nu.parse(t,"Request_Response");if(n===-1){co.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else n.status_code?(r=new ru.IncomingResponse,r.status_code=n.status_code,r.reason_phrase=n.reason_phrase):(r=new ru.IncomingRequest(s),r.method=n.method,r.ruri=n.uri);r.data=c;let p=a+2;for(;;){if(a=Dg(c,p),a===-2){o=p+2;break}else if(a===-1){co.warn("parseMessage() | malformed message");return}if(n=Ng(r,c,p,a),n!==!0){co.warn("parseMessage() |",n.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 Dg(c,s){let r=s,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 Ng(c,s,r,o){let a;const t=s.indexOf(":",r),n=s.substring(r,t).trim(),p=s.substring(t+1,o).trim();switch(n.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=nu.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=nu.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 ru.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(n,p),a=0}return a===void 0?{error:`error parsing header "${n}"`}:!0}const Ug=lt,e_=De,t_=Ut,iu=mt(),lu=new Ug("sanityCheck"),Pg=[Vg],xg=[kg,Lg,$g,Hg],Mg=[Fg,jg];let je,ss,s_;var n_=(c,s,r)=>{je=c,ss=s,s_=r;for(const o of Pg)if(o()===!1)return!1;if(je instanceof t_.IncomingRequest){for(const o of xg)if(o()===!1)return!1}else if(je instanceof t_.IncomingResponse){for(const o of Mg)if(o()===!1)return!1}return!0};function kg(){if(je.s("to").uri.scheme!=="sip")return Xr(416),!1}function Lg(){if(!je.to_tag&&je.call_id.substr(0,5)===ss.configuration.jssip_id)return Xr(482),!1}function $g(){const c=iu.str_utf8_length(je.body),s=je.getHeader("content-length");if(c<s)return Xr(400),!1}function Hg(){const c=je.from_tag,s=je.call_id,r=je.cseq;let o;if(!je.to_tag)if(je.method===e_.INVITE){if(ss._transactions.ist[je.via_branch])return!1;for(const a in ss._transactions.ist)if(Object.prototype.hasOwnProperty.call(ss._transactions.ist,a)&&(o=ss._transactions.ist[a],o.request.from_tag===c&&o.request.call_id===s&&o.request.cseq===r))return Xr(482),!1}else{if(ss._transactions.nist[je.via_branch])return!1;for(const a in ss._transactions.nist)if(Object.prototype.hasOwnProperty.call(ss._transactions.nist,a)&&(o=ss._transactions.nist[a],o.request.from_tag===c&&o.request.call_id===s&&o.request.cseq===r))return Xr(482),!1}}function Fg(){if(je.getHeaders("via").length>1)return lu.debug("more than one Via header field present in the response, dropping the response"),!1}function jg(){const c=iu.str_utf8_length(je.body),s=je.getHeader("content-length");if(c<s)return lu.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function Vg(){const c=["from","to","call_id","cseq","via"];for(const s of c)if(!je.hasHeader(s))return lu.debug(`missing mandatory header field : ${s}, dropping the response`),!1}function Xr(c){const s=je.getHeaders("via");let r,o=`SIP/2.0 ${c} ${e_.REASON_PHRASE[c]}\r
|
128
128
|
`;for(const a of s)o+=`Via: ${a}\r
|
129
129
|
`;r=je.getHeader("To"),je.to_tag||(r+=`;tag=${iu.newTag()}`),o+=`To: ${r}\r
|
130
130
|
`,o+=`From: ${je.getHeader("From")}\r
|
131
131
|
`,o+=`Call-ID: ${je.call_id}\r
|
132
132
|
`,o+=`CSeq: ${je.cseq} ${je.method}\r
|
133
133
|
`,o+=`\r
|
134
|
-
`,s_.send(o)}const Bg=ke(n_);var Qr={};const kn=mt(),en=De,ou=es(),r_=fs(),au=eu,uu=ds;Qr.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:en.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:en.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:en.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${kn.createRandomToken(12)}.invalid`};const fo={mandatory:{sockets(c){const s=[];if(au.isSocket(c))s.push({socket:c});else if(Array.isArray(c)&&c.length)for(const r of c)Object.prototype.hasOwnProperty.call(r,"socket")&&au.isSocket(r.socket)?s.push(r):au.isSocket(r)&&s.push({socket:r});else return;return s},uri(c){/^sip:/i.test(c)||(c=`${en.SIP}:${c}`);const s=r_.parse(c);if(s)return s.user?s:void 0}},optional:{authorization_user(c){if(ou.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(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},connection_recovery_min_interval(c){if(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},contact_uri(c){if(typeof c=="string"){const s=ou.parse(c,"SIP_URI");if(s!==-1)return s}},display_name(c){return c},instance_id(c){if(/^uuid:/i.test(c)&&(c=c.substr(5)),ou.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},session_timers(c){if(typeof c=="boolean")return c},session_timers_refresh_method(c){if(typeof c=="string"&&(c=c.toUpperCase(),c===en.INVITE||c===en.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(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},registrar_server(c){/^sip:/i.test(c)||(c=`${en.SIP}:${c}`);const s=r_.parse(c);if(s)return s.user?void 0:s},use_preloaded_route(c){if(typeof c=="boolean")return c},extra_headers(c){const s=[];if(Array.isArray(c)&&c.length)for(const r of c)typeof r=="string"&&s.push(r);else return;return s}}};Qr.load=(c,s)=>{for(const r in fo.mandatory)if(s.hasOwnProperty(r)){const o=s[r],a=fo.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new uu.ConfigurationError(r,o)}else throw new uu.ConfigurationError(r);for(const r in fo.optional)if(s.hasOwnProperty(r)){const o=s[r];if(kn.isEmpty(o))continue;const a=fo.optional[r](o);if(a!==void 0)c[r]=a;else throw new uu.ConfigurationError(r,o)}};const Gg=ut.EventEmitter,Wg=lt,Tt=De,Kg=Mm,i_=zf,l_=vg,o_=Cg,cu=xn,Yg=Zf,_o=mt(),zg=ds,Jg=fs(),Xg=su,fu=Ut,Qg=n_,_u=Qr,qe=new Wg("UA"),vt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var a_=class extends Gg{static get C(){return vt}constructor(s){if(qe.debug("new() [configuration:%o]",s),super(),this._cache={credentials:{}},this._configuration=Object.assign({},_u.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=vt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,s===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(s)}catch(r){throw this._status=vt.STATUS_NOT_READY,this._error=vt.CONFIGURATION_ERROR,r}this._registrator=new Kg(this)}get C(){return vt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){qe.debug("start()"),this._status===vt.STATUS_INIT?this._transport.connect():this._status===vt.STATUS_USER_CLOSED?(qe.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=vt.STATUS_INIT,this._transport.connect()):this._status===vt.STATUS_READY?qe.debug("UA is in READY status, not restarted"):qe.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){qe.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(s){qe.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(s)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(s,r){qe.debug("call()");const o=new i_(this);return o.connect(s,r),o}sendMessage(s,r,o){qe.debug("sendMessage()");const a=new l_(this);return a.send(s,r,o),a}sendOptions(s,r,o){qe.debug("sendOptions()");const a=new o_(this);return a.send(s,r,o),a}terminateSessions(s){qe.debug("terminateSessions()");for(const r in this._sessions)this._sessions[r].isEnded()||this._sessions[r].terminate(s)}stop(){if(qe.debug("stop()"),this._dynConfiguration={},this._status===vt.STATUS_USER_CLOSED){qe.debug("UA already closed");return}this._registrator.close();const s=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){qe.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=vt.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&&s===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(s){return _o.normalizeTarget(s,this._configuration.hostport_params)}get(s){switch(s){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:qe.warn('get() | cannot get "%s" parameter in runtime',s);return}}set(s,r){switch(s){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 qe.warn('set() | cannot set "%s" parameter in runtime',s),!1}return!0}newTransaction(s){this._transactions[s.type][s.id]=s,this.emit("newTransaction",{transaction:s})}destroyTransaction(s){delete this._transactions[s.type][s.id],this.emit("transactionDestroyed",{transaction:s})}newDialog(s){this._dialogs[s.id]=s}destroyDialog(s){delete this._dialogs[s.id]}newMessage(s,r){this._applicants[s]=s,this.emit("newMessage",r)}newOptions(s,r){this._applicants[s]=s,this.emit("newOptions",r)}destroyMessage(s){delete this._applicants[s]}newRTCSession(s,r){this._sessions[s.id]=s,this.emit("newRTCSession",r)}destroyRTCSession(s){delete this._sessions[s.id]}registered(s){this.emit("registered",s)}unregistered(s){this.emit("unregistered",s)}registrationFailed(s){this.emit("registrationFailed",s)}receiveRequest(s){const r=s.method;if(s.ruri.user!==this._configuration.uri.user&&s.ruri.user!==this._contact.uri.user){qe.debug("Request-URI does not point to us"),s.method!==Tt.ACK&&s.reply_sl(404);return}if(s.ruri.scheme===Tt.SIPS){s.reply_sl(416);return}if(cu.checkTransaction(this,s))return;if(r===Tt.INVITE?new cu.InviteServerTransaction(this,this._transport,s):r!==Tt.ACK&&r!==Tt.CANCEL&&new cu.NonInviteServerTransaction(this,this._transport,s),r===Tt.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new o_(this).init_incoming(s)}else if(r===Tt.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new l_(this).init_incoming(s)}else if(r===Tt.INVITE&&!s.to_tag&&this.listeners("newRTCSession").length===0){s.reply(405);return}let o,a;if(s.to_tag)o=this._findDialog(s.call_id,s.from_tag,s.to_tag),o?o.receiveRequest(s):r===Tt.NOTIFY?(a=this._findSession(s),a?a.receiveRequest(s):(qe.debug("received NOTIFY request for a non existent subscription"),s.reply(481,"Subscription does not exist"))):r!==Tt.ACK&&s.reply(481);else switch(r){case Tt.INVITE:if(window.RTCPeerConnection)if(s.hasHeader("replaces")){const t=s.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?s.reply(603):a.receiveRequest(s)):s.reply(481)}else a=new i_(this),a.init_incoming(s);else qe.warn("INVITE received but WebRTC is not supported"),s.reply(488);break;case Tt.BYE:s.reply(481);break;case Tt.CANCEL:a=this._findSession(s),a?a.receiveRequest(s):qe.debug("received CANCEL request for a non existent session");break;case Tt.ACK:break;case Tt.NOTIFY:this.emit("sipEvent",{event:s.event,request:s}),s.reply(200);break;default:s.reply(405);break}}_findSession({call_id:s,from_tag:r,to_tag:o}){const a=s+r,t=this._sessions[a],n=s+o,p=this._sessions[n];return t||p||null}_findDialog(s,r,o){let a=s+r+o,t=this._dialogs[a];return t||(a=s+o+r,t=this._dialogs[a],t||null)}_loadConfig(s){try{_u.load(this._configuration,s)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=_o.newUUID()),this._configuration.jssip_id=_o.createRandomToken(5);const r=this._configuration.uri.clone();r.user=null,this._configuration.hostport_params=r.toString().replace(/^sip:/i,"");try{this._transport=new Yg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Zg.bind(this),this._transport.onconnect=eT.bind(this),this._transport.ondisconnect=tT.bind(this),this._transport.ondata=sT.bind(this)}catch(a){throw qe.warn(a),new zg.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 Jg("sip",_o.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,n=a.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),n&&(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}));qe.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(_u.settings,a))switch(a){case"uri":case"registrar_server":qe.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":qe.debug(`- ${a}: NOT SHOWN`);break;default:qe.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}};function Zg(c){this.emit("connecting",c)}function eT(c){this._status!==vt.STATUS_USER_CLOSED&&(this._status=vt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function tT(c){const s=["nict","ict","nist","ist"];for(const r of s)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!==vt.STATUS_USER_CLOSED&&(this._status=vt.STATUS_NOT_READY,this._error=vt.NETWORK_ERROR)}function sT(c){console.log("onTransportData",c);const s=c.transport;let r=c.message;if(r=Xg.parseMessage(r,this),!!r&&!(this._status===vt.STATUS_USER_CLOSED&&r instanceof fu.IncomingRequest)&&Qg(r,this,s)){if(r instanceof fu.IncomingRequest)r.transport=s,this.receiveRequest(r);else if(r instanceof fu.IncomingResponse){let o;switch(r.method){case Tt.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case Tt.ACK:break;default:o=this._transactions.nict[r.via_branch],o&&o.receiveResponse(r);break}}}}const nT=ke(a_);for(var Et=[],hu=0;hu<256;++hu)Et.push((hu+256).toString(16).slice(1));function rT(c,s=0){return(Et[c[s+0]]+Et[c[s+1]]+Et[c[s+2]]+Et[c[s+3]]+"-"+Et[c[s+4]]+Et[c[s+5]]+"-"+Et[c[s+6]]+Et[c[s+7]]+"-"+Et[c[s+8]]+Et[c[s+9]]+"-"+Et[c[s+10]]+Et[c[s+11]]+Et[c[s+12]]+Et[c[s+13]]+Et[c[s+14]]+Et[c[s+15]]).toLowerCase()}var ho,iT=new Uint8Array(16);function lT(){if(!ho&&(ho=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ho))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ho(iT)}var oT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const u_={randomUUID:oT};function c_(c,s,r){if(u_.randomUUID&&!s&&!c)return u_.randomUUID();c=c||{};var o=c.random||(c.rng||lT)();if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,s){r=r||0;for(var a=0;a<16;++a)s[r+a]=o[a];return s}return rT(o)}var Me=mt();const Ln=ke(Me),du=new mf("Dialog"),Os={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};class po{static get C(){return Os}constructor(s,r,o,a=Os.STATUS_CONFIRMED){if(this._owner=s,this._ua=s._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,r instanceof Ut.IncomingResponse&&(a=r.status_code<200?Os.STATUS_EARLY:Os.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),du.debug(`new ${o} dialog created with status ${this._state===Os.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(s){this._local_seqnum=s}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(s){this._uac_pending_reply=s}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Os.STATUS_TERMINATED}update(s,r){this._state=Os.STATUS_CONFIRMED,du.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){du.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Os.STATUS_TERMINATED}sendRequest(s,r={}){const o=Ln.cloneArray(r.extraHeaders),a=Ln.cloneObject(r.eventHandlers),t=r.body||null,n=this._createRequest(s,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new jm(this,n,a).send(),n}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===j.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===j.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,r,o){r=Ln.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===j.CANCEL||s===j.ACK?this._local_seqnum:this._local_seqnum+=1;return new Ut.OutgoingRequest(s,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(s){if(!this._remote_seqnum)this._remote_seqnum=s.cseq;else if(s.cseq<this._remote_seqnum)if(s.method===j.ACK){if(this._ack_seqnum===null||s.cseq!==this._ack_seqnum)return!1}else return s.reply(500),!1;else s.cseq>this._remote_seqnum&&(this._remote_seqnum=s.cseq);if(s.method===j.INVITE||s.method===j.UPDATE&&s.body){if(this._uac_pending_reply===!0)s.reply(491);else if(this._uas_pending_reply===!0){const r=(Math.random()*10|0)+1;return s.reply(500,null,[`Retry-After:${r}`]),!1}else{this._uas_pending_reply=!0;const r=()=>{(s.server_transaction.state===$t.C.STATUS_ACCEPTED||s.server_transaction.state===$t.C.STATUS_COMPLETED||s.server_transaction.state===$t.C.STATUS_TERMINATED)&&(s.server_transaction.removeListener("stateChanged",r),this._uas_pending_reply=!1)};s.server_transaction.on("stateChanged",r)}s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===$t.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===j.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===$t.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}}class aT{constructor(s,r){Jt(this,"plugin",null);Jt(this,"rtcpPeer",null);Jt(this,"handleId",0);Jt(this,"info",null);Jt(this,"joinResult",null);Jt(this,"state",{});Jt(this,"stream",null);Jt(this,"loaded",!1);Jt(this,"aTracks",[]);Jt(this,"vTracks",[]);this.info=s,this.plugin=r,this.rtcpPeer=new RTCPeerConnection({iceServers:[]})}get memberInfo(){return{stream:this.stream,joinResult:this.joinResult,sender:this.handleId,type:"subscriber",name:this.info.display,state:this.state,id:this.handleId}}updateMemberState(s){var r;this.state={...this.state,...s||{}},(r=this.plugin)==null||r.session.emit("member:update",this.memberInfo)}updateMemberStateFromMessage(s){var t,n,p,_;const r=(n=(t=s==null?void 0:s.plugindata)==null?void 0:t.data)==null?void 0:n.newStatePublisher,a=((_=(p=s==null?void 0:s.plugindata)==null?void 0:p.data)==null?void 0:_.publisher_state).find(d=>d.id===r);this.updateMemberState(a==null?void 0:a.state)}hangup(){this.rtcpPeer&&(this.rtcpPeer.close(),this.rtcpPeer=null),this.plugin.session.emit("member:hangup",{info:this.info,sender:this.handleId}),this.plugin.send({janus:"detach"},{handle_id:this.handleId}).catch(console.log)}}var uT=fs();const $n=ke(uT),J=new mf("JanusSession"),cT="/opt/recordings/",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},mo=["audio","video"];class go extends ut.EventEmitter{static get C(){return te}constructor(s){J.debug("new"),super(),console.log("constructor call"),this._id=null,this._ua=s,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:j.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._candidates=[],this.publishers=[],this.private_id=null,this.memberList={},this.myFeedList=[],this.display_name="",this.stunServers=[{urls:"stun:turn.voicenter.co",credential:"kxsjahnsdjns3eds23esd",username:"turn2es21e"}];const r=c_().replace(/-/g,"").slice(0,12);this.opaque_id=`videoroomtest-${r}`,this._data={}}get C(){return te}get causes(){return j.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(s){this._data=s}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(s,r,o={},a){J.debug("connect()"),this.display_name=r;const t=s,n=Me.cloneObject(o.eventHandlers),p=Me.cloneArray(o.extraHeaders),_=Me.cloneObject(o.mediaConstraints,{audio:!0,video:!0}),d=o.mediaStream||null,g=Me.cloneObject(o.pcConfig,{iceServers:[]}),T=o.rtcConstraints||null,E=o.rtcOfferConstraints||null;if(this._rtcOfferConstraints=E,this._rtcAnswerConstraints=o.rtcAnswerConstraints||null,this._data=o.data||this._data,s===void 0)throw new TypeError("Not enough arguments");if(this._status!==te.STATUS_NULL)throw new Is.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Is.NotSupportedError("WebRTC not supported");if(console.log("target",s),s=this._ua.normalizeTarget(s),console.log("normalizeTarget target",s),this.room_id=s.user,!s)throw new TypeError(`Invalid target: ${t}`);this._sessionTimers.enabled&&Me.isDecimal(o.sessionTimersExpires)&&(o.sessionTimersExpires>=j.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=o.sessionTimersExpires:this._sessionTimers.defaultExpires=j.SESSION_EXPIRES);for(const C in n)Object.prototype.hasOwnProperty.call(n,C)&&this.on(C,n[C]);this._from_tag=Me.newTag();const y=o.anonymous||!1,A={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:y,outbound:!0}),y?(A.from_display_name="Anonymous",A.from_uri=new $n("sip","anonymous","anonymous.invalid"),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),p.push("Privacy: id")):o.fromUserName&&(A.from_uri=new $n("sip",o.fromUserName,this._ua.configuration.uri.host),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(A.from_display_name=o.fromDisplayName),p.push(`Contact: ${this._contact}`),p.push("Content-Type: application/json"),this._sessionTimers.enabled&&p.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Ut.InitialOutgoingInviteRequest(s,this._ua,A,p),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(g,T),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,console.log("this._remote_identity",this._remote_identity),a&&a(this),this._newJanusSession("local",this._request),this._sendInitialRequest(_,E,d)}init_incoming(s,r){J.debug("init_incoming()");let o;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=te.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(o=s.getHeader("expires")*1e3),s.to_tag=Me.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=te.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),this._failed("local",null,j.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===te.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),this._failed("system",null,j.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,r&&r(this),this._newJanusSession("remote",s),this._status!==te.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(s={}){J.debug("answer()");const r=this._request,o=Me.cloneArray(s.extraHeaders),a=Me.cloneObject(s.mediaConstraints),t=s.mediaStream||null,n=Me.cloneObject(s.pcConfig,{iceServers:[]}),p=s.rtcConstraints||null,_=s.rtcAnswerConstraints||null,d=Me.cloneObject(s.rtcOfferConstraints);let g,T=!1,E=!1,y=!1,A=!1;if(this._rtcAnswerConstraints=_,this._rtcOfferConstraints=s.rtcOfferConstraints||null,this._data=s.data||this._data,this._direction!=="incoming")throw new Is.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==te.STATUS_WAITING_FOR_ANSWER)throw new Is.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Me.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=j.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=j.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 C=r.parseSDP();Array.isArray(C.media)||(C.media=[C.media]);for(const I of C.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(n,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,j.causes.USER_DENIED_MEDIA_ACCESS),J.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};J.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,j.causes.WEBRTC_ERROR),J.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,j.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==te.STATUS_TERMINATED&&J.warn(I)})}terminate(s={}){J.debug("terminate()");const r=s.cause||j.causes.BYE,o=Me.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,p=s.reason_phrase;if(this._status===te.STATUS_TERMINATED)throw new Is.InvalidStateError(this._status);switch(this._status){case te.STATUS_NULL:case te.STATUS_INVITE_SENT:case te.STATUS_1XX_RECEIVED:if(J.debug("canceling session"),n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(p=p||j.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;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,j.causes.CANCELED);break;case te.STATUS_WAITING_FOR_ANSWER:case te.STATUS_ANSWERED:if(J.debug("rejecting session"),n=n||480,n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._request.reply(n,p,o,a),this._failed("local",null,j.causes.REJECTED);break;case te.STATUS_WAITING_FOR_ACK:case te.STATUS_CONFIRMED:if(J.debug("terminating session"),p=s.reason_phrase||j.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${p}"`),this._status===te.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==$t.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===j.ACK&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===$t.C.STATUS_TERMINATED&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,console.log("SET DIALOG terminate"),this._ua.newDialog(_)}else this.sendRequest(j.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendInfo(s,r,o={}){if(J.debug("sendInfo()"),this._status!==te.STATUS_CONFIRMED&&this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_1XX_RECEIVED)throw new Is.InvalidStateError(this._status);new Ja(this).send(s,r,o)}mute(s={audio:!0,video:!1}){J.debug("mute()");let r=!1,o=!1;this._audioMuted===!1&&s.audio&&(r=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&s.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(r===!0||o===!0)&&this._onmute({audio:r,video:o})}unmute(s={audio:!0,video:!0}){J.debug("unmute()");let r=!1,o=!1;this._audioMuted===!0&&s.audio&&(r=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&s.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(r===!0||o===!0)&&this._onunmute({audio:r,video:o})}hold(s={},r){if(J.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:j.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}unhold(s={},r){if(J.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:j.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}renegotiate(s={},r){J.debug("renegotiate()");const o=s.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:j.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}),!0}refer(s,r){J.debug("refer()");const o=s;if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${o}`);const a=new lg(this);a.sendRefer(s,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(s,r){return J.debug("sendRequest()"),this._dialog.sendRequest(s,r)}receiveNotify(s){J.debug("receiveRequest()")}receiveRequest(s){if(J.debug("receiveRequest()"),s.method===j.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",s,j.causes.CANCELED));else switch(s.method){case j.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(!s.body){this.terminate({cause:j.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:s.body};J.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",s)}).catch(a=>{this.terminate({cause:j.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",s);break;case j.BYE:this._status===te.STATUS_CONFIRMED||this._status===te.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,j.causes.BYE)):this._status===te.STATUS_INVITE_RECEIVED||this._status===te.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,j.causes.BYE)):s.reply(403,"Wrong Status");break;case j.INVITE:this._status===te.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case j.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=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;r&&r.match(/^application\/dtmf-relay/i)?new zm(this).init_incoming(s):r!==void 0?new Ja(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case j.UPDATE:this._status===te.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case j.REFER:this._status===te.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case j.NOTIFY:this._status===te.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){J.warn("onTransportError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.CONNECTION_ERROR,cause:j.causes.CONNECTION_ERROR})}onRequestTimeout(){J.warn("onRequestTimeout()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:j.causes.REQUEST_TIMEOUT,cause:j.causes.REQUEST_TIMEOUT})}onDialogError(){J.warn("onDialogError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.DIALOG_ERROR,cause:j.causes.DIALOG_ERROR})}newDTMF(s){J.debug("newDTMF()"),this.emit("newDTMF",s)}newInfo(s){J.debug("newInfo()"),this.emit("newInfo",s)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(J.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(J.debug("_isReadyToReOffer() | session not established yet"),!1):(J.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(J.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(J.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(s){J.warn("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(s,r){let o=Fr.T1;function a(){this._status===te.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],r),o<Fr.T2&&(o=o*2,o>Fr.T2&&(o=Fr.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&&(J.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(j.BYE),this._ended("remote",null,j.causes.NO_ACK))},Fr.TIMER_H)}_createRTCConnection(s,r){this.stunServers,this._connection=new RTCPeerConnection(s,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:j.causes.RTP_TIMEOUT,status_code:408,reason_phrase:j.causes.RTP_TIMEOUT})});let o;const a=t=>{this._connection.signalingState!=="stable"&&this._connection.signalingState!=="have-local-offer"||t.candidate&&(this._candidates.push(t.candidate),clearTimeout(o),o=setTimeout(()=>{this.lastTrickleReceived=!0,this.subscribeSent&&!this.isConfigureSent&&this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{})},500))};this._connection.onicecandidate=a,J.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(s,r){if(J.debug("createLocalDescription()"),s!=="offer"&&s!=="answer")throw new Error(`createLocalDescription() | invalid type "${s}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>s==="offer"?o.createOffer(r).catch(a=>(J.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(r).catch(a=>(J.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,J.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:s,sdp:o.localDescription.sdp};return J.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let n=!1,p,_;this._iceReady=!1;const d=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",_),n=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:s,sdp:o.localDescription.sdp};J.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}):n||d()}),o.addEventListener("icegatheringstatechange",_=()=>{o.iceGatheringState==="complete"&&!n&&d()})})})}_createDialog(s,r,o){console.log("_createDialog",s);const a=r==="UAS"?s.to_tag:s.from_tag,t=r==="UAS"?s.from_tag:s.to_tag,n=s.call_id+a+t;console.log("remote_tag",t);let p=this._earlyDialogs[n];if(o)return p?!0:(p=new po(this,s,r,po.C.STATUS_EARLY),console.log("SET DIALOG early"),p.error?(console.log("early_dialog error",p.error),J.debug(p.error),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,r),console.log("SET DIALOG 1"),this._dialog=p,delete this._earlyDialogs[n],!0;const _=new po(this,s,r);return _.error?(console.log("dialog.error",_.error),J.debug(_.error),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(console.log("AAA SET DIALOG 2"),this._dialog=_,!0)}}_receiveReinvite(s){J.debug("receiveReinvite()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,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: ${_}`);s.reply(_,d,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!s.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=>{n.call(this,p)}).catch(()=>{s.reply(500)});return}if(r!=="application/sdp"){J.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==te.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{J.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),this._late_sdp&&(p=this._mangleOffer(p)),s.reply(200,null,_,p,()=>{this._status=te.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(s){J.debug("receiveUpdate()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,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: ${_}`);s.reply(_,d,g)}if(this.emit("update",o),a)return;if(!s.body){n.call(this,null);return}if(r!=="application/sdp"){J.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==te.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{J.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),s.reply(200,null,_,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(s){J.debug("_processInDialogSdpOffer()");const r=s.parseSDP();let o=!1;for(const n of r.media){if(mo.indexOf(n.type)===-1)continue;const p=n.direction||r.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:s.body};J.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(n=>{throw s.reply(488),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),this.emit("peerconnection:setremotedescriptionfailed",n),n})}).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(n=>{throw s.reply(500),J.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',n),n})}).catch(n=>{J.warn("_processInDialogSdpOffer() failed [error: %o]",n)}),this._connectionPromiseQueue}_receiveRefer(s){if(J.debug("receiveRefer()"),!s.refer_to){J.debug("no Refer-To header field present in REFER"),s.reply(400);return}if(s.refer_to.uri.scheme!==j.SIP){J.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const r=new sg(this,s.cseq);J.debug('emit "refer"'),this.emit("refer",{request:s,accept:(t,n)=>{o.call(this,t,n)},reject:()=>{a.call(this)}});function o(t,n={}){if(t=typeof t=="function"?t:null,this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const p=new go(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)}),s.refer_to.uri.hasHeader("replaces")){const _=decodeURIComponent(s.refer_to.uri.getHeader("replaces"));n.extraHeaders=Me.cloneArray(n.extraHeaders),n.extraHeaders.push(`Replaces: ${_}`)}p.connect(s.refer_to.uri.toAor(),n,t)}function a(){r.notify(603)}}_receiveNotify(s){switch(J.debug("receiveNotify()"),s.event||s.reply(400),s.event.event){case"refer":{let r,o;if(s.event.params&&s.event.params.id)r=s.event.params.id,o=this._referSubscribers[r];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{s.reply(400,"Missing event id parameter");return}if(!o){s.reply(481,"Subscription does not exist");return}o.receiveNotify(s),s.reply(200);break}default:s.reply(489)}}_receiveReplaces(s){J.debug("receiveReplaces()");function r(a){if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const t=new go(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(s,a)}function o(){J.debug("Replaced INVITE rejected by the user"),s.reply(486)}this.emit("replaces",{request:s,accept:a=>{r.call(this,a)},reject:()=>{o.call(this)}})}_getNextTransactionId(){return(this.lastTransaction+1).toString()}_sendInitialRequest(s,r,o){this.ackSent=!1,this.publisherSubscribeSent=!1;const a=new Nf(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(s.audio||s.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(s).catch(t=>{throw this._status===te.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,j.causes.USER_DENIED_MEDIA_ACCESS),J.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(n=>{this._connection.addTrack(n,t)}),this._connecting(this._request),this._createLocalDescription("offer",r).catch(n=>{throw this._failed("local",null,j.causes.WEBRTC_ERROR),n})}).then(t=>{if(this._is_canceled||this._status===te.STATUS_TERMINATED)throw new Error("terminated");const n={janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:this.opaque_id},p=JSON.stringify(n);this._request.body=p,this._status=te.STATUS_INVITE_SENT,J.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==te.STATUS_TERMINATED&&J.warn(t)})}requestAudioAndVideoPermissions(){return console.log("MMM requestAudioAndVideoPermissions"),this.loadStream()}async loadStream(){const s={audio:!0,video:!0};try{this.stream=await navigator.mediaDevices.getUserMedia(s)}catch{try{s.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(s)}catch{s.audio=!1,s.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(s)}}return{stream:this.stream,options:s}}addTracks(s){s.forEach(r=>{this._connection.addTrack(r)})}getRecordFileName(){return cT+this.room_id+btoa(unescape(encodeURIComponent(this.displayName)))+Date.now()}async processIceCandidates(){for(let s=0;s<this.iceCandidates.length;s++)await this._connection.addIceCandidate(this.iceCandidates[s]);this.iceCandidates=[]}async _sendConfigureMessage(s){const r={offerToReceiveAudio:!1,offerToReceiveVideo:!1},o=await this._connection.createOffer(r);await this._connection.setLocalDescription(o);const a=this._candidates.map(_=>({janus:"trickle",candidate:_,handle_id:this.handle_id,session_id:this.session_id})),n={configure:{janus:"message",body:{request:"configure",record:!0,filename:this.getRecordFileName(),...s},jsep:o,handle_id:this.handle_id,session_id:this.session_id},trickles:[...a]},p=["Content-Type: application/json","PTYPE: Ice"];this.sendRequest(j.INFO,{extraHeaders:p,body:JSON.stringify(n),eventHandlers:{onSuccessResponse:async _=>{this.isConfigureSent=!0;const g=_.data.split(`\r
|
135
|
-
`),T=g[g.length-1],E=JSON.parse(T);await this._connection.setRemoteDescription(E.jsep),this._candidates=[]}}})}_sendMemberStartMessage(s,r){const o={janus:"message",body:{request:"start",room:this.room_id},handle_id:s.handleId,session_id:this.session_id,jsep:r},a=["Content-Type: application/json","PTYPE: Configure"];this.sendRequest(j.INFO,{extraHeaders:a,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async t=>{t.status_code===200&&await s.rtcpPeer.setLocalDescription(r)}}})}_sendTrickleMessage(s){const o={trickles:[...s.map(t=>({janus:"trickle",candidate:t,handle_id:this.handle_id,session_id:this.session_id}))]},a=["PTYPE: Trickle"];this.sendRequest(j.INFO,{extraHeaders:a,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async t=>{console.log("_sendTrickleMessage",t)}}})}async _answerAttachedStream(s,r){let o=null;const a=async _=>{if(!s.rtcpPeer||s.loaded)return;{s.loaded=!0;const y={audio:!0,video:!0};await new Promise(A=>{setTimeout(A,100)}),o=await s.rtcpPeer.createAnswer(y),this._sendMemberStartMessage(s,o)}const d=_.streams[0].getAudioTracks(),g=_.streams[0].getVideoTracks(),T=[];d[0]&&T.push(d[0]),g[0]&&T.push(g[0]);const E=new MediaStream(T);s.stream=E,this._ua.emit("memberJoin",s.memberInfo)};let t,n=[];const p=_=>{s.rtcpPeer.signalingState!=="stable"&&s.rtcpPeer.signalingState!=="have-local-offer"||(n.push(_.candidate||null),clearTimeout(t),t=setTimeout(()=>{this._sendTrickleMessage(n)},500))};s.rtcpPeer=new RTCPeerConnection,s.rtcpPeer.ontrack=a,s.rtcpPeer.onicecandidate=p,s.rtcpPeer.sender=r.sender,await s.rtcpPeer.setRemoteDescription(r.jsep)}_sendJoinMemberRequest(s){const r={janus:"message",body:{request:"join",room:this.room_id,feed:s.info.id,ptype:"subscriber"},handle_id:s.handleId,session_id:this.session_id},o=["PTYPE: Subscriber"];this.sendRequest(j.SUBSCRIBE,{extraHeaders:o,body:JSON.stringify(r),eventHandlers:{onSuccessResponse:async a=>{var t,n;if(a.status_code===200){const p=JSON.parse(a.body);(n=(t=p==null?void 0:p.plugindata)==null?void 0:t.data)!=null&&n.id&&await this._answerAttachedStream(s,p)}}}})}_attachMember(s){const r={janus:"attach",opaque_id:this.opaque_id,plugin:"janus.plugin.videoroom",session_id:this.session_id},o=["PTYPE: Subscriber"];this.sendRequest(j.INFO,{extraHeaders:o,body:JSON.stringify(r),eventHandlers:{onSuccessResponse:async a=>{if(a.status_code===200){const n=JSON.parse(a.body).data.id;s.handleId=n,this._sendJoinMemberRequest(s)}}}})}receivePublishers(s){var o,a,t,n,p,_,d,g;const r={...this.memberList};(a=(o=s==null?void 0:s.plugindata)==null?void 0:o.data)==null||a.publishers.forEach(T=>{delete r[T.id],!this.memberList[T.id]&&!this.myFeedList.includes(T.id)&&T.clientID!==this.client_id&&(this.memberList[T.id]=new aT(T,this),this._attachMember(this.memberList[T.id]))}),((n=(t=s==null?void 0:s.plugindata)==null?void 0:t.data)==null?void 0:n.videoroom)==="synced"&&Object.keys(r).forEach(T=>{r[T].hangup(),delete this.memberList[T]}),this.publishers=(_=(p=s==null?void 0:s.plugindata)==null?void 0:p.data)==null?void 0:_.publishers,this.private_id=(g=(d=s==null?void 0:s.plugindata)==null?void 0:d.data)==null?void 0:g.private_id}_receiveInviteResponse(s){if(J.debug("receiveInviteResponse()"),console.log("_receiveInviteResponse response",s),console.log("dialog",this._dialog),this._dialog&&s.status_code>=200&&s.status_code<=299&&!this.ackSent)if(console.log("IF 1 dialog"),this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.ackSent=!0,this.sendRequest(j.ACK);return}else{const r=new po(this,s,"UAC");if(r.error!==void 0){J.debug(r.error);return}this.sendRequest(j.ACK),this.sendRequest(j.BYE);return}if(this.ackSent&&!this.publisherSubscribeSent){const r=JSON.parse(s.body);this.requestAudioAndVideoPermissions().then(()=>{this.session_id=r.session_id,this.handle_id=r.data.id,this.client_id=c_();const o={janus:"message",body:{request:"join",room:this.room_id,ptype:"publisher",display:this.display_name,clientID:this.client_id,opaque_id:this.opaque_id},handle_id:this.handle_id},a=["PTYPE: Publisher"];this.sendRequest(j.SUBSCRIBE,{extraHeaders:a,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async t=>{t.status_code===200&&(this.subscribeSent=!0,this.lastTrickleReceived&&!this.isConfigureSent&&(this.addTracks(this.stream.getTracks()),this._ua.emit("changeMainVideoStream",{name:this.display_name,stream:this.stream}),this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{})))}}}),this.publisherSubscribeSent=!0})}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==te.STATUS_INVITE_SENT&&this._status!==te.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(s.status_code):this._status=te.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){J.debug("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=te.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const r={originator:"remote",type:"answer",sdp:s.body};J.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",s)).catch(a=>{J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(this._status=te.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,j.causes.MISSING_SDP),this._failed("remote",s,j.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;break}default:{const r=Me.sipErrorCause(s.status_code);this._failed("remote",s,r)}}}_sendReinvite(s={}){J.debug("sendReinvite()");const r=Me.cloneArray(s.extraHeaders),o=Me.cloneObject(s.eventHandlers),a=s.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:_};J.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(j.INVITE,{extraHeaders:r,body:_,eventHandlers:{onSuccessResponse:g=>{n.call(this,g),t=!0},onErrorResponse:g=>{p.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function n(_){if(this._status===te.STATUS_TERMINATED||(this.sendRequest(j.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};J.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),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',T),this.emit("peerconnection:setremotedescriptionfailed",T)})}function p(_){o.failed&&o.failed(_)}}_sendUpdate(s={}){J.debug("sendUpdate()");const r=Me.cloneArray(s.extraHeaders),o=Me.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null,t=s.sdpOffer||!1;let n=!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};J.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(j.UPDATE,{extraHeaders:r,body:d,eventHandlers:{onSuccessResponse:T=>{p.call(this,T),n=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(j.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&&!n)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};J.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),J.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(s,r,o){J.debug("acceptAndTerminate()");const a=[];r&&(o=o||j.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest(j.ACK),this.sendRequest(j.BYE,{extraHeaders:a})),this._status=te.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=Dt.parse(s),this._localHold&&!this._remoteHold){J.debug("mangleOffer() | me on hold, mangling offer");for(const r of s.media)mo.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){J.debug("mangleOffer() | both on hold, mangling offer");for(const r of s.media)mo.indexOf(r.type)!==-1&&(r.direction="inactive")}else if(this._remoteHold){J.debug("mangleOffer() | remote on hold, mangling offer");for(const r of s.media)mo.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="recvonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="recvonly")}return Dt.write(s)}_setLocalMediaStatus(){let s=!0,r=!0;(this._localHold||this._remoteHold)&&(s=!1,r=!1),this._audioMuted&&(s=!1),this._videoMuted&&(r=!1),this._toggleMuteAudio(!s),this._toggleMuteVideo(!r)}_handleSessionTimersInIncomingRequest(s,r){if(!this._sessionTimers.enabled)return;let o;s.session_expires&&s.session_expires>=j.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,o=s.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(s){if(!this._sessionTimers.enabled)return;let r;s.session_expires&&s.session_expires>=j.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,r=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}_runSessionTimer(){const s=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()&&(J.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===j.UPDATE?this._sendUpdate():this._sendReinvite())},s*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==te.STATUS_TERMINATED&&(J.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:j.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},s*1100)}_toggleMuteAudio(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of r)o.track.enabled=!s}_toggleMuteVideo(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of r)o.track.enabled=!s}_newJanusSession(s,r){J.debug("newRTCSession()"),this._ua.newJanusSession(this,{originator:s,session:this,request:r})}_connecting(s){J.debug("session connecting"),J.debug('emit "connecting"'),this.emit("connecting",{request:s})}_progress(s,r){J.debug("session progress"),J.debug('emit "progress"'),this.emit("progress",{originator:s,response:r||null})}_accepted(s,r){J.debug("session accepted"),this._start_time=new Date,J.debug('emit "accepted"'),this.emit("accepted",{originator:s,response:r||null})}_confirmed(s,r){J.debug("session confirmed"),this._is_confirmed=!0,J.debug('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:r||null})}_ended(s,r,o){J.debug("session ended"),this._end_time=new Date,this._close(),J.debug('emit "ended"'),this.emit("ended",{originator:s,message:r||null,cause:o})}_failed(s,r,o){J.debug("session failed"),J.debug('emit "_failed"'),this.emit("_failed",{originator:s,message:r||null,cause:o}),this._close(),J.debug('emit "failed"'),this.emit("failed",{originator:s,message:r||null,cause:o})}_onhold(s){J.debug("session onhold"),this._setLocalMediaStatus(),J.debug('emit "hold"'),this.emit("hold",{originator:s})}_onunhold(s){J.debug("session onunhold"),this._setLocalMediaStatus(),J.debug('emit "unhold"'),this.emit("unhold",{originator:s})}_onmute({audio:s,video:r}){J.debug("session onmute"),this._setLocalMediaStatus(),J.debug('emit "muted"'),this.emit("muted",{audio:s,video:r})}_onunmute({audio:s,video:r}){J.debug("session onunmute"),this._setLocalMediaStatus(),J.debug('emit "unmuted"'),this.emit("unmuted",{audio:s,video:r})}}class Hn{constructor(s){if(this.headers={},s.length>0){let r=!1;const o=s.split(`\r
|
134
|
+
`,s_.send(o)}const qg=ke(n_);var Qr={};const kn=mt(),en=De,ou=es(),r_=fs(),au=eu,uu=ds;Qr.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:en.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:en.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:en.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${kn.createRandomToken(12)}.invalid`};const fo={mandatory:{sockets(c){const s=[];if(au.isSocket(c))s.push({socket:c});else if(Array.isArray(c)&&c.length)for(const r of c)Object.prototype.hasOwnProperty.call(r,"socket")&&au.isSocket(r.socket)?s.push(r):au.isSocket(r)&&s.push({socket:r});else return;return s},uri(c){/^sip:/i.test(c)||(c=`${en.SIP}:${c}`);const s=r_.parse(c);if(s)return s.user?s:void 0}},optional:{authorization_user(c){if(ou.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(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},connection_recovery_min_interval(c){if(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},contact_uri(c){if(typeof c=="string"){const s=ou.parse(c,"SIP_URI");if(s!==-1)return s}},display_name(c){return c},instance_id(c){if(/^uuid:/i.test(c)&&(c=c.substr(5)),ou.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},session_timers(c){if(typeof c=="boolean")return c},session_timers_refresh_method(c){if(typeof c=="string"&&(c=c.toUpperCase(),c===en.INVITE||c===en.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(kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},registrar_server(c){/^sip:/i.test(c)||(c=`${en.SIP}:${c}`);const s=r_.parse(c);if(s)return s.user?void 0:s},use_preloaded_route(c){if(typeof c=="boolean")return c},extra_headers(c){const s=[];if(Array.isArray(c)&&c.length)for(const r of c)typeof r=="string"&&s.push(r);else return;return s}}};Qr.load=(c,s)=>{for(const r in fo.mandatory)if(s.hasOwnProperty(r)){const o=s[r],a=fo.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new uu.ConfigurationError(r,o)}else throw new uu.ConfigurationError(r);for(const r in fo.optional)if(s.hasOwnProperty(r)){const o=s[r];if(kn.isEmpty(o))continue;const a=fo.optional[r](o);if(a!==void 0)c[r]=a;else throw new uu.ConfigurationError(r,o)}};const Bg=ut.EventEmitter,Gg=lt,Tt=De,Wg=xm,i_=Jf,l_=Tg,o_=Ag,cu=xn,Kg=Zf,_o=mt(),Yg=ds,Jg=fs(),zg=su,fu=Ut,Xg=n_,_u=Qr,qe=new Gg("UA"),vt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var a_=class extends Bg{static get C(){return vt}constructor(s){if(qe.debug("new() [configuration:%o]",s),super(),this._cache={credentials:{}},this._configuration=Object.assign({},_u.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=vt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,s===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(s)}catch(r){throw this._status=vt.STATUS_NOT_READY,this._error=vt.CONFIGURATION_ERROR,r}this._registrator=new Wg(this)}get C(){return vt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){qe.debug("start()"),this._status===vt.STATUS_INIT?this._transport.connect():this._status===vt.STATUS_USER_CLOSED?(qe.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=vt.STATUS_INIT,this._transport.connect()):this._status===vt.STATUS_READY?qe.debug("UA is in READY status, not restarted"):qe.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){qe.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(s){qe.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(s)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(s,r){qe.debug("call()");const o=new i_(this);return o.connect(s,r),o}sendMessage(s,r,o){qe.debug("sendMessage()");const a=new l_(this);return a.send(s,r,o),a}sendOptions(s,r,o){qe.debug("sendOptions()");const a=new o_(this);return a.send(s,r,o),a}terminateSessions(s){qe.debug("terminateSessions()");for(const r in this._sessions)this._sessions[r].isEnded()||this._sessions[r].terminate(s)}stop(){if(qe.debug("stop()"),this._dynConfiguration={},this._status===vt.STATUS_USER_CLOSED){qe.debug("UA already closed");return}this._registrator.close();const s=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){qe.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=vt.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&&s===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(s){return _o.normalizeTarget(s,this._configuration.hostport_params)}get(s){switch(s){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:qe.warn('get() | cannot get "%s" parameter in runtime',s);return}}set(s,r){switch(s){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 qe.warn('set() | cannot set "%s" parameter in runtime',s),!1}return!0}newTransaction(s){this._transactions[s.type][s.id]=s,this.emit("newTransaction",{transaction:s})}destroyTransaction(s){delete this._transactions[s.type][s.id],this.emit("transactionDestroyed",{transaction:s})}newDialog(s){this._dialogs[s.id]=s}destroyDialog(s){delete this._dialogs[s.id]}newMessage(s,r){this._applicants[s]=s,this.emit("newMessage",r)}newOptions(s,r){this._applicants[s]=s,this.emit("newOptions",r)}destroyMessage(s){delete this._applicants[s]}newRTCSession(s,r){this._sessions[s.id]=s,this.emit("newRTCSession",r)}destroyRTCSession(s){delete this._sessions[s.id]}registered(s){this.emit("registered",s)}unregistered(s){this.emit("unregistered",s)}registrationFailed(s){this.emit("registrationFailed",s)}receiveRequest(s){const r=s.method;if(s.ruri.user!==this._configuration.uri.user&&s.ruri.user!==this._contact.uri.user){qe.debug("Request-URI does not point to us"),s.method!==Tt.ACK&&s.reply_sl(404);return}if(s.ruri.scheme===Tt.SIPS){s.reply_sl(416);return}if(cu.checkTransaction(this,s))return;if(r===Tt.INVITE?new cu.InviteServerTransaction(this,this._transport,s):r!==Tt.ACK&&r!==Tt.CANCEL&&new cu.NonInviteServerTransaction(this,this._transport,s),r===Tt.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new o_(this).init_incoming(s)}else if(r===Tt.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new l_(this).init_incoming(s)}else if(r===Tt.INVITE&&!s.to_tag&&this.listeners("newRTCSession").length===0){s.reply(405);return}let o,a;if(s.to_tag)o=this._findDialog(s.call_id,s.from_tag,s.to_tag),o?o.receiveRequest(s):r===Tt.NOTIFY?(a=this._findSession(s),a?a.receiveRequest(s):(qe.debug("received NOTIFY request for a non existent subscription"),s.reply(481,"Subscription does not exist"))):r!==Tt.ACK&&s.reply(481);else switch(r){case Tt.INVITE:if(window.RTCPeerConnection)if(s.hasHeader("replaces")){const t=s.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?s.reply(603):a.receiveRequest(s)):s.reply(481)}else a=new i_(this),a.init_incoming(s);else qe.warn("INVITE received but WebRTC is not supported"),s.reply(488);break;case Tt.BYE:s.reply(481);break;case Tt.CANCEL:a=this._findSession(s),a?a.receiveRequest(s):qe.debug("received CANCEL request for a non existent session");break;case Tt.ACK:break;case Tt.NOTIFY:this.emit("sipEvent",{event:s.event,request:s}),s.reply(200);break;default:s.reply(405);break}}_findSession({call_id:s,from_tag:r,to_tag:o}){const a=s+r,t=this._sessions[a],n=s+o,p=this._sessions[n];return t||p||null}_findDialog(s,r,o){let a=s+r+o,t=this._dialogs[a];return t||(a=s+o+r,t=this._dialogs[a],t||null)}_loadConfig(s){try{_u.load(this._configuration,s)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=_o.newUUID()),this._configuration.jssip_id=_o.createRandomToken(5);const r=this._configuration.uri.clone();r.user=null,this._configuration.hostport_params=r.toString().replace(/^sip:/i,"");try{this._transport=new Kg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Qg.bind(this),this._transport.onconnect=Zg.bind(this),this._transport.ondisconnect=eT.bind(this),this._transport.ondata=tT.bind(this)}catch(a){throw qe.warn(a),new Yg.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 Jg("sip",_o.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,n=a.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),n&&(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}));qe.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(_u.settings,a))switch(a){case"uri":case"registrar_server":qe.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":qe.debug(`- ${a}: NOT SHOWN`);break;default:qe.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}};function Qg(c){this.emit("connecting",c)}function Zg(c){this._status!==vt.STATUS_USER_CLOSED&&(this._status=vt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function eT(c){const s=["nict","ict","nist","ist"];for(const r of s)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!==vt.STATUS_USER_CLOSED&&(this._status=vt.STATUS_NOT_READY,this._error=vt.NETWORK_ERROR)}function tT(c){console.log("onTransportData",c);const s=c.transport;let r=c.message;if(r=zg.parseMessage(r,this),!!r&&!(this._status===vt.STATUS_USER_CLOSED&&r instanceof fu.IncomingRequest)&&Xg(r,this,s)){if(r instanceof fu.IncomingRequest)r.transport=s,this.receiveRequest(r);else if(r instanceof fu.IncomingResponse){let o;switch(r.method){case Tt.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case Tt.ACK:break;default:o=this._transactions.nict[r.via_branch],o&&o.receiveResponse(r);break}}}}const sT=ke(a_);for(var Et=[],hu=0;hu<256;++hu)Et.push((hu+256).toString(16).slice(1));function nT(c,s=0){return(Et[c[s+0]]+Et[c[s+1]]+Et[c[s+2]]+Et[c[s+3]]+"-"+Et[c[s+4]]+Et[c[s+5]]+"-"+Et[c[s+6]]+Et[c[s+7]]+"-"+Et[c[s+8]]+Et[c[s+9]]+"-"+Et[c[s+10]]+Et[c[s+11]]+Et[c[s+12]]+Et[c[s+13]]+Et[c[s+14]]+Et[c[s+15]]).toLowerCase()}var ho,rT=new Uint8Array(16);function iT(){if(!ho&&(ho=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ho))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ho(rT)}var lT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const u_={randomUUID:lT};function c_(c,s,r){if(u_.randomUUID&&!s&&!c)return u_.randomUUID();c=c||{};var o=c.random||(c.rng||iT)();if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,s){r=r||0;for(var a=0;a<16;++a)s[r+a]=o[a];return s}return nT(o)}var Me=mt();const Ln=ke(Me),du=new mf("Dialog"),Os={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};class po{static get C(){return Os}constructor(s,r,o,a=Os.STATUS_CONFIRMED){if(this._owner=s,this._ua=s._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,r instanceof Ut.IncomingResponse&&(a=r.status_code<200?Os.STATUS_EARLY:Os.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),du.debug(`new ${o} dialog created with status ${this._state===Os.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(s){this._local_seqnum=s}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(s){this._uac_pending_reply=s}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Os.STATUS_TERMINATED}update(s,r){this._state=Os.STATUS_CONFIRMED,du.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){du.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Os.STATUS_TERMINATED}sendRequest(s,r={}){const o=Ln.cloneArray(r.extraHeaders),a=Ln.cloneObject(r.eventHandlers),t=r.body||null,n=this._createRequest(s,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new Fm(this,n,a).send(),n}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===j.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===j.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,r,o){r=Ln.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===j.CANCEL||s===j.ACK?this._local_seqnum:this._local_seqnum+=1;return new Ut.OutgoingRequest(s,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(s){if(!this._remote_seqnum)this._remote_seqnum=s.cseq;else if(s.cseq<this._remote_seqnum)if(s.method===j.ACK){if(this._ack_seqnum===null||s.cseq!==this._ack_seqnum)return!1}else return s.reply(500),!1;else s.cseq>this._remote_seqnum&&(this._remote_seqnum=s.cseq);if(s.method===j.INVITE||s.method===j.UPDATE&&s.body){if(this._uac_pending_reply===!0)s.reply(491);else if(this._uas_pending_reply===!0){const r=(Math.random()*10|0)+1;return s.reply(500,null,[`Retry-After:${r}`]),!1}else{this._uas_pending_reply=!0;const r=()=>{(s.server_transaction.state===$t.C.STATUS_ACCEPTED||s.server_transaction.state===$t.C.STATUS_COMPLETED||s.server_transaction.state===$t.C.STATUS_TERMINATED)&&(s.server_transaction.removeListener("stateChanged",r),this._uas_pending_reply=!1)};s.server_transaction.on("stateChanged",r)}s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===$t.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===j.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===$t.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}}class oT{constructor(s,r){zt(this,"plugin",null);zt(this,"rtcpPeer",null);zt(this,"handleId",0);zt(this,"info",null);zt(this,"joinResult",null);zt(this,"state",{});zt(this,"stream",null);zt(this,"loaded",!1);zt(this,"aTracks",[]);zt(this,"vTracks",[]);this.info=s,this.plugin=r,this.rtcpPeer=new RTCPeerConnection({iceServers:[]})}get memberInfo(){return{stream:this.stream,joinResult:this.joinResult,sender:this.handleId,type:"subscriber",name:this.info.display,state:this.state,id:this.handleId}}updateMemberState(s){var r;this.state={...this.state,...s||{}},(r=this.plugin)==null||r.session.emit("member:update",this.memberInfo)}updateMemberStateFromMessage(s){var t,n,p,_;const r=(n=(t=s==null?void 0:s.plugindata)==null?void 0:t.data)==null?void 0:n.newStatePublisher,a=((_=(p=s==null?void 0:s.plugindata)==null?void 0:p.data)==null?void 0:_.publisher_state).find(h=>h.id===r);this.updateMemberState(a==null?void 0:a.state)}hangup(){this.rtcpPeer&&(this.rtcpPeer.close(),this.rtcpPeer=null),this.stream&&this.stream.getTracks().forEach(s=>{s.stop()})}}var aT=fs();const $n=ke(aT),z=new mf("JanusSession"),uT="/opt/recordings/",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},mo=["audio","video"];class go extends ut.EventEmitter{static get C(){return te}constructor(s){z.debug("new"),super(),console.log("constructor call"),this._id=null,this._ua=s,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:j.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._candidates=[],this.publishers=[],this.private_id=null,this.memberList={},this.myFeedList=[],this.display_name="",this.stunServers=[{urls:"stun:turn.voicenter.co",credential:"kxsjahnsdjns3eds23esd",username:"turn2es21e"}];const r=c_().replace(/-/g,"").slice(0,12);this.opaque_id=`videoroomtest-${r}`,this._data={}}get C(){return te}get causes(){return j.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(s){this._data=s}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(s,r,o={},a){z.debug("connect()"),this.display_name=r;const t=s,n=Me.cloneObject(o.eventHandlers),p=Me.cloneArray(o.extraHeaders),_=Me.cloneObject(o.mediaConstraints,{audio:!0,video:!0}),h=o.mediaStream||null,g=Me.cloneObject(o.pcConfig,{iceServers:[]}),T=o.rtcConstraints||null,E=o.rtcOfferConstraints||null;if(this._rtcOfferConstraints=E,this._rtcAnswerConstraints=o.rtcAnswerConstraints||null,this._data=o.data||this._data,s===void 0)throw new TypeError("Not enough arguments");if(this._status!==te.STATUS_NULL)throw new Is.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Is.NotSupportedError("WebRTC not supported");if(console.log("target",s),s=this._ua.normalizeTarget(s),console.log("normalizeTarget target",s),this.room_id=s.user,!s)throw new TypeError(`Invalid target: ${t}`);this._sessionTimers.enabled&&Me.isDecimal(o.sessionTimersExpires)&&(o.sessionTimersExpires>=j.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=o.sessionTimersExpires:this._sessionTimers.defaultExpires=j.SESSION_EXPIRES);for(const C in n)Object.prototype.hasOwnProperty.call(n,C)&&this.on(C,n[C]);this._from_tag=Me.newTag();const y=o.anonymous||!1,A={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:y,outbound:!0}),y?(A.from_display_name="Anonymous",A.from_uri=new $n("sip","anonymous","anonymous.invalid"),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),p.push("Privacy: id")):o.fromUserName&&(A.from_uri=new $n("sip",o.fromUserName,this._ua.configuration.uri.host),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(A.from_display_name=o.fromDisplayName),p.push(`Contact: ${this._contact}`),p.push("Content-Type: application/json"),this._sessionTimers.enabled&&p.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Ut.InitialOutgoingInviteRequest(s,this._ua,A,p),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(g,T),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,console.log("this._remote_identity",this._remote_identity),a&&a(this),this._newJanusSession("local",this._request),this._sendInitialRequest(_,E,h)}init_incoming(s,r){z.debug("init_incoming()");let o;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=te.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(o=s.getHeader("expires")*1e3),s.to_tag=Me.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=te.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),this._failed("local",null,j.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===te.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),this._failed("system",null,j.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,r&&r(this),this._newJanusSession("remote",s),this._status!==te.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(s={}){z.debug("answer()");const r=this._request,o=Me.cloneArray(s.extraHeaders),a=Me.cloneObject(s.mediaConstraints),t=s.mediaStream||null,n=Me.cloneObject(s.pcConfig,{iceServers:[]}),p=s.rtcConstraints||null,_=s.rtcAnswerConstraints||null,h=Me.cloneObject(s.rtcOfferConstraints);let g,T=!1,E=!1,y=!1,A=!1;if(this._rtcAnswerConstraints=_,this._rtcOfferConstraints=s.rtcOfferConstraints||null,this._data=s.data||this._data,this._direction!=="incoming")throw new Is.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==te.STATUS_WAITING_FOR_ANSWER)throw new Is.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Me.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=j.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=j.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 C=r.parseSDP();Array.isArray(C.media)||(C.media=[C.media]);for(const I of C.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&&!h.offerToReceiveAudio&&(a.audio=!1),!t&&!E&&!h.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(n,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,j.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,j.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,j.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==te.STATUS_TERMINATED&&z.warn(I)})}terminate(s={}){z.debug("terminate()");const r=s.cause||j.causes.BYE,o=Me.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,p=s.reason_phrase;if(this._status===te.STATUS_TERMINATED)throw new Is.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"),n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(p=p||j.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;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,j.causes.CANCELED);break;case te.STATUS_WAITING_FOR_ANSWER:case te.STATUS_ANSWERED:if(z.debug("rejecting session"),n=n||480,n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._request.reply(n,p,o,a),this._failed("local",null,j.causes.REJECTED);break;case te.STATUS_WAITING_FOR_ACK:case te.STATUS_CONFIRMED:if(z.debug("terminating session"),p=s.reason_phrase||j.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${p}"`),this._status===te.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==$t.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:h})=>{h===j.ACK&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate(),this.closeSession())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===$t.C.STATUS_TERMINATED&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate(),this.closeSession())}),this._ended("local",null,r),this._dialog=_,console.log("SET DIALOG terminate"),this._ua.newDialog(_)}else this.sendRequest(j.BYE,{extraHeaders:o,body:a}),this.closeSession(),this._ended("local",null,r)}}sendInfo(s,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 Is.InvalidStateError(this._status);new za(this).send(s,r,o)}mute(s={audio:!0,video:!1}){z.debug("mute()");let r=!1,o=!1;this._audioMuted===!1&&s.audio&&(r=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&s.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(r===!0||o===!0)&&this._onmute({audio:r,video:o})}unmute(s={audio:!0,video:!0}){z.debug("unmute()");let r=!1,o=!1;this._audioMuted===!0&&s.audio&&(r=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&s.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(r===!0||o===!0)&&this._onunmute({audio:r,video:o})}hold(s={},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:j.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}unhold(s={},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:j.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:s.extraHeaders}),!0}renegotiate(s={},r){z.debug("renegotiate()");const o=s.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:j.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:s.extraHeaders}),!0}refer(s,r){z.debug("refer()");const o=s;if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${o}`);const a=new ig(this);a.sendRefer(s,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(s,r){return z.debug("sendRequest()"),this._dialog.sendRequest(s,r)}receiveNotify(s){z.debug("receiveRequest()")}receiveRequest(s){if(z.debug("receiveRequest()"),s.method===j.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",s,j.causes.CANCELED));else switch(s.method){case j.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(!s.body){this.terminate({cause:j.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:s.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",s)}).catch(a=>{this.terminate({cause:j.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",s);break;case j.BYE:this._status===te.STATUS_CONFIRMED||this._status===te.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,j.causes.BYE)):this._status===te.STATUS_INVITE_RECEIVED||this._status===te.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,j.causes.BYE)):s.reply(403,"Wrong Status");break;case j.INVITE:this._status===te.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case j.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=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;r&&r.match(/^application\/dtmf-relay/i)?new Ym(this).init_incoming(s):r!==void 0?new za(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case j.UPDATE:this._status===te.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case j.REFER:this._status===te.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case j.NOTIFY:this._status===te.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){z.warn("onTransportError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.CONNECTION_ERROR,cause:j.causes.CONNECTION_ERROR})}onRequestTimeout(){z.warn("onRequestTimeout()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:j.causes.REQUEST_TIMEOUT,cause:j.causes.REQUEST_TIMEOUT})}onDialogError(){z.warn("onDialogError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.DIALOG_ERROR,cause:j.causes.DIALOG_ERROR})}newDTMF(s){z.debug("newDTMF()"),this.emit("newDTMF",s)}newInfo(s){z.debug("newInfo()"),this.emit("newInfo",s)}_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(s){z.warn("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(s,r){let o=Fr.T1;function a(){this._status===te.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],r),o<Fr.T2&&(o=o*2,o>Fr.T2&&(o=Fr.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(j.BYE),this._ended("remote",null,j.causes.NO_ACK))},Fr.TIMER_H)}_createRTCConnection(s,r){this.stunServers,this._connection=new RTCPeerConnection(s,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:j.causes.RTP_TIMEOUT,status_code:408,reason_phrase:j.causes.RTP_TIMEOUT})});let o;const a=t=>{this._connection.signalingState!=="stable"&&this._connection.signalingState!=="have-local-offer"||t.candidate&&(this._candidates.push(t.candidate),clearTimeout(o),o=setTimeout(()=>{this.lastTrickleReceived=!0,this.subscribeSent&&!this.isConfigureSent&&(this.addTracks(this.stream.getTracks()),this._ua.emit("changeMainVideoStream",{name:this.display_name,stream:this.stream}),this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{}))},500))};this._connection.onicecandidate=a,z.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(s,r){if(z.debug("createLocalDescription()"),s!=="offer"&&s!=="answer")throw new Error(`createLocalDescription() | invalid type "${s}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>s==="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:s,sdp:o.localDescription.sdp};return z.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let n=!1,p,_;this._iceReady=!1;const h=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",_),n=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:s,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:h}):n||h()}),o.addEventListener("icegatheringstatechange",_=()=>{o.iceGatheringState==="complete"&&!n&&h()})})})}_createDialog(s,r,o){console.log("_createDialog",s);const a=r==="UAS"?s.to_tag:s.from_tag,t=r==="UAS"?s.from_tag:s.to_tag,n=s.call_id+a+t;console.log("remote_tag",t);let p=this._earlyDialogs[n];if(o)return p?!0:(p=new po(this,s,r,po.C.STATUS_EARLY),console.log("SET DIALOG early"),p.error?(console.log("early_dialog error",p.error),z.debug(p.error),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,r),console.log("SET DIALOG 1"),this._dialog=p,delete this._earlyDialogs[n],!0;const _=new po(this,s,r);return _.error?(console.log("dialog.error",_.error),z.debug(_.error),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(console.log("AAA SET DIALOG 2"),this._dialog=_,!0)}}_receiveReinvite(s){z.debug("receiveReinvite()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,h=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: ${_}`);s.reply(_,h,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!s.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=>{n.call(this,p)}).catch(()=>{s.reply(500)});return}if(r!=="application/sdp"){z.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==te.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{z.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),this._late_sdp&&(p=this._mangleOffer(p)),s.reply(200,null,_,p,()=>{this._status=te.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(s){z.debug("receiveUpdate()");const r=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,o={request:s,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,h=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: ${_}`);s.reply(_,h,g)}if(this.emit("update",o),a)return;if(!s.body){n.call(this,null);return}if(r!=="application/sdp"){z.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==te.STATUS_TERMINATED&&n.call(this,p)}).catch(p=>{z.warn(p)});function n(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),s.reply(200,null,_,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(s){z.debug("_processInDialogSdpOffer()");const r=s.parseSDP();let o=!1;for(const n of r.media){if(mo.indexOf(n.type)===-1)continue;const p=n.direction||r.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:s.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(n=>{throw s.reply(488),z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),this.emit("peerconnection:setremotedescriptionfailed",n),n})}).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(n=>{throw s.reply(500),z.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',n),n})}).catch(n=>{z.warn("_processInDialogSdpOffer() failed [error: %o]",n)}),this._connectionPromiseQueue}_receiveRefer(s){if(z.debug("receiveRefer()"),!s.refer_to){z.debug("no Refer-To header field present in REFER"),s.reply(400);return}if(s.refer_to.uri.scheme!==j.SIP){z.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const r=new tg(this,s.cseq);z.debug('emit "refer"'),this.emit("refer",{request:s,accept:(t,n)=>{o.call(this,t,n)},reject:()=>{a.call(this)}});function o(t,n={}){if(t=typeof t=="function"?t:null,this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const p=new go(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:h})=>{_?r.notify(_.status_code,_.reason_phrase):r.notify(487,h)}),s.refer_to.uri.hasHeader("replaces")){const _=decodeURIComponent(s.refer_to.uri.getHeader("replaces"));n.extraHeaders=Me.cloneArray(n.extraHeaders),n.extraHeaders.push(`Replaces: ${_}`)}p.connect(s.refer_to.uri.toAor(),n,t)}function a(){r.notify(603)}}_receiveNotify(s){switch(z.debug("receiveNotify()"),s.event||s.reply(400),s.event.event){case"refer":{let r,o;if(s.event.params&&s.event.params.id)r=s.event.params.id,o=this._referSubscribers[r];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{s.reply(400,"Missing event id parameter");return}if(!o){s.reply(481,"Subscription does not exist");return}o.receiveNotify(s),s.reply(200);break}default:s.reply(489)}}_receiveReplaces(s){z.debug("receiveReplaces()");function r(a){if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const t=new go(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(s,a)}function o(){z.debug("Replaced INVITE rejected by the user"),s.reply(486)}this.emit("replaces",{request:s,accept:a=>{r.call(this,a)},reject:()=>{o.call(this)}})}_getNextTransactionId(){return(this.lastTransaction+1).toString()}_sendInitialRequest(s,r,o){this.ackSent=!1,this.publisherSubscribeSent=!1;const a=new Nf(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(s.audio||s.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(s).catch(t=>{throw this._status===te.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,j.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(n=>{this._connection.addTrack(n,t)}),this._connecting(this._request),this._createLocalDescription("offer",r).catch(n=>{throw this._failed("local",null,j.causes.WEBRTC_ERROR),n})}).then(t=>{if(this._is_canceled||this._status===te.STATUS_TERMINATED)throw new Error("terminated");const n={janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:this.opaque_id},p=JSON.stringify(n);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)})}requestAudioAndVideoPermissions(){return this.loadStream()}async loadStream(){const s={audio:!0,video:!0};try{this.stream=await navigator.mediaDevices.getUserMedia(s)}catch{try{s.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(s)}catch{s.audio=!1,s.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(s)}}return{stream:this.stream,options:s}}addTracks(s){s.forEach(r=>{this._connection.addTrack(r)})}getRecordFileName(){return uT+this.room_id+btoa(unescape(encodeURIComponent(this.displayName)))+Date.now()}async processIceCandidates(){for(let s=0;s<this.iceCandidates.length;s++)await this._connection.addIceCandidate(this.iceCandidates[s]);this.iceCandidates=[]}async _sendConfigureMessage(s){const r={offerToReceiveAudio:!1,offerToReceiveVideo:!1},o=await this._connection.createOffer(r);await this._connection.setLocalDescription(o);const a=this._candidates.map(_=>({janus:"trickle",candidate:_,handle_id:this.handle_id,session_id:this.session_id})),n={configure:{janus:"message",body:{request:"configure",record:!0,filename:this.getRecordFileName(),...s},jsep:o,handle_id:this.handle_id,session_id:this.session_id},trickles:[...a]},p=["Content-Type: application/json","PTYPE: Ice"];this.sendRequest(j.INFO,{extraHeaders:p,body:JSON.stringify(n),eventHandlers:{onSuccessResponse:async _=>{this.isConfigureSent=!0;const g=_.data.split(`\r
|
135
|
+
`),T=g[g.length-1],E=JSON.parse(T);await this._connection.setRemoteDescription(E.jsep),this._candidates=[]}}})}_sendMemberStartMessage(s,r){const o={janus:"message",body:{request:"start",room:this.room_id},handle_id:s.handleId,session_id:this.session_id,jsep:r},a=["Content-Type: application/json","PTYPE: Configure"];this.sendRequest(j.INFO,{extraHeaders:a,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async t=>{t.status_code===200&&await s.rtcpPeer.setLocalDescription(r)}}})}_sendTrickleMessage(s){const o={trickles:[...s.map(t=>({janus:"trickle",candidate:t,handle_id:this.handle_id,session_id:this.session_id}))]},a=["PTYPE: Trickle"];this.sendRequest(j.INFO,{extraHeaders:a,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async t=>{console.log("_sendTrickleMessage",t)}}})}async _answerAttachedStream(s,r){let o=null;const a=async _=>{if(!s.rtcpPeer||s.loaded)return;{s.loaded=!0;const y={audio:!0,video:!0};await new Promise(A=>{setTimeout(A,100)}),o=await s.rtcpPeer.createAnswer(y),this._sendMemberStartMessage(s,o)}const h=_.streams[0].getAudioTracks(),g=_.streams[0].getVideoTracks(),T=[];h[0]&&T.push(h[0]),g[0]&&T.push(g[0]);const E=new MediaStream(T);s.stream=E,this._ua.emit("memberJoin",s.memberInfo)};let t,n=[];const p=_=>{s.rtcpPeer.signalingState!=="stable"&&s.rtcpPeer.signalingState!=="have-local-offer"||(n.push(_.candidate||null),clearTimeout(t),t=setTimeout(()=>{this._sendTrickleMessage(n)},500))};s.rtcpPeer=new RTCPeerConnection,s.rtcpPeer.ontrack=a,s.rtcpPeer.onicecandidate=p,s.rtcpPeer.sender=r.sender,await s.rtcpPeer.setRemoteDescription(r.jsep)}_sendJoinMemberRequest(s){const r={janus:"message",body:{request:"join",room:this.room_id,feed:s.info.id,ptype:"subscriber"},handle_id:s.handleId,session_id:this.session_id},o=["PTYPE: Subscriber"];this.sendRequest(j.SUBSCRIBE,{extraHeaders:o,body:JSON.stringify(r),eventHandlers:{onSuccessResponse:async a=>{var t,n;if(a.status_code===200){const p=JSON.parse(a.body);(n=(t=p==null?void 0:p.plugindata)==null?void 0:t.data)!=null&&n.id&&await this._answerAttachedStream(s,p)}}}})}_attachMember(s){const r={janus:"attach",opaque_id:this.opaque_id,plugin:"janus.plugin.videoroom",session_id:this.session_id},o=["PTYPE: Subscriber"];this.sendRequest(j.INFO,{extraHeaders:o,body:JSON.stringify(r),eventHandlers:{onSuccessResponse:async a=>{if(a.status_code===200){const n=JSON.parse(a.body).data.id;s.handleId=n,this._sendJoinMemberRequest(s)}}}})}_detachMember(s){const r={janus:"detach",handle_id:s.handleId,session_id:this.session_id},o=["PTYPE: Subscriber"];this.sendRequest(j.INFO,{extraHeaders:o,body:JSON.stringify(r)}),this._ua.emit("memberHangup",s.memberInfo)}receivePublishers(s){var o,a,t,n,p,_,h,g;const r={...this.memberList};(a=(o=s==null?void 0:s.plugindata)==null?void 0:o.data)==null||a.publishers.forEach(T=>{delete r[T.id],!this.memberList[T.id]&&!this.myFeedList.includes(T.id)&&T.clientID!==this.client_id&&(this.memberList[T.id]=new oT(T,this),this._attachMember(this.memberList[T.id]))}),((n=(t=s==null?void 0:s.plugindata)==null?void 0:t.data)==null?void 0:n.videoroom)==="synced"&&Object.keys(r).forEach(T=>{r[T].hangup(),delete this.memberList[T]}),this.publishers=(_=(p=s==null?void 0:s.plugindata)==null?void 0:p.data)==null?void 0:_.publishers,this.private_id=(g=(h=s==null?void 0:s.plugindata)==null?void 0:h.data)==null?void 0:g.private_id}receiveUnpublished(s){const r=this.memberList[s];r&&(r.hangup(),this._detachMember(r),delete this.memberList[s])}closeSession(){this.stream&&this.stream.getTracks().forEach(r=>{r.stop()}),Object.values(this.memberList).forEach(r=>{r.hangup(),this._detachMember(r)})}_receiveInviteResponse(s){if(z.debug("receiveInviteResponse()"),console.log("_receiveInviteResponse response",s),console.log("dialog",this._dialog),this._dialog&&s.status_code>=200&&s.status_code<=299&&!this.ackSent)if(console.log("IF 1 dialog"),this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.ackSent=!0,this.sendRequest(j.ACK);return}else{const r=new po(this,s,"UAC");if(r.error!==void 0){z.debug(r.error);return}this.sendRequest(j.ACK),this.sendRequest(j.BYE);return}if(this.ackSent&&!this.publisherSubscribeSent){const r=JSON.parse(s.body);this.requestAudioAndVideoPermissions().then(()=>{this.session_id=r.session_id,this.handle_id=r.data.id,this.client_id=c_();const o={janus:"message",body:{request:"join",room:this.room_id,ptype:"publisher",display:this.display_name,clientID:this.client_id,opaque_id:this.opaque_id},handle_id:this.handle_id},a=["PTYPE: Publisher"];this.sendRequest(j.SUBSCRIBE,{extraHeaders:a,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async t=>{var n,p;if(t.status_code===200){if(this.subscribeSent=!0,t.body)try{const _=JSON.parse(t.body)||{};(p=(n=_.plugindata)==null?void 0:n.data)!=null&&p.publishers&&this.receivePublishers(_)}catch(_){console.error(_)}this.lastTrickleReceived&&!this.isConfigureSent&&(this.addTracks(this.stream.getTracks()),this._ua.emit("changeMainVideoStream",{name:this.display_name,stream:this.stream}),this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{}))}}}}),this.publisherSubscribeSent=!0})}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==te.STATUS_INVITE_SENT&&this._status!==te.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(s.status_code):this._status=te.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){z.debug("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=te.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const r={originator:"remote",type:"answer",sdp:s.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",s)).catch(a=>{z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(this._status=te.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,j.causes.MISSING_SDP),this._failed("remote",s,j.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;break}default:{const r=Me.sipErrorCause(s.status_code);this._failed("remote",s,r)}}}_sendReinvite(s={}){z.debug("sendReinvite()");const r=Me.cloneArray(s.extraHeaders),o=Me.cloneObject(s.eventHandlers),a=s.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 h={originator:"local",type:"offer",sdp:_};z.debug('emit "sdp"'),this.emit("sdp",h),this.sendRequest(j.INVITE,{extraHeaders:r,body:_,eventHandlers:{onSuccessResponse:g=>{n.call(this,g),t=!0},onErrorResponse:g=>{p.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function n(_){if(this._status===te.STATUS_TERMINATED||(this.sendRequest(j.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 h={originator:"remote",type:"answer",sdp:_.body};z.debug('emit "sdp"'),this.emit("sdp",h);const g=new RTCSessionDescription({type:"answer",sdp:h.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(s={}){z.debug("sendUpdate()");const r=Me.cloneArray(s.extraHeaders),o=Me.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null,t=s.sdpOffer||!1;let n=!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(h=>{h=this._mangleOffer(h);const g={originator:"local",type:"offer",sdp:h};z.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(j.UPDATE,{extraHeaders:r,body:h,eventHandlers:{onSuccessResponse:T=>{p.call(this,T),n=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(j.UPDATE,{extraHeaders:r,eventHandlers:{onSuccessResponse:h=>{p.call(this,h)},onErrorResponse:h=>{_.call(this,h)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(h){if(this._status!==te.STATUS_TERMINATED&&!n)if(this._handleSessionTimersInIncomingResponse(h),t){if(h.body){if(!h.hasHeader("Content-Type")||h.getHeader("Content-Type").toLowerCase()!=="application/sdp"){_.call(this);return}}else{_.call(this);return}const g={originator:"remote",type:"answer",sdp:h.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(h)}).catch(E=>{_.call(this),z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else o.succeeded&&o.succeeded(h)}function _(h){o.failed&&o.failed(h)}}_acceptAndTerminate(s,r,o){z.debug("acceptAndTerminate()");const a=[];r&&(o=o||j.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest(j.ACK),this.sendRequest(j.BYE,{extraHeaders:a})),this._status=te.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=Dt.parse(s),this._localHold&&!this._remoteHold){z.debug("mangleOffer() | me on hold, mangling offer");for(const r of s.media)mo.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 s.media)mo.indexOf(r.type)!==-1&&(r.direction="inactive")}else if(this._remoteHold){z.debug("mangleOffer() | remote on hold, mangling offer");for(const r of s.media)mo.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="recvonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="recvonly")}return Dt.write(s)}_setLocalMediaStatus(){let s=!0,r=!0;(this._localHold||this._remoteHold)&&(s=!1,r=!1),this._audioMuted&&(s=!1),this._videoMuted&&(r=!1),this._toggleMuteAudio(!s),this._toggleMuteVideo(!r)}_handleSessionTimersInIncomingRequest(s,r){if(!this._sessionTimers.enabled)return;let o;s.session_expires&&s.session_expires>=j.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,o=s.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(s){if(!this._sessionTimers.enabled)return;let r;s.session_expires&&s.session_expires>=j.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,r=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}_runSessionTimer(){const s=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===j.UPDATE?this._sendUpdate():this._sendReinvite())},s*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==te.STATUS_TERMINATED&&(z.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:j.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},s*1100)}_toggleMuteAudio(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of r)o.track.enabled=!s}_toggleMuteVideo(s){const r=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of r)o.track.enabled=!s}_newJanusSession(s,r){z.debug("newRTCSession()"),this._ua.newJanusSession(this,{originator:s,session:this,request:r})}_connecting(s){z.debug("session connecting"),z.debug('emit "connecting"'),this.emit("connecting",{request:s})}_progress(s,r){z.debug("session progress"),z.debug('emit "progress"'),this.emit("progress",{originator:s,response:r||null})}_accepted(s,r){z.debug("session accepted"),this._start_time=new Date,z.debug('emit "accepted"'),this.emit("accepted",{originator:s,response:r||null})}_confirmed(s,r){z.debug("session confirmed"),this._is_confirmed=!0,z.debug('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:r||null})}_ended(s,r,o){z.debug("session ended"),this._end_time=new Date,this._close(),z.debug('emit "ended"'),this.emit("ended",{originator:s,message:r||null,cause:o})}_failed(s,r,o){z.debug("session failed"),z.debug('emit "_failed"'),this.emit("_failed",{originator:s,message:r||null,cause:o}),this._close(),z.debug('emit "failed"'),this.emit("failed",{originator:s,message:r||null,cause:o})}_onhold(s){z.debug("session onhold"),this._setLocalMediaStatus(),z.debug('emit "hold"'),this.emit("hold",{originator:s})}_onunhold(s){z.debug("session onunhold"),this._setLocalMediaStatus(),z.debug('emit "unhold"'),this.emit("unhold",{originator:s})}_onmute({audio:s,video:r}){z.debug("session onmute"),this._setLocalMediaStatus(),z.debug('emit "muted"'),this.emit("muted",{audio:s,video:r})}_onunmute({audio:s,video:r}){z.debug("session onunmute"),this._setLocalMediaStatus(),z.debug('emit "unmuted"'),this.emit("unmuted",{audio:s,video:r})}}class Hn{constructor(s){if(this.headers={},s.length>0){let r=!1;const o=s.split(`\r
|
136
136
|
`),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
|
137
137
|
`;else{const n=t.split(": ");this.addHeader(n[0],n[1].trim())}}}else this.ident=Me.createRandomToken(12),this.protocol="MSRP"}addHeader(s,r){this.headers[s]=r}getHeader(s){return this.headers[s]}toString(){let s=`${this.protocol} ${this.ident} ${this.code} ${this.method}`.replaceAll(/null\s|undefined\s/ig,"")+`\r
|
138
138
|
`;for(const r in this.headers)s+=`${r}: ${this.headers[r]}\r
|
@@ -153,4 +153,4 @@ t=0 0
|
|
153
153
|
m=message 2856 TCP/TLS/MSRP *
|
154
154
|
a=accept-types:text/plain text/html
|
155
155
|
a=path:${s.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
|
156
|
-
`),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new Nf(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=Ce.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=Ce.STATUS_INVITE_SENT}terminate(s={}){console.log("terminate",this);const r=s.cause||j.causes.BYE,o=Me.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,p=s.reason_phrase;if(this._status===Ce.STATUS_TERMINATED)throw new Is.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Ce.STATUS_NULL:case Ce.STATUS_INVITE_SENT:case Ce.STATUS_1XX_RECEIVED:if(n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(p=p||j.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;text="${p}"`),this._status===Ce.STATUS_NULL||this._status===Ce.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===Ce.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=Ce.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,j.causes.CANCELED);break;case Ce.STATUS_WAITING_FOR_ANSWER:case Ce.STATUS_ANSWERED:if(n=n||480,console.log("REPLY 480"),n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._request.reply(n,p,o,a),console.log("failed 2"),this._failed("local",null,j.causes.REJECTED);break;case Ce.STATUS_WAITING_FOR_ACK:case Ce.STATUS_CONFIRMED:if(p=s.reason_phrase||j.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${p}"`),this._status===Ce.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==$t.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===j.ACK&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===$t.C.STATUS_TERMINATED&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else console.log("here it is"),this.sendRequest(j.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendRequest(s,r){return this._dialog.sendRequest(s,r)}authenticate(s){this.status="auth";let r=new Hn("");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`),s&&r.addHeader("Authorization",s.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(s){console.log("onmessage",s);const r=new Hn(s.data);if(this.status==="auth"&&r.code===401){const o=this.parseAuth(r.getHeader("WWW-Authenticate")),a=new ym(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 s=new RTCPeerConnection({iceServers:[]});s.createDataChannel(""),s.createOffer().then(s.setLocalDescription.bind(s)),s.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],s.onicecandidate=()=>{},this.authenticate(null)}}onerror(s){console.log(s)}_receiveInviteResponse(s){if(console.log("resp0000000000000",s),this._dialog&&s.status_code>=200&&s.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.sendRequest(j.ACK);return}else{const r=new io(this,s,"UAC");if(r.error!==void 0){console.log(r.error);return}this.sendRequest(j.ACK),this.sendRequest(j.BYE);return}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==Ce.STATUS_INVITE_SENT&&this._status!==Ce.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(s.status_code):this._status=Ce.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){console.log("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=Ce.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const r={originator:"remote",type:"answer",sdp:s.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",s)).catch(a=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(console.log("maybe here???"),this._status=Ce.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,j.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",s,j.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;const r={originator:"remote",type:"answer",sdp:s.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(s,500,o.toString()),console.log("failed 4"),this._failed("local",s,j.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest(j.ACK),this._confirmed("local",null)});break}default:{const r=Me.sipErrorCause(s.status_code);console.log("failed 5"),this._failed("remote",s,r)}}}sendMSRP(s){const r=new Hn("");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=s;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(s){let r=s.ident,o=s.getHeader("Message-ID"),a=new Hn("");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 n=[];for(var p=0;p<t.length;p++)n.push(t.charCodeAt(p).toString(16));console.log(n),this._connection.send(a.toString())}_sendReport(s){let r=s.ident,o=s.getHeader("Message-ID"),a=new Hn("");a.method="REPORT",a.addHeader("To-Path",`${s.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 n=[];for(var p=0;p<t.length;p++)n.push(t.charCodeAt(p).toString(16));console.log(n),this._connection.send(a.toString())}parseAuth(s){const r={},o=s.replace("Digest","").split(",");for(const a of o){const t=a.trim().split("=");r[t[0]]=t[1].match('^"(.+)"$')[1]}return r}init_incoming(s,r){let o;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=Ce.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(o=s.getHeader("expires")*1e3),s.to_tag=Me.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Ce.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),console.log("failed 6"),this._failed("local",null,j.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Ce.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),console.log("failed 7"),this._failed("system",null,j.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,r&&r(this),s.parseSDP(!0),this.target_addr=s.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",s),this._status!==Ce.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(s,r,o){this.emit("_failed",{originator:s,message:r||null,cause:o}),this._close(),this.emit("failed",{originator:s,message:r||null,cause:o})}_close(){if(console.log("CLOSE SESSION"),this._status!==Ce.STATUS_TERMINATED){if(this._status=Ce.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){console.log("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyMSRPSession(this)}}_createDialog(s,r,o){const a=r==="UAS"?s.to_tag:s.from_tag,t=r==="UAS"?s.from_tag:s.to_tag,n=s.call_id+a+t;let p=this._earlyDialogs[n];if(o)return p?!0:(p=new io(this,s,r,io.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,r),this._dialog=p,delete this._earlyDialogs[n],!0;const _=new io(this,s,r);return _.error?(console.log("failed 9"),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_newMSRPSession(s,r){this._ua.newMSRPSession(this,{originator:s,session:this,request:r})}_progress(s,r){this.emit("progress",{originator:s,response:r||null})}isEnded(){switch(this._status){case Ce.STATUS_CANCELED:case Ce.STATUS_TERMINATED:return!0;default:return!1}}_accepted(s,r){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:s,response:r||null})}_confirmed(s,r){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:r||null})}_ended(s,r,o){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:s,message:r||null,cause:o})}_handleSessionTimersInIncomingResponse(s){if(!this._sessionTimers.enabled)return;let r;s.session_expires&&s.session_expires>=j.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,r=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}receiveRequest(s){if(console.log("receiveRequest()"),s.method===j.CANCEL)(this._status===Ce.STATUS_WAITING_FOR_ANSWER||this._status===Ce.STATUS_ANSWERED)&&(this._status=Ce.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",s,j.causes.CANCELED));else switch(s.method){case j.ACK:if(this._status!==Ce.STATUS_WAITING_FOR_ACK)return;if(this._status=Ce.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!s.body){this.terminate({cause:j.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:s.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",s)}).catch(a=>{this.terminate({cause:j.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",s);break;case j.BYE:this._status===Ce.STATUS_CONFIRMED||this._status===Ce.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,j.causes.BYE)):this._status===Ce.STATUS_INVITE_RECEIVED||this._status===Ce.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,j.causes.BYE)):s.reply(403,"Wrong Status");break;case j.INVITE:this._status===Ce.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case j.INFO:this._status===Ce.STATUS_1XX_RECEIVED||this._status===Ce.STATUS_WAITING_FOR_ANSWER||this._status===Ce.STATUS_ANSWERED||this._status===Ce.STATUS_WAITING_FOR_ACK||this._status===Ce.STATUS_CONFIRMED?(s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new Ja(this).init_incoming(s):s.reply(415):s.reply(403,"Wrong Status");break;case j.UPDATE:this._status===Ce.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case j.REFER:this._status===Ce.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case j.NOTIFY:this._status===Ce.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Ce.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.CONNECTION_ERROR,cause:j.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Ce.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:j.causes.REQUEST_TIMEOUT,cause:j.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Ce.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.DIALOG_ERROR,cause:j.causes.DIALOG_ERROR})}}const ft=console,Ds={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},fT=nT;class _T extends fT{constructor(s){super(s),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[]}call(s,r){return super.call(s,r)}joinVideoCall(s,r,o){ft.debug("call()");const a=new go(this);return a.connect(s,r,o),a}_loadConfig(s){try{Qr.load(this._configuration,s)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Ln.newUUID()),this._configuration.jssip_id=Ln.createRandomToken(5);const r=this._configuration.uri.clone();r.user=null,this._configuration.hostport_params=r.toString().replace(/^sip:/i,"");try{this._transport=new Og(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=hT.bind(this),this._transport.onconnect=dT.bind(this),this._transport.ondisconnect=pT.bind(this),this._transport.ondata=mT.bind(this)}catch(a){throw ft.warn(a),new Is.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 $n("sip",Ln.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,n=a.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),n&&(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}));ft.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Qr.settings,a))switch(a){case"uri":case"registrar_server":ft.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":ft.debug(`- ${a}: NOT SHOWN`);break;default:ft.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}newMSRPSession(s,r){s.on("msgHistoryUpdate",o=>{console.log(o)}),this._msrp_sessions[s.id]=s,this.emit("newMSRPSession",r)}newJanusSession(s,r){this._janus_sessions[s.id]=s,this.emit("newJanusSession",r)}destroyMSRPSession(s){delete this._msrp_sessions[s.id]}destroyJanusSession(s){delete this._janus_sessions[s.id]}receiveRequest(s){var t,n;const r=s.method;if(console.log("-----------"),s.ruri.user!==this._configuration.uri.user&&s.ruri.user!==this._contact.uri.user){ft.debug("Request-URI does not point to us"),s.method!==De.ACK&&s.reply_sl(404);return}if(s.ruri.scheme===De.SIPS){s.reply_sl(416);return}if($t.checkTransaction(this,s))return;if(r===De.INVITE?new $t.InviteServerTransaction(this,this._transport,s):r!==De.ACK&&r!==De.CANCEL&&new $t.NonInviteServerTransaction(this,this._transport,s),r===De.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new pf.Options(this).init_incoming(s)}else if(r===De.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new pf.Message(this).init_incoming(s)}else if(r===De.INVITE&&!s.to_tag&&this.listeners("newRTCSession").length===0){s.reply(405);return}let o,a;if(s.to_tag)if(o=this._findDialog(s.call_id,s.from_tag,s.to_tag),o)o.receiveRequest(s);else if(r===De.NOTIFY)if(a=this._findSession(s),a)a.receiveRequest(s);else{if(s.body){const p=JSON.parse(s.body)||{};(n=(t=p.plugindata)==null?void 0:t.data)!=null&&n.publishers&&Object.values(this._janus_sessions)[0].receivePublishers(p)}s.reply(200)}else r!==De.ACK&&s.reply(481);else switch(r){case De.INVITE:if(window.RTCPeerConnection)if(s.hasHeader("replaces")){const p=s.replaces;o=this._findDialog(p.call_id,p.from_tag,p.to_tag),o?(a=o.owner,a.isEnded()?s.reply(603):a.receiveRequest(s)):s.reply(481)}else s.body.search(/MSRP/ig)>-1?(a=new pu(this),a.init_incoming(s)):s.body.search(/JANUS/ig)>-1||(a=new hg(this),a.init_incoming(s));else ft.warn("INVITE received but WebRTC is not supported"),s.reply(488);break;case De.BYE:s.reply(481);break;case De.CANCEL:a=this._findSession(s),a?a.receiveRequest(s):ft.debug("received CANCEL request for a non existent session");break;case De.ACK:break;case De.NOTIFY:this.emit("sipEvent",{event:s.event,request:s}),s.reply(200);break;default:s.reply(405);break}}startMSRP(s,r){ft.debug("startMSRP()",r);const o=new pu(this);return o.connect(s),o}startJanus(s,r){ft.debug("startJanus()",r);const o=new pu(this);return o.connect(s),o}terminateMSRPSessions(s){ft.debug("terminateSessions()");for(const r in this._msrp_sessions)this._msrp_sessions[r].isEnded()||this._msrp_sessions[r].terminate(s)}terminateJanusSessions(s){ft.debug("terminateSessions()");for(const r in this._janus_sessions)this._janus_sessions[r].isEnded()||this._janus_sessions[r].terminate(s)}stop(){if(ft.debug("stop()"),this._dynConfiguration={},this._status===Ds.STATUS_USER_CLOSED){ft.debug("UA already closed");return}this._registrator.close();const s=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){ft.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)){ft.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)){ft.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=Ds.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&&s===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}function hT(c){this.emit("connecting",c)}function dT(c){this._status!==Ds.STATUS_USER_CLOSED&&(this._status=Ds.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function pT(c){const s=["nict","ict","nist","ist"];for(const r of s)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!==Ds.STATUS_USER_CLOSED&&(this._status=Ds.STATUS_NOT_READY,this._error=Ds.NETWORK_ERROR)}function mT(c){console.log("onTransportData",c);const s=c.transport;let r=c.message;if(r=su.parseMessage(r,this),!r){console.log("if 1 return");return}if(this._status===Ds.STATUS_USER_CLOSED&&r instanceof eo.IncomingRequest){console.log("if 2 return");return}if(!Bg(r,this,s)){console.log("if 3 return");return}if(console.log("onTransportData message",r),console.log("onTransportData instanceof",r instanceof eo.IncomingRequest),r instanceof eo.IncomingRequest)r.transport=s,console.log("onTransportData receiveRequest"),this.receiveRequest(r);else if(r instanceof eo.IncomingResponse){let o;switch(r.method){case De.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case De.ACK:break;default:o=this._transactions.nict[r.via_branch],o&&o.receiveResponse(r);break}}}const gT=["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"],TT=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function f_(c){const s={};return gT.forEach(r=>{c[r]!==void 0&&(s[r]=c[r])}),s.localHold=c._localHold,s}function __(c){const s={};return TT.forEach(r=>{c[r]!==void 0&&(s[r]=c[r])}),s}function h_(c,s){const r=new AudioContext,o=r.createMediaStreamSource(c),a=r.createMediaStreamDestination(),t=r.createGain();return o.connect(t),t.connect(a),t.gain.value=s,a.stream}function vT(c,s,r,o){const a=document.createElement("audio");a.id=s._id,a.className="audioTag",a.srcObject=c,d_()||(a.setSinkId(r),a.volume=o),a.play(),s.audioTag=a}function ET(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}function d_(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}const ST=lt,yT=es(),wt=new ST("WebSocketInterface");var AT=class{constructor(s){wt.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;const r=yT.parse(s,"absoluteURI");if(r===-1)throw wt.warn(`invalid WebSocket URI: ${s}`),new TypeError(`Invalid argument: ${s}`);if(r.scheme!=="wss"&&r.scheme!=="ws")throw wt.warn(`invalid WebSocket URI scheme: ${r.scheme}`),new TypeError(`Invalid argument: ${s}`);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(s){this._via_transport=s.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(wt.debug("connect()"),this.isConnected()){wt.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){wt.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),wt.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(s){this._onError(s)}}disconnect(){wt.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(s){return wt.debug("send()"),this.isConnected()?(this._ws.send(s),!0):(wt.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(){wt.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:s,code:r,reason:o}){wt.debug(`WebSocket ${this._url} closed`),s===!1&&wt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!s,r,o)}_onMessage({data:s}){wt.debug("received WebSocket message"),this.ondata(s)}_onError(s){wt.warn(`WebSocket ${this._url} error: `,s)}};const mu=dl,CT=De,RT=ds,IT=mt(),bT=a_,wT=fs(),OT=ka(),DT=es(),NT=AT;wn("JsSIP")("version %s",mu.version);var UT={C:CT,Exceptions:RT,Utils:IT,UA:bT,URI:wT,NameAddrHeader:OT,WebSocketInterface:NT,Grammar:DT,debug:wn,get name(){return mu.title},get version(){return mu.version}};const PT=ke(UT);function gu(c){return c<10?`0${c}`:`${c}`}function xT(c){let s=c.hours||0,r=c.minutes||0,o=c.seconds||0;o++,o===60&&(o=0,r++,r===60&&(r=0,s++));const a=`${gu(s)}:${gu(r)}:${gu(o)}`;return{seconds:o,minutes:r,hours:s,formatted:a}}var St={};St.forEach=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)if(a in c){const t=Promise.resolve(c[a]).then(n=>s.call(r||globalThis,n,a,c));o.push(t)}await Promise.all(o)},St.forEachSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)o in c&&await s.call(r||globalThis,await c[o],o,c)},St.map=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=Promise.resolve(c[a]).then(t=>s.call(r||globalThis,t,a,c)));return Promise.all(o)},St.mapSeries=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=await s.call(r||globalThis,await c[a],a,c));return o},St.find=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o();let t=1;for(let n=0;n<c.length;n++){const p=_=>{_?o(c[n]):t===c.length&&o(),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.findSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(await s.call(r||globalThis,await c[o],o,c))return c[o]},St.findIndex=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o(-1);let t=1;for(let n=0;n<c.length;n++){const p=_=>{_?o(n):t===c.length&&o(-1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.findIndexSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(await s.call(r||globalThis,await c[o],o,c))return o},St.some=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o(!1);let t=1;for(let n=0;n<c.length;n++){if(!(n in c)){t++;continue}const p=_=>{_?o(!0):t===c.length&&o(!1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.someSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(o in c&&await s.call(r||globalThis,await c[o],o,c))return!0;return!1},St.every=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o(!0);let t=1;for(let n=0;n<c.length;n++){if(!(n in c)){t++;continue}const p=_=>{_?t===c.length&&o(!0):o(!1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.everySeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(o in c&&!await s.call(r||globalThis,await c[o],o,c))return!1;return!0},St.filter=(c,s,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(_=>s.call(r||globalThis,_,p,c)).catch(a));const n=[];for(let p=0;p<t.length;p++)await t[p]&&n.push(await c[p]);o(n)}),St.filterSeries=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&await s.call(r||globalThis,await c[a],a,c)&&o.push(await c[a]);return o},St.reduce=async(c,s,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 s(await a,await c[o],o,c));return a};var p_={};(function(c){const s=St;Object.keys(s).forEach(r=>{const o=r.charAt(0).toUpperCase()+r.slice(1);c[`async${o}`]=async function(...a){return s[r](this,...a)}})})(p_);var m_=Object.assign(St,{instanceMethods:p_});const tn=new AudioContext,Kt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var MT={exports:{}};(function(c){var s=function(r){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(ee,Y,G){ee[Y]=G.value},n,p=typeof Symbol=="function"?Symbol:{},_=p.iterator||"@@iterator",d=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function T(ee,Y,G){return Object.defineProperty(ee,Y,{value:G,enumerable:!0,configurable:!0,writable:!0}),ee[Y]}try{T({},"")}catch{T=function(Y,G,re){return Y[G]=re}}function E(ee,Y,G,re){var ge=Y&&Y.prototype instanceof ae?Y:ae,be=Object.create(ge.prototype),xe=new P(re||[]);return t(be,"_invoke",{value:z(ee,G,xe)}),be}r.wrap=E;function y(ee,Y,G){try{return{type:"normal",arg:ee.call(Y,G)}}catch(re){return{type:"throw",arg:re}}}var A="suspendedStart",C="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 B(ee){["next","throw","return"].forEach(function(Y){T(ee,Y,function(G){return this._invoke(Y,G)})})}r.isGeneratorFunction=function(ee){var Y=typeof ee=="function"&&ee.constructor;return Y?Y===N||(Y.displayName||Y.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 q(ee,Y){function G(be,xe,Re,le){var ye=y(ee[be],ee,xe);if(ye.type==="throw")le(ye.arg);else{var it=ye.arg,ot=it.value;return ot&&typeof ot=="object"&&a.call(ot,"__await")?Y.resolve(ot.__await).then(function(Ee){G("next",Ee,Re,le)},function(Ee){G("throw",Ee,Re,le)}):Y.resolve(ot).then(function(Ee){it.value=Ee,Re(it)},function(Ee){return G("throw",Ee,Re,le)})}}var re;function ge(be,xe){function Re(){return new Y(function(le,ye){G(be,xe,le,ye)})}return re=re?re.then(Re,Re):Re()}t(this,"_invoke",{value:ge})}B(q.prototype),T(q.prototype,d,function(){return this}),r.AsyncIterator=q,r.async=function(ee,Y,G,re,ge){ge===void 0&&(ge=Promise);var be=new q(E(ee,Y,G,re),ge);return r.isGeneratorFunction(Y)?be:be.next().then(function(xe){return xe.done?xe.value:be.next()})};function z(ee,Y,G){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 rt()}for(G.method=be,G.arg=xe;;){var Re=G.delegate;if(Re){var le=H(Re,G);if(le){if(le===L)continue;return le}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(re===A)throw re=$,G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);re=I;var ye=y(ee,Y,G);if(ye.type==="normal"){if(re=G.done?$:C,ye.arg===L)continue;return{value:ye.arg,done:G.done}}else ye.type==="throw"&&(re=$,G.method="throw",G.arg=ye.arg)}}}function H(ee,Y){var G=Y.method,re=ee.iterator[G];if(re===n)return Y.delegate=null,G==="throw"&&ee.iterator.return&&(Y.method="return",Y.arg=n,H(ee,Y),Y.method==="throw")||G!=="return"&&(Y.method="throw",Y.arg=new TypeError("The iterator does not provide a '"+G+"' method")),L;var ge=y(re,ee.iterator,Y.arg);if(ge.type==="throw")return Y.method="throw",Y.arg=ge.arg,Y.delegate=null,L;var be=ge.arg;if(!be)return Y.method="throw",Y.arg=new TypeError("iterator result is not an object"),Y.delegate=null,L;if(be.done)Y[ee.resultName]=be.value,Y.next=ee.nextLoc,Y.method!=="return"&&(Y.method="next",Y.arg=n);else return be;return Y.delegate=null,L}B(D),T(D,g,"Generator"),T(D,_,function(){return this}),T(D,"toString",function(){return"[object Generator]"});function Z(ee){var Y={tryLoc:ee[0]};1 in ee&&(Y.catchLoc=ee[1]),2 in ee&&(Y.finallyLoc=ee[2],Y.afterLoc=ee[3]),this.tryEntries.push(Y)}function U(ee){var Y=ee.completion||{};Y.type="normal",delete Y.arg,ee.completion=Y}function P(ee){this.tryEntries=[{tryLoc:"root"}],ee.forEach(Z,this),this.reset(!0)}r.keys=function(ee){var Y=Object(ee),G=[];for(var re in Y)G.push(re);return G.reverse(),function ge(){for(;G.length;){var be=G.pop();if(be in Y)return ge.value=be,ge.done=!1,ge}return ge.done=!0,ge}};function se(ee){if(ee){var Y=ee[_];if(Y)return Y.call(ee);if(typeof ee.next=="function")return ee;if(!isNaN(ee.length)){var G=-1,re=function ge(){for(;++G<ee.length;)if(a.call(ee,G))return ge.value=ee[G],ge.done=!1,ge;return ge.value=n,ge.done=!0,ge};return re.next=re}}return{next:rt}}r.values=se;function rt(){return{value:n,done:!0}}return P.prototype={constructor:P,reset:function(ee){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(U),!ee)for(var Y in this)Y.charAt(0)==="t"&&a.call(this,Y)&&!isNaN(+Y.slice(1))&&(this[Y]=n)},stop:function(){this.done=!0;var ee=this.tryEntries[0],Y=ee.completion;if(Y.type==="throw")throw Y.arg;return this.rval},dispatchException:function(ee){if(this.done)throw ee;var Y=this;function G(le,ye){return be.type="throw",be.arg=ee,Y.next=le,ye&&(Y.method="next",Y.arg=n),!!ye}for(var re=this.tryEntries.length-1;re>=0;--re){var ge=this.tryEntries[re],be=ge.completion;if(ge.tryLoc==="root")return G("end");if(ge.tryLoc<=this.prev){var xe=a.call(ge,"catchLoc"),Re=a.call(ge,"finallyLoc");if(xe&&Re){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0);if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else if(xe){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0)}else if(Re){if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(ee,Y){for(var G=this.tryEntries.length-1;G>=0;--G){var re=this.tryEntries[G];if(re.tryLoc<=this.prev&&a.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var ge=re;break}}ge&&(ee==="break"||ee==="continue")&&ge.tryLoc<=Y&&Y<=ge.finallyLoc&&(ge=null);var be=ge?ge.completion:{};return be.type=ee,be.arg=Y,ge?(this.method="next",this.next=ge.finallyLoc,L):this.complete(be)},complete:function(ee,Y){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"&&Y&&(this.next=Y),L},finish:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.finallyLoc===ee)return this.complete(G.completion,G.afterLoc),U(G),L}},catch:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.tryLoc===ee){var re=G.completion;if(re.type==="throw"){var ge=re.arg;U(G)}return ge}}throw new Error("illegal catch attempt")},delegateYield:function(ee,Y,G){return this.delegate={iterator:se(ee),resultName:Y,nextLoc:G},this.method==="next"&&(this.arg=n),L}},r}(c.exports);try{regeneratorRuntime=s}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=s:Function("r","regeneratorRuntime = r")(s)}})(MT);var g_={exports:{}};(function(c){(function(s,r){c.exports?c.exports=r():s.log=r()})(Gs,function(){var s=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(C,I){var $=C[I];if(typeof $.bind=="function")return $.bind(C);try{return Function.prototype.bind.call($,C)}catch{return function(){return Function.prototype.apply.apply($,[C,arguments])}}}function n(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(C){return C==="debug"&&(C="log"),typeof console===r?!1:C==="trace"&&o?n:console[C]!==void 0?t(console,C):console.log!==void 0?t(console,"log"):s}function _(C,I){for(var $=0;$<a.length;$++){var L=a[$];this[L]=$<C?s:this.methodFactory(L,C,I)}this.log=this.debug}function d(C,I,$){return function(){typeof console!==r&&(_.call(this,I,$),this[C].apply(this,arguments))}}function g(C,I,$){return p(C)||d.apply(this,arguments)}function T(C,I,$){var L=this,ae;I=I??"WARN";var N="loglevel";typeof C=="string"?N+=":"+C:typeof C=="symbol"&&(N=void 0);function F(D){var B=(a[D]||"silent").toUpperCase();if(!(typeof window===r||!N)){try{window.localStorage[N]=B;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+B+";"}catch{}}}function Se(){var D;if(!(typeof window===r||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===r)try{var B=window.document.cookie,q=B.indexOf(encodeURIComponent(N)+"=");q!==-1&&(D=/^([^;]+)/.exec(B.slice(q))[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=C,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,B){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,B!==!1&&F(D),_.call(L,D,C),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})})(g_);var Rt=g_.exports;const ps=()=>`${new Date().toISOString()} | metrics`,ms=(c,s,r)=>`${c} | ${s} | ${r}`;Rt.setDefaultLevel(Rt.levels.TRACE);const kT=c=>{Rt.info(ms(ps(),"log ",`set log level to ${c?"verbose":"info"}`)),Rt.setLevel(c?Rt.levels.TRACE:Rt.levels.INFO)},LT=c=>{const s=[...Object.keys(Rt.levels)];s.includes(c)?(Rt.info(ms(ps(),"log ",`update log level to ${c.toLowerCase()}`)),Rt.setLevel(c)):Rt.warn(ms(ps(),"log ","Incorrect log level please choose one of "),s)},Pe=(c,s,r)=>{r?Rt.debug(ms(ps(),c,s),r):Rt.debug(ms(ps(),c,s))},Tu=(c,s)=>{Rt.info(ms(ps(),c,s))},sn=(c,s)=>{Rt.info(ms(ps(),c,s))},To=(c,s)=>{Rt.warn(ms(ps(),c,s))},Fn=(c,s)=>{Rt.error(ms(ps(),c,s))};function $T(c){return Math.floor(Math.random()*c).toString()}function T_(c,s){let r=s;return c.forEach(o=>{r=r.replace(o,"")}),r}function HT(c,s){let r="";for(let o=0;o<s;o+=1)r+=c[$T(c.length)];return r}function FT({length:c=20,useLetters:s=!0,useNumbers:r=!0,includeSymbols:o=[],excludeSymbols:a=[]}={}){let t="abcdefghijklmnopqrstuvwxyz",n="0123456789",p=[],_=[],d=[];return s&&(a.length&&(t=T_(a,t)),_=t.split("")),r&&(a.length&&(n=T_(a,n)),d=n.split("")),p=[..._,...d,...o],HT(p,c)}var jT=FT;const Zr=ke(jT),VT=()=>"WebRTCMetrics",qT=()=>"5.0.3",$e={INBOUND:"inbound",OUTBOUND:"outbound"},gs={IDLE:"idle",RUNNING:"running",MUTED:"muted"},ei={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},BT=()=>({...{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:[]}}),v_={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},E_={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},S_={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},y_={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},GT=c=>{const s={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{...s,audio:{},video:{},data:{...s.data},network:{...s.network},experimental:{...s.experimental}}},WT={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${Zr()}`,cid:`c-${Zr()}`,uid:`u-${Zr()}`,record:!1,ticket:!0},Yt={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"},ti={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},vu={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ne={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},Eu="config ",KT=(c,s={},r)=>{const o={...r,...s};return s.pname||To(Eu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${r.pname}'`),s.cid||To(Eu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${r.cid}'`),s.uid||To(Eu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${r.uid}'`),o.pc=c,o},YT=(c={})=>{const s={...WT,...c};return s.name=VT(),s.version=qT(),s},si=(c,s,r,o=!1,a)=>{let t=c.map(n=>{if(!r)return n[s];if(!a)return n[s][r];const p=n[s][a];return p?p[r]:null});return t=t.filter(n=>o?Number.isFinite(n)&&n>0:Number.isFinite(n)),t.length===0?[]:t},Ns=c=>c.reduce((s,r)=>s+r,0)/c.length,zT=()=>`probe-${Zr()}`,JT=()=>`coltr-${Zr()}`,A_=c=>new Promise(s=>setTimeout(s,c)),Su=(c,s,r)=>{s?c.call(s,r):c(r)},We=(c,s,r,o)=>{const a=si(c,s,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},Xe=(c,s,r,o=!1,a)=>{const t=si(c,s,r,o,a);return t.length===0?null:t.reduce((n,p)=>n+p,0)/t.length},nn=(c,s,r)=>si(c,s,r).reduce((a,t)=>a+t,0),Ke=(c,s,r,o)=>{const a=si(c,s,r,!0,o);return a.length===0?null:Math.min(...a)},Ye=(c,s,r,o)=>{const a=si(c,s,r,!1,o);return a.length===0?null:Math.max(...a)},yt=(c,s,r,o)=>{const a=c.slice().pop();if(!a)return null;if(!r)return a[s];if(!o)return a[s][r];const t=a[s][o];return t?t[r]:null},XT=c=>c.slice().pop(),_t=(c,s,r)=>{if(!s)return null;const o={};let a=s[x.AUDIO][c];a||(a=r===$e.INBOUND?{...v_}:{...E_}),o[x.AUDIO]=a;let t=s[x.VIDEO][c];return t||(t=r===$e.INBOUND?{...S_}:{...y_}),o[x.VIDEO]=t,o},ni="exporter ",QT="2.0",C_=(c,s,r)=>{if(!c||c.length===0)return 0;const o=c[c.length-1];if(!o)return 0;const a=o[s][r];if(a){const t=a.total_rtt_ms_out,n=a.total_rtt_measure_out;return!n||!t?Xe(c,s,"delta_rtt_ms_out",!1,r):Number(t/n)}return null},ZT=(c,s)=>{if(!c||c.length===0)return 0;const r=c[c.length-1];if(!r)return 0;const o=r[s].total_rtt_connectivity_ms,a=r[s].total_rtt_connectivity_measure;return!a||!o?Xe(c,s,"delta_rtt_connectivity_ms"):Number(o/a)},ev=c=>yt(c,"network","local_candidate_type")!=="relay"?`direct/${yt(c,"network","local_candidate_protocol")}`:`turn/${yt(c,"network","local_candidate_relay_protocol")}`,tv=c=>{const s=yt(c,"network","remote_candidate_type"),r=yt(c,"network","remote_candidate_protocol");return s!=="relay"?`direct/${r}`:`turn/${r}`};class sv{constructor(s){this._start=null,this._end=null,this._cfg=s,this._referenceReport=null,this._reports=[],this._events=[]}start(){Tu(ni,"start() - start exporter...");const s=new Date;return this._start=s.toJSON(),s}stop(){Tu(ni,"stop() - stop exporter...");const s=new Date;return this._end=s.toJSON(),s}saveReferenceReport(s){this._referenceReport=s}getReferenceReport(){return this._referenceReport}addReport(s){this._cfg.ticket&&(Pe(ni,`addReport() - add report to exporter at ${s.timestamp}`),this._reports.push(s))}addCustomEvent(s){this._events.push(s)}reset(){Tu(ni,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Pe(ni,"ticket() - generate ticket");const s=yt(this._reports,"audio","total_packets_lost_in"),r=yt(this._reports,"audio","total_packets_in"),o=yt(this._reports,"video","total_packets_lost_in"),a=yt(this._reports,"video","total_packets_in"),t={},n=XT(this._reports);return n&&(Object.keys(n[x.AUDIO]).forEach(p=>{const _=n[x.AUDIO][p];if(t[_.ssrc]={type:x.AUDIO,direction:_.direction},_.direction===$e.INBOUND){const d={avg:Xe(this._reports,x.AUDIO,"delta_jitter_ms_in",!1,p),min:Ke(this._reports,x.AUDIO,"delta_jitter_ms_in",p),max:Ye(this._reports,x.AUDIO,"delta_jitter_ms_in",p),volatility:We(this._reports,x.AUDIO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.AUDIO,"delta_kbs_in",!1,p),min:Ke(this._reports,x.AUDIO,"delta_kbs_in",p),max:Ye(this._reports,x.AUDIO,"delta_kbs_in",p),volatility:We(this._reports,x.AUDIO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.AUDIO,"delta_KBytes_in",!1,p),min:Ke(this._reports,x.AUDIO,"delta_KBytes_in",p),max:Ye(this._reports,x.AUDIO,"delta_KBytes_in",p),volatility:We(this._reports,x.AUDIO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:Xe(this._reports,x.AUDIO,"mos_emodel_in",!1,p),min:Ke(this._reports,x.AUDIO,"mos_emodel_in",p),max:Ye(this._reports,x.AUDIO,"mos_emodel_in",p),volatility:We(this._reports,x.AUDIO,"mos_emodel_in",p)},effective:{avg:Xe(this._reports,x.AUDIO,"mos_in",!1,p),min:Ke(this._reports,x.AUDIO,"mos_in",p),max:Ye(this._reports,x.AUDIO,"mos_in",p),volatility:We(this._reports,x.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},y=yt(this._reports,x.AUDIO,"total_packets_lost_in",p),A=yt(this._reports,x.AUDIO,"total_packets_in",p),C={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=C}else{const d={avg:Xe(this._reports,x.AUDIO,"delta_jitter_ms_out",!1,p),min:Ke(this._reports,x.AUDIO,"delta_jitter_ms_out",p),max:Ye(this._reports,x.AUDIO,"delta_jitter_ms_out",p),volatility:We(this._reports,x.AUDIO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.AUDIO,"delta_kbs_out",!1,p),min:Ke(this._reports,x.AUDIO,"delta_kbs_out",p),max:Ye(this._reports,x.AUDIO,"delta_kbs_out",p),volatility:We(this._reports,x.AUDIO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.AUDIO,"delta_KBytes_out",!1,p),min:Ke(this._reports,x.AUDIO,"delta_KBytes_out",p),max:Ye(this._reports,x.AUDIO,"delta_KBytes_out",p),volatility:We(this._reports,x.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:C_(this._reports,x.AUDIO,p),min:Ke(this._reports,x.AUDIO,"delta_rtt_ms_out",p),max:Ye(this._reports,x.AUDIO,"delta_rtt_ms_out",p),volatility:We(this._reports,x.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=yt(this._reports,x.AUDIO,"total_packets_lost_out",p),A=yt(this._reports,x.AUDIO,"total_packets_out",p),C={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},I={emodel:{avg:Xe(this._reports,x.AUDIO,"mos_emodel_out",!1,p),min:Ke(this._reports,x.AUDIO,"mos_emodel_out",p),max:Ye(this._reports,x.AUDIO,"mos_emodel_out",p),volatility:We(this._reports,x.AUDIO,"mos_emodel_out",p)},effective:{avg:Xe(this._reports,x.AUDIO,"mos_out",!1,p),min:Ke(this._reports,x.AUDIO,"mos_out",p),max:Ye(this._reports,x.AUDIO,"mos_out",p),volatility:We(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=C,t[p].mos=I}}),Object.keys(n[x.VIDEO]).forEach(p=>{const _=n[x.VIDEO][p];if(t[p]={type:x.VIDEO,direction:_.direction},_.direction===$e.INBOUND){const d={avg:Xe(this._reports,x.VIDEO,"delta_jitter_ms_in",!1,p),min:Ke(this._reports,x.VIDEO,"delta_jitter_ms_in",p),max:Ye(this._reports,x.VIDEO,"delta_jitter_ms_in",p),volatility:We(this._reports,x.VIDEO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.VIDEO,"delta_kbs_in",!1,p),min:Ke(this._reports,x.VIDEO,"delta_kbs_in",p),max:Ye(this._reports,x.VIDEO,"delta_kbs_in",p),volatility:We(this._reports,x.VIDEO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.VIDEO,"delta_KBytes_in",!1,p),min:Ke(this._reports,x.VIDEO,"delta_KBytes_in",p),max:Ye(this._reports,x.VIDEO,"delta_KBytes_in",p),volatility:We(this._reports,x.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=yt(this._reports,x.VIDEO,"total_packets_lost_in",p),y=yt(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:Xe(this._reports,x.VIDEO,"delta_jitter_ms_out",!1,p),min:Ke(this._reports,x.VIDEO,"delta_jitter_ms_out",p),max:Ye(this._reports,x.VIDEO,"delta_jitter_ms_out",p),volatility:We(this._reports,x.VIDEO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.VIDEO,"delta_kbs_out",!1,p),min:Ke(this._reports,x.VIDEO,"delta_kbs_out",p),max:Ye(this._reports,x.VIDEO,"delta_kbs_out",p),volatility:We(this._reports,x.VIDEO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.VIDEO,"delta_KBytes_out",!1,p),min:Ke(this._reports,x.VIDEO,"delta_KBytes_out",p),max:Ye(this._reports,x.VIDEO,"delta_KBytes_out",p),volatility:We(this._reports,x.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:C_(this._reports,x.VIDEO,p),min:Ke(this._reports,x.VIDEO,"delta_rtt_ms_out",p),max:Ye(this._reports,x.VIDEO,"delta_rtt_ms_out",p),volatility:We(this._reports,x.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=yt(this._reports,x.VIDEO,"total_packets_lost_out",p),A=yt(this._reports,x.VIDEO,"total_packets_out",p),C={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=C}})),{version:QT,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:ZT(this._reports,"data"),min:Ke(this._reports,"data","delta_rtt_connectivity_ms"),max:Ye(this._reports,"data","delta_rtt_connectivity_ms"),volatility:We(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((s/(s+r)*100||0)*100)/100}},video:{in:{avg:Math.round((o/(o+a)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:Xe(this._reports,"data","delta_kbs_in"),min:Ke(this._reports,"data","delta_kbs_in"),max:Ye(this._reports,"data","delta_kbs_in"),volatility:We(this._reports,"data","delta_kbs_in")},out:{avg:Xe(this._reports,"data","delta_kbs_out"),min:Ke(this._reports,"data","delta_kbs_out"),max:Ye(this._reports,"data","delta_kbs_out"),volatility:We(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:Xe(this._reports,"data","delta_KBytes_in"),min:Ke(this._reports,"data","delta_KBytes_in"),max:Ye(this._reports,"data","delta_KBytes_in"),volatility:We(this._reports,"data","delta_KBytes_in")},out:{avg:Xe(this._reports,"data","delta_KBytes_out"),min:Ke(this._reports,"data","delta_KBytes_out"),max:Ye(this._reports,"data","delta_KBytes_out"),volatility:We(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:ev(this._reports),remoteConnection:tv(this._reports)}}}}updateConfig(s){this._cfg=s}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const s=this._reports.slice();return s.pop(),s.pop()||null}getReportsNumber(){return this._reports.length}}const Us="extractor ",R_=(c,s,r,o)=>{let a=!1;const t=o[s].total_rtt_ms_out,n=o[s].total_rtt_measure_out,p=r?r[s].total_rtt_ms_out:0,_=r?r[s].total_rtt_measure_out:0,d={rtt:null,totalRTT:t,totalRTTMeasurements:n};if(c[V.TIMESTAMP]===o[s].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])-_===n))return d;const g=1e3*Number(c[V.ROUND_TRIP_TIME]);let T=t+g,E=n+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}},nv=(c,s,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,V.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:o[s].total_rtt_connectivity_ms,totalRTTMeasurements:o[s].total_rtt_connectivity_measure};const a=1e3*Number(c[V.CURRENT_ROUND_TRIP_TIME]);let t=o[s].total_rtt_connectivity_ms+a,n=o[s].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[s].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,V.RESPONSES_RECEIVED)&&(n=Number(c[V.RESPONSES_RECEIVED])-(r?r[s].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:t,totalRTTMeasurements:n}},vo=(c,s,r)=>c[V.TIMESTAMP]===r[s].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.JITTER)?null:1e3*(Number(c[V.JITTER])||0),rv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:s[x.VIDEO].delta_ms_decode_frame_in,frames_decoded:s[x.VIDEO].total_frames_decoded_in,total_decode_time:s[x.VIDEO].total_time_decoded_in};const r=c[V.FRAMES_DECODED],o=c[V.TOTAL_DECODE_TIME],a=o-s[x.VIDEO].total_time_decoded_in,t=r-s[x.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:t>0?a*1e3/t:0,frames_decoded:r,total_decode_time:o}},iv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:s[x.VIDEO].delta_ms_encode_frame_out,frames_encoded:s[x.VIDEO].total_frames_encoded_out,total_encode_time:s[x.VIDEO].total_time_encoded_out};const r=c[V.FRAMES_ENCODED],o=c[V.TOTAL_ENCODE_TIME],a=o-s[x.VIDEO].total_time_encoded_out,t=r-s[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}},I_=(c,s,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_SENT))return{packetsSent:r[s].total_packets_out,packetsLost:r[s].total_packets_lost_out,bytesSent:r[s].total_KBytes_out};const a=Number(c[V.PACKETS_SENT])||0-(o?o[s].total_packets_out:0),t=a-r[s].total_packets_out,n=Number(c[V.BYTES_SENT])/1024-(o?o[s].total_KBytes_out:0),p=n-r[s].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:n,deltaKBytesSent:p,kbsSent:E}},b_=(c,s,r,o)=>{let a=r[s].total_packets_lost_out,t=0,n=0;return Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)&&(a=Number(c[V.PACKETS_LOST])||0-(o?o[s].total_packets_lost_out:0),t=a-r[s].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,V.FRACTION_LOST)&&(n=Number(100*c[V.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:t,fractionLost:n}},w_=(c,s,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[s].percent_packets_lost_in,packetsReceived:r[s].total_packets_in,packetsLost:r[s].total_packets_lost_in,bytesReceived:r[s].total_KBytes_in};const a=Number(c[V.PACKETS_RECEIVED])||0-(o?o[s].total_packets_in:0),t=Number(c[V.PACKETS_LOST])||0-(o?o[s].total_packets_lost_in:0),n=t-r[s].total_packets_lost_in,p=a-r[s].total_packets_in,_=a!==r[s].total_packets_in?n*100/(n+p):0,d=Number(c[V.BYTES_RECEIVED])/1024-(o?o[s].total_KBytes_in:0),g=d-r[s].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,C=A>0?g*.008*1024/A*1e3:0;return{percentPacketsLost:_,packetsReceived:a,deltaPacketsReceived:p,packetsLost:t,deltaPacketsLost:n,KBytesReceived:d,deltaKBytesReceived:g,kbsReceived:C}},lv=c=>c[V.CANDIDATE_TYPE]!=="relay"?"":c[V.RELAY_PROTOCOL]||"",ov=c=>{if(!Object.prototype.hasOwnProperty.call(c,V.NETWORK_TYPE))return ti.WIFI;switch(c[V.NETWORK_TYPE]){case vu.ETHERNET:return ti.ETHERNET;case vu.CELLULAR_4G:return ti.CELLULAR_4G;case vu.WIFI:return ti.WIFI;default:return ti.CELLULAR}},O_=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]},av=c=>{const s=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:s,durations:o,resolutionChanges:r}},uv=(c,s,r)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:s.total_pli_sent_in,nackCount:s.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-s[x.VIDEO].total_pli_sent_in,deltaNackCount:a-s[x.VIDEO].total_nack_sent_in}},cv=(c,s,r)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:s.total_pli_received_out,nackCount:s.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-s[x.VIDEO].total_pli_received_out,deltaNackCount:a-s[x.VIDEO].total_nack_received_out}},fv=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}),_v=c=>({clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null}),hv=(c,s,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(),n=o-s.data.total_KBytes_in,p=a-s.data.total_KBytes_out,_=r?r.timestamp:null;let d=s.timestamp;!d&&_&&(d=_);const g=d?t-d:0,T=g>0?n*.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:n,delta_KBytes_sent:p,kbs_speed_received:T,kbs_speed_sent:E}},dv=c=>{const s=c[V.AVAILABLE_INCOMING_BITRATE]/1024||0,r=c[V.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:s,kbs_outgoing_bandwidth:r}},pv=(c,s,r,o)=>{if(!c)return[];switch(c[V.TYPE]){case Yt.CANDIDATE_PAIR:let a=!1;if(c[V.NOMINATED]&&c[V.STATE]===x.SUCCEEDED&&(a=!0,Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c),V.SELECTED in c&&!c[V.SELECTED]&&(a=!1)),a){const n=c[V.LOCAL_CANDIDATE_ID],p=c[V.REMOTE_CANDIDATE_ID],_=hv(c,s,o),d=dv(c),g=nv(c,"data",o,s);return[{type:ne.NETWORK,value:{local_candidate_id:n}},{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 Yt.LOCAL_CANDIDATE:if(c[V.ID]===s.network.local_candidate_id)return[{type:ne.NETWORK,value:{infrastructure:ov(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:lv(c)}}];break;case Yt.REMOTE_CANDIDATE:if(c[V.ID]===s.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 Yt.INBOUND_RTP:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const n=c[V.SSRC],p=_t(n,s,$e.INBOUND);p&&(p.timestamp=s.timestamp);const _=_t(n,o,$e.INBOUND);if(_&&(_.timestamp=o.timestamp),c[V.MEDIA_TYPE]===x.AUDIO){const d=w_(c,x.AUDIO,p,_),g=vo(c,x.AUDIO,p),T=c[V.CODEC_ID]||"";return[{ssrc:n,type:ne.AUDIO,value:{codec_id_in:T}},{ssrc:n,type:ne.AUDIO,value:{total_packets_in:d.packetsReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_in:d.deltaPacketsReceived}},{ssrc:n,type:ne.AUDIO,value:{total_packets_lost_in:d.packetsLost}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_lost_in:d.deltaPacketsLost}},{ssrc:n,type:ne.AUDIO,value:{percent_packets_lost_in:d.percentPacketsLost}},{ssrc:n,type:ne.AUDIO,value:{total_KBytes_in:d.KBytesReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_KBytes_in:d.deltaKBytesReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_kbs_in:d.kbsReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[V.MEDIA_TYPE]===x.VIDEO){const d=rv(c,p),g=w_(c,x.VIDEO,p,_),T=vo(c,x.VIDEO,p),E=c[V.DECODER_IMPLEMENTATION]||null,y=c[V.CODEC_ID]||null,A=O_(c),C=uv(c,p,_);return[{ssrc:n,type:ne.VIDEO,value:{codec_id_in:y}},{ssrc:n,type:ne.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:n,type:ne.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:n,type:ne.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:n,type:ne.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_jitter_ms_in:T}},{ssrc:n,type:ne.VIDEO,value:{decoder_in:E}},{ssrc:n,type:ne.VIDEO,value:{delta_ms_decode_frame_in:d.delta_ms_decode_frame}},{ssrc:n,type:ne.VIDEO,value:{total_frames_decoded_in:d.frames_decoded}},{ssrc:n,type:ne.VIDEO,value:{total_time_decoded_in:d.total_decode_time}},{ssrc:n,type:ne.VIDEO,value:{total_nack_sent_in:C.nackCount}},{ssrc:n,type:ne.VIDEO,value:{delta_nack_sent_in:C.deltaNackCount}},{ssrc:n,type:ne.VIDEO,value:{total_pli_sent_in:C.pliCount}},{ssrc:n,type:ne.VIDEO,value:{delta_pli_sent_in:C.deltaPliCount}},{ssrc:n,type:ne.VIDEO,value:{size_in:A}}]}break}case Yt.OUTBOUND_RTP:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const n=c[V.SSRC],p=_t(n,s,$e.OUTBOUND);p&&(p.timestamp=s.timestamp);const _=_t(n,o,$e.OUTBOUND);if(_&&(_.timestamp=o.timestamp),c[V.MEDIA_TYPE]===x.AUDIO){const d=c[V.CODEC_ID]||null,g=I_(c,x.AUDIO,p,_);return[{ssrc:n,type:ne.AUDIO,value:{codec_id_out:d}},{ssrc:n,type:ne.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:n,type:ne.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:n,type:ne.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:n,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=iv(c,p),E=O_(c),y=av(c),A=cv(c,p,_),C=I_(c,x.VIDEO,p,_);return[{ssrc:n,type:ne.VIDEO,value:{codec_id_out:g}},{ssrc:n,type:ne.VIDEO,value:{total_packets_out:C.packetsSent}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_out:C.deltaPacketsSent}},{ssrc:n,type:ne.VIDEO,value:{total_KBytes_out:C.KBytesSent}},{ssrc:n,type:ne.VIDEO,value:{delta_KBytes_out:C.deltaKBytesSent}},{ssrc:n,type:ne.VIDEO,value:{delta_kbs_out:C.kbsSent}},{ssrc:n,type:ne.VIDEO,value:{encoder_out:d}},{ssrc:n,type:ne.VIDEO,value:{delta_ms_encode_frame_out:T.delta_ms_encode_frame}},{ssrc:n,type:ne.VIDEO,value:{total_frames_encoded_out:T.frames_encoded}},{ssrc:n,type:ne.VIDEO,value:{total_time_encoded_out:T.total_encode_time}},{ssrc:n,type:ne.VIDEO,value:{total_nack_received_out:A.nackCount}},{ssrc:n,type:ne.VIDEO,value:{delta_nack_received_out:A.deltaNackCount}},{ssrc:n,type:ne.VIDEO,value:{total_pli_received_out:A.pliCount}},{ssrc:n,type:ne.VIDEO,value:{delta_pli_received_out:A.deltaPliCount}},{ssrc:n,type:ne.VIDEO,value:{size_out:E}},{ssrc:n,type:ne.VIDEO,value:{limitation_out:y}}]}break}case Yt.MEDIA_SOURCE:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);break}case Yt.TRACK:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);break}case Yt.CODEC:const t=[];return Object.keys(s[x.AUDIO]).forEach(n=>{const p=s[x.AUDIO][n];if(p.codec_id_in===c[V.ID]||p.codec_id_out===c[V.ID]){Pe(Us,`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.AUDIO,value:{codec_in:_}}):t.push({ssrc:p.ssrc,type:ne.AUDIO,value:{codec_out:_}})}}),Object.keys(s[x.VIDEO]).forEach(n=>{const p=s[x.VIDEO][n];if(p.codec_id_in===c[V.ID]||p.codec_id_out===c[V.ID]){Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const _=_v(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 Yt.REMOTE_INBOUND_RTP:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const n=c[V.SSRC],p=_t(n,s,$e.OUTBOUND),_=_t(n,o,$e.OUTBOUND);if(c[V.KIND]===x.AUDIO){const d=R_(c,x.AUDIO,_,p),g=vo(c,x.AUDIO,p),T=b_(c,x.AUDIO,p,_);return[{ssrc:n,type:ne.AUDIO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:n,type:ne.AUDIO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:n,type:ne.AUDIO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:n,type:ne.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:n,type:ne.AUDIO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:n,type:ne.AUDIO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:n,type:ne.AUDIO,value:{percent_packets_lost_out:T.fractionLost}}]}if(c[V.KIND]===x.VIDEO){const d=R_(c,x.VIDEO,_,p),g=vo(c,x.VIDEO,p),T=b_(c,x.VIDEO,p,_);return[{ssrc:n,type:ne.VIDEO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:n,type:ne.VIDEO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:n,type:ne.VIDEO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:n,type:ne.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:n,type:ne.VIDEO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:n,type:ne.VIDEO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:n,type:ne.VIDEO,value:{percent_packets_lost_out:T.fractionLost}}]}break}}return[]},Eo=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),mv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.INBOUND),n=_t(a,r,$e.INBOUND),p=_t(a,o,$e.INBOUND),_=[],d=[],g=t[s].percent_packets_lost_in,T=t[s].delta_jitter_ms_in,E=n&&n[s].delta_jitter_ms_in||null,y=p&&p[s].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,C=r&&r.data.delta_rtt_connectivity_ms||null,I=o&&o.data.delta_rtt_connectivity_ms||null;A&&_.push(A),C&&_.push(C),I&&_.push(I),T&&d.push(T),r&&E&&d.push(E),o&&y&&d.push(y);const $=_.length>0?Ns(_):100,L=d.length>0?Ns(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 Eo(M)},gv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.OUTBOUND),n=_t(a,r,$e.OUTBOUND),p=_t(a,o,$e.OUTBOUND),_=[],d=[],g=t[s].percent_packets_lost_out,T=t[s].delta_rtt_ms_out,E=n&&n[s].delta_rtt_ms_out||null,y=p&&p[s].delta_rtt_ms_out||null,A=t[s].delta_jitter_ms_out,C=n&&n[s].delta_jitter_ms_out||null,I=p&&p[s].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&&C&&d.push(C),o&&I&&d.push(I);const N=_.length>0?Ns(_):100,F=d.length>0?Ns(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,B=.024*M+.11*(M-177.3)*D,q=ve-B;return Eo(q)},Tv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.INBOUND),n=_t(a,r,$e.INBOUND),p=_t(a,o,$e.INBOUND),_=[],d=[],g=t[s].percent_packets_lost_in/100,T=t[s].delta_jitter_ms_in,E=n&&n[s].delta_jitter_ms_in||null,y=p&&p[s].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,C=r&&r.data.delta_rtt_connectivity_ms||null,I=o&&o.data.delta_rtt_connectivity_ms||null;A&&_.push(A),C&&_.push(C),I&&_.push(I),T&&d.push(T),n&&E&&d.push(E),p&&y&&d.push(y);const $=_.length>0?Ns(_):100,L=d.length>0?Ns(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,q=93.2-(ae+N*Math.log(1+F*g)+D);return Eo(q)},vv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.OUTBOUND),n=_t(a,r,$e.OUTBOUND),p=_t(a,o,$e.OUTBOUND),_=[],d=[],g=t[s].percent_packets_lost_out/100,T=t[s].delta_rtt_ms_out,E=n&&n[s].delta_rtt_ms_out||null,y=p&&p[s].delta_rtt_ms_out||null,A=t[s].delta_jitter_ms_out,C=n&&n[s].delta_jitter_ms_out||null,I=p&&p[s].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),n&&C&&d.push(C),p&&I&&d.push(I);const N=_.length>0?Ns(_):100,F=d.length>0?Ns(d):10,Se=0,ve=19.8,M=29.7,D=30,B=(N+F)/2+D,q=B-177.3<0?0:1,z=.024*B+.11*(B-177.3)*q,Z=93.2-(Se+ve*Math.log(1+M*g)+z);return Eo(Z)};class Ev{constructor(s,r){this._callbacks={onreport:null,onticket:null},this._id=JT(),this._moduleName=this._id,this._probeId=r,this._config=s,this._exporter=new sv(s),this._state=gs.IDLE,this.registerToPCEvents(),sn(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(s,r,o,a){const t=(_,d)=>_===x.AUDIO?d===Yt.INBOUND_RTP?{...v_}:{...E_}:d===Yt.INBOUND_RTP?{...S_}:{...y_},n=GT(r);n.pname=this._config.pname,n.call_id=this._config.cid,n.user_id=this._config.uid,n.count=r?r.count+1:1;let p=null;return s.forEach(_=>{!p&&_.timestamp&&(p=_.timestamp),pv(_,n,n.pname,a).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let T=n[g.type][g.ssrc];T||(T=t(g.type,_.type),T.ssrc=g.ssrc,n[g.type][g.ssrc]=T),Object.keys(g.value).forEach(E=>{T[E]=g.value[E]})}else Object.keys(g.value).forEach(T=>{n[g.type][T]=g.value[T]})})}),n.timestamp=p,Object.keys(n[x.AUDIO]).forEach(_=>{const d=n[x.AUDIO][_];d.direction===$e.INBOUND?(d.mos_emodel_in=mv(n,x.AUDIO,r,o,d.ssrc),d.mos_in=Tv(n,x.AUDIO,r,o,d.ssrc)):(d.mos_emodel_out=gv(n,x.AUDIO,r,o,d.ssrc),d.mos_out=vv(n,x.AUDIO,r,o,d.ssrc))}),n}async takeReferenceStats(){return new Promise((s,r)=>{const o=Date.now();setTimeout(async()=>{try{const a=Date.now()-o,t=Date.now(),n=await this._config.pc.getStats(),p=this.analyze(n,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}`),s()}catch(a){r(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==gs.RUNNING||!this._config.pc)return Pe(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const s=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-s,this._exporter.addReport(o),Pe(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(o),o}catch(s){return Fn(this._moduleName,`got error ${s}`),null}}async start(){Pe(this._moduleName,"starting"),this.state=gs.RUNNING,this._startedTime=this._exporter.start(),Pe(this._moduleName,"started")}async mute(){this.state=gs.MUTED,Pe(this._moduleName,"muted")}async unmute(){this.state=gs.RUNNING,Pe(this._moduleName,"unmuted")}async stop(s){if(Pe(this._moduleName,`stopping${s?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=gs.IDLE,this._config.ticket){const{ticket:r}=this._exporter;this.fireOnTicket(r)}this._exporter.reset(),Pe(this._moduleName,"stopped")}registerCallback(s,r,o){s in this._callbacks?(this._callbacks[s]={callback:r,context:o},Pe(this._moduleName,`registered callback '${s}'`)):Fn(this._moduleName,`can't register callback for '${s}' - not found`)}unregisterCallback(s){s in this._callbacks?(this._callbacks[s]=null,delete this._callbacks[s],Pe(this._moduleName,`unregistered callback '${s}'`)):Fn(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReport(s){this._callbacks.onreport&&Su(this._callbacks.onreport.callback,this._callbacks.onreport.context,s)}fireOnTicket(s){this._callbacks.onticket&&Su(this._callbacks.onticket.callback,this._callbacks.onticket.context,s)}updateConfig(s){this._config=s,this._exporter.updateConfig(s)}get state(){return this._state}set state(s){this._state=s,Pe(this._moduleName,`state changed to ${s}`)}addCustomEvent(s,r,o,a){this._exporter.addCustomEvent({at:typeof s=="object"?s.toJSON():s,category:r,name:o,description:a})}async registerToPCEvents(){const{pc:s}=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{Fn(this._moduleName,"can't get devices")}},s){s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;o===ei.CONNECTED||o===ei.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===ei.DISCONNECTED||o===ei.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===ei.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},s.onicegatheringstatechange=()=>{const o=s.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",o,"ICE gathering state")},s.ontrack=o=>{this.addCustomEvent(new Date().toJSON(),"call",`${o.track.kind}track`,"MediaStreamTrack received")},s.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const r=s.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 Sv{constructor(s){this._id=s.pname&&s.pname.substr(0,12).padEnd(12," ")||zT(),this._moduleName=this._id,sn(this._moduleName,"probe created"),this._config=s,this._collector=new Ev(this._config,this._id)}set onreport(s){s?this._collector.registerCallback("onreport",s):this._collector.unregisterCallback("onreport")}set onticket(s){s?this._collector.registerCallback("onticket",s):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(s){this._collector.state=s}addCustomEvent(s,r,o,a=new Date().toJSON()){this._collector.addCustomEvent(a,r,s,o)}get isRunning(){return this._collector.state===gs.RUNNING}get isIdle(){return this._collector.state===gs.IDLE}updateUserId(s){this._config.uid=s,this._collector.updateConfig(this._config)}updateCallId(s){this._config.cid=s,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){To(this._moduleName,"probe is already running");return}this._collector.start()}stop(s=!1){this.isRunning&&this._collector.stop(s)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const It="engine ";class yv{constructor(s){this._config=s,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},sn(It,`configured for probing every ${this._config.refreshEvery}ms`),sn(It,`configured for starting after ${this._config.startAfter}ms`),sn(It,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Pe(It,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(s=>s.isRunning)}get isIdle(){return this._probes.every(s=>s.isIdle)}addNewProbe(s,r){if(!s)throw new Error("undefined peer connection");const o=KT(s,r,this._config),a=new Sv(o);return this._probes.push(a),Pe(It,`${this._probes.length} probes registered`),a}removeExistingProbe(s){if(!s)throw new Error("undefined probe");s.state===gs.RUNNING&&s.stop(),this._probes=this._probes.filter(r=>s.id!==r.id)}async start(){const s=()=>{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=BT(),n=this._probes.filter(p=>p.isRunning);for(const p of n){const _=await p.collectStats();_&&t.probes.push(_),Pe(It,`got probe ${p.id}`),await A_(0)}return t.delta_time_to_measure_probes_ms=nn(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=nn(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=nn(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=nn(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=nn(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=nn(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=nn(t.probes,"video","total_time_encoded_out"),t};for(Pe(It,"starting to collect"),s(),Pe(It,"generating reference reports..."),await r(),Pe(It,"reference reports generated"),this._startedTime=Date.now();o();)if(Pe(It,`wait ${this._config.refreshEvery}ms before collecting`),await A_(this._config.refreshEvery),o()){Pe(It,"collecting...");const t=Date.now(),n=await a(),p=Date.now();n.delta_time_consumed_to_measure_ms=p-t,this.fireOnReports(n),Pe(It,"collected")}Pe(It,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(s){const r=o=>{this._probes.forEach(a=>{a.stop(o)})};sn(It,"stop collecting"),r(s)}registerCallback(s,r,o){s in this._callbacks?(this._callbacks[s]={callback:r,context:o},Pe(It,`registered callback '${s}'`)):Fn(It,`can't register callback for '${s}' - not found`)}unregisterCallback(s){s in this._callbacks?(this._callbacks[s]=null,delete this._callbacks[s],Pe(this._moduleName,`unregistered callback '${s}'`)):Fn(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReports(s){this._callbacks.onresult&&s.probes.length>0&&Su(this._callbacks.onresult.callback,this._callbacks.onresult.context,s)}}const Av="interface ";class Cv{constructor(s){this._config=YT(s),sn(Av,`welcome to ${this._config.name} version ${this._config.version}`),kT(this._config.verbose||!1),this._engine=new yv(this._config)}setupLogLevel(s){LT(s)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(s,r){return this._engine.addNewProbe(s,r)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(s){this._engine.removeExistingProbe(s)}set onresult(s){s?this._engine.registerCallback("onresult",s):this._engine.unregisterCallback("onresult")}}function Rv(c,s){return Object.keys(c).filter(r=>s.includes(r)).reduce((r,o)=>{const a=o;return{...r,[a]:c[a]}},{})}const Iv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"];class bv{constructor(s){this.intervals={},this.emitInterval=s.emitInterval||200,this.onChangeFunction=s.onChangeFunction}start(s,r){s&&s.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(s,r))}stop(s){this.clearVolumeInterval(s)}clearVolumeInterval(s){console.log("clearVolumeInterval",s),clearInterval(this.intervals[s]),delete this.intervals[s]}clearAllIntervals(){Object.keys(this.intervals).forEach(s=>{clearInterval(this.intervals[s])}),this.intervals={}}beginCalculation(s,r){this.clearVolumeInterval(r);const o=tn.createAnalyser(),a=tn.createMediaStreamSource(s),t=tn.createScriptProcessor(2048,1,1);o.smoothingTimeConstant=.8,o.fftSize=1024,a.connect(o),o.connect(t),t.connect(tn.destination),this.intervals[r]=setInterval(()=>{const n=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(n);let p=0;const _=n.length;for(let g=0;g<_;g++)p+=n[g];const d=p/_;this.onChangeFunction(r,d)},this.emitInterval)}}const So={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},wv=0;class Ov{constructor(s){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=s,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new bv({onChangeFunction:this.emitVolumeChange.bind(this)}),this.initializeMediaDevices()}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(s){this.currentActiveRoomIdValue=s,this.context.emit("currentActiveRoomChanged",s)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(s){this.isCallAddingInProgress=s,this.context.emit("callAddingInProgressChanged",s)}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(s=>s.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(s=>s.kind==="audiooutput")}get getUserMediaConstraints(){return d_()?{video:!1,audio:!0}:{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(s){this.availableMediaDevices=s,this.context.emit("changeAvailableDeviceList",s)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const s=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(s)}async initializeMediaDevices(){const s=localStorage.getItem(So.SELECTED_INPUT_DEVICE)||"default",r=localStorage.getItem(So.SELECTED_OUTPUT_DEVICE)||"default";try{const o=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),a=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(a),await this.setMicrophone(s),await this.setSpeaker(r),navigator.mediaDevices.addEventListener("devicechange",async()=>{const t=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(t)}),o.getTracks().forEach(t=>t.stop())}catch(o){console.error(o)}}setCallTime(s){const r={...s};delete r.callId,this.callTime={...this.callTime,[s.callId]:r},this.context.emit("changeCallTime",this.callTime)}removeCallTime(s){const r={...this.callTime};delete r[s],this.callTime={...r},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(s,r){this.timeIntervals={...this.timeIntervals,[s]:r}}removeTimeInterval(s){const r={...this.timeIntervals};r[s]&&(clearInterval(r[s]),delete r[s],this.timeIntervals={...r})}stopCallTimer(s){this.removeTimeInterval(s),this.removeCallTime(s)}emitVolumeChange(s,r){this.context.emit("changeCallVolume",{callId:s,volume:r})}setMetricsConfig(s){this.metricConfig={...this.metricConfig,...s}}sendDTMF(s,r){if(!/^[A-D0-9]+$/g.test(r))throw new Error("Not allowed character in DTMF input");this.extendedCalls[s].sendDTMF(r)}setIsMuted(s){this.muted=s,this.context.emit("changeIsMuted",s)}processMute(s){const r=this.currentActiveRoomId;this.setIsMuted(s),this.initialStreamValue.getTracks().forEach(o=>o.enabled=!s),this.roomReconfigure(r)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:s,toHold:r,automatic:o}){const a=this.extendedCalls[s];a._automaticHold=o??!1,await new Promise(p=>{const _=()=>{p()};r?a.hold({},_):a.unhold({},_)}),this.updateCall(a);const n=Object.values(this.extendedCalls).filter(p=>p.roomId===this.currentActiveRoomId&&(r?s!==p._id:!0));n.length>1&&await this.doConference(n)}holdCall(s,r=!1){return this.processHold({callId:s,automatic:r,toHold:!0})}unholdCall(s){return this.processHold({callId:s,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(s=>s.direction==="outgoing"&&s.status===wv).forEach(s=>this.terminateCall(s._id))}answerCall(s){const r=this.extendedCalls[s];this.cancelAllOutgoingUnanswered(),r.answer(this.sipOptions),this.updateCall(r),this.setActiveRoom(r.roomId),r.connection.addEventListener("track",o=>{this.triggerAddStream(o,r)})}async moveCall(s,r){this.updateCallStatus({callId:s,isMoving:!0}),await this.processRoomChange({callId:s,roomId:r}),this.updateCallStatus({callId:s,isMoving:!1})}updateCall(s){this.activeCalls[s._id]=f_(s),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(s){const o={...this.activeRooms[s.roomId],...s};this.activeRooms={...this.activeRooms,[s.roomId]:{...o}},this.context.emit("updateRoom",{room:o,roomList:this.activeRooms})}hasAutoAnswerHeaders(s){const r=/answer-after=0/,a=s.request.getHeader("Call-Info");return a&&r.test(a)}addCall(s,r=!0){this.activeCalls={...this.activeCalls,[s._id]:f_(s)},this.extendedCalls[s._id]=s,r&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(s){this.callStatus={...this.callStatus,[s]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(s){const o={...{...this.callStatus[s.callId]}};s.isMoving!==void 0&&(o.isMoving=s.isMoving),s.isTransferring!==void 0&&(o.isTransferring=s.isTransferring),s.isMerging!==void 0&&(o.isMerging=s.isMerging),this.callStatus={...this.callStatus,[s.callId]:{...o}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(s){const r={...this.callStatus};delete r[s],this.callStatus={...r},this.context.emit("changeCallStatus",this.callStatus)}addRoom(s){this.activeRooms={...this.activeRooms,[s.roomId]:s},this.context.emit("addRoom",{room:s,roomList:this.activeRooms})}getActiveStream(){const s=h_(this.initialStreamValue,this.microphoneInputLevel*2);return s.getTracks().forEach(r=>r.enabled=!this.isMuted),this.setActiveStream(s),s}async setMicrophone(s){if(!this.getInputDeviceList.find(({deviceId:o})=>o===s)||(this.setSelectedInputDevice(s),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(s){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(s,"origin"),this.activeStreamValue=s,this.context.emit("changeActiveStream",s)}async setSpeaker(s){if(!this.getOutputDeviceList.find(({deviceId:a})=>a===s))return;this.setSelectedOutputDevice(s);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(s),this.updateCall(a)}):await this.doConference(o)}removeRoom(s){const r={...this.activeRooms},o={...r[s]};delete r[s],this.activeRooms={...r},this.context.emit("removeRoom",{room:o,roomList:this.activeRooms})}deleteRoomIfEmpty(s){s!==void 0&&Object.values(this.extendedCalls).filter(r=>r.roomId===s).length===0&&(this.removeRoom(s),this.currentActiveRoomId===s&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(s){this.muted?s.mute({audio:!0}):s.unmute({audio:!0})}async roomReconfigure(s){var o;if(s===void 0)return;const r=Object.values(this.extendedCalls).filter(a=>a.roomId===s);if(this.currentActiveRoomId===s?r.forEach(a=>{a.audioTag&&(this.muteReconfigure(a),a.audioTag.muted=!1,this.updateCall(a))}):r.forEach(a=>{a.audioTag&&(a.audioTag.muted=!0,this.updateCall(a))}),r.length===0)this.deleteRoomIfEmpty(s);else if(r.length===1&&this.currentActiveRoomId!==s)r[0].isOnHold().local||await this.holdCall(r[0].id,!0);else if(r.length===1&&this.currentActiveRoomId===s){if(r[0].isOnHold().local&&r[0]._automaticHold&&await this.unholdCall(r[0].id),r[0].connection&&((o=r[0].connection)!=null&&o.getSenders()[0])){const a=this.getActiveStream();await r[0].connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.muteReconfigure(r[0])}}else r.length>1&&await this.doConference(r)}async doConference(s){await m_.forEach(s,async o=>{o._localHold&&await this.unholdCall(o._id)});const r=[];s.forEach(o=>{o!=null&&o.connection.getReceivers().forEach(a=>{r.push(a.track)})}),await m_.forEach(s,async o=>{var n;if(o==null)return;const a=new MediaStream,t=tn.createMediaStreamDestination();if(o.connection.getReceivers().forEach(p=>{r.forEach(_=>{a.addTrack(p.track),p.track.id!==_.id&&tn.createMediaStreamSource(new MediaStream([_])).connect(t)})}),s[0].roomId===this.currentActiveRoomId){const p=this.getActiveStream();tn.createMediaStreamSource(p).connect(t)}(n=o.connection)!=null&&n.getSenders()[0]&&(await o.connection.getSenders()[0].replaceTrack(t.stream.getTracks()[0]),this.muteReconfigure(o))})}processCallerMute(s,r){const o=this.extendedCalls[s];o&&o.connection.getReceivers().length&&(o.localMuted=r,o.connection.getReceivers().forEach(a=>{a.track.enabled=!r}),this.updateCall(o))}muteCaller(s){this.processCallerMute(s,!0)}unmuteCaller(s){this.processCallerMute(s,!1)}terminateCall(s){const r=this.extendedCalls[s];r._status!==8&&r.terminate()}transferCall(s,r){if(r.toString().length===0)return new Error("Target must be passed");const o=this.extendedCalls[s];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:s,isTransferring:!0}),o.refer(`sip:${r}@${this.context.sipDomain}`),this.updateCall(o)}mergeCall(s){const r=Object.values(this.extendedCalls).filter(t=>t.roomId===s);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(s){this.isDNDEnabled=s,this.context.emit("changeIsDND",s)}startCallTimer(s){this.removeTimeInterval(s);const r={callId:s,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(r);const o=setInterval(()=>{const a={...this.callTime[s]},t=xT(a);this.setCallTime({callId:s,...t})},1e3);this.setTimeInterval(s,o)}async setActiveRoom(s){const r=this.currentActiveRoomId;s!==r&&(this.currentActiveRoomId=s,await this.roomReconfigure(r),await this.roomReconfigure(s))}getNewRoomId(){const s=Object.keys(this.activeRooms);return s.length===0?1:parseInt(s.sort()[s.length-1])+1}async setupCall(s){var d,g;const r=s.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(Kt.CALL_CONFIRMED,T=>{r.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(r.id))}),this.context.subscribe(Kt.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 n=r,p=this.hasAutoAnswerHeaders(s),_=n.direction==="incoming"&&!this.hasActiveCalls&&(p||this.autoAnswer);n.roomId=a,n.localMuted=!1,n.autoAnswer=_,_?this.addCall(n,!1):this.addCall(n),this.addCallStatus(r.id),this.addRoom(t),_&&this.answerCall(n._id)}removeCall(s){const r={...this.activeCalls};delete r[s],this.activeCalls={...r};const o={...this.extendedCalls};delete o[s],this.extendedCalls={...o},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(s){var a;const r=this.extendedCalls[s._id];this.stopVUMeter("origin"),(a=r.connection)==null||a.getSenders().forEach(t=>{t.track.stop()});const o=r.roomId;this.removeCall(s._id),this.roomReconfigure(o)}async newRTCSessionCallback(s){const r=s.session;if(this.isDND){r.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(this.context.triggerListener({listenerType:Kt.NEW_CALL,session:r,event:s}),r.on("ended",o=>{var t,n,p;this.stopVUMeter(r.id),this.context.logger.log("Session ended for",(n=(t=r._remote_identity)==null?void 0:t._uri)==null?void 0:n._user),this.context.triggerListener({listenerType:Kt.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),(p=this.initialStreamValue)==null||p.getTracks().forEach(_=>_.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:Kt.CALL_PROGRESS,session:r,event:o})}),r.on("failed",o=>{var t,n,p;this.stopVUMeter(r.id),this.context.logger.log("Session failed for",(n=(t=r._remote_identity)==null?void 0:t._uri)==null?void 0:n._user),this.context.triggerListener({listenerType:Kt.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),(p=this.initialStreamValue)==null||p.getTracks().forEach(_=>_.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:Kt.CALL_CONFIRMED,session:r,event:o}),this.updateCall(r),r.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(s),r.direction==="outgoing"){const o=this.getActiveCalls[r.id].roomId;this.setActiveRoom(o)}}setMuteWhenJoin(s){this.muteWhenJoinEnabled=s,this.context.emit("changeMuteWhenJoin",s)}setMicrophoneSensitivity(s){if(s<0||s>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=s,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(s){this.speakerVolumeValue=s,Object.values(this.extendedCalls).forEach(r=>{r.audioTag&&(r.audioTag.volume=s,this.updateCall(r))})}setAutoAnswer(s){this.isAutoAnswer=s}setSelectedInputDevice(s){localStorage.setItem(So.SELECTED_INPUT_DEVICE,s),this.selectedMediaDevices.input=s,this.context.emit("changeActiveInputMediaDevice",s)}setSelectedOutputDevice(s){localStorage.setItem(So.SELECTED_OUTPUT_DEVICE,s),this.selectedMediaDevices.output=s,this.context.emit("changeActiveOutputMediaDevice",s)}setCallMetrics(s){const r={...s};delete r.callId,this.callMetrics={...this.callMetrics,[s.callId]:r},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(s){const r={...this.callMetrics};delete r[s],this.callMetrics={...r},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(s){const r=new Cv(this.metricConfig),o=r.createProbe(s.connection,{cid:s._id}),a=[];let t;o.onreport=n=>{Object.entries(n.audio).forEach(([d,g])=>{g.direction==="inbound"&&!a.includes(d)&&(a.push(d),t=d)});const p=n.audio[t];if(!p)return;const _=Rv(p,Iv);_.callId=s._id,this.setCallMetrics(_)},this.context.subscribe(Kt.CALL_ENDED,n=>{n._id===s._id&&r.stopAllProbes()}),r.startAllProbes()}setupVUMeter(s,r){this.VUMeter.start(s,r)}stopVUMeter(s){this.VUMeter.stop(s)}async setupStream(){const s=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(r=>r.stop()),this.initialStreamValue=null),this.initialStreamValue=s}async triggerAddStream(s,r){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const o=h_(this.initialStreamValue,this.microphoneInputLevel*2),a=this.isMuted||this.muteWhenJoin;o.getTracks().forEach(n=>n.enabled=!a),this.setActiveStream(o),await r.connection.getSenders()[0].replaceTrack(o.getTracks()[0]);const t=new MediaStream([s.track]);vT(t,r,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(t,r._id),this.getCallQuality(r),this.updateCall(r)}initCall(s,r){if(this.checkInitialized(),s.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${s}@${this.context.sipDomain}...`);const o=this.context.call(`sip:${s}@${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:s,roomId:r}){const o=this.extendedCalls[s].roomId;this.extendedCalls[s].roomId=r;const a=this.extendedCalls[s];return this.updateCall(a),await this.setActiveRoom(r),Promise.all([this.roomReconfigure(o),this.roomReconfigure(r)]).then(()=>{this.deleteRoomIfEmpty(o),this.deleteRoomIfEmpty(r)})}}class Dv{constructor(s){this.context=s}get sipOptions(){return{...this.context.options.sipOptions}}initCall(s,r){if(s.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${s}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${s}@${this.context.sipDomain}`,r,this.sipOptions),console.log("video call")}stop(s={}){this.context.terminateJanusSessions(s)}}class Nv{constructor(s){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=s,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(s){const r=this.extendedMessages[s];this.updateMSRPSession(r)}updateMSRPSession(s){this.activeMessages[s._id]=__(s),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(s){this.activeMessages={...this.activeMessages,[s._id]:__(s)},this.extendedMessages[s._id]=s,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(s,r){const o=this.msrpHistory[r.id]||[];o.push(s),this.msrpHistory={...this.msrpHistory,[r.id]:[...o]},this.context.emit("newMSRPMessage",{message:s,session:r})}messageTerminate(s){const r=this.extendedMessages[s];r._status!==8&&r.terminate()}addMessageSession(s){if(!s._id||this.getActiveMessages[s._id]!==void 0)return;const o=s;this.addMMSRPSession(o)}triggerMSRPListener({listenerType:s,session:r,event:o}){const a=this.context.listenersList[s];!a||!a.length||a.forEach(t=>{t(r,o)})}removeMMSRPSession(s){const r={...this.activeMessages};delete r[s],this.activeMessages={...r};const o={...this.extendedMessages};delete o[s],this.extendedMessages={...o},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(s){this.removeMMSRPSession(s._id)}newMSRPSessionCallback(s){const r=s.session;r.on("ended",o=>{this.triggerMSRPListener({listenerType:Kt.CALL_ENDED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("failed",o=>{this.triggerMSRPListener({listenerType:Kt.CALL_FAILED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("confirmed",o=>{this.triggerMSRPListener({listenerType:Kt.CALL_CONFIRMED,session:r,event:o}),this.updateMSRPSession(r)}),r.on("newMessage",o=>{this.addMSRPMessage(o,r)}),this.addMessageSession(r)}setIsMSRPInitializing(s){this.isMSRPInitializingValue=s,this.context.emit("isMSRPInitializingChanged",s)}initMSRP(s,r,o){if(s.length===0)return console.error("Target must be a valid string");const a=this.context.startMSRP(s,o);a.on("active",()=>{this.addMessageSession(a),a.sendMSRP(r),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(s,r){const o=this.extendedMessages[s];if(!o)throw new Error(`MSRP session with id ${s} doesn't exist!`);o.sendMSRP(r)}}const yu={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class Uv extends _T{constructor(s,r){if(!s.modules.length)throw new Error("options.modules should include at least 1 module");const o={...s.configuration,sockets:s.socketInterfaces.map(a=>new PT.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=[],s.pnExtraHeaders&&Object.keys(s.pnExtraHeaders).length&&this.registrator().setExtraContactParams(s.pnExtraHeaders),this.options=s,this.modules=s.modules,r&&ET(r)&&(this.logger=r)}on(s,r){return super.on(s,r)}off(s,r){return super.off(s,r)}emit(s,r){return super.emit(s,r)}get sipDomain(){return this.options.sipDomain}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(yu.AUDIO)&&(this.audio=new Ov(this)),this.modules.includes(yu.MSRP)&&(this.msrp=new Nv(this)),this.modules.includes(yu.VIDEO)&&(this.video=new Dv(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(s,r){const a=!this.listenersList[s]||!this.listenersList[s].length?[r]:[...this.listenersList[s],r];this.listenersList={...this.listenersList,[s]:a}}removeIListener(s){const r={...this.listenersList};delete r[s],this.listenersList={...r}}triggerListener({listenerType:s,session:r,event:o}){const a=this.listenersList[s];!a||!a.length||a.forEach(t=>{t(r,o)})}setInitialized(s){this.initialized=s,this.emit("ready",s)}}return Uv}();
|
156
|
+
`),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new Nf(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=Ce.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=Ce.STATUS_INVITE_SENT}terminate(s={}){console.log("terminate",this);const r=s.cause||j.causes.BYE,o=Me.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,p=s.reason_phrase;if(this._status===Ce.STATUS_TERMINATED)throw new Is.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Ce.STATUS_NULL:case Ce.STATUS_INVITE_SENT:case Ce.STATUS_1XX_RECEIVED:if(n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(p=p||j.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;text="${p}"`),this._status===Ce.STATUS_NULL||this._status===Ce.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===Ce.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=Ce.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,j.causes.CANCELED);break;case Ce.STATUS_WAITING_FOR_ANSWER:case Ce.STATUS_ANSWERED:if(n=n||480,console.log("REPLY 480"),n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._request.reply(n,p,o,a),console.log("failed 2"),this._failed("local",null,j.causes.REJECTED);break;case Ce.STATUS_WAITING_FOR_ACK:case Ce.STATUS_CONFIRMED:if(p=s.reason_phrase||j.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${p}"`),this._status===Ce.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==$t.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:h})=>{h===j.ACK&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===$t.C.STATUS_TERMINATED&&(this.sendRequest(j.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else console.log("here it is"),this.sendRequest(j.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendRequest(s,r){return this._dialog.sendRequest(s,r)}authenticate(s){this.status="auth";let r=new Hn("");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`),s&&r.addHeader("Authorization",s.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(s){console.log("onmessage",s);const r=new Hn(s.data);if(this.status==="auth"&&r.code===401){const o=this.parseAuth(r.getHeader("WWW-Authenticate")),a=new Sm(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 s=new RTCPeerConnection({iceServers:[]});s.createDataChannel(""),s.createOffer().then(s.setLocalDescription.bind(s)),s.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],s.onicecandidate=()=>{},this.authenticate(null)}}onerror(s){console.log(s)}_receiveInviteResponse(s){if(console.log("resp0000000000000",s),this._dialog&&s.status_code>=200&&s.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.sendRequest(j.ACK);return}else{const r=new io(this,s,"UAC");if(r.error!==void 0){console.log(r.error);return}this.sendRequest(j.ACK),this.sendRequest(j.BYE);return}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==Ce.STATUS_INVITE_SENT&&this._status!==Ce.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(s.status_code):this._status=Ce.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){console.log("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=Ce.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const r={originator:"remote",type:"answer",sdp:s.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",s)).catch(a=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(console.log("maybe here???"),this._status=Ce.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,j.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",s,j.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;const r={originator:"remote",type:"answer",sdp:s.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(s,500,o.toString()),console.log("failed 4"),this._failed("local",s,j.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest(j.ACK),this._confirmed("local",null)});break}default:{const r=Me.sipErrorCause(s.status_code);console.log("failed 5"),this._failed("remote",s,r)}}}sendMSRP(s){const r=new Hn("");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=s;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(s){let r=s.ident,o=s.getHeader("Message-ID"),a=new Hn("");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 n=[];for(var p=0;p<t.length;p++)n.push(t.charCodeAt(p).toString(16));console.log(n),this._connection.send(a.toString())}_sendReport(s){let r=s.ident,o=s.getHeader("Message-ID"),a=new Hn("");a.method="REPORT",a.addHeader("To-Path",`${s.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 n=[];for(var p=0;p<t.length;p++)n.push(t.charCodeAt(p).toString(16));console.log(n),this._connection.send(a.toString())}parseAuth(s){const r={},o=s.replace("Digest","").split(",");for(const a of o){const t=a.trim().split("=");r[t[0]]=t[1].match('^"(.+)"$')[1]}return r}init_incoming(s,r){let o;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=Ce.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(o=s.getHeader("expires")*1e3),s.to_tag=Me.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Ce.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),console.log("failed 6"),this._failed("local",null,j.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Ce.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),console.log("failed 7"),this._failed("system",null,j.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,r&&r(this),s.parseSDP(!0),this.target_addr=s.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",s),this._status!==Ce.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(s,r,o){this.emit("_failed",{originator:s,message:r||null,cause:o}),this._close(),this.emit("failed",{originator:s,message:r||null,cause:o})}_close(){if(console.log("CLOSE SESSION"),this._status!==Ce.STATUS_TERMINATED){if(this._status=Ce.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){console.log("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyMSRPSession(this)}}_createDialog(s,r,o){const a=r==="UAS"?s.to_tag:s.from_tag,t=r==="UAS"?s.from_tag:s.to_tag,n=s.call_id+a+t;let p=this._earlyDialogs[n];if(o)return p?!0:(p=new io(this,s,r,io.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,r),this._dialog=p,delete this._earlyDialogs[n],!0;const _=new io(this,s,r);return _.error?(console.log("failed 9"),this._failed("remote",s,j.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_newMSRPSession(s,r){this._ua.newMSRPSession(this,{originator:s,session:this,request:r})}_progress(s,r){this.emit("progress",{originator:s,response:r||null})}isEnded(){switch(this._status){case Ce.STATUS_CANCELED:case Ce.STATUS_TERMINATED:return!0;default:return!1}}_accepted(s,r){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:s,response:r||null})}_confirmed(s,r){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:r||null})}_ended(s,r,o){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:s,message:r||null,cause:o})}_handleSessionTimersInIncomingResponse(s){if(!this._sessionTimers.enabled)return;let r;s.session_expires&&s.session_expires>=j.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,r=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,r="uac"),this._sessionTimers.refresher=r==="uac",this._runSessionTimer()}receiveRequest(s){if(console.log("receiveRequest()"),s.method===j.CANCEL)(this._status===Ce.STATUS_WAITING_FOR_ANSWER||this._status===Ce.STATUS_ANSWERED)&&(this._status=Ce.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",s,j.causes.CANCELED));else switch(s.method){case j.ACK:if(this._status!==Ce.STATUS_WAITING_FOR_ACK)return;if(this._status=Ce.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!s.body){this.terminate({cause:j.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:s.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",s)}).catch(a=>{this.terminate({cause:j.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",s);break;case j.BYE:this._status===Ce.STATUS_CONFIRMED||this._status===Ce.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,j.causes.BYE)):this._status===Ce.STATUS_INVITE_RECEIVED||this._status===Ce.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,j.causes.BYE)):s.reply(403,"Wrong Status");break;case j.INVITE:this._status===Ce.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case j.INFO:this._status===Ce.STATUS_1XX_RECEIVED||this._status===Ce.STATUS_WAITING_FOR_ANSWER||this._status===Ce.STATUS_ANSWERED||this._status===Ce.STATUS_WAITING_FOR_ACK||this._status===Ce.STATUS_CONFIRMED?(s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new za(this).init_incoming(s):s.reply(415):s.reply(403,"Wrong Status");break;case j.UPDATE:this._status===Ce.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case j.REFER:this._status===Ce.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case j.NOTIFY:this._status===Ce.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Ce.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.CONNECTION_ERROR,cause:j.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Ce.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:j.causes.REQUEST_TIMEOUT,cause:j.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Ce.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:j.causes.DIALOG_ERROR,cause:j.causes.DIALOG_ERROR})}}const ft=console,Ds={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},cT=sT;class fT extends cT{constructor(s){super(s),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[]}call(s,r){return super.call(s,r)}joinVideoCall(s,r,o){ft.debug("call()");const a=new go(this);return a.connect(s,r,o),a}_loadConfig(s){try{Qr.load(this._configuration,s)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Ln.newUUID()),this._configuration.jssip_id=Ln.createRandomToken(5);const r=this._configuration.uri.clone();r.user=null,this._configuration.hostport_params=r.toString().replace(/^sip:/i,"");try{this._transport=new wg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=_T.bind(this),this._transport.onconnect=hT.bind(this),this._transport.ondisconnect=dT.bind(this),this._transport.ondata=pT.bind(this)}catch(a){throw ft.warn(a),new Is.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 $n("sip",Ln.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,n=a.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),n&&(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}));ft.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Qr.settings,a))switch(a){case"uri":case"registrar_server":ft.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":ft.debug(`- ${a}: NOT SHOWN`);break;default:ft.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}newMSRPSession(s,r){s.on("msgHistoryUpdate",o=>{console.log(o)}),this._msrp_sessions[s.id]=s,this.emit("newMSRPSession",r)}newJanusSession(s,r){this._janus_sessions[s.id]=s,this.emit("newJanusSession",r)}destroyMSRPSession(s){delete this._msrp_sessions[s.id]}destroyJanusSession(s){delete this._janus_sessions[s.id]}receiveRequest(s){var t,n,p,_;const r=s.method;if(console.log("-----------"),s.ruri.user!==this._configuration.uri.user&&s.ruri.user!==this._contact.uri.user){ft.debug("Request-URI does not point to us"),s.method!==De.ACK&&s.reply_sl(404);return}if(s.ruri.scheme===De.SIPS){s.reply_sl(416);return}if($t.checkTransaction(this,s))return;if(r===De.INVITE?new $t.InviteServerTransaction(this,this._transport,s):r!==De.ACK&&r!==De.CANCEL&&new $t.NonInviteServerTransaction(this,this._transport,s),r===De.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new pf.Options(this).init_incoming(s)}else if(r===De.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new pf.Message(this).init_incoming(s)}else if(r===De.INVITE&&!s.to_tag&&this.listeners("newRTCSession").length===0){s.reply(405);return}let o,a;if(s.to_tag)if(o=this._findDialog(s.call_id,s.from_tag,s.to_tag),o)o.receiveRequest(s);else if(r===De.NOTIFY)if(a=this._findSession(s),a)a.receiveRequest(s);else{if(s.body)try{const h=JSON.parse(s.body)||{};(n=(t=h.plugindata)==null?void 0:t.data)!=null&&n.publishers&&Object.values(this._janus_sessions)[0].receivePublishers(h),(_=(p=h.plugindata)==null?void 0:p.data)!=null&&_.unpublished&&Object.values(this._janus_sessions)[0].receiveUnpublished(h.plugindata.data.unpublished)}catch(h){console.error(h)}s.reply(200)}else r!==De.ACK&&s.reply(481);else switch(r){case De.INVITE:if(window.RTCPeerConnection)if(s.hasHeader("replaces")){const h=s.replaces;o=this._findDialog(h.call_id,h.from_tag,h.to_tag),o?(a=o.owner,a.isEnded()?s.reply(603):a.receiveRequest(s)):s.reply(481)}else s.body.search(/MSRP/ig)>-1?(a=new pu(this),a.init_incoming(s)):s.body.search(/JANUS/ig)>-1||(a=new _g(this),a.init_incoming(s));else ft.warn("INVITE received but WebRTC is not supported"),s.reply(488);break;case De.BYE:s.reply(481);break;case De.CANCEL:a=this._findSession(s),a?a.receiveRequest(s):ft.debug("received CANCEL request for a non existent session");break;case De.ACK:break;case De.NOTIFY:this.emit("sipEvent",{event:s.event,request:s}),s.reply(200);break;default:s.reply(405);break}}startMSRP(s,r){ft.debug("startMSRP()",r);const o=new pu(this);return o.connect(s),o}startJanus(s,r){ft.debug("startJanus()",r);const o=new pu(this);return o.connect(s),o}terminateMSRPSessions(s){ft.debug("terminateSessions()");for(const r in this._msrp_sessions)this._msrp_sessions[r].isEnded()||this._msrp_sessions[r].terminate(s)}terminateJanusSessions(s){ft.debug("terminateSessions()");for(const r in this._janus_sessions)this._janus_sessions[r].isEnded()||this._janus_sessions[r].terminate(s)}stop(){if(ft.debug("stop()"),this._dynConfiguration={},this._status===Ds.STATUS_USER_CLOSED){ft.debug("UA already closed");return}this._registrator.close();const s=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){ft.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)){ft.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)){ft.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=Ds.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&&s===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}function _T(c){this.emit("connecting",c)}function hT(c){this._status!==Ds.STATUS_USER_CLOSED&&(this._status=Ds.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function dT(c){const s=["nict","ict","nist","ist"];for(const r of s)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!==Ds.STATUS_USER_CLOSED&&(this._status=Ds.STATUS_NOT_READY,this._error=Ds.NETWORK_ERROR)}function pT(c){console.log("onTransportData",c);const s=c.transport;let r=c.message;if(r=su.parseMessage(r,this),!r){console.log("if 1 return");return}if(this._status===Ds.STATUS_USER_CLOSED&&r instanceof eo.IncomingRequest){console.log("if 2 return");return}if(!qg(r,this,s)){console.log("if 3 return");return}if(console.log("onTransportData message",r),console.log("onTransportData instanceof",r instanceof eo.IncomingRequest),r instanceof eo.IncomingRequest)r.transport=s,console.log("onTransportData receiveRequest"),this.receiveRequest(r);else if(r instanceof eo.IncomingResponse){let o;switch(r.method){case De.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case De.ACK:break;default:o=this._transactions.nict[r.via_branch],o&&o.receiveResponse(r);break}}}const mT=["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"],gT=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function f_(c){const s={};return mT.forEach(r=>{c[r]!==void 0&&(s[r]=c[r])}),s.localHold=c._localHold,s}function __(c){const s={};return gT.forEach(r=>{c[r]!==void 0&&(s[r]=c[r])}),s}function h_(c,s){const r=new AudioContext,o=r.createMediaStreamSource(c),a=r.createMediaStreamDestination(),t=r.createGain();return o.connect(t),t.connect(a),t.gain.value=s,a.stream}function TT(c,s,r,o){const a=document.createElement("audio");a.id=s._id,a.className="audioTag",a.srcObject=c,d_()||(a.setSinkId(r),a.volume=o),a.play(),s.audioTag=a}function vT(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}function d_(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}const ET=lt,ST=es(),wt=new ET("WebSocketInterface");var yT=class{constructor(s){wt.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;const r=ST.parse(s,"absoluteURI");if(r===-1)throw wt.warn(`invalid WebSocket URI: ${s}`),new TypeError(`Invalid argument: ${s}`);if(r.scheme!=="wss"&&r.scheme!=="ws")throw wt.warn(`invalid WebSocket URI scheme: ${r.scheme}`),new TypeError(`Invalid argument: ${s}`);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(s){this._via_transport=s.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(wt.debug("connect()"),this.isConnected()){wt.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){wt.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),wt.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(s){this._onError(s)}}disconnect(){wt.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(s){return wt.debug("send()"),this.isConnected()?(this._ws.send(s),!0):(wt.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(){wt.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:s,code:r,reason:o}){wt.debug(`WebSocket ${this._url} closed`),s===!1&&wt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!s,r,o)}_onMessage({data:s}){wt.debug("received WebSocket message"),this.ondata(s)}_onError(s){wt.warn(`WebSocket ${this._url} error: `,s)}};const mu=dl,AT=De,CT=ds,RT=mt(),IT=a_,bT=fs(),wT=ka(),OT=es(),DT=yT;wn("JsSIP")("version %s",mu.version);var NT={C:AT,Exceptions:CT,Utils:RT,UA:IT,URI:bT,NameAddrHeader:wT,WebSocketInterface:DT,Grammar:OT,debug:wn,get name(){return mu.title},get version(){return mu.version}};const UT=ke(NT);function gu(c){return c<10?`0${c}`:`${c}`}function PT(c){let s=c.hours||0,r=c.minutes||0,o=c.seconds||0;o++,o===60&&(o=0,r++,r===60&&(r=0,s++));const a=`${gu(s)}:${gu(r)}:${gu(o)}`;return{seconds:o,minutes:r,hours:s,formatted:a}}var St={};St.forEach=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)if(a in c){const t=Promise.resolve(c[a]).then(n=>s.call(r||globalThis,n,a,c));o.push(t)}await Promise.all(o)},St.forEachSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)o in c&&await s.call(r||globalThis,await c[o],o,c)},St.map=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=Promise.resolve(c[a]).then(t=>s.call(r||globalThis,t,a,c)));return Promise.all(o)},St.mapSeries=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=await s.call(r||globalThis,await c[a],a,c));return o},St.find=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o();let t=1;for(let n=0;n<c.length;n++){const p=_=>{_?o(c[n]):t===c.length&&o(),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.findSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(await s.call(r||globalThis,await c[o],o,c))return c[o]},St.findIndex=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o(-1);let t=1;for(let n=0;n<c.length;n++){const p=_=>{_?o(n):t===c.length&&o(-1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.findIndexSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(await s.call(r||globalThis,await c[o],o,c))return o},St.some=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o(!1);let t=1;for(let n=0;n<c.length;n++){if(!(n in c)){t++;continue}const p=_=>{_?o(!0):t===c.length&&o(!1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.someSeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(o in c&&await s.call(r||globalThis,await c[o],o,c))return!0;return!1},St.every=(c,s,r)=>new Promise((o,a)=>{if(c.length===0)return o(!0);let t=1;for(let n=0;n<c.length;n++){if(!(n in c)){t++;continue}const p=_=>{_?t===c.length&&o(!0):o(!1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(p).catch(a)}}),St.everySeries=async(c,s,r)=>{for(let o=0;o<c.length;o++)if(o in c&&!await s.call(r||globalThis,await c[o],o,c))return!1;return!0},St.filter=(c,s,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(_=>s.call(r||globalThis,_,p,c)).catch(a));const n=[];for(let p=0;p<t.length;p++)await t[p]&&n.push(await c[p]);o(n)}),St.filterSeries=async(c,s,r)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&await s.call(r||globalThis,await c[a],a,c)&&o.push(await c[a]);return o},St.reduce=async(c,s,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 s(await a,await c[o],o,c));return a};var p_={};(function(c){const s=St;Object.keys(s).forEach(r=>{const o=r.charAt(0).toUpperCase()+r.slice(1);c[`async${o}`]=async function(...a){return s[r](this,...a)}})})(p_);var xT=Object.assign(St,{instanceMethods:p_});const tn=new AudioContext,Kt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var MT={exports:{}};(function(c){var s=function(r){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(ee,Y,G){ee[Y]=G.value},n,p=typeof Symbol=="function"?Symbol:{},_=p.iterator||"@@iterator",h=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function T(ee,Y,G){return Object.defineProperty(ee,Y,{value:G,enumerable:!0,configurable:!0,writable:!0}),ee[Y]}try{T({},"")}catch{T=function(Y,G,re){return Y[G]=re}}function E(ee,Y,G,re){var ge=Y&&Y.prototype instanceof ae?Y:ae,be=Object.create(ge.prototype),xe=new P(re||[]);return t(be,"_invoke",{value:J(ee,G,xe)}),be}r.wrap=E;function y(ee,Y,G){try{return{type:"normal",arg:ee.call(Y,G)}}catch(re){return{type:"throw",arg:re}}}var A="suspendedStart",C="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 B(ee){["next","throw","return"].forEach(function(Y){T(ee,Y,function(G){return this._invoke(Y,G)})})}r.isGeneratorFunction=function(ee){var Y=typeof ee=="function"&&ee.constructor;return Y?Y===N||(Y.displayName||Y.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 q(ee,Y){function G(be,xe,Re,le){var ye=y(ee[be],ee,xe);if(ye.type==="throw")le(ye.arg);else{var it=ye.arg,ot=it.value;return ot&&typeof ot=="object"&&a.call(ot,"__await")?Y.resolve(ot.__await).then(function(Ee){G("next",Ee,Re,le)},function(Ee){G("throw",Ee,Re,le)}):Y.resolve(ot).then(function(Ee){it.value=Ee,Re(it)},function(Ee){return G("throw",Ee,Re,le)})}}var re;function ge(be,xe){function Re(){return new Y(function(le,ye){G(be,xe,le,ye)})}return re=re?re.then(Re,Re):Re()}t(this,"_invoke",{value:ge})}B(q.prototype),T(q.prototype,h,function(){return this}),r.AsyncIterator=q,r.async=function(ee,Y,G,re,ge){ge===void 0&&(ge=Promise);var be=new q(E(ee,Y,G,re),ge);return r.isGeneratorFunction(Y)?be:be.next().then(function(xe){return xe.done?xe.value:be.next()})};function J(ee,Y,G){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 rt()}for(G.method=be,G.arg=xe;;){var Re=G.delegate;if(Re){var le=H(Re,G);if(le){if(le===L)continue;return le}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(re===A)throw re=$,G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);re=I;var ye=y(ee,Y,G);if(ye.type==="normal"){if(re=G.done?$:C,ye.arg===L)continue;return{value:ye.arg,done:G.done}}else ye.type==="throw"&&(re=$,G.method="throw",G.arg=ye.arg)}}}function H(ee,Y){var G=Y.method,re=ee.iterator[G];if(re===n)return Y.delegate=null,G==="throw"&&ee.iterator.return&&(Y.method="return",Y.arg=n,H(ee,Y),Y.method==="throw")||G!=="return"&&(Y.method="throw",Y.arg=new TypeError("The iterator does not provide a '"+G+"' method")),L;var ge=y(re,ee.iterator,Y.arg);if(ge.type==="throw")return Y.method="throw",Y.arg=ge.arg,Y.delegate=null,L;var be=ge.arg;if(!be)return Y.method="throw",Y.arg=new TypeError("iterator result is not an object"),Y.delegate=null,L;if(be.done)Y[ee.resultName]=be.value,Y.next=ee.nextLoc,Y.method!=="return"&&(Y.method="next",Y.arg=n);else return be;return Y.delegate=null,L}B(D),T(D,g,"Generator"),T(D,_,function(){return this}),T(D,"toString",function(){return"[object Generator]"});function Z(ee){var Y={tryLoc:ee[0]};1 in ee&&(Y.catchLoc=ee[1]),2 in ee&&(Y.finallyLoc=ee[2],Y.afterLoc=ee[3]),this.tryEntries.push(Y)}function U(ee){var Y=ee.completion||{};Y.type="normal",delete Y.arg,ee.completion=Y}function P(ee){this.tryEntries=[{tryLoc:"root"}],ee.forEach(Z,this),this.reset(!0)}r.keys=function(ee){var Y=Object(ee),G=[];for(var re in Y)G.push(re);return G.reverse(),function ge(){for(;G.length;){var be=G.pop();if(be in Y)return ge.value=be,ge.done=!1,ge}return ge.done=!0,ge}};function se(ee){if(ee){var Y=ee[_];if(Y)return Y.call(ee);if(typeof ee.next=="function")return ee;if(!isNaN(ee.length)){var G=-1,re=function ge(){for(;++G<ee.length;)if(a.call(ee,G))return ge.value=ee[G],ge.done=!1,ge;return ge.value=n,ge.done=!0,ge};return re.next=re}}return{next:rt}}r.values=se;function rt(){return{value:n,done:!0}}return P.prototype={constructor:P,reset:function(ee){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(U),!ee)for(var Y in this)Y.charAt(0)==="t"&&a.call(this,Y)&&!isNaN(+Y.slice(1))&&(this[Y]=n)},stop:function(){this.done=!0;var ee=this.tryEntries[0],Y=ee.completion;if(Y.type==="throw")throw Y.arg;return this.rval},dispatchException:function(ee){if(this.done)throw ee;var Y=this;function G(le,ye){return be.type="throw",be.arg=ee,Y.next=le,ye&&(Y.method="next",Y.arg=n),!!ye}for(var re=this.tryEntries.length-1;re>=0;--re){var ge=this.tryEntries[re],be=ge.completion;if(ge.tryLoc==="root")return G("end");if(ge.tryLoc<=this.prev){var xe=a.call(ge,"catchLoc"),Re=a.call(ge,"finallyLoc");if(xe&&Re){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0);if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else if(xe){if(this.prev<ge.catchLoc)return G(ge.catchLoc,!0)}else if(Re){if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(ee,Y){for(var G=this.tryEntries.length-1;G>=0;--G){var re=this.tryEntries[G];if(re.tryLoc<=this.prev&&a.call(re,"finallyLoc")&&this.prev<re.finallyLoc){var ge=re;break}}ge&&(ee==="break"||ee==="continue")&&ge.tryLoc<=Y&&Y<=ge.finallyLoc&&(ge=null);var be=ge?ge.completion:{};return be.type=ee,be.arg=Y,ge?(this.method="next",this.next=ge.finallyLoc,L):this.complete(be)},complete:function(ee,Y){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"&&Y&&(this.next=Y),L},finish:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.finallyLoc===ee)return this.complete(G.completion,G.afterLoc),U(G),L}},catch:function(ee){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var G=this.tryEntries[Y];if(G.tryLoc===ee){var re=G.completion;if(re.type==="throw"){var ge=re.arg;U(G)}return ge}}throw new Error("illegal catch attempt")},delegateYield:function(ee,Y,G){return this.delegate={iterator:se(ee),resultName:Y,nextLoc:G},this.method==="next"&&(this.arg=n),L}},r}(c.exports);try{regeneratorRuntime=s}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=s:Function("r","regeneratorRuntime = r")(s)}})(MT);var m_={exports:{}};(function(c){(function(s,r){c.exports?c.exports=r():s.log=r()})(Gs,function(){var s=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(C,I){var $=C[I];if(typeof $.bind=="function")return $.bind(C);try{return Function.prototype.bind.call($,C)}catch{return function(){return Function.prototype.apply.apply($,[C,arguments])}}}function n(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(C){return C==="debug"&&(C="log"),typeof console===r?!1:C==="trace"&&o?n:console[C]!==void 0?t(console,C):console.log!==void 0?t(console,"log"):s}function _(C,I){for(var $=0;$<a.length;$++){var L=a[$];this[L]=$<C?s:this.methodFactory(L,C,I)}this.log=this.debug}function h(C,I,$){return function(){typeof console!==r&&(_.call(this,I,$),this[C].apply(this,arguments))}}function g(C,I,$){return p(C)||h.apply(this,arguments)}function T(C,I,$){var L=this,ae;I=I??"WARN";var N="loglevel";typeof C=="string"?N+=":"+C:typeof C=="symbol"&&(N=void 0);function F(D){var B=(a[D]||"silent").toUpperCase();if(!(typeof window===r||!N)){try{window.localStorage[N]=B;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+B+";"}catch{}}}function Se(){var D;if(!(typeof window===r||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===r)try{var B=window.document.cookie,q=B.indexOf(encodeURIComponent(N)+"=");q!==-1&&(D=/^([^;]+)/.exec(B.slice(q))[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=C,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,B){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,B!==!1&&F(D),_.call(L,D,C),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})})(m_);var Rt=m_.exports;const ps=()=>`${new Date().toISOString()} | metrics`,ms=(c,s,r)=>`${c} | ${s} | ${r}`;Rt.setDefaultLevel(Rt.levels.TRACE);const kT=c=>{Rt.info(ms(ps(),"log ",`set log level to ${c?"verbose":"info"}`)),Rt.setLevel(c?Rt.levels.TRACE:Rt.levels.INFO)},LT=c=>{const s=[...Object.keys(Rt.levels)];s.includes(c)?(Rt.info(ms(ps(),"log ",`update log level to ${c.toLowerCase()}`)),Rt.setLevel(c)):Rt.warn(ms(ps(),"log ","Incorrect log level please choose one of "),s)},Pe=(c,s,r)=>{r?Rt.debug(ms(ps(),c,s),r):Rt.debug(ms(ps(),c,s))},Tu=(c,s)=>{Rt.info(ms(ps(),c,s))},sn=(c,s)=>{Rt.info(ms(ps(),c,s))},To=(c,s)=>{Rt.warn(ms(ps(),c,s))},Fn=(c,s)=>{Rt.error(ms(ps(),c,s))};function $T(c){return Math.floor(Math.random()*c).toString()}function g_(c,s){let r=s;return c.forEach(o=>{r=r.replace(o,"")}),r}function HT(c,s){let r="";for(let o=0;o<s;o+=1)r+=c[$T(c.length)];return r}function FT({length:c=20,useLetters:s=!0,useNumbers:r=!0,includeSymbols:o=[],excludeSymbols:a=[]}={}){let t="abcdefghijklmnopqrstuvwxyz",n="0123456789",p=[],_=[],h=[];return s&&(a.length&&(t=g_(a,t)),_=t.split("")),r&&(a.length&&(n=g_(a,n)),h=n.split("")),p=[..._,...h,...o],HT(p,c)}var jT=FT;const Zr=ke(jT),VT=()=>"WebRTCMetrics",qT=()=>"5.0.3",$e={INBOUND:"inbound",OUTBOUND:"outbound"},gs={IDLE:"idle",RUNNING:"running",MUTED:"muted"},ei={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},BT=()=>({...{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:[]}}),T_={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},v_={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},E_={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},S_={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},GT=c=>{const s={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{...s,audio:{},video:{},data:{...s.data},network:{...s.network},experimental:{...s.experimental}}},WT={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${Zr()}`,cid:`c-${Zr()}`,uid:`u-${Zr()}`,record:!1,ticket:!0},Yt={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"},ti={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},vu={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ne={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},Eu="config ",KT=(c,s={},r)=>{const o={...r,...s};return s.pname||To(Eu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${r.pname}'`),s.cid||To(Eu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${r.cid}'`),s.uid||To(Eu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${r.uid}'`),o.pc=c,o},YT=(c={})=>{const s={...WT,...c};return s.name=VT(),s.version=qT(),s},si=(c,s,r,o=!1,a)=>{let t=c.map(n=>{if(!r)return n[s];if(!a)return n[s][r];const p=n[s][a];return p?p[r]:null});return t=t.filter(n=>o?Number.isFinite(n)&&n>0:Number.isFinite(n)),t.length===0?[]:t},Ns=c=>c.reduce((s,r)=>s+r,0)/c.length,JT=()=>`probe-${Zr()}`,zT=()=>`coltr-${Zr()}`,y_=c=>new Promise(s=>setTimeout(s,c)),Su=(c,s,r)=>{s?c.call(s,r):c(r)},We=(c,s,r,o)=>{const a=si(c,s,r,!0,o);if(a.length===0)return null;const t=a.reduce((h,g)=>h+g,0)/a.length;return t===0?null:a.map(h=>Math.abs(t-h)).reduce((h,g)=>h+g,0)/a.length*100/t},Xe=(c,s,r,o=!1,a)=>{const t=si(c,s,r,o,a);return t.length===0?null:t.reduce((n,p)=>n+p,0)/t.length},nn=(c,s,r)=>si(c,s,r).reduce((a,t)=>a+t,0),Ke=(c,s,r,o)=>{const a=si(c,s,r,!0,o);return a.length===0?null:Math.min(...a)},Ye=(c,s,r,o)=>{const a=si(c,s,r,!1,o);return a.length===0?null:Math.max(...a)},yt=(c,s,r,o)=>{const a=c.slice().pop();if(!a)return null;if(!r)return a[s];if(!o)return a[s][r];const t=a[s][o];return t?t[r]:null},XT=c=>c.slice().pop(),_t=(c,s,r)=>{if(!s)return null;const o={};let a=s[x.AUDIO][c];a||(a=r===$e.INBOUND?{...T_}:{...v_}),o[x.AUDIO]=a;let t=s[x.VIDEO][c];return t||(t=r===$e.INBOUND?{...E_}:{...S_}),o[x.VIDEO]=t,o},ni="exporter ",QT="2.0",A_=(c,s,r)=>{if(!c||c.length===0)return 0;const o=c[c.length-1];if(!o)return 0;const a=o[s][r];if(a){const t=a.total_rtt_ms_out,n=a.total_rtt_measure_out;return!n||!t?Xe(c,s,"delta_rtt_ms_out",!1,r):Number(t/n)}return null},ZT=(c,s)=>{if(!c||c.length===0)return 0;const r=c[c.length-1];if(!r)return 0;const o=r[s].total_rtt_connectivity_ms,a=r[s].total_rtt_connectivity_measure;return!a||!o?Xe(c,s,"delta_rtt_connectivity_ms"):Number(o/a)},ev=c=>yt(c,"network","local_candidate_type")!=="relay"?`direct/${yt(c,"network","local_candidate_protocol")}`:`turn/${yt(c,"network","local_candidate_relay_protocol")}`,tv=c=>{const s=yt(c,"network","remote_candidate_type"),r=yt(c,"network","remote_candidate_protocol");return s!=="relay"?`direct/${r}`:`turn/${r}`};class sv{constructor(s){this._start=null,this._end=null,this._cfg=s,this._referenceReport=null,this._reports=[],this._events=[]}start(){Tu(ni,"start() - start exporter...");const s=new Date;return this._start=s.toJSON(),s}stop(){Tu(ni,"stop() - stop exporter...");const s=new Date;return this._end=s.toJSON(),s}saveReferenceReport(s){this._referenceReport=s}getReferenceReport(){return this._referenceReport}addReport(s){this._cfg.ticket&&(Pe(ni,`addReport() - add report to exporter at ${s.timestamp}`),this._reports.push(s))}addCustomEvent(s){this._events.push(s)}reset(){Tu(ni,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Pe(ni,"ticket() - generate ticket");const s=yt(this._reports,"audio","total_packets_lost_in"),r=yt(this._reports,"audio","total_packets_in"),o=yt(this._reports,"video","total_packets_lost_in"),a=yt(this._reports,"video","total_packets_in"),t={},n=XT(this._reports);return n&&(Object.keys(n[x.AUDIO]).forEach(p=>{const _=n[x.AUDIO][p];if(t[_.ssrc]={type:x.AUDIO,direction:_.direction},_.direction===$e.INBOUND){const h={avg:Xe(this._reports,x.AUDIO,"delta_jitter_ms_in",!1,p),min:Ke(this._reports,x.AUDIO,"delta_jitter_ms_in",p),max:Ye(this._reports,x.AUDIO,"delta_jitter_ms_in",p),volatility:We(this._reports,x.AUDIO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.AUDIO,"delta_kbs_in",!1,p),min:Ke(this._reports,x.AUDIO,"delta_kbs_in",p),max:Ye(this._reports,x.AUDIO,"delta_kbs_in",p),volatility:We(this._reports,x.AUDIO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.AUDIO,"delta_KBytes_in",!1,p),min:Ke(this._reports,x.AUDIO,"delta_KBytes_in",p),max:Ye(this._reports,x.AUDIO,"delta_KBytes_in",p),volatility:We(this._reports,x.AUDIO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:Xe(this._reports,x.AUDIO,"mos_emodel_in",!1,p),min:Ke(this._reports,x.AUDIO,"mos_emodel_in",p),max:Ye(this._reports,x.AUDIO,"mos_emodel_in",p),volatility:We(this._reports,x.AUDIO,"mos_emodel_in",p)},effective:{avg:Xe(this._reports,x.AUDIO,"mos_in",!1,p),min:Ke(this._reports,x.AUDIO,"mos_in",p),max:Ye(this._reports,x.AUDIO,"mos_in",p),volatility:We(this._reports,x.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},y=yt(this._reports,x.AUDIO,"total_packets_lost_in",p),A=yt(this._reports,x.AUDIO,"total_packets_in",p),C={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=h,t[p].mos=E,t[p].traffic=T,t[p].bitrate=g,t[p].loss=C}else{const h={avg:Xe(this._reports,x.AUDIO,"delta_jitter_ms_out",!1,p),min:Ke(this._reports,x.AUDIO,"delta_jitter_ms_out",p),max:Ye(this._reports,x.AUDIO,"delta_jitter_ms_out",p),volatility:We(this._reports,x.AUDIO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.AUDIO,"delta_kbs_out",!1,p),min:Ke(this._reports,x.AUDIO,"delta_kbs_out",p),max:Ye(this._reports,x.AUDIO,"delta_kbs_out",p),volatility:We(this._reports,x.AUDIO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.AUDIO,"delta_KBytes_out",!1,p),min:Ke(this._reports,x.AUDIO,"delta_KBytes_out",p),max:Ye(this._reports,x.AUDIO,"delta_KBytes_out",p),volatility:We(this._reports,x.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:A_(this._reports,x.AUDIO,p),min:Ke(this._reports,x.AUDIO,"delta_rtt_ms_out",p),max:Ye(this._reports,x.AUDIO,"delta_rtt_ms_out",p),volatility:We(this._reports,x.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=yt(this._reports,x.AUDIO,"total_packets_lost_out",p),A=yt(this._reports,x.AUDIO,"total_packets_out",p),C={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},I={emodel:{avg:Xe(this._reports,x.AUDIO,"mos_emodel_out",!1,p),min:Ke(this._reports,x.AUDIO,"mos_emodel_out",p),max:Ye(this._reports,x.AUDIO,"mos_emodel_out",p),volatility:We(this._reports,x.AUDIO,"mos_emodel_out",p)},effective:{avg:Xe(this._reports,x.AUDIO,"mos_out",!1,p),min:Ke(this._reports,x.AUDIO,"mos_out",p),max:Ye(this._reports,x.AUDIO,"mos_out",p),volatility:We(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=h,t[p].rtt=E,t[p].traffic=T,t[p].bitrate=g,t[p].loss=C,t[p].mos=I}}),Object.keys(n[x.VIDEO]).forEach(p=>{const _=n[x.VIDEO][p];if(t[p]={type:x.VIDEO,direction:_.direction},_.direction===$e.INBOUND){const h={avg:Xe(this._reports,x.VIDEO,"delta_jitter_ms_in",!1,p),min:Ke(this._reports,x.VIDEO,"delta_jitter_ms_in",p),max:Ye(this._reports,x.VIDEO,"delta_jitter_ms_in",p),volatility:We(this._reports,x.VIDEO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.VIDEO,"delta_kbs_in",!1,p),min:Ke(this._reports,x.VIDEO,"delta_kbs_in",p),max:Ye(this._reports,x.VIDEO,"delta_kbs_in",p),volatility:We(this._reports,x.VIDEO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.VIDEO,"delta_KBytes_in",!1,p),min:Ke(this._reports,x.VIDEO,"delta_KBytes_in",p),max:Ye(this._reports,x.VIDEO,"delta_KBytes_in",p),volatility:We(this._reports,x.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=yt(this._reports,x.VIDEO,"total_packets_lost_in",p),y=yt(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=h,t[p].traffic=T,t[p].bitrate=g,t[p].loss=A}else{const h={avg:Xe(this._reports,x.VIDEO,"delta_jitter_ms_out",!1,p),min:Ke(this._reports,x.VIDEO,"delta_jitter_ms_out",p),max:Ye(this._reports,x.VIDEO,"delta_jitter_ms_out",p),volatility:We(this._reports,x.VIDEO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:Xe(this._reports,x.VIDEO,"delta_kbs_out",!1,p),min:Ke(this._reports,x.VIDEO,"delta_kbs_out",p),max:Ye(this._reports,x.VIDEO,"delta_kbs_out",p),volatility:We(this._reports,x.VIDEO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:Xe(this._reports,x.VIDEO,"delta_KBytes_out",!1,p),min:Ke(this._reports,x.VIDEO,"delta_KBytes_out",p),max:Ye(this._reports,x.VIDEO,"delta_KBytes_out",p),volatility:We(this._reports,x.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:A_(this._reports,x.VIDEO,p),min:Ke(this._reports,x.VIDEO,"delta_rtt_ms_out",p),max:Ye(this._reports,x.VIDEO,"delta_rtt_ms_out",p),volatility:We(this._reports,x.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=yt(this._reports,x.VIDEO,"total_packets_lost_out",p),A=yt(this._reports,x.VIDEO,"total_packets_out",p),C={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=h,t[p].rtt=E,t[p].traffic=T,t[p].bitrate=g,t[p].loss=C}})),{version:QT,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:ZT(this._reports,"data"),min:Ke(this._reports,"data","delta_rtt_connectivity_ms"),max:Ye(this._reports,"data","delta_rtt_connectivity_ms"),volatility:We(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((s/(s+r)*100||0)*100)/100}},video:{in:{avg:Math.round((o/(o+a)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:Xe(this._reports,"data","delta_kbs_in"),min:Ke(this._reports,"data","delta_kbs_in"),max:Ye(this._reports,"data","delta_kbs_in"),volatility:We(this._reports,"data","delta_kbs_in")},out:{avg:Xe(this._reports,"data","delta_kbs_out"),min:Ke(this._reports,"data","delta_kbs_out"),max:Ye(this._reports,"data","delta_kbs_out"),volatility:We(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:Xe(this._reports,"data","delta_KBytes_in"),min:Ke(this._reports,"data","delta_KBytes_in"),max:Ye(this._reports,"data","delta_KBytes_in"),volatility:We(this._reports,"data","delta_KBytes_in")},out:{avg:Xe(this._reports,"data","delta_KBytes_out"),min:Ke(this._reports,"data","delta_KBytes_out"),max:Ye(this._reports,"data","delta_KBytes_out"),volatility:We(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:ev(this._reports),remoteConnection:tv(this._reports)}}}}updateConfig(s){this._cfg=s}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const s=this._reports.slice();return s.pop(),s.pop()||null}getReportsNumber(){return this._reports.length}}const Us="extractor ",C_=(c,s,r,o)=>{let a=!1;const t=o[s].total_rtt_ms_out,n=o[s].total_rtt_measure_out,p=r?r[s].total_rtt_ms_out:0,_=r?r[s].total_rtt_measure_out:0,h={rtt:null,totalRTT:t,totalRTTMeasurements:n};if(c[V.TIMESTAMP]===o[s].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])-_===n))return h;const g=1e3*Number(c[V.ROUND_TRIP_TIME]);let T=t+g,E=n+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}},nv=(c,s,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,V.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:o[s].total_rtt_connectivity_ms,totalRTTMeasurements:o[s].total_rtt_connectivity_measure};const a=1e3*Number(c[V.CURRENT_ROUND_TRIP_TIME]);let t=o[s].total_rtt_connectivity_ms+a,n=o[s].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[s].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,V.RESPONSES_RECEIVED)&&(n=Number(c[V.RESPONSES_RECEIVED])-(r?r[s].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:t,totalRTTMeasurements:n}},vo=(c,s,r)=>c[V.TIMESTAMP]===r[s].timestamp_out||!Object.prototype.hasOwnProperty.call(c,V.JITTER)?null:1e3*(Number(c[V.JITTER])||0),rv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:s[x.VIDEO].delta_ms_decode_frame_in,frames_decoded:s[x.VIDEO].total_frames_decoded_in,total_decode_time:s[x.VIDEO].total_time_decoded_in};const r=c[V.FRAMES_DECODED],o=c[V.TOTAL_DECODE_TIME],a=o-s[x.VIDEO].total_time_decoded_in,t=r-s[x.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:t>0?a*1e3/t:0,frames_decoded:r,total_decode_time:o}},iv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,V.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,V.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:s[x.VIDEO].delta_ms_encode_frame_out,frames_encoded:s[x.VIDEO].total_frames_encoded_out,total_encode_time:s[x.VIDEO].total_time_encoded_out};const r=c[V.FRAMES_ENCODED],o=c[V.TOTAL_ENCODE_TIME],a=o-s[x.VIDEO].total_time_encoded_out,t=r-s[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}},R_=(c,s,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,V.BYTES_SENT))return{packetsSent:r[s].total_packets_out,packetsLost:r[s].total_packets_lost_out,bytesSent:r[s].total_KBytes_out};const a=Number(c[V.PACKETS_SENT])||0-(o?o[s].total_packets_out:0),t=a-r[s].total_packets_out,n=Number(c[V.BYTES_SENT])/1024-(o?o[s].total_KBytes_out:0),p=n-r[s].total_KBytes_out,_=c[V.TIMESTAMP]||Date.now(),h=o?o.timestamp:null;let g=r.timestamp;!g&&h&&(g=h);const T=g?_-g:0,E=T>0?p*.008*1024/T*1e3:0;return{packetsSent:a,deltaPacketsSent:t,KBytesSent:n,deltaKBytesSent:p,kbsSent:E}},I_=(c,s,r,o)=>{let a=r[s].total_packets_lost_out,t=0,n=0;return Object.prototype.hasOwnProperty.call(c,V.PACKETS_LOST)&&(a=Number(c[V.PACKETS_LOST])||0-(o?o[s].total_packets_lost_out:0),t=a-r[s].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,V.FRACTION_LOST)&&(n=Number(100*c[V.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:t,fractionLost:n}},b_=(c,s,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[s].percent_packets_lost_in,packetsReceived:r[s].total_packets_in,packetsLost:r[s].total_packets_lost_in,bytesReceived:r[s].total_KBytes_in};const a=Number(c[V.PACKETS_RECEIVED])||0-(o?o[s].total_packets_in:0),t=Number(c[V.PACKETS_LOST])||0-(o?o[s].total_packets_lost_in:0),n=t-r[s].total_packets_lost_in,p=a-r[s].total_packets_in,_=a!==r[s].total_packets_in?n*100/(n+p):0,h=Number(c[V.BYTES_RECEIVED])/1024-(o?o[s].total_KBytes_in:0),g=h-r[s].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,C=A>0?g*.008*1024/A*1e3:0;return{percentPacketsLost:_,packetsReceived:a,deltaPacketsReceived:p,packetsLost:t,deltaPacketsLost:n,KBytesReceived:h,deltaKBytesReceived:g,kbsReceived:C}},lv=c=>c[V.CANDIDATE_TYPE]!=="relay"?"":c[V.RELAY_PROTOCOL]||"",ov=c=>{if(!Object.prototype.hasOwnProperty.call(c,V.NETWORK_TYPE))return ti.WIFI;switch(c[V.NETWORK_TYPE]){case vu.ETHERNET:return ti.ETHERNET;case vu.CELLULAR_4G:return ti.CELLULAR_4G;case vu.WIFI:return ti.WIFI;default:return ti.CELLULAR}},w_=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]},av=c=>{const s=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:s,durations:o,resolutionChanges:r}},uv=(c,s,r)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:s.total_pli_sent_in,nackCount:s.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-s[x.VIDEO].total_pli_sent_in,deltaNackCount:a-s[x.VIDEO].total_nack_sent_in}},cv=(c,s,r)=>{if(!Object.prototype.hasOwnProperty.call(c,V.PLI)||!Object.prototype.hasOwnProperty.call(c,V.NACK))return{pliCount:s.total_pli_received_out,nackCount:s.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-s[x.VIDEO].total_pli_received_out,deltaNackCount:a-s[x.VIDEO].total_nack_received_out}},fv=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}),_v=c=>({clock_rate:c[V.CLOCK_RATE]||null,mime_type:c[V.MIME_TYPE]||null}),hv=(c,s,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(),n=o-s.data.total_KBytes_in,p=a-s.data.total_KBytes_out,_=r?r.timestamp:null;let h=s.timestamp;!h&&_&&(h=_);const g=h?t-h:0,T=g>0?n*.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:n,delta_KBytes_sent:p,kbs_speed_received:T,kbs_speed_sent:E}},dv=c=>{const s=c[V.AVAILABLE_INCOMING_BITRATE]/1024||0,r=c[V.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:s,kbs_outgoing_bandwidth:r}},pv=(c,s,r,o)=>{if(!c)return[];switch(c[V.TYPE]){case Yt.CANDIDATE_PAIR:let a=!1;if(c[V.NOMINATED]&&c[V.STATE]===x.SUCCEEDED&&(a=!0,Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c),V.SELECTED in c&&!c[V.SELECTED]&&(a=!1)),a){const n=c[V.LOCAL_CANDIDATE_ID],p=c[V.REMOTE_CANDIDATE_ID],_=hv(c,s,o),h=dv(c),g=nv(c,"data",o,s);return[{type:ne.NETWORK,value:{local_candidate_id:n}},{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:h.kbs_incoming_bandwidth}},{type:ne.DATA,value:{delta_kbs_bandwidth_out:h.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 Yt.LOCAL_CANDIDATE:if(c[V.ID]===s.network.local_candidate_id)return[{type:ne.NETWORK,value:{infrastructure:ov(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:lv(c)}}];break;case Yt.REMOTE_CANDIDATE:if(c[V.ID]===s.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 Yt.INBOUND_RTP:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const n=c[V.SSRC],p=_t(n,s,$e.INBOUND);p&&(p.timestamp=s.timestamp);const _=_t(n,o,$e.INBOUND);if(_&&(_.timestamp=o.timestamp),c[V.MEDIA_TYPE]===x.AUDIO){const h=b_(c,x.AUDIO,p,_),g=vo(c,x.AUDIO,p),T=c[V.CODEC_ID]||"";return[{ssrc:n,type:ne.AUDIO,value:{codec_id_in:T}},{ssrc:n,type:ne.AUDIO,value:{total_packets_in:h.packetsReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_in:h.deltaPacketsReceived}},{ssrc:n,type:ne.AUDIO,value:{total_packets_lost_in:h.packetsLost}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_lost_in:h.deltaPacketsLost}},{ssrc:n,type:ne.AUDIO,value:{percent_packets_lost_in:h.percentPacketsLost}},{ssrc:n,type:ne.AUDIO,value:{total_KBytes_in:h.KBytesReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_KBytes_in:h.deltaKBytesReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_kbs_in:h.kbsReceived}},{ssrc:n,type:ne.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[V.MEDIA_TYPE]===x.VIDEO){const h=rv(c,p),g=b_(c,x.VIDEO,p,_),T=vo(c,x.VIDEO,p),E=c[V.DECODER_IMPLEMENTATION]||null,y=c[V.CODEC_ID]||null,A=w_(c),C=uv(c,p,_);return[{ssrc:n,type:ne.VIDEO,value:{codec_id_in:y}},{ssrc:n,type:ne.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:n,type:ne.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:n,type:ne.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:n,type:ne.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:n,type:ne.VIDEO,value:{delta_jitter_ms_in:T}},{ssrc:n,type:ne.VIDEO,value:{decoder_in:E}},{ssrc:n,type:ne.VIDEO,value:{delta_ms_decode_frame_in:h.delta_ms_decode_frame}},{ssrc:n,type:ne.VIDEO,value:{total_frames_decoded_in:h.frames_decoded}},{ssrc:n,type:ne.VIDEO,value:{total_time_decoded_in:h.total_decode_time}},{ssrc:n,type:ne.VIDEO,value:{total_nack_sent_in:C.nackCount}},{ssrc:n,type:ne.VIDEO,value:{delta_nack_sent_in:C.deltaNackCount}},{ssrc:n,type:ne.VIDEO,value:{total_pli_sent_in:C.pliCount}},{ssrc:n,type:ne.VIDEO,value:{delta_pli_sent_in:C.deltaPliCount}},{ssrc:n,type:ne.VIDEO,value:{size_in:A}}]}break}case Yt.OUTBOUND_RTP:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const n=c[V.SSRC],p=_t(n,s,$e.OUTBOUND);p&&(p.timestamp=s.timestamp);const _=_t(n,o,$e.OUTBOUND);if(_&&(_.timestamp=o.timestamp),c[V.MEDIA_TYPE]===x.AUDIO){const h=c[V.CODEC_ID]||null,g=R_(c,x.AUDIO,p,_);return[{ssrc:n,type:ne.AUDIO,value:{codec_id_out:h}},{ssrc:n,type:ne.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:n,type:ne.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:n,type:ne.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:n,type:ne.AUDIO,value:{delta_kbs_out:g.kbsSent}}]}if(c[V.MEDIA_TYPE]===x.VIDEO){const h=c[V.ENCODER_IMPLEMENTATION]||null,g=c[V.CODEC_ID]||null,T=iv(c,p),E=w_(c),y=av(c),A=cv(c,p,_),C=R_(c,x.VIDEO,p,_);return[{ssrc:n,type:ne.VIDEO,value:{codec_id_out:g}},{ssrc:n,type:ne.VIDEO,value:{total_packets_out:C.packetsSent}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_out:C.deltaPacketsSent}},{ssrc:n,type:ne.VIDEO,value:{total_KBytes_out:C.KBytesSent}},{ssrc:n,type:ne.VIDEO,value:{delta_KBytes_out:C.deltaKBytesSent}},{ssrc:n,type:ne.VIDEO,value:{delta_kbs_out:C.kbsSent}},{ssrc:n,type:ne.VIDEO,value:{encoder_out:h}},{ssrc:n,type:ne.VIDEO,value:{delta_ms_encode_frame_out:T.delta_ms_encode_frame}},{ssrc:n,type:ne.VIDEO,value:{total_frames_encoded_out:T.frames_encoded}},{ssrc:n,type:ne.VIDEO,value:{total_time_encoded_out:T.total_encode_time}},{ssrc:n,type:ne.VIDEO,value:{total_nack_received_out:A.nackCount}},{ssrc:n,type:ne.VIDEO,value:{delta_nack_received_out:A.deltaNackCount}},{ssrc:n,type:ne.VIDEO,value:{total_pli_received_out:A.pliCount}},{ssrc:n,type:ne.VIDEO,value:{delta_pli_received_out:A.deltaPliCount}},{ssrc:n,type:ne.VIDEO,value:{size_out:E}},{ssrc:n,type:ne.VIDEO,value:{limitation_out:y}}]}break}case Yt.MEDIA_SOURCE:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);break}case Yt.TRACK:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);break}case Yt.CODEC:const t=[];return Object.keys(s[x.AUDIO]).forEach(n=>{const p=s[x.AUDIO][n];if(p.codec_id_in===c[V.ID]||p.codec_id_out===c[V.ID]){Pe(Us,`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.AUDIO,value:{codec_in:_}}):t.push({ssrc:p.ssrc,type:ne.AUDIO,value:{codec_out:_}})}}),Object.keys(s[x.VIDEO]).forEach(n=>{const p=s[x.VIDEO][n];if(p.codec_id_in===c[V.ID]||p.codec_id_out===c[V.ID]){Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const _=_v(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 Yt.REMOTE_INBOUND_RTP:{Pe(Us,`analyze() - got stats ${c[V.TYPE]} for ${r}`,c);const n=c[V.SSRC],p=_t(n,s,$e.OUTBOUND),_=_t(n,o,$e.OUTBOUND);if(c[V.KIND]===x.AUDIO){const h=C_(c,x.AUDIO,_,p),g=vo(c,x.AUDIO,p),T=I_(c,x.AUDIO,p,_);return[{ssrc:n,type:ne.AUDIO,value:{delta_rtt_ms_out:h.rtt}},{ssrc:n,type:ne.AUDIO,value:{total_rtt_ms_out:h.totalRTT}},{ssrc:n,type:ne.AUDIO,value:{total_rtt_measure_out:h.totalRTTMeasurements}},{ssrc:n,type:ne.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:n,type:ne.AUDIO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:n,type:ne.AUDIO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:n,type:ne.AUDIO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:n,type:ne.AUDIO,value:{percent_packets_lost_out:T.fractionLost}}]}if(c[V.KIND]===x.VIDEO){const h=C_(c,x.VIDEO,_,p),g=vo(c,x.VIDEO,p),T=I_(c,x.VIDEO,p,_);return[{ssrc:n,type:ne.VIDEO,value:{delta_rtt_ms_out:h.rtt}},{ssrc:n,type:ne.VIDEO,value:{total_rtt_ms_out:h.totalRTT}},{ssrc:n,type:ne.VIDEO,value:{total_rtt_measure_out:h.totalRTTMeasurements}},{ssrc:n,type:ne.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:n,type:ne.VIDEO,value:{timestamp_out:c[V.TIMESTAMP]}},{ssrc:n,type:ne.VIDEO,value:{total_packets_lost_out:T.packetsLost}},{ssrc:n,type:ne.VIDEO,value:{delta_packets_lost_out:T.deltaPacketsLost}},{ssrc:n,type:ne.VIDEO,value:{percent_packets_lost_out:T.fractionLost}}]}break}}return[]},Eo=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),mv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.INBOUND),n=_t(a,r,$e.INBOUND),p=_t(a,o,$e.INBOUND),_=[],h=[],g=t[s].percent_packets_lost_in,T=t[s].delta_jitter_ms_in,E=n&&n[s].delta_jitter_ms_in||null,y=p&&p[s].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,C=r&&r.data.delta_rtt_connectivity_ms||null,I=o&&o.data.delta_rtt_connectivity_ms||null;A&&_.push(A),C&&_.push(C),I&&_.push(I),T&&h.push(T),r&&E&&h.push(E),o&&y&&h.push(y);const $=_.length>0?Ns(_):100,L=h.length>0?Ns(h):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 Eo(M)},gv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.OUTBOUND),n=_t(a,r,$e.OUTBOUND),p=_t(a,o,$e.OUTBOUND),_=[],h=[],g=t[s].percent_packets_lost_out,T=t[s].delta_rtt_ms_out,E=n&&n[s].delta_rtt_ms_out||null,y=p&&p[s].delta_rtt_ms_out||null,A=t[s].delta_jitter_ms_out,C=n&&n[s].delta_jitter_ms_out||null,I=p&&p[s].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&&h.push(A),r&&C&&h.push(C),o&&I&&h.push(I);const N=_.length>0?Ns(_):100,F=h.length>0?Ns(h):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,B=.024*M+.11*(M-177.3)*D,q=ve-B;return Eo(q)},Tv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.INBOUND),n=_t(a,r,$e.INBOUND),p=_t(a,o,$e.INBOUND),_=[],h=[],g=t[s].percent_packets_lost_in/100,T=t[s].delta_jitter_ms_in,E=n&&n[s].delta_jitter_ms_in||null,y=p&&p[s].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,C=r&&r.data.delta_rtt_connectivity_ms||null,I=o&&o.data.delta_rtt_connectivity_ms||null;A&&_.push(A),C&&_.push(C),I&&_.push(I),T&&h.push(T),n&&E&&h.push(E),p&&y&&h.push(y);const $=_.length>0?Ns(_):100,L=h.length>0?Ns(h):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,q=93.2-(ae+N*Math.log(1+F*g)+D);return Eo(q)},vv=(c,s=x.AUDIO,r,o,a)=>{const t=_t(a,c,$e.OUTBOUND),n=_t(a,r,$e.OUTBOUND),p=_t(a,o,$e.OUTBOUND),_=[],h=[],g=t[s].percent_packets_lost_out/100,T=t[s].delta_rtt_ms_out,E=n&&n[s].delta_rtt_ms_out||null,y=p&&p[s].delta_rtt_ms_out||null,A=t[s].delta_jitter_ms_out,C=n&&n[s].delta_jitter_ms_out||null,I=p&&p[s].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&&h.push(A),n&&C&&h.push(C),p&&I&&h.push(I);const N=_.length>0?Ns(_):100,F=h.length>0?Ns(h):10,Se=0,ve=19.8,M=29.7,D=30,B=(N+F)/2+D,q=B-177.3<0?0:1,J=.024*B+.11*(B-177.3)*q,Z=93.2-(Se+ve*Math.log(1+M*g)+J);return Eo(Z)};class Ev{constructor(s,r){this._callbacks={onreport:null,onticket:null},this._id=zT(),this._moduleName=this._id,this._probeId=r,this._config=s,this._exporter=new sv(s),this._state=gs.IDLE,this.registerToPCEvents(),sn(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(s,r,o,a){const t=(_,h)=>_===x.AUDIO?h===Yt.INBOUND_RTP?{...T_}:{...v_}:h===Yt.INBOUND_RTP?{...E_}:{...S_},n=GT(r);n.pname=this._config.pname,n.call_id=this._config.cid,n.user_id=this._config.uid,n.count=r?r.count+1:1;let p=null;return s.forEach(_=>{!p&&_.timestamp&&(p=_.timestamp),pv(_,n,n.pname,a).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let T=n[g.type][g.ssrc];T||(T=t(g.type,_.type),T.ssrc=g.ssrc,n[g.type][g.ssrc]=T),Object.keys(g.value).forEach(E=>{T[E]=g.value[E]})}else Object.keys(g.value).forEach(T=>{n[g.type][T]=g.value[T]})})}),n.timestamp=p,Object.keys(n[x.AUDIO]).forEach(_=>{const h=n[x.AUDIO][_];h.direction===$e.INBOUND?(h.mos_emodel_in=mv(n,x.AUDIO,r,o,h.ssrc),h.mos_in=Tv(n,x.AUDIO,r,o,h.ssrc)):(h.mos_emodel_out=gv(n,x.AUDIO,r,o,h.ssrc),h.mos_out=vv(n,x.AUDIO,r,o,h.ssrc))}),n}async takeReferenceStats(){return new Promise((s,r)=>{const o=Date.now();setTimeout(async()=>{try{const a=Date.now()-o,t=Date.now(),n=await this._config.pc.getStats(),p=this.analyze(n,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}`),s()}catch(a){r(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==gs.RUNNING||!this._config.pc)return Pe(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const s=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-s,this._exporter.addReport(o),Pe(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(o),o}catch(s){return Fn(this._moduleName,`got error ${s}`),null}}async start(){Pe(this._moduleName,"starting"),this.state=gs.RUNNING,this._startedTime=this._exporter.start(),Pe(this._moduleName,"started")}async mute(){this.state=gs.MUTED,Pe(this._moduleName,"muted")}async unmute(){this.state=gs.RUNNING,Pe(this._moduleName,"unmuted")}async stop(s){if(Pe(this._moduleName,`stopping${s?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=gs.IDLE,this._config.ticket){const{ticket:r}=this._exporter;this.fireOnTicket(r)}this._exporter.reset(),Pe(this._moduleName,"stopped")}registerCallback(s,r,o){s in this._callbacks?(this._callbacks[s]={callback:r,context:o},Pe(this._moduleName,`registered callback '${s}'`)):Fn(this._moduleName,`can't register callback for '${s}' - not found`)}unregisterCallback(s){s in this._callbacks?(this._callbacks[s]=null,delete this._callbacks[s],Pe(this._moduleName,`unregistered callback '${s}'`)):Fn(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReport(s){this._callbacks.onreport&&Su(this._callbacks.onreport.callback,this._callbacks.onreport.context,s)}fireOnTicket(s){this._callbacks.onticket&&Su(this._callbacks.onticket.callback,this._callbacks.onticket.context,s)}updateConfig(s){this._config=s,this._exporter.updateConfig(s)}get state(){return this._state}set state(s){this._state=s,Pe(this._moduleName,`state changed to ${s}`)}addCustomEvent(s,r,o,a){this._exporter.addCustomEvent({at:typeof s=="object"?s.toJSON():s,category:r,name:o,description:a})}async registerToPCEvents(){const{pc:s}=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{Fn(this._moduleName,"can't get devices")}},s){s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;o===ei.CONNECTED||o===ei.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===ei.DISCONNECTED||o===ei.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===ei.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},s.onicegatheringstatechange=()=>{const o=s.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",o,"ICE gathering state")},s.ontrack=o=>{this.addCustomEvent(new Date().toJSON(),"call",`${o.track.kind}track`,"MediaStreamTrack received")},s.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const r=s.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 Sv{constructor(s){this._id=s.pname&&s.pname.substr(0,12).padEnd(12," ")||JT(),this._moduleName=this._id,sn(this._moduleName,"probe created"),this._config=s,this._collector=new Ev(this._config,this._id)}set onreport(s){s?this._collector.registerCallback("onreport",s):this._collector.unregisterCallback("onreport")}set onticket(s){s?this._collector.registerCallback("onticket",s):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(s){this._collector.state=s}addCustomEvent(s,r,o,a=new Date().toJSON()){this._collector.addCustomEvent(a,r,s,o)}get isRunning(){return this._collector.state===gs.RUNNING}get isIdle(){return this._collector.state===gs.IDLE}updateUserId(s){this._config.uid=s,this._collector.updateConfig(this._config)}updateCallId(s){this._config.cid=s,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){To(this._moduleName,"probe is already running");return}this._collector.start()}stop(s=!1){this.isRunning&&this._collector.stop(s)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const It="engine ";class yv{constructor(s){this._config=s,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},sn(It,`configured for probing every ${this._config.refreshEvery}ms`),sn(It,`configured for starting after ${this._config.startAfter}ms`),sn(It,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Pe(It,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(s=>s.isRunning)}get isIdle(){return this._probes.every(s=>s.isIdle)}addNewProbe(s,r){if(!s)throw new Error("undefined peer connection");const o=KT(s,r,this._config),a=new Sv(o);return this._probes.push(a),Pe(It,`${this._probes.length} probes registered`),a}removeExistingProbe(s){if(!s)throw new Error("undefined probe");s.state===gs.RUNNING&&s.stop(),this._probes=this._probes.filter(r=>s.id!==r.id)}async start(){const s=()=>{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=BT(),n=this._probes.filter(p=>p.isRunning);for(const p of n){const _=await p.collectStats();_&&t.probes.push(_),Pe(It,`got probe ${p.id}`),await y_(0)}return t.delta_time_to_measure_probes_ms=nn(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=nn(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=nn(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=nn(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=nn(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=nn(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=nn(t.probes,"video","total_time_encoded_out"),t};for(Pe(It,"starting to collect"),s(),Pe(It,"generating reference reports..."),await r(),Pe(It,"reference reports generated"),this._startedTime=Date.now();o();)if(Pe(It,`wait ${this._config.refreshEvery}ms before collecting`),await y_(this._config.refreshEvery),o()){Pe(It,"collecting...");const t=Date.now(),n=await a(),p=Date.now();n.delta_time_consumed_to_measure_ms=p-t,this.fireOnReports(n),Pe(It,"collected")}Pe(It,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(s){const r=o=>{this._probes.forEach(a=>{a.stop(o)})};sn(It,"stop collecting"),r(s)}registerCallback(s,r,o){s in this._callbacks?(this._callbacks[s]={callback:r,context:o},Pe(It,`registered callback '${s}'`)):Fn(It,`can't register callback for '${s}' - not found`)}unregisterCallback(s){s in this._callbacks?(this._callbacks[s]=null,delete this._callbacks[s],Pe(this._moduleName,`unregistered callback '${s}'`)):Fn(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReports(s){this._callbacks.onresult&&s.probes.length>0&&Su(this._callbacks.onresult.callback,this._callbacks.onresult.context,s)}}const Av="interface ";class Cv{constructor(s){this._config=YT(s),sn(Av,`welcome to ${this._config.name} version ${this._config.version}`),kT(this._config.verbose||!1),this._engine=new yv(this._config)}setupLogLevel(s){LT(s)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(s,r){return this._engine.addNewProbe(s,r)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(s){this._engine.removeExistingProbe(s)}set onresult(s){s?this._engine.registerCallback("onresult",s):this._engine.unregisterCallback("onresult")}}function Rv(c,s){return Object.keys(c).filter(r=>s.includes(r)).reduce((r,o)=>{const a=o;return{...r,[a]:c[a]}},{})}const Iv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"];class bv{constructor(s){this.intervals={},this.emitInterval=s.emitInterval||200,this.onChangeFunction=s.onChangeFunction}start(s,r){s&&s.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(s,r))}stop(s){this.clearVolumeInterval(s)}clearVolumeInterval(s){console.log("clearVolumeInterval",s),clearInterval(this.intervals[s]),delete this.intervals[s]}clearAllIntervals(){Object.keys(this.intervals).forEach(s=>{clearInterval(this.intervals[s])}),this.intervals={}}beginCalculation(s,r){this.clearVolumeInterval(r);const o=tn.createAnalyser(),a=tn.createMediaStreamSource(s),t=tn.createScriptProcessor(2048,1,1);o.smoothingTimeConstant=.8,o.fftSize=1024,a.connect(o),o.connect(t),t.connect(tn.destination),this.intervals[r]=setInterval(()=>{const n=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(n);let p=0;const _=n.length;for(let g=0;g<_;g++)p+=n[g];const h=p/_;this.onChangeFunction(r,h)},this.emitInterval)}}const So={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},wv=0;class Ov{constructor(s){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=s,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new bv({onChangeFunction:this.emitVolumeChange.bind(this)}),this.initializeMediaDevices()}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(s){this.currentActiveRoomIdValue=s,this.context.emit("currentActiveRoomChanged",s)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(s){this.isCallAddingInProgress=s,this.context.emit("callAddingInProgressChanged",s)}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(s=>s.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(s=>s.kind==="audiooutput")}get getUserMediaConstraints(){return d_()?{video:!1,audio:!0}:{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(s){this.availableMediaDevices=s,this.context.emit("changeAvailableDeviceList",s)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const s=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(s)}async initializeMediaDevices(){const s=localStorage.getItem(So.SELECTED_INPUT_DEVICE)||"default",r=localStorage.getItem(So.SELECTED_OUTPUT_DEVICE)||"default";try{const o=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),a=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(a),await this.setMicrophone(s),await this.setSpeaker(r),navigator.mediaDevices.addEventListener("devicechange",async()=>{const t=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(t)}),o.getTracks().forEach(t=>t.stop())}catch(o){console.error(o)}}setCallTime(s){const r={...s};delete r.callId,this.callTime={...this.callTime,[s.callId]:r},this.context.emit("changeCallTime",this.callTime)}removeCallTime(s){const r={...this.callTime};delete r[s],this.callTime={...r},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(s,r){this.timeIntervals={...this.timeIntervals,[s]:r}}removeTimeInterval(s){const r={...this.timeIntervals};r[s]&&(clearInterval(r[s]),delete r[s],this.timeIntervals={...r})}stopCallTimer(s){this.removeTimeInterval(s),this.removeCallTime(s)}emitVolumeChange(s,r){this.context.emit("changeCallVolume",{callId:s,volume:r})}setMetricsConfig(s){this.metricConfig={...this.metricConfig,...s}}sendDTMF(s,r){if(!/^[A-D0-9]+$/g.test(r))throw new Error("Not allowed character in DTMF input");this.extendedCalls[s].sendDTMF(r)}setIsMuted(s){this.muted=s,this.context.emit("changeIsMuted",s)}processMute(s){const r=this.currentActiveRoomId;this.setIsMuted(s),this.initialStreamValue.getTracks().forEach(o=>o.enabled=!s),this.roomReconfigure(r)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:s,toHold:r,automatic:o}){const a=this.extendedCalls[s];a._automaticHold=o??!1,await new Promise(p=>{const _=()=>{p()};r?a.hold({},_):a.unhold({},_)}),this.updateCall(a);const n=Object.values(this.extendedCalls).filter(p=>p.roomId===this.currentActiveRoomId&&(r?s!==p._id:!0));n.length>1&&await this.doConference(n)}holdCall(s,r=!1){return this.processHold({callId:s,automatic:r,toHold:!0})}unholdCall(s){return this.processHold({callId:s,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(s=>s.direction==="outgoing"&&s.status===wv).forEach(s=>this.terminateCall(s._id))}answerCall(s){const r=this.extendedCalls[s];this.cancelAllOutgoingUnanswered(),r.answer(this.sipOptions),this.updateCall(r),this.setActiveRoom(r.roomId),r.connection.addEventListener("track",o=>{this.triggerAddStream(o,r)})}async moveCall(s,r){this.updateCallStatus({callId:s,isMoving:!0}),await this.processRoomChange({callId:s,roomId:r}),this.updateCallStatus({callId:s,isMoving:!1})}updateCall(s){this.activeCalls[s._id]=f_(s),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(s){const o={...this.activeRooms[s.roomId],...s};this.activeRooms={...this.activeRooms,[s.roomId]:{...o}},this.context.emit("updateRoom",{room:o,roomList:this.activeRooms})}hasAutoAnswerHeaders(s){const r=/answer-after=0/,a=s.request.getHeader("Call-Info");return a&&r.test(a)}addCall(s,r=!0){this.activeCalls={...this.activeCalls,[s._id]:f_(s)},this.extendedCalls[s._id]=s,r&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(s){this.callStatus={...this.callStatus,[s]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(s){const o={...{...this.callStatus[s.callId]}};s.isMoving!==void 0&&(o.isMoving=s.isMoving),s.isTransferring!==void 0&&(o.isTransferring=s.isTransferring),s.isMerging!==void 0&&(o.isMerging=s.isMerging),this.callStatus={...this.callStatus,[s.callId]:{...o}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(s){const r={...this.callStatus};delete r[s],this.callStatus={...r},this.context.emit("changeCallStatus",this.callStatus)}addRoom(s){this.activeRooms={...this.activeRooms,[s.roomId]:s},this.context.emit("addRoom",{room:s,roomList:this.activeRooms})}getActiveStream(){const s=h_(this.initialStreamValue,this.microphoneInputLevel*2);return s.getTracks().forEach(r=>r.enabled=!this.isMuted),this.setActiveStream(s),s}async setMicrophone(s){if(!this.getInputDeviceList.find(({deviceId:o})=>o===s)||(this.setSelectedInputDevice(s),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(s){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(s,"origin"),this.activeStreamValue=s,this.context.emit("changeActiveStream",s)}async setSpeaker(s){if(!this.getOutputDeviceList.find(({deviceId:a})=>a===s))return;this.setSelectedOutputDevice(s);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(s),this.updateCall(a)}):await this.doConference(o)}removeRoom(s){const r={...this.activeRooms},o={...r[s]};delete r[s],this.activeRooms={...r},this.context.emit("removeRoom",{room:o,roomList:this.activeRooms})}deleteRoomIfEmpty(s){s!==void 0&&Object.values(this.extendedCalls).filter(r=>r.roomId===s).length===0&&(this.removeRoom(s),this.currentActiveRoomId===s&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(s){this.muted?s.mute({audio:!0}):s.unmute({audio:!0})}async roomReconfigure(s){var o;if(s===void 0)return;const r=Object.values(this.extendedCalls).filter(a=>a.roomId===s);if(this.currentActiveRoomId===s?r.forEach(a=>{a.audioTag&&(this.muteReconfigure(a),a.audioTag.muted=!1,this.updateCall(a))}):r.forEach(a=>{a.audioTag&&(a.audioTag.muted=!0,this.updateCall(a))}),r.length===0)this.deleteRoomIfEmpty(s);else if(r.length===1&&this.currentActiveRoomId!==s)r[0].isOnHold().local||await this.holdCall(r[0].id,!0);else if(r.length===1&&this.currentActiveRoomId===s){if(r[0].isOnHold().local&&r[0]._automaticHold&&await this.unholdCall(r[0].id),r[0].connection&&((o=r[0].connection)!=null&&o.getSenders()[0])){const a=this.getActiveStream();await r[0].connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.muteReconfigure(r[0])}}else r.length>1&&await this.doConference(r)}async doConference(s){const r=[];s.forEach(o=>{o!=null&&o.connection.getReceivers().forEach(a=>{r.push(a.track)})}),await xT.forEach(s,async o=>{var n;if(o==null)return;const a=new MediaStream,t=tn.createMediaStreamDestination();if(o.connection.getReceivers().forEach(p=>{r.forEach(_=>{a.addTrack(p.track),p.track.id!==_.id&&tn.createMediaStreamSource(new MediaStream([_])).connect(t)})}),s[0].roomId===this.currentActiveRoomId){const p=this.getActiveStream();tn.createMediaStreamSource(p).connect(t)}(n=o.connection)!=null&&n.getSenders()[0]&&(await o.connection.getSenders()[0].replaceTrack(t.stream.getTracks()[0]),this.muteReconfigure(o))})}processCallerMute(s,r){const o=this.extendedCalls[s];o&&o.connection.getReceivers().length&&(o.localMuted=r,o.connection.getReceivers().forEach(a=>{a.track.enabled=!r}),this.updateCall(o))}muteCaller(s){this.processCallerMute(s,!0)}unmuteCaller(s){this.processCallerMute(s,!1)}terminateCall(s){const r=this.extendedCalls[s];r._status!==8&&r.terminate()}transferCall(s,r){if(r.toString().length===0)return new Error("Target must be passed");const o=this.extendedCalls[s];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:s,isTransferring:!0}),o.refer(`sip:${r}@${this.context.sipDomain}`),this.updateCall(o)}mergeCall(s){const r=Object.values(this.extendedCalls).filter(t=>t.roomId===s);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))}mergeCallByIds(s,r){const o=Object.values(this.extendedCalls).find(t=>t._id===s),a=Object.values(this.extendedCalls).find(t=>t._id===r);if(!o||!a)throw new Error("Call ID is not provided");this.updateCallStatus({callId:s,isMerging:!0}),this.updateCallStatus({callId:r,isMerging:!0}),o.refer(a.remote_identity.uri.toString(),{replaces:a}),this.updateCall(o)}setDND(s){this.isDNDEnabled=s,this.context.emit("changeIsDND",s)}startCallTimer(s){this.removeTimeInterval(s);const r={callId:s,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(r);const o=setInterval(()=>{const a={...this.callTime[s]},t=PT(a);this.setCallTime({callId:s,...t})},1e3);this.setTimeInterval(s,o)}async setActiveRoom(s){const r=this.currentActiveRoomId;s!==r&&(this.currentActiveRoomId=s,await this.roomReconfigure(r),await this.roomReconfigure(s))}getNewRoomId(){const s=Object.keys(this.activeRooms);return s.length===0?1:parseInt(s.sort()[s.length-1])+1}async setupCall(s){var h,g;const r=s.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=(h=r._remote_identity)==null?void 0:h._uri)==null?void 0:g._user),t.incomingInProgress=!0,this.context.subscribe(Kt.CALL_CONFIRMED,T=>{r.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(r.id))}),this.context.subscribe(Kt.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 n=r,p=this.hasAutoAnswerHeaders(s),_=n.direction==="incoming"&&!this.hasActiveCalls&&(p||this.autoAnswer);n.roomId=a,n.localMuted=!1,n.autoAnswer=_,_?this.addCall(n,!1):this.addCall(n),this.addCallStatus(r.id),this.addRoom(t),_&&this.answerCall(n._id)}removeCall(s){const r={...this.activeCalls};delete r[s],this.activeCalls={...r};const o={...this.extendedCalls};delete o[s],this.extendedCalls={...o},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(s){var a;const r=this.extendedCalls[s._id];this.stopVUMeter("origin"),(a=r.connection)==null||a.getSenders().forEach(t=>{t.track.stop()});const o=r.roomId;this.removeCall(s._id),this.roomReconfigure(o)}async newRTCSessionCallback(s){const r=s.session;if(this.isDND){r.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(this.context.triggerListener({listenerType:Kt.NEW_CALL,session:r,event:s}),r.on("ended",o=>{var t,n,p;this.stopVUMeter(r.id),this.context.logger.log("Session ended for",(n=(t=r._remote_identity)==null?void 0:t._uri)==null?void 0:n._user),this.context.triggerListener({listenerType:Kt.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),(p=this.initialStreamValue)==null||p.getTracks().forEach(_=>_.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:Kt.CALL_PROGRESS,session:r,event:o})}),r.on("failed",o=>{var t,n,p;this.stopVUMeter(r.id),this.context.logger.log("Session failed for",(n=(t=r._remote_identity)==null?void 0:t._uri)==null?void 0:n._user),this.context.triggerListener({listenerType:Kt.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),(p=this.initialStreamValue)==null||p.getTracks().forEach(_=>_.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:Kt.CALL_CONFIRMED,session:r,event:o}),this.updateCall(r),r.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(s),r.direction==="outgoing"){const o=this.getActiveCalls[r.id].roomId;this.setActiveRoom(o)}}setMuteWhenJoin(s){this.muteWhenJoinEnabled=s,this.context.emit("changeMuteWhenJoin",s)}setMicrophoneSensitivity(s){if(s<0||s>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=s,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(s){this.speakerVolumeValue=s,Object.values(this.extendedCalls).forEach(r=>{r.audioTag&&(r.audioTag.volume=s,this.updateCall(r))})}setAutoAnswer(s){this.isAutoAnswer=s}setSelectedInputDevice(s){localStorage.setItem(So.SELECTED_INPUT_DEVICE,s),this.selectedMediaDevices.input=s,this.context.emit("changeActiveInputMediaDevice",s)}setSelectedOutputDevice(s){localStorage.setItem(So.SELECTED_OUTPUT_DEVICE,s),this.selectedMediaDevices.output=s,this.context.emit("changeActiveOutputMediaDevice",s)}setCallMetrics(s){const r={...s};delete r.callId,this.callMetrics={...this.callMetrics,[s.callId]:r},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(s){const r={...this.callMetrics};delete r[s],this.callMetrics={...r},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(s){const r=new Cv(this.metricConfig),o=r.createProbe(s.connection,{cid:s._id}),a=[];let t;o.onreport=n=>{Object.entries(n.audio).forEach(([h,g])=>{g.direction==="inbound"&&!a.includes(h)&&(a.push(h),t=h)});const p=n.audio[t];if(!p)return;const _=Rv(p,Iv);_.callId=s._id,this.setCallMetrics(_)},this.context.subscribe(Kt.CALL_ENDED,n=>{n._id===s._id&&r.stopAllProbes()}),r.startAllProbes()}setupVUMeter(s,r){this.VUMeter.start(s,r)}stopVUMeter(s){this.VUMeter.stop(s)}async setupStream(){const s=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(r=>r.stop()),this.initialStreamValue=null),this.initialStreamValue=s}async triggerAddStream(s,r){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const o=h_(this.initialStreamValue,this.microphoneInputLevel*2),a=this.isMuted||this.muteWhenJoin;o.getTracks().forEach(n=>n.enabled=!a),this.setActiveStream(o),await r.connection.getSenders()[0].replaceTrack(o.getTracks()[0]);const t=new MediaStream([s.track]);TT(t,r,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(t,r._id),this.getCallQuality(r),this.updateCall(r)}initCall(s,r){if(this.checkInitialized(),s.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${s}@${this.context.sipDomain}...`);const o=this.context.call(`sip:${s}@${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:s,roomId:r}){const o=this.extendedCalls[s].roomId;this.extendedCalls[s].roomId=r;const a=this.extendedCalls[s];return this.updateCall(a),await this.setActiveRoom(r),Promise.all([this.roomReconfigure(o),this.roomReconfigure(r)]).then(()=>{this.deleteRoomIfEmpty(o),this.deleteRoomIfEmpty(r)})}}class Dv{constructor(s){this.context=s}get sipOptions(){return{...this.context.options.sipOptions}}initCall(s,r){if(s.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${s}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${s}@${this.context.sipDomain}`,r,this.sipOptions)}stop(s={}){this.context.terminateJanusSessions(s)}}class Nv{constructor(s){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=s,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(s){const r=this.extendedMessages[s];this.updateMSRPSession(r)}updateMSRPSession(s){this.activeMessages[s._id]=__(s),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(s){this.activeMessages={...this.activeMessages,[s._id]:__(s)},this.extendedMessages[s._id]=s,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(s,r){const o=this.msrpHistory[r.id]||[];o.push(s),this.msrpHistory={...this.msrpHistory,[r.id]:[...o]},this.context.emit("newMSRPMessage",{message:s,session:r})}messageTerminate(s){const r=this.extendedMessages[s];r._status!==8&&r.terminate()}addMessageSession(s){if(!s._id||this.getActiveMessages[s._id]!==void 0)return;const o=s;this.addMMSRPSession(o)}triggerMSRPListener({listenerType:s,session:r,event:o}){const a=this.context.listenersList[s];!a||!a.length||a.forEach(t=>{t(r,o)})}removeMMSRPSession(s){const r={...this.activeMessages};delete r[s],this.activeMessages={...r};const o={...this.extendedMessages};delete o[s],this.extendedMessages={...o},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(s){this.removeMMSRPSession(s._id)}newMSRPSessionCallback(s){const r=s.session;r.on("ended",o=>{this.triggerMSRPListener({listenerType:Kt.CALL_ENDED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("failed",o=>{this.triggerMSRPListener({listenerType:Kt.CALL_FAILED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("confirmed",o=>{this.triggerMSRPListener({listenerType:Kt.CALL_CONFIRMED,session:r,event:o}),this.updateMSRPSession(r)}),r.on("newMessage",o=>{this.addMSRPMessage(o,r)}),this.addMessageSession(r)}setIsMSRPInitializing(s){this.isMSRPInitializingValue=s,this.context.emit("isMSRPInitializingChanged",s)}initMSRP(s,r,o){if(s.length===0)return console.error("Target must be a valid string");const a=this.context.startMSRP(s,o);a.on("active",()=>{this.addMessageSession(a),a.sendMSRP(r),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(s,r){const o=this.extendedMessages[s];if(!o)throw new Error(`MSRP session with id ${s} doesn't exist!`);o.sendMSRP(r)}}const yu={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class Uv extends fT{constructor(s,r){if(!s.modules.length)throw new Error("options.modules should include at least 1 module");const o={...s.configuration,sockets:s.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.isReconnecting=!1,this.audio=null,this.msrp=null,this.video=null,this.listenersList={},this.modules=[],s.pnExtraHeaders&&Object.keys(s.pnExtraHeaders).length&&this.registrator().setExtraContactParams(s.pnExtraHeaders),this.options=s,this.modules=s.modules,r&&vT(r)&&(this.logger=r)}on(s,r){return super.on(s,r)}off(s,r){return super.off(s,r)}emit(s,r){return super.emit(s,r)}get sipDomain(){return this.options.sipDomain}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(yu.AUDIO)&&(this.audio=new Ov(this)),this.modules.includes(yu.MSRP)&&(this.msrp=new Nv(this)),this.modules.includes(yu.VIDEO)&&(this.video=new Dv(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(s,r){const a=!this.listenersList[s]||!this.listenersList[s].length?[r]:[...this.listenersList[s],r];this.listenersList={...this.listenersList,[s]:a}}removeIListener(s){const r={...this.listenersList};delete r[s],this.listenersList={...r}}triggerListener({listenerType:s,session:r,event:o}){const a=this.listenersList[s];!a||!a.length||a.forEach(t=>{t(r,o)})}setInitialized(s){this.initialized=s,this.emit("ready",s)}}return Uv}();
|