@voicenter-team/opensips-js 1.0.90 → 1.0.92

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,156 +1,161 @@
1
- "use strict";var U_=Object.defineProperty;var P_=(c,s,r)=>s in c?U_(c,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[s]=r;var Wt=(c,s,r)=>(P_(c,typeof s!="symbol"?s+"":s,r),r);var x_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xe(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const M_="jssip",k_="JsSIP",L_="the Javascript SIP library",$_="3.10.0",H_="https://jssip.net",F_=["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],j_="lib/JsSIP.d.ts",q_="lib-es5/JsSIP.js",V_=["sip","websocket","webrtc","node","browser","library"],B_="MIT",G_={type:"git",url:"https://github.com/versatica/JsSIP.git"},W_={url:"https://github.com/versatica/JsSIP/issues"},K_={"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},Y_={"@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"},J_={lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"},Lo={name:M_,title:k_,description:L_,version:$_,homepage:H_,contributors:F_,types:j_,main:q_,keywords:V_,license:B_,repository:G_,bugs:W_,dependencies:K_,devDependencies:Y_,scripts:J_};var qu=Lo,it={USER_AGENT:"".concat(qu.title," ").concat(qu.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 fo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?fo=function(r){return typeof r}:fo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fo(c)}function $o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Ho(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&&zi(c,s)}function Fo(c){var s=Hf();return function(){var o=Xi(c),a;if(s){var t=Xi(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return z_(this,a)}}function z_(c,s){return s&&(fo(s)==="object"||typeof s=="function")?s:X_(c)}function X_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function hr(c){var s=typeof Map=="function"?new Map:void 0;return hr=function(o){if(o===null||!Q_(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 _o(o,arguments,Xi(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),zi(a,o)},hr(c)}function _o(c,s,r){return Hf()?_o=Reflect.construct:_o=function(a,t,n){var d=[null];d.push.apply(d,t);var _=Function.bind.apply(a,d),h=new _;return n&&zi(h,n.prototype),h},_o.apply(null,arguments)}function Hf(){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 Q_(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function zi(c,s){return zi=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},zi(c,s)}function Xi(c){return Xi=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Xi(c)}var Z_=function(c){Ho(r,c);var s=Fo(r);function r(o,a){var t;return $o(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}(hr(Error)),eh=function(c){Ho(r,c);var s=Fo(r);function r(o){var a;return $o(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}(hr(Error)),th=function(c){Ho(r,c);var s=Fo(r);function r(o){var a;return $o(this,r),a=s.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return r}(hr(Error)),sh=function(c){Ho(r,c);var s=Fo(r);function r(o){var a;return $o(this,r),a=s.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return r}(hr(Error)),Bs={ConfigurationError:Z_,InvalidStateError:eh,NotSupportedError:th,NotReadyError:sh},Ze={},oa,Vu;function Cu(){if(Vu)return oa;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 d=0;d<n.length;d++){var _=n[d];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(t,_.key,_)}}function r(t,n,d){return n&&s(t.prototype,n),d&&s(t,d),t}var o=Gs(),a=is();return oa=function(){r(t,null,[{key:"parse",value:function(d){if(d=a.parse(d,"Name_Addr_Header"),d!==-1)return d}}]);function t(n,d,_){if(c(this,t),!n||!(n instanceof o))throw new TypeError('missing or invalid "uri" parameter');this._uri=n,this._parameters={},this.display_name=d;for(var h in _)Object.prototype.hasOwnProperty.call(_,h)&&this.setParam(h,_[h])}return r(t,[{key:"setParam",value:function(d,_){d&&(this._parameters[d.toLowerCase()]=typeof _>"u"||_===null?null:_.toString())}},{key:"getParam",value:function(d){if(d)return this._parameters[d.toLowerCase()]}},{key:"hasParam",value:function(d){if(d)return this._parameters.hasOwnProperty(d.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(d){if(d=d.toLowerCase(),this._parameters.hasOwnProperty(d)){var _=this._parameters[d];return delete this._parameters[d],_}}},{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(d){return d.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var d=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";d+="<".concat(this._uri.toString(),">");for(var _ in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,_)&&(d+=";".concat(_),this._parameters[_]!==null&&(d+="=".concat(this._parameters[_])));return d}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(d){this._display_name=d===0?"0":d}}]),t}(),oa}var aa,Bu;function is(){return Bu||(Bu=1,aa=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:H,HTAB:L,alphanum:ae,reserved:N,unreserved:j,mark:Se,escaped:ve,LWS:M,SWS:D,HCOLON:B,TEXT_UTF8_TRIM:V,TEXT_UTF8char:J,UTF8_NONASCII:F,UTF8_CONT:X,LHEX:U,token:P,token_nodot:se,separators:tt,word:ee,STAR:W,SLASH:G,EQUAL:re,LPAREN:ge,RPAREN:be,RAQUOT:xe,LAQUOT:Ce,COMMA:le,SEMI:ye,COLON:st,LDQUOT:lt,RDQUOT:Ee,comment:Ae,ctext:Ie,quoted_string:Oe,quoted_string_clean:pe,qdtext:ue,quoted_pair:de,SIP_URI_noparams:we,SIP_URI:Ne,uri_scheme:Qe,uri_scheme_sips:Le,uri_scheme_sip:kt,userinfo:ht,user:Rn,user_unreserved:In,password:Ws,hostport:Xt,host:os,hostname:Ks,domainlabel:bn,toplabel:wn,IPv6reference:Ys,IPv6address:me,h16:oe,ls32:ot,IPv4address:Gt,dec_octet:ys,port:gr,uri_parameters:On,uri_parameter:Dn,transport_param:Tr,user_param:vr,method_param:Er,ttl_param:Sr,maddr_param:yr,lr_param:Ar,other_param:Cr,pname:Rr,pvalue:As,paramchar:Cs,param_unreserved:Ir,headers:Js,header:zs,hname:br,hvalue:Rs,hnv_unreserved:Xs,Request_Response:hl,Request_Line:wr,Request_URI:Nn,absoluteURI:Un,hier_part:Or,net_path:Qs,abs_path:Zs,opaque_part:Is,uric:bs,uric_no_slash:Dr,path_segments:en,segment:ws,param:as,pchar:Os,scheme:Nr,authority:Ur,srvr:Pr,reg_name:xr,query:Pn,SIP_Version:xn,INVITEm:Mr,ACKm:kr,OPTIONSm:Lr,BYEm:$r,CANCELm:Hr,REGISTERm:Fr,SUBSCRIBEm:jr,NOTIFYm:qr,REFERm:tn,Method:sn,Status_Line:Vr,Status_Code:Br,extension_code:Gr,Reason_Phrase:dl,Allow_Events:Go,Call_ID:Wo,Contact:Mn,contact_param:Lt,name_addr:$t,display_name:Ds,contact_params:kn,c_p_q:Wr,c_p_expires:Qt,delta_seconds:Zt,qvalue:Ge,generic_param:We,gen_value:pl,Content_Disposition:ml,disp_type:Ln,disp_param:$n,handling_param:gl,Content_Encoding:Ko,Content_Length:Yo,Content_Type:Tl,media_type:Kr,m_type:Yr,discrete_type:Jr,composite_type:nn,extension_token:rn,x_token:zr,m_subtype:Hn,m_parameter:Fn,m_value:vl,CSeq:El,CSeq_value:Sl,Expires:Jo,Event:ln,event_type:on,From:Xr,from_param:an,tag_param:Qr,Max_Forwards:zo,Min_Expires:Xo,Name_Addr_Header:Qo,Proxy_Authenticate:Zr,challenge:jn,other_challenge:Ns,auth_param:es,digest_cln:un,realm:ei,realm_value:ti,domain:cn,URI:fn,nonce:si,nonce_value:ni,opaque:ri,stale:ii,algorithm:li,qop_options:_n,qop_value:qn,Proxy_Require:Zo,Record_Route:Vn,rec_route:Bn,Reason:oi,reason_param:Gn,reason_cause:yl,Require:ea,Route:Wn,route_param:Kn,Subscription_State:Al,substate_value:Yn,subexp_params:Jn,event_reason_value:Cl,Subject:ta,Supported:sa,To:ai,to_param:ui,Via:zn,via_param:Us,via_params:Xn,via_ttl:ci,via_maddr:fi,via_received:_i,via_branch:hi,response_port:di,rport:pi,sent_protocol:mi,protocol_name:gi,transport:Ti,sent_by:vi,via_host:Ei,via_port:Qn,ttl:Si,WWW_Authenticate:na,Session_Expires:Rl,s_e_expires:Zn,s_e_params:er,s_e_refresher:Il,extension_header:bl,header_value:wl,message_body:ra,uuid_URI:Ol,uuid:Ht,hex4:Ft,hex8:yi,hex12:Dl,Refer_To:ia,Replaces:Nl,call_id:tr,replaces_param:sr,to_tag:Ai,from_tag:Ci,early_flag:Ul};if(a!==void 0){if(t[a]===void 0)throw new Error("Invalid rule name: "+c(a)+".")}else a="CRLF";var n=0,d=0,_=[];function h(e){n<d||(n>d&&(d=n,_=[]),_.push(e))}function g(){var e;return o.substr(n,2)===`\r
2
- `?(e=`\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=H(),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 H(){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 j(){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,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){return v.join("")}(f,e)),e===null&&(n=f),e}function M(){var e,l,u,f,p,m;for(f=n,p=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=p)}else e=null,n=p;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,p;for(f=n,p=n,e=[],l=H(),l===null&&(l=L());l!==null;)e.push(l),l=H(),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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return":"}()),e===null&&(n=f),e}function V(){var e,l,u,f,p,m,v;if(p=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)}(p)),e===null&&(n=p),e}function J(){var e;return/^[!-~]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[!-~]")),e===null&&(e=F()),e}function F(){var e;return/^[\x80-\uFFFF]/.test(o.charAt(n))?(e=o.charAt(n),n++):(e=null,h("[\\x80-\\uFFFF]")),e}function X(){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 tt(){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=H(),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 W(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return"*"}()),e===null&&(n=f),e}function G(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return"/"}()),e===null&&(n=f),e}function re(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return"="}()),e===null&&(n=f),e}function ge(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return"("}()),e===null&&(n=f),e}function be(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),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(p){return">"}()),e===null&&(n=u),e}function Ce(){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(p){return"<"}()),e===null&&(n=u),e}function le(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return","}()),e===null&&(n=f),e}function ye(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return";"}()),e===null&&(n=f),e}function st(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m){return":"}()),e===null&&(n=f),e}function lt(){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(p){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(p){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=F(),e===null&&(e=M())))),e}function Oe(){var e,l,u,f,p,m;if(p=n,m=n,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=ue(),f===null&&(f=de());f!==null;)u.push(f),f=ue(),f===null&&(f=de());u!==null?(f=I(),f!==null?e=[e,l,u,f]:(e=null,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)}(p)),e===null&&(n=p),e}function pe(){var e,l,u,f,p,m;if(p=n,m=n,e=D(),e!==null)if(l=I(),l!==null){for(u=[],f=ue(),f===null&&(f=de());f!==null;)u.push(f),f=ue(),f===null&&(f=de());u!==null?(f=I(),f!==null?e=[e,l,u,f]:(e=null,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")}(p)),e===null&&(n=p),e}function ue(){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=F())))),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,p,m;return p=n,m=n,e=Qe(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=ht(),u=u!==null?u:"",u!==null?(f=Xt(),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 us(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=p),e}function Ne(){var e,l,u,f,p,m,v,S;return v=n,S=n,e=Qe(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=ht(),u=u!==null?u:"",u!==null?(f=Xt(),f!==null?(p=On(),p!==null?(m=Js(),m=m!==null?m:"",m!==null?e=[e,l,u,f,p,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 us(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 Qe(){var e;return e=Le(),e===null&&(e=kt()),e}function Le(){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 kt(){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 ht(){var e,l,u,f,p,m;return f=n,p=n,e=Rn(),e!==null?(m=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=Ws(),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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(v){w.user=decodeURIComponent(o.substring(n-1,v))}(f)),e===null&&(n=f),e}function Rn(){var e,l;if(l=j(),l===null&&(l=ve(),l===null&&(l=In())),l!==null)for(e=[];l!==null;)e.push(l),l=j(),l===null&&(l=ve(),l===null&&(l=In()));else e=null;return e}function In(){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 Ws(){var e,l,u;for(u=n,e=[],l=j(),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=j(),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 Xt(){var e,l,u,f,p;return f=n,e=os(),e!==null?(p=n,o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=gr(),u!==null?l=[l,u]:(l=null,n=p)):(l=null,n=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function os(){var e,l;return l=n,e=Ks(),e===null&&(e=Gt(),e===null&&(e=Ys())),e!==null&&(e=function(u){return w.host=o.substring(n,u).toLowerCase(),w.host}(l)),e===null&&(n=l),e}function Ks(){var e,l,u,f,p,m;for(f=n,p=n,e=[],m=n,l=bn(),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=bn(),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=wn(),l!==null?(o.charCodeAt(n)===46?(u=".",n++):(u=null,h('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(v){return w.host_type="domain",o.substring(n,v)}(f)),e===null&&(n=f),e}function bn(){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 wn(){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 Ys(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),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,p,m,v,S,O,ie,Ue,wt,Ps,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?(p=oe(),p!==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?(wt=":",n++):(wt=null,h('":"')),wt!==null?(Ps=ot(),Ps!==null?e=[e,l,u,f,p,m,v,S,O,ie,Ue,wt,Ps]:(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?(p=":",n++):(p=null,h('":"')),p!==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?(wt=ot(),wt!==null?e=[e,l,u,f,p,m,v,S,O,ie,Ue,wt]:(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?(p=":",n++):(p=null,h('":"')),p!==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=ot(),ie!==null?e=[e,l,u,f,p,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?(p=":",n++):(p=null,h('":"')),p!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=ot(),S!==null?e=[e,l,u,f,p,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?(p=":",n++):(p=null,h('":"')),p!==null?(m=ot(),m!==null?e=[e,l,u,f,p,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=ot(),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=ot(),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?(p=oe(),p!==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=ot(),Ue!==null?e=[e,l,u,f,p,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?(p=":",n++):(p=null,h('":"')),p!==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=ot(),ie!==null?e=[e,l,u,f,p,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?(p=oe(),p!==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=ot(),O!==null?e=[e,l,u,f,p,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?(p=oe(),p!==null?f=[f,p]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(o.substr(n,2)==="::"?(p="::",n+=2):(p=null,h('"::"')),p!==null?(m=oe(),m!==null?(o.charCodeAt(n)===58?(v=":",n++):(v=null,h('":"')),v!==null?(S=ot(),S!==null?e=[e,l,u,f,p,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?(p=oe(),p!==null?f=[f,p]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(p=":",n++):(p=null,h('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,n=Te)):(p=null,n=Te),p=p!==null?p:"",p!==null?(o.substr(n,2)==="::"?(m="::",n+=2):(m=null,h('"::"')),m!==null?(v=ot(),v!==null?e=[e,l,u,f,p,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?(p=oe(),p!==null?f=[f,p]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(p=":",n++):(p=null,h('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,n=Te)):(p=null,n=Te),p=p!==null?p:"",p!==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,p,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?(p=oe(),p!==null?f=[f,p]:(f=null,n=Te)):(f=null,n=Te),f=f!==null?f:"",f!==null?(Te=n,o.charCodeAt(n)===58?(p=":",n++):(p=null,h('":"')),p!==null?(m=oe(),m!==null?p=[p,m]:(p=null,n=Te)):(p=null,n=Te),p=p!==null?p:"",p!==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,p,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(N_){return w.host_type="IPv6",o.substring(n,N_)}(k)),e===null&&(n=k),e}function oe(){var e,l,u,f,p;return p=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=p)):(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e}function ot(){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=Gt()),e}function Gt(){var e,l,u,f,p,m,v,S,O;return S=n,O=n,e=ys(),e!==null?(o.charCodeAt(n)===46?(l=".",n++):(l=null,h('"."')),l!==null?(u=ys(),u!==null?(o.charCodeAt(n)===46?(f=".",n++):(f=null,h('"."')),f!==null?(p=ys(),p!==null?(o.charCodeAt(n)===46?(m=".",n++):(m=null,h('"."')),m!==null?(v=ys(),v!==null?e=[e,l,u,f,p,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 ys(){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 gr(){var e,l,u,f,p,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?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(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 On(){var e,l,u,f;for(e=[],f=n,o.charCodeAt(n)===59?(l=";",n++):(l=null,h('";"')),l!==null?(u=Dn(),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=Dn(),u!==null?l=[l,u]:(l=null,n=f)):(l=null,n=f);return e}function Dn(){var e;return e=Tr(),e===null&&(e=vr(),e===null&&(e=Er(),e===null&&(e=Sr(),e===null&&(e=yr(),e===null&&(e=Ar(),e===null&&(e=Cr())))))),e}function Tr(){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(p,m){w.uri_params||(w.uri_params={}),w.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(n=u),e}function vr(){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(p,m){w.uri_params||(w.uri_params={}),w.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(n=u),e}function Er(){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=sn(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.method=m}(u,e[1])),e===null&&(n=u),e}function Sr(){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=Si(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(p,m){w.params||(w.params={}),w.params.ttl=m}(u,e[1])),e===null&&(n=u),e}function yr(){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=os(),l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e!==null&&(e=function(p,m){w.uri_params||(w.uri_params={}),w.uri_params.maddr=m}(u,e[1])),e===null&&(n=u),e}function Ar(){var e,l,u,f,p,m;return f=n,p=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=p)):(e=null,n=p),e!==null&&(e=function(v){w.uri_params||(w.uri_params={}),w.uri_params.lr=void 0}()),e===null&&(n=f),e}function Cr(){var e,l,u,f,p,m;return f=n,p=n,e=Rr(),e!==null?(m=n,o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l!==null?(u=As(),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=p)):(e=null,n=p),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 Rr(){var e,l,u;if(u=n,l=Cs(),l!==null)for(e=[];l!==null;)e.push(l),l=Cs();else e=null;return e!==null&&(e=function(f,p){return p.join("")}(u,e)),e===null&&(n=u),e}function As(){var e,l,u;if(u=n,l=Cs(),l!==null)for(e=[];l!==null;)e.push(l),l=Cs();else e=null;return e!==null&&(e=function(f,p){return p.join("")}(u,e)),e===null&&(n=u),e}function Cs(){var e;return e=Ir(),e===null&&(e=j(),e===null&&(e=ve())),e}function Ir(){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 Js(){var e,l,u,f,p,m,v;if(m=n,o.charCodeAt(n)===63?(e="?",n++):(e=null,h('"?"')),e!==null)if(l=zs(),l!==null){for(u=[],v=n,o.charCodeAt(n)===38?(f="&",n++):(f=null,h('"&"')),f!==null?(p=zs(),p!==null?f=[f,p]:(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?(p=zs(),p!==null?f=[f,p]:(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 zs(){var e,l,u,f,p;return f=n,p=n,e=br(),e!==null?(o.charCodeAt(n)===61?(l="=",n++):(l=null,h('"="')),l!==null?(u=Rs(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),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 br(){var e,l;if(l=Xs(),l===null&&(l=j(),l===null&&(l=ve())),l!==null)for(e=[];l!==null;)e.push(l),l=Xs(),l===null&&(l=j(),l===null&&(l=ve()));else e=null;return e}function Rs(){var e,l;for(e=[],l=Xs(),l===null&&(l=j(),l===null&&(l=ve()));l!==null;)e.push(l),l=Xs(),l===null&&(l=j(),l===null&&(l=ve()));return e}function Xs(){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 hl(){var e;return e=Vr(),e===null&&(e=wr()),e}function wr(){var e,l,u,f,p,m;return m=n,e=sn(),e!==null?(l=H(),l!==null?(u=Nn(),u!==null?(f=H(),f!==null?(p=xn(),p!==null?e=[e,l,u,f,p]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function Nn(){var e;return e=Ne(),e===null&&(e=Un()),e}function Un(){var e,l,u,f;return f=n,e=Nr(),e!==null?(o.charCodeAt(n)===58?(l=":",n++):(l=null,h('":"')),l!==null?(u=Or(),u===null&&(u=Is()),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Or(){var e,l,u,f,p;return f=n,e=Qs(),e===null&&(e=Zs()),e!==null?(p=n,o.charCodeAt(n)===63?(l="?",n++):(l=null,h('"?"')),l!==null?(u=Pn(),u!==null?l=[l,u]:(l=null,n=p)):(l=null,n=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function Qs(){var e,l,u,f;return f=n,o.substr(n,2)==="//"?(e="//",n+=2):(e=null,h('"//"')),e!==null?(l=Ur(),l!==null?(u=Zs(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Zs(){var e,l,u;return u=n,o.charCodeAt(n)===47?(e="/",n++):(e=null,h('"/"')),e!==null?(l=en(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function Is(){var e,l,u,f;if(f=n,e=Dr(),e!==null){for(l=[],u=bs();u!==null;)l.push(u),u=bs();l!==null?e=[e,l]:(e=null,n=f)}else e=null,n=f;return e}function bs(){var e;return e=N(),e===null&&(e=j(),e===null&&(e=ve())),e}function Dr(){var e;return e=j(),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 en(){var e,l,u,f,p,m;if(p=n,e=ws(),e!==null){for(l=[],m=n,o.charCodeAt(n)===47?(u="/",n++):(u=null,h('"/"')),u!==null?(f=ws(),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=ws(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function ws(){var e,l,u,f,p,m;for(p=n,e=[],l=Os();l!==null;)e.push(l),l=Os();if(e!==null){for(l=[],m=n,o.charCodeAt(n)===59?(u=";",n++):(u=null,h('";"')),u!==null?(f=as(),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=as(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function as(){var e,l;for(e=[],l=Os();l!==null;)e.push(l),l=Os();return e}function Os(){var e;return e=j(),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 Nr(){var e,l,u,f,p;if(f=n,p=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=p)}else e=null,n=p;return e!==null&&(e=function(m){w.scheme=o.substring(n,m)}(f)),e===null&&(n=f),e}function Ur(){var e;return e=Pr(),e===null&&(e=xr()),e}function Pr(){var e,l,u,f;return u=n,f=n,e=ht(),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=Xt(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e=e!==null?e:"",e}function xr(){var e,l;if(l=j(),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=j(),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 Pn(){var e,l;for(e=[],l=bs();l!==null;)e.push(l),l=bs();return e}function xn(){var e,l,u,f,p,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(p=[];m!==null;)p.push(m),m=T();else p=null;p!==null?e=[e,l,u,f,p]:(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 Mr(){var e;return o.substr(n,6)==="INVITE"?(e="INVITE",n+=6):(e=null,h('"INVITE"')),e}function kr(){var e;return o.substr(n,3)==="ACK"?(e="ACK",n+=3):(e=null,h('"ACK"')),e}function Lr(){var e;return o.substr(n,7)==="OPTIONS"?(e="OPTIONS",n+=7):(e=null,h('"OPTIONS"')),e}function $r(){var e;return o.substr(n,3)==="BYE"?(e="BYE",n+=3):(e=null,h('"BYE"')),e}function Hr(){var e;return o.substr(n,6)==="CANCEL"?(e="CANCEL",n+=6):(e=null,h('"CANCEL"')),e}function Fr(){var e;return o.substr(n,8)==="REGISTER"?(e="REGISTER",n+=8):(e=null,h('"REGISTER"')),e}function jr(){var e;return o.substr(n,9)==="SUBSCRIBE"?(e="SUBSCRIBE",n+=9):(e=null,h('"SUBSCRIBE"')),e}function qr(){var e;return o.substr(n,6)==="NOTIFY"?(e="NOTIFY",n+=6):(e=null,h('"NOTIFY"')),e}function tn(){var e;return o.substr(n,5)==="REFER"?(e="REFER",n+=5):(e=null,h('"REFER"')),e}function sn(){var e,l;return l=n,e=Mr(),e===null&&(e=kr(),e===null&&(e=Lr(),e===null&&(e=$r(),e===null&&(e=Hr(),e===null&&(e=Fr(),e===null&&(e=jr(),e===null&&(e=qr(),e===null&&(e=tn(),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 Vr(){var e,l,u,f,p,m;return m=n,e=xn(),e!==null?(l=H(),l!==null?(u=Br(),u!==null?(f=H(),f!==null?(p=dl(),p!==null?e=[e,l,u,f,p]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function Br(){var e,l;return l=n,e=Gr(),e!==null&&(e=function(u,f){w.status_code=parseInt(f.join(""))}(l,e)),e===null&&(n=l),e}function Gr(){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 dl(){var e,l,u;for(u=n,e=[],l=N(),l===null&&(l=j(),l===null&&(l=ve(),l===null&&(l=F(),l===null&&(l=X(),l===null&&(l=H(),l===null&&(l=L()))))));l!==null;)e.push(l),l=N(),l===null&&(l=j(),l===null&&(l=ve(),l===null&&(l=F(),l===null&&(l=X(),l===null&&(l=H(),l===null&&(l=L()))))));return e!==null&&(e=function(f){w.reason_phrase=o.substring(n,f)}(u)),e===null&&(n=u),e}function Go(){var e,l,u,f,p,m;if(p=n,e=on(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=on(),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=on(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function Wo(){var e,l,u,f,p,m;return f=n,p=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=p)):(e=null,n=p),e!==null&&(e=function(v){w=o.substring(n,v)}(f)),e===null&&(n=f),e}function Mn(){var e,l,u,f,p,m,v;if(p=n,e=W(),e===null)if(m=n,e=Lt(),e!==null){for(l=[],v=n,u=le(),u!==null?(f=Lt(),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=Lt(),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=p),e}function Lt(){var e,l,u,f,p,m,v;if(p=n,m=n,e=we(),e===null&&(e=$t()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=kn(),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=kn(),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})}(p)),e===null&&(n=p),e}function $t(){var e,l,u,f,p;return p=n,e=Ds(),e=e!==null?e:"",e!==null?(l=Ce(),l!==null?(u=Ne(),u!==null?(f=xe(),f!==null?e=[e,l,u,f]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e}function Ds(){var e,l,u,f,p,m,v;if(p=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])}(p,e)),e===null&&(n=p),e}function kn(){var e;return e=Wr(),e===null&&(e=Qt(),e===null&&(e=We())),e}function Wr(){var e,l,u,f,p;return f=n,p=n,o.substr(n,1).toLowerCase()==="q"?(e=o.substr(n,1),n++):(e=null,h('"q"')),e!==null?(l=re(),l!==null?(u=Ge(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.q=v}(f,e[2])),e===null&&(n=f),e}function Qt(){var e,l,u,f,p;return f=n,p=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=Zt(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.params||(w.params={}),w.params.expires=v}(f,e[2])),e===null&&(n=f),e}function Zt(){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,p){return parseInt(p.join(""))}(u,e)),e===null&&(n=u),e}function Ge(){var e,l,u,f,p,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?(p=T(),p=p!==null?p:"",p!==null?l=[l,u,f,p]:(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 We(){var e,l,u,f,p,m;return f=n,p=n,e=P(),e!==null?(m=n,l=re(),l!==null?(u=pl(),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=p)):(e=null,n=p),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 pl(){var e;return e=P(),e===null&&(e=os(),e===null&&(e=Oe())),e}function ml(){var e,l,u,f,p,m;if(p=n,e=Ln(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=$n(),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=$n(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function Ln(){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 $n(){var e;return e=gl(),e===null&&(e=We()),e}function gl(){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 Ko(){var e,l,u,f,p,m;if(p=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=p)}else e=null,n=p;return e}function Yo(){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,p){w=parseInt(p.join(""))}(u,e)),e===null&&(n=u),e}function Tl(){var e,l;return l=n,e=Kr(),e!==null&&(e=function(u){w=o.substring(n,u)}(l)),e===null&&(n=l),e}function Kr(){var e,l,u,f,p,m,v,S;if(v=n,e=Yr(),e!==null)if(l=G(),l!==null)if(u=Hn(),u!==null){for(f=[],S=n,p=ye(),p!==null?(m=Fn(),m!==null?p=[p,m]:(p=null,n=S)):(p=null,n=S);p!==null;)f.push(p),S=n,p=ye(),p!==null?(m=Fn(),m!==null?p=[p,m]:(p=null,n=S)):(p=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 Yr(){var e;return e=Jr(),e===null&&(e=nn()),e}function Jr(){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=rn()))))),e}function nn(){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=rn())),e}function rn(){var e;return e=P(),e===null&&(e=zr()),e}function zr(){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 Hn(){var e;return e=rn(),e===null&&(e=P()),e}function Fn(){var e,l,u,f;return f=n,e=P(),e!==null?(l=re(),l!==null?(u=vl(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function vl(){var e;return e=P(),e===null&&(e=Oe()),e}function El(){var e,l,u,f;return f=n,e=Sl(),e!==null?(l=M(),l!==null?(u=sn(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function Sl(){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,p){w.value=parseInt(p.join(""))}(u,e)),e===null&&(n=u),e}function Jo(){var e,l;return l=n,e=Zt(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(n=l),e}function ln(){var e,l,u,f,p,m,v;if(p=n,m=n,e=on(),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=We(),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=We(),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()}(p,e[0])),e===null&&(n=p),e}function on(){var e,l,u,f,p,m;if(p=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=p)}else e=null,n=p;return e}function Xr(){var e,l,u,f,p,m,v;if(p=n,m=n,e=we(),e===null&&(e=$t()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=an(),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=an(),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=p),e}function an(){var e;return e=Qr(),e===null&&(e=We()),e}function Qr(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.tag=v}(f,e[2])),e===null&&(n=f),e}function zo(){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,p){w=parseInt(p.join(""))}(u,e)),e===null&&(n=u),e}function Xo(){var e,l;return l=n,e=Zt(),e!==null&&(e=function(u,f){w=f}(l,e)),e===null&&(n=l),e}function Qo(){var e,l,u,f,p,m,v,S,O,ie;for(S=n,O=n,e=[],l=Ds();l!==null;)e.push(l),l=Ds();if(e!==null)if(l=Ce(),l!==null)if(u=Ne(),u!==null)if(f=xe(),f!==null){for(p=[],ie=n,m=ye(),m!==null?(v=We(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);m!==null;)p.push(m),ie=n,m=ye(),m!==null?(v=We(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);p!==null?e=[e,l,u,f,p]:(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 Zr(){var e;return e=jn(),e}function jn(){var e,l,u,f,p,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=un(),u!==null){for(f=[],S=n,p=le(),p!==null?(m=un(),m!==null?p=[p,m]:(p=null,n=S)):(p=null,n=S);p!==null;)f.push(p),S=n,p=le(),p!==null?(m=un(),m!==null?p=[p,m]:(p=null,n=S)):(p=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=Ns()),e}function Ns(){var e,l,u,f,p,m,v,S;if(v=n,e=P(),e!==null)if(l=M(),l!==null)if(u=es(),u!==null){for(f=[],S=n,p=le(),p!==null?(m=es(),m!==null?p=[p,m]:(p=null,n=S)):(p=null,n=S);p!==null;)f.push(p),S=n,p=le(),p!==null?(m=es(),m!==null?p=[p,m]:(p=null,n=S)):(p=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 es(){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 un(){var e;return e=ei(),e===null&&(e=cn(),e===null&&(e=si(),e===null&&(e=ri(),e===null&&(e=ii(),e===null&&(e=li(),e===null&&(e=_n(),e===null&&(e=es()))))))),e}function ei(){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=ti(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function ti(){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 cn(){var e,l,u,f,p,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=lt(),u!==null)if(f=fn(),f!==null){if(p=[],O=n,v=H(),v!==null)for(m=[];v!==null;)m.push(v),v=H();else m=null;for(m!==null?(v=fn(),v!==null?m=[m,v]:(m=null,n=O)):(m=null,n=O);m!==null;){if(p.push(m),O=n,v=H(),v!==null)for(m=[];v!==null;)m.push(v),v=H();else m=null;m!==null?(v=fn(),v!==null?m=[m,v]:(m=null,n=O)):(m=null,n=O)}p!==null?(m=Ee(),m!==null?e=[e,l,u,f,p,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 fn(){var e;return e=Un(),e===null&&(e=Zs()),e}function si(){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=ni(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function ni(){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 ri(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.opaque=v}(f,e[2])),e===null&&(n=f),e}function ii(){var e,l,u,f,p;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?(p=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=p),u===null&&(p=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=p)),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function li(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.algorithm=v.toUpperCase()}(f,e[2])),e===null&&(n=f),e}function _n(){var e,l,u,f,p,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=lt(),u!==null){if(O=n,f=qn(),f!==null){for(p=[],ie=n,o.charCodeAt(n)===44?(m=",",n++):(m=null,h('","')),m!==null?(v=qn(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);m!==null;)p.push(m),ie=n,o.charCodeAt(n)===44?(m=",",n++):(m=null,h('","')),m!==null?(v=qn(),v!==null?m=[m,v]:(m=null,n=ie)):(m=null,n=ie);p!==null?f=[f,p]:(f=null,n=O)}else f=null,n=O;f!==null?(p=Ee(),p!==null?e=[e,l,u,f,p]:(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 qn(){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 Zo(){var e,l,u,f,p,m;if(p=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=p)}else e=null,n=p;return e}function Vn(){var e,l,u,f,p,m,v;if(p=n,m=n,e=Bn(),e!==null){for(l=[],v=n,u=le(),u!==null?(f=Bn(),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=Bn(),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=p),e}function Bn(){var e,l,u,f,p,m,v;if(p=n,m=n,e=$t(),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=We(),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=We(),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})}(p)),e===null&&(n=p),e}function oi(){var e,l,u,f,p,m,v;if(p=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=Gn(),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=Gn(),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}}(p,e[0])),e===null&&(n=p),e}function Gn(){var e;return e=yl(),e===null&&(e=We()),e}function yl(){var e,l,u,f,p,m;if(p=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(""))}(p,e[2])),e===null&&(n=p),e}function ea(){var e,l,u,f,p,m;if(p=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=p)}else e=null,n=p;return e}function Wn(){var e,l,u,f,p,m;if(p=n,e=Kn(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=Kn(),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=Kn(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function Kn(){var e,l,u,f,p,m;if(p=n,e=$t(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=We(),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=We(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function Al(){var e,l,u,f,p,m;if(p=n,e=Yn(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=Jn(),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=Jn(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function Yn(){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 Jn(){var e,l,u,f,p;return f=n,p=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=Cl(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.reason=v)}(f,e[2])),e===null&&(n=f),e===null&&(f=n,p=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=Zt(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.expires=v)}(f,e[2])),e===null&&(n=f),e===null&&(f=n,p=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=Zt(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){typeof v<"u"&&(w.retry_after=v)}(f,e[2])),e===null&&(n=f),e===null&&(e=We()))),e}function Cl(){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 ta(){var e;return e=V(),e=e!==null?e:"",e}function sa(){var e,l,u,f,p,m;if(p=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=p)}else e=null,n=p;return e=e!==null?e:"",e}function ai(){var e,l,u,f,p,m,v;if(p=n,m=n,e=we(),e===null&&(e=$t()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=ui(),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=ui(),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=p),e}function ui(){var e;return e=Qr(),e===null&&(e=We()),e}function zn(){var e,l,u,f,p,m;if(p=n,e=Us(),e!==null){for(l=[],m=n,u=le(),u!==null?(f=Us(),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=Us(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function Us(){var e,l,u,f,p,m,v,S;if(v=n,e=mi(),e!==null)if(l=M(),l!==null)if(u=vi(),u!==null){for(f=[],S=n,p=ye(),p!==null?(m=Xn(),m!==null?p=[p,m]:(p=null,n=S)):(p=null,n=S);p!==null;)f.push(p),S=n,p=ye(),p!==null?(m=Xn(),m!==null?p=[p,m]:(p=null,n=S)):(p=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 Xn(){var e;return e=ci(),e===null&&(e=fi(),e===null&&(e=_i(),e===null&&(e=hi(),e===null&&(e=di(),e===null&&(e=We()))))),e}function ci(){var e,l,u,f,p;return f=n,p=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=Si(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.ttl=v}(f,e[2])),e===null&&(n=f),e}function fi(){var e,l,u,f,p;return f=n,p=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=os(),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.maddr=v}(f,e[2])),e===null&&(n=f),e}function _i(){var e,l,u,f,p;return f=n,p=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=Gt(),u===null&&(u=me()),u!==null?e=[e,l,u]:(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.received=v}(f,e[2])),e===null&&(n=f),e}function hi(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.branch=v}(f,e[2])),e===null&&(n=f),e}function di(){var e,l,u,f,p;return f=n,o.substr(n,5).toLowerCase()==="rport"?(e=o.substr(n,5),n+=5):(e=null,h('"rport"')),e!==null?(p=n,l=re(),l!==null?(u=pi(),u!==null?l=[l,u]:(l=null,n=p)):(l=null,n=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function pi(){var e,l,u,f,p,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?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(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 mi(){var e,l,u,f,p,m;return m=n,e=gi(),e!==null?(l=G(),l!==null?(u=P(),u!==null?(f=G(),f!==null?(p=Ti(),p!==null?e=[e,l,u,f,p]:(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m)):(e=null,n=m),e}function gi(){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 Ti(){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 vi(){var e,l,u,f,p;return f=n,e=Ei(),e!==null?(p=n,l=st(),l!==null?(u=Qn(),u!==null?l=[l,u]:(l=null,n=p)):(l=null,n=p),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,n=f)):(e=null,n=f),e}function Ei(){var e,l;return l=n,e=Gt(),e===null&&(e=Ys(),e===null&&(e=Ks())),e!==null&&(e=function(u){w.host=o.substring(n,u)}(l)),e===null&&(n=l),e}function Qn(){var e,l,u,f,p,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?(p=T(),p=p!==null?p:"",p!==null?e=[e,l,u,f,p]:(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 Si(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){return parseInt(v.join(""))}(f,e)),e===null&&(n=f),e}function na(){var e;return e=jn(),e}function Rl(){var e,l,u,f,p,m;if(p=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=p)}else e=null,n=p;return e}function Zn(){var e,l;return l=n,e=Zt(),e!==null&&(e=function(u,f){w.expires=f}(l,e)),e===null&&(n=l),e}function er(){var e;return e=Il(),e===null&&(e=We()),e}function Il(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.refresher=v.toLowerCase()}(f,e[2])),e===null&&(n=f),e}function bl(){var e,l,u,f;return f=n,e=P(),e!==null?(l=B(),l!==null?(u=wl(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function wl(){var e,l;for(e=[],l=J(),l===null&&(l=X(),l===null&&(l=M()));l!==null;)e.push(l),l=J(),l===null&&(l=X(),l===null&&(l=M()));return e}function ra(){var e,l;for(e=[],l=C();l!==null;)e.push(l),l=C();return e}function Ol(){var e,l,u;return u=n,o.substr(n,5)==="uuid:"?(e="uuid:",n+=5):(e=null,h('"uuid:"')),e!==null?(l=Ht(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function Ht(){var e,l,u,f,p,m,v,S,O,ie,Ue;return ie=n,Ue=n,e=yi(),e!==null?(o.charCodeAt(n)===45?(l="-",n++):(l=null,h('"-"')),l!==null?(u=Ft(),u!==null?(o.charCodeAt(n)===45?(f="-",n++):(f=null,h('"-"')),f!==null?(p=Ft(),p!==null?(o.charCodeAt(n)===45?(m="-",n++):(m=null,h('"-"')),m!==null?(v=Ft(),v!==null?(o.charCodeAt(n)===45?(S="-",n++):(S=null,h('"-"')),S!==null?(O=Dl(),O!==null?e=[e,l,u,f,p,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(wt,Ps){w=o.substring(n+5,wt)}(ie,e[0])),e===null&&(n=ie),e}function Ft(){var e,l,u,f,p;return p=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=p)):(e=null,n=p)):(e=null,n=p)):(e=null,n=p),e}function yi(){var e,l,u;return u=n,e=Ft(),e!==null?(l=Ft(),l!==null?e=[e,l]:(e=null,n=u)):(e=null,n=u),e}function Dl(){var e,l,u,f;return f=n,e=Ft(),e!==null?(l=Ft(),l!==null?(u=Ft(),u!==null?e=[e,l,u]:(e=null,n=f)):(e=null,n=f)):(e=null,n=f),e}function ia(){var e,l,u,f,p,m,v;if(p=n,m=n,e=we(),e===null&&(e=$t()),e!==null){for(l=[],v=n,u=ye(),u!==null?(f=We(),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=We(),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=p),e}function Nl(){var e,l,u,f,p,m;if(p=n,e=tr(),e!==null){for(l=[],m=n,u=ye(),u!==null?(f=sr(),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=sr(),f!==null?u=[u,f]:(u=null,n=m)):(u=null,n=m);l!==null?e=[e,l]:(e=null,n=p)}else e=null,n=p;return e}function tr(){var e,l,u,f,p,m;return f=n,p=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=p)):(e=null,n=p),e!==null&&(e=function(v){w.call_id=o.substring(n,v)}(f)),e===null&&(n=f),e}function sr(){var e;return e=Ai(),e===null&&(e=Ci(),e===null&&(e=Ul(),e===null&&(e=We()))),e}function Ai(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.to_tag=v}(f,e[2])),e===null&&(n=f),e}function Ci(){var e,l,u,f,p;return f=n,p=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=p)):(e=null,n=p)):(e=null,n=p),e!==null&&(e=function(m,v){w.from_tag=v}(f,e[2])),e===null&&(n=f),e}function Ul(){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 la(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 Pl(){for(var e=1,l=1,u=!1,f=0;f<Math.max(n,d);f++){var p=o.charAt(f);p===`
4
- `?(u||e++,l=1,u=!1):p==="\r"||p==="\u2028"||p==="\u2029"?(e++,l=1,u=!0):(l++,u=!1)}return{line:e,column:l}}var us=Gs(),b=Cu(),w={},Ri=t[a]();if(Ri===null||n!==o.length){var Ii=Math.max(n,d),xl=Ii<o.length?o.charAt(Ii):null,i=Pl();return new this.SyntaxError(la(_),xl,Ii,i.line,i.column),-1}return w},toSource:function(){return this._source}};return s.SyntaxError=function(r,o,a,t,n){function d(_,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=d(r,o),this.offset=a,this.line=t,this.column=n},s.SyntaxError.prototype=Error.prototype,s}()),aa}var ua,Gu;function Gs(){if(Gu)return ua;Gu=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=it,d=bt(),_=is();return ua=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 H in C)Object.prototype.hasOwnProperty.call(C,H)&&this.setHeader(H,C[H])}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[d.headerize(T)]=Array.isArray(E)?E:[E]}},{key:"getHeader",value:function(T){if(T)return this._headers[d.headerize(T)]}},{key:"hasHeader",value:function(T){if(T)return this._headers.hasOwnProperty(d.headerize(T))&&!0||!1}},{key:"deleteHeader",value:function(T){if(T=d.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(d.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 H=I.value;T.push("".concat(A,"=").concat(H))}}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(d.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}(),ua}var Wu;function bt(){if(Wu)return Ze;Wu=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,H;return{s:function(){E=g[Symbol.iterator]()},n:function(){var ae=E.next();return C=ae.done,ae},e:function(ae){I=!0,H=ae},f:function(){try{!C&&E.return!=null&&E.return()}finally{if(I)throw H}}}}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=it,t=Gs(),n=is();Ze.str_utf8_length=function(g){return unescape(encodeURIComponent(g)).length};var d=Ze.isFunction=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object Function]":!1};Ze.isString=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object String]":!1},Ze.isDecimal=function(g){return!isNaN(g)&&parseFloat(g)===parseInt(g,10)},Ze.isEmpty=function(g){return g===null||g===""||g===void 0||Array.isArray(g)&&g.length===0||typeof g=="number"&&isNaN(g)},Ze.hasMethods=function(g){for(var 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(d(g[I]))return!1}return!0};var _=Ze.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};Ze.newTag=function(){return _(10)},Ze.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},Ze.hostType=function(g){if(g){if(g=n.parse(g,"host"),g!==-1)return g.host_type}else return};var h=Ze.escapeUser=function(g){return encodeURIComponent(decodeURIComponent(g)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return Ze.normalizeTarget=function(g,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},Ze.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},Ze.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},Ze.getRandomTestNetIP=function(){function g(T,E){return Math.floor(Math.random()*(E-T+1)+T)}return"192.0.2.".concat(g(1,254))},Ze.calculateMD5=function(g){function T(pe,ue){return pe<<ue|pe>>>32-ue}function E(pe,ue){var de=pe&2147483648,we=ue&2147483648,Ne=pe&1073741824,Qe=ue&1073741824,Le=(pe&1073741823)+(ue&1073741823);return Ne&Qe?Le^2147483648^de^we:Ne|Qe?Le&1073741824?Le^3221225472^de^we:Le^1073741824^de^we:Le^de^we}function y(pe,ue,de){return pe&ue|~pe&de}function A(pe,ue,de){return pe&de|ue&~de}function C(pe,ue,de){return pe^ue^de}function I(pe,ue,de){return ue^(pe|~de)}function H(pe,ue,de,we,Ne,Qe,Le){return pe=E(pe,E(E(y(ue,de,we),Ne),Le)),E(T(pe,Qe),ue)}function L(pe,ue,de,we,Ne,Qe,Le){return pe=E(pe,E(E(A(ue,de,we),Ne),Le)),E(T(pe,Qe),ue)}function ae(pe,ue,de,we,Ne,Qe,Le){return pe=E(pe,E(E(C(ue,de,we),Ne),Le)),E(T(pe,Qe),ue)}function N(pe,ue,de,we,Ne,Qe,Le){return pe=E(pe,E(E(I(ue,de,we),Ne),Le)),E(T(pe,Qe),ue)}function j(pe){for(var ue,de=pe.length,we=de+8,Ne=(we-we%64)/64,Qe=(Ne+1)*16,Le=new Array(Qe-1),kt=0,ht=0;ht<de;)ue=(ht-ht%4)/4,kt=ht%4*8,Le[ue]=Le[ue]|pe.charCodeAt(ht)<<kt,ht++;return ue=(ht-ht%4)/4,kt=ht%4*8,Le[ue]=Le[ue]|128<<kt,Le[Qe-2]=de<<3,Le[Qe-1]=de>>>29,Le}function Se(pe){var ue="",de="",we,Ne;for(Ne=0;Ne<=3;Ne++)we=pe>>>Ne*8&255,de="0".concat(we.toString(16)),ue=ue+de.substr(de.length-2,2);return ue}function ve(pe){for(var ue="",de=0;de<pe.length;de++){var we=pe.charCodeAt(de);we<128?ue+=String.fromCharCode(we):we>127&&we<2048?(ue+=String.fromCharCode(we>>6|192),ue+=String.fromCharCode(we&63|128)):(ue+=String.fromCharCode(we>>12|224),ue+=String.fromCharCode(we>>6&63|128),ue+=String.fromCharCode(we&63|128))}return ue}var M=[],D,B,V,J,F,X,U,P,se,tt=7,ee=12,W=17,G=22,re=5,ge=9,be=14,xe=20,Ce=4,le=11,ye=16,st=23,lt=6,Ee=10,Ae=15,Ie=21;for(g=ve(g),M=j(g),X=1732584193,U=4023233417,P=2562383102,se=271733878,D=0;D<M.length;D+=16)B=X,V=U,J=P,F=se,X=H(X,U,P,se,M[D+0],tt,3614090360),se=H(se,X,U,P,M[D+1],ee,3905402710),P=H(P,se,X,U,M[D+2],W,606105819),U=H(U,P,se,X,M[D+3],G,3250441966),X=H(X,U,P,se,M[D+4],tt,4118548399),se=H(se,X,U,P,M[D+5],ee,1200080426),P=H(P,se,X,U,M[D+6],W,2821735955),U=H(U,P,se,X,M[D+7],G,4249261313),X=H(X,U,P,se,M[D+8],tt,1770035416),se=H(se,X,U,P,M[D+9],ee,2336552879),P=H(P,se,X,U,M[D+10],W,4294925233),U=H(U,P,se,X,M[D+11],G,2304563134),X=H(X,U,P,se,M[D+12],tt,1804603682),se=H(se,X,U,P,M[D+13],ee,4254626195),P=H(P,se,X,U,M[D+14],W,2792965006),U=H(U,P,se,X,M[D+15],G,1236535329),X=L(X,U,P,se,M[D+1],re,4129170786),se=L(se,X,U,P,M[D+6],ge,3225465664),P=L(P,se,X,U,M[D+11],be,643717713),U=L(U,P,se,X,M[D+0],xe,3921069994),X=L(X,U,P,se,M[D+5],re,3593408605),se=L(se,X,U,P,M[D+10],ge,38016083),P=L(P,se,X,U,M[D+15],be,3634488961),U=L(U,P,se,X,M[D+4],xe,3889429448),X=L(X,U,P,se,M[D+9],re,568446438),se=L(se,X,U,P,M[D+14],ge,3275163606),P=L(P,se,X,U,M[D+3],be,4107603335),U=L(U,P,se,X,M[D+8],xe,1163531501),X=L(X,U,P,se,M[D+13],re,2850285829),se=L(se,X,U,P,M[D+2],ge,4243563512),P=L(P,se,X,U,M[D+7],be,1735328473),U=L(U,P,se,X,M[D+12],xe,2368359562),X=ae(X,U,P,se,M[D+5],Ce,4294588738),se=ae(se,X,U,P,M[D+8],le,2272392833),P=ae(P,se,X,U,M[D+11],ye,1839030562),U=ae(U,P,se,X,M[D+14],st,4259657740),X=ae(X,U,P,se,M[D+1],Ce,2763975236),se=ae(se,X,U,P,M[D+4],le,1272893353),P=ae(P,se,X,U,M[D+7],ye,4139469664),U=ae(U,P,se,X,M[D+10],st,3200236656),X=ae(X,U,P,se,M[D+13],Ce,681279174),se=ae(se,X,U,P,M[D+0],le,3936430074),P=ae(P,se,X,U,M[D+3],ye,3572445317),U=ae(U,P,se,X,M[D+6],st,76029189),X=ae(X,U,P,se,M[D+9],Ce,3654602809),se=ae(se,X,U,P,M[D+12],le,3873151461),P=ae(P,se,X,U,M[D+15],ye,530742520),U=ae(U,P,se,X,M[D+2],st,3299628645),X=N(X,U,P,se,M[D+0],lt,4096336452),se=N(se,X,U,P,M[D+7],Ee,1126891415),P=N(P,se,X,U,M[D+14],Ae,2878612391),U=N(U,P,se,X,M[D+5],Ie,4237533241),X=N(X,U,P,se,M[D+12],lt,1700485571),se=N(se,X,U,P,M[D+3],Ee,2399980690),P=N(P,se,X,U,M[D+10],Ae,4293915773),U=N(U,P,se,X,M[D+1],Ie,2240044497),X=N(X,U,P,se,M[D+8],lt,1873313359),se=N(se,X,U,P,M[D+15],Ee,4264355552),P=N(P,se,X,U,M[D+6],Ae,2734768916),U=N(U,P,se,X,M[D+13],Ie,1309151649),X=N(X,U,P,se,M[D+4],lt,4149444226),se=N(se,X,U,P,M[D+11],Ee,3174756917),P=N(P,se,X,U,M[D+2],Ae,718787259),U=N(U,P,se,X,M[D+9],Ie,3951481745),X=E(X,B),U=E(U,V),P=E(P,J),se=E(se,F);var Oe=Se(X)+Se(U)+Se(P)+Se(se);return Oe.toLowerCase()},Ze.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(j){E.e(j)}finally{E.f()}}else{T=g.getAudioTracks();var C=s(T),I;try{for(C.s();!(I=C.n()).done;){var H=I.value;H.stop()}}catch(j){C.e(j)}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(j){L.e(j)}finally{L.f()}}}catch{(typeof g.stop=="function"||c(g.stop)==="object")&&g.stop()}},Ze.cloneArray=function(g){return g&&g.slice()||[]},Ze.cloneObject=function(g){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g&&Object.assign({},g)||T},Ze}var Ru={exports:{}},fr=typeof Reflect=="object"?Reflect:null,Ku=fr&&typeof fr.apply=="function"?fr.apply:function(s,r,o){return Function.prototype.apply.call(s,r,o)},ho;fr&&typeof fr.ownKeys=="function"?ho=fr.ownKeys:Object.getOwnPropertySymbols?ho=function(s){return Object.getOwnPropertyNames(s).concat(Object.getOwnPropertySymbols(s))}:ho=function(s){return Object.getOwnPropertyNames(s)};function nh(c){console&&console.warn&&console.warn(c)}var Ff=Number.isNaN||function(s){return s!==s};function ke(){ke.init.call(this)}Ru.exports=ke;Ru.exports.once=oh;ke.EventEmitter=ke;ke.prototype._events=void 0;ke.prototype._eventsCount=0;ke.prototype._maxListeners=void 0;var Yu=10;function jo(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(ke,"defaultMaxListeners",{enumerable:!0,get:function(){return Yu},set:function(c){if(typeof c!="number"||c<0||Ff(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Yu=c}});ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ke.prototype.setMaxListeners=function(s){if(typeof s!="number"||s<0||Ff(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 jf(c){return c._maxListeners===void 0?ke.defaultMaxListeners:c._maxListeners}ke.prototype.getMaxListeners=function(){return jf(this)};ke.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 d=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw d.context=n,d}var _=t[s];if(_===void 0)return!1;if(typeof _=="function")Ku(_,this,r);else for(var h=_.length,g=Wf(_,h),o=0;o<h;++o)Ku(g[o],this,r);return!0};function qf(c,s,r,o){var a,t,n;if(jo(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=jf(c),a>0&&n.length>a&&!n.warned){n.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(s)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=c,d.type=s,d.count=n.length,nh(d)}return c}ke.prototype.addListener=function(s,r){return qf(this,s,r,!1)};ke.prototype.on=ke.prototype.addListener;ke.prototype.prependListener=function(s,r){return qf(this,s,r,!0)};function rh(){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 Vf(c,s,r){var o={fired:!1,wrapFn:void 0,target:c,type:s,listener:r},a=rh.bind(o);return a.listener=r,o.wrapFn=a,a}ke.prototype.once=function(s,r){return jo(r),this.on(s,Vf(this,s,r)),this};ke.prototype.prependOnceListener=function(s,r){return jo(r),this.prependListener(s,Vf(this,s,r)),this};ke.prototype.removeListener=function(s,r){var o,a,t,n,d;if(jo(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){d=o[n].listener,t=n;break}if(t<0)return this;t===0?o.shift():ih(o,t),o.length===1&&(a[s]=o[0]),a.removeListener!==void 0&&this.emit("removeListener",s,d||r)}return this};ke.prototype.off=ke.prototype.removeListener;ke.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 Bf(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?lh(a):Wf(a,a.length)}ke.prototype.listeners=function(s){return Bf(this,s,!0)};ke.prototype.rawListeners=function(s){return Bf(this,s,!1)};ke.listenerCount=function(c,s){return typeof c.listenerCount=="function"?c.listenerCount(s):Gf.call(c,s)};ke.prototype.listenerCount=Gf;function Gf(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}ke.prototype.eventNames=function(){return this._eventsCount>0?ho(this._events):[]};function Wf(c,s){for(var r=new Array(s),o=0;o<s;++o)r[o]=c[o];return r}function ih(c,s){for(;s+1<c.length;s++)c[s]=c[s+1];c.pop()}function lh(c){for(var s=new Array(c.length),r=0;r<s.length;++r)s[r]=c[r].listener||c[r];return s}function oh(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))}Kf(c,s,t,{once:!0}),s!=="error"&&ah(c,a,{once:!0})})}function ah(c,s,r){typeof c.on=="function"&&Kf(c,"error",s,r)}function Kf(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 ft=Ru.exports,iu={exports:{}},ca,Ju;function uh(){if(Ju)return ca;Ju=1;var c=1e3,s=c*60,r=s*60,o=r*24,a=o*7,t=o*365.25;ca=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):d(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 d(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 ca}function ch(c){r.debug=r,r.default=r,r.coerce=_,r.disable=t,r.enable=a,r.enabled=n,r.humanize=uh(),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 H=C,L=Number(new Date),ae=L-(T||L);H.diff=ae,H.prev=T,H.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(H,D),I.splice(N,1),N--}return Se}),r.formatArgs.call(H,I),(H.log||r.log).apply(H,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(d),...r.skips.map(d).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 d(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 fh=ch;(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=fh(s);const{formatters:d}=c.exports;d.j=function(_){try{return JSON.stringify(_)}catch(h){return"[UnexpectedJSONParseError]: "+h.message}}})(iu,iu.exports);var dr=iu.exports;function _h(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function zu(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 hh(c,s,r){return s&&zu(c.prototype,s),r&&zu(c,r),c}var nr=dr,rr="JsSIP",_t=function(){function c(s){_h(this,c),s?(this._debug=nr.default("".concat(rr,":").concat(s)),this._warn=nr.default("".concat(rr,":WARN:").concat(s)),this._error=nr.default("".concat(rr,":ERROR:").concat(s))):(this._debug=nr.default(rr),this._warn=nr.default("".concat(rr,":WARN")),this._error=nr.default("".concat(rr,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return hh(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),Pt={},Yf={},Jf={exports:{}},Xu=Jf.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(Xu).forEach(function(c){var s=Xu[c];s.forEach(function(r){r.reg||(r.reg=/(.*)/),r.format||(r.format="%s")})});var zf=Jf.exports;(function(c){var s=function(d){return String(Number(d))===d?Number(d):d},r=function(d,_,h,g){if(g&&!h)_[g]=s(d[1]);else for(var T=0;T<h.length;T+=1)d[T+1]!=null&&(_[h[T]]=s(d[T+1]))},o=function(d,_,h){var g=d.name&&d.names;d.push&&!_[d.push]?_[d.push]=[]:g&&!_[d.name]&&(_[d.name]={});var T=d.push?{}:g?_[d.name]:_;r(h.match(d.reg),T,d.names,d.name),d.push&&_[d.push].push(T)},a=zf,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(d){var _={},h=[],g=_;return d.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(d,_){var h=_.split(/=(.+)/,2);return h.length===2?d[h[0]]=s(h[1]):h.length===1&&_.length>1&&(d[h[0]]=void 0),d};c.parseParams=function(d){return d.split(/;\s?/).reduce(n,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(d){return d.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(d){for(var _=[],h=d.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(d){return d.split(" ").map(function(_){return _.substring(1,_.length-1).split(",").reduce(n,{})})},c.parseSimulcastStreamList=function(d){return d.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}})})}})(Yf);var fa=zf,dh=/%[sdv%]/g,ph=function(c){var s=1,r=arguments,o=r.length;return c.replace(dh,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""}})},bi=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 ph.apply(null,a)},mh=["v","o","s","i","u","e","p","c","b","t","r","z","a"],gh=["i","c","b","a"],Th=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||mh,o=s.innerOrder||gh,a=[];return r.forEach(function(t){fa[t].forEach(function(n){n.name in c&&c[n.name]!=null?a.push(bi(t,n,c)):n.push in c&&c[n.push]!=null&&c[n.push].forEach(function(d){a.push(bi(t,n,d))})})}),c.media.forEach(function(t){a.push(bi("m",fa.m[0],t)),o.forEach(function(n){fa[n].forEach(function(d){d.name in t&&t[d.name]!=null?a.push(bi(n,d,t)):d.push in t&&t[d.push]!=null&&t[d.push].forEach(function(_){a.push(bi(n,d,_))})})})}),a.join(`\r
1
+ "use strict";var Hh=Object.defineProperty;var Fh=(u,n,a)=>n in u?Hh(u,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):u[n]=a;var Fs=(u,n,a)=>(Fh(u,typeof n!="symbol"?n+"":n,a),a);var qh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ot(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}const jh="jssip",Vh="JsSIP",Bh="the Javascript SIP library",Gh="3.10.0",Wh="https://jssip.net",Kh=["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],Yh="lib/JsSIP.d.ts",zh="lib-es5/JsSIP.js",Jh=["sip","websocket","webrtc","node","browser","library"],Xh="MIT",Qh={type:"git",url:"https://github.com/versatica/JsSIP.git"},Zh={url:"https://github.com/versatica/JsSIP/issues"},e_={"@types/events":"^3.0.0","@types/debug":"^4.1.7",debug:"^4.3.1",events:"^3.3.0","sdp-transform":"^2.14.1"},t_={"@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"},s_={lint:"node npm-scripts.js lint",test:"node npm-scripts.js test",prepublish:"node npm-scripts.js prepublish",release:"node npm-scripts.js release"},lo={name:jh,title:Vh,description:Bh,version:Gh,homepage:Wh,contributors:Kh,types:Yh,main:zh,keywords:Jh,license:Xh,repository:Qh,bugs:Zh,dependencies:e_,devDependencies:t_,scripts:s_};var Wu=lo,vt={USER_AGENT:"".concat(Wu.title," ").concat(Wu.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 xa(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xa=function(a){return typeof a}:xa=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},xa(u)}function ro(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function io(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&Hi(u,n)}function ao(u){var n=Bf();return function(){var e=Fi(u),o;if(n){var p=Fi(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return n_(this,o)}}function n_(u,n){return n&&(xa(n)==="object"||typeof n=="function")?n:l_(u)}function l_(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function ai(u){var n=typeof Map=="function"?new Map:void 0;return ai=function(e){if(e===null||!r_(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n<"u"){if(n.has(e))return n.get(e);n.set(e,o)}function o(){return Pa(e,arguments,Fi(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),Hi(o,e)},ai(u)}function Pa(u,n,a){return Bf()?Pa=Reflect.construct:Pa=function(o,p,t){var v=[null];v.push.apply(v,p);var C=Function.bind.apply(o,v),l=new C;return t&&Hi(l,t.prototype),l},Pa.apply(null,arguments)}function Bf(){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 r_(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function Hi(u,n){return Hi=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},Hi(u,n)}function Fi(u){return Fi=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Fi(u)}var i_=function(u){io(a,u);var n=ao(a);function a(e,o){var p;return ro(this,a),p=n.call(this),p.code=1,p.name="CONFIGURATION_ERROR",p.parameter=e,p.value=o,p.message=p.value?"Invalid value ".concat(JSON.stringify(p.value),' for parameter "').concat(p.parameter,'"'):"Missing parameter: ".concat(p.parameter),p}return a}(ai(Error)),a_=function(u){io(a,u);var n=ao(a);function a(e){var o;return ro(this,a),o=n.call(this),o.code=2,o.name="INVALID_STATE_ERROR",o.status=e,o.message="Invalid status: ".concat(e),o}return a}(ai(Error)),o_=function(u){io(a,u);var n=ao(a);function a(e){var o;return ro(this,a),o=n.call(this),o.code=3,o.name="NOT_SUPPORTED_ERROR",o.message=e,o}return a}(ai(Error)),u_=function(u){io(a,u);var n=ao(a);function a(e){var o;return ro(this,a),o=n.call(this),o.code=4,o.name="NOT_READY_ERROR",o.message=e,o}return a}(ai(Error)),Ql={ConfigurationError:i_,InvalidStateError:a_,NotSupportedError:o_,NotReadyError:u_},_t={},po,Ku;function Nu(){if(Ku)return po;Ku=1;function u(p,t){if(!(p instanceof t))throw new TypeError("Cannot call a class as a function")}function n(p,t){for(var v=0;v<t.length;v++){var C=t[v];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(p,C.key,C)}}function a(p,t,v){return t&&n(p.prototype,t),v&&n(p,v),p}var e=Zl(),o=_n();return po=function(){a(p,null,[{key:"parse",value:function(v){if(v=o.parse(v,"Name_Addr_Header"),v!==-1)return v}}]);function p(t,v,C){if(u(this,p),!t||!(t instanceof e))throw new TypeError('missing or invalid "uri" parameter');this._uri=t,this._parameters={},this.display_name=v;for(var l in C)Object.prototype.hasOwnProperty.call(C,l)&&this.setParam(l,C[l])}return a(p,[{key:"setParam",value:function(v,C){v&&(this._parameters[v.toLowerCase()]=typeof C>"u"||C===null?null:C.toString())}},{key:"getParam",value:function(v){if(v)return this._parameters[v.toLowerCase()]}},{key:"hasParam",value:function(v){if(v)return this._parameters.hasOwnProperty(v.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(v){if(v=v.toLowerCase(),this._parameters.hasOwnProperty(v)){var C=this._parameters[v];return delete this._parameters[v],C}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new p(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(v){return v.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var v=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";v+="<".concat(this._uri.toString(),">");for(var C in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,C)&&(v+=";".concat(C),this._parameters[C]!==null&&(v+="=".concat(this._parameters[C])));return v}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(v){this._display_name=v===0?"0":v}}]),p}(),po}var mo,Yu;function _n(){return Yu||(Yu=1,mo=function(){function u(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(e,o){var p={CRLF:A,DIGIT:b,ALPHA:E,HEXDIG:O,WSP:w,OCTET:N,DQUOTE:U,SP:Y,HTAB:j,alphanum:_e,reserved:k,unreserved:H,mark:de,escaped:Ue,LWS:B,SWS:L,HCOLON:V,TEXT_UTF8_TRIM:G,TEXT_UTF8char:K,UTF8_NONASCII:M,UTF8_CONT:te,LHEX:se,token:$,token_nodot:ne,separators:ct,word:P,STAR:Q,SLASH:oe,EQUAL:he,LPAREN:Re,RPAREN:be,RAQUOT:fe,LAQUOT:qe,COMMA:xe,SEMI:we,COLON:st,LDQUOT:$e,RDQUOT:ue,comment:Oe,ctext:Pe,quoted_string:Le,quoted_string_clean:ye,qdtext:pe,quoted_pair:Ce,SIP_URI_noparams:ke,SIP_URI:He,uri_scheme:Be,uri_scheme_sips:Ve,uri_scheme_sip:Mt,userinfo:ft,user:Gs,user_unreserved:is,password:As,hostport:ys,host:as,hostname:Ws,domainlabel:os,toplabel:Se,IPv6reference:ht,IPv6address:Xt,h16:Ae,ls32:pt,IPv4address:us,dec_octet:me,port:Tt,uri_parameters:Rs,uri_parameter:cs,transport_param:Wn,user_param:Kn,method_param:pn,ttl_param:Yn,maddr_param:zn,lr_param:Jn,other_param:bs,pname:Xn,pvalue:Qn,paramchar:Qt,param_unreserved:Zn,headers:el,header:kt,hname:er,hvalue:tl,hnv_unreserved:Zt,Request_Response:sl,Request_Line:nl,Request_URI:Is,absoluteURI:Ks,hier_part:ll,net_path:ws,abs_path:Os,opaque_part:rl,uric:es,uric_no_slash:Ds,path_segments:Ns,segment:ts,param:mn,pchar:Us,scheme:Ys,authority:gn,srvr:fs,reg_name:il,query:al,SIP_Version:vn,INVITEm:ol,ACKm:ul,OPTIONSm:Tn,BYEm:cl,CANCELm:fl,REGISTERm:hl,SUBSCRIBEm:zs,NOTIFYm:_l,REFERm:dl,Method:Js,Status_Line:pl,Status_Code:tr,extension_code:En,Reason_Phrase:sr,Allow_Events:Cn,Call_ID:hs,Contact:Sn,contact_param:Xs,name_addr:_s,display_name:An,contact_params:Lt,c_p_q:ss,c_p_expires:Ke,delta_seconds:Gt,qvalue:nr,generic_param:Je,gen_value:Wt,Content_Disposition:lr,disp_type:Ze,disp_param:ml,handling_param:$r,Content_Encoding:rr,Content_Length:gl,Content_Type:ir,media_type:ar,m_type:yn,discrete_type:or,composite_type:vl,extension_token:xs,x_token:Tl,m_subtype:ur,m_parameter:Ps,m_value:cr,CSeq:Hr,CSeq_value:ds,Expires:Fr,Event:fr,event_type:ps,From:fi,from_param:hr,tag_param:Ms,Max_Forwards:hi,Min_Expires:Rn,Name_Addr_Header:El,Proxy_Authenticate:bn,challenge:Qs,other_challenge:_r,auth_param:Zs,digest_cln:ks,realm:en,realm_value:Ls,domain:tn,URI:sn,nonce:Cl,nonce_value:Sl,opaque:nn,stale:ln,algorithm:dr,qop_options:pr,qop_value:ms,Proxy_Require:qr,Record_Route:Al,rec_route:gs,Reason:_i,reason_param:mr,reason_cause:vs,Require:di,Route:yl,route_param:$s,Subscription_State:jr,substate_value:Vr,subexp_params:rn,event_reason_value:Br,Subject:Rl,Supported:gr,To:In,to_param:wn,Via:Gr,via_param:On,via_params:an,via_ttl:vr,via_maddr:on,via_received:Dn,via_branch:bl,response_port:Il,rport:wl,sent_protocol:Ol,protocol_name:Dl,transport:Nl,sent_by:Nn,via_host:Tr,via_port:Er,ttl:Un,WWW_Authenticate:Ul,Session_Expires:Cr,s_e_expires:xl,s_e_params:Pl,s_e_refresher:Wr,extension_header:Kr,header_value:xn,message_body:Kt,uuid_URI:Yr,uuid:Ml,hex4:ns,hex8:zr,hex12:kl,Refer_To:jt,Replaces:Sr,call_id:Ll,replaces_param:$l,to_tag:Jr,from_tag:Ar,early_flag:x};if(o!==void 0){if(p[o]===void 0)throw new Error("Invalid rule name: "+u(o)+".")}else o="CRLF";var t=0,v=0,C=[];function l(r){t<v||(t>v&&(v=t,C=[]),C.push(r))}function A(){var r;return e.substr(t,2)===`\r
2
+ `?(r=`\r
3
+ `,t+=2):(r=null,l('"\\r\\n"')),r}function b(){var r;return/^[0-9]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[0-9]")),r}function E(){var r;return/^[a-zA-Z]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[a-zA-Z]")),r}function O(){var r;return/^[0-9a-fA-F]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[0-9a-fA-F]")),r}function w(){var r;return r=Y(),r===null&&(r=j()),r}function N(){var r;return/^[\0-\xFF]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\0-\\xFF]")),r}function U(){var r;return/^["]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l('["]')),r}function Y(){var r;return e.charCodeAt(t)===32?(r=" ",t++):(r=null,l('" "')),r}function j(){var r;return e.charCodeAt(t)===9?(r=" ",t++):(r=null,l('"\\t"')),r}function _e(){var r;return/^[a-zA-Z0-9]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[a-zA-Z0-9]")),r}function k(){var r;return e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","'))))))))))),r}function H(){var r;return r=_e(),r===null&&(r=de()),r}function de(){var r;return e.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(e.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"')),r===null&&(e.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r===null&&(e.charCodeAt(t)===33?(r="!",t++):(r=null,l('"!"')),r===null&&(e.charCodeAt(t)===126?(r="~",t++):(r=null,l('"~"')),r===null&&(e.charCodeAt(t)===42?(r="*",t++):(r=null,l('"*"')),r===null&&(e.charCodeAt(t)===39?(r="'",t++):(r=null,l(`"'"`)),r===null&&(e.charCodeAt(t)===40?(r="(",t++):(r=null,l('"("')),r===null&&(e.charCodeAt(t)===41?(r=")",t++):(r=null,l('")"')))))))))),r}function Ue(){var r,f,d,s,c;return s=t,c=t,e.charCodeAt(t)===37?(r="%",t++):(r=null,l('"%"')),r!==null?(f=O(),f!==null?(d=O(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){return g.join("")}(s,r)),r===null&&(t=s),r}function B(){var r,f,d,s,c,h;for(s=t,c=t,h=t,r=[],f=w();f!==null;)r.push(f),f=w();if(r!==null?(f=A(),f!==null?r=[r,f]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null){if(d=w(),d!==null)for(f=[];d!==null;)f.push(d),d=w();else f=null;f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r!==null&&(r=function(g){return" "}()),r===null&&(t=s),r}function L(){var r;return r=B(),r=r!==null?r:"",r}function V(){var r,f,d,s,c;for(s=t,c=t,r=[],f=Y(),f===null&&(f=j());f!==null;)r.push(f),f=Y(),f===null&&(f=j());return r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return":"}()),r===null&&(t=s),r}function G(){var r,f,d,s,c,h,g;if(c=t,h=t,f=K(),f!==null)for(r=[];f!==null;)r.push(f),f=K();else r=null;if(r!==null){for(f=[],g=t,d=[],s=B();s!==null;)d.push(s),s=B();for(d!==null?(s=K(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;){for(f.push(d),g=t,d=[],s=B();s!==null;)d.push(s),s=B();d!==null?(s=K(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g)}f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){return e.substring(t,S)}(c)),r===null&&(t=c),r}function K(){var r;return/^[!-~]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[!-~]")),r===null&&(r=M()),r}function M(){var r;return/^[\x80-\uFFFF]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\x80-\\uFFFF]")),r}function te(){var r;return/^[\x80-\xBF]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\x80-\\xBF]")),r}function se(){var r;return r=b(),r===null&&(/^[a-f]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[a-f]"))),r}function $(){var r,f,d;if(d=t,f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"'))))))))))));else r=null;return r!==null&&(r=function(s){return e.substring(t,s)}(d)),r===null&&(t=d),r}function ne(){var r,f,d;if(d=t,f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"'))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')))))))))));else r=null;return r!==null&&(r=function(s){return e.substring(t,s)}(d)),r===null&&(t=d),r}function ct(){var r;return e.charCodeAt(t)===40?(r="(",t++):(r=null,l('"("')),r===null&&(e.charCodeAt(t)===41?(r=")",t++):(r=null,l('")"')),r===null&&(e.charCodeAt(t)===60?(r="<",t++):(r=null,l('"<"')),r===null&&(e.charCodeAt(t)===62?(r=">",t++):(r=null,l('">"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')),r===null&&(e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===92?(r="\\",t++):(r=null,l('"\\\\"')),r===null&&(r=U(),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r===null&&(e.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===123?(r="{",t++):(r=null,l('"{"')),r===null&&(e.charCodeAt(t)===125?(r="}",t++):(r=null,l('"}"')),r===null&&(r=Y(),r===null&&(r=j())))))))))))))))))),r}function P(){var r,f,d;if(d=t,f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')),f===null&&(e.charCodeAt(t)===40?(f="(",t++):(f=null,l('"("')),f===null&&(e.charCodeAt(t)===41?(f=")",t++):(f=null,l('")"')),f===null&&(e.charCodeAt(t)===60?(f="<",t++):(f=null,l('"<"')),f===null&&(e.charCodeAt(t)===62?(f=">",t++):(f=null,l('">"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===92?(f="\\",t++):(f=null,l('"\\\\"')),f===null&&(f=U(),f===null&&(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f===null&&(e.charCodeAt(t)===91?(f="[",t++):(f=null,l('"["')),f===null&&(e.charCodeAt(t)===93?(f="]",t++):(f=null,l('"]"')),f===null&&(e.charCodeAt(t)===63?(f="?",t++):(f=null,l('"?"')),f===null&&(e.charCodeAt(t)===123?(f="{",t++):(f=null,l('"{"')),f===null&&(e.charCodeAt(t)===125?(f="}",t++):(f=null,l('"}"'))))))))))))))))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')),f===null&&(e.charCodeAt(t)===40?(f="(",t++):(f=null,l('"("')),f===null&&(e.charCodeAt(t)===41?(f=")",t++):(f=null,l('")"')),f===null&&(e.charCodeAt(t)===60?(f="<",t++):(f=null,l('"<"')),f===null&&(e.charCodeAt(t)===62?(f=">",t++):(f=null,l('">"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===92?(f="\\",t++):(f=null,l('"\\\\"')),f===null&&(f=U(),f===null&&(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f===null&&(e.charCodeAt(t)===91?(f="[",t++):(f=null,l('"["')),f===null&&(e.charCodeAt(t)===93?(f="]",t++):(f=null,l('"]"')),f===null&&(e.charCodeAt(t)===63?(f="?",t++):(f=null,l('"?"')),f===null&&(e.charCodeAt(t)===123?(f="{",t++):(f=null,l('"{"')),f===null&&(e.charCodeAt(t)===125?(f="}",t++):(f=null,l('"}"')))))))))))))))))))))))));else r=null;return r!==null&&(r=function(s){return e.substring(t,s)}(d)),r===null&&(t=d),r}function Q(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"*"}()),r===null&&(t=s),r}function oe(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"/"}()),r===null&&(t=s),r}function he(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"="}()),r===null&&(t=s),r}function Re(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===40?(f="(",t++):(f=null,l('"("')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"("}()),r===null&&(t=s),r}function be(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===41?(f=")",t++):(f=null,l('")"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return")"}()),r===null&&(t=s),r}function fe(){var r,f,d,s;return d=t,s=t,e.charCodeAt(t)===62?(r=">",t++):(r=null,l('">"')),r!==null?(f=L(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return">"}()),r===null&&(t=d),r}function qe(){var r,f,d,s;return d=t,s=t,r=L(),r!==null?(e.charCodeAt(t)===60?(f="<",t++):(f=null,l('"<"')),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return"<"}()),r===null&&(t=d),r}function xe(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return","}()),r===null&&(t=s),r}function we(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return";"}()),r===null&&(t=s),r}function st(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return":"}()),r===null&&(t=s),r}function $e(){var r,f,d,s;return d=t,s=t,r=L(),r!==null?(f=U(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return'"'}()),r===null&&(t=d),r}function ue(){var r,f,d,s;return d=t,s=t,r=U(),r!==null?(f=L(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return'"'}()),r===null&&(t=d),r}function Oe(){var r,f,d,s;if(s=t,r=Re(),r!==null){for(f=[],d=Pe(),d===null&&(d=Ce(),d===null&&(d=Oe()));d!==null;)f.push(d),d=Pe(),d===null&&(d=Ce(),d===null&&(d=Oe()));f!==null?(d=be(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)}else r=null,t=s;return r}function Pe(){var r;return/^[!-']/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[!-']")),r===null&&(/^[*-[]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[*-[]")),r===null&&(/^[\]-~]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\]-~]")),r===null&&(r=M(),r===null&&(r=B())))),r}function Le(){var r,f,d,s,c,h;if(c=t,h=t,r=L(),r!==null)if(f=U(),f!==null){for(d=[],s=pe(),s===null&&(s=Ce());s!==null;)d.push(s),s=pe(),s===null&&(s=Ce());d!==null?(s=U(),s!==null?r=[r,f,d,s]:(r=null,t=h)):(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r!==null&&(r=function(g){return e.substring(t,g)}(c)),r===null&&(t=c),r}function ye(){var r,f,d,s,c,h;if(c=t,h=t,r=L(),r!==null)if(f=U(),f!==null){for(d=[],s=pe(),s===null&&(s=Ce());s!==null;)d.push(s),s=pe(),s===null&&(s=Ce());d!==null?(s=U(),s!==null?r=[r,f,d,s]:(r=null,t=h)):(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r!==null&&(r=function(g){var S=e.substring(t,g).trim();return S.substring(1,S.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(c)),r===null&&(t=c),r}function pe(){var r;return r=B(),r===null&&(e.charCodeAt(t)===33?(r="!",t++):(r=null,l('"!"')),r===null&&(/^[#-[]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[#-[]")),r===null&&(/^[\]-~]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\]-~]")),r===null&&(r=M())))),r}function Ce(){var r,f,d;return d=t,e.charCodeAt(t)===92?(r="\\",t++):(r=null,l('"\\\\"')),r!==null?(/^[\0-\t]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[\\0-\\t]")),f===null&&(/^[\x0B-\f]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[\\x0B-\\f]")),f===null&&(/^[\x0E-]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[\\x0E-]")))),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function ke(){var r,f,d,s,c,h;return c=t,h=t,r=Be(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=ft(),d=d!==null?d:"",d!==null?(s=ys(),s!==null?r=[r,f,d,s]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r!==null&&(r=function(g){try{i.uri=new yr(i.scheme,i.user,i.host,i.port),delete i.scheme,delete i.user,delete i.host,delete i.host_type,delete i.port}catch{i=-1}}()),r===null&&(t=c),r}function He(){var r,f,d,s,c,h,g,S;return g=t,S=t,r=Be(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=ft(),d=d!==null?d:"",d!==null?(s=ys(),s!==null?(c=Rs(),c!==null?(h=el(),h=h!==null?h:"",h!==null?r=[r,f,d,s,c,h]:(r=null,t=S)):(r=null,t=S)):(r=null,t=S)):(r=null,t=S)):(r=null,t=S)):(r=null,t=S),r!==null&&(r=function(R){try{i.uri=new yr(i.scheme,i.user,i.host,i.port,i.uri_params,i.uri_headers),delete i.scheme,delete i.user,delete i.host,delete i.host_type,delete i.port,delete i.uri_params,o==="SIP_URI"&&(i=i.uri)}catch{i=-1}}()),r===null&&(t=g),r}function Be(){var r;return r=Ve(),r===null&&(r=Mt()),r}function Ve(){var r,f;return f=t,e.substr(t,4).toLowerCase()==="sips"?(r=e.substr(t,4),t+=4):(r=null,l('"sips"')),r!==null&&(r=function(d,s){i.scheme=s.toLowerCase()}(f,r)),r===null&&(t=f),r}function Mt(){var r,f;return f=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"sip"')),r!==null&&(r=function(d,s){i.scheme=s.toLowerCase()}(f,r)),r===null&&(t=f),r}function ft(){var r,f,d,s,c,h;return s=t,c=t,r=Gs(),r!==null?(h=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=As(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?(e.charCodeAt(t)===64?(d="@",t++):(d=null,l('"@"')),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i.user=decodeURIComponent(e.substring(t-1,g))}(s)),r===null&&(t=s),r}function Gs(){var r,f;if(f=H(),f===null&&(f=Ue(),f===null&&(f=is())),f!==null)for(r=[];f!==null;)r.push(f),f=H(),f===null&&(f=Ue(),f===null&&(f=is()));else r=null;return r}function is(){var r;return e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')),r===null&&(e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"'))))))))),r}function As(){var r,f,d;for(d=t,r=[],f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","'))))))));f!==null;)r.push(f),f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","'))))))));return r!==null&&(r=function(s){i.password=e.substring(t,s)}(d)),r===null&&(t=d),r}function ys(){var r,f,d,s,c;return s=t,r=as(),r!==null?(c=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Tt(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function as(){var r,f;return f=t,r=Ws(),r===null&&(r=us(),r===null&&(r=ht())),r!==null&&(r=function(d){return i.host=e.substring(t,d).toLowerCase(),i.host}(f)),r===null&&(t=f),r}function Ws(){var r,f,d,s,c,h;for(s=t,c=t,r=[],h=t,f=os(),f!==null?(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h);f!==null;)r.push(f),h=t,f=os(),f!==null?(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h);return r!==null?(f=Se(),f!==null?(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d=d!==null?d:"",d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){return i.host_type="domain",e.substring(t,g)}(s)),r===null&&(t=s),r}function os(){var r,f,d,s;if(s=t,r=_e(),r!==null){for(f=[],d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));d!==null;)f.push(d),d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));f!==null?r=[r,f]:(r=null,t=s)}else r=null,t=s;return r}function Se(){var r,f,d,s;if(s=t,r=E(),r!==null){for(f=[],d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));d!==null;)f.push(d),d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));f!==null?r=[r,f]:(r=null,t=s)}else r=null,t=s;return r}function ht(){var r,f,d,s,c;return s=t,c=t,e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r!==null?(f=Xt(),f!==null?(e.charCodeAt(t)===93?(d="]",t++):(d=null,l('"]"')),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return i.host_type="IPv6",e.substring(t,h)}(s)),r===null&&(t=s),r}function Xt(){var r,f,d,s,c,h,g,S,R,I,D,J,Ne,We,F,Ie;return We=t,F=t,r=Ae(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?(e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?(e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?(e.charCodeAt(t)===58?(S=":",t++):(S=null,l('":"')),S!==null?(R=Ae(),R!==null?(e.charCodeAt(t)===58?(I=":",t++):(I=null,l('":"')),I!==null?(D=Ae(),D!==null?(e.charCodeAt(t)===58?(J=":",t++):(J=null,l('":"')),J!==null?(Ne=pt(),Ne!==null?r=[r,f,d,s,c,h,g,S,R,I,D,J,Ne]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?(e.charCodeAt(t)===58?(R=":",t++):(R=null,l('":"')),R!==null?(I=Ae(),I!==null?(e.charCodeAt(t)===58?(D=":",t++):(D=null,l('":"')),D!==null?(J=pt(),J!==null?r=[r,f,d,s,c,h,g,S,R,I,D,J]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?(e.charCodeAt(t)===58?(R=":",t++):(R=null,l('":"')),R!==null?(I=pt(),I!==null?r=[r,f,d,s,c,h,g,S,R,I]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=pt(),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=pt(),h!==null?r=[r,f,d,s,c,h]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=pt(),s!==null?r=[r,f,d,s]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=pt(),f!==null?r=[r,f]:(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?r=[r,f]:(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(e.substr(t,2)==="::"?(f="::",t+=2):(f=null,l('"::"')),f!==null?(d=Ae(),d!==null?(e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?(e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?(e.charCodeAt(t)===58?(S=":",t++):(S=null,l('":"')),S!==null?(R=Ae(),R!==null?(e.charCodeAt(t)===58?(I=":",t++):(I=null,l('":"')),I!==null?(D=pt(),D!==null?r=[r,f,d,s,c,h,g,S,R,I,D]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(e.substr(t,2)==="::"?(d="::",t+=2):(d=null,l('"::"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?(e.charCodeAt(t)===58?(R=":",t++):(R=null,l('":"')),R!==null?(I=pt(),I!==null?r=[r,f,d,s,c,h,g,S,R,I]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(e.substr(t,2)==="::"?(s="::",t+=2):(s=null,l('"::"')),s!==null?(c=Ae(),c!==null?(e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?(e.charCodeAt(t)===58?(S=":",t++):(S=null,l('":"')),S!==null?(R=pt(),R!==null?r=[r,f,d,s,c,h,g,S,R]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(e.substr(t,2)==="::"?(c="::",t+=2):(c=null,l('"::"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=pt(),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(Ie=t,e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?c=[c,h]:(c=null,t=Ie)):(c=null,t=Ie),c=c!==null?c:"",c!==null?(e.substr(t,2)==="::"?(h="::",t+=2):(h=null,l('"::"')),h!==null?(g=pt(),g!==null?r=[r,f,d,s,c,h,g]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(Ie=t,e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?c=[c,h]:(c=null,t=Ie)):(c=null,t=Ie),c=c!==null?c:"",c!==null?(Ie=t,e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?h=[h,g]:(h=null,t=Ie)):(h=null,t=Ie),h=h!==null?h:"",h!==null?(e.substr(t,2)==="::"?(g="::",t+=2):(g=null,l('"::"')),g!==null?(S=Ae(),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(Ie=t,e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?c=[c,h]:(c=null,t=Ie)):(c=null,t=Ie),c=c!==null?c:"",c!==null?(Ie=t,e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?h=[h,g]:(h=null,t=Ie)):(h=null,t=Ie),h=h!==null?h:"",h!==null?(Ie=t,e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?g=[g,S]:(g=null,t=Ie)):(g=null,t=Ie),g=g!==null?g:"",g!==null?(e.substr(t,2)==="::"?(S="::",t+=2):(S=null,l('"::"')),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F))))))))))))))),r!==null&&(r=function(pi){return i.host_type="IPv6",e.substring(t,pi)}(We)),r===null&&(t=We),r}function Ae(){var r,f,d,s,c;return c=t,r=O(),r!==null?(f=O(),f=f!==null?f:"",f!==null?(d=O(),d=d!==null?d:"",d!==null?(s=O(),s=s!==null?s:"",s!==null?r=[r,f,d,s]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r}function pt(){var r,f,d,s;return s=t,r=Ae(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r===null&&(r=us()),r}function us(){var r,f,d,s,c,h,g,S,R;return S=t,R=t,r=me(),r!==null?(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f!==null?(d=me(),d!==null?(e.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null?(c=me(),c!==null?(e.charCodeAt(t)===46?(h=".",t++):(h=null,l('"."')),h!==null?(g=me(),g!==null?r=[r,f,d,s,c,h,g]:(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R),r!==null&&(r=function(I){return i.host_type="IPv4",e.substring(t,I)}(S)),r===null&&(t=S),r}function me(){var r,f,d,s;return s=t,e.substr(t,2)==="25"?(r="25",t+=2):(r=null,l('"25"')),r!==null?(/^[0-5]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[0-5]")),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r===null&&(s=t,e.charCodeAt(t)===50?(r="2",t++):(r=null,l('"2"')),r!==null?(/^[0-4]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[0-4]")),f!==null?(d=b(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r===null&&(s=t,e.charCodeAt(t)===49?(r="1",t++):(r=null,l('"1"')),r!==null?(f=b(),f!==null?(d=b(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r===null&&(s=t,/^[1-9]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[1-9]")),r!==null?(f=b(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r===null&&(r=b())))),r}function Tt(){var r,f,d,s,c,h,g;return h=t,g=t,r=b(),r=r!==null?r:"",r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?r=[r,f,d,s,c]:(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(S,R){return R=parseInt(R.join("")),i.port=R,R}(h,r)),r===null&&(t=h),r}function Rs(){var r,f,d,s;for(r=[],s=t,e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f!==null?(d=cs(),d!==null?f=[f,d]:(f=null,t=s)):(f=null,t=s);f!==null;)r.push(f),s=t,e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f!==null?(d=cs(),d!==null?f=[f,d]:(f=null,t=s)):(f=null,t=s);return r}function cs(){var r;return r=Wn(),r===null&&(r=Kn(),r===null&&(r=pn(),r===null&&(r=Yn(),r===null&&(r=zn(),r===null&&(r=Jn(),r===null&&(r=bs())))))),r}function Wn(){var r,f,d,s;return d=t,s=t,e.substr(t,10).toLowerCase()==="transport="?(r=e.substr(t,10),t+=10):(r=null,l('"transport="')),r!==null?(e.substr(t,3).toLowerCase()==="udp"?(f=e.substr(t,3),t+=3):(f=null,l('"udp"')),f===null&&(e.substr(t,3).toLowerCase()==="tcp"?(f=e.substr(t,3),t+=3):(f=null,l('"tcp"')),f===null&&(e.substr(t,4).toLowerCase()==="sctp"?(f=e.substr(t,4),t+=4):(f=null,l('"sctp"')),f===null&&(e.substr(t,3).toLowerCase()==="tls"?(f=e.substr(t,3),t+=3):(f=null,l('"tls"')),f===null&&(f=$())))),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.transport=h.toLowerCase()}(d,r[1])),r===null&&(t=d),r}function Kn(){var r,f,d,s;return d=t,s=t,e.substr(t,5).toLowerCase()==="user="?(r=e.substr(t,5),t+=5):(r=null,l('"user="')),r!==null?(e.substr(t,5).toLowerCase()==="phone"?(f=e.substr(t,5),t+=5):(f=null,l('"phone"')),f===null&&(e.substr(t,2).toLowerCase()==="ip"?(f=e.substr(t,2),t+=2):(f=null,l('"ip"')),f===null&&(f=$())),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.user=h.toLowerCase()}(d,r[1])),r===null&&(t=d),r}function pn(){var r,f,d,s;return d=t,s=t,e.substr(t,7).toLowerCase()==="method="?(r=e.substr(t,7),t+=7):(r=null,l('"method="')),r!==null?(f=Js(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.method=h}(d,r[1])),r===null&&(t=d),r}function Yn(){var r,f,d,s;return d=t,s=t,e.substr(t,4).toLowerCase()==="ttl="?(r=e.substr(t,4),t+=4):(r=null,l('"ttl="')),r!==null?(f=Un(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.params||(i.params={}),i.params.ttl=h}(d,r[1])),r===null&&(t=d),r}function zn(){var r,f,d,s;return d=t,s=t,e.substr(t,6).toLowerCase()==="maddr="?(r=e.substr(t,6),t+=6):(r=null,l('"maddr="')),r!==null?(f=as(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.maddr=h}(d,r[1])),r===null&&(t=d),r}function Jn(){var r,f,d,s,c,h;return s=t,c=t,e.substr(t,2).toLowerCase()==="lr"?(r=e.substr(t,2),t+=2):(r=null,l('"lr"')),r!==null?(h=t,e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=$(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i.uri_params||(i.uri_params={}),i.uri_params.lr=void 0}()),r===null&&(t=s),r}function bs(){var r,f,d,s,c,h;return s=t,c=t,r=Xn(),r!==null?(h=t,e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=Qn(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g,S,R){i.uri_params||(i.uri_params={}),typeof R>"u"?R=void 0:R=R[1],i.uri_params[S.toLowerCase()]=R}(s,r[0],r[1])),r===null&&(t=s),r}function Xn(){var r,f,d;if(d=t,f=Qt(),f!==null)for(r=[];f!==null;)r.push(f),f=Qt();else r=null;return r!==null&&(r=function(s,c){return c.join("")}(d,r)),r===null&&(t=d),r}function Qn(){var r,f,d;if(d=t,f=Qt(),f!==null)for(r=[];f!==null;)r.push(f),f=Qt();else r=null;return r!==null&&(r=function(s,c){return c.join("")}(d,r)),r===null&&(t=d),r}function Qt(){var r;return r=Zn(),r===null&&(r=H(),r===null&&(r=Ue())),r}function Zn(){var r;return e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r===null&&(e.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')))))))),r}function el(){var r,f,d,s,c,h,g;if(h=t,e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r!==null)if(f=kt(),f!==null){for(d=[],g=t,e.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s!==null?(c=kt(),c!==null?s=[s,c]:(s=null,t=g)):(s=null,t=g);s!==null;)d.push(s),g=t,e.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s!==null?(c=kt(),c!==null?s=[s,c]:(s=null,t=g)):(s=null,t=g);d!==null?r=[r,f,d]:(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r}function kt(){var r,f,d,s,c;return s=t,c=t,r=er(),r!==null?(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=tl(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g,S){g=g.join("").toLowerCase(),S=S.join(""),i.uri_headers||(i.uri_headers={}),i.uri_headers[g]?i.uri_headers[g].push(S):i.uri_headers[g]=[S]}(s,r[0],r[2])),r===null&&(t=s),r}function er(){var r,f;if(f=Zt(),f===null&&(f=H(),f===null&&(f=Ue())),f!==null)for(r=[];f!==null;)r.push(f),f=Zt(),f===null&&(f=H(),f===null&&(f=Ue()));else r=null;return r}function tl(){var r,f;for(r=[],f=Zt(),f===null&&(f=H(),f===null&&(f=Ue()));f!==null;)r.push(f),f=Zt(),f===null&&(f=H(),f===null&&(f=Ue()));return r}function Zt(){var r;return e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r===null&&(e.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')))))))),r}function sl(){var r;return r=pl(),r===null&&(r=nl()),r}function nl(){var r,f,d,s,c,h;return h=t,r=Js(),r!==null?(f=Y(),f!==null?(d=Is(),d!==null?(s=Y(),s!==null?(c=vn(),c!==null?r=[r,f,d,s,c]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r}function Is(){var r;return r=He(),r===null&&(r=Ks()),r}function Ks(){var r,f,d,s;return s=t,r=Ys(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=ll(),d===null&&(d=rl()),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function ll(){var r,f,d,s,c;return s=t,r=ws(),r===null&&(r=Os()),r!==null?(c=t,e.charCodeAt(t)===63?(f="?",t++):(f=null,l('"?"')),f!==null?(d=al(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function ws(){var r,f,d,s;return s=t,e.substr(t,2)==="//"?(r="//",t+=2):(r=null,l('"//"')),r!==null?(f=gn(),f!==null?(d=Os(),d=d!==null?d:"",d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Os(){var r,f,d;return d=t,e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r!==null?(f=Ns(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function rl(){var r,f,d,s;if(s=t,r=Ds(),r!==null){for(f=[],d=es();d!==null;)f.push(d),d=es();f!==null?r=[r,f]:(r=null,t=s)}else r=null,t=s;return r}function es(){var r;return r=k(),r===null&&(r=H(),r===null&&(r=Ue())),r}function Ds(){var r;return r=H(),r===null&&(r=Ue(),r===null&&(e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')))))))))))),r}function Ns(){var r,f,d,s,c,h;if(c=t,r=ts(),r!==null){for(f=[],h=t,e.charCodeAt(t)===47?(d="/",t++):(d=null,l('"/"')),d!==null?(s=ts(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,e.charCodeAt(t)===47?(d="/",t++):(d=null,l('"/"')),d!==null?(s=ts(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function ts(){var r,f,d,s,c,h;for(c=t,r=[],f=Us();f!==null;)r.push(f),f=Us();if(r!==null){for(f=[],h=t,e.charCodeAt(t)===59?(d=";",t++):(d=null,l('";"')),d!==null?(s=mn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,e.charCodeAt(t)===59?(d=";",t++):(d=null,l('";"')),d!==null?(s=mn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function mn(){var r,f;for(r=[],f=Us();f!==null;)r.push(f),f=Us();return r}function Us(){var r;return r=H(),r===null&&(r=Ue(),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')))))))))),r}function Ys(){var r,f,d,s,c;if(s=t,c=t,r=E(),r!==null){for(f=[],d=E(),d===null&&(d=b(),d===null&&(e.charCodeAt(t)===43?(d="+",t++):(d=null,l('"+"')),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."'))))));d!==null;)f.push(d),d=E(),d===null&&(d=b(),d===null&&(e.charCodeAt(t)===43?(d="+",t++):(d=null,l('"+"')),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."'))))));f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r!==null&&(r=function(h){i.scheme=e.substring(t,h)}(s)),r===null&&(t=s),r}function gn(){var r;return r=fs(),r===null&&(r=il()),r}function fs(){var r,f,d,s;return d=t,s=t,r=ft(),r!==null?(e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r=r!==null?r:"",r!==null?(f=ys(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r=r!==null?r:"",r}function il(){var r,f;if(f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","')),f===null&&(e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"'))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","')),f===null&&(e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')))))))))));else r=null;return r}function al(){var r,f;for(r=[],f=es();f!==null;)r.push(f),f=es();return r}function vn(){var r,f,d,s,c,h,g,S;if(g=t,S=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"SIP"')),r!==null)if(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f!==null){if(s=b(),s!==null)for(d=[];s!==null;)d.push(s),s=b();else d=null;if(d!==null)if(e.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null){if(h=b(),h!==null)for(c=[];h!==null;)c.push(h),h=b();else c=null;c!==null?r=[r,f,d,s,c]:(r=null,t=S)}else r=null,t=S;else r=null,t=S}else r=null,t=S;else r=null,t=S;return r!==null&&(r=function(R){i.sip_version=e.substring(t,R)}(g)),r===null&&(t=g),r}function ol(){var r;return e.substr(t,6)==="INVITE"?(r="INVITE",t+=6):(r=null,l('"INVITE"')),r}function ul(){var r;return e.substr(t,3)==="ACK"?(r="ACK",t+=3):(r=null,l('"ACK"')),r}function Tn(){var r;return e.substr(t,7)==="OPTIONS"?(r="OPTIONS",t+=7):(r=null,l('"OPTIONS"')),r}function cl(){var r;return e.substr(t,3)==="BYE"?(r="BYE",t+=3):(r=null,l('"BYE"')),r}function fl(){var r;return e.substr(t,6)==="CANCEL"?(r="CANCEL",t+=6):(r=null,l('"CANCEL"')),r}function hl(){var r;return e.substr(t,8)==="REGISTER"?(r="REGISTER",t+=8):(r=null,l('"REGISTER"')),r}function zs(){var r;return e.substr(t,9)==="SUBSCRIBE"?(r="SUBSCRIBE",t+=9):(r=null,l('"SUBSCRIBE"')),r}function _l(){var r;return e.substr(t,6)==="NOTIFY"?(r="NOTIFY",t+=6):(r=null,l('"NOTIFY"')),r}function dl(){var r;return e.substr(t,5)==="REFER"?(r="REFER",t+=5):(r=null,l('"REFER"')),r}function Js(){var r,f;return f=t,r=ol(),r===null&&(r=ul(),r===null&&(r=Tn(),r===null&&(r=cl(),r===null&&(r=fl(),r===null&&(r=hl(),r===null&&(r=zs(),r===null&&(r=_l(),r===null&&(r=dl(),r===null&&(r=$()))))))))),r!==null&&(r=function(d){return i.method=e.substring(t,d),i.method}(f)),r===null&&(t=f),r}function pl(){var r,f,d,s,c,h;return h=t,r=vn(),r!==null?(f=Y(),f!==null?(d=tr(),d!==null?(s=Y(),s!==null?(c=sr(),c!==null?r=[r,f,d,s,c]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r}function tr(){var r,f;return f=t,r=En(),r!==null&&(r=function(d,s){i.status_code=parseInt(s.join(""))}(f,r)),r===null&&(t=f),r}function En(){var r,f,d,s;return s=t,r=b(),r!==null?(f=b(),f!==null?(d=b(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function sr(){var r,f,d;for(d=t,r=[],f=k(),f===null&&(f=H(),f===null&&(f=Ue(),f===null&&(f=M(),f===null&&(f=te(),f===null&&(f=Y(),f===null&&(f=j()))))));f!==null;)r.push(f),f=k(),f===null&&(f=H(),f===null&&(f=Ue(),f===null&&(f=M(),f===null&&(f=te(),f===null&&(f=Y(),f===null&&(f=j()))))));return r!==null&&(r=function(s){i.reason_phrase=e.substring(t,s)}(d)),r===null&&(t=d),r}function Cn(){var r,f,d,s,c,h;if(c=t,r=ps(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=ps(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=ps(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function hs(){var r,f,d,s,c,h;return s=t,c=t,r=P(),r!==null?(h=t,e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f!==null?(d=P(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i=e.substring(t,g)}(s)),r===null&&(t=s),r}function Sn(){var r,f,d,s,c,h,g;if(c=t,r=Q(),r===null)if(h=t,r=Xs(),r!==null){for(f=[],g=t,d=xe(),d!==null?(s=Xs(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=xe(),d!==null?(s=Xs(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R,I;for(I=i.multi_header.length,R=0;R<I;R++)if(i.multi_header[R].parsed===null){i=null;break}i!==null?i=i.multi_header:i=-1}()),r===null&&(t=c),r}function Xs(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=_s()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Lt(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Lt(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R;i.multi_header||(i.multi_header=[]);try{R=new Hs(i.uri,i.display_name,i.params),delete i.uri,delete i.display_name,delete i.params}catch{R=null}i.multi_header.push({possition:t,offset:S,parsed:R})}(c)),r===null&&(t=c),r}function _s(){var r,f,d,s,c;return c=t,r=An(),r=r!==null?r:"",r!==null?(f=qe(),f!==null?(d=He(),d!==null?(s=fe(),s!==null?r=[r,f,d,s]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r}function An(){var r,f,d,s,c,h,g;if(c=t,h=t,r=$(),r!==null){for(f=[],g=t,d=B(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=B(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r===null&&(r=ye()),r!==null&&(r=function(S,R){typeof R=="string"?i.display_name=R:i.display_name=R[1].reduce(function(I,D){return I+D[0]+D[1]},R[0])}(c,r)),r===null&&(t=c),r}function Lt(){var r;return r=ss(),r===null&&(r=Ke(),r===null&&(r=Je())),r}function ss(){var r,f,d,s,c;return s=t,c=t,e.substr(t,1).toLowerCase()==="q"?(r=e.substr(t,1),t++):(r=null,l('"q"')),r!==null?(f=he(),f!==null?(d=nr(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.params||(i.params={}),i.params.q=g}(s,r[2])),r===null&&(t=s),r}function Ke(){var r,f,d,s,c;return s=t,c=t,e.substr(t,7).toLowerCase()==="expires"?(r=e.substr(t,7),t+=7):(r=null,l('"expires"')),r!==null?(f=he(),f!==null?(d=Gt(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.params||(i.params={}),i.params.expires=g}(s,r[2])),r===null&&(t=s),r}function Gt(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){return parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function nr(){var r,f,d,s,c,h,g,S;return h=t,g=t,e.charCodeAt(t)===48?(r="0",t++):(r=null,l('"0"')),r!==null?(S=t,e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?f=[f,d,s,c]:(f=null,t=S)):(f=null,t=S)):(f=null,t=S)):(f=null,t=S),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(R){return parseFloat(e.substring(t,R))}(h)),r===null&&(t=h),r}function Je(){var r,f,d,s,c,h;return s=t,c=t,r=$(),r!==null?(h=t,f=he(),f!==null?(d=Wt(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g,S,R){i.params||(i.params={}),typeof R>"u"?R=void 0:R=R[1],i.params[S.toLowerCase()]=R}(s,r[0],r[1])),r===null&&(t=s),r}function Wt(){var r;return r=$(),r===null&&(r=as(),r===null&&(r=Le())),r}function lr(){var r,f,d,s,c,h;if(c=t,r=Ze(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=ml(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=ml(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Ze(){var r;return e.substr(t,6).toLowerCase()==="render"?(r=e.substr(t,6),t+=6):(r=null,l('"render"')),r===null&&(e.substr(t,7).toLowerCase()==="session"?(r=e.substr(t,7),t+=7):(r=null,l('"session"')),r===null&&(e.substr(t,4).toLowerCase()==="icon"?(r=e.substr(t,4),t+=4):(r=null,l('"icon"')),r===null&&(e.substr(t,5).toLowerCase()==="alert"?(r=e.substr(t,5),t+=5):(r=null,l('"alert"')),r===null&&(r=$())))),r}function ml(){var r;return r=$r(),r===null&&(r=Je()),r}function $r(){var r,f,d,s;return s=t,e.substr(t,8).toLowerCase()==="handling"?(r=e.substr(t,8),t+=8):(r=null,l('"handling"')),r!==null?(f=he(),f!==null?(e.substr(t,8).toLowerCase()==="optional"?(d=e.substr(t,8),t+=8):(d=null,l('"optional"')),d===null&&(e.substr(t,8).toLowerCase()==="required"?(d=e.substr(t,8),t+=8):(d=null,l('"required"')),d===null&&(d=$())),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function rr(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function gl(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){i=parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function ir(){var r,f;return f=t,r=ar(),r!==null&&(r=function(d){i=e.substring(t,d)}(f)),r===null&&(t=f),r}function ar(){var r,f,d,s,c,h,g,S;if(g=t,r=yn(),r!==null)if(f=oe(),f!==null)if(d=ur(),d!==null){for(s=[],S=t,c=we(),c!==null?(h=Ps(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=we(),c!==null?(h=Ps(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r}function yn(){var r;return r=or(),r===null&&(r=vl()),r}function or(){var r;return e.substr(t,4).toLowerCase()==="text"?(r=e.substr(t,4),t+=4):(r=null,l('"text"')),r===null&&(e.substr(t,5).toLowerCase()==="image"?(r=e.substr(t,5),t+=5):(r=null,l('"image"')),r===null&&(e.substr(t,5).toLowerCase()==="audio"?(r=e.substr(t,5),t+=5):(r=null,l('"audio"')),r===null&&(e.substr(t,5).toLowerCase()==="video"?(r=e.substr(t,5),t+=5):(r=null,l('"video"')),r===null&&(e.substr(t,11).toLowerCase()==="application"?(r=e.substr(t,11),t+=11):(r=null,l('"application"')),r===null&&(r=xs()))))),r}function vl(){var r;return e.substr(t,7).toLowerCase()==="message"?(r=e.substr(t,7),t+=7):(r=null,l('"message"')),r===null&&(e.substr(t,9).toLowerCase()==="multipart"?(r=e.substr(t,9),t+=9):(r=null,l('"multipart"')),r===null&&(r=xs())),r}function xs(){var r;return r=$(),r===null&&(r=Tl()),r}function Tl(){var r,f,d;return d=t,e.substr(t,2).toLowerCase()==="x-"?(r=e.substr(t,2),t+=2):(r=null,l('"x-"')),r!==null?(f=$(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function ur(){var r;return r=xs(),r===null&&(r=$()),r}function Ps(){var r,f,d,s;return s=t,r=$(),r!==null?(f=he(),f!==null?(d=cr(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function cr(){var r;return r=$(),r===null&&(r=Le()),r}function Hr(){var r,f,d,s;return s=t,r=ds(),r!==null?(f=B(),f!==null?(d=Js(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function ds(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){i.value=parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function Fr(){var r,f;return f=t,r=Gt(),r!==null&&(r=function(d,s){i=s}(f,r)),r===null&&(t=f),r}function fr(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ps(),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S,R){i.event=R.join("").toLowerCase()}(c,r[0])),r===null&&(t=c),r}function ps(){var r,f,d,s,c,h;if(c=t,r=ne(),r!==null){for(f=[],h=t,e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?(s=ne(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?(s=ne(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function fi(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=_s()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=hr(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=hr(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R=i.tag;try{i=new Hs(i.uri,i.display_name,i.params),R&&i.setParam("tag",R)}catch{i=-1}}()),r===null&&(t=c),r}function hr(){var r;return r=Ms(),r===null&&(r=Je()),r}function Ms(){var r,f,d,s,c;return s=t,c=t,e.substr(t,3).toLowerCase()==="tag"?(r=e.substr(t,3),t+=3):(r=null,l('"tag"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.tag=g}(s,r[2])),r===null&&(t=s),r}function hi(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){i=parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function Rn(){var r,f;return f=t,r=Gt(),r!==null&&(r=function(d,s){i=s}(f,r)),r===null&&(t=f),r}function El(){var r,f,d,s,c,h,g,S,R,I;for(S=t,R=t,r=[],f=An();f!==null;)r.push(f),f=An();if(r!==null)if(f=qe(),f!==null)if(d=He(),d!==null)if(s=fe(),s!==null){for(c=[],I=t,h=we(),h!==null?(g=Je(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);h!==null;)c.push(h),I=t,h=we(),h!==null?(g=Je(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);c!==null?r=[r,f,d,s,c]:(r=null,t=R)}else r=null,t=R;else r=null,t=R;else r=null,t=R;else r=null,t=R;return r!==null&&(r=function(D){try{i=new Hs(i.uri,i.display_name,i.params)}catch{i=-1}}()),r===null&&(t=S),r}function bn(){var r;return r=Qs(),r}function Qs(){var r,f,d,s,c,h,g,S;if(g=t,e.substr(t,6).toLowerCase()==="digest"?(r=e.substr(t,6),t+=6):(r=null,l('"Digest"')),r!==null)if(f=B(),f!==null)if(d=ks(),d!==null){for(s=[],S=t,c=xe(),c!==null?(h=ks(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=xe(),c!==null?(h=ks(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r===null&&(r=_r()),r}function _r(){var r,f,d,s,c,h,g,S;if(g=t,r=$(),r!==null)if(f=B(),f!==null)if(d=Zs(),d!==null){for(s=[],S=t,c=xe(),c!==null?(h=Zs(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=xe(),c!==null?(h=Zs(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r}function Zs(){var r,f,d,s;return s=t,r=$(),r!==null?(f=he(),f!==null?(d=$(),d===null&&(d=Le()),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function ks(){var r;return r=en(),r===null&&(r=tn(),r===null&&(r=Cl(),r===null&&(r=nn(),r===null&&(r=ln(),r===null&&(r=dr(),r===null&&(r=pr(),r===null&&(r=Zs()))))))),r}function en(){var r,f,d,s;return s=t,e.substr(t,5).toLowerCase()==="realm"?(r=e.substr(t,5),t+=5):(r=null,l('"realm"')),r!==null?(f=he(),f!==null?(d=Ls(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Ls(){var r,f;return f=t,r=ye(),r!==null&&(r=function(d,s){i.realm=s}(f,r)),r===null&&(t=f),r}function tn(){var r,f,d,s,c,h,g,S,R;if(S=t,e.substr(t,6).toLowerCase()==="domain"?(r=e.substr(t,6),t+=6):(r=null,l('"domain"')),r!==null)if(f=he(),f!==null)if(d=$e(),d!==null)if(s=sn(),s!==null){if(c=[],R=t,g=Y(),g!==null)for(h=[];g!==null;)h.push(g),g=Y();else h=null;for(h!==null?(g=sn(),g!==null?h=[h,g]:(h=null,t=R)):(h=null,t=R);h!==null;){if(c.push(h),R=t,g=Y(),g!==null)for(h=[];g!==null;)h.push(g),g=Y();else h=null;h!==null?(g=sn(),g!==null?h=[h,g]:(h=null,t=R)):(h=null,t=R)}c!==null?(h=ue(),h!==null?r=[r,f,d,s,c,h]:(r=null,t=S)):(r=null,t=S)}else r=null,t=S;else r=null,t=S;else r=null,t=S;else r=null,t=S;return r}function sn(){var r;return r=Ks(),r===null&&(r=Os()),r}function Cl(){var r,f,d,s;return s=t,e.substr(t,5).toLowerCase()==="nonce"?(r=e.substr(t,5),t+=5):(r=null,l('"nonce"')),r!==null?(f=he(),f!==null?(d=Sl(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Sl(){var r,f;return f=t,r=ye(),r!==null&&(r=function(d,s){i.nonce=s}(f,r)),r===null&&(t=f),r}function nn(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6).toLowerCase()==="opaque"?(r=e.substr(t,6),t+=6):(r=null,l('"opaque"')),r!==null?(f=he(),f!==null?(d=ye(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.opaque=g}(s,r[2])),r===null&&(t=s),r}function ln(){var r,f,d,s,c;return s=t,e.substr(t,5).toLowerCase()==="stale"?(r=e.substr(t,5),t+=5):(r=null,l('"stale"')),r!==null?(f=he(),f!==null?(c=t,e.substr(t,4).toLowerCase()==="true"?(d=e.substr(t,4),t+=4):(d=null,l('"true"')),d!==null&&(d=function(h){i.stale=!0}()),d===null&&(t=c),d===null&&(c=t,e.substr(t,5).toLowerCase()==="false"?(d=e.substr(t,5),t+=5):(d=null,l('"false"')),d!==null&&(d=function(h){i.stale=!1}()),d===null&&(t=c)),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function dr(){var r,f,d,s,c;return s=t,c=t,e.substr(t,9).toLowerCase()==="algorithm"?(r=e.substr(t,9),t+=9):(r=null,l('"algorithm"')),r!==null?(f=he(),f!==null?(e.substr(t,3).toLowerCase()==="md5"?(d=e.substr(t,3),t+=3):(d=null,l('"MD5"')),d===null&&(e.substr(t,8).toLowerCase()==="md5-sess"?(d=e.substr(t,8),t+=8):(d=null,l('"MD5-sess"')),d===null&&(d=$())),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.algorithm=g.toUpperCase()}(s,r[2])),r===null&&(t=s),r}function pr(){var r,f,d,s,c,h,g,S,R,I;if(S=t,e.substr(t,3).toLowerCase()==="qop"?(r=e.substr(t,3),t+=3):(r=null,l('"qop"')),r!==null)if(f=he(),f!==null)if(d=$e(),d!==null){if(R=t,s=ms(),s!==null){for(c=[],I=t,e.charCodeAt(t)===44?(h=",",t++):(h=null,l('","')),h!==null?(g=ms(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);h!==null;)c.push(h),I=t,e.charCodeAt(t)===44?(h=",",t++):(h=null,l('","')),h!==null?(g=ms(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);c!==null?s=[s,c]:(s=null,t=R)}else s=null,t=R;s!==null?(c=ue(),c!==null?r=[r,f,d,s,c]:(r=null,t=S)):(r=null,t=S)}else r=null,t=S;else r=null,t=S;else r=null,t=S;return r}function ms(){var r,f;return f=t,e.substr(t,8).toLowerCase()==="auth-int"?(r=e.substr(t,8),t+=8):(r=null,l('"auth-int"')),r===null&&(e.substr(t,4).toLowerCase()==="auth"?(r=e.substr(t,4),t+=4):(r=null,l('"auth"')),r===null&&(r=$())),r!==null&&(r=function(d,s){i.qop||(i.qop=[]),i.qop.push(s.toLowerCase())}(f,r)),r===null&&(t=f),r}function qr(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Al(){var r,f,d,s,c,h,g;if(c=t,h=t,r=gs(),r!==null){for(f=[],g=t,d=xe(),d!==null?(s=gs(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=xe(),d!==null?(s=gs(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R,I;for(I=i.multi_header.length,R=0;R<I;R++)if(i.multi_header[R].parsed===null){i=null;break}i!==null?i=i.multi_header:i=-1}()),r===null&&(t=c),r}function gs(){var r,f,d,s,c,h,g;if(c=t,h=t,r=_s(),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R;i.multi_header||(i.multi_header=[]);try{R=new Hs(i.uri,i.display_name,i.params),delete i.uri,delete i.display_name,delete i.params}catch{R=null}i.multi_header.push({possition:t,offset:S,parsed:R})}(c)),r===null&&(t=c),r}function _i(){var r,f,d,s,c,h,g;if(c=t,h=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"SIP"')),r===null&&(r=$()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=mr(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=mr(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S,R){if(i.protocol=R.toLowerCase(),i.params||(i.params={}),i.params.text&&i.params.text[0]==='"'){var I=i.params.text;i.text=I.substring(1,I.length-1),delete i.params.text}}(c,r[0])),r===null&&(t=c),r}function mr(){var r;return r=vs(),r===null&&(r=Je()),r}function vs(){var r,f,d,s,c,h;if(c=t,h=t,e.substr(t,5).toLowerCase()==="cause"?(r=e.substr(t,5),t+=5):(r=null,l('"cause"')),r!==null)if(f=he(),f!==null){if(s=b(),s!==null)for(d=[];s!==null;)d.push(s),s=b();else d=null;d!==null?r=[r,f,d]:(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r!==null&&(r=function(g,S){i.cause=parseInt(S.join(""))}(c,r[2])),r===null&&(t=c),r}function di(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function yl(){var r,f,d,s,c,h;if(c=t,r=$s(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$s(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$s(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function $s(){var r,f,d,s,c,h;if(c=t,r=_s(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function jr(){var r,f,d,s,c,h;if(c=t,r=Vr(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=rn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=rn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Vr(){var r,f;return f=t,e.substr(t,6).toLowerCase()==="active"?(r=e.substr(t,6),t+=6):(r=null,l('"active"')),r===null&&(e.substr(t,7).toLowerCase()==="pending"?(r=e.substr(t,7),t+=7):(r=null,l('"pending"')),r===null&&(e.substr(t,10).toLowerCase()==="terminated"?(r=e.substr(t,10),t+=10):(r=null,l('"terminated"')),r===null&&(r=$()))),r!==null&&(r=function(d){i.state=e.substring(t,d)}(f)),r===null&&(t=f),r}function rn(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6).toLowerCase()==="reason"?(r=e.substr(t,6),t+=6):(r=null,l('"reason"')),r!==null?(f=he(),f!==null?(d=Br(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){typeof g<"u"&&(i.reason=g)}(s,r[2])),r===null&&(t=s),r===null&&(s=t,c=t,e.substr(t,7).toLowerCase()==="expires"?(r=e.substr(t,7),t+=7):(r=null,l('"expires"')),r!==null?(f=he(),f!==null?(d=Gt(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){typeof g<"u"&&(i.expires=g)}(s,r[2])),r===null&&(t=s),r===null&&(s=t,c=t,e.substr(t,11).toLowerCase()==="retry_after"?(r=e.substr(t,11),t+=11):(r=null,l('"retry_after"')),r!==null?(f=he(),f!==null?(d=Gt(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){typeof g<"u"&&(i.retry_after=g)}(s,r[2])),r===null&&(t=s),r===null&&(r=Je()))),r}function Br(){var r;return e.substr(t,11).toLowerCase()==="deactivated"?(r=e.substr(t,11),t+=11):(r=null,l('"deactivated"')),r===null&&(e.substr(t,9).toLowerCase()==="probation"?(r=e.substr(t,9),t+=9):(r=null,l('"probation"')),r===null&&(e.substr(t,8).toLowerCase()==="rejected"?(r=e.substr(t,8),t+=8):(r=null,l('"rejected"')),r===null&&(e.substr(t,7).toLowerCase()==="timeout"?(r=e.substr(t,7),t+=7):(r=null,l('"timeout"')),r===null&&(e.substr(t,6).toLowerCase()==="giveup"?(r=e.substr(t,6),t+=6):(r=null,l('"giveup"')),r===null&&(e.substr(t,10).toLowerCase()==="noresource"?(r=e.substr(t,10),t+=10):(r=null,l('"noresource"')),r===null&&(e.substr(t,9).toLowerCase()==="invariant"?(r=e.substr(t,9),t+=9):(r=null,l('"invariant"')),r===null&&(r=$()))))))),r}function Rl(){var r;return r=G(),r=r!==null?r:"",r}function gr(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r=r!==null?r:"",r}function In(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=_s()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=wn(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=wn(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R=i.tag;try{i=new Hs(i.uri,i.display_name,i.params),R&&i.setParam("tag",R)}catch{i=-1}}()),r===null&&(t=c),r}function wn(){var r;return r=Ms(),r===null&&(r=Je()),r}function Gr(){var r,f,d,s,c,h;if(c=t,r=On(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=On(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=On(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function On(){var r,f,d,s,c,h,g,S;if(g=t,r=Ol(),r!==null)if(f=B(),f!==null)if(d=Nn(),d!==null){for(s=[],S=t,c=we(),c!==null?(h=an(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=we(),c!==null?(h=an(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r}function an(){var r;return r=vr(),r===null&&(r=on(),r===null&&(r=Dn(),r===null&&(r=bl(),r===null&&(r=Il(),r===null&&(r=Je()))))),r}function vr(){var r,f,d,s,c;return s=t,c=t,e.substr(t,3).toLowerCase()==="ttl"?(r=e.substr(t,3),t+=3):(r=null,l('"ttl"')),r!==null?(f=he(),f!==null?(d=Un(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.ttl=g}(s,r[2])),r===null&&(t=s),r}function on(){var r,f,d,s,c;return s=t,c=t,e.substr(t,5).toLowerCase()==="maddr"?(r=e.substr(t,5),t+=5):(r=null,l('"maddr"')),r!==null?(f=he(),f!==null?(d=as(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.maddr=g}(s,r[2])),r===null&&(t=s),r}function Dn(){var r,f,d,s,c;return s=t,c=t,e.substr(t,8).toLowerCase()==="received"?(r=e.substr(t,8),t+=8):(r=null,l('"received"')),r!==null?(f=he(),f!==null?(d=us(),d===null&&(d=Xt()),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.received=g}(s,r[2])),r===null&&(t=s),r}function bl(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6).toLowerCase()==="branch"?(r=e.substr(t,6),t+=6):(r=null,l('"branch"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.branch=g}(s,r[2])),r===null&&(t=s),r}function Il(){var r,f,d,s,c;return s=t,e.substr(t,5).toLowerCase()==="rport"?(r=e.substr(t,5),t+=5):(r=null,l('"rport"')),r!==null?(c=t,f=he(),f!==null?(d=wl(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function wl(){var r,f,d,s,c,h,g;return h=t,g=t,r=b(),r=r!==null?r:"",r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?r=[r,f,d,s,c]:(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(S,R){i.rport=parseInt(R.join(""))}(h,r)),r===null&&(t=h),r}function Ol(){var r,f,d,s,c,h;return h=t,r=Dl(),r!==null?(f=oe(),f!==null?(d=$(),d!==null?(s=oe(),s!==null?(c=Nl(),c!==null?r=[r,f,d,s,c]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r}function Dl(){var r,f;return f=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"SIP"')),r===null&&(r=$()),r!==null&&(r=function(d,s){i.protocol=s}(f,r)),r===null&&(t=f),r}function Nl(){var r,f;return f=t,e.substr(t,3).toLowerCase()==="udp"?(r=e.substr(t,3),t+=3):(r=null,l('"UDP"')),r===null&&(e.substr(t,3).toLowerCase()==="tcp"?(r=e.substr(t,3),t+=3):(r=null,l('"TCP"')),r===null&&(e.substr(t,3).toLowerCase()==="tls"?(r=e.substr(t,3),t+=3):(r=null,l('"TLS"')),r===null&&(e.substr(t,4).toLowerCase()==="sctp"?(r=e.substr(t,4),t+=4):(r=null,l('"SCTP"')),r===null&&(r=$())))),r!==null&&(r=function(d,s){i.transport=s}(f,r)),r===null&&(t=f),r}function Nn(){var r,f,d,s,c;return s=t,r=Tr(),r!==null?(c=t,f=st(),f!==null?(d=Er(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function Tr(){var r,f;return f=t,r=us(),r===null&&(r=ht(),r===null&&(r=Ws())),r!==null&&(r=function(d){i.host=e.substring(t,d)}(f)),r===null&&(t=f),r}function Er(){var r,f,d,s,c,h,g;return h=t,g=t,r=b(),r=r!==null?r:"",r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?r=[r,f,d,s,c]:(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(S,R){i.port=parseInt(R.join(""))}(h,r)),r===null&&(t=h),r}function Un(){var r,f,d,s,c;return s=t,c=t,r=b(),r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){return parseInt(g.join(""))}(s,r)),r===null&&(t=s),r}function Ul(){var r;return r=Qs(),r}function Cr(){var r,f,d,s,c,h;if(c=t,r=xl(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=Pl(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=Pl(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function xl(){var r,f;return f=t,r=Gt(),r!==null&&(r=function(d,s){i.expires=s}(f,r)),r===null&&(t=f),r}function Pl(){var r;return r=Wr(),r===null&&(r=Je()),r}function Wr(){var r,f,d,s,c;return s=t,c=t,e.substr(t,9).toLowerCase()==="refresher"?(r=e.substr(t,9),t+=9):(r=null,l('"refresher"')),r!==null?(f=he(),f!==null?(e.substr(t,3).toLowerCase()==="uac"?(d=e.substr(t,3),t+=3):(d=null,l('"uac"')),d===null&&(e.substr(t,3).toLowerCase()==="uas"?(d=e.substr(t,3),t+=3):(d=null,l('"uas"'))),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.refresher=g.toLowerCase()}(s,r[2])),r===null&&(t=s),r}function Kr(){var r,f,d,s;return s=t,r=$(),r!==null?(f=V(),f!==null?(d=xn(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function xn(){var r,f;for(r=[],f=K(),f===null&&(f=te(),f===null&&(f=B()));f!==null;)r.push(f),f=K(),f===null&&(f=te(),f===null&&(f=B()));return r}function Kt(){var r,f;for(r=[],f=N();f!==null;)r.push(f),f=N();return r}function Yr(){var r,f,d;return d=t,e.substr(t,5)==="uuid:"?(r="uuid:",t+=5):(r=null,l('"uuid:"')),r!==null?(f=Ml(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function Ml(){var r,f,d,s,c,h,g,S,R,I,D;return I=t,D=t,r=zr(),r!==null?(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f!==null?(d=ns(),d!==null?(e.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s!==null?(c=ns(),c!==null?(e.charCodeAt(t)===45?(h="-",t++):(h=null,l('"-"')),h!==null?(g=ns(),g!==null?(e.charCodeAt(t)===45?(S="-",t++):(S=null,l('"-"')),S!==null?(R=kl(),R!==null?r=[r,f,d,s,c,h,g,S,R]:(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D),r!==null&&(r=function(J,Ne){i=e.substring(t+5,J)}(I,r[0])),r===null&&(t=I),r}function ns(){var r,f,d,s,c;return c=t,r=O(),r!==null?(f=O(),f!==null?(d=O(),d!==null?(s=O(),s!==null?r=[r,f,d,s]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r}function zr(){var r,f,d;return d=t,r=ns(),r!==null?(f=ns(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function kl(){var r,f,d,s;return s=t,r=ns(),r!==null?(f=ns(),f!==null?(d=ns(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function jt(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=_s()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Je(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){try{i=new Hs(i.uri,i.display_name,i.params)}catch{i=-1}}()),r===null&&(t=c),r}function Sr(){var r,f,d,s,c,h;if(c=t,r=Ll(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=$l(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=$l(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Ll(){var r,f,d,s,c,h;return s=t,c=t,r=P(),r!==null?(h=t,e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f!==null?(d=P(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i.call_id=e.substring(t,g)}(s)),r===null&&(t=s),r}function $l(){var r;return r=Jr(),r===null&&(r=Ar(),r===null&&(r=x(),r===null&&(r=Je()))),r}function Jr(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6)==="to-tag"?(r="to-tag",t+=6):(r=null,l('"to-tag"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.to_tag=g}(s,r[2])),r===null&&(t=s),r}function Ar(){var r,f,d,s,c;return s=t,c=t,e.substr(t,8)==="from-tag"?(r="from-tag",t+=8):(r=null,l('"from-tag"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.from_tag=g}(s,r[2])),r===null&&(t=s),r}function x(){var r,f;return f=t,e.substr(t,10)==="early-only"?(r="early-only",t+=10):(r=null,l('"early-only"')),r!==null&&(r=function(d){i.early_only=!0}()),r===null&&(t=f),r}function Hl(r){r.sort();for(var f=null,d=[],s=0;s<r.length;s++)r[s]!==f&&(d.push(r[s]),f=r[s]);return d}function Fl(){for(var r=1,f=1,d=!1,s=0;s<Math.max(t,v);s++){var c=e.charAt(s);c===`
4
+ `?(d||r++,f=1,d=!1):c==="\r"||c==="\u2028"||c==="\u2029"?(r++,f=1,d=!0):(f++,d=!1)}return{line:r,column:f}}var yr=Zl(),Hs=Nu(),i={},_=p[o]();if(_===null||t!==e.length){var m=Math.max(t,v),T=m<e.length?e.charAt(m):null,y=Fl();return new this.SyntaxError(Hl(C),T,m,y.line,y.column),-1}return i},toSource:function(){return this._source}};return n.SyntaxError=function(a,e,o,p,t){function v(C,l){var A,b;switch(C.length){case 0:A="end of input";break;case 1:A=C[0];break;default:A=C.slice(0,C.length-1).join(", ")+" or "+C[C.length-1]}return b=l?u(l):"end of input","Expected "+A+" but "+b+" found."}this.name="SyntaxError",this.expected=a,this.found=e,this.message=v(a,e),this.offset=o,this.line=p,this.column=t},n.SyntaxError.prototype=Error.prototype,n}()),mo}var go,zu;function Zl(){if(zu)return go;zu=1;function u(l,A){var b;if(typeof Symbol>"u"||l[Symbol.iterator]==null){if(Array.isArray(l)||(b=n(l))||A&&l&&typeof l.length=="number"){b&&(l=b);var E=0,O=function(){};return{s:O,n:function(){return E>=l.length?{done:!0}:{done:!1,value:l[E++]}},e:function(j){throw j},f:O}}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 w=!0,N=!1,U;return{s:function(){b=l[Symbol.iterator]()},n:function(){var j=b.next();return w=j.done,j},e:function(j){N=!0,U=j},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(N)throw U}}}}function n(l,A){if(l){if(typeof l=="string")return a(l,A);var b=Object.prototype.toString.call(l).slice(8,-1);if(b==="Object"&&l.constructor&&(b=l.constructor.name),b==="Map"||b==="Set")return Array.from(l);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return a(l,A)}}function a(l,A){(A==null||A>l.length)&&(A=l.length);for(var b=0,E=new Array(A);b<A;b++)E[b]=l[b];return E}function e(l,A){if(!(l instanceof A))throw new TypeError("Cannot call a class as a function")}function o(l,A){for(var b=0;b<A.length;b++){var E=A[b];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(l,E.key,E)}}function p(l,A,b){return A&&o(l.prototype,A),b&&o(l,b),l}var t=vt,v=qt(),C=_n();return go=function(){p(l,null,[{key:"parse",value:function(b){if(b=C.parse(b,"SIP_URI"),b!==-1)return b}}]);function l(A,b,E,O){var w=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},N=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(e(this,l),!E)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=A||t.SIP,this._user=b,this._host=E,this._port=O;for(var U in w)Object.prototype.hasOwnProperty.call(w,U)&&this.setParam(U,w[U]);for(var Y in N)Object.prototype.hasOwnProperty.call(N,Y)&&this.setHeader(Y,N[Y])}return p(l,[{key:"setParam",value:function(b,E){b&&(this._parameters[b.toLowerCase()]=typeof E>"u"||E===null?null:E.toString())}},{key:"getParam",value:function(b){if(b)return this._parameters[b.toLowerCase()]}},{key:"hasParam",value:function(b){if(b)return this._parameters.hasOwnProperty(b.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(b){if(b=b.toLowerCase(),this._parameters.hasOwnProperty(b)){var E=this._parameters[b];return delete this._parameters[b],E}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(b,E){this._headers[v.headerize(b)]=Array.isArray(E)?E:[E]}},{key:"getHeader",value:function(b){if(b)return this._headers[v.headerize(b)]}},{key:"hasHeader",value:function(b){if(b)return this._headers.hasOwnProperty(v.headerize(b))&&!0||!1}},{key:"deleteHeader",value:function(b){if(b=v.headerize(b),this._headers.hasOwnProperty(b)){var E=this._headers[b];return delete this._headers[b],E}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new l(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 b=[],E="".concat(this._scheme,":");this._user&&(E+="".concat(v.escapeUser(this._user),"@")),E+=this._host,(this._port||this._port===0)&&(E+=":".concat(this._port));for(var O in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,O)&&(E+=";".concat(O),this._parameters[O]!==null&&(E+="=".concat(this._parameters[O])));for(var w in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,w)){var N=u(this._headers[w]),U;try{for(N.s();!(U=N.n()).done;){var Y=U.value;b.push("".concat(w,"=").concat(Y))}}catch(j){N.e(j)}finally{N.f()}}return b.length>0&&(E+="?".concat(b.join("&"))),E}},{key:"toAor",value:function(b){var E="".concat(this._scheme,":");return this._user&&(E+="".concat(v.escapeUser(this._user),"@")),E+=this._host,b&&(this._port||this._port===0)&&(E+=":".concat(this._port)),E}},{key:"scheme",get:function(){return this._scheme},set:function(b){this._scheme=b.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(b){this._user=b}},{key:"host",get:function(){return this._host},set:function(b){this._host=b.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(b){this._port=b===0?b:parseInt(b,10)||null}}]),l}(),go}var Ju;function qt(){if(Ju)return _t;Ju=1;function u(A){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?u=function(E){return typeof E}:u=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},u(A)}function n(A,b){var E;if(typeof Symbol>"u"||A[Symbol.iterator]==null){if(Array.isArray(A)||(E=a(A))||b&&A&&typeof A.length=="number"){E&&(A=E);var O=0,w=function(){};return{s:w,n:function(){return O>=A.length?{done:!0}:{done:!1,value:A[O++]}},e:function(_e){throw _e},f:w}}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 N=!0,U=!1,Y;return{s:function(){E=A[Symbol.iterator]()},n:function(){var _e=E.next();return N=_e.done,_e},e:function(_e){U=!0,Y=_e},f:function(){try{!N&&E.return!=null&&E.return()}finally{if(U)throw Y}}}}function a(A,b){if(A){if(typeof A=="string")return e(A,b);var E=Object.prototype.toString.call(A).slice(8,-1);if(E==="Object"&&A.constructor&&(E=A.constructor.name),E==="Map"||E==="Set")return Array.from(A);if(E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E))return e(A,b)}}function e(A,b){(b==null||b>A.length)&&(b=A.length);for(var E=0,O=new Array(b);E<b;E++)O[E]=A[E];return O}var o=vt,p=Zl(),t=_n();_t.str_utf8_length=function(A){return unescape(encodeURIComponent(A)).length};var v=_t.isFunction=function(A){return A!==void 0?Object.prototype.toString.call(A)==="[object Function]":!1};_t.isString=function(A){return A!==void 0?Object.prototype.toString.call(A)==="[object String]":!1},_t.isDecimal=function(A){return!isNaN(A)&&parseFloat(A)===parseInt(A,10)},_t.isEmpty=function(A){return A===null||A===""||A===void 0||Array.isArray(A)&&A.length===0||typeof A=="number"&&isNaN(A)},_t.hasMethods=function(A){for(var b=arguments.length,E=new Array(b>1?b-1:0),O=1;O<b;O++)E[O-1]=arguments[O];for(var w=0,N=E;w<N.length;w++){var U=N[w];if(v(A[U]))return!1}return!0};var C=_t.createRandomToken=function(A){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,E,O,w="";for(E=0;E<A;E++)O=Math.random()*b|0,w+=O.toString(b);return w};_t.newTag=function(){return C(10)},_t.newUUID=function(){var A="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var E=Math.random()*16|0,O=b==="x"?E:E&3|8;return O.toString(16)});return A},_t.hostType=function(A){if(A){if(A=t.parse(A,"host"),A!==-1)return A.host_type}else return};var l=_t.escapeUser=function(A){return encodeURIComponent(decodeURIComponent(A)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return _t.normalizeTarget=function(A,b){if(A){if(A instanceof p)return A;if(typeof A=="string"){var E=A.split("@"),O,w;switch(E.length){case 1:if(!b)return;O=A,w=b;break;case 2:O=E[0],w=E[1];break;default:O=E.slice(0,E.length-1).join("@"),w=E[E.length-1]}O=O.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(O)&&(O=O.replace(/[-.()]/g,"")),A="".concat(o.SIP,":").concat(l(O),"@").concat(w);var N;return(N=p.parse(A))?N:void 0}else return}else return},_t.headerize=function(A){var b={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},E=A.toLowerCase().replace(/_/g,"-").split("-"),O="",w=E.length,N;for(N=0;N<w;N++)N!==0&&(O+="-"),O+=E[N].charAt(0).toUpperCase()+E[N].substring(1);return b[O]&&(O=b[O]),O},_t.sipErrorCause=function(A){for(var b in o.SIP_ERROR_CAUSES)if(o.SIP_ERROR_CAUSES[b].indexOf(A)!==-1)return o.causes[b];return o.causes.SIP_FAILURE_CODE},_t.getRandomTestNetIP=function(){function A(b,E){return Math.floor(Math.random()*(E-b+1)+b)}return"192.0.2.".concat(A(1,254))},_t.calculateMD5=function(A){function b(ye,pe){return ye<<pe|ye>>>32-pe}function E(ye,pe){var Ce=ye&2147483648,ke=pe&2147483648,He=ye&1073741824,Be=pe&1073741824,Ve=(ye&1073741823)+(pe&1073741823);return He&Be?Ve^2147483648^Ce^ke:He|Be?Ve&1073741824?Ve^3221225472^Ce^ke:Ve^1073741824^Ce^ke:Ve^Ce^ke}function O(ye,pe,Ce){return ye&pe|~ye&Ce}function w(ye,pe,Ce){return ye&Ce|pe&~Ce}function N(ye,pe,Ce){return ye^pe^Ce}function U(ye,pe,Ce){return pe^(ye|~Ce)}function Y(ye,pe,Ce,ke,He,Be,Ve){return ye=E(ye,E(E(O(pe,Ce,ke),He),Ve)),E(b(ye,Be),pe)}function j(ye,pe,Ce,ke,He,Be,Ve){return ye=E(ye,E(E(w(pe,Ce,ke),He),Ve)),E(b(ye,Be),pe)}function _e(ye,pe,Ce,ke,He,Be,Ve){return ye=E(ye,E(E(N(pe,Ce,ke),He),Ve)),E(b(ye,Be),pe)}function k(ye,pe,Ce,ke,He,Be,Ve){return ye=E(ye,E(E(U(pe,Ce,ke),He),Ve)),E(b(ye,Be),pe)}function H(ye){for(var pe,Ce=ye.length,ke=Ce+8,He=(ke-ke%64)/64,Be=(He+1)*16,Ve=new Array(Be-1),Mt=0,ft=0;ft<Ce;)pe=(ft-ft%4)/4,Mt=ft%4*8,Ve[pe]=Ve[pe]|ye.charCodeAt(ft)<<Mt,ft++;return pe=(ft-ft%4)/4,Mt=ft%4*8,Ve[pe]=Ve[pe]|128<<Mt,Ve[Be-2]=Ce<<3,Ve[Be-1]=Ce>>>29,Ve}function de(ye){var pe="",Ce="",ke,He;for(He=0;He<=3;He++)ke=ye>>>He*8&255,Ce="0".concat(ke.toString(16)),pe=pe+Ce.substr(Ce.length-2,2);return pe}function Ue(ye){for(var pe="",Ce=0;Ce<ye.length;Ce++){var ke=ye.charCodeAt(Ce);ke<128?pe+=String.fromCharCode(ke):ke>127&&ke<2048?(pe+=String.fromCharCode(ke>>6|192),pe+=String.fromCharCode(ke&63|128)):(pe+=String.fromCharCode(ke>>12|224),pe+=String.fromCharCode(ke>>6&63|128),pe+=String.fromCharCode(ke&63|128))}return pe}var B=[],L,V,G,K,M,te,se,$,ne,ct=7,P=12,Q=17,oe=22,he=5,Re=9,be=14,fe=20,qe=4,xe=11,we=16,st=23,$e=6,ue=10,Oe=15,Pe=21;for(A=Ue(A),B=H(A),te=1732584193,se=4023233417,$=2562383102,ne=271733878,L=0;L<B.length;L+=16)V=te,G=se,K=$,M=ne,te=Y(te,se,$,ne,B[L+0],ct,3614090360),ne=Y(ne,te,se,$,B[L+1],P,3905402710),$=Y($,ne,te,se,B[L+2],Q,606105819),se=Y(se,$,ne,te,B[L+3],oe,3250441966),te=Y(te,se,$,ne,B[L+4],ct,4118548399),ne=Y(ne,te,se,$,B[L+5],P,1200080426),$=Y($,ne,te,se,B[L+6],Q,2821735955),se=Y(se,$,ne,te,B[L+7],oe,4249261313),te=Y(te,se,$,ne,B[L+8],ct,1770035416),ne=Y(ne,te,se,$,B[L+9],P,2336552879),$=Y($,ne,te,se,B[L+10],Q,4294925233),se=Y(se,$,ne,te,B[L+11],oe,2304563134),te=Y(te,se,$,ne,B[L+12],ct,1804603682),ne=Y(ne,te,se,$,B[L+13],P,4254626195),$=Y($,ne,te,se,B[L+14],Q,2792965006),se=Y(se,$,ne,te,B[L+15],oe,1236535329),te=j(te,se,$,ne,B[L+1],he,4129170786),ne=j(ne,te,se,$,B[L+6],Re,3225465664),$=j($,ne,te,se,B[L+11],be,643717713),se=j(se,$,ne,te,B[L+0],fe,3921069994),te=j(te,se,$,ne,B[L+5],he,3593408605),ne=j(ne,te,se,$,B[L+10],Re,38016083),$=j($,ne,te,se,B[L+15],be,3634488961),se=j(se,$,ne,te,B[L+4],fe,3889429448),te=j(te,se,$,ne,B[L+9],he,568446438),ne=j(ne,te,se,$,B[L+14],Re,3275163606),$=j($,ne,te,se,B[L+3],be,4107603335),se=j(se,$,ne,te,B[L+8],fe,1163531501),te=j(te,se,$,ne,B[L+13],he,2850285829),ne=j(ne,te,se,$,B[L+2],Re,4243563512),$=j($,ne,te,se,B[L+7],be,1735328473),se=j(se,$,ne,te,B[L+12],fe,2368359562),te=_e(te,se,$,ne,B[L+5],qe,4294588738),ne=_e(ne,te,se,$,B[L+8],xe,2272392833),$=_e($,ne,te,se,B[L+11],we,1839030562),se=_e(se,$,ne,te,B[L+14],st,4259657740),te=_e(te,se,$,ne,B[L+1],qe,2763975236),ne=_e(ne,te,se,$,B[L+4],xe,1272893353),$=_e($,ne,te,se,B[L+7],we,4139469664),se=_e(se,$,ne,te,B[L+10],st,3200236656),te=_e(te,se,$,ne,B[L+13],qe,681279174),ne=_e(ne,te,se,$,B[L+0],xe,3936430074),$=_e($,ne,te,se,B[L+3],we,3572445317),se=_e(se,$,ne,te,B[L+6],st,76029189),te=_e(te,se,$,ne,B[L+9],qe,3654602809),ne=_e(ne,te,se,$,B[L+12],xe,3873151461),$=_e($,ne,te,se,B[L+15],we,530742520),se=_e(se,$,ne,te,B[L+2],st,3299628645),te=k(te,se,$,ne,B[L+0],$e,4096336452),ne=k(ne,te,se,$,B[L+7],ue,1126891415),$=k($,ne,te,se,B[L+14],Oe,2878612391),se=k(se,$,ne,te,B[L+5],Pe,4237533241),te=k(te,se,$,ne,B[L+12],$e,1700485571),ne=k(ne,te,se,$,B[L+3],ue,2399980690),$=k($,ne,te,se,B[L+10],Oe,4293915773),se=k(se,$,ne,te,B[L+1],Pe,2240044497),te=k(te,se,$,ne,B[L+8],$e,1873313359),ne=k(ne,te,se,$,B[L+15],ue,4264355552),$=k($,ne,te,se,B[L+6],Oe,2734768916),se=k(se,$,ne,te,B[L+13],Pe,1309151649),te=k(te,se,$,ne,B[L+4],$e,4149444226),ne=k(ne,te,se,$,B[L+11],ue,3174756917),$=k($,ne,te,se,B[L+2],Oe,718787259),se=k(se,$,ne,te,B[L+9],Pe,3951481745),te=E(te,V),se=E(se,G),$=E($,K),ne=E(ne,M);var Le=de(te)+de(se)+de($)+de(ne);return Le.toLowerCase()},_t.closeMediaStream=function(A){if(A)try{var b;if(A.getTracks){b=A.getTracks();var E=n(b),O;try{for(E.s();!(O=E.n()).done;){var w=O.value;w.stop()}}catch(H){E.e(H)}finally{E.f()}}else{b=A.getAudioTracks();var N=n(b),U;try{for(N.s();!(U=N.n()).done;){var Y=U.value;Y.stop()}}catch(H){N.e(H)}finally{N.f()}b=A.getVideoTracks();var j=n(b),_e;try{for(j.s();!(_e=j.n()).done;){var k=_e.value;k.stop()}}catch(H){j.e(H)}finally{j.f()}}}catch{(typeof A.stop=="function"||u(A.stop)==="object")&&A.stop()}},_t.cloneArray=function(A){return A&&A.slice()||[]},_t.cloneObject=function(A){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return A&&Object.assign({},A)||b},_t}var Uu={exports:{}},ii=typeof Reflect=="object"?Reflect:null,Xu=ii&&typeof ii.apply=="function"?ii.apply:function(n,a,e){return Function.prototype.apply.call(n,a,e)},Ma;ii&&typeof ii.ownKeys=="function"?Ma=ii.ownKeys:Object.getOwnPropertySymbols?Ma=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Ma=function(n){return Object.getOwnPropertyNames(n)};function c_(u){console&&console.warn&&console.warn(u)}var Gf=Number.isNaN||function(n){return n!==n};function Ye(){Ye.init.call(this)}Uu.exports=Ye;Uu.exports.once=d_;Ye.EventEmitter=Ye;Ye.prototype._events=void 0;Ye.prototype._eventsCount=0;Ye.prototype._maxListeners=void 0;var Qu=10;function oo(u){if(typeof u!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}Object.defineProperty(Ye,"defaultMaxListeners",{enumerable:!0,get:function(){return Qu},set:function(u){if(typeof u!="number"||u<0||Gf(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");Qu=u}});Ye.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};Ye.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||Gf(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Wf(u){return u._maxListeners===void 0?Ye.defaultMaxListeners:u._maxListeners}Ye.prototype.getMaxListeners=function(){return Wf(this)};Ye.prototype.emit=function(n){for(var a=[],e=1;e<arguments.length;e++)a.push(arguments[e]);var o=n==="error",p=this._events;if(p!==void 0)o=o&&p.error===void 0;else if(!o)return!1;if(o){var t;if(a.length>0&&(t=a[0]),t instanceof Error)throw t;var v=new Error("Unhandled error."+(t?" ("+t.message+")":""));throw v.context=t,v}var C=p[n];if(C===void 0)return!1;if(typeof C=="function")Xu(C,this,a);else for(var l=C.length,A=Xf(C,l),e=0;e<l;++e)Xu(A[e],this,a);return!0};function Kf(u,n,a,e){var o,p,t;if(oo(a),p=u._events,p===void 0?(p=u._events=Object.create(null),u._eventsCount=0):(p.newListener!==void 0&&(u.emit("newListener",n,a.listener?a.listener:a),p=u._events),t=p[n]),t===void 0)t=p[n]=a,++u._eventsCount;else if(typeof t=="function"?t=p[n]=e?[a,t]:[t,a]:e?t.unshift(a):t.push(a),o=Wf(u),o>0&&t.length>o&&!t.warned){t.warned=!0;var v=new Error("Possible EventEmitter memory leak detected. "+t.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");v.name="MaxListenersExceededWarning",v.emitter=u,v.type=n,v.count=t.length,c_(v)}return u}Ye.prototype.addListener=function(n,a){return Kf(this,n,a,!1)};Ye.prototype.on=Ye.prototype.addListener;Ye.prototype.prependListener=function(n,a){return Kf(this,n,a,!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 Yf(u,n,a){var e={fired:!1,wrapFn:void 0,target:u,type:n,listener:a},o=f_.bind(e);return o.listener=a,e.wrapFn=o,o}Ye.prototype.once=function(n,a){return oo(a),this.on(n,Yf(this,n,a)),this};Ye.prototype.prependOnceListener=function(n,a){return oo(a),this.prependListener(n,Yf(this,n,a)),this};Ye.prototype.removeListener=function(n,a){var e,o,p,t,v;if(oo(a),o=this._events,o===void 0)return this;if(e=o[n],e===void 0)return this;if(e===a||e.listener===a)--this._eventsCount===0?this._events=Object.create(null):(delete o[n],o.removeListener&&this.emit("removeListener",n,e.listener||a));else if(typeof e!="function"){for(p=-1,t=e.length-1;t>=0;t--)if(e[t]===a||e[t].listener===a){v=e[t].listener,p=t;break}if(p<0)return this;p===0?e.shift():h_(e,p),e.length===1&&(o[n]=e[0]),o.removeListener!==void 0&&this.emit("removeListener",n,v||a)}return this};Ye.prototype.off=Ye.prototype.removeListener;Ye.prototype.removeAllListeners=function(n){var a,e,o;if(e=this._events,e===void 0)return this;if(e.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):e[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete e[n]),this;if(arguments.length===0){var p=Object.keys(e),t;for(o=0;o<p.length;++o)t=p[o],t!=="removeListener"&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(a=e[n],typeof a=="function")this.removeListener(n,a);else if(a!==void 0)for(o=a.length-1;o>=0;o--)this.removeListener(n,a[o]);return this};function zf(u,n,a){var e=u._events;if(e===void 0)return[];var o=e[n];return o===void 0?[]:typeof o=="function"?a?[o.listener||o]:[o]:a?__(o):Xf(o,o.length)}Ye.prototype.listeners=function(n){return zf(this,n,!0)};Ye.prototype.rawListeners=function(n){return zf(this,n,!1)};Ye.listenerCount=function(u,n){return typeof u.listenerCount=="function"?u.listenerCount(n):Jf.call(u,n)};Ye.prototype.listenerCount=Jf;function Jf(u){var n=this._events;if(n!==void 0){var a=n[u];if(typeof a=="function")return 1;if(a!==void 0)return a.length}return 0}Ye.prototype.eventNames=function(){return this._eventsCount>0?Ma(this._events):[]};function Xf(u,n){for(var a=new Array(n),e=0;e<n;++e)a[e]=u[e];return a}function h_(u,n){for(;n+1<u.length;n++)u[n]=u[n+1];u.pop()}function __(u){for(var n=new Array(u.length),a=0;a<n.length;++a)n[a]=u[a].listener||u[a];return n}function d_(u,n){return new Promise(function(a,e){function o(t){u.removeListener(n,p),e(t)}function p(){typeof u.removeListener=="function"&&u.removeListener("error",o),a([].slice.call(arguments))}Qf(u,n,p,{once:!0}),n!=="error"&&p_(u,o,{once:!0})})}function p_(u,n,a){typeof u.on=="function"&&Qf(u,"error",n,a)}function Qf(u,n,a,e){if(typeof u.on=="function")e.once?u.once(n,a):u.on(n,a);else if(typeof u.addEventListener=="function")u.addEventListener(n,function o(p){e.once&&u.removeEventListener(n,o),a(p)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u)}var At=Uu.exports,hu={exports:{}},vo,Zu;function m_(){if(Zu)return vo;Zu=1;var u=1e3,n=u*60,a=n*60,e=a*24,o=e*7,p=e*365.25;vo=function(A,b){b=b||{};var E=typeof A;if(E==="string"&&A.length>0)return t(A);if(E==="number"&&isFinite(A))return b.long?C(A):v(A);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(A))};function t(A){if(A=String(A),!(A.length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(A);if(b){var E=parseFloat(b[1]),O=(b[2]||"ms").toLowerCase();switch(O){case"years":case"year":case"yrs":case"yr":case"y":return E*p;case"weeks":case"week":case"w":return E*o;case"days":case"day":case"d":return E*e;case"hours":case"hour":case"hrs":case"hr":case"h":return E*a;case"minutes":case"minute":case"mins":case"min":case"m":return E*n;case"seconds":case"second":case"secs":case"sec":case"s":return E*u;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}function v(A){var b=Math.abs(A);return b>=e?Math.round(A/e)+"d":b>=a?Math.round(A/a)+"h":b>=n?Math.round(A/n)+"m":b>=u?Math.round(A/u)+"s":A+"ms"}function C(A){var b=Math.abs(A);return b>=e?l(A,b,e,"day"):b>=a?l(A,b,a,"hour"):b>=n?l(A,b,n,"minute"):b>=u?l(A,b,u,"second"):A+" ms"}function l(A,b,E,O){var w=b>=E*1.5;return Math.round(A/E)+" "+O+(w?"s":"")}return vo}function g_(u){a.debug=a,a.default=a,a.coerce=C,a.disable=p,a.enable=o,a.enabled=t,a.humanize=m_(),a.destroy=l,Object.keys(u).forEach(A=>{a[A]=u[A]}),a.names=[],a.skips=[],a.formatters={};function n(A){let b=0;for(let E=0;E<A.length;E++)b=(b<<5)-b+A.charCodeAt(E),b|=0;return a.colors[Math.abs(b)%a.colors.length]}a.selectColor=n;function a(A){let b,E=null,O,w;function N(...U){if(!N.enabled)return;const Y=N,j=Number(new Date),_e=j-(b||j);Y.diff=_e,Y.prev=b,Y.curr=j,b=j,U[0]=a.coerce(U[0]),typeof U[0]!="string"&&U.unshift("%O");let k=0;U[0]=U[0].replace(/%([a-zA-Z%])/g,(de,Ue)=>{if(de==="%%")return"%";k++;const B=a.formatters[Ue];if(typeof B=="function"){const L=U[k];de=B.call(Y,L),U.splice(k,1),k--}return de}),a.formatArgs.call(Y,U),(Y.log||a.log).apply(Y,U)}return N.namespace=A,N.useColors=a.useColors(),N.color=a.selectColor(A),N.extend=e,N.destroy=a.destroy,Object.defineProperty(N,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(O!==a.namespaces&&(O=a.namespaces,w=a.enabled(A)),w),set:U=>{E=U}}),typeof a.init=="function"&&a.init(N),N}function e(A,b){const E=a(this.namespace+(typeof b>"u"?":":b)+A);return E.log=this.log,E}function o(A){a.save(A),a.namespaces=A,a.names=[],a.skips=[];let b;const E=(typeof A=="string"?A:"").split(/[\s,]+/),O=E.length;for(b=0;b<O;b++)E[b]&&(A=E[b].replace(/\*/g,".*?"),A[0]==="-"?a.skips.push(new RegExp("^"+A.slice(1)+"$")):a.names.push(new RegExp("^"+A+"$")))}function p(){const A=[...a.names.map(v),...a.skips.map(v).map(b=>"-"+b)].join(",");return a.enable(""),A}function t(A){if(A[A.length-1]==="*")return!0;let b,E;for(b=0,E=a.skips.length;b<E;b++)if(a.skips[b].test(A))return!1;for(b=0,E=a.names.length;b<E;b++)if(a.names[b].test(A))return!0;return!1}function v(A){return A.toString().substring(2,A.toString().length-2).replace(/\.\*\?$/,"*")}function C(A){return A instanceof Error?A.stack||A.message:A}function l(){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 a.enable(a.load()),a}var v_=g_;(function(u,n){n.formatArgs=e,n.save=o,n.load=p,n.useColors=a,n.storage=t(),n.destroy=(()=>{let C=!1;return()=>{C||(C=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function a(){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 e(C){if(C[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+C[0]+(this.useColors?"%c ":" ")+"+"+u.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;C.splice(1,0,l,"color: inherit");let A=0,b=0;C[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(A++,E==="%c"&&(b=A))}),C.splice(b,0,l)}n.log=console.debug||console.log||(()=>{});function o(C){try{C?n.storage.setItem("debug",C):n.storage.removeItem("debug")}catch{}}function p(){let C;try{C=n.storage.getItem("debug")}catch{}return!C&&typeof process<"u"&&"env"in process&&(C=process.env.DEBUG),C}function t(){try{return localStorage}catch{}}u.exports=v_(n);const{formatters:v}=u.exports;v.j=function(C){try{return JSON.stringify(C)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}})(hu,hu.exports);var oi=hu.exports;function T_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function ec(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function E_(u,n,a){return n&&ec(u.prototype,n),a&&ec(u,a),u}var Xr=oi,Qr="JsSIP",yt=function(){function u(n){T_(this,u),n?(this._debug=Xr.default("".concat(Qr,":").concat(n)),this._warn=Xr.default("".concat(Qr,":WARN:").concat(n)),this._error=Xr.default("".concat(Qr,":ERROR:").concat(n))):(this._debug=Xr.default(Qr),this._warn=Xr.default("".concat(Qr,":WARN")),this._error=Xr.default("".concat(Qr,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return E_(u,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),u}(),Jt={},Zf={},eh={exports:{}},tc=eh.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(u){return u.encoding?"rtpmap:%d %s/%s/%s":u.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(u){return u.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(u){return u.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(u){return"extmap:%d"+(u.direction?"/%s":"%v")+(u["encrypt-uri"]?" %s":"%v")+" %s"+(u.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(u){return u.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(u){var n="candidate:%s %d %s %d %s %d typ %s";return n+=u.raddr!=null?" raddr %s rport %d":"%v%v",n+=u.tcptype!=null?" tcptype %s":"%v",u.generation!=null&&(n+=" generation %d"),n+=u["network-id"]!=null?" network-id %d":"%v",n+=u["network-cost"]!=null?" network-cost %d":"%v",n}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(u){var n="ssrc:%d";return u.attribute!=null&&(n+=" %s",u.value!=null&&(n+=":%s")),n}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(u){return u.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(u){return u.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(u){return"imageattr:%s %s %s"+(u.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(u){return"simulcast:%s %s"+(u.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(u){return"ts-refclk:%s"+(u.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(u){var n="mediaclk:";return n+=u.id!=null?"id=%s %s":"%v%s",n+=u.mediaClockValue!=null?"=%s":"",n+=u.rateNumerator!=null?" rate=%s":"",n+=u.rateDenominator!=null?"/%s":"",n}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(tc).forEach(function(u){var n=tc[u];n.forEach(function(a){a.reg||(a.reg=/(.*)/),a.format||(a.format="%s")})});var th=eh.exports;(function(u){var n=function(v){return String(Number(v))===v?Number(v):v},a=function(v,C,l,A){if(A&&!l)C[A]=n(v[1]);else for(var b=0;b<l.length;b+=1)v[b+1]!=null&&(C[l[b]]=n(v[b+1]))},e=function(v,C,l){var A=v.name&&v.names;v.push&&!C[v.push]?C[v.push]=[]:A&&!C[v.name]&&(C[v.name]={});var b=v.push?{}:A?C[v.name]:C;a(l.match(v.reg),b,v.names,v.name),v.push&&C[v.push].push(b)},o=th,p=RegExp.prototype.test.bind(/^([a-z])=(.*)/);u.parse=function(v){var C={},l=[],A=C;return v.split(/(\r\n|\r|\n)/).filter(p).forEach(function(b){var E=b[0],O=b.slice(2);E==="m"&&(l.push({rtp:[],fmtp:[]}),A=l[l.length-1]);for(var w=0;w<(o[E]||[]).length;w+=1){var N=o[E][w];if(N.reg.test(O))return e(N,A,O)}}),C.media=l,C};var t=function(v,C){var l=C.split(/=(.+)/,2);return l.length===2?v[l[0]]=n(l[1]):l.length===1&&C.length>1&&(v[l[0]]=void 0),v};u.parseParams=function(v){return v.split(/;\s?/).reduce(t,{})},u.parseFmtpConfig=u.parseParams,u.parsePayloads=function(v){return v.toString().split(" ").map(Number)},u.parseRemoteCandidates=function(v){for(var C=[],l=v.split(" ").map(n),A=0;A<l.length;A+=3)C.push({component:l[A],ip:l[A+1],port:l[A+2]});return C},u.parseImageAttributes=function(v){return v.split(" ").map(function(C){return C.substring(1,C.length-1).split(",").reduce(t,{})})},u.parseSimulcastStreamList=function(v){return v.split(";").map(function(C){return C.split(",").map(function(l){var A,b=!1;return l[0]!=="~"?A=n(l):(A=n(l.substring(1,l.length)),b=!0),{scid:A,paused:b}})})}})(Zf);var To=th,C_=/%[sdv%]/g,S_=function(u){var n=1,a=arguments,e=a.length;return u.replace(C_,function(o){if(n>=e)return o;var p=a[n];switch(n+=1,o){case"%%":return"%";case"%s":return String(p);case"%d":return Number(p);case"%v":return""}})},mi=function(u,n,a){var e=n.format instanceof Function?n.format(n.push?a:a[n.name]):n.format,o=[u+"="+e];if(n.names)for(var p=0;p<n.names.length;p+=1){var t=n.names[p];n.name?o.push(a[n.name][t]):o.push(a[n.names[p]])}else o.push(a[n.name]);return S_.apply(null,o)},A_=["v","o","s","i","u","e","p","c","b","t","r","z","a"],y_=["i","c","b","a"],R_=function(u,n){n=n||{},u.version==null&&(u.version=0),u.name==null&&(u.name=" "),u.media.forEach(function(p){p.payloads==null&&(p.payloads="")});var a=n.outerOrder||A_,e=n.innerOrder||y_,o=[];return a.forEach(function(p){To[p].forEach(function(t){t.name in u&&u[t.name]!=null?o.push(mi(p,t,u)):t.push in u&&u[t.push]!=null&&u[t.push].forEach(function(v){o.push(mi(p,t,v))})})}),u.media.forEach(function(p){o.push(mi("m",To.m[0],p)),e.forEach(function(t){To[t].forEach(function(v){v.name in p&&p[v.name]!=null?o.push(mi(t,v,p)):v.push in p&&p[v.push]!=null&&p[v.push].forEach(function(C){o.push(mi(t,v,C))})})})}),o.join(`\r
7
7
  `)+`\r
8
- `},Cn=Yf,vh=Th;Pt.write=vh;Pt.parse=Cn.parse;Pt.parseParams=Cn.parseParams;Pt.parseFmtpConfig=Cn.parseFmtpConfig;Pt.parsePayloads=Cn.parsePayloads;Pt.parseRemoteCandidates=Cn.parseRemoteCandidates;Pt.parseImageAttributes=Cn.parseImageAttributes;Pt.parseSimulcastStreamList=Cn.parseSimulcastStreamList;function po(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?po=function(r){return typeof r}:po=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},po(c)}function Iu(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&&lu(c,s)}function lu(c,s){return lu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},lu(c,s)}function bu(c){var s=yh();return function(){var o=Io(c),a;if(s){var t=Io(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Eh(this,a)}}function Eh(c,s){return s&&(po(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 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 Io(c){return Io=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Io(c)}function Vt(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Ah(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,d;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,d=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw d}}}}function Ah(c,s){if(c){if(typeof c=="string")return Qu(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 Qu(c,s)}}function Qu(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 tl(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Zu(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 qo(c,s,r){return s&&Zu(c.prototype,s),r&&Zu(c,r),c}var Xf=Pt,Ch=_t,Et=it,nt=bt(),ec=Cu(),Rh=is(),_a=new Ch("SIPMessage"),Qf=function(){function c(s,r,o,a,t,n){if(tl(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=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","<".concat(o.transport.sip_uri,";lr>")),this.setHeader("via",""),this.setHeader("max-forwards",Et.MAX_FORWARDS);var d=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 ec(d,h,_),this.setHeader("to",this.to.toString());var g=a.from_uri||o.configuration.uri,T={tag:a.from_tag||nt.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 ec(g,E,T),this.setHeader("from",this.from.toString());var y=a.call_id||o.configuration.jssip_id+nt.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 qo(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[nt.headerize(r)]=Array.isArray(o)?o:[o]}},{key:"getHeader",value:function(r){var o=this.headers[nt.headerize(r)];if(o){if(o[0])return o[0]}else{var a=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),t=Vt(this.extraHeaders),n;try{for(t.s();!(n=t.n()).done;){var d=n.value;if(a.test(d))return d.substring(d.indexOf(":")+1).trim()}}catch(_){t.e(_)}finally{t.f()}}}},{key:"getHeaders",value:function(r){var o=this.headers[nt.headerize(r)],a=[];if(o){var t=Vt(o),n;try{for(t.s();!(n=t.n()).done;){var d=n.value;a.push(d)}}catch(E){t.e(E)}finally{t.f()}return a}else{var _=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),h=Vt(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[nt.headerize(r)])return!0;var o=new RegExp("^\\s*".concat(r,"\\s*:"),"i"),a=Vt(this.extraHeaders),t;try{for(a.s();!(t=a.n()).done;){var n=t.value;if(o.test(n))return!0}}catch(d){a.e(d)}finally{a.f()}return!1}},{key:"parseSDP",value:function(r){return!r&&this.sdp?this.sdp:(this.sdp=Xf.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var r="".concat(this.method," ").concat(this.ruri,` SIP/2.0\r
10
- `);for(var o in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,o)){var a=Vt(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 d=Vt(this.extraHeaders),_;try{for(d.s();!(_=d.n()).done;){var h=_.value;r+="".concat(h.trim(),`\r
12
- `)}}catch(y){d.e(y)}finally{d.f()}var g=[];switch(this.method){case Et.REGISTER:g.push("path","gruu");break;case Et.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 Et.UPDATE:this.ua.configuration.session_timers&&g.push("timer"),g.push("ice");break}g.push("outbound");var T=this.ua.configuration.user_agent||Et.USER_AGENT;if(r+="Allow: ".concat(Et.ALLOWED_METHODS,`\r
13
- `),r+="Supported: ".concat(g,`\r
14
- `),r+="User-Agent: ".concat(T,`\r
15
- `),this.body){var E=nt.str_utf8_length(this.body);r+="Content-Length: ".concat(E,`\r
8
+ `},Lr=Zf,b_=R_;Jt.write=b_;Jt.parse=Lr.parse;Jt.parseParams=Lr.parseParams;Jt.parseFmtpConfig=Lr.parseFmtpConfig;Jt.parsePayloads=Lr.parsePayloads;Jt.parseRemoteCandidates=Lr.parseRemoteCandidates;Jt.parseImageAttributes=Lr.parseImageAttributes;Jt.parseSimulcastStreamList=Lr.parseSimulcastStreamList;function ka(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ka=function(a){return typeof a}:ka=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ka(u)}function xu(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&_u(u,n)}function _u(u,n){return _u=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},_u(u,n)}function Pu(u){var n=O_();return function(){var e=Ka(u),o;if(n){var p=Ka(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return I_(this,o)}}function I_(u,n){return n&&(ka(n)==="object"||typeof n=="function")?n:w_(u)}function w_(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function O_(){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 Ka(u){return Ka=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Ka(u)}function Cs(u,n){var a;if(typeof Symbol>"u"||u[Symbol.iterator]==null){if(Array.isArray(u)||(a=D_(u))||n&&u&&typeof u.length=="number"){a&&(u=a);var e=0,o=function(){};return{s:o,n:function(){return e>=u.length?{done:!0}:{done:!1,value:u[e++]}},e:function(l){throw l},f:o}}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 p=!0,t=!1,v;return{s:function(){a=u[Symbol.iterator]()},n:function(){var l=a.next();return p=l.done,l},e:function(l){t=!0,v=l},f:function(){try{!p&&a.return!=null&&a.return()}finally{if(t)throw v}}}}function D_(u,n){if(u){if(typeof u=="string")return sc(u,n);var a=Object.prototype.toString.call(u).slice(8,-1);if(a==="Object"&&u.constructor&&(a=u.constructor.name),a==="Map"||a==="Set")return Array.from(u);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return sc(u,n)}}function sc(u,n){(n==null||n>u.length)&&(n=u.length);for(var a=0,e=new Array(n);a<n;a++)e[a]=u[a];return e}function Gi(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function nc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function uo(u,n,a){return n&&nc(u.prototype,n),a&&nc(u,a),u}var sh=Jt,N_=yt,Nt=vt,mt=qt(),lc=Nu(),U_=_n(),Eo=new N_("SIPMessage"),nh=function(){function u(n,a,e,o,p,t){if(Gi(this,u),!n||!a||!e)return null;o=o||{},this.ua=e,this.headers={},this.method=n,this.ruri=a,this.body=t,this.extraHeaders=mt.cloneArray(p),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),o.route_set?this.setHeader("route",o.route_set):e.configuration.use_preloaded_route&&this.setHeader("route","<".concat(e.transport.sip_uri,";lr>")),this.setHeader("via",""),this.setHeader("max-forwards",Nt.MAX_FORWARDS);var v=o.to_uri||a,C=o.to_tag?{tag:o.to_tag}:null,l=typeof o.to_display_name<"u"?o.to_display_name:null;this.to=new lc(v,l,C),this.setHeader("to",this.to.toString());var A=o.from_uri||e.configuration.uri,b={tag:o.from_tag||mt.newTag()},E;typeof o.from_display_name<"u"?E=o.from_display_name:e.configuration.display_name?E=e.configuration.display_name:E=null,this.from=new lc(A,E,b),this.setHeader("from",this.from.toString());var O=o.call_id||e.configuration.jssip_id+mt.createRandomToken(15);this.call_id=O,this.setHeader("call-id",O);var w=o.cseq||Math.floor(Math.random()*1e4);this.cseq=w,this.setHeader("cseq","".concat(w," ").concat(n))}return uo(u,[{key:"setHeader",value:function(a,e){for(var o=new RegExp("^\\s*".concat(a,"\\s*:"),"i"),p=0;p<this.extraHeaders.length;p++)o.test(this.extraHeaders[p])&&this.extraHeaders.splice(p,1);this.headers[mt.headerize(a)]=Array.isArray(e)?e:[e]}},{key:"getHeader",value:function(a){var e=this.headers[mt.headerize(a)];if(e){if(e[0])return e[0]}else{var o=new RegExp("^\\s*".concat(a,"\\s*:"),"i"),p=Cs(this.extraHeaders),t;try{for(p.s();!(t=p.n()).done;){var v=t.value;if(o.test(v))return v.substring(v.indexOf(":")+1).trim()}}catch(C){p.e(C)}finally{p.f()}}}},{key:"getHeaders",value:function(a){var e=this.headers[mt.headerize(a)],o=[];if(e){var p=Cs(e),t;try{for(p.s();!(t=p.n()).done;){var v=t.value;o.push(v)}}catch(E){p.e(E)}finally{p.f()}return o}else{var C=new RegExp("^\\s*".concat(a,"\\s*:"),"i"),l=Cs(this.extraHeaders),A;try{for(l.s();!(A=l.n()).done;){var b=A.value;C.test(b)&&o.push(b.substring(b.indexOf(":")+1).trim())}}catch(E){l.e(E)}finally{l.f()}return o}}},{key:"hasHeader",value:function(a){if(this.headers[mt.headerize(a)])return!0;var e=new RegExp("^\\s*".concat(a,"\\s*:"),"i"),o=Cs(this.extraHeaders),p;try{for(o.s();!(p=o.n()).done;){var t=p.value;if(e.test(t))return!0}}catch(v){o.e(v)}finally{o.f()}return!1}},{key:"parseSDP",value:function(a){return!a&&this.sdp?this.sdp:(this.sdp=sh.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var a="".concat(this.method," ").concat(this.ruri,` SIP/2.0\r
10
+ `);for(var e in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,e)){var o=Cs(this.headers[e]),p;try{for(o.s();!(p=o.n()).done;){var t=p.value;a+="".concat(e,": ").concat(t,`\r
11
+ `)}}catch(O){o.e(O)}finally{o.f()}}var v=Cs(this.extraHeaders),C;try{for(v.s();!(C=v.n()).done;){var l=C.value;a+="".concat(l.trim(),`\r
12
+ `)}}catch(O){v.e(O)}finally{v.f()}var A=[];switch(this.method){case Nt.REGISTER:A.push("path","gruu");break;case Nt.INVITE:this.ua.configuration.session_timers&&A.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&A.push("gruu"),A.push("ice","replaces");break;case Nt.UPDATE:this.ua.configuration.session_timers&&A.push("timer"),A.push("ice");break}A.push("outbound");var b=this.ua.configuration.user_agent||Nt.USER_AGENT;if(a+="Allow: ".concat(Nt.ALLOWED_METHODS,`\r
13
+ `),a+="Supported: ".concat(A,`\r
14
+ `),a+="User-Agent: ".concat(b,`\r
15
+ `),this.body){var E=mt.str_utf8_length(this.body);a+="Content-Length: ".concat(E,`\r
16
16
  \r
17
- `),r+=this.body}else r+=`Content-Length: 0\r
17
+ `),a+=this.body}else a+=`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=nt.cloneArray(this.extraHeaders),r.to=this.to,r.from=this.from,r.call_id=this.call_id,r.cseq=this.cseq,r}}]),c}(),Ih=function(c){Iu(r,c);var s=bu(r);function r(o,a,t,n,d){var _;return tl(this,r),_=s.call(this,Et.INVITE,o,a,t,n,d),_.transaction=null,_}return qo(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=nt.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}(Qf),Zf=function(){function c(){tl(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 qo(c,[{key:"addHeader",value:function(r,o){var a={raw:o};r=nt.headerize(r),this.headers[r]?this.headers[r].push(a):this.headers[r]=[a]}},{key:"getHeader",value:function(r){var o=this.headers[nt.headerize(r)];if(o){if(o[0])return o[0].raw}else return}},{key:"getHeaders",value:function(r){var o=this.headers[nt.headerize(r)],a=[];if(!o)return[];var t=Vt(o),n;try{for(t.s();!(n=t.n()).done;){var d=n.value;a.push(d.raw)}}catch(_){t.e(_)}finally{t.f()}return a}},{key:"hasHeader",value:function(r){return!!this.headers[nt.headerize(r)]}},{key:"parseHeader",value:function(r){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(r=nt.headerize(r),this.headers[r]){if(o>=this.headers[r].length){_a.debug('not so many "'.concat(r,'" headers present'));return}}else{_a.debug('header "'.concat(r,'" not present'));return}var a=this.headers[r][o],t=a.raw;if(a.parsed)return a.parsed;var n=Rh.parse(t,r.replace(/-/g,"_"));if(n===-1){this.headers[r].splice(o,1),_a.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[nt.headerize(r)]=[a]}},{key:"parseSDP",value:function(r){return!r&&this.sdp?this.sdp:(this.sdp=Xf.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),c}(),bh=function(c){Iu(r,c);var s=bu(r);function r(o){var a;return tl(this,r),a=s.call(this),a.ua=o,a.headers={},a.ruri=null,a.transport=null,a.server_transaction=null,a}return qo(r,[{key:"reply",value:function(a,t,n,d,_,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||Et.REASON_PHRASE[a]||"",n=nt.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
- `);if(this.method===Et.INVITE&&a>100&&a<=200){var y=this.getHeaders("record-route"),A=Vt(y),C;try{for(A.s();!(C=A.n()).done;){var I=C.value;E+="Record-Route: ".concat(I,`\r
21
- `)}}catch(D){A.e(D)}finally{A.f()}}var H=this.getHeaders("via"),L=Vt(H),ae;try{for(L.s();!(ae=L.n()).done;){var N=ae.value;E+="Via: ".concat(N,`\r
22
- `)}}catch(D){L.e(D)}finally{L.f()}!this.to_tag&&a>100?T+=";tag=".concat(nt.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(T+=";tag=".concat(this.to_tag)),E+="To: ".concat(T,`\r
19
+ `;return a}},{key:"clone",value:function(){var a=new u(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(e){a.headers[e]=this.headers[e].slice()},this),a.body=this.body,a.extraHeaders=mt.cloneArray(this.extraHeaders),a.to=this.to,a.from=this.from,a.call_id=this.call_id,a.cseq=this.cseq,a}}]),u}(),x_=function(u){xu(a,u);var n=Pu(a);function a(e,o,p,t,v){var C;return Gi(this,a),C=n.call(this,Nt.INVITE,e,o,p,t,v),C.transaction=null,C}return uo(a,[{key:"cancel",value:function(o){this.transaction.cancel(o)}},{key:"clone",value:function(){var o=new a(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(p){o.headers[p]=this.headers[p].slice()},this),o.body=this.body,o.extraHeaders=mt.cloneArray(this.extraHeaders),o.to=this.to,o.from=this.from,o.call_id=this.call_id,o.cseq=this.cseq,o.transaction=this.transaction,o}}]),a}(nh),lh=function(){function u(){Gi(this,u),this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}return uo(u,[{key:"addHeader",value:function(a,e){var o={raw:e};a=mt.headerize(a),this.headers[a]?this.headers[a].push(o):this.headers[a]=[o]}},{key:"getHeader",value:function(a){var e=this.headers[mt.headerize(a)];if(e){if(e[0])return e[0].raw}else return}},{key:"getHeaders",value:function(a){var e=this.headers[mt.headerize(a)],o=[];if(!e)return[];var p=Cs(e),t;try{for(p.s();!(t=p.n()).done;){var v=t.value;o.push(v.raw)}}catch(C){p.e(C)}finally{p.f()}return o}},{key:"hasHeader",value:function(a){return!!this.headers[mt.headerize(a)]}},{key:"parseHeader",value:function(a){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(a=mt.headerize(a),this.headers[a]){if(e>=this.headers[a].length){Eo.debug('not so many "'.concat(a,'" headers present'));return}}else{Eo.debug('header "'.concat(a,'" not present'));return}var o=this.headers[a][e],p=o.raw;if(o.parsed)return o.parsed;var t=U_.parse(p,a.replace(/-/g,"_"));if(t===-1){this.headers[a].splice(e,1),Eo.debug('error parsing "'.concat(a,'" header field with value "').concat(p,'"'));return}else return o.parsed=t,t}},{key:"s",value:function(a,e){return this.parseHeader(a,e)}},{key:"setHeader",value:function(a,e){var o={raw:e};this.headers[mt.headerize(a)]=[o]}},{key:"parseSDP",value:function(a){return!a&&this.sdp?this.sdp:(this.sdp=sh.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),u}(),P_=function(u){xu(a,u);var n=Pu(a);function a(e){var o;return Gi(this,a),o=n.call(this),o.ua=e,o.headers={},o.ruri=null,o.transport=null,o.server_transaction=null,o}return uo(a,[{key:"reply",value:function(o,p,t,v,C,l){var A=[],b=this.getHeader("To");if(o=o||null,p=p||null,!o||o<100||o>699)throw new TypeError("Invalid status_code: ".concat(o));if(p&&typeof p!="string"&&!(p instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(p));p=p||Nt.REASON_PHRASE[o]||"",t=mt.cloneArray(t),this.ua.configuration.extra_headers&&(t=t.concat(this.ua.configuration.extra_headers));var E="SIP/2.0 ".concat(o," ").concat(p,`\r
20
+ `);if(this.method===Nt.INVITE&&o>100&&o<=200){var O=this.getHeaders("record-route"),w=Cs(O),N;try{for(w.s();!(N=w.n()).done;){var U=N.value;E+="Record-Route: ".concat(U,`\r
21
+ `)}}catch(L){w.e(L)}finally{w.f()}}var Y=this.getHeaders("via"),j=Cs(Y),_e;try{for(j.s();!(_e=j.n()).done;){var k=_e.value;E+="Via: ".concat(k,`\r
22
+ `)}}catch(L){j.e(L)}finally{j.f()}!this.to_tag&&o>100?b+=";tag=".concat(mt.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(b+=";tag=".concat(this.to_tag)),E+="To: ".concat(b,`\r
23
23
  `),E+="From: ".concat(this.getHeader("From"),`\r
24
24
  `),E+="Call-ID: ".concat(this.call_id,`\r
25
25
  `),E+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
26
- `);var j=Vt(n),Se;try{for(j.s();!(Se=j.n()).done;){var ve=Se.value;E+="".concat(ve.trim(),`\r
27
- `)}}catch(D){j.e(D)}finally{j.f()}switch(this.method){case Et.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 Et.UPDATE:this.ua.configuration.session_timers&&g.push("timer"),d&&g.push("ice"),g.push("replaces")}if(g.push("outbound"),this.method===Et.OPTIONS?(E+="Allow: ".concat(Et.ALLOWED_METHODS,`\r
28
- `),E+="Accept: ".concat(Et.ACCEPTED_BODY_TYPES,`\r
29
- `)):a===405?E+="Allow: ".concat(Et.ALLOWED_METHODS,`\r
30
- `):a===415&&(E+="Accept: ".concat(Et.ACCEPTED_BODY_TYPES,`\r
31
- `)),E+="Supported: ".concat(g,`\r
32
- `),d){var M=nt.str_utf8_length(d);E+=`Content-Type: application/sdp\r
33
- `,E+="Content-Length: ".concat(M,`\r
26
+ `);var H=Cs(t),de;try{for(H.s();!(de=H.n()).done;){var Ue=de.value;E+="".concat(Ue.trim(),`\r
27
+ `)}}catch(L){H.e(L)}finally{H.f()}switch(this.method){case Nt.INVITE:this.ua.configuration.session_timers&&A.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&A.push("gruu"),A.push("ice","replaces");break;case Nt.UPDATE:this.ua.configuration.session_timers&&A.push("timer"),v&&A.push("ice"),A.push("replaces")}if(A.push("outbound"),this.method===Nt.OPTIONS?(E+="Allow: ".concat(Nt.ALLOWED_METHODS,`\r
28
+ `),E+="Accept: ".concat(Nt.ACCEPTED_BODY_TYPES,`\r
29
+ `)):o===405?E+="Allow: ".concat(Nt.ALLOWED_METHODS,`\r
30
+ `):o===415&&(E+="Accept: ".concat(Nt.ACCEPTED_BODY_TYPES,`\r
31
+ `)),E+="Supported: ".concat(A,`\r
32
+ `),v){var B=mt.str_utf8_length(v);E+=`Content-Type: application/sdp\r
33
+ `,E+="Content-Length: ".concat(B,`\r
34
34
  \r
35
- `),E+=d}else E+="Content-Length: ".concat(0,`\r
35
+ `),E+=v}else E+="Content-Length: ".concat(0,`\r
36
36
  \r
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||Et.REASON_PHRASE[a]||"";var d="SIP/2.0 ".concat(a," ").concat(t,`\r
38
- `),_=Vt(n),h;try{for(_.s();!(h=_.n()).done;){var g=h.value;d+="Via: ".concat(g,`\r
39
- `)}}catch(C){_.e(C)}finally{_.f()}var T=this.getHeader("To");if(!this.to_tag&&a>100?T+=";tag=".concat(nt.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(T+=";tag=".concat(this.to_tag)),d+="To: ".concat(T,`\r
40
- `),d+="From: ".concat(this.getHeader("From"),`\r
41
- `),d+="Call-ID: ".concat(this.call_id,`\r
42
- `),d+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
43
- `),this.ua.configuration.extra_headers){var E=Vt(this.ua.configuration.extra_headers),y;try{for(E.s();!(y=E.n()).done;){var A=y.value;d+="".concat(A.trim(),`\r
44
- `)}}catch(C){E.e(C)}finally{E.f()}}d+="Content-Length: ".concat(0,`\r
37
+ `);this.server_transaction.receiveResponse(o,E,C,l)}},{key:"reply_sl",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,t=this.getHeaders("via");if(!o||o<100||o>699)throw new TypeError("Invalid status_code: ".concat(o));if(p&&typeof p!="string"&&!(p instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(p));p=p||Nt.REASON_PHRASE[o]||"";var v="SIP/2.0 ".concat(o," ").concat(p,`\r
38
+ `),C=Cs(t),l;try{for(C.s();!(l=C.n()).done;){var A=l.value;v+="Via: ".concat(A,`\r
39
+ `)}}catch(N){C.e(N)}finally{C.f()}var b=this.getHeader("To");if(!this.to_tag&&o>100?b+=";tag=".concat(mt.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(b+=";tag=".concat(this.to_tag)),v+="To: ".concat(b,`\r
40
+ `),v+="From: ".concat(this.getHeader("From"),`\r
41
+ `),v+="Call-ID: ".concat(this.call_id,`\r
42
+ `),v+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
43
+ `),this.ua.configuration.extra_headers){var E=Cs(this.ua.configuration.extra_headers),O;try{for(E.s();!(O=E.n()).done;){var w=O.value;v+="".concat(w.trim(),`\r
44
+ `)}}catch(N){E.e(N)}finally{E.f()}}v+="Content-Length: ".concat(0,`\r
45
45
  \r
46
- `),this.transport.send(d)}}]),r}(Zf),wh=function(c){Iu(r,c);var s=bu(r);function r(){var o;return tl(this,r),o=s.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return r}(Zf),vs={OutgoingRequest:Qf,InitialOutgoingInviteRequest:Ih,IncomingRequest:bh,IncomingResponse:wh};function Oh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function tc(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&&tc(c.prototype,s),r&&tc(c,r),c}var Nh=_t,cs=bt(),Kt=new Nh("DigestAuthentication"),Uh=function(){function c(s){Oh(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 Dh(c,[{key:"get",value:function(r){switch(r){case"realm":return this._realm;case"ha1":return this._ha1;default:Kt.warn('get() | cannot get "%s" parameter',r);return}}},{key:"authenticate",value:function(r,o){var a=r.method,t=r.ruri,n=r.body,d=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 Kt.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Kt.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Kt.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Kt.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Kt.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 Kt.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=d||cs.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=cs.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=cs.calculateMD5(h),Kt.debug('authenticate() | using qop=auth [a2:"%s"]',h),this._response=cs.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(cs.calculateMD5(n||"")),g=cs.calculateMD5(h),Kt.debug('authenticate() | using qop=auth-int [a2:"%s"]',h),this._response=cs.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=cs.calculateMD5(h),Kt.debug('authenticate() | using qop=null [a2:"%s"]',h),this._response=cs.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(g))),Kt.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}(),fs=500,Ph=4e3,sc=5e3,e_={T1:fs,T2:Ph,T4:sc,TIMER_B:64*fs,TIMER_D:0*fs,TIMER_F:64*fs,TIMER_H:64*fs,TIMER_I:0*fs,TIMER_J:0*fs,TIMER_K:0*sc,TIMER_L:64*fs,TIMER_M:64*fs,PROVISIONAL_RESPONSE_INTERVAL:6e4};function mo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?mo=function(r){return typeof r}:mo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},mo(c)}function sl(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 nl(c,s,r){return s&&nc(c.prototype,s),r&&nc(c,r),c}function rl(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&&ou(c,s)}function ou(c,s){return ou=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ou(c,s)}function il(c){var s=Mh();return function(){var o=bo(c),a;if(s){var t=bo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return xh(this,a)}}function xh(c,s){return s&&(mo(s)==="object"||typeof s=="function")?s:qs(c)}function qs(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 bo(c){return bo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},bo(c)}var ll=ft.EventEmitter,ol=_t,Ki=it,rc=vs,ns=e_,ic=new ol("NonInviteClientTransaction"),Ml=new ol("InviteClientTransaction"),kh=new ol("AckClientTransaction"),lc=new ol("NonInviteServerTransaction"),kl=new ol("InviteServerTransaction"),_e={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"},Lh=function(c){rl(r,c);var s=il(r);function r(o,a,t,n){var d;sl(this,r),d=s.call(this),d.type=_e.NON_INVITE_CLIENT,d.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),d.ua=o,d.transport=a,d.request=t,d.eventHandlers=n;var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(d.id),d.request.setHeader("via",_),d.ua.newTransaction(qs(d)),d}return nl(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(_e.STATUS_TRYING),this.F=setTimeout(function(){a.timer_F()},ns.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){ic.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){ic.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(a){var t=this,n=a.status_code;if(n<200)switch(this.state){case _e.STATUS_TRYING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break}else switch(this.state){case _e.STATUS_TRYING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_COMPLETED),clearTimeout(this.F),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},ns.TIMER_K);break;case _e.STATUS_COMPLETED:break}}},{key:"C",get:function(){return _e}}]),r}(ll),$h=function(c){rl(r,c);var s=il(r);function r(o,a,t,n){var d;sl(this,r),d=s.call(this),d.type=_e.INVITE_CLIENT,d.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),d.ua=o,d.transport=a,d.request=t,d.eventHandlers=n,t.transaction=qs(d);var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(d.id),d.request.setHeader("via",_),d.ua.newTransaction(qs(d)),d}return nl(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(_e.STATUS_CALLING),this.B=setTimeout(function(){a.timer_B()},ns.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==_e.STATUS_ACCEPTED&&(Ml.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){Ml.debug("Timer M expired for transaction ".concat(this.id)),this.state===_e.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){Ml.debug("Timer B expired for transaction ".concat(this.id)),this.state===_e.STATUS_CALLING&&(this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){Ml.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(a){var t=this,n=new rc.OutgoingRequest(Ki.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()},ns.TIMER_D),this.transport.send(n)}},{key:"cancel",value:function(a){if(this.state===_e.STATUS_PROCEEDING){var t=new rc.OutgoingRequest(Ki.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 _e.STATUS_CALLING:this.stateChanged(_e.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break;case _e.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(a);break}else if(n>=200&&n<=299)switch(this.state){case _e.STATUS_CALLING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},ns.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case _e.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(n>=300&&n<=699)switch(this.state){case _e.STATUS_CALLING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_COMPLETED),this.sendACK(a),this.eventHandlers.onReceiveResponse(a);break;case _e.STATUS_COMPLETED:this.sendACK(a);break}}},{key:"C",get:function(){return _e}}]),r}(ll),Hh=function(c){rl(r,c);var s=il(r);function r(o,a,t,n){var d;sl(this,r),d=s.call(this),d.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),d.transport=a,d.request=t,d.eventHandlers=n;var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(d.id),d.request.setHeader("via",_),d}return nl(r,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){kh.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return _e}}]),r}(ll),Fh=function(c){rl(r,c);var s=il(r);function r(o,a,t){var n;return sl(this,r),n=s.call(this),n.type=_e.NON_INVITE_SERVER,n.id=t.via_branch,n.ua=o,n.transport=a,n.request=t,n.last_response="",t.server_transaction=qs(n),n.state=_e.STATUS_TRYING,o.newTransaction(qs(n)),n}return nl(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){lc.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,lc.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(a,t,n,d){var _=this;if(a===100)switch(this.state){case _e.STATUS_TRYING:this.stateChanged(_e.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case _e.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),d&&d());break}else if(a>=200&&a<=699)switch(this.state){case _e.STATUS_TRYING:case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){_.timer_J()},ns.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),d&&d());break;case _e.STATUS_COMPLETED:break}}},{key:"C",get:function(){return _e}}]),r}(ll),jh=function(c){rl(r,c);var s=il(r);function r(o,a,t){var n;return sl(this,r),n=s.call(this),n.type=_e.INVITE_SERVER,n.id=t.via_branch,n.ua=o,n.transport=a,n.request=t,n.last_response="",t.server_transaction=qs(n),n.state=_e.STATUS_PROCEEDING,o.newTransaction(qs(n)),n.resendProvisionalTimer=null,t.reply(100),n}return nl(r,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){kl.debug("Timer H expired for transaction ".concat(this.id)),this.state===_e.STATUS_COMPLETED&&kl.debug("ACK not received, dialog will be terminated"),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){kl.debug("Timer L expired for transaction ".concat(this.id)),this.state===_e.STATUS_ACCEPTED&&(this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,kl.debug("transport error occurred, deleting transaction ".concat(this.id)),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(_e.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(a,t,n,d){var _=this;if(a>=100&&a<=199)switch(this.state){case _e.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t;break}if(a>100&&a<=199&&this.state===_e.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){_.resend_provisional()},ns.PROVISIONAL_RESPONSE_INTERVAL));else if(a>=200&&a<=299)switch(this.state){case _e.STATUS_PROCEEDING:this.stateChanged(_e.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){_.timer_L()},ns.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case _e.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),d&&d());break}else if(a>=300&&a<=699)switch(this.state){case _e.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(_e.STATUS_COMPLETED),this.H=setTimeout(function(){_.timer_H()},ns.TIMER_H),n&&n()):(this.onTransportError(),d&&d());break}}},{key:"C",get:function(){return _e}}]),r}(ll);function qh(c,s){var r=c._transactions,o;switch(s.method){case Ki.INVITE:if(o=r.ist[s.via_branch],o){switch(o.state){case _e.STATUS_PROCEEDING:o.transport.send(o.last_response);break;case _e.STATUS_ACCEPTED:break}return!0}break;case Ki.ACK:if(o=r.ist[s.via_branch],o){if(o.state===_e.STATUS_ACCEPTED)return!1;if(o.state===_e.STATUS_COMPLETED)return o.state=_e.STATUS_CONFIRMED,o.I=setTimeout(function(){o.timer_I()},ns.TIMER_I),!0}else return!1;break;case Ki.CANCEL:return o=r.ist[s.via_branch],o?(s.reply_sl(200),o.state!==_e.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(o=r.nist[s.via_branch],o){switch(o.state){case _e.STATUS_TRYING:break;case _e.STATUS_PROCEEDING:case _e.STATUS_COMPLETED:o.transport.send(o.last_response);break}return!0}break}}var al={C:_e,NonInviteClientTransaction:Lh,InviteClientTransaction:$h,AckClientTransaction:Hh,NonInviteServerTransaction:Fh,InviteServerTransaction:jh,checkTransaction:qh};function Vh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function oc(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 Bh(c,s,r){return s&&oc(c.prototype,s),r&&oc(c,r),c}var Gh=_t,ac=it,Wh=Uh,ha=al,Kh=new Gh("RequestSender"),da={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},ul=function(){function c(s,r,o){Vh(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 da)Object.prototype.hasOwnProperty.call(da,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=da[a]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==ac.BYE||this._method!==ac.ACK)&&this._eventHandlers.onTransportError()}return Bh(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 ha.InviteClientTransaction(this._ua,this._ua.transport,this._request,o);break;case"ACK":this.clientTransaction=new ha.AckClientTransaction(this._ua,this._ua.transport,this._request,o);break;default:this.clientTransaction=new ha.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){Kh.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 Yh(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 Jh(c,s,r){return s&&uc(c.prototype,s),r&&uc(c,r),c}var zh=_t,pa=bt(),hn=it,cc=vs,fc=ul,wi=new zh("Registrator"),Ll=10,Xh=function(){function c(s,r){Yh(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=pa.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 Jh(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){wi.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(hn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new fc(this._ua,a,{onRequestTimeout:function(){r._registrationFailure(null,hn.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._registrationFailure(null,hn.causes.CONNECTION_ERROR)},onAuthenticated:function(){r._cseq+=1},onReceiveResponse:function(d){if(d.cseq===r._cseq)switch(r._registrationTimer!==null&&(clearTimeout(r._registrationTimer),r._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(d.status_code):break;case/^2[0-9]{2}$/.test(d.status_code):{if(r._registering=!1,!d.hasHeader("Contact")){wi.debug("no Contact header in response to REGISTER, response ignored");break}var _=d.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){wi.debug("no Contact header pointing to us, response ignored");break}var g=h.getParam("expires");!g&&d.hasHeader("expires")&&(g=d.getHeader("expires")),g||(g=r._expires),g=Number(g),g<Ll&&(g=Ll);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:d}));break}case/^423$/.test(d.status_code):{d.hasHeader("min-expires")?(r._expires=Number(d.getHeader("min-expires")),r._expires<Ll&&(r._expires=Ll),r.register()):(wi.debug("423 response received for REGISTER without Min-Expires"),r._registrationFailure(d,hn.causes.SIP_FAILURE_CODE));break}default:{var E=pa.sipErrorCause(d.status_code);r._registrationFailure(d,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){wi.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(hn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),n=new fc(this._ua,t,{onRequestTimeout:function(){r._unregistered(null,hn.causes.REQUEST_TIMEOUT)},onTransportError:function(){r._unregistered(null,hn.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=pa.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 Qh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function _c(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 Zh(c,s,r){return s&&_c(c.prototype,s),r&&_c(c,r),c}var ma=it,$l=al,ed=ul,ga={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},td=function(){function c(s,r,o){Qh(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 ga)Object.prototype.hasOwnProperty.call(ga,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=ga[a]))}return Zh(c,[{key:"send",value:function(){var r=this,o=new ed(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===ma.INVITE||this._request.method===ma.UPDATE&&this._request.body)&&o.clientTransaction.state!==$l.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===$l.C.STATUS_ACCEPTED||o.clientTransaction.state===$l.C.STATUS_COMPLETED||o.clientTransaction.state===$l.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===ma.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 sd(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 dc(c,s,r){return s&&hc(c.prototype,s),r&&hc(c,r),c}var nd=_t,pc=vs,xs=it,Oi=al,rd=td,Ta=bt(),va=new nd("Dialog"),Ms={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},id=function(){dc(c,null,[{key:"C",get:function(){return Ms}}]);function c(s,r,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ms.STATUS_CONFIRMED;if(sd(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 pc.IncomingResponse&&(a=r.status_code<200?Ms.STATUS_EARLY:Ms.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),va.debug("new ".concat(o," dialog created with status ").concat(this._state===Ms.STATUS_EARLY?"EARLY":"CONFIRMED"))}return dc(c,[{key:"isTerminated",value:function(){return this._status===Ms.STATUS_TERMINATED}},{key:"update",value:function(r,o){this._state=Ms.STATUS_CONFIRMED,va.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),o==="UAC"&&(this._route_set=r.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){va.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Ms.STATUS_TERMINATED}},{key:"sendRequest",value:function(r){var o=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=Ta.cloneArray(a.extraHeaders),n=Ta.cloneObject(a.eventHandlers),d=a.body||null,_=this._createRequest(r,t,d);n.onAuthenticated=function(){o._local_seqnum+=1};var h=new rd(this,_,n);return h.send(),_}},{key:"receiveRequest",value:function(r){this._checkInDialogRequest(r)&&(r.method===xs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===xs.INVITE&&(this._ack_seqnum=r.cseq),this._owner.receiveRequest(r))}},{key:"_createRequest",value:function(r,o,a){o=Ta.cloneArray(o),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var t=r===xs.CANCEL||r===xs.ACK?this._local_seqnum:this._local_seqnum+=1,n=new pc.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===xs.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===xs.INVITE||r.method===xs.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===Oi.C.STATUS_ACCEPTED||r.server_transaction.state===Oi.C.STATUS_COMPLETED||r.server_transaction.state===Oi.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===Oi.C.STATUS_ACCEPTED&&(o._remote_target=r.parseHeader("contact").uri)})}else r.method===xs.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",function(){r.server_transaction.state===Oi.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}(),wu={exports:{}};function go(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?go=function(r){return typeof r}:go=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},go(c)}function ld(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function mc(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 od(c,s,r){return s&&mc(c.prototype,s),r&&mc(c,r),c}function ad(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&&au(c,s)}function au(c,s){return au=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},au(c,s)}function ud(c){var s=_d();return function(){var o=wo(c),a;if(s){var t=wo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return cd(this,a)}}function cd(c,s){return s&&(go(s)==="object"||typeof s=="function")?s:fd(c)}function fd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function _d(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function wo(c){return wo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},wo(c)}var hd=ft.EventEmitter,dd=_t,pd=it,md=Bs,gc=bt(),gd=new dd("RTCSession:DTMF"),t_={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};wu.exports=function(c){ad(r,c);var s=ud(r);function r(o){var a;return ld(this,r),a=s.call(this),a._session=o,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return od(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 md.InvalidStateError(this._session.status);var d=gc.cloneArray(n.extraHeaders);if(this.eventHandlers=gc.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,d.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(pd.INFO,{extraHeaders:d,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 d=a.body.split(`
48
- `);d.length>=1&&t.test(d[0])&&(this._tone=d[0].replace(t,"$2")),d.length>=2&&n.test(d[1])&&(this._duration=parseInt(d[1].replace(n,"$2"),10))}this._duration||(this._duration=t_.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):gd.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),r}(hd);wu.exports.C=t_;var Td=wu.exports;function To(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?To=function(r){return typeof r}:To=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},To(c)}function vd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Tc(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 Ed(c,s,r){return s&&Tc(c.prototype,s),r&&Tc(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&&uu(c,s)}function uu(c,s){return uu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},uu(c,s)}function yd(c){var s=Rd();return function(){var o=Oo(c),a;if(s){var t=Oo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Ad(this,a)}}function Ad(c,s){return s&&(To(s)==="object"||typeof s=="function")?s:Cd(c)}function Cd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Rd(){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 Oo(c){return Oo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Oo(c)}var Id=ft.EventEmitter,bd=it,wd=Bs,Od=bt(),Dd=function(c){Sd(r,c);var s=yd(r);function r(o){var a;return vd(this,r),a=s.call(this),a._session=o,a._direction=null,a._contentType=null,a._body=null,a}return Ed(r,[{key:"send",value:function(a,t){var n=this,d=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 wd.InvalidStateError(this._session.status);this._contentType=a,this._body=t;var _=Od.cloneArray(d.extraHeaders);_.push("Content-Type: ".concat(a)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(bd.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}(Id);function Nd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function vc(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 Ud(c,s,r){return s&&vc(c.prototype,s),r&&vc(c,r),c}var Pd=_t,Ec=it,xd=new Pd("RTCSession:ReferNotifier"),Ea={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300},Md=function(){function c(s,r,o){Nd(this,c),this._session=s,this._id=r,this._expires=o||Ea.expires,this._active=!0,this.notify(100)}return Ud(c,[{key:"notify",value:function(r,o){if(xd.debug("notify()"),this._active!==!1){o=o||Ec.REASON_PHRASE[r]||"";var a;r>=200?a="terminated;reason=noresource":a="active;expires=".concat(this._expires),this._session.sendRequest(Ec.NOTIFY,{extraHeaders:["Event: ".concat(Ea.event_type,";id=").concat(this._id),"Subscription-State: ".concat(a),"Content-Type: ".concat(Ea.body_type)],body:"SIP/2.0 ".concat(r," ").concat(o),eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),c}();function vo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?vo=function(r){return typeof r}:vo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},vo(c)}function kd(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 Ld(c,s,r){return s&&Sc(c.prototype,s),r&&Sc(c,r),c}function $d(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&&cu(c,s)}function cu(c,s){return cu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},cu(c,s)}function Hd(c){var s=qd();return function(){var o=Do(c),a;if(s){var t=Do(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Fd(this,a)}}function Fd(c,s){return s&&(vo(s)==="object"||typeof s=="function")?s:jd(c)}function jd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function qd(){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 Do(c){return Do=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Do(c)}var Vd=ft.EventEmitter,Bd=_t,Di=it,Gd=is(),yc=bt(),dn=new Bd("RTCSession:ReferSubscriber"),Wd=function(c){$d(r,c);var s=Hd(r);function r(o){var a;return kd(this,r),a=s.call(this),a._id=null,a._session=o,a}return Ld(r,[{key:"sendRefer",value:function(a){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};dn.debug("sendRefer()");var d=yc.cloneArray(n.extraHeaders),_=yc.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(d.push(T),!d.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,">");d.push(E)}d.push("Contact: ".concat(this._session.contact));var y=this._session.sendRequest(Di.REFER,{extraHeaders:d,eventHandlers:{onSuccessResponse:function(C){t._requestSucceeded(C)},onErrorResponse:function(C){t._requestFailed(C,Di.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,Di.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,Di.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,Di.causes.DIALOG_ERROR)}}});this._id=y.cseq}},{key:"receiveNotify",value:function(a){if(dn.debug("receiveNotify()"),!!a.body){var t=Gd.parse(a.body.trim().split(`\r
49
- `,1)[0],"Status_Line");if(t===-1){dn.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){dn.debug("REFER succeeded"),dn.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:a})}},{key:"_requestFailed",value:function(a,t){dn.debug("REFER failed"),dn.debug('emit "requestFailed"'),this.emit("requestFailed",{response:a||null,cause:t})}},{key:"id",get:function(){return this._id}}]),r}(Vd);function Eo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Eo=function(r){return typeof r}:Eo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Eo(c)}function _s(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Kd(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,d;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,d=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw d}}}}function Kd(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 Yd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Cc(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 Rc(c,s,r){return s&&Cc(c.prototype,s),r&&Cc(c,r),c}function Jd(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&&fu(c,s)}function fu(c,s){return fu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},fu(c,s)}function zd(c){var s=Zd();return function(){var o=No(c),a;if(s){var t=No(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Xd(this,a)}}function Xd(c,s){return s&&(Eo(s)==="object"||typeof s=="function")?s:Qd(c)}function Qd(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 No(c){return No=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},No(c)}var ep=ft.EventEmitter,Ic=Pt,tp=_t,ce=it,pn=Bs,bc=al,Ve=bt(),Ni=e_,sp=vs,Hl=id,np=ul,xt=Td,wc=Dd,rp=Md,ip=Wd,Oc=Gs(),K=new tp("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},Fl=["audio","video"],lp=function(c){Jd(r,c);var s=zd(r);Rc(r,null,[{key:"C",get:function(){return Q}}]);function r(o){var a;return Yd(this,r),K.debug("new"),a=s.call(this),a._id=null,a._ua=o,a._status=Q.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 Rc(r,[{key:"isInProgress",value:function(){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}}},{key:"isEstablished",value:function(){switch(this._status){case Q.STATUS_ANSWERED:case Q.STATUS_WAITING_FOR_ACK:case Q.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case Q.STATUS_CANCELED:case Q.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;K.debug("connect()");var d=a,_=Ve.cloneObject(t.eventHandlers),h=Ve.cloneArray(t.extraHeaders),g=Ve.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),T=t.mediaStream||null,E=Ve.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!==Q.STATUS_NULL)throw new pn.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new pn.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(d));this._sessionTimers.enabled&&Ve.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=Ve.newTag();var I=t.anonymous||!1,H={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:I,outbound:!0}),I?(H.from_display_name="Anonymous",H.from_uri=new Oc("sip","anonymous","anonymous.invalid"),h.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),h.push("Privacy: id")):t.fromUserName&&(H.from_uri=new Oc("sip",t.fromUserName,this._ua.configuration.uri.host),h.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&(H.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 sp.InitialOutgoingInviteRequest(a,this._ua,H,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;K.debug("init_incoming()");var d,_=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;if(a.body&&_!=="application/sdp"){a.reply(415);return}if(this._status=Q.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")&&(d=a.getHeader("expires")*1e3),a.to_tag=Ve.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=Q.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),d&&(this._timers.expiresTimer=setTimeout(function(){n._status===Q.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),n._failed("system",null,ce.causes.EXPIRES))},d)),this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from,t&&t(this),this._newRTCSession("remote",a),this._status!==Q.STATUS_TERMINATED&&(a.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))}},{key:"answer",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.debug("answer()");var n=this._request,d=Ve.cloneArray(t.extraHeaders),_=Ve.cloneObject(t.mediaConstraints),h=t.mediaStream||null,g=Ve.cloneObject(t.pcConfig,{iceServers:[]}),T=t.rtcConstraints||null,E=t.rtcAnswerConstraints||null,y=Ve.cloneObject(t.rtcOfferConstraints),A,C=!1,I=!1,H=!1,L=!1;if(this._rtcAnswerConstraints=E,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,this._direction!=="incoming")throw new pn.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==Q.STATUS_WAITING_FOR_ANSWER)throw new pn.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Ve.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=ce.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=ce.SESSION_EXPIRES),this._status=Q.STATUS_ANSWERED,!this._createDialog(n,"UAS")){n.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),d.unshift("Contact: ".concat(this._contact));var ae=n.parseSDP();Array.isArray(ae.media)||(ae.media=[ae.media]);var N=_s(ae.media),j;try{for(N.s();!(j=N.n()).done;){var Se=j.value;Se.type==="audio"&&(C=!0,(!Se.direction||Se.direction==="sendrecv")&&(H=!0)),Se.type==="video"&&(I=!0,(!Se.direction||Se.direction==="sendrecv")&&(L=!0))}}catch(F){N.e(F)}finally{N.f()}if(h&&_.audio===!1){A=h.getAudioTracks();var ve=_s(A),M;try{for(ve.s();!(M=ve.n()).done;){var D=M.value;h.removeTrack(D)}}catch(F){ve.e(F)}finally{ve.f()}}if(h&&_.video===!1){A=h.getVideoTracks();var B=_s(A),V;try{for(B.s();!(V=B.n()).done;){var J=V.value;h.removeTrack(J)}}catch(F){B.e(F)}finally{B.f()}}!h&&_.audio===void 0&&(_.audio=H),!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(F){throw a._status===Q.STATUS_TERMINATED?new Error("terminated"):(n.reply(480),a._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',F),a.emit("getusermediafailed",F),new Error("getUserMedia() failed"))})}).then(function(F){if(a._status===Q.STATUS_TERMINATED)throw new Error("terminated");a._localMediaStream=F,F&&F.getTracks().forEach(function(X){a._connection.addTrack(X,F)})}).then(function(){if(!a._late_sdp){var F={originator:"remote",type:"offer",sdp:n.body};K.debug('emit "sdp"'),a.emit("sdp",F);var X=new RTCSessionDescription({type:"offer",sdp:F.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(X)}).catch(function(U){throw n.reply(488),a._failed("system",null,ce.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),a.emit("peerconnection:setremotedescriptionfailed",U),new Error("peerconnection.setRemoteDescription() failed")}),a._connectionPromiseQueue}}).then(function(){if(a._status===Q.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(F){if(a._status===Q.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(n,d),n.reply(200,null,d,F,function(){a._status=Q.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(n,F),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,ce.causes.CONNECTION_ERROR)})}).catch(function(F){a._status!==Q.STATUS_TERMINATED&&K.warn(F)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.debug("terminate()");var n=t.cause||ce.causes.BYE,d=Ve.cloneArray(t.extraHeaders),_=t.body,h,g=t.status_code,T=t.reason_phrase;if(this._status===Q.STATUS_TERMINATED)throw new pn.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"),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===Q.STATUS_NULL||this._status===Q.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=h):this._status===Q.STATUS_1XX_RECEIVED&&this._request.cancel(h),this._status=Q.STATUS_CANCELED,this._failed("local",null,ce.causes.CANCELED);break;case Q.STATUS_WAITING_FOR_ANSWER:case Q.STATUS_ANSWERED:if(K.debug("rejecting session"),g=g||480,g<300||g>=700)throw new TypeError("Invalid status_code: ".concat(g));this._request.reply(g,T,d,_),this._failed("local",null,ce.causes.REJECTED);break;case Q.STATUS_WAITING_FOR_ACK:case Q.STATUS_CONFIRMED:if(K.debug("terminating session"),T=t.reason_phrase||ce.REASON_PHRASE[g]||"",g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));if(g&&d.push("Reason: SIP ;cause=".concat(g,'; text="').concat(T,'"')),this._status===Q.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==bc.C.STATUS_TERMINATED){var E=this._dialog;this.receiveRequest=function(y){var A=y.method;A===ce.ACK&&(a.sendRequest(ce.BYE,{extraHeaders:d,body:_}),E.terminate())},this._request.server_transaction.on("stateChanged",function(){a._request.server_transaction.state===bc.C.STATUS_TERMINATED&&(a.sendRequest(ce.BYE,{extraHeaders:d,body:_}),E.terminate())}),this._ended("local",null,n),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(ce.BYE,{extraHeaders:d,body:_}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};K.debug("sendDTMF() | tones: %s",a);var n=0,d=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!==Q.STATUS_CONFIRMED&&this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_1XX_RECEIVED)throw new pn.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(d&&!Ve.isDecimal(d))throw new TypeError("Invalid tone duration: ".concat(d));if(d?d<xt.C.MIN_DURATION?(K.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(xt.C.MIN_DURATION," milliseconds")),d=xt.C.MIN_DURATION):d>xt.C.MAX_DURATION?(K.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(xt.C.MAX_DURATION," milliseconds")),d=xt.C.MAX_DURATION):d=Math.abs(d):d=xt.C.DEFAULT_DURATION,t.duration=d,_&&!Ve.isDecimal(_))throw new TypeError("Invalid interToneGap: ".concat(_));if(_?_<xt.C.MIN_INTER_TONE_GAP?(K.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,d,_));return}if(this._tones){this._tones+=a;return}this._tones=a,T.call(this);function T(){var E=this,y;if(this._status===Q.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=d+_}setTimeout(T.bind(this),y)}}},{key:"sendInfo",value:function(a,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(K.debug("sendInfo()"),this._status!==Q.STATUS_CONFIRMED&&this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_1XX_RECEIVED)throw new pn.InvalidStateError(this._status);var d=new wc(this);d.send(a,t,n)}},{key:"mute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};K.debug("mute()");var t=!1,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};K.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(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");var d={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:d,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:d,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(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");var d={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:d,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:d,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;K.debug("renegotiate()");var d=t.rtcOfferConstraints||null;if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.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:d,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:_,rtcOfferConstraints:d,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(a,t){var n=this;K.debug("refer()");var d=a;if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(d));var _=new ip(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 K.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(K.debug("receiveRequest()"),a.method===ce.CANCEL)(this._status===Q.STATUS_WAITING_FOR_ANSWER||this._status===Q.STATUS_ANSWERED)&&(this._status=Q.STATUS_CANCELED,this._request.reply(487),this._failed("remote",a,ce.causes.CANCELED));else switch(a.method){case ce.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(!a.body){this.terminate({cause:ce.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:a.body};K.debug('emit "sdp"'),this.emit("sdp",n);var d=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(d)}).then(function(){t._is_confirmed||t._confirmed("remote",a)}).catch(function(h){t.terminate({cause:ce.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),K.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===Q.STATUS_CONFIRMED||this._status===Q.STATUS_WAITING_FOR_ACK?(a.reply(200),this._ended("remote",a,ce.causes.BYE)):this._status===Q.STATUS_INVITE_RECEIVED||this._status===Q.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===Q.STATUS_CONFIRMED?a.hasHeader("replaces")?this._receiveReplaces(a):this._receiveReinvite(a):a.reply(403,"Wrong Status");break;case ce.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){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 wc(this).init_incoming(a):a.reply(415)}else a.reply(403,"Wrong Status");break;case ce.UPDATE:this._status===Q.STATUS_CONFIRMED?this._receiveUpdate(a):a.reply(403,"Wrong Status");break;case ce.REFER:this._status===Q.STATUS_CONFIRMED?this._receiveRefer(a):a.reply(403,"Wrong Status");break;case ce.NOTIFY:this._status===Q.STATUS_CONFIRMED?this._receiveNotify(a):a.reply(403,"Wrong Status");break;default:a.reply(501)}}},{key:"onTransportError",value:function(){K.warn("onTransportError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ce.causes.CONNECTION_ERROR,cause:ce.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){K.warn("onRequestTimeout()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ce.causes.REQUEST_TIMEOUT,cause:ce.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){K.warn("onDialogError()"),this._status!==Q.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ce.causes.DIALOG_ERROR,cause:ce.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(a){K.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){K.debug("newInfo()"),this.emit("newInfo",a)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(K.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(K.debug("_isReadyToReOffer() | session not established yet"),!1):(K.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),Ve.closeMediaStream(this._localMediaStream)),this._status!==Q.STATUS_TERMINATED){if(this._status=Q.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(d){K.warn("close() | error closing the RTCPeerConnection: %o",d)}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=Ni.T1;function d(){this._status===Q.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),n<Ni.T2&&(n=n*2,n>Ni.T2&&(n=Ni.T2)),this._timers.invite2xxTimer=setTimeout(d.bind(this),n))}this._timers.invite2xxTimer=setTimeout(d.bind(this),n)}},{key:"_setACKTimer",value:function(){var a=this;this._timers.ackTimer=setTimeout(function(){a._status===Q.STATUS_WAITING_FOR_ACK&&(K.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(ce.BYE),a._ended("remote",null,ce.causes.NO_ACK))},Ni.TIMER_H)}},{key:"_createRTCConnection",value:function(a,t){var n=this;this._connection=new RTCPeerConnection(a,t),this._connection.addEventListener("iceconnectionstatechange",function(){var d=n._connection.iceConnectionState;d==="failed"&&n.terminate({cause:ce.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ce.causes.RTP_TIMEOUT})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var n=this;if(K.debug("createLocalDescription()"),a!=="offer"&&a!=="answer")throw new Error('createLocalDescription() | invalid type "'.concat(a,'"'));var d=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return a==="offer"?d.createOffer(t).catch(function(_){return K.warn('emit "peerconnection:createofferfailed" [error:%o]',_),n.emit("peerconnection:createofferfailed",_),Promise.reject(_)}):d.createAnswer(t).catch(function(_){return K.warn('emit "peerconnection:createanswerfailed" [error:%o]',_),n.emit("peerconnection:createanswerfailed",_),Promise.reject(_)})}).then(function(_){return d.setLocalDescription(_).catch(function(h){return n._rtcReady=!0,K.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',h),n.emit("peerconnection:setlocaldescriptionfailed",h),Promise.reject(h)})}).then(function(){var _=t&&t.iceRestart;if(d.iceGatheringState==="complete"&&!_||d.iceGatheringState==="gathering"&&n._iceReady){n._rtcReady=!0;var h={originator:"local",type:a,sdp:d.localDescription.sdp};return K.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(){d.removeEventListener("icecandidate",E),d.removeEventListener("icegatheringstatechange",y),T=!0,n._rtcReady=!0,n._iceReady=!0;var I={originator:"local",type:a,sdp:d.localDescription.sdp};K.debug('emit "sdp"'),n.emit("sdp",I),g(I.sdp)};d.addEventListener("icecandidate",E=function(I){var H=I.candidate;H?n.emit("icecandidate",{candidate:H,ready:A}):T||A()}),d.addEventListener("icegatheringstatechange",y=function(){d.iceGatheringState==="complete"&&!T&&A()})})})}},{key:"_createDialog",value:function(a,t,n){var d=t==="UAS"?a.to_tag:a.from_tag,_=t==="UAS"?a.from_tag:a.to_tag,h=a.call_id+d+_,g=this._earlyDialogs[h];if(n)return g?!0:(g=new Hl(this,a,t,Hl.C.STATUS_EARLY),g.error?(K.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?(K.debug(T.error),this._failed("remote",a,ce.causes.INTERNAL_ERROR),!1):(this._dialog=T,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;K.debug("receiveReinvite()");var n=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,d={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=Ve.cloneArray(T.extraHeaders);if(this._status!==Q.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",d),_)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"){K.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(T){t._status!==Q.STATUS_TERMINATED&&g.call(t,T)}).catch(function(T){K.warn(T)});function g(T){var E=this,y=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,y),this._late_sdp&&(T=this._mangleOffer(T)),a.reply(200,null,y,T,function(){E._status=Q.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(a,T),E._setACKTimer()}),typeof d.callback=="function"&&d.callback()}}},{key:"_receiveUpdate",value:function(a){var t=this;K.debug("receiveUpdate()");var n=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,d={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=Ve.cloneArray(T.extraHeaders);if(this._status!==Q.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",d),_)return;if(!a.body){g.call(this,null);return}if(n!=="application/sdp"){K.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(T){t._status!==Q.STATUS_TERMINATED&&g.call(t,T)}).catch(function(T){K.warn(T)});function g(T){var E=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,E),a.reply(200,null,E,T),typeof d.callback=="function"&&d.callback()}}},{key:"_processInDialogSdpOffer",value:function(a){var t=this;K.debug("_processInDialogSdpOffer()");var n=a.parseSDP(),d=!1,_=_s(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")d=!0;else{d=!1;break}}}}catch(A){_.e(A)}finally{_.f()}var E={originator:"remote",type:"offer",sdp:a.body};K.debug('emit "sdp"'),this.emit("sdp",E);var y=new RTCSessionDescription({type:"offer",sdp:E.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===Q.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(y).catch(function(A){throw a.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',A),t.emit("peerconnection:setremotedescriptionfailed",A),A})}).then(function(){if(t._status===Q.STATUS_TERMINATED)throw new Error("terminated");t._remoteHold===!0&&d===!1?(t._remoteHold=!1,t._onunhold("remote")):t._remoteHold===!1&&d===!0&&(t._remoteHold=!0,t._onhold("remote"))}).then(function(){if(t._status===Q.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(A){throw a.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',A),A})}).catch(function(A){K.warn("_processInDialogSdpOffer() failed [error: %o]",A)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(K.debug("receiveRefer()"),!a.refer_to){K.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==ce.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var n=new rp(this,a.cseq);K.debug('emit "refer"'),this.emit("refer",{request:a,accept:function(g,T){d.call(t,g,T)},reject:function(){_.call(t)}});function d(h){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(h=typeof h=="function"?h:null,this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.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=Ve.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(K.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;K.debug("receiveReplaces()");function n(_){var h=this;if(this._status!==Q.STATUS_WAITING_FOR_ACK&&this._status!==Q.STATUS_CONFIRMED)return!1;var g=new r(this._ua);g.on("confirmed",function(){h.terminate()}),g.init_incoming(a,_)}function d(){K.debug("Replaced INVITE rejected by the user"),a.reply(486)}this.emit("replaces",{request:a,accept:function(h){n.call(t,h)},reject:function(){d.call(t)}})}},{key:"_sendInitialRequest",value:function(a,t,n){var d=this,_=new np(this._ua,this._request,{onRequestTimeout:function(){d.onRequestTimeout()},onTransportError:function(){d.onTransportError()},onAuthenticated:function(g){d._request=g},onReceiveResponse:function(g){d._receiveInviteResponse(g)}});Promise.resolve().then(function(){if(n)return n;if(a.audio||a.video)return d._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(function(h){throw d._status===Q.STATUS_TERMINATED?new Error("terminated"):(d._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',h),d.emit("getusermediafailed",h),h)})}).then(function(h){if(d._status===Q.STATUS_TERMINATED)throw new Error("terminated");return d._localMediaStream=h,h&&h.getTracks().forEach(function(g){d._connection.addTrack(g,h)}),d._connecting(d._request),d._createLocalDescription("offer",t).catch(function(g){throw d._failed("local",null,ce.causes.WEBRTC_ERROR),g})}).then(function(h){if(d._is_canceled||d._status===Q.STATUS_TERMINATED)throw new Error("terminated");d._request.body=h,d._status=Q.STATUS_INVITE_SENT,K.debug('emit "sending" [request:%o]',d._request),d.emit("sending",{request:d._request}),_.send()}).catch(function(h){d._status!==Q.STATUS_TERMINATED&&K.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)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(K.debug("receiveInviteResponse()"),this._dialog&&a.status_code>=200&&a.status_code<=299)if(this._dialog.id.call_id===a.call_id&&this._dialog.id.local_tag===a.from_tag&&this._dialog.id.remote_tag===a.to_tag){this.sendRequest(ce.ACK);return}else{var n=new Hl(this,a,"UAC");if(n.error!==void 0){K.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!==Q.STATUS_INVITE_SENT&&this._status!==Q.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(a.status_code):this._status=Q.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(a.status_code):{if(!a.to_tag){K.debug("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this._createDialog(a,"UAC",!0))break;if(this._status=Q.STATUS_1XX_RECEIVED,!a.body){this._progress("remote",a);break}var d={originator:"remote",type:"answer",sdp:a.body};K.debug('emit "sdp"'),this.emit("sdp",d);var _=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(_)}).then(function(){return t._progress("remote",a)}).catch(function(E){K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)});break}case/^2[0-9]{2}$/.test(a.status_code):{if(this._status=Q.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};K.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),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var T=Ve.sipErrorCause(a.status_code);this._failed("remote",a,T)}}}},{key:"_sendReinvite",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.debug("sendReinvite()");var n=Ve.cloneArray(t.extraHeaders),d=Ve.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};K.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!==Q.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};K.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(){d.succeeded&&d.succeeded(E)}).catch(function(I){T.call(y),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',I),y.emit("peerconnection:setremotedescriptionfailed",I)})}}function T(E){d.failed&&d.failed(E)}}},{key:"_sendUpdate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};K.debug("sendUpdate()");var n=Ve.cloneArray(t.extraHeaders),d=Ve.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};K.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!==Q.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};K.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(){d.succeeded&&d.succeeded(y)}).catch(function(H){E.call(A),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',H),A.emit("peerconnection:setremotedescriptionfailed",H)})}else d.succeeded&&d.succeeded(y)}function E(y){d.failed&&d.failed(y)}}},{key:"_acceptAndTerminate",value:function(a,t,n){K.debug("acceptAndTerminate()");var d=[];t&&(n=n||ce.REASON_PHRASE[t]||"",d.push("Reason: SIP ;cause=".concat(t,'; text="').concat(n,'"'))),(this._dialog||this._createDialog(a,"UAC"))&&(this.sendRequest(ce.ACK),this.sendRequest(ce.BYE,{extraHeaders:d})),this._status=Q.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(a){if(!this._localHold&&!this._remoteHold)return a;if(a=Ic.parse(a),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");var t=_s(a.media),n;try{for(t.s();!(n=t.n()).done;){var d=n.value;Fl.indexOf(d.type)!==-1&&(d.direction?d.direction==="sendrecv"?d.direction="sendonly":d.direction==="recvonly"&&(d.direction="inactive"):d.direction="sendonly")}}catch(A){t.e(A)}finally{t.f()}}else if(this._localHold&&this._remoteHold){K.debug("mangleOffer() | both on hold, mangling offer");var _=_s(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){K.debug("mangleOffer() | remote on hold, mangling offer");var T=_s(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 Ic.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!==Q.STATUS_TERMINATED&&a._isReadyToReOffer()&&(K.debug("runSessionTimer() | sending session refresh request"),a._sessionTimers.refreshMethod===ce.UPDATE?a._sendUpdate():a._sendReinvite())},t*500):this._sessionTimers.timer=setTimeout(function(){a._status!==Q.STATUS_TERMINATED&&(K.warn("runSessionTimer() | timer expired, terminating the session"),a.terminate({cause:ce.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},t*1100)}},{key:"_toggleMuteAudio",value:function(a){var t=this._connection.getSenders().filter(function(h){return h.track&&h.track.kind==="audio"}),n=_s(t),d;try{for(n.s();!(d=n.n()).done;){var _=d.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=_s(t),d;try{for(n.s();!(d=n.n()).done;){var _=d.value;_.track.enabled=!a}}catch(h){n.e(h)}finally{n.f()}}},{key:"_newRTCSession",value:function(a,t){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,n){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:n})}},{key:"_failed",value:function(a,t,n){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:n}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:n})}},{key:"_onhold",value:function(a){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,n=a.video;K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(a){var t=a.audio,n=a.video;K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return Q}},{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}(ep);function So(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?So=function(r){return typeof r}:So=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},So(c)}function op(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 ap(c,s,r){return s&&Dc(c.prototype,s),r&&Dc(c,r),c}function up(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&&_u(c,s)}function _u(c,s){return _u=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},_u(c,s)}function cp(c){var s=hp();return function(){var o=Uo(c),a;if(s){var t=Uo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return fp(this,a)}}function fp(c,s){return s&&(So(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 hp(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Uo(c){return Uo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Uo(c)}var dp=ft.EventEmitter,pp=_t,Sa=it,mp=vs,Ui=bt(),gp=ul,Nc=Bs,Tp=Gs(),jl=new pp("Message"),vp=function(c){up(r,c);var s=cp(r);function r(o){var a;return op(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 ap(r,[{key:"send",value:function(a,t){var n=this,d=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=Ui.cloneArray(d.extraHeaders),g=Ui.cloneObject(d.eventHandlers),T=d.contentType||"text/plain",E={};d.fromUserName&&(E.from_uri=new Tp("sip",d.fromUserName,this._ua.configuration.uri.host),h.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),d.fromDisplayName&&(E.from_display_name=d.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 mp.OutgoingRequest(Sa.MESSAGE,a,this._ua,E,h),t&&(this._request.body=t);var A=new gp(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=Ui.cloneArray(a.extraHeaders),n=a.body;if(this._direction!=="incoming")throw new Nc.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,d=Ui.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new Nc.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,d,_)}},{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=Ui.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,Sa.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,Sa.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(a,t){a==="remote"?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):a==="local"&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:a,message:this,request:t})}},{key:"_failed",value:function(a,t,n){jl.debug("MESSAGE failed"),this._close(),jl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:n})}},{key:"_succeeded",value:function(a,t){jl.debug("MESSAGE succeeded"),this._close(),jl.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),r}(dp);function yo(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?yo=function(r){return typeof r}:yo=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},yo(c)}function Ep(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 Sp(c,s,r){return s&&Uc(c.prototype,s),r&&Uc(c,r),c}function yp(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&&hu(c,s)}function hu(c,s){return hu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},hu(c,s)}function Ap(c){var s=Ip();return function(){var o=Po(c),a;if(s){var t=Po(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Cp(this,a)}}function Cp(c,s){return s&&(yo(s)==="object"||typeof s=="function")?s:Rp(c)}function Rp(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Ip(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Po(c){return Po=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Po(c)}var bp=ft.EventEmitter,wp=_t,ya=it,Op=vs,Pi=bt(),Dp=ul,Pc=Bs,ql=new wp("Options"),Np=function(c){yp(r,c);var s=Ap(r);function r(o){var a;return Ep(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,d=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=Pi.cloneArray(d.extraHeaders),g=Pi.cloneObject(d.eventHandlers),T=d.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 Op.OutgoingRequest(ya.OPTIONS,a,this._ua,null,h),t&&(this._request.body=t);var y=new Dp(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=Pi.cloneArray(a.extraHeaders),n=a.body;if(this._direction!=="incoming")throw new Pc.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,d=Pi.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new Pc.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,d,_)}},{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=Pi.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,ya.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,ya.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){ql.debug("OPTIONS 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("OPTIONS 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}(bp),Ou={},Up=_t,Aa=bt(),Pp=is(),xi=new Up("Socket");Ou.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return xi.warn("undefined JsSIP.Socket instance"),!1;try{if(!Aa.isString(c.url))throw xi.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!Aa.isString(c.via_transport))throw xi.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 xi.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(!Aa.isFunction(c[s]))throw xi.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 xp(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 Mp(c,s,r){return s&&xc(c.prototype,s),r&&xc(c,r),c}var kp=_t,Lp=Ou,Mc=it,Nt=new kp("Transport"),jt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Mc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Mc.CONNECTION_RECOVERY_MAX_INTERVAL}},$p=function(){function c(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jt.recovery_options;xp(this,c),Nt.debug("new()"),this.status=jt.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(!Lp.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:jt.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=jt.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=jt.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(v)}}]),a}(lh),M_=function(u){xu(a,u);var n=Pu(a);function a(){var e;return Gi(this,a),e=n.call(this),e.headers={},e.status_code=null,e.reason_phrase=null,e}return a}(lh),Vn={OutgoingRequest:nh,InitialOutgoingInviteRequest:x_,IncomingRequest:P_,IncomingResponse:M_};function k_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function rc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function L_(u,n,a){return n&&rc(u.prototype,n),a&&rc(u,a),u}var $_=yt,Pn=qt(),qs=new $_("DigestAuthentication"),H_=function(){function u(n){k_(this,u),this._credentials=n,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}return L_(u,[{key:"get",value:function(a){switch(a){case"realm":return this._realm;case"ha1":return this._ha1;default:qs.warn('get() | cannot get "%s" parameter',a);return}}},{key:"authenticate",value:function(a,e){var o=a.method,p=a.ruri,t=a.body,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(this._algorithm=e.algorithm,this._realm=e.realm,this._nonce=e.nonce,this._opaque=e.opaque,this._stale=e.stale,this._algorithm){if(this._algorithm!=="MD5")return qs.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return qs.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return qs.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return qs.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return qs.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(e.qop)if(e.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(e.qop.indexOf("auth")>-1)this._qop="auth";else return qs.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=o,this._uri=p,this._cnonce=v||Pn.createRandomToken(12),this._nc+=1;var C=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-C.length)+C,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=Pn.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1;var l,A;return this._qop==="auth"?(l="".concat(this._method,":").concat(this._uri),A=Pn.calculateMD5(l),qs.debug('authenticate() | using qop=auth [a2:"%s"]',l),this._response=Pn.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(A))):this._qop==="auth-int"?(l="".concat(this._method,":").concat(this._uri,":").concat(Pn.calculateMD5(t||"")),A=Pn.calculateMD5(l),qs.debug('authenticate() | using qop=auth-int [a2:"%s"]',l),this._response=Pn.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(A))):this._qop===null&&(l="".concat(this._method,":").concat(this._uri),A=Pn.calculateMD5(l),qs.debug('authenticate() | using qop=null [a2:"%s"]',l),this._response=Pn.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(A))),qs.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var a=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return a.push("algorithm=".concat(this._algorithm)),a.push('username="'.concat(this._credentials.username,'"')),a.push('realm="'.concat(this._realm,'"')),a.push('nonce="'.concat(this._nonce,'"')),a.push('uri="'.concat(this._uri,'"')),a.push('response="'.concat(this._response,'"')),this._opaque&&a.push('opaque="'.concat(this._opaque,'"')),this._qop&&(a.push("qop=".concat(this._qop)),a.push('cnonce="'.concat(this._cnonce,'"')),a.push("nc=".concat(this._ncHex))),"Digest ".concat(a.join(", "))}}]),u}(),Mn=500,F_=4e3,ic=5e3,rh={T1:Mn,T2:F_,T4:ic,TIMER_B:64*Mn,TIMER_D:0*Mn,TIMER_F:64*Mn,TIMER_H:64*Mn,TIMER_I:0*Mn,TIMER_J:0*Mn,TIMER_K:0*ic,TIMER_L:64*Mn,TIMER_M:64*Mn,PROVISIONAL_RESPONSE_INTERVAL:6e4};function La(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?La=function(a){return typeof a}:La=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},La(u)}function Wi(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function ac(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Ki(u,n,a){return n&&ac(u.prototype,n),a&&ac(u,a),u}function Yi(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&du(u,n)}function du(u,n){return du=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},du(u,n)}function zi(u){var n=j_();return function(){var e=Ya(u),o;if(n){var p=Ya(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return q_(this,o)}}function q_(u,n){return n&&(La(n)==="object"||typeof n=="function")?n:Jl(u)}function Jl(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function j_(){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 Ya(u){return Ya=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Ya(u)}var Ji=At.EventEmitter,Xi=yt,ki=vt,oc=Vn,fn=rh,uc=new Xi("NonInviteClientTransaction"),na=new Xi("InviteClientTransaction"),V_=new Xi("AckClientTransaction"),cc=new Xi("NonInviteServerTransaction"),la=new Xi("InviteServerTransaction"),Te={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"},B_=function(u){Yi(a,u);var n=zi(a);function a(e,o,p,t){var v;Wi(this,a),v=n.call(this),v.type=Te.NON_INVITE_CLIENT,v.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),v.ua=e,v.transport=o,v.request=p,v.eventHandlers=t;var C="SIP/2.0/".concat(o.via_transport);return C+=" ".concat(e.configuration.via_host,";branch=").concat(v.id),v.request.setHeader("via",C),v.ua.newTransaction(Jl(v)),v}return Ki(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"send",value:function(){var o=this;this.stateChanged(Te.STATUS_TRYING),this.F=setTimeout(function(){o.timer_F()},fn.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){uc.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){uc.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(o){var p=this,t=o.status_code;if(t<200)switch(this.state){case Te.STATUS_TRYING:case Te.STATUS_PROCEEDING:this.stateChanged(Te.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(o);break}else switch(this.state){case Te.STATUS_TRYING:case Te.STATUS_PROCEEDING:this.stateChanged(Te.STATUS_COMPLETED),clearTimeout(this.F),t===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(o),this.K=setTimeout(function(){p.timer_K()},fn.TIMER_K);break;case Te.STATUS_COMPLETED:break}}},{key:"C",get:function(){return Te}}]),a}(Ji),G_=function(u){Yi(a,u);var n=zi(a);function a(e,o,p,t){var v;Wi(this,a),v=n.call(this),v.type=Te.INVITE_CLIENT,v.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),v.ua=e,v.transport=o,v.request=p,v.eventHandlers=t,p.transaction=Jl(v);var C="SIP/2.0/".concat(o.via_transport);return C+=" ".concat(e.configuration.via_host,";branch=").concat(v.id),v.request.setHeader("via",C),v.ua.newTransaction(Jl(v)),v}return Ki(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"send",value:function(){var o=this;this.stateChanged(Te.STATUS_CALLING),this.B=setTimeout(function(){o.timer_B()},fn.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==Te.STATUS_ACCEPTED&&(na.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){na.debug("Timer M expired for transaction ".concat(this.id)),this.state===Te.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){na.debug("Timer B expired for transaction ".concat(this.id)),this.state===Te.STATUS_CALLING&&(this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){na.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(o){var p=this,t=new oc.OutgoingRequest(ki.ACK,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",o.getHeader("to")),this.D=setTimeout(function(){p.timer_D()},fn.TIMER_D),this.transport.send(t)}},{key:"cancel",value:function(o){if(this.state===Te.STATUS_PROCEEDING){var p=new oc.OutgoingRequest(ki.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});p.setHeader("from",this.request.getHeader("from")),p.setHeader("via",this.request.getHeader("via")),p.setHeader("to",this.request.getHeader("to")),o&&p.setHeader("reason",o),this.transport.send(p)}}},{key:"receiveResponse",value:function(o){var p=this,t=o.status_code;if(t>=100&&t<=199)switch(this.state){case Te.STATUS_CALLING:this.stateChanged(Te.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(o);break;case Te.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(o);break}else if(t>=200&&t<=299)switch(this.state){case Te.STATUS_CALLING:case Te.STATUS_PROCEEDING:this.stateChanged(Te.STATUS_ACCEPTED),this.M=setTimeout(function(){p.timer_M()},fn.TIMER_M),this.eventHandlers.onReceiveResponse(o);break;case Te.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(o);break}else if(t>=300&&t<=699)switch(this.state){case Te.STATUS_CALLING:case Te.STATUS_PROCEEDING:this.stateChanged(Te.STATUS_COMPLETED),this.sendACK(o),this.eventHandlers.onReceiveResponse(o);break;case Te.STATUS_COMPLETED:this.sendACK(o);break}}},{key:"C",get:function(){return Te}}]),a}(Ji),W_=function(u){Yi(a,u);var n=zi(a);function a(e,o,p,t){var v;Wi(this,a),v=n.call(this),v.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),v.transport=o,v.request=p,v.eventHandlers=t;var C="SIP/2.0/".concat(o.via_transport);return C+=" ".concat(e.configuration.via_host,";branch=").concat(v.id),v.request.setHeader("via",C),v}return Ki(a,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){V_.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return Te}}]),a}(Ji),K_=function(u){Yi(a,u);var n=zi(a);function a(e,o,p){var t;return Wi(this,a),t=n.call(this),t.type=Te.NON_INVITE_SERVER,t.id=p.via_branch,t.ua=e,t.transport=o,t.request=p,t.last_response="",p.server_transaction=Jl(t),t.state=Te.STATUS_TRYING,e.newTransaction(Jl(t)),t}return Ki(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"timer_J",value:function(){cc.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,cc.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(o,p,t,v){var C=this;if(o===100)switch(this.state){case Te.STATUS_TRYING:this.stateChanged(Te.STATUS_PROCEEDING),this.transport.send(p)||this.onTransportError();break;case Te.STATUS_PROCEEDING:this.last_response=p,this.transport.send(p)?t&&t():(this.onTransportError(),v&&v());break}else if(o>=200&&o<=699)switch(this.state){case Te.STATUS_TRYING:case Te.STATUS_PROCEEDING:this.stateChanged(Te.STATUS_COMPLETED),this.last_response=p,this.J=setTimeout(function(){C.timer_J()},fn.TIMER_J),this.transport.send(p)?t&&t():(this.onTransportError(),v&&v());break;case Te.STATUS_COMPLETED:break}}},{key:"C",get:function(){return Te}}]),a}(Ji),Y_=function(u){Yi(a,u);var n=zi(a);function a(e,o,p){var t;return Wi(this,a),t=n.call(this),t.type=Te.INVITE_SERVER,t.id=p.via_branch,t.ua=e,t.transport=o,t.request=p,t.last_response="",p.server_transaction=Jl(t),t.state=Te.STATUS_PROCEEDING,e.newTransaction(Jl(t)),t.resendProvisionalTimer=null,p.reply(100),t}return Ki(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"timer_H",value:function(){la.debug("Timer H expired for transaction ".concat(this.id)),this.state===Te.STATUS_COMPLETED&&la.debug("ACK not received, dialog will be terminated"),this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){la.debug("Timer L expired for transaction ".concat(this.id)),this.state===Te.STATUS_ACCEPTED&&(this.stateChanged(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,la.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(Te.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(o,p,t,v){var C=this;if(o>=100&&o<=199)switch(this.state){case Te.STATUS_PROCEEDING:this.transport.send(p)||this.onTransportError(),this.last_response=p;break}if(o>100&&o<=199&&this.state===Te.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){C.resend_provisional()},fn.PROVISIONAL_RESPONSE_INTERVAL));else if(o>=200&&o<=299)switch(this.state){case Te.STATUS_PROCEEDING:this.stateChanged(Te.STATUS_ACCEPTED),this.last_response=p,this.L=setTimeout(function(){C.timer_L()},fn.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case Te.STATUS_ACCEPTED:this.transport.send(p)?t&&t():(this.onTransportError(),v&&v());break}else if(o>=300&&o<=699)switch(this.state){case Te.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(p)?(this.stateChanged(Te.STATUS_COMPLETED),this.H=setTimeout(function(){C.timer_H()},fn.TIMER_H),t&&t()):(this.onTransportError(),v&&v());break}}},{key:"C",get:function(){return Te}}]),a}(Ji);function z_(u,n){var a=u._transactions,e;switch(n.method){case ki.INVITE:if(e=a.ist[n.via_branch],e){switch(e.state){case Te.STATUS_PROCEEDING:e.transport.send(e.last_response);break;case Te.STATUS_ACCEPTED:break}return!0}break;case ki.ACK:if(e=a.ist[n.via_branch],e){if(e.state===Te.STATUS_ACCEPTED)return!1;if(e.state===Te.STATUS_COMPLETED)return e.state=Te.STATUS_CONFIRMED,e.I=setTimeout(function(){e.timer_I()},fn.TIMER_I),!0}else return!1;break;case ki.CANCEL:return e=a.ist[n.via_branch],e?(n.reply_sl(200),e.state!==Te.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:if(e=a.nist[n.via_branch],e){switch(e.state){case Te.STATUS_TRYING:break;case Te.STATUS_PROCEEDING:case Te.STATUS_COMPLETED:e.transport.send(e.last_response);break}return!0}break}}var Qi={C:Te,NonInviteClientTransaction:B_,InviteClientTransaction:G_,AckClientTransaction:W_,NonInviteServerTransaction:K_,InviteServerTransaction:Y_,checkTransaction:z_};function J_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function fc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function X_(u,n,a){return n&&fc(u.prototype,n),a&&fc(u,a),u}var Q_=yt,hc=vt,Z_=H_,Co=Qi,ed=new Q_("RequestSender"),So={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Zi=function(){function u(n,a,e){J_(this,u),this._ua=n,this._eventHandlers=e,this._method=a.method,this._request=a,this._auth=null,this._challenged=!1,this._staled=!1;for(var o in So)Object.prototype.hasOwnProperty.call(So,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=So[o]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==hc.BYE||this._method!==hc.ACK)&&this._eventHandlers.onTransportError()}return X_(u,[{key:"send",value:function(){var a=this,e={onRequestTimeout:function(){a._eventHandlers.onRequestTimeout()},onTransportError:function(){a._eventHandlers.onTransportError()},onReceiveResponse:function(p){a._receiveResponse(p)}};switch(this._method){case"INVITE":this.clientTransaction=new Co.InviteClientTransaction(this._ua,this._ua.transport,this._request,e);break;case"ACK":this.clientTransaction=new Co.AckClientTransaction(this._ua,this._ua.transport,this._request,e);break;default:this.clientTransaction=new Co.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,e)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(a){var e,o,p=a.status_code;if((p===401||p===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(a.status_code===401?(e=a.parseHeader("www-authenticate"),o="authorization"):(e=a.parseHeader("proxy-authenticate"),o="proxy-authorization"),!e){ed.debug("".concat(a.status_code," with wrong or missing challenge, cannot authenticate")),this._eventHandlers.onReceiveResponse(a);return}if(!this._challenged||!this._staled&&e.stale===!0){if(this._auth||(this._auth=new Z_({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,e)){this._eventHandlers.onReceiveResponse(a);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),e.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(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(a)}else this._eventHandlers.onReceiveResponse(a)}}]),u}();function td(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function _c(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function sd(u,n,a){return n&&_c(u.prototype,n),a&&_c(u,a),u}var nd=yt,Ao=qt(),Rr=vt,dc=Vn,pc=Zi,gi=new nd("Registrator"),ra=10,ld=function(){function u(n,a){td(this,u),this._reg_id=1,this._ua=n,this._transport=a,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=Ao.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance='"<urn:uuid:'.concat(this._ua.configuration.instance_id,'>"'),this._contact+=";reg-id=".concat(this._reg_id),this._contact+=";+sip.instance=".concat(this._sipInstance)}return sd(u,[{key:"setExtraHeaders",value:function(a){Array.isArray(a)||(a=[]),this._extraHeaders=a.slice()}},{key:"setExtraContactParams",value:function(a){a instanceof Object||(a={}),this._extraContactParams="";for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var o=a[e];this._extraContactParams+=";".concat(e),o&&(this._extraContactParams+="=".concat(o))}}},{key:"register",value:function(){var a=this;if(this._registering){gi.debug("Register request in progress...");return}var e=this._extraHeaders.slice();e.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),e.push("Expires: ".concat(this._expires));var o=new dc.OutgoingRequest(Rr.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},e),p=new pc(this._ua,o,{onRequestTimeout:function(){a._registrationFailure(null,Rr.causes.REQUEST_TIMEOUT)},onTransportError:function(){a._registrationFailure(null,Rr.causes.CONNECTION_ERROR)},onAuthenticated:function(){a._cseq+=1},onReceiveResponse:function(v){if(v.cseq===a._cseq)switch(a._registrationTimer!==null&&(clearTimeout(a._registrationTimer),a._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(v.status_code):break;case/^2[0-9]{2}$/.test(v.status_code):{if(a._registering=!1,!v.hasHeader("Contact")){gi.debug("no Contact header in response to REGISTER, response ignored");break}var C=v.headers.Contact.reduce(function(O,w){return O.concat(w.parsed)},[]),l=C.find(function(O){return a._sipInstance===O.getParam("+sip.instance")&&a._reg_id===parseInt(O.getParam("reg-id"))});if(l||(l=C.find(function(O){return O.uri.user===a._ua.contact.uri.user})),!l){gi.debug("no Contact header pointing to us, response ignored");break}var A=l.getParam("expires");!A&&v.hasHeader("expires")&&(A=v.getHeader("expires")),A||(A=a._expires),A=Number(A),A<ra&&(A=ra);var b=A>64?A*1e3/2+Math.floor((A/2-32)*1e3*Math.random()):A*1e3-5e3;a._registrationTimer=setTimeout(function(){a._registrationTimer=null,a._ua.listeners("registrationExpiring").length===0?a.register():a._ua.emit("registrationExpiring")},b),l.hasParam("temp-gruu")&&(a._ua.contact.temp_gruu=l.getParam("temp-gruu").replace(/"/g,"")),l.hasParam("pub-gruu")&&(a._ua.contact.pub_gruu=l.getParam("pub-gruu").replace(/"/g,"")),a._registered||(a._registered=!0,a._ua.registered({response:v}));break}case/^423$/.test(v.status_code):{v.hasHeader("min-expires")?(a._expires=Number(v.getHeader("min-expires")),a._expires<ra&&(a._expires=ra),a.register()):(gi.debug("423 response received for REGISTER without Min-Expires"),a._registrationFailure(v,Rr.causes.SIP_FAILURE_CODE));break}default:{var E=Ao.sipErrorCause(v.status_code);a._registrationFailure(v,E)}}}});this._registering=!0,p.send()}},{key:"unregister",value:function(){var a=this,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){gi.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var o=this._extraHeaders.slice();e.all?o.push("Contact: *".concat(this._extraContactParams)):o.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),o.push("Expires: 0");var p=new dc.OutgoingRequest(Rr.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new pc(this._ua,p,{onRequestTimeout:function(){a._unregistered(null,Rr.causes.REQUEST_TIMEOUT)},onTransportError:function(){a._unregistered(null,Rr.causes.CONNECTION_ERROR)},onAuthenticated:function(){a._cseq+=1},onReceiveResponse:function(C){switch(!0){case/^1[0-9]{2}$/.test(C.status_code):break;case/^2[0-9]{2}$/.test(C.status_code):a._unregistered(C);break;default:{var l=Ao.sipErrorCause(C.status_code);a._unregistered(C,l)}}}});t.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(a,e){this._registering=!1,this._ua.registrationFailed({response:a||null,cause:e}),this._registered&&(this._registered=!1,this._ua.unregistered({response:a||null,cause:e}))}},{key:"_unregistered",value:function(a,e){this._registering=!1,this._registered=!1,this._ua.unregistered({response:a||null,cause:e||null})}},{key:"registered",get:function(){return this._registered}}]),u}();function rd(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function mc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function id(u,n,a){return n&&mc(u.prototype,n),a&&mc(u,a),u}var yo=vt,ia=Qi,ad=Zi,Ro={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},od=function(){function u(n,a,e){rd(this,u),this._dialog=n,this._ua=n._ua,this._request=a,this._eventHandlers=e,this._reattempt=!1,this._reattemptTimer=null;for(var o in Ro)Object.prototype.hasOwnProperty.call(Ro,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=Ro[o]))}return id(u,[{key:"send",value:function(){var a=this,e=new ad(this._ua,this._request,{onRequestTimeout:function(){a._eventHandlers.onRequestTimeout()},onTransportError:function(){a._eventHandlers.onTransportError()},onAuthenticated:function(t){a._eventHandlers.onAuthenticated(t)},onReceiveResponse:function(t){a._receiveResponse(t)}});if(e.send(),(this._request.method===yo.INVITE||this._request.method===yo.UPDATE&&this._request.body)&&e.clientTransaction.state!==ia.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var o=function p(){(e.clientTransaction.state===ia.C.STATUS_ACCEPTED||e.clientTransaction.state===ia.C.STATUS_COMPLETED||e.clientTransaction.state===ia.C.STATUS_TERMINATED)&&(e.clientTransaction.removeListener("stateChanged",p),a._dialog.uac_pending_reply=!1)};e.clientTransaction.on("stateChanged",o)}}},{key:"_receiveResponse",value:function(a){var e=this;a.status_code===408||a.status_code===481?this._eventHandlers.onDialogError(a):a.method===yo.INVITE&&a.status_code===491?this._reattempt?a.status_code>=200&&a.status_code<300?this._eventHandlers.onSuccessResponse(a):a.status_code>=300&&this._eventHandlers.onErrorResponse(a):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){e._dialog.isTerminated()||(e._reattempt=!0,e.send())},1e3)):a.status_code>=200&&a.status_code<300?this._eventHandlers.onSuccessResponse(a):a.status_code>=300&&this._eventHandlers.onErrorResponse(a)}},{key:"request",get:function(){return this._request}}]),u}();function ud(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function gc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function vc(u,n,a){return n&&gc(u.prototype,n),a&&gc(u,a),u}var cd=yt,Tc=Vn,ql=vt,vi=Qi,fd=od,bo=qt(),Io=new cd("Dialog"),jl={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},hd=function(){vc(u,null,[{key:"C",get:function(){return jl}}]);function u(n,a,e){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:jl.STATUS_CONFIRMED;if(ud(this,u),this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!a.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};a instanceof Tc.IncomingResponse&&(o=a.status_code<200?jl.STATUS_EARLY:jl.STATUS_CONFIRMED);var p=a.parseHeader("contact");e==="UAS"?(this._id={call_id:a.call_id,local_tag:a.to_tag,remote_tag:a.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._remote_seqnum=a.cseq,this._local_uri=a.parseHeader("to").uri,this._remote_uri=a.parseHeader("from").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):e==="UAC"&&(this._id={call_id:a.call_id,local_tag:a.from_tag,remote_tag:a.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._local_seqnum=a.cseq,this._local_uri=a.parseHeader("from").uri,this._remote_uri=a.parseHeader("to").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Io.debug("new ".concat(e," dialog created with status ").concat(this._state===jl.STATUS_EARLY?"EARLY":"CONFIRMED"))}return vc(u,[{key:"isTerminated",value:function(){return this._status===jl.STATUS_TERMINATED}},{key:"update",value:function(a,e){this._state=jl.STATUS_CONFIRMED,Io.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),e==="UAC"&&(this._route_set=a.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){Io.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=jl.STATUS_TERMINATED}},{key:"sendRequest",value:function(a){var e=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},p=bo.cloneArray(o.extraHeaders),t=bo.cloneObject(o.eventHandlers),v=o.body||null,C=this._createRequest(a,p,v);t.onAuthenticated=function(){e._local_seqnum+=1};var l=new fd(this,C,t);return l.send(),C}},{key:"receiveRequest",value:function(a){this._checkInDialogRequest(a)&&(a.method===ql.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:a.method===ql.INVITE&&(this._ack_seqnum=a.cseq),this._owner.receiveRequest(a))}},{key:"_createRequest",value:function(a,e,o){e=bo.cloneArray(e),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var p=a===ql.CANCEL||a===ql.ACK?this._local_seqnum:this._local_seqnum+=1,t=new Tc.OutgoingRequest(a,this._remote_target,this._ua,{cseq:p,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},e,o);return t}},{key:"_checkInDialogRequest",value:function(a){var e=this;if(!this._remote_seqnum)this._remote_seqnum=a.cseq;else if(a.cseq<this._remote_seqnum)if(a.method===ql.ACK){if(this._ack_seqnum===null||a.cseq!==this._ack_seqnum)return!1}else return a.reply(500),!1;else a.cseq>this._remote_seqnum&&(this._remote_seqnum=a.cseq);if(a.method===ql.INVITE||a.method===ql.UPDATE&&a.body){if(this._uac_pending_reply===!0)a.reply(491);else if(this._uas_pending_reply===!0){var o=(Math.random()*10|0)+1;return a.reply(500,null,["Retry-After:".concat(o)]),!1}else{this._uas_pending_reply=!0;var p=function t(){(a.server_transaction.state===vi.C.STATUS_ACCEPTED||a.server_transaction.state===vi.C.STATUS_COMPLETED||a.server_transaction.state===vi.C.STATUS_TERMINATED)&&(a.server_transaction.removeListener("stateChanged",t),e._uas_pending_reply=!1)};a.server_transaction.on("stateChanged",p)}a.hasHeader("contact")&&a.server_transaction.on("stateChanged",function(){a.server_transaction.state===vi.C.STATUS_ACCEPTED&&(e._remote_target=a.parseHeader("contact").uri)})}else a.method===ql.NOTIFY&&a.hasHeader("contact")&&a.server_transaction.on("stateChanged",function(){a.server_transaction.state===vi.C.STATUS_COMPLETED&&(e._remote_target=a.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(a){this._local_seqnum=a}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(a){this._uac_pending_reply=a}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),u}(),Mu={exports:{}};function $a(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$a=function(a){return typeof a}:$a=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},$a(u)}function _d(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Ec(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function dd(u,n,a){return n&&Ec(u.prototype,n),a&&Ec(u,a),u}function pd(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&pu(u,n)}function pu(u,n){return pu=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},pu(u,n)}function md(u){var n=Td();return function(){var e=za(u),o;if(n){var p=za(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return gd(this,o)}}function gd(u,n){return n&&($a(n)==="object"||typeof n=="function")?n:vd(u)}function vd(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function Td(){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 za(u){return za=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},za(u)}var Ed=At.EventEmitter,Cd=yt,Sd=vt,Ad=Ql,Cc=qt(),yd=new Cd("RTCSession:DTMF"),ih={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Mu.exports=function(u){pd(a,u);var n=md(a);function a(e){var o;return _d(this,a),o=n.call(this),o._session=e,o._direction=null,o._tone=null,o._duration=null,o._request=null,o}return dd(a,[{key:"send",value:function(o){var p=this,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(o===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 Ad.InvalidStateError(this._session.status);var v=Cc.cloneArray(t.extraHeaders);if(this.eventHandlers=Cc.cloneObject(t.eventHandlers),typeof o=="string")o=o.toUpperCase();else if(typeof o=="number")o=o.toString();else throw new TypeError("Invalid tone: ".concat(o));if(o.match(/^[0-9A-DR#*]$/))this._tone=o;else throw new TypeError("Invalid tone: ".concat(o));this._duration=t.duration,v.push("Content-Type: application/dtmf-relay");var C="Signal=".concat(this._tone,`\r
47
+ `);C+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(Sd.INFO,{extraHeaders:v,eventHandlers:{onSuccessResponse:function(A){p.emit("succeeded",{originator:"remote",response:A})},onErrorResponse:function(A){p.eventHandlers.onFailed&&p.eventHandlers.onFailed(),p.emit("failed",{originator:"remote",response:A})},onRequestTimeout:function(){p._session.onRequestTimeout()},onTransportError:function(){p._session.onTransportError()},onDialogError:function(){p._session.onDialogError()}},body:C})}},{key:"init_incoming",value:function(o){var p=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,t=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=o,o.reply(200),o.body){var v=o.body.split(`
48
+ `);v.length>=1&&p.test(v[0])&&(this._tone=v[0].replace(p,"$2")),v.length>=2&&t.test(v[1])&&(this._duration=parseInt(v[1].replace(t,"$2"),10))}this._duration||(this._duration=ih.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:o}):yd.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),a}(Ed);Mu.exports.C=ih;var Rd=Mu.exports;function Ha(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ha=function(a){return typeof a}:Ha=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Ha(u)}function bd(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Sc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Id(u,n,a){return n&&Sc(u.prototype,n),a&&Sc(u,a),u}function wd(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&mu(u,n)}function mu(u,n){return mu=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},mu(u,n)}function Od(u){var n=Ud();return function(){var e=Ja(u),o;if(n){var p=Ja(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return Dd(this,o)}}function Dd(u,n){return n&&(Ha(n)==="object"||typeof n=="function")?n:Nd(u)}function Nd(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function Ud(){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 Ja(u){return Ja=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Ja(u)}var xd=At.EventEmitter,Pd=vt,Md=Ql,kd=qt(),Ld=function(u){wd(a,u);var n=Od(a);function a(e){var o;return bd(this,a),o=n.call(this),o._session=e,o._direction=null,o._contentType=null,o._body=null,o}return Id(a,[{key:"send",value:function(o,p){var t=this,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this._direction="outgoing",o===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 Md.InvalidStateError(this._session.status);this._contentType=o,this._body=p;var C=kd.cloneArray(v.extraHeaders);C.push("Content-Type: ".concat(o)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(Pd.INFO,{extraHeaders:C,eventHandlers:{onSuccessResponse:function(A){t.emit("succeeded",{originator:"remote",response:A})},onErrorResponse:function(A){t.emit("failed",{originator:"remote",response:A})},onTransportError:function(){t._session.onTransportError()},onRequestTimeout:function(){t._session.onRequestTimeout()},onDialogError:function(){t._session.onDialogError()}},body:p})}},{key:"init_incoming",value:function(o){this._direction="incoming",this.request=o,o.reply(200),this._contentType=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,this._body=o.body,this._session.newInfo({originator:"remote",info:this,request:o})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),a}(xd);function $d(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Ac(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Hd(u,n,a){return n&&Ac(u.prototype,n),a&&Ac(u,a),u}var Fd=yt,yc=vt,qd=new Fd("RTCSession:ReferNotifier"),wo={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300},jd=function(){function u(n,a,e){$d(this,u),this._session=n,this._id=a,this._expires=e||wo.expires,this._active=!0,this.notify(100)}return Hd(u,[{key:"notify",value:function(a,e){if(qd.debug("notify()"),this._active!==!1){e=e||yc.REASON_PHRASE[a]||"";var o;a>=200?o="terminated;reason=noresource":o="active;expires=".concat(this._expires),this._session.sendRequest(yc.NOTIFY,{extraHeaders:["Event: ".concat(wo.event_type,";id=").concat(this._id),"Subscription-State: ".concat(o),"Content-Type: ".concat(wo.body_type)],body:"SIP/2.0 ".concat(a," ").concat(e),eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),u}();function Fa(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Fa=function(a){return typeof a}:Fa=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Fa(u)}function Vd(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Rc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Bd(u,n,a){return n&&Rc(u.prototype,n),a&&Rc(u,a),u}function Gd(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&gu(u,n)}function gu(u,n){return gu=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},gu(u,n)}function Wd(u){var n=zd();return function(){var e=Xa(u),o;if(n){var p=Xa(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return Kd(this,o)}}function Kd(u,n){return n&&(Fa(n)==="object"||typeof n=="function")?n:Yd(u)}function Yd(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}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 Xa(u){return Xa=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Xa(u)}var Jd=At.EventEmitter,Xd=yt,Ti=vt,Qd=_n(),bc=qt(),br=new Xd("RTCSession:ReferSubscriber"),Zd=function(u){Gd(a,u);var n=Wd(a);function a(e){var o;return Vd(this,a),o=n.call(this),o._id=null,o._session=e,o}return Bd(a,[{key:"sendRefer",value:function(o){var p=this,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};br.debug("sendRefer()");var v=bc.cloneArray(t.extraHeaders),C=bc.cloneObject(t.eventHandlers);for(var l in C)Object.prototype.hasOwnProperty.call(C,l)&&this.on(l,C[l]);var A=null;t.replaces&&(A=t.replaces._request.call_id,A+=";to-tag=".concat(t.replaces._to_tag),A+=";from-tag=".concat(t.replaces._from_tag),A=encodeURIComponent(A));var b="Refer-To: <".concat(o).concat(A?"?Replaces=".concat(A):"",">");if(v.push(b),!v.some(function(w){return w.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,">");v.push(E)}v.push("Contact: ".concat(this._session.contact));var O=this._session.sendRequest(Ti.REFER,{extraHeaders:v,eventHandlers:{onSuccessResponse:function(N){p._requestSucceeded(N)},onErrorResponse:function(N){p._requestFailed(N,Ti.causes.REJECTED)},onTransportError:function(){p._requestFailed(null,Ti.causes.CONNECTION_ERROR)},onRequestTimeout:function(){p._requestFailed(null,Ti.causes.REQUEST_TIMEOUT)},onDialogError:function(){p._requestFailed(null,Ti.causes.DIALOG_ERROR)}}});this._id=O.cseq}},{key:"receiveNotify",value:function(o){if(br.debug("receiveNotify()"),!!o.body){var p=Qd.parse(o.body.trim().split(`\r
49
+ `,1)[0],"Status_Line");if(p===-1){br.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(o.body,'"'));return}switch(!0){case/^100$/.test(p.status_code):this.emit("trying",{request:o,status_line:p});break;case/^1[0-9]{2}$/.test(p.status_code):this.emit("progress",{request:o,status_line:p});break;case/^2[0-9]{2}$/.test(p.status_code):this.emit("accepted",{request:o,status_line:p});break;default:this.emit("failed",{request:o,status_line:p});break}}}},{key:"_requestSucceeded",value:function(o){br.debug("REFER succeeded"),br.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:o})}},{key:"_requestFailed",value:function(o,p){br.debug("REFER failed"),br.debug('emit "requestFailed"'),this.emit("requestFailed",{response:o||null,cause:p})}},{key:"id",get:function(){return this._id}}]),a}(Jd);function qa(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?qa=function(a){return typeof a}:qa=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},qa(u)}function kn(u,n){var a;if(typeof Symbol>"u"||u[Symbol.iterator]==null){if(Array.isArray(u)||(a=ep(u))||n&&u&&typeof u.length=="number"){a&&(u=a);var e=0,o=function(){};return{s:o,n:function(){return e>=u.length?{done:!0}:{done:!1,value:u[e++]}},e:function(l){throw l},f:o}}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 p=!0,t=!1,v;return{s:function(){a=u[Symbol.iterator]()},n:function(){var l=a.next();return p=l.done,l},e:function(l){t=!0,v=l},f:function(){try{!p&&a.return!=null&&a.return()}finally{if(t)throw v}}}}function ep(u,n){if(u){if(typeof u=="string")return Ic(u,n);var a=Object.prototype.toString.call(u).slice(8,-1);if(a==="Object"&&u.constructor&&(a=u.constructor.name),a==="Map"||a==="Set")return Array.from(u);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Ic(u,n)}}function Ic(u,n){(n==null||n>u.length)&&(n=u.length);for(var a=0,e=new Array(n);a<n;a++)e[a]=u[a];return e}function tp(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function wc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Oc(u,n,a){return n&&wc(u.prototype,n),a&&wc(u,a),u}function sp(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&vu(u,n)}function vu(u,n){return vu=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},vu(u,n)}function np(u){var n=ip();return function(){var e=Qa(u),o;if(n){var p=Qa(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return lp(this,o)}}function lp(u,n){return n&&(qa(n)==="object"||typeof n=="function")?n:rp(u)}function rp(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function ip(){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 Qa(u){return Qa=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Qa(u)}var ap=At.EventEmitter,Dc=Jt,op=yt,ge=vt,Ir=Ql,Nc=Qi,nt=qt(),Ei=rh,up=Vn,aa=hd,cp=Zi,ls=Rd,Uc=Ld,fp=jd,hp=Zd,xc=Zl(),Z=new op("RTCSession"),re={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},oa=["audio","video"],_p=function(u){sp(a,u);var n=np(a);Oc(a,null,[{key:"C",get:function(){return re}}]);function a(e){var o;return tp(this,a),Z.debug("new"),o=n.call(this),o._id=null,o._ua=e,o._status=re.STATUS_NULL,o._dialog=null,o._earlyDialogs={},o._contact=null,o._from_tag=null,o._to_tag=null,o._connection=null,o._connectionPromiseQueue=Promise.resolve(),o._request=null,o._is_canceled=!1,o._cancel_reason="",o._is_confirmed=!1,o._late_sdp=!1,o._rtcOfferConstraints=null,o._rtcAnswerConstraints=null,o._localMediaStream=null,o._localMediaStreamLocallyGenerated=!1,o._rtcReady=!0,o._iceReady=!1,o._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},o._direction=null,o._local_identity=null,o._remote_identity=null,o._start_time=null,o._end_time=null,o._tones=null,o._audioMuted=!1,o._videoMuted=!1,o._localHold=!1,o._remoteHold=!1,o._sessionTimers={enabled:o._ua.configuration.session_timers,refreshMethod:o._ua.configuration.session_timers_refresh_method,defaultExpires:ge.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},o._referSubscribers={},o._data={},o}return Oc(a,[{key:"isInProgress",value:function(){switch(this._status){case re.STATUS_NULL:case re.STATUS_INVITE_SENT:case re.STATUS_1XX_RECEIVED:case re.STATUS_INVITE_RECEIVED:case re.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case re.STATUS_ANSWERED:case re.STATUS_WAITING_FOR_ACK:case re.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case re.STATUS_CANCELED:case re.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(o){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;Z.debug("connect()");var v=o,C=nt.cloneObject(p.eventHandlers),l=nt.cloneArray(p.extraHeaders),A=nt.cloneObject(p.mediaConstraints,{audio:!0,video:!0}),b=p.mediaStream||null,E=nt.cloneObject(p.pcConfig,{iceServers:[]}),O=p.rtcConstraints||null,w=p.rtcOfferConstraints||null;if(this._rtcOfferConstraints=w,this._rtcAnswerConstraints=p.rtcAnswerConstraints||null,this._data=p.data||this._data,o===void 0)throw new TypeError("Not enough arguments");if(this._status!==re.STATUS_NULL)throw new Ir.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Ir.NotSupportedError("WebRTC not supported");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(v));this._sessionTimers.enabled&&nt.isDecimal(p.sessionTimersExpires)&&(p.sessionTimersExpires>=ge.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=p.sessionTimersExpires:this._sessionTimers.defaultExpires=ge.SESSION_EXPIRES);for(var N in C)Object.prototype.hasOwnProperty.call(C,N)&&this.on(N,C[N]);this._from_tag=nt.newTag();var U=p.anonymous||!1,Y={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:U,outbound:!0}),U?(Y.from_display_name="Anonymous",Y.from_uri=new xc("sip","anonymous","anonymous.invalid"),l.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),l.push("Privacy: id")):p.fromUserName&&(Y.from_uri=new xc("sip",p.fromUserName,this._ua.configuration.uri.host),l.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),p.fromDisplayName&&(Y.from_display_name=p.fromDisplayName),l.push("Contact: ".concat(this._contact)),l.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&l.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new up.InitialOutgoingInviteRequest(o,this._ua,Y,l),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(E,O),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,t&&t(this),this._newRTCSession("local",this._request),this._sendInitialRequest(A,w,b)}},{key:"init_incoming",value:function(o,p){var t=this;Z.debug("init_incoming()");var v,C=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;if(o.body&&C!=="application/sdp"){o.reply(415);return}if(this._status=re.STATUS_INVITE_RECEIVED,this._from_tag=o.from_tag,this._id=o.call_id+this._from_tag,this._request=o,this._contact=this._ua.contact.toString(),o.hasHeader("expires")&&(v=o.getHeader("expires")*1e3),o.to_tag=nt.newTag(),!this._createDialog(o,"UAS",!0)){o.reply(500,"Missing Contact header field");return}o.body?this._late_sdp=!1:this._late_sdp=!0,this._status=re.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){o.reply(408),t._failed("local",null,ge.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),v&&(this._timers.expiresTimer=setTimeout(function(){t._status===re.STATUS_WAITING_FOR_ANSWER&&(o.reply(487),t._failed("system",null,ge.causes.EXPIRES))},v)),this._direction="incoming",this._local_identity=o.to,this._remote_identity=o.from,p&&p(this),this._newRTCSession("remote",o),this._status!==re.STATUS_TERMINATED&&(o.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))}},{key:"answer",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("answer()");var t=this._request,v=nt.cloneArray(p.extraHeaders),C=nt.cloneObject(p.mediaConstraints),l=p.mediaStream||null,A=nt.cloneObject(p.pcConfig,{iceServers:[]}),b=p.rtcConstraints||null,E=p.rtcAnswerConstraints||null,O=nt.cloneObject(p.rtcOfferConstraints),w,N=!1,U=!1,Y=!1,j=!1;if(this._rtcAnswerConstraints=E,this._rtcOfferConstraints=p.rtcOfferConstraints||null,this._data=p.data||this._data,this._direction!=="incoming")throw new Ir.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==re.STATUS_WAITING_FOR_ANSWER)throw new Ir.InvalidStateError(this._status);if(this._sessionTimers.enabled&&nt.isDecimal(p.sessionTimersExpires)&&(p.sessionTimersExpires>=ge.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=p.sessionTimersExpires:this._sessionTimers.defaultExpires=ge.SESSION_EXPIRES),this._status=re.STATUS_ANSWERED,!this._createDialog(t,"UAS")){t.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),v.unshift("Contact: ".concat(this._contact));var _e=t.parseSDP();Array.isArray(_e.media)||(_e.media=[_e.media]);var k=kn(_e.media),H;try{for(k.s();!(H=k.n()).done;){var de=H.value;de.type==="audio"&&(N=!0,(!de.direction||de.direction==="sendrecv")&&(Y=!0)),de.type==="video"&&(U=!0,(!de.direction||de.direction==="sendrecv")&&(j=!0))}}catch(M){k.e(M)}finally{k.f()}if(l&&C.audio===!1){w=l.getAudioTracks();var Ue=kn(w),B;try{for(Ue.s();!(B=Ue.n()).done;){var L=B.value;l.removeTrack(L)}}catch(M){Ue.e(M)}finally{Ue.f()}}if(l&&C.video===!1){w=l.getVideoTracks();var V=kn(w),G;try{for(V.s();!(G=V.n()).done;){var K=G.value;l.removeTrack(K)}}catch(M){V.e(M)}finally{V.f()}}!l&&C.audio===void 0&&(C.audio=Y),!l&&C.video===void 0&&(C.video=j),!l&&!N&&!O.offerToReceiveAudio&&(C.audio=!1),!l&&!U&&!O.offerToReceiveVideo&&(C.video=!1),this._createRTCConnection(A,b),Promise.resolve().then(function(){if(l)return l;if(C.audio||C.video)return o._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(C).catch(function(M){throw o._status===re.STATUS_TERMINATED?new Error("terminated"):(t.reply(480),o._failed("local",null,ge.causes.USER_DENIED_MEDIA_ACCESS),Z.warn('emit "getusermediafailed" [error:%o]',M),o.emit("getusermediafailed",M),new Error("getUserMedia() failed"))})}).then(function(M){if(o._status===re.STATUS_TERMINATED)throw new Error("terminated");o._localMediaStream=M,M&&M.getTracks().forEach(function(te){o._connection.addTrack(te,M)})}).then(function(){if(!o._late_sdp){var M={originator:"remote",type:"offer",sdp:t.body};Z.debug('emit "sdp"'),o.emit("sdp",M);var te=new RTCSessionDescription({type:"offer",sdp:M.sdp});return o._connectionPromiseQueue=o._connectionPromiseQueue.then(function(){return o._connection.setRemoteDescription(te)}).catch(function(se){throw t.reply(488),o._failed("system",null,ge.causes.WEBRTC_ERROR),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',se),o.emit("peerconnection:setremotedescriptionfailed",se),new Error("peerconnection.setRemoteDescription() failed")}),o._connectionPromiseQueue}}).then(function(){if(o._status===re.STATUS_TERMINATED)throw new Error("terminated");return o._connecting(t),o._late_sdp?o._createLocalDescription("offer",o._rtcOfferConstraints).catch(function(){throw t.reply(500),new Error("_createLocalDescription() failed")}):o._createLocalDescription("answer",E).catch(function(){throw t.reply(500),new Error("_createLocalDescription() failed")})}).then(function(M){if(o._status===re.STATUS_TERMINATED)throw new Error("terminated");o._handleSessionTimersInIncomingRequest(t,v),t.reply(200,null,v,M,function(){o._status=re.STATUS_WAITING_FOR_ACK,o._setInvite2xxTimer(t,M),o._setACKTimer(),o._accepted("local")},function(){o._failed("system",null,ge.causes.CONNECTION_ERROR)})}).catch(function(M){o._status!==re.STATUS_TERMINATED&&Z.warn(M)})}},{key:"terminate",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("terminate()");var t=p.cause||ge.causes.BYE,v=nt.cloneArray(p.extraHeaders),C=p.body,l,A=p.status_code,b=p.reason_phrase;if(this._status===re.STATUS_TERMINATED)throw new Ir.InvalidStateError(this._status);switch(this._status){case re.STATUS_NULL:case re.STATUS_INVITE_SENT:case re.STATUS_1XX_RECEIVED:if(Z.debug("canceling session"),A&&(A<200||A>=700))throw new TypeError("Invalid status_code: ".concat(A));A&&(b=b||ge.REASON_PHRASE[A]||"",l="SIP ;cause=".concat(A,' ;text="').concat(b,'"')),this._status===re.STATUS_NULL||this._status===re.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=l):this._status===re.STATUS_1XX_RECEIVED&&this._request.cancel(l),this._status=re.STATUS_CANCELED,this._failed("local",null,ge.causes.CANCELED);break;case re.STATUS_WAITING_FOR_ANSWER:case re.STATUS_ANSWERED:if(Z.debug("rejecting session"),A=A||480,A<300||A>=700)throw new TypeError("Invalid status_code: ".concat(A));this._request.reply(A,b,v,C),this._failed("local",null,ge.causes.REJECTED);break;case re.STATUS_WAITING_FOR_ACK:case re.STATUS_CONFIRMED:if(Z.debug("terminating session"),b=p.reason_phrase||ge.REASON_PHRASE[A]||"",A&&(A<200||A>=700))throw new TypeError("Invalid status_code: ".concat(A));if(A&&v.push("Reason: SIP ;cause=".concat(A,'; text="').concat(b,'"')),this._status===re.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Nc.C.STATUS_TERMINATED){var E=this._dialog;this.receiveRequest=function(O){var w=O.method;w===ge.ACK&&(o.sendRequest(ge.BYE,{extraHeaders:v,body:C}),E.terminate())},this._request.server_transaction.on("stateChanged",function(){o._request.server_transaction.state===Nc.C.STATUS_TERMINATED&&(o.sendRequest(ge.BYE,{extraHeaders:v,body:C}),E.terminate())}),this._ended("local",null,t),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(ge.BYE,{extraHeaders:v,body:C}),this._ended("local",null,t)}}},{key:"sendDTMF",value:function(o){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Z.debug("sendDTMF() | tones: %s",o);var t=0,v=p.duration||null,C=p.interToneGap||null,l=p.transportType||ge.DTMF_TRANSPORT.INFO;if(o===void 0)throw new TypeError("Not enough arguments");if(this._status!==re.STATUS_CONFIRMED&&this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_1XX_RECEIVED)throw new Ir.InvalidStateError(this._status);if(l!==ge.DTMF_TRANSPORT.INFO&&l!==ge.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(l));if(typeof o=="number"&&(o=o.toString()),!o||typeof o!="string"||!o.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(o));if(v&&!nt.isDecimal(v))throw new TypeError("Invalid tone duration: ".concat(v));if(v?v<ls.C.MIN_DURATION?(Z.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(ls.C.MIN_DURATION," milliseconds")),v=ls.C.MIN_DURATION):v>ls.C.MAX_DURATION?(Z.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(ls.C.MAX_DURATION," milliseconds")),v=ls.C.MAX_DURATION):v=Math.abs(v):v=ls.C.DEFAULT_DURATION,p.duration=v,C&&!nt.isDecimal(C))throw new TypeError("Invalid interToneGap: ".concat(C));if(C?C<ls.C.MIN_INTER_TONE_GAP?(Z.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(ls.C.MIN_INTER_TONE_GAP," milliseconds")),C=ls.C.MIN_INTER_TONE_GAP):C=Math.abs(C):C=ls.C.DEFAULT_INTER_TONE_GAP,l===ge.DTMF_TRANSPORT.RFC2833){var A=this._getDTMFRTPSender();A&&(o=A.toneBuffer+o,A.insertDTMF(o,v,C));return}if(this._tones){this._tones+=o;return}this._tones=o,b.call(this);function b(){var E=this,O;if(this._status===re.STATUS_TERMINATED||!this._tones||t>=this._tones.length){this._tones=null;return}var w=this._tones[t];if(t+=1,w===",")O=2e3;else{var N=new ls(this);p.eventHandlers={onFailed:function(){E._tones=null}},N.send(w,p),O=v+C}setTimeout(b.bind(this),O)}}},{key:"sendInfo",value:function(o,p){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Z.debug("sendInfo()"),this._status!==re.STATUS_CONFIRMED&&this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_1XX_RECEIVED)throw new Ir.InvalidStateError(this._status);var v=new Uc(this);v.send(o,p,t)}},{key:"mute",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};Z.debug("mute()");var p=!1,t=!1;this._audioMuted===!1&&o.audio&&(p=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&o.video&&(t=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(p===!0||t===!0)&&this._onmute({audio:p,video:t})}},{key:"unmute",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};Z.debug("unmute()");var p=!1,t=!1;this._audioMuted===!0&&o.audio&&(p=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&o.video&&(t=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(p===!0||t===!0)&&this._onunmute({audio:p,video:t})}},{key:"hold",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(Z.debug("hold()"),this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var v={succeeded:function(){t&&t()},failed:function(){o.terminate({cause:ge.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return p.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:v,extraHeaders:p.extraHeaders}):this._sendReinvite({eventHandlers:v,extraHeaders:p.extraHeaders}),!0}},{key:"unhold",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(Z.debug("unhold()"),this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var v={succeeded:function(){t&&t()},failed:function(){o.terminate({cause:ge.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return p.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:v,extraHeaders:p.extraHeaders}):this._sendReinvite({eventHandlers:v,extraHeaders:p.extraHeaders}),!0}},{key:"renegotiate",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;Z.debug("renegotiate()");var v=p.rtcOfferConstraints||null;if(this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var C={succeeded:function(){t&&t()},failed:function(){o.terminate({cause:ge.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),p.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:C,rtcOfferConstraints:v,extraHeaders:p.extraHeaders}):this._sendReinvite({eventHandlers:C,rtcOfferConstraints:v,extraHeaders:p.extraHeaders}),!0}},{key:"refer",value:function(o,p){var t=this;Z.debug("refer()");var v=o;if(this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED)return!1;if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(v));var C=new hp(this);C.sendRefer(o,p);var l=C.id;return this._referSubscribers[l]=C,C.on("requestFailed",function(){delete t._referSubscribers[l]}),C.on("accepted",function(){delete t._referSubscribers[l]}),C.on("failed",function(){delete t._referSubscribers[l]}),C}},{key:"sendRequest",value:function(o,p){return Z.debug("sendRequest()"),this._dialog.sendRequest(o,p)}},{key:"receiveRequest",value:function(o){var p=this;if(Z.debug("receiveRequest()"),o.method===ge.CANCEL)(this._status===re.STATUS_WAITING_FOR_ANSWER||this._status===re.STATUS_ANSWERED)&&(this._status=re.STATUS_CANCELED,this._request.reply(487),this._failed("remote",o,ge.causes.CANCELED));else switch(o.method){case ge.ACK:if(this._status!==re.STATUS_WAITING_FOR_ACK)return;if(this._status=re.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!o.body){this.terminate({cause:ge.causes.MISSING_SDP,status_code:400});break}var t={originator:"remote",type:"answer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",t);var v=new RTCSessionDescription({type:"answer",sdp:t.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return p._connection.setRemoteDescription(v)}).then(function(){p._is_confirmed||p._confirmed("remote",o)}).catch(function(l){p.terminate({cause:ge.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',l),p.emit("peerconnection:setremotedescriptionfailed",l)})}else this._is_confirmed||this._confirmed("remote",o);break;case ge.BYE:this._status===re.STATUS_CONFIRMED||this._status===re.STATUS_WAITING_FOR_ACK?(o.reply(200),this._ended("remote",o,ge.causes.BYE)):this._status===re.STATUS_INVITE_RECEIVED||this._status===re.STATUS_WAITING_FOR_ANSWER?(o.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",o,ge.causes.BYE)):o.reply(403,"Wrong Status");break;case ge.INVITE:this._status===re.STATUS_CONFIRMED?o.hasHeader("replaces")?this._receiveReplaces(o):this._receiveReinvite(o):o.reply(403,"Wrong Status");break;case ge.INFO:if(this._status===re.STATUS_1XX_RECEIVED||this._status===re.STATUS_WAITING_FOR_ANSWER||this._status===re.STATUS_ANSWERED||this._status===re.STATUS_WAITING_FOR_ACK||this._status===re.STATUS_CONFIRMED){var C=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;C&&C.match(/^application\/dtmf-relay/i)?new ls(this).init_incoming(o):C!==void 0?new Uc(this).init_incoming(o):o.reply(415)}else o.reply(403,"Wrong Status");break;case ge.UPDATE:this._status===re.STATUS_CONFIRMED?this._receiveUpdate(o):o.reply(403,"Wrong Status");break;case ge.REFER:this._status===re.STATUS_CONFIRMED?this._receiveRefer(o):o.reply(403,"Wrong Status");break;case ge.NOTIFY:this._status===re.STATUS_CONFIRMED?this._receiveNotify(o):o.reply(403,"Wrong Status");break;default:o.reply(501)}}},{key:"onTransportError",value:function(){Z.warn("onTransportError()"),this._status!==re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ge.causes.CONNECTION_ERROR,cause:ge.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){Z.warn("onRequestTimeout()"),this._status!==re.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ge.causes.REQUEST_TIMEOUT,cause:ge.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){Z.warn("onDialogError()"),this._status!==re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ge.causes.DIALOG_ERROR,cause:ge.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(o){Z.debug("newDTMF()"),this.emit("newDTMF",o)}},{key:"newInfo",value:function(o){Z.debug("newInfo()"),this.emit("newInfo",o)}},{key:"_isReadyToReOffer",value:function(){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)}},{key:"_close",value:function(){if(Z.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(Z.debug("close() | closing local MediaStream"),nt.closeMediaStream(this._localMediaStream)),this._status!==re.STATUS_TERMINATED){if(this._status=re.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(v){Z.warn("close() | error closing the RTCPeerConnection: %o",v)}for(var o in this._timers)Object.prototype.hasOwnProperty.call(this._timers,o)&&clearTimeout(this._timers[o]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var p in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,p)&&(this._earlyDialogs[p].terminate(),delete this._earlyDialogs[p]);for(var t in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,t)&&delete this._referSubscribers[t];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(o,p){var t=Ei.T1;function v(){this._status===re.STATUS_WAITING_FOR_ACK&&(o.reply(200,null,["Contact: ".concat(this._contact)],p),t<Ei.T2&&(t=t*2,t>Ei.T2&&(t=Ei.T2)),this._timers.invite2xxTimer=setTimeout(v.bind(this),t))}this._timers.invite2xxTimer=setTimeout(v.bind(this),t)}},{key:"_setACKTimer",value:function(){var o=this;this._timers.ackTimer=setTimeout(function(){o._status===re.STATUS_WAITING_FOR_ACK&&(Z.debug("no ACK received, terminating the session"),clearTimeout(o._timers.invite2xxTimer),o.sendRequest(ge.BYE),o._ended("remote",null,ge.causes.NO_ACK))},Ei.TIMER_H)}},{key:"_createRTCConnection",value:function(o,p){var t=this;this._connection=new RTCPeerConnection(o,p),this._connection.addEventListener("iceconnectionstatechange",function(){var v=t._connection.iceConnectionState;v==="failed"&&t.terminate({cause:ge.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ge.causes.RTP_TIMEOUT})}),Z.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(o,p){var t=this;if(Z.debug("createLocalDescription()"),o!=="offer"&&o!=="answer")throw new Error('createLocalDescription() | invalid type "'.concat(o,'"'));var v=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return o==="offer"?v.createOffer(p).catch(function(C){return Z.warn('emit "peerconnection:createofferfailed" [error:%o]',C),t.emit("peerconnection:createofferfailed",C),Promise.reject(C)}):v.createAnswer(p).catch(function(C){return Z.warn('emit "peerconnection:createanswerfailed" [error:%o]',C),t.emit("peerconnection:createanswerfailed",C),Promise.reject(C)})}).then(function(C){return v.setLocalDescription(C).catch(function(l){return t._rtcReady=!0,Z.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',l),t.emit("peerconnection:setlocaldescriptionfailed",l),Promise.reject(l)})}).then(function(){var C=p&&p.iceRestart;if(v.iceGatheringState==="complete"&&!C||v.iceGatheringState==="gathering"&&t._iceReady){t._rtcReady=!0;var l={originator:"local",type:o,sdp:v.localDescription.sdp};return Z.debug('emit "sdp"'),t.emit("sdp",l),Promise.resolve(l.sdp)}return new Promise(function(A){var b=!1,E,O;t._iceReady=!1;var w=function(){v.removeEventListener("icecandidate",E),v.removeEventListener("icegatheringstatechange",O),b=!0,t._rtcReady=!0,t._iceReady=!0;var U={originator:"local",type:o,sdp:v.localDescription.sdp};Z.debug('emit "sdp"'),t.emit("sdp",U),A(U.sdp)};v.addEventListener("icecandidate",E=function(U){var Y=U.candidate;Y?t.emit("icecandidate",{candidate:Y,ready:w}):b||w()}),v.addEventListener("icegatheringstatechange",O=function(){v.iceGatheringState==="complete"&&!b&&w()})})})}},{key:"_createDialog",value:function(o,p,t){var v=p==="UAS"?o.to_tag:o.from_tag,C=p==="UAS"?o.from_tag:o.to_tag,l=o.call_id+v+C,A=this._earlyDialogs[l];if(t)return A?!0:(A=new aa(this,o,p,aa.C.STATUS_EARLY),A.error?(Z.debug(A.error),this._failed("remote",o,ge.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[l]=A,!0));if(this._from_tag=o.from_tag,this._to_tag=o.to_tag,A)return A.update(o,p),this._dialog=A,delete this._earlyDialogs[l],!0;var b=new aa(this,o,p);return b.error?(Z.debug(b.error),this._failed("remote",o,ge.causes.INTERNAL_ERROR),!1):(this._dialog=b,!0)}},{key:"_receiveReinvite",value:function(o){var p=this;Z.debug("receiveReinvite()");var t=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,v={request:o,callback:void 0,reject:l.bind(this)},C=!1;function l(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};C=!0;var E=b.status_code||403,O=b.reason_phrase||"",w=nt.cloneArray(b.extraHeaders);if(this._status!==re.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));o.reply(E,O,w)}if(this.emit("reinvite",v),C)return;if(this._late_sdp=!1,!o.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return p._createLocalDescription("offer",p._rtcOfferConstraints)}).then(function(b){A.call(p,b)}).catch(function(){o.reply(500)});return}if(t!=="application/sdp"){Z.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(function(b){p._status!==re.STATUS_TERMINATED&&A.call(p,b)}).catch(function(b){Z.warn(b)});function A(b){var E=this,O=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(o,O),this._late_sdp&&(b=this._mangleOffer(b)),o.reply(200,null,O,b,function(){E._status=re.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(o,b),E._setACKTimer()}),typeof v.callback=="function"&&v.callback()}}},{key:"_receiveUpdate",value:function(o){var p=this;Z.debug("receiveUpdate()");var t=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,v={request:o,callback:void 0,reject:l.bind(this)},C=!1;function l(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};C=!0;var E=b.status_code||403,O=b.reason_phrase||"",w=nt.cloneArray(b.extraHeaders);if(this._status!==re.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));o.reply(E,O,w)}if(this.emit("update",v),C)return;if(!o.body){A.call(this,null);return}if(t!=="application/sdp"){Z.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(function(b){p._status!==re.STATUS_TERMINATED&&A.call(p,b)}).catch(function(b){Z.warn(b)});function A(b){var E=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(o,E),o.reply(200,null,E,b),typeof v.callback=="function"&&v.callback()}}},{key:"_processInDialogSdpOffer",value:function(o){var p=this;Z.debug("_processInDialogSdpOffer()");var t=o.parseSDP(),v=!1,C=kn(t.media),l;try{for(C.s();!(l=C.n()).done;){var A=l.value;if(oa.indexOf(A.type)!==-1){var b=A.direction||t.direction||"sendrecv";if(b==="sendonly"||b==="inactive")v=!0;else{v=!1;break}}}}catch(w){C.e(w)}finally{C.f()}var E={originator:"remote",type:"offer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",E);var O=new RTCSessionDescription({type:"offer",sdp:E.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(p._status===re.STATUS_TERMINATED)throw new Error("terminated");return p._connection.setRemoteDescription(O).catch(function(w){throw o.reply(488),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',w),p.emit("peerconnection:setremotedescriptionfailed",w),w})}).then(function(){if(p._status===re.STATUS_TERMINATED)throw new Error("terminated");p._remoteHold===!0&&v===!1?(p._remoteHold=!1,p._onunhold("remote")):p._remoteHold===!1&&v===!0&&(p._remoteHold=!0,p._onhold("remote"))}).then(function(){if(p._status===re.STATUS_TERMINATED)throw new Error("terminated");return p._createLocalDescription("answer",p._rtcAnswerConstraints).catch(function(w){throw o.reply(500),Z.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',w),w})}).catch(function(w){Z.warn("_processInDialogSdpOffer() failed [error: %o]",w)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(o){var p=this;if(Z.debug("receiveRefer()"),!o.refer_to){Z.debug("no Refer-To header field present in REFER"),o.reply(400);return}if(o.refer_to.uri.scheme!==ge.SIP){Z.debug("Refer-To header field points to a non-SIP URI scheme"),o.reply(416);return}o.reply(202);var t=new fp(this,o.cseq);Z.debug('emit "refer"'),this.emit("refer",{request:o,accept:function(A,b){v.call(p,A,b)},reject:function(){C.call(p)}});function v(l){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(l=typeof l=="function"?l:null,this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED)return!1;var b=new a(this._ua);if(b.on("progress",function(O){var w=O.response;t.notify(w.status_code,w.reason_phrase)}),b.on("accepted",function(O){var w=O.response;t.notify(w.status_code,w.reason_phrase)}),b.on("_failed",function(O){var w=O.message,N=O.cause;w?t.notify(w.status_code,w.reason_phrase):t.notify(487,N)}),o.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(o.refer_to.uri.getHeader("replaces"));A.extraHeaders=nt.cloneArray(A.extraHeaders),A.extraHeaders.push("Replaces: ".concat(E))}b.connect(o.refer_to.uri.toAor(),A,l)}function C(){t.notify(603)}}},{key:"_receiveNotify",value:function(o){switch(Z.debug("receiveNotify()"),o.event||o.reply(400),o.event.event){case"refer":{var p,t;if(o.event.params&&o.event.params.id)p=o.event.params.id,t=this._referSubscribers[p];else if(Object.keys(this._referSubscribers).length===1)t=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{o.reply(400,"Missing event id parameter");return}if(!t){o.reply(481,"Subscription does not exist");return}t.receiveNotify(o),o.reply(200);break}default:o.reply(489)}}},{key:"_receiveReplaces",value:function(o){var p=this;Z.debug("receiveReplaces()");function t(C){var l=this;if(this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED)return!1;var A=new a(this._ua);A.on("confirmed",function(){l.terminate()}),A.init_incoming(o,C)}function v(){Z.debug("Replaced INVITE rejected by the user"),o.reply(486)}this.emit("replaces",{request:o,accept:function(l){t.call(p,l)},reject:function(){v.call(p)}})}},{key:"_sendInitialRequest",value:function(o,p,t){var v=this,C=new cp(this._ua,this._request,{onRequestTimeout:function(){v.onRequestTimeout()},onTransportError:function(){v.onTransportError()},onAuthenticated:function(A){v._request=A},onReceiveResponse:function(A){v._receiveInviteResponse(A)}});Promise.resolve().then(function(){if(t)return t;if(o.audio||o.video)return v._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(function(l){throw v._status===re.STATUS_TERMINATED?new Error("terminated"):(v._failed("local",null,ge.causes.USER_DENIED_MEDIA_ACCESS),Z.warn('emit "getusermediafailed" [error:%o]',l),v.emit("getusermediafailed",l),l)})}).then(function(l){if(v._status===re.STATUS_TERMINATED)throw new Error("terminated");return v._localMediaStream=l,l&&l.getTracks().forEach(function(A){v._connection.addTrack(A,l)}),v._connecting(v._request),v._createLocalDescription("offer",p).catch(function(A){throw v._failed("local",null,ge.causes.WEBRTC_ERROR),A})}).then(function(l){if(v._is_canceled||v._status===re.STATUS_TERMINATED)throw new Error("terminated");v._request.body=l,v._status=re.STATUS_INVITE_SENT,Z.debug('emit "sending" [request:%o]',v._request),v.emit("sending",{request:v._request}),C.send()}).catch(function(l){v._status!==re.STATUS_TERMINATED&&Z.warn(l)})}},{key:"_getDTMFRTPSender",value:function(){var o=this._connection.getSenders().find(function(p){return p.track&&p.track.kind==="audio"});if(!(o&&o.dtmf)){Z.warn("sendDTMF() | no local audio track to send DTMF with");return}return o.dtmf}},{key:"_receiveInviteResponse",value:function(o){var p=this;if(Z.debug("receiveInviteResponse()"),this._dialog&&o.status_code>=200&&o.status_code<=299)if(this._dialog.id.call_id===o.call_id&&this._dialog.id.local_tag===o.from_tag&&this._dialog.id.remote_tag===o.to_tag){this.sendRequest(ge.ACK);return}else{var t=new aa(this,o,"UAC");if(t.error!==void 0){Z.debug(t.error);return}this.sendRequest(ge.ACK),this.sendRequest(ge.BYE);return}if(this._is_canceled){o.status_code>=100&&o.status_code<200?this._request.cancel(this._cancel_reason):o.status_code>=200&&o.status_code<299&&this._acceptAndTerminate(o);return}if(!(this._status!==re.STATUS_INVITE_SENT&&this._status!==re.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(o.status_code):this._status=re.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(o.status_code):{if(!o.to_tag){Z.debug("1xx response received without to tag");break}if(o.hasHeader("contact")&&!this._createDialog(o,"UAC",!0))break;if(this._status=re.STATUS_1XX_RECEIVED,!o.body){this._progress("remote",o);break}var v={originator:"remote",type:"answer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",v);var C=new RTCSessionDescription({type:"answer",sdp:v.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return p._connection.setRemoteDescription(C)}).then(function(){return p._progress("remote",o)}).catch(function(E){Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),p.emit("peerconnection:setremotedescriptionfailed",E)});break}case/^2[0-9]{2}$/.test(o.status_code):{if(this._status=re.STATUS_CONFIRMED,!o.body){this._acceptAndTerminate(o,400,ge.causes.MISSING_SDP),this._failed("remote",o,ge.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(o,"UAC"))break;var l={originator:"remote",type:"answer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",l);var A=new RTCSessionDescription({type:"answer",sdp:l.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(p._connection.signalingState==="stable")return p._connection.createOffer(p._rtcOfferConstraints).then(function(E){return p._connection.setLocalDescription(E)}).catch(function(E){p._acceptAndTerminate(o,500,E.toString()),p._failed("local",o,ge.causes.WEBRTC_ERROR)})}).then(function(){p._connection.setRemoteDescription(A).then(function(){p._handleSessionTimersInIncomingResponse(o),p._accepted("remote",o),p.sendRequest(ge.ACK),p._confirmed("local",null)}).catch(function(E){p._acceptAndTerminate(o,488,"Not Acceptable Here"),p._failed("remote",o,ge.causes.BAD_MEDIA_DESCRIPTION),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),p.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var b=nt.sipErrorCause(o.status_code);this._failed("remote",o,b)}}}},{key:"_sendReinvite",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("sendReinvite()");var t=nt.cloneArray(p.extraHeaders),v=nt.cloneObject(p.eventHandlers),C=p.rtcOfferConstraints||this._rtcOfferConstraints||null,l=!1;t.push("Contact: ".concat(this._contact)),t.push("Content-Type: application/sdp"),this._sessionTimers.running&&t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return o._createLocalDescription("offer",C)}).then(function(E){E=o._mangleOffer(E);var O={originator:"local",type:"offer",sdp:E};Z.debug('emit "sdp"'),o.emit("sdp",O),o.sendRequest(ge.INVITE,{extraHeaders:t,body:E,eventHandlers:{onSuccessResponse:function(N){A.call(o,N),l=!0},onErrorResponse:function(N){b.call(o,N)},onTransportError:function(){o.onTransportError()},onRequestTimeout:function(){o.onRequestTimeout()},onDialogError:function(){o.onDialogError()}}})}).catch(function(){b()});function A(E){var O=this;if(this._status!==re.STATUS_TERMINATED&&(this.sendRequest(ge.ACK),!l)){if(this._handleSessionTimersInIncomingResponse(E),E.body){if(!E.hasHeader("Content-Type")||E.getHeader("Content-Type").toLowerCase()!=="application/sdp"){b.call(this);return}}else{b.call(this);return}var w={originator:"remote",type:"answer",sdp:E.body};Z.debug('emit "sdp"'),this.emit("sdp",w);var N=new RTCSessionDescription({type:"answer",sdp:w.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return O._connection.setRemoteDescription(N)}).then(function(){v.succeeded&&v.succeeded(E)}).catch(function(U){b.call(O),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),O.emit("peerconnection:setremotedescriptionfailed",U)})}}function b(E){v.failed&&v.failed(E)}}},{key:"_sendUpdate",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("sendUpdate()");var t=nt.cloneArray(p.extraHeaders),v=nt.cloneObject(p.eventHandlers),C=p.rtcOfferConstraints||this._rtcOfferConstraints||null,l=p.sdpOffer||!1,A=!1;t.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),l?(t.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return o._createLocalDescription("offer",C)}).then(function(O){O=o._mangleOffer(O);var w={originator:"local",type:"offer",sdp:O};Z.debug('emit "sdp"'),o.emit("sdp",w),o.sendRequest(ge.UPDATE,{extraHeaders:t,body:O,eventHandlers:{onSuccessResponse:function(U){b.call(o,U),A=!0},onErrorResponse:function(U){E.call(o,U)},onTransportError:function(){o.onTransportError()},onRequestTimeout:function(){o.onRequestTimeout()},onDialogError:function(){o.onDialogError()}}})}).catch(function(){E.call(o)})):this.sendRequest(ge.UPDATE,{extraHeaders:t,eventHandlers:{onSuccessResponse:function(w){b.call(o,w)},onErrorResponse:function(w){E.call(o,w)},onTransportError:function(){o.onTransportError()},onRequestTimeout:function(){o.onRequestTimeout()},onDialogError:function(){o.onDialogError()}}});function b(O){var w=this;if(this._status!==re.STATUS_TERMINATED&&!A)if(this._handleSessionTimersInIncomingResponse(O),l){if(O.body){if(!O.hasHeader("Content-Type")||O.getHeader("Content-Type").toLowerCase()!=="application/sdp"){E.call(this);return}}else{E.call(this);return}var N={originator:"remote",type:"answer",sdp:O.body};Z.debug('emit "sdp"'),this.emit("sdp",N);var U=new RTCSessionDescription({type:"answer",sdp:N.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return w._connection.setRemoteDescription(U)}).then(function(){v.succeeded&&v.succeeded(O)}).catch(function(Y){E.call(w),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',Y),w.emit("peerconnection:setremotedescriptionfailed",Y)})}else v.succeeded&&v.succeeded(O)}function E(O){v.failed&&v.failed(O)}}},{key:"_acceptAndTerminate",value:function(o,p,t){Z.debug("acceptAndTerminate()");var v=[];p&&(t=t||ge.REASON_PHRASE[p]||"",v.push("Reason: SIP ;cause=".concat(p,'; text="').concat(t,'"'))),(this._dialog||this._createDialog(o,"UAC"))&&(this.sendRequest(ge.ACK),this.sendRequest(ge.BYE,{extraHeaders:v})),this._status=re.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(o){if(!this._localHold&&!this._remoteHold)return o;if(o=Dc.parse(o),this._localHold&&!this._remoteHold){Z.debug("mangleOffer() | me on hold, mangling offer");var p=kn(o.media),t;try{for(p.s();!(t=p.n()).done;){var v=t.value;oa.indexOf(v.type)!==-1&&(v.direction?v.direction==="sendrecv"?v.direction="sendonly":v.direction==="recvonly"&&(v.direction="inactive"):v.direction="sendonly")}}catch(w){p.e(w)}finally{p.f()}}else if(this._localHold&&this._remoteHold){Z.debug("mangleOffer() | both on hold, mangling offer");var C=kn(o.media),l;try{for(C.s();!(l=C.n()).done;){var A=l.value;oa.indexOf(A.type)!==-1&&(A.direction="inactive")}}catch(w){C.e(w)}finally{C.f()}}else if(this._remoteHold){Z.debug("mangleOffer() | remote on hold, mangling offer");var b=kn(o.media),E;try{for(b.s();!(E=b.n()).done;){var O=E.value;oa.indexOf(O.type)!==-1&&(O.direction?O.direction==="sendrecv"?O.direction="recvonly":O.direction==="recvonly"&&(O.direction="inactive"):O.direction="recvonly")}}catch(w){b.e(w)}finally{b.f()}}return Dc.write(o)}},{key:"_setLocalMediaStatus",value:function(){var o=!0,p=!0;(this._localHold||this._remoteHold)&&(o=!1,p=!1),this._audioMuted&&(o=!1),this._videoMuted&&(p=!1),this._toggleMuteAudio(!o),this._toggleMuteVideo(!p)}},{key:"_handleSessionTimersInIncomingRequest",value:function(o,p){if(this._sessionTimers.enabled){var t;o.session_expires&&o.session_expires>=ge.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,t=o.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uas"),p.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(t)),this._sessionTimers.refresher=t==="uas",this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(o){if(this._sessionTimers.enabled){var p;o.session_expires&&o.session_expires>=ge.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,p=o.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,p="uac"),this._sessionTimers.refresher=p==="uac",this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var o=this,p=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){o._status!==re.STATUS_TERMINATED&&o._isReadyToReOffer()&&(Z.debug("runSessionTimer() | sending session refresh request"),o._sessionTimers.refreshMethod===ge.UPDATE?o._sendUpdate():o._sendReinvite())},p*500):this._sessionTimers.timer=setTimeout(function(){o._status!==re.STATUS_TERMINATED&&(Z.warn("runSessionTimer() | timer expired, terminating the session"),o.terminate({cause:ge.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},p*1100)}},{key:"_toggleMuteAudio",value:function(o){var p=this._connection.getSenders().filter(function(l){return l.track&&l.track.kind==="audio"}),t=kn(p),v;try{for(t.s();!(v=t.n()).done;){var C=v.value;C.track.enabled=!o}}catch(l){t.e(l)}finally{t.f()}}},{key:"_toggleMuteVideo",value:function(o){var p=this._connection.getSenders().filter(function(l){return l.track&&l.track.kind==="video"}),t=kn(p),v;try{for(t.s();!(v=t.n()).done;){var C=v.value;C.track.enabled=!o}}catch(l){t.e(l)}finally{t.f()}}},{key:"_newRTCSession",value:function(o,p){Z.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:o,session:this,request:p})}},{key:"_connecting",value:function(o){Z.debug("session connecting"),Z.debug('emit "connecting"'),this.emit("connecting",{request:o})}},{key:"_progress",value:function(o,p){Z.debug("session progress"),Z.debug('emit "progress"'),this.emit("progress",{originator:o,response:p||null})}},{key:"_accepted",value:function(o,p){Z.debug("session accepted"),this._start_time=new Date,Z.debug('emit "accepted"'),this.emit("accepted",{originator:o,response:p||null})}},{key:"_confirmed",value:function(o,p){Z.debug("session confirmed"),this._is_confirmed=!0,Z.debug('emit "confirmed"'),this.emit("confirmed",{originator:o,ack:p||null})}},{key:"_ended",value:function(o,p,t){Z.debug("session ended"),this._end_time=new Date,this._close(),Z.debug('emit "ended"'),this.emit("ended",{originator:o,message:p||null,cause:t})}},{key:"_failed",value:function(o,p,t){Z.debug("session failed"),Z.debug('emit "_failed"'),this.emit("_failed",{originator:o,message:p||null,cause:t}),this._close(),Z.debug('emit "failed"'),this.emit("failed",{originator:o,message:p||null,cause:t})}},{key:"_onhold",value:function(o){Z.debug("session onhold"),this._setLocalMediaStatus(),Z.debug('emit "hold"'),this.emit("hold",{originator:o})}},{key:"_onunhold",value:function(o){Z.debug("session onunhold"),this._setLocalMediaStatus(),Z.debug('emit "unhold"'),this.emit("unhold",{originator:o})}},{key:"_onmute",value:function(o){var p=o.audio,t=o.video;Z.debug("session onmute"),this._setLocalMediaStatus(),Z.debug('emit "muted"'),this.emit("muted",{audio:p,video:t})}},{key:"_onunmute",value:function(o){var p=o.audio,t=o.video;Z.debug("session onunmute"),this._setLocalMediaStatus(),Z.debug('emit "unmuted"'),this.emit("unmuted",{audio:p,video:t})}},{key:"C",get:function(){return re}},{key:"causes",get:function(){return ge.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(o){this._data=o}},{key:"status",get:function(){return this._status}}]),a}(ap);function ja(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ja=function(a){return typeof a}:ja=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ja(u)}function dp(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Pc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function pp(u,n,a){return n&&Pc(u.prototype,n),a&&Pc(u,a),u}function mp(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&Tu(u,n)}function Tu(u,n){return Tu=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},Tu(u,n)}function gp(u){var n=Ep();return function(){var e=Za(u),o;if(n){var p=Za(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return vp(this,o)}}function vp(u,n){return n&&(ja(n)==="object"||typeof n=="function")?n:Tp(u)}function Tp(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function Ep(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Za(u){return Za=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Za(u)}var Cp=At.EventEmitter,Sp=yt,Oo=vt,Ap=Vn,Ci=qt(),yp=Zi,Mc=Ql,Rp=Zl(),ua=new Sp("Message"),bp=function(u){mp(a,u);var n=gp(a);function a(e){var o;return dp(this,a),o=n.call(this),o._ua=e,o._request=null,o._closed=!1,o._direction=null,o._local_identity=null,o._remote_identity=null,o._is_replied=!1,o._data={},o}return pp(a,[{key:"send",value:function(o,p){var t=this,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},C=o;if(o===void 0||p===void 0)throw new TypeError("Not enough arguments");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(C));var l=Ci.cloneArray(v.extraHeaders),A=Ci.cloneObject(v.eventHandlers),b=v.contentType||"text/plain",E={};v.fromUserName&&(E.from_uri=new Rp("sip",v.fromUserName,this._ua.configuration.uri.host),l.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),v.fromDisplayName&&(E.from_display_name=v.fromDisplayName);for(var O in A)Object.prototype.hasOwnProperty.call(A,O)&&this.on(O,A[O]);l.push("Content-Type: ".concat(b)),this._request=new Ap.OutgoingRequest(Oo.MESSAGE,o,this._ua,E,l),p&&(this._request.body=p);var w=new yp(this._ua,this._request,{onRequestTimeout:function(){t._onRequestTimeout()},onTransportError:function(){t._onTransportError()},onReceiveResponse:function(U){t._receiveResponse(U)}});this._newMessage("local",this._request),w.send()}},{key:"init_incoming",value:function(o){this._request=o,this._newMessage("remote",o),this._is_replied||(this._is_replied=!0,o.reply(200)),this._close()}},{key:"accept",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=Ci.cloneArray(o.extraHeaders),t=o.body;if(this._direction!=="incoming")throw new Mc.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,p,t)}},{key:"reject",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=o.status_code||480,t=o.reason_phrase,v=Ci.cloneArray(o.extraHeaders),C=o.body;if(this._direction!=="incoming")throw new Mc.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(p<300||p>=700)throw new TypeError("Invalid status_code: ".concat(p));this._is_replied=!0,this._request.reply(p,t,v,C)}},{key:"_receiveResponse",value:function(o){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):this._succeeded("remote",o);break;default:{var p=Ci.sipErrorCause(o.status_code);this._failed("remote",o,p);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,Oo.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,Oo.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(o,p){o==="remote"?(this._direction="incoming",this._local_identity=p.to,this._remote_identity=p.from):o==="local"&&(this._direction="outgoing",this._local_identity=p.from,this._remote_identity=p.to),this._ua.newMessage(this,{originator:o,message:this,request:p})}},{key:"_failed",value:function(o,p,t){ua.debug("MESSAGE failed"),this._close(),ua.debug('emit "failed"'),this.emit("failed",{originator:o,response:p||null,cause:t})}},{key:"_succeeded",value:function(o,p){ua.debug("MESSAGE succeeded"),this._close(),ua.debug('emit "succeeded"'),this.emit("succeeded",{originator:o,response:p})}},{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}}]),a}(Cp);function Va(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Va=function(a){return typeof a}:Va=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Va(u)}function Ip(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function kc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function wp(u,n,a){return n&&kc(u.prototype,n),a&&kc(u,a),u}function Op(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&Eu(u,n)}function Eu(u,n){return Eu=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},Eu(u,n)}function Dp(u){var n=xp();return function(){var e=eo(u),o;if(n){var p=eo(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return Np(this,o)}}function Np(u,n){return n&&(Va(n)==="object"||typeof n=="function")?n:Up(u)}function Up(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function xp(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function eo(u){return eo=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},eo(u)}var Pp=At.EventEmitter,Mp=yt,Do=vt,kp=Vn,Si=qt(),Lp=Zi,Lc=Ql,ca=new Mp("Options"),$p=function(u){Op(a,u);var n=Dp(a);function a(e){var o;return Ip(this,a),o=n.call(this),o._ua=e,o._request=null,o._closed=!1,o._direction=null,o._local_identity=null,o._remote_identity=null,o._is_replied=!1,o._data={},o}return wp(a,[{key:"send",value:function(o,p){var t=this,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},C=o;if(o===void 0)throw new TypeError("A target is required for OPTIONS");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(C));var l=Si.cloneArray(v.extraHeaders),A=Si.cloneObject(v.eventHandlers),b=v.contentType||"application/sdp";for(var E in A)Object.prototype.hasOwnProperty.call(A,E)&&this.on(E,A[E]);l.push("Content-Type: ".concat(b)),this._request=new kp.OutgoingRequest(Do.OPTIONS,o,this._ua,null,l),p&&(this._request.body=p);var O=new Lp(this._ua,this._request,{onRequestTimeout:function(){t._onRequestTimeout()},onTransportError:function(){t._onTransportError()},onReceiveResponse:function(N){t._receiveResponse(N)}});this._newOptions("local",this._request),O.send()}},{key:"init_incoming",value:function(o){this._request=o,this._newOptions("remote",o),this._is_replied||(this._is_replied=!0,o.reply(200)),this._close()}},{key:"accept",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=Si.cloneArray(o.extraHeaders),t=o.body;if(this._direction!=="incoming")throw new Lc.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,p,t)}},{key:"reject",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=o.status_code||480,t=o.reason_phrase,v=Si.cloneArray(o.extraHeaders),C=o.body;if(this._direction!=="incoming")throw new Lc.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(p<300||p>=700)throw new TypeError("Invalid status_code: ".concat(p));this._is_replied=!0,this._request.reply(p,t,v,C)}},{key:"_receiveResponse",value:function(o){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):this._succeeded("remote",o);break;default:{var p=Si.sipErrorCause(o.status_code);this._failed("remote",o,p);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,Do.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,Do.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(o,p){o==="remote"?(this._direction="incoming",this._local_identity=p.to,this._remote_identity=p.from):o==="local"&&(this._direction="outgoing",this._local_identity=p.from,this._remote_identity=p.to),this._ua.newOptions(this,{originator:o,message:this,request:p})}},{key:"_failed",value:function(o,p,t){ca.debug("OPTIONS failed"),this._close(),ca.debug('emit "failed"'),this.emit("failed",{originator:o,response:p||null,cause:t})}},{key:"_succeeded",value:function(o,p){ca.debug("OPTIONS succeeded"),this._close(),ca.debug('emit "succeeded"'),this.emit("succeeded",{originator:o,response:p})}},{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}}]),a}(Pp),ku={},Hp=yt,No=qt(),Fp=_n(),Ai=new Hp("Socket");ku.isSocket=function(u){if(Array.isArray(u))return!1;if(typeof u>"u")return Ai.warn("undefined JsSIP.Socket instance"),!1;try{if(!No.isString(u.url))throw Ai.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!No.isString(u.via_transport))throw Ai.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Fp.parse(u.sip_uri,"SIP_URI")===-1)throw Ai.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(function(n){if(!No.isFunction(u[n]))throw Ai.warn("missing or invalid JsSIP.Socket method: ".concat(n)),new Error("Missing or invalid JsSIP.Socket method: ".concat(n))})}catch{return!1}return!0};function qp(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function $c(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function jp(u,n,a){return n&&$c(u.prototype,n),a&&$c(u,a),u}var Vp=yt,Bp=ku,Hc=vt,Yt=new Vp("Transport"),Ts={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Hc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Hc.CONNECTION_RECOVERY_MAX_INTERVAL}},Gp=function(){function u(n){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ts.recovery_options;qp(this,u),Yt.debug("new()"),this.status=Ts.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=a,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(e){Yt.warn("cannot use TextDecoder: ".concat(e))}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(e){if(!Bp.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:Ts.SOCKET_STATUS_READY})},this),this._getSocket()}return jp(u,[{key:"connect",value:function(){if(Yt.debug("connect()"),this.isConnected()){Yt.debug("Transport is already connected");return}else if(this.isConnecting()){Yt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ts.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(){Yt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ts.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(a){if(Yt.debug("send()"),!this.isConnected())return Yt.warn("unable to send message, transport is not connected"),!1;var e=a.toString();return Yt.debug(`sending message:
51
51
 
52
- `.concat(o,`
53
- `)),this.socket.send(o)}},{key:"isConnected",value:function(){return this.status===jt.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===jt.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!==jt.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=jt.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=jt.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=jt.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=jt.SOCKET_STATUS_ERROR)},this),this._reconnect(r))}},{key:"_onData",value:function(r){if(r===`\r
54
- `){Nt.debug("received message with CRLF Keep Alive response");return}else if(typeof r!="string"){try{this.textDecoder?r=this.textDecoder.decode(r):r=String.fromCharCode.apply(null,new Uint8Array(r))}catch{Nt.debug("received binary message failed to be converted into string, message discarded");return}Nt.debug(`received binary message:
52
+ `.concat(e,`
53
+ `)),this.socket.send(e)}},{key:"isConnected",value:function(){return this.status===Ts.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===Ts.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var a=this;this.recover_attempts+=1;var e=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);e<this.recovery_options.min_interval?e=this.recovery_options.min_interval:e>this.recovery_options.max_interval&&(e=this.recovery_options.max_interval),Yt.debug("reconnection attempt: ".concat(this.recover_attempts,". next connection attempt in ").concat(e," seconds")),this.recovery_timer=setTimeout(function(){!a.close_requested&&!(a.isConnected()||a.isConnecting())&&(a._getSocket(),a.connect())},e*1e3)}},{key:"_getSocket",value:function(){var a=[];if(this.sockets.forEach(function(o){o.status!==Ts.SOCKET_STATUS_ERROR&&(a.length===0?a.push(o):o.weight>a[0].weight?a=[o]:o.weight===a[0].weight&&a.push(o))}),a.length===0){this.sockets.forEach(function(o){o.status=Ts.SOCKET_STATUS_READY}),this._getSocket();return}var e=Math.floor(Math.random()*a.length);this.socket=a[e].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=Ts.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(a,e,o){this.status=Ts.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:a,code:e,reason:o}),!this.close_requested&&(this.sockets.forEach(function(p){this.socket===p.socket&&(p.status=Ts.SOCKET_STATUS_ERROR)},this),this._reconnect(a))}},{key:"_onData",value:function(a){if(a===`\r
54
+ `){Yt.debug("received message with CRLF Keep Alive response");return}else if(typeof a!="string"){try{this.textDecoder?a=this.textDecoder.decode(a):a=String.fromCharCode.apply(null,new Uint8Array(a))}catch{Yt.debug("received binary message failed to be converted into string, message discarded");return}Yt.debug(`received binary message:
55
55
 
56
- `.concat(r,`
57
- `))}else Nt.debug(`received text message:
56
+ `.concat(a,`
57
+ `))}else Yt.debug(`received text message:
58
58
 
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}(),s_={};function kc(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Hp(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,d;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,d=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw d}}}}function Hp(c,s){if(c){if(typeof c=="string")return Lc(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 Lc(c,s)}}function Lc(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 Fp=_t,du=is(),pu=vs,Vl=new Fp("Parser");s_.parseMessage=function(c,s){var r,o,a=c.indexOf(`\r
62
- `);if(a===-1){Vl.warn("parseMessage() | no CRLF found, not a SIP message");return}var t=c.substring(0,a),n=du.parse(t,"Request_Response");if(n===-1){Vl.warn('parseMessage() | error parsing first line of SIP message: "'.concat(t,'"'));return}else n.status_code?(r=new pu.IncomingResponse,r.status_code=n.status_code,r.reason_phrase=n.reason_phrase):(r=new pu.IncomingRequest(s),r.method=n.method,r.ruri=n.uri);r.data=c;for(var d=a+2;;){if(a=jp(c,d),a===-2){o=d+2;break}else if(a===-1){Vl.warn("parseMessage() | malformed message");return}if(n=qp(r,c,d,a),n!==!0){Vl.warn("parseMessage() |",n.error);return}d=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 jp(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 qp(c,s,r,o){var a,t=s.indexOf(":",r),n=s.substring(r,t).trim(),d=s.substring(t+1,o).trim();switch(n.toLowerCase()){case"via":case"v":c.addHeader("via",d),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",d),a=c.parseHeader("from"),a&&(c.from=a,c.from_tag=a.getParam("tag"));break;case"to":case"t":c.setHeader("to",d),a=c.parseHeader("to"),a&&(c.to=a,c.to_tag=a.getParam("tag"));break;case"record-route":if(a=du.parse(d,"Record_Route"),a===-1)a=void 0;else{var _=kc(a),h;try{for(_.s();!(h=_.n()).done;){var g=h.value;c.addHeader("record-route",d.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",d),a=c.parseHeader("call-id"),a&&(c.call_id=d);break;case"contact":case"m":if(a=du.parse(d,"Contact"),a===-1)a=void 0;else{var T=kc(a),E;try{for(T.s();!(E=T.n()).done;){var y=E.value;c.addHeader("contact",d.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",d),a=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",d),a=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",d),a=c.parseHeader("cseq"),a&&(c.cseq=a.value),c instanceof pu.IncomingResponse&&(c.method=a.method);break;case"max-forwards":c.setHeader("max-forwards",d),a=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",d),a=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",d),a=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",d),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",d),a=c.parseHeader("refer-to"),a&&(c.refer_to=a);break;case"replaces":c.setHeader("replaces",d),a=c.parseHeader("replaces"),a&&(c.replaces=a);break;case"event":case"o":c.setHeader("event",d),a=c.parseHeader("event"),a&&(c.event=a);break;default:c.addHeader(n,d),a=0}return a===void 0?{error:'error parsing header "'.concat(n,'"')}:!0}function Ao(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=Vp(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,d;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,d=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw d}}}}function Vp(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}var Bp=_t,n_=it,Hc=vs,Du=bt(),Nu=new Bp("sanityCheck"),Gp=[tm],Wp=[Jp,zp,Xp,Qp],Kp=[Zp,em],He,ts,r_,Yp=function(c,s,r){He=c,ts=s,r_=r;var o=Ao(Gp),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;if(t()===!1)return!1}}catch(E){o.e(E)}finally{o.f()}if(He instanceof Hc.IncomingRequest){var n=Ao(Wp),d;try{for(n.s();!(d=n.n()).done;){var _=d.value;if(_()===!1)return!1}}catch(E){n.e(E)}finally{n.f()}}else if(He instanceof Hc.IncomingResponse){var h=Ao(Kp),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 Jp(){if(He.s("to").uri.scheme!=="sip")return Qi(416),!1}function zp(){if(!He.to_tag&&He.call_id.substr(0,5)===ts.configuration.jssip_id)return Qi(482),!1}function Xp(){var c=Du.str_utf8_length(He.body),s=He.getHeader("content-length");if(c<s)return Qi(400),!1}function Qp(){var c=He.from_tag,s=He.call_id,r=He.cseq,o;if(!He.to_tag)if(He.method===n_.INVITE){if(ts._transactions.ist[He.via_branch])return!1;for(var a in ts._transactions.ist)if(Object.prototype.hasOwnProperty.call(ts._transactions.ist,a)&&(o=ts._transactions.ist[a],o.request.from_tag===c&&o.request.call_id===s&&o.request.cseq===r))return Qi(482),!1}else{if(ts._transactions.nist[He.via_branch])return!1;for(var t in ts._transactions.nist)if(Object.prototype.hasOwnProperty.call(ts._transactions.nist,t)&&(o=ts._transactions.nist[t],o.request.from_tag===c&&o.request.call_id===s&&o.request.cseq===r))return Qi(482),!1}}function Zp(){if(He.getHeaders("via").length>1)return Nu.debug("more than one Via header field present in the response, dropping the response"),!1}function em(){var c=Du.str_utf8_length(He.body),s=He.getHeader("content-length");if(c<s)return Nu.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function tm(){for(var c=["from","to","call_id","cseq","via"],s=0,r=c;s<r.length;s++){var o=r[s];if(!He.hasHeader(o))return Nu.debug("missing mandatory header field : ".concat(o,", dropping the response")),!1}}function Qi(c){var s=He.getHeaders("via"),r,o="SIP/2.0 ".concat(c," ").concat(n_.REASON_PHRASE[c],`\r
65
- `),a=Ao(s),t;try{for(a.s();!(t=a.n()).done;){var n=t.value;o+="Via: ".concat(n,`\r
66
- `)}}catch(d){a.e(d)}finally{a.f()}r=He.getHeader("To"),He.to_tag||(r+=";tag=".concat(Du.newTag())),o+="To: ".concat(r,`\r
67
- `),o+="From: ".concat(He.getHeader("From"),`\r
68
- `),o+="Call-ID: ".concat(He.call_id,`\r
69
- `),o+="CSeq: ".concat(He.cseq," ").concat(He.method,`\r
70
- `),o+=`\r
71
- `,r_.send(o)}var Uu={};function Fc(c,s){var r;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(r=sm(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,d;return{s:function(){r=c[Symbol.iterator]()},n:function(){var h=r.next();return t=h.done,h},e:function(h){n=!0,d=h},f:function(){try{!t&&r.return!=null&&r.return()}finally{if(n)throw d}}}}function sm(c,s){if(c){if(typeof c=="string")return jc(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 jc(c,s)}}function jc(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 ar=bt(),En=it,Ca=is(),qc=Gs(),Ra=Ou,Ia=Bs;Uu.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method: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:"".concat(ar.createRandomToken(12),".invalid")};var Bl={mandatory:{sockets:function(s){var r=[];if(Ra.isSocket(s))r.push({socket:s});else if(Array.isArray(s)&&s.length){var o=Fc(s),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&Ra.isSocket(t.socket)?r.push(t):Ra.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(En.SIP,":").concat(s));var r=qc.parse(s);if(r)return r.user?r:void 0}},optional:{authorization_user:function(s){if(Ca.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(ar.isDecimal(s)){var r=Number(s);if(r>0)return r}},connection_recovery_min_interval:function(s){if(ar.isDecimal(s)){var r=Number(s);if(r>0)return r}},contact_uri:function(s){if(typeof s=="string"){var r=Ca.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)),Ca.parse(s,"uuid")!==-1)return s},no_answer_timeout:function(s){if(ar.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===En.INVITE||s===En.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(ar.isDecimal(s)){var r=Number(s);if(r>0)return r}},registrar_server:function(s){/^sip:/i.test(s)||(s="".concat(En.SIP,":").concat(s));var r=qc.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=Fc(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}}};Uu.load=function(c,s){for(var r in Bl.mandatory)if(s.hasOwnProperty(r)){var o=s[r],a=Bl.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new Ia.ConfigurationError(r,o)}else throw new Ia.ConfigurationError(r);for(var t in Bl.optional)if(s.hasOwnProperty(t)){var n=s[t];if(ar.isEmpty(n))continue;var d=Bl.optional[t](n);if(d!==void 0)c[t]=d;else throw new Ia.ConfigurationError(t,n)}};function Co(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Co=function(r){return typeof r}:Co=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Co(c)}function nm(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Vc(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 Bc(c,s,r){return s&&Vc(c.prototype,s),r&&Vc(c,r),c}function rm(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&&mu(c,s)}function mu(c,s){return mu=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},mu(c,s)}function im(c){var s=om();return function(){var o=xo(c),a;if(s){var t=xo(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return lm(this,a)}}function lm(c,s){return s&&(Co(s)==="object"||typeof s=="function")?s:i_(c)}function i_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function om(){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 xo(c){return xo=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},xo(c)}var am=ft.EventEmitter,um=_t,pt=it,cm=Xh,Gc=lp,Wc=vp,Kc=Np,ba=al,fm=$p,Gl=bt(),_m=Bs,hm=Gs(),dm=s_,wa=vs,pm=Yp,Oa=Uu,je=new um("UA"),Tt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},mm=function(c){rm(r,c);var s=im(r);Bc(r,null,[{key:"C",get:function(){return Tt}}]);function r(o){var a;if(nm(this,r),je.debug("new() [configuration:%o]",o),a=s.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},Oa.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=Tt.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=Tt.STATUS_NOT_READY,a._error=Tt.CONFIGURATION_ERROR,t}return a._registrator=new cm(i_(a)),a}return Bc(r,[{key:"start",value:function(){je.debug("start()"),this._status===Tt.STATUS_INIT?this._transport.connect():this._status===Tt.STATUS_USER_CLOSED?(je.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=Tt.STATUS_INIT,this._transport.connect()):this._status===Tt.STATUS_READY?je.debug("UA is in READY status, not restarted"):je.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){je.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(a){je.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){je.debug("call()");var n=new Gc(this);return n.connect(a,t),n}},{key:"sendMessage",value:function(a,t,n){je.debug("sendMessage()");var d=new Wc(this);return d.send(a,t,n),d}},{key:"sendOptions",value:function(a,t,n){je.debug("sendOptions()");var d=new Kc(this);return d.send(a,t,n),d}},{key:"terminateSessions",value:function(a){je.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(je.debug("stop()"),this._dynConfiguration={},this._status===Tt.STATUS_USER_CLOSED){je.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)){je.debug("closing session ".concat(n));try{this._sessions[n].terminate()}catch{}}for(var d in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,d))try{this._applicants[d].close()}catch{}this._status=Tt.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 Gl.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:je.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 je.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){je.debug("Request-URI does not point to us"),a.method!==pt.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===pt.SIPS){a.reply_sl(416);return}if(!ba.checkTransaction(this,a)){if(t===pt.INVITE?new ba.InviteServerTransaction(this,this._transport,a):t!==pt.ACK&&t!==pt.CANCEL&&new ba.NonInviteServerTransaction(this,this._transport,a),t===pt.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var n=new Kc(this);n.init_incoming(a)}else if(t===pt.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var d=new Wc(this);d.init_incoming(a)}else if(t===pt.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===pt.NOTIFY?(h=this._findSession(a),h?h.receiveRequest(a):(je.debug("received NOTIFY request for a non existent subscription"),a.reply(481,"Subscription does not exist"))):t!==pt.ACK&&a.reply(481);else switch(t){case pt.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 Gc(this),h.init_incoming(a);else je.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case pt.BYE:a.reply(481);break;case pt.CANCEL:h=this._findSession(a),h?h.receiveRequest(a):je.debug("received CANCEL request for a non existent session");break;case pt.ACK:break;case pt.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,d=a.to_tag,_=t+n,h=this._sessions[_],g=t+d,T=this._sessions[g];return h||T||null}},{key:"_findDialog",value:function(a,t,n){var d=a+t+n,_=this._dialogs[d];return _||(d=a+n+t,_=this._dialogs[d],_||null)}},{key:"_loadConfig",value:function(a){try{Oa.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=Gl.newUUID()),this._configuration.jssip_id=Gl.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new fm(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=gm.bind(this),this._transport.onconnect=Tm.bind(this),this._transport.ondisconnect=vm.bind(this),this._transport.ondata=Em.bind(this)}catch(g){throw je.warn(g),new _m.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 hm("sip",Gl.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString: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 d=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var _ in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,_)&&(d.indexOf(_)!==-1?Object.defineProperty(this._configuration,_,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,_,{writable:!1,configurable:!1}));je.debug("configuration parameters after validation:");for(var h in this._configuration)if(Object.prototype.hasOwnProperty.call(Oa.settings,h))switch(h){case"uri":case"registrar_server":je.debug("- ".concat(h,": ").concat(this._configuration[h]));break;case"password":case"ha1":case"authorization_jwt":je.debug("- ".concat(h,": NOT SHOWN"));break;default:je.debug("- ".concat(h,": ").concat(JSON.stringify(this._configuration[h])))}}},{key:"C",get:function(){return Tt}},{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}(am);function gm(c){this.emit("connecting",c)}function Tm(c){this._status!==Tt.STATUS_USER_CLOSED&&(this._status=Tt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function vm(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!==Tt.STATUS_USER_CLOSED&&(this._status=Tt.STATUS_NOT_READY,this._error=Tt.NETWORK_ERROR)}function Em(c){var s=c.transport,r=c.message;if(r=dm.parseMessage(r,this),!!r&&!(this._status===Tt.STATUS_USER_CLOSED&&r instanceof wa.IncomingRequest)&&pm(r,this,s)){if(r instanceof wa.IncomingRequest)r.transport=s,this.receiveRequest(r);else if(r instanceof wa.IncomingResponse){var o;switch(r.method){case pt.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case pt.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 Yc(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 ym(c,s,r){return s&&Yc(c.prototype,s),r&&Yc(c,r),c}var Am=_t,Cm=is(),Ot=new Am("WebSocketInterface"),Rm=function(){function c(s){Sm(this,c),Ot.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;var r=Cm.parse(s,"absoluteURI");if(r===-1)throw Ot.warn("invalid WebSocket URI: ".concat(s)),new TypeError("Invalid argument: ".concat(s));if(r.scheme!=="wss"&&r.scheme!=="ws")throw Ot.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 ym(c,[{key:"connect",value:function(){if(Ot.debug("connect()"),this.isConnected()){Ot.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){Ot.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),Ot.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(){Ot.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 Ot.debug("send()"),this.isConnected()?(this._ws.send(r),!0):(Ot.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(){Ot.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(r){var o=r.wasClean,a=r.code,t=r.reason;Ot.debug("WebSocket ".concat(this._url," closed")),o===!1&&Ot.debug("WebSocket abrupt disconnection"),this.ondisconnect(!o,a,t)}},{key:"_onMessage",value:function(r){var o=r.data;Ot.debug("received WebSocket message"),this.ondata(o)}},{key:"_onError",value:function(r){Ot.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}(),gu=Lo,Im=it,bm=Bs,wm=bt(),Om=mm,Dm=Gs(),Nm=Cu(),Um=is(),Pm=Rm,xm=dr("JsSIP");xm("version %s",gu.version);var Jc={C:Im,Exceptions:bm,Utils:wm,UA:Om,URI:Dm,NameAddrHeader:Nm,WebSocketInterface:Pm,Grammar:Um,debug:dr,get name(){return gu.title},get version(){return gu.version}};const ir=dr,lr="JsSIP";var at=class{constructor(s){s?(this._debug=ir.default(`${lr}:${s}`),this._warn=ir.default(`${lr}:WARN:${s}`),this._error=ir.default(`${lr}:ERROR:${s}`)):(this._debug=ir.default(lr),this._warn=ir.default(`${lr}:WARN`),this._error=ir.default(`${lr}: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 Pu=Xe(at),zc=Lo;var De={USER_AGENT:`${zc.title} ${zc.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 $=Xe(De);var et={},Da,Xc;function xu(){if(Xc)return Da;Xc=1;const c=Es(),s=ls();return Da=class l_{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 l_(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}},Da}var Na,Qc;function ls(){return Qc||(Qc=1,Na=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:H,alphanum:L,reserved:ae,unreserved:N,mark:j,escaped:Se,LWS:ve,SWS:M,HCOLON:D,TEXT_UTF8_TRIM:B,TEXT_UTF8char:V,UTF8_NONASCII:J,UTF8_CONT:F,LHEX:X,token:U,token_nodot:P,separators:se,word:tt,STAR:ee,SLASH:W,EQUAL:G,LPAREN:re,RPAREN:ge,RAQUOT:be,LAQUOT:xe,COMMA:Ce,SEMI:le,COLON:ye,LDQUOT:st,RDQUOT:lt,comment:Ee,ctext:Ae,quoted_string:Ie,quoted_string_clean:Oe,qdtext:pe,quoted_pair:ue,SIP_URI_noparams:de,SIP_URI:we,uri_scheme:Ne,uri_scheme_sips:Qe,uri_scheme_sip:Le,userinfo:kt,user:ht,user_unreserved:Rn,password:In,hostport:Ws,host:Xt,hostname:os,domainlabel:Ks,toplabel:bn,IPv6reference:wn,IPv6address:Ys,h16:me,ls32:oe,IPv4address:ot,dec_octet:Gt,port:ys,uri_parameters:gr,uri_parameter:On,transport_param:Dn,user_param:Tr,method_param:vr,ttl_param:Er,maddr_param:Sr,lr_param:yr,other_param:Ar,pname:Cr,pvalue:Rr,paramchar:As,param_unreserved:Cs,headers:Ir,header:Js,hname:zs,hvalue:br,hnv_unreserved:Rs,Request_Response:Xs,Request_Line:hl,Request_URI:wr,absoluteURI:Nn,hier_part:Un,net_path:Or,abs_path:Qs,opaque_part:Zs,uric:Is,uric_no_slash:bs,path_segments:Dr,segment:en,param:ws,pchar:as,scheme:Os,authority:Nr,srvr:Ur,reg_name:Pr,query:xr,SIP_Version:Pn,INVITEm:xn,ACKm:Mr,OPTIONSm:kr,BYEm:Lr,CANCELm:$r,REGISTERm:Hr,SUBSCRIBEm:Fr,NOTIFYm:jr,REFERm:qr,Method:tn,Status_Line:sn,Status_Code:Vr,extension_code:Br,Reason_Phrase:Gr,Allow_Events:dl,Call_ID:Go,Contact:Wo,contact_param:Mn,name_addr:Lt,display_name:$t,contact_params:Ds,c_p_q:kn,c_p_expires:Wr,delta_seconds:Qt,qvalue:Zt,generic_param:Ge,gen_value:We,Content_Disposition:pl,disp_type:ml,disp_param:Ln,handling_param:$n,Content_Encoding:gl,Content_Length:Ko,Content_Type:Yo,media_type:Tl,m_type:Kr,discrete_type:Yr,composite_type:Jr,extension_token:nn,x_token:rn,m_subtype:zr,m_parameter:Hn,m_value:Fn,CSeq:vl,CSeq_value:El,Expires:Sl,Event:Jo,event_type:ln,From:on,from_param:Xr,tag_param:an,Max_Forwards:Qr,Min_Expires:zo,Name_Addr_Header:Xo,Proxy_Authenticate:Qo,challenge:Zr,other_challenge:jn,auth_param:Ns,digest_cln:es,realm:un,realm_value:ei,domain:ti,URI:cn,nonce:fn,nonce_value:si,opaque:ni,stale:ri,algorithm:ii,qop_options:li,qop_value:_n,Proxy_Require:qn,Record_Route:Zo,rec_route:Vn,Reason:Bn,reason_param:oi,reason_cause:Gn,Require:yl,Route:ea,route_param:Wn,Subscription_State:Kn,substate_value:Al,subexp_params:Yn,event_reason_value:Jn,Subject:Cl,Supported:ta,To:sa,to_param:ai,Via:ui,via_param:zn,via_params:Us,via_ttl:Xn,via_maddr:ci,via_received:fi,via_branch:_i,response_port:hi,rport:di,sent_protocol:pi,protocol_name:mi,transport:gi,sent_by:Ti,via_host:vi,via_port:Ei,ttl:Qn,WWW_Authenticate:Si,Session_Expires:na,s_e_expires:Rl,s_e_params:Zn,s_e_refresher:er,extension_header:Il,header_value:bl,message_body:wl,uuid_URI:ra,uuid:Ol,hex4:Ht,hex8:Ft,hex12:yi,Refer_To:Dl,Replaces:ia,call_id:Nl,replaces_param:tr,to_tag:sr,from_tag:Ai,early_flag:Ci};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,d=[];function _(i){t<n||(t>n&&(n=t,d=[]),d.push(i))}function h(){var i;return r.substr(t,2)===`\r
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=H()),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 H(){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=j()),i}function j(){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(p,m){return m.join("")}(u,i)),i===null&&(t=u),i}function ve(){var i,e,l,u,f,p;for(u=t,f=t,p=t,i=[],e=y();e!==null;)i.push(e),e=y();if(i!==null?(e=h(),e!==null?i=[i,e]:(i=null,t=p)):(i=null,t=p),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=H());e!==null;)i.push(e),e=I(),e===null&&(e=H());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(p){return":"}()),i===null&&(t=u),i}function B(){var i,e,l,u,f,p,m;if(f=t,p=t,e=V(),e!==null)for(i=[];e!==null;)i.push(e),e=V();else i=null;if(i!==null){for(e=[],m=t,l=[],u=ve();u!==null;)l.push(u),u=ve();for(l!==null?(u=V(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;){for(e.push(l),m=t,l=[],u=ve();u!==null;)l.push(u),u=ve();l!==null?(u=V(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m)}e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;return i!==null&&(i=function(v){return r.substring(t,v)}(f)),i===null&&(t=f),i}function V(){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 F(){var i;return/^[\x80-\xBF]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[\\x80-\\xBF]")),i}function X(){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=H())))))))))))))))))),i}function tt(){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(p){return"*"}()),i===null&&(t=u),i}function W(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p){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(p){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(p){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(p){return")"}()),i===null&&(t=u),i}function be(){var i,e,l,u;return l=t,u=t,r.charCodeAt(t)===62?(i=">",t++):(i=null,_('">"')),i!==null?(e=M(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return">"}()),i===null&&(t=l),i}function xe(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(r.charCodeAt(t)===60?(e="<",t++):(e=null,_('"<"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return"<"}()),i===null&&(t=l),i}function Ce(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(r.charCodeAt(t)===44?(e=",",t++):(e=null,_('","')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p){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(p){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(p){return":"}()),i===null&&(t=u),i}function st(){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 lt(){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=ue(),l===null&&(l=Ee()));l!==null;)e.push(l),l=Ae(),l===null&&(l=ue(),l===null&&(l=Ee()));e!==null?(l=ge(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)}else i=null,t=u;return i}function Ae(){var i;return/^[!-']/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[!-']")),i===null&&(/^[*-[]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[*-[]")),i===null&&(/^[\]-~]/.test(r.charAt(t))?(i=r.charAt(t),t++):(i=null,_("[\\]-~]")),i===null&&(i=J(),i===null&&(i=ve())))),i}function Ie(){var i,e,l,u,f,p;if(f=t,p=t,i=M(),i!==null)if(e=C(),e!==null){for(l=[],u=pe(),u===null&&(u=ue());u!==null;)l.push(u),u=pe(),u===null&&(u=ue());l!==null?(u=C(),u!==null?i=[i,e,l,u]:(i=null,t=p)):(i=null,t=p)}else i=null,t=p;else i=null,t=p;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,p;if(f=t,p=t,i=M(),i!==null)if(e=C(),e!==null){for(l=[],u=pe(),u===null&&(u=ue());u!==null;)l.push(u),u=pe(),u===null&&(u=ue());l!==null?(u=C(),u!==null?i=[i,e,l,u]:(i=null,t=p)):(i=null,t=p)}else i=null,t=p;else i=null,t=p;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 ue(){var i,e,l;return l=t,r.charCodeAt(t)===92?(i="\\",t++):(i=null,_('"\\\\"')),i!==null?(/^[\0-\t]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[\\0-\\t]")),e===null&&(/^[\x0B-\f]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[\\x0B-\\f]")),e===null&&(/^[\x0E-]/.test(r.charAt(t))?(e=r.charAt(t),t++):(e=null,_("[\\x0E-]")))),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function de(){var i,e,l,u,f,p;return f=t,p=t,i=Ne(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=kt(),l=l!==null?l:"",l!==null?(u=Ws(),u!==null?i=[i,e,l,u]:(i=null,t=p)):(i=null,t=p)):(i=null,t=p)):(i=null,t=p),i!==null&&(i=function(m){try{b.uri=new Pl(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,p,m,v;return m=t,v=t,i=Ne(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=kt(),l=l!==null?l:"",l!==null?(u=Ws(),u!==null?(f=gr(),f!==null?(p=Ir(),p=p!==null?p:"",p!==null?i=[i,e,l,u,f,p]:(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 Pl(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=Qe(),i===null&&(i=Le()),i}function Qe(){var i,e;return e=t,r.substr(t,4).toLowerCase()==="sips"?(i=r.substr(t,4),t+=4):(i=null,_('"sips"')),i!==null&&(i=function(l,u){b.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Le(){var i,e;return e=t,r.substr(t,3).toLowerCase()==="sip"?(i=r.substr(t,3),t+=3):(i=null,_('"sip"')),i!==null&&(i=function(l,u){b.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function kt(){var i,e,l,u,f,p;return u=t,f=t,i=ht(),i!==null?(p=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=In(),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p),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 ht(){var i,e;if(e=N(),e===null&&(e=Se(),e===null&&(e=Rn())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=Se(),e===null&&(e=Rn()));else i=null;return i}function Rn(){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 In(){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 Ws(){var i,e,l,u,f;return u=t,i=Xt(),i!==null?(f=t,r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=ys(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function Xt(){var i,e;return e=t,i=os(),i===null&&(i=ot(),i===null&&(i=wn())),i!==null&&(i=function(l){return b.host=r.substring(t,l).toLowerCase(),b.host}(e)),i===null&&(t=e),i}function os(){var i,e,l,u,f,p;for(u=t,f=t,i=[],p=t,e=Ks(),e!==null?(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p);e!==null;)i.push(e),p=t,e=Ks(),e!==null?(r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p);return i!==null?(e=bn(),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 Ks(){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 bn(){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 wn(){var i,e,l,u,f;return u=t,f=t,r.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i!==null?(e=Ys(),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(p){return b.host_type="IPv6",r.substring(t,p)}(u)),i===null&&(t=u),i}function Ys(){var i,e,l,u,f,p,m,v,S,O,ie,Ue,wt,Ps,k,R;return Ps=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?(p=":",t++):(p=null,_('":"')),p!==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?(wt=oe(),wt!==null?i=[i,e,l,u,f,p,m,v,S,O,ie,Ue,wt]:(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?(p=me(),p!==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,p,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?(p=me(),p!==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,p,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?(p=me(),p!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?i=[i,e,l,u,f,p,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?(p=oe(),p!==null?i=[i,e,l,u,f,p]:(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?(p=":",t++):(p=null,_('":"')),p!==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,p,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?(p=me(),p!==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,p,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?(p=":",t++):(p=null,_('":"')),p!==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,p,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?(p=me(),p!==null?(r.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(v=oe(),v!==null?i=[i,e,l,u,f,p,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?(p=me(),p!==null?f=[f,p]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(r.substr(t,2)==="::"?(p="::",t+=2):(p=null,_('"::"')),p!==null?(m=oe(),m!==null?i=[i,e,l,u,f,p,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?(p=me(),p!==null?f=[f,p]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(R=t,r.charCodeAt(t)===58?(p=":",t++):(p=null,_('":"')),p!==null?(m=me(),m!==null?p=[p,m]:(p=null,t=R)):(p=null,t=R),p=p!==null?p:"",p!==null?(r.substr(t,2)==="::"?(m="::",t+=2):(m=null,_('"::"')),m!==null?(v=me(),v!==null?i=[i,e,l,u,f,p,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?(p=me(),p!==null?f=[f,p]:(f=null,t=R)):(f=null,t=R),f=f!==null?f:"",f!==null?(R=t,r.charCodeAt(t)===58?(p=":",t++):(p=null,_('":"')),p!==null?(m=me(),m!==null?p=[p,m]:(p=null,t=R)):(p=null,t=R),p=p!==null?p:"",p!==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,p,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)}(Ps)),i===null&&(t=Ps),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=ot()),i}function ot(){var i,e,l,u,f,p,m,v,S;return v=t,S=t,i=Gt(),i!==null?(r.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e!==null?(l=Gt(),l!==null?(r.charCodeAt(t)===46?(u=".",t++):(u=null,_('"."')),u!==null?(f=Gt(),f!==null?(r.charCodeAt(t)===46?(p=".",t++):(p=null,_('"."')),p!==null?(m=Gt(),m!==null?i=[i,e,l,u,f,p,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 Gt(){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 ys(){var i,e,l,u,f,p,m;return p=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}(p,i)),i===null&&(t=p),i}function gr(){var i,e,l,u;for(i=[],u=t,r.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=On(),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=On(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function On(){var i;return i=Dn(),i===null&&(i=Tr(),i===null&&(i=vr(),i===null&&(i=Er(),i===null&&(i=Sr(),i===null&&(i=yr(),i===null&&(i=Ar())))))),i}function Dn(){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,p){b.uri_params||(b.uri_params={}),b.uri_params.transport=p.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function Tr(){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,p){b.uri_params||(b.uri_params={}),b.uri_params.user=p.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function vr(){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=tn(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,p){b.uri_params||(b.uri_params={}),b.uri_params.method=p}(l,i[1])),i===null&&(t=l),i}function Er(){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=Qn(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,p){b.params||(b.params={}),b.params.ttl=p}(l,i[1])),i===null&&(t=l),i}function Sr(){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=Xt(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,p){b.uri_params||(b.uri_params={}),b.uri_params.maddr=p}(l,i[1])),i===null&&(t=l),i}function yr(){var i,e,l,u,f,p;return u=t,f=t,r.substr(t,2).toLowerCase()==="lr"?(i=r.substr(t,2),t+=2):(i=null,_('"lr"')),i!==null?(p=t,r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=U(),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p),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 Ar(){var i,e,l,u,f,p;return u=t,f=t,i=Cr(),i!==null?(p=t,r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=Rr(),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p),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 Cr(){var i,e,l;if(l=t,e=As(),e!==null)for(i=[];e!==null;)i.push(e),e=As();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function Rr(){var i,e,l;if(l=t,e=As(),e!==null)for(i=[];e!==null;)i.push(e),e=As();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function As(){var i;return i=Cs(),i===null&&(i=N(),i===null&&(i=Se())),i}function Cs(){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 Ir(){var i,e,l,u,f,p,m;if(p=t,r.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i!==null)if(e=Js(),e!==null){for(l=[],m=t,r.charCodeAt(t)===38?(u="&",t++):(u=null,_('"&"')),u!==null?(f=Js(),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=Js(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);l!==null?i=[i,e,l]:(i=null,t=p)}else i=null,t=p;else i=null,t=p;return i}function Js(){var i,e,l,u,f;return u=t,f=t,i=zs(),i!==null?(r.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=br(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,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 zs(){var i,e;if(e=Rs(),e===null&&(e=N(),e===null&&(e=Se())),e!==null)for(i=[];e!==null;)i.push(e),e=Rs(),e===null&&(e=N(),e===null&&(e=Se()));else i=null;return i}function br(){var i,e;for(i=[],e=Rs(),e===null&&(e=N(),e===null&&(e=Se()));e!==null;)i.push(e),e=Rs(),e===null&&(e=N(),e===null&&(e=Se()));return i}function Rs(){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 Xs(){var i;return i=sn(),i===null&&(i=hl()),i}function hl(){var i,e,l,u,f,p;return p=t,i=tn(),i!==null?(e=I(),e!==null?(l=wr(),l!==null?(u=I(),u!==null?(f=Pn(),f!==null?i=[i,e,l,u,f]:(i=null,t=p)):(i=null,t=p)):(i=null,t=p)):(i=null,t=p)):(i=null,t=p),i}function wr(){var i;return i=we(),i===null&&(i=Nn()),i}function Nn(){var i,e,l,u;return u=t,i=Os(),i!==null?(r.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Un(),l===null&&(l=Zs()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Un(){var i,e,l,u,f;return u=t,i=Or(),i===null&&(i=Qs()),i!==null?(f=t,r.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e!==null?(l=xr(),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 Or(){var i,e,l,u;return u=t,r.substr(t,2)==="//"?(i="//",t+=2):(i=null,_('"//"')),i!==null?(e=Nr(),e!==null?(l=Qs(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Qs(){var i,e,l;return l=t,r.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i!==null?(e=Dr(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Zs(){var i,e,l,u;if(u=t,i=bs(),i!==null){for(e=[],l=Is();l!==null;)e.push(l),l=Is();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Is(){var i;return i=ae(),i===null&&(i=N(),i===null&&(i=Se())),i}function bs(){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 Dr(){var i,e,l,u,f,p;if(f=t,i=en(),i!==null){for(e=[],p=t,r.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=en(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,r.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=en(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function en(){var i,e,l,u,f,p;for(f=t,i=[],e=as();e!==null;)i.push(e),e=as();if(i!==null){for(e=[],p=t,r.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=ws(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,r.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=ws(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function ws(){var i,e;for(i=[],e=as();e!==null;)i.push(e),e=as();return i}function as(){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 Os(){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(p){b.scheme=r.substring(t,p)}(u)),i===null&&(t=u),i}function Nr(){var i;return i=Ur(),i===null&&(i=Pr()),i}function Ur(){var i,e,l,u;return l=t,u=t,i=kt(),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=Ws(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function Pr(){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 xr(){var i,e;for(i=[],e=Is();e!==null;)i.push(e),e=Is();return i}function Pn(){var i,e,l,u,f,p,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(p=g(),p!==null)for(f=[];p!==null;)f.push(p),p=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 xn(){var i;return r.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,_('"INVITE"')),i}function Mr(){var i;return r.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,_('"ACK"')),i}function kr(){var i;return r.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,_('"OPTIONS"')),i}function Lr(){var i;return r.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,_('"BYE"')),i}function $r(){var i;return r.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,_('"CANCEL"')),i}function Hr(){var i;return r.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,_('"REGISTER"')),i}function Fr(){var i;return r.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,_('"SUBSCRIBE"')),i}function jr(){var i;return r.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,_('"NOTIFY"')),i}function qr(){var i;return r.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,_('"REFER"')),i}function tn(){var i,e;return e=t,i=xn(),i===null&&(i=Mr(),i===null&&(i=kr(),i===null&&(i=Lr(),i===null&&(i=$r(),i===null&&(i=Hr(),i===null&&(i=Fr(),i===null&&(i=jr(),i===null&&(i=qr(),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 sn(){var i,e,l,u,f,p;return p=t,i=Pn(),i!==null?(e=I(),e!==null?(l=Vr(),l!==null?(u=I(),u!==null?(f=Gr(),f!==null?i=[i,e,l,u,f]:(i=null,t=p)):(i=null,t=p)):(i=null,t=p)):(i=null,t=p)):(i=null,t=p),i}function Vr(){var i,e;return e=t,i=Br(),i!==null&&(i=function(l,u){b.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function Br(){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 Gr(){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=F(),e===null&&(e=I(),e===null&&(e=H()))))));e!==null;)i.push(e),e=ae(),e===null&&(e=N(),e===null&&(e=Se(),e===null&&(e=J(),e===null&&(e=F(),e===null&&(e=I(),e===null&&(e=H()))))));return i!==null&&(i=function(u){b.reason_phrase=r.substring(t,u)}(l)),i===null&&(t=l),i}function dl(){var i,e,l,u,f,p;if(f=t,i=ln(),i!==null){for(e=[],p=t,l=Ce(),l!==null?(u=ln(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=Ce(),l!==null?(u=ln(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Go(){var i,e,l,u,f,p;return u=t,f=t,i=tt(),i!==null?(p=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=tt(),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p),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 Wo(){var i,e,l,u,f,p,m;if(f=t,i=ee(),i===null)if(p=t,i=Mn(),i!==null){for(e=[],m=t,l=Ce(),l!==null?(u=Mn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Ce(),l!==null?(u=Mn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;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 Mn(){var i,e,l,u,f,p,m;if(f=t,p=t,i=de(),i===null&&(i=Lt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Ds(),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=Ds(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;return i!==null&&(i=function(v){var S;b.multi_header||(b.multi_header=[]);try{S=new us(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 Lt(){var i,e,l,u,f;return f=t,i=$t(),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 $t(){var i,e,l,u,f,p,m;if(f=t,p=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=p)}else i=null,t=p;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 Ds(){var i;return i=kn(),i===null&&(i=Wr(),i===null&&(i=Ge())),i}function kn(){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=Zt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,m){b.params||(b.params={}),b.params.q=m}(u,i[2])),i===null&&(t=u),i}function Wr(){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=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,m){b.params||(b.params={}),b.params.expires=m}(u,i[2])),i===null&&(t=u),i}function Qt(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){return parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function Zt(){var i,e,l,u,f,p,m,v;return p=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))}(p)),i===null&&(t=p),i}function Ge(){var i,e,l,u,f,p;return u=t,f=t,i=U(),i!==null?(p=t,e=G(),e!==null?(l=We(),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,v,S){b.params||(b.params={}),typeof S>"u"?S=void 0:S=S[1],b.params[v.toLowerCase()]=S}(u,i[0],i[1])),i===null&&(t=u),i}function We(){var i;return i=U(),i===null&&(i=Xt(),i===null&&(i=Ie())),i}function pl(){var i,e,l,u,f,p;if(f=t,i=ml(),i!==null){for(e=[],p=t,l=le(),l!==null?(u=Ln(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=le(),l!==null?(u=Ln(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function ml(){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 Ln(){var i;return i=$n(),i===null&&(i=Ge()),i}function $n(){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 gl(){var i,e,l,u,f,p;if(f=t,i=U(),i!==null){for(e=[],p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Ko(){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 Yo(){var i,e;return e=t,i=Tl(),i!==null&&(i=function(l){b=r.substring(t,l)}(e)),i===null&&(t=e),i}function Tl(){var i,e,l,u,f,p,m,v;if(m=t,i=Kr(),i!==null)if(e=W(),e!==null)if(l=zr(),l!==null){for(u=[],v=t,f=le(),f!==null?(p=Hn(),p!==null?f=[f,p]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=le(),f!==null?(p=Hn(),p!==null?f=[f,p]:(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 Kr(){var i;return i=Yr(),i===null&&(i=Jr()),i}function Yr(){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=nn()))))),i}function Jr(){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=nn())),i}function nn(){var i;return i=U(),i===null&&(i=rn()),i}function rn(){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 zr(){var i;return i=nn(),i===null&&(i=U()),i}function Hn(){var i,e,l,u;return u=t,i=U(),i!==null?(e=G(),e!==null?(l=Fn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Fn(){var i;return i=U(),i===null&&(i=Ie()),i}function vl(){var i,e,l,u;return u=t,i=El(),i!==null?(e=ve(),e!==null?(l=tn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function El(){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 Sl(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function Jo(){var i,e,l,u,f,p,m;if(f=t,p=t,i=ln(),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;return i!==null&&(i=function(v,S){b.event=S.join("").toLowerCase()}(f,i[0])),i===null&&(t=f),i}function ln(){var i,e,l,u,f,p;if(f=t,i=P(),i!==null){for(e=[],p=t,r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,r.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function on(){var i,e,l,u,f,p,m;if(f=t,p=t,i=de(),i===null&&(i=Lt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Xr(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=Xr(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;return i!==null&&(i=function(v){var S=b.tag;try{b=new us(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function Xr(){var i;return i=an(),i===null&&(i=Ge()),i}function an(){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(p,m){b.tag=m}(u,i[2])),i===null&&(t=u),i}function Qr(){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 zo(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){b=u}(e,i)),i===null&&(t=e),i}function Xo(){var i,e,l,u,f,p,m,v,S,O;for(v=t,S=t,i=[],e=$t();e!==null;)i.push(e),e=$t();if(i!==null)if(e=xe(),e!==null)if(l=we(),l!==null)if(u=be(),u!==null){for(f=[],O=t,p=le(),p!==null?(m=Ge(),m!==null?p=[p,m]:(p=null,t=O)):(p=null,t=O);p!==null;)f.push(p),O=t,p=le(),p!==null?(m=Ge(),m!==null?p=[p,m]:(p=null,t=O)):(p=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 us(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=v),i}function Qo(){var i;return i=Zr(),i}function Zr(){var i,e,l,u,f,p,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=es(),l!==null){for(u=[],v=t,f=Ce(),f!==null?(p=es(),p!==null?f=[f,p]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Ce(),f!==null?(p=es(),p!==null?f=[f,p]:(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=jn()),i}function jn(){var i,e,l,u,f,p,m,v;if(m=t,i=U(),i!==null)if(e=ve(),e!==null)if(l=Ns(),l!==null){for(u=[],v=t,f=Ce(),f!==null?(p=Ns(),p!==null?f=[f,p]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=Ce(),f!==null?(p=Ns(),p!==null?f=[f,p]:(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 Ns(){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 es(){var i;return i=un(),i===null&&(i=ti(),i===null&&(i=fn(),i===null&&(i=ni(),i===null&&(i=ri(),i===null&&(i=ii(),i===null&&(i=li(),i===null&&(i=Ns()))))))),i}function un(){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=ei(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ei(){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 ti(){var i,e,l,u,f,p,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=st(),l!==null)if(u=cn(),u!==null){if(f=[],S=t,m=I(),m!==null)for(p=[];m!==null;)p.push(m),m=I();else p=null;for(p!==null?(m=cn(),m!==null?p=[p,m]:(p=null,t=S)):(p=null,t=S);p!==null;){if(f.push(p),S=t,m=I(),m!==null)for(p=[];m!==null;)p.push(m),m=I();else p=null;p!==null?(m=cn(),m!==null?p=[p,m]:(p=null,t=S)):(p=null,t=S)}f!==null?(p=lt(),p!==null?i=[i,e,l,u,f,p]:(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 cn(){var i;return i=Nn(),i===null&&(i=Qs()),i}function fn(){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=si(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function si(){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 ni(){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(p,m){b.opaque=m}(u,i[2])),i===null&&(t=u),i}function ri(){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(p){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(p){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 ii(){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(p,m){b.algorithm=m.toUpperCase()}(u,i[2])),i===null&&(t=u),i}function li(){var i,e,l,u,f,p,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=st(),l!==null){if(S=t,u=_n(),u!==null){for(f=[],O=t,r.charCodeAt(t)===44?(p=",",t++):(p=null,_('","')),p!==null?(m=_n(),m!==null?p=[p,m]:(p=null,t=O)):(p=null,t=O);p!==null;)f.push(p),O=t,r.charCodeAt(t)===44?(p=",",t++):(p=null,_('","')),p!==null?(m=_n(),m!==null?p=[p,m]:(p=null,t=O)):(p=null,t=O);f!==null?u=[u,f]:(u=null,t=S)}else u=null,t=S;u!==null?(f=lt(),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 _n(){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 qn(){var i,e,l,u,f,p;if(f=t,i=U(),i!==null){for(e=[],p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Zo(){var i,e,l,u,f,p,m;if(f=t,p=t,i=Vn(),i!==null){for(e=[],m=t,l=Ce(),l!==null?(u=Vn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Ce(),l!==null?(u=Vn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;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 Vn(){var i,e,l,u,f,p,m;if(f=t,p=t,i=Lt(),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;return i!==null&&(i=function(v){var S;b.multi_header||(b.multi_header=[]);try{S=new us(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 Bn(){var i,e,l,u,f,p,m;if(f=t,p=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=oi(),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=oi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;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 oi(){var i;return i=Gn(),i===null&&(i=Ge()),i}function Gn(){var i,e,l,u,f,p;if(f=t,p=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=p)}else i=null,t=p;else i=null,t=p;return i!==null&&(i=function(m,v){b.cause=parseInt(v.join(""))}(f,i[2])),i===null&&(t=f),i}function yl(){var i,e,l,u,f,p;if(f=t,i=U(),i!==null){for(e=[],p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function ea(){var i,e,l,u,f,p;if(f=t,i=Wn(),i!==null){for(e=[],p=t,l=Ce(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=Ce(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Wn(){var i,e,l,u,f,p;if(f=t,i=Lt(),i!==null){for(e=[],p=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Kn(){var i,e,l,u,f,p;if(f=t,i=Al(),i!==null){for(e=[],p=t,l=le(),l!==null?(u=Yn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=le(),l!==null?(u=Yn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Al(){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 Yn(){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=Jn(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,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=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,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=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,m){typeof m<"u"&&(b.retry_after=m)}(u,i[2])),i===null&&(t=u),i===null&&(i=Ge()))),i}function Jn(){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 Cl(){var i;return i=B(),i=i!==null?i:"",i}function ta(){var i,e,l,u,f,p;if(f=t,i=U(),i!==null){for(e=[],p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=Ce(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i=i!==null?i:"",i}function sa(){var i,e,l,u,f,p,m;if(f=t,p=t,i=de(),i===null&&(i=Lt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=ai(),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=ai(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;return i!==null&&(i=function(v){var S=b.tag;try{b=new us(b.uri,b.display_name,b.params),S&&b.setParam("tag",S)}catch{b=-1}}()),i===null&&(t=f),i}function ai(){var i;return i=an(),i===null&&(i=Ge()),i}function ui(){var i,e,l,u,f,p;if(f=t,i=zn(),i!==null){for(e=[],p=t,l=Ce(),l!==null?(u=zn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=Ce(),l!==null?(u=zn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function zn(){var i,e,l,u,f,p,m,v;if(m=t,i=pi(),i!==null)if(e=ve(),e!==null)if(l=Ti(),l!==null){for(u=[],v=t,f=le(),f!==null?(p=Us(),p!==null?f=[f,p]:(f=null,t=v)):(f=null,t=v);f!==null;)u.push(f),v=t,f=le(),f!==null?(p=Us(),p!==null?f=[f,p]:(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 Us(){var i;return i=Xn(),i===null&&(i=ci(),i===null&&(i=fi(),i===null&&(i=_i(),i===null&&(i=hi(),i===null&&(i=Ge()))))),i}function Xn(){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=Qn(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,m){b.ttl=m}(u,i[2])),i===null&&(t=u),i}function ci(){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=Xt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,m){b.maddr=m}(u,i[2])),i===null&&(t=u),i}function fi(){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=ot(),l===null&&(l=Ys()),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(p,m){b.received=m}(u,i[2])),i===null&&(t=u),i}function _i(){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(p,m){b.branch=m}(u,i[2])),i===null&&(t=u),i}function hi(){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=di(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function di(){var i,e,l,u,f,p,m;return p=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(""))}(p,i)),i===null&&(t=p),i}function pi(){var i,e,l,u,f,p;return p=t,i=mi(),i!==null?(e=W(),e!==null?(l=U(),l!==null?(u=W(),u!==null?(f=gi(),f!==null?i=[i,e,l,u,f]:(i=null,t=p)):(i=null,t=p)):(i=null,t=p)):(i=null,t=p)):(i=null,t=p),i}function mi(){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 gi(){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 Ti(){var i,e,l,u,f;return u=t,i=vi(),i!==null?(f=t,e=ye(),e!==null?(l=Ei(),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 vi(){var i,e;return e=t,i=ot(),i===null&&(i=wn(),i===null&&(i=os())),i!==null&&(i=function(l){b.host=r.substring(t,l)}(e)),i===null&&(t=e),i}function Ei(){var i,e,l,u,f,p,m;return p=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(""))}(p,i)),i===null&&(t=p),i}function Qn(){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(p,m){return parseInt(m.join(""))}(u,i)),i===null&&(t=u),i}function Si(){var i;return i=Zr(),i}function na(){var i,e,l,u,f,p;if(f=t,i=Rl(),i!==null){for(e=[],p=t,l=le(),l!==null?(u=Zn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=le(),l!==null?(u=Zn(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Rl(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){b.expires=u}(e,i)),i===null&&(t=e),i}function Zn(){var i;return i=er(),i===null&&(i=Ge()),i}function er(){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(p,m){b.refresher=m.toLowerCase()}(u,i[2])),i===null&&(t=u),i}function Il(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=bl(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function bl(){var i,e;for(i=[],e=V(),e===null&&(e=F(),e===null&&(e=ve()));e!==null;)i.push(e),e=V(),e===null&&(e=F(),e===null&&(e=ve()));return i}function wl(){var i,e;for(i=[],e=A();e!==null;)i.push(e),e=A();return i}function ra(){var i,e,l;return l=t,r.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,_('"uuid:"')),i!==null?(e=Ol(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Ol(){var i,e,l,u,f,p,m,v,S,O,ie;return O=t,ie=t,i=Ft(),i!==null?(r.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e!==null?(l=Ht(),l!==null?(r.charCodeAt(t)===45?(u="-",t++):(u=null,_('"-"')),u!==null?(f=Ht(),f!==null?(r.charCodeAt(t)===45?(p="-",t++):(p=null,_('"-"')),p!==null?(m=Ht(),m!==null?(r.charCodeAt(t)===45?(v="-",t++):(v=null,_('"-"')),v!==null?(S=yi(),S!==null?i=[i,e,l,u,f,p,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,wt){b=r.substring(t+5,Ue)}(O,i[0])),i===null&&(t=O),i}function Ht(){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 Ft(){var i,e,l;return l=t,i=Ht(),i!==null?(e=Ht(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function yi(){var i,e,l,u;return u=t,i=Ht(),i!==null?(e=Ht(),e!==null?(l=Ht(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Dl(){var i,e,l,u,f,p,m;if(f=t,p=t,i=de(),i===null&&(i=Lt()),i!==null){for(e=[],m=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=le(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=p)}else i=null,t=p;return i!==null&&(i=function(v){try{b=new us(b.uri,b.display_name,b.params)}catch{b=-1}}()),i===null&&(t=f),i}function ia(){var i,e,l,u,f,p;if(f=t,i=Nl(),i!==null){for(e=[],p=t,l=le(),l!==null?(u=tr(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);l!==null;)e.push(l),p=t,l=le(),l!==null?(u=tr(),u!==null?l=[l,u]:(l=null,t=p)):(l=null,t=p);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Nl(){var i,e,l,u,f,p;return u=t,f=t,i=tt(),i!==null?(p=t,r.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=tt(),l!==null?e=[e,l]:(e=null,t=p)):(e=null,t=p),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 tr(){var i;return i=sr(),i===null&&(i=Ai(),i===null&&(i=Ci(),i===null&&(i=Ge()))),i}function sr(){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(p,m){b.to_tag=m}(u,i[2])),i===null&&(t=u),i}function Ai(){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(p,m){b.from_tag=m}(u,i[2])),i===null&&(t=u),i}function Ci(){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 Ul(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 la(){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 Pl=Es(),us=xu(),b={},w=a[o]();if(w===null||t!==r.length){var Ri=Math.max(t,n),Ii=Ri<r.length?r.charAt(Ri):null,xl=la();return new this.SyntaxError(Ul(d),Ii,Ri,xl.line,xl.column),-1}return b},toSource:function(){return this._source}};return s.SyntaxError=function(r,o,a,t,n){function d(_,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=d(r,o),this.offset=a,this.line=t,this.column=n},s.SyntaxError.prototype=Error.prototype,s}()),Na}var Ua,Zc;function Es(){if(Zc)return Ua;Zc=1;const c=De,s=yt(),r=ls();return Ua=class o_{static parse(a){if(a=r.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,t,n,d,_={},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=d;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 o_(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 d of this._headers[n])a.push(`${n}=${d}`);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}},Ua}var ef;function yt(){if(ef)return et;ef=1;const c=De,s=Es(),r=ls();et.str_utf8_length=n=>unescape(encodeURIComponent(n)).length;const o=et.isFunction=n=>n!==void 0?Object.prototype.toString.call(n)==="[object Function]":!1;et.isString=n=>n!==void 0?Object.prototype.toString.call(n)==="[object String]":!1,et.isDecimal=n=>!isNaN(n)&&parseFloat(n)===parseInt(n,10),et.isEmpty=n=>n===null||n===""||n===void 0||Array.isArray(n)&&n.length===0||typeof n=="number"&&isNaN(n),et.hasMethods=function(n,...d){for(const _ of d)if(o(n[_]))return!1;return!0};const a=et.createRandomToken=(n,d=32)=>{let _,h,g="";for(_=0;_<n;_++)h=Math.random()*d|0,g+=h.toString(d);return g};et.newTag=()=>a(10),et.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,d=>{const _=Math.random()*16|0;return(d==="x"?_:_&3|8).toString(16)}),et.hostType=n=>{if(n){if(n=r.parse(n,"host"),n!==-1)return n.host_type}else return};const t=et.escapeUser=n=>encodeURIComponent(decodeURIComponent(n)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return et.normalizeTarget=(n,d)=>{if(n){if(n instanceof s)return n;if(typeof n=="string"){const _=n.split("@");let h,g;switch(_.length){case 1:if(!d)return;h=n,g=d;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},et.headerize=n=>{const d={"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 d[h]&&(h=d[h]),h},et.sipErrorCause=n=>{for(const d in c.SIP_ERROR_CAUSES)if(c.SIP_ERROR_CAUSES[d].indexOf(n)!==-1)return c.causes[d];return c.causes.SIP_FAILURE_CODE},et.getRandomTestNetIP=()=>{function n(d,_){return Math.floor(Math.random()*(_-d+1)+d)}return`192.0.2.${n(1,254)}`},et.calculateMD5=n=>{function d(Ee,Ae){return Ee<<Ae|Ee>>>32-Ae}function _(Ee,Ae){const Ie=Ee&2147483648,Oe=Ae&2147483648,pe=Ee&1073741824,ue=Ae&1073741824,de=(Ee&1073741823)+(Ae&1073741823);return pe&ue?de^2147483648^Ie^Oe:pe|ue?de&1073741824?de^3221225472^Ie^Oe:de^1073741824^Ie^Oe:de^Ie^Oe}function 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,ue,de){return Ee=_(Ee,_(_(h(Ae,Ie,Oe),pe),de)),_(d(Ee,ue),Ae)}function A(Ee,Ae,Ie,Oe,pe,ue,de){return Ee=_(Ee,_(_(g(Ae,Ie,Oe),pe),de)),_(d(Ee,ue),Ae)}function C(Ee,Ae,Ie,Oe,pe,ue,de){return Ee=_(Ee,_(_(T(Ae,Ie,Oe),pe),de)),_(d(Ee,ue),Ae)}function I(Ee,Ae,Ie,Oe,pe,ue,de){return Ee=_(Ee,_(_(E(Ae,Ie,Oe),pe),de)),_(d(Ee,ue),Ae)}function H(Ee){let Ae;const Ie=Ee.length,Oe=Ie+8,ue=((Oe-Oe%64)/64+1)*16,de=new Array(ue-1);let we=0,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[ue-2]=Ie<<3,de[ue-1]=Ie>>>29,de}function L(Ee){let Ae="",Ie="",Oe,pe;for(pe=0;pe<=3;pe++)Oe=Ee>>>pe*8&255,Ie=`0${Oe.toString(16)}`,Ae=Ae+Ie.substr(Ie.length-2,2);return Ae}function ae(Ee){let Ae="";for(let Ie=0;Ie<Ee.length;Ie++){const Oe=Ee.charCodeAt(Ie);Oe<128?Ae+=String.fromCharCode(Oe):Oe>127&&Oe<2048?(Ae+=String.fromCharCode(Oe>>6|192),Ae+=String.fromCharCode(Oe&63|128)):(Ae+=String.fromCharCode(Oe>>12|224),Ae+=String.fromCharCode(Oe>>6&63|128),Ae+=String.fromCharCode(Oe&63|128))}return Ae}let N=[],j,Se,ve,M,D,B,V,J,F;const X=7,U=12,P=17,se=22,tt=5,ee=9,W=14,G=20,re=4,ge=11,be=16,xe=23,Ce=6,le=10,ye=15,st=21;for(n=ae(n),N=H(n),B=1732584193,V=4023233417,J=2562383102,F=271733878,j=0;j<N.length;j+=16)Se=B,ve=V,M=J,D=F,B=y(B,V,J,F,N[j+0],X,3614090360),F=y(F,B,V,J,N[j+1],U,3905402710),J=y(J,F,B,V,N[j+2],P,606105819),V=y(V,J,F,B,N[j+3],se,3250441966),B=y(B,V,J,F,N[j+4],X,4118548399),F=y(F,B,V,J,N[j+5],U,1200080426),J=y(J,F,B,V,N[j+6],P,2821735955),V=y(V,J,F,B,N[j+7],se,4249261313),B=y(B,V,J,F,N[j+8],X,1770035416),F=y(F,B,V,J,N[j+9],U,2336552879),J=y(J,F,B,V,N[j+10],P,4294925233),V=y(V,J,F,B,N[j+11],se,2304563134),B=y(B,V,J,F,N[j+12],X,1804603682),F=y(F,B,V,J,N[j+13],U,4254626195),J=y(J,F,B,V,N[j+14],P,2792965006),V=y(V,J,F,B,N[j+15],se,1236535329),B=A(B,V,J,F,N[j+1],tt,4129170786),F=A(F,B,V,J,N[j+6],ee,3225465664),J=A(J,F,B,V,N[j+11],W,643717713),V=A(V,J,F,B,N[j+0],G,3921069994),B=A(B,V,J,F,N[j+5],tt,3593408605),F=A(F,B,V,J,N[j+10],ee,38016083),J=A(J,F,B,V,N[j+15],W,3634488961),V=A(V,J,F,B,N[j+4],G,3889429448),B=A(B,V,J,F,N[j+9],tt,568446438),F=A(F,B,V,J,N[j+14],ee,3275163606),J=A(J,F,B,V,N[j+3],W,4107603335),V=A(V,J,F,B,N[j+8],G,1163531501),B=A(B,V,J,F,N[j+13],tt,2850285829),F=A(F,B,V,J,N[j+2],ee,4243563512),J=A(J,F,B,V,N[j+7],W,1735328473),V=A(V,J,F,B,N[j+12],G,2368359562),B=C(B,V,J,F,N[j+5],re,4294588738),F=C(F,B,V,J,N[j+8],ge,2272392833),J=C(J,F,B,V,N[j+11],be,1839030562),V=C(V,J,F,B,N[j+14],xe,4259657740),B=C(B,V,J,F,N[j+1],re,2763975236),F=C(F,B,V,J,N[j+4],ge,1272893353),J=C(J,F,B,V,N[j+7],be,4139469664),V=C(V,J,F,B,N[j+10],xe,3200236656),B=C(B,V,J,F,N[j+13],re,681279174),F=C(F,B,V,J,N[j+0],ge,3936430074),J=C(J,F,B,V,N[j+3],be,3572445317),V=C(V,J,F,B,N[j+6],xe,76029189),B=C(B,V,J,F,N[j+9],re,3654602809),F=C(F,B,V,J,N[j+12],ge,3873151461),J=C(J,F,B,V,N[j+15],be,530742520),V=C(V,J,F,B,N[j+2],xe,3299628645),B=I(B,V,J,F,N[j+0],Ce,4096336452),F=I(F,B,V,J,N[j+7],le,1126891415),J=I(J,F,B,V,N[j+14],ye,2878612391),V=I(V,J,F,B,N[j+5],st,4237533241),B=I(B,V,J,F,N[j+12],Ce,1700485571),F=I(F,B,V,J,N[j+3],le,2399980690),J=I(J,F,B,V,N[j+10],ye,4293915773),V=I(V,J,F,B,N[j+1],st,2240044497),B=I(B,V,J,F,N[j+8],Ce,1873313359),F=I(F,B,V,J,N[j+15],le,4264355552),J=I(J,F,B,V,N[j+6],ye,2734768916),V=I(V,J,F,B,N[j+13],st,1309151649),B=I(B,V,J,F,N[j+4],Ce,4149444226),F=I(F,B,V,J,N[j+11],le,3174756917),J=I(J,F,B,V,N[j+2],ye,718787259),V=I(V,J,F,B,N[j+9],st,3951481745),B=_(B,Se),V=_(V,ve),J=_(J,M),F=_(F,D);return(L(B)+L(V)+L(J)+L(F)).toLowerCase()},et.closeMediaStream=n=>{if(n)try{let d;if(n.getTracks){d=n.getTracks();for(const _ of d)_.stop()}else{d=n.getAudioTracks();for(const _ of d)_.stop();d=n.getVideoTracks();for(const _ of d)_.stop()}}catch{(typeof n.stop=="function"||typeof n.stop=="object")&&n.stop()}},et.cloneArray=n=>n&&n.slice()||[],et.cloneObject=(n,d={})=>n&&Object.assign({},n)||d,et}const a_=Pt,Mm=at,St=De,rt=yt(),tf=xu(),km=ls(),Pa=new Mm("SIPMessage");class Vo{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=rt.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",St.MAX_FORWARDS);const d=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 tf(d,h,_),this.setHeader("to",this.to.toString());const g=a.from_uri||o.configuration.uri,T={tag:a.from_tag||rt.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 tf(g,E,T),this.setHeader("from",this.from.toString());const y=a.call_id||o.configuration.jssip_id+rt.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[rt.headerize(s)]=Array.isArray(r)?r:[r]}getHeader(s){const r=this.headers[rt.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[rt.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[rt.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=a_.parse(this.body||""),this.sdp)}toString(){let s=`${this.method} ${this.ruri} SIP/2.0\r
76
- `;for(const a in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,a))for(const t of this.headers[a])s+=`${a}: ${t}\r
77
- `;for(const a of this.extraHeaders)s+=`${a.trim()}\r
78
- `;const r=[];switch(this.method){case St.REGISTER:r.push("path","gruu");break;case St.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 St.UPDATE:this.ua.configuration.session_timers&&r.push("timer"),r.push("ice");break}r.push("outbound");const o=this.ua.configuration.user_agent||St.USER_AGENT;if(s+=`Allow: ${St.ALLOWED_METHODS}\r
79
- `,s+=`Supported: ${r}\r
80
- `,s+=`User-Agent: ${o}\r
81
- `,this.body){const a=rt.str_utf8_length(this.body);s+=`Content-Length: ${a}\r
59
+ `.concat(a,`
60
+ `));this.ondata({transport:this,message:a})}},{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}}]),u}(),ah={};function Fc(u,n){var a;if(typeof Symbol>"u"||u[Symbol.iterator]==null){if(Array.isArray(u)||(a=Wp(u))||n&&u&&typeof u.length=="number"){a&&(u=a);var e=0,o=function(){};return{s:o,n:function(){return e>=u.length?{done:!0}:{done:!1,value:u[e++]}},e:function(l){throw l},f:o}}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 p=!0,t=!1,v;return{s:function(){a=u[Symbol.iterator]()},n:function(){var l=a.next();return p=l.done,l},e:function(l){t=!0,v=l},f:function(){try{!p&&a.return!=null&&a.return()}finally{if(t)throw v}}}}function Wp(u,n){if(u){if(typeof u=="string")return qc(u,n);var a=Object.prototype.toString.call(u).slice(8,-1);if(a==="Object"&&u.constructor&&(a=u.constructor.name),a==="Map"||a==="Set")return Array.from(u);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return qc(u,n)}}function qc(u,n){(n==null||n>u.length)&&(n=u.length);for(var a=0,e=new Array(n);a<n;a++)e[a]=u[a];return e}var Kp=yt,Cu=_n(),Su=Vn,fa=new Kp("Parser");ah.parseMessage=function(u,n){var a,e,o=u.indexOf(`\r
62
+ `);if(o===-1){fa.warn("parseMessage() | no CRLF found, not a SIP message");return}var p=u.substring(0,o),t=Cu.parse(p,"Request_Response");if(t===-1){fa.warn('parseMessage() | error parsing first line of SIP message: "'.concat(p,'"'));return}else t.status_code?(a=new Su.IncomingResponse,a.status_code=t.status_code,a.reason_phrase=t.reason_phrase):(a=new Su.IncomingRequest(n),a.method=t.method,a.ruri=t.uri);a.data=u;for(var v=o+2;;){if(o=Yp(u,v),o===-2){e=v+2;break}else if(o===-1){fa.warn("parseMessage() | malformed message");return}if(t=zp(a,u,v,o),t!==!0){fa.warn("parseMessage() |",t.error);return}v=o+2}if(a.hasHeader("content-length")){var C=a.getHeader("content-length");a.body=u.substr(e,C)}else a.body=u.substring(e);return a};function Yp(u,n){var a=n,e=0,o=0;if(u.substring(a,a+2).match(/(^\r\n)/))return-2;for(;e===0;){if(o=u.indexOf(`\r
63
+ `,a),o===-1)return o;!u.substring(o+2,o+4).match(/(^\r\n)/)&&u.charAt(o+2).match(/(^\s+)/)?a=o+2:e=o}return e}function zp(u,n,a,e){var o,p=n.indexOf(":",a),t=n.substring(a,p).trim(),v=n.substring(p+1,e).trim();switch(t.toLowerCase()){case"via":case"v":u.addHeader("via",v),u.getHeaders("via").length===1?(o=u.parseHeader("Via"),o&&(u.via=o,u.via_branch=o.branch)):o=0;break;case"from":case"f":u.setHeader("from",v),o=u.parseHeader("from"),o&&(u.from=o,u.from_tag=o.getParam("tag"));break;case"to":case"t":u.setHeader("to",v),o=u.parseHeader("to"),o&&(u.to=o,u.to_tag=o.getParam("tag"));break;case"record-route":if(o=Cu.parse(v,"Record_Route"),o===-1)o=void 0;else{var C=Fc(o),l;try{for(C.s();!(l=C.n()).done;){var A=l.value;u.addHeader("record-route",v.substring(A.possition,A.offset)),u.headers["Record-Route"][u.getHeaders("record-route").length-1].parsed=A.parsed}}catch(w){C.e(w)}finally{C.f()}}break;case"call-id":case"i":u.setHeader("call-id",v),o=u.parseHeader("call-id"),o&&(u.call_id=v);break;case"contact":case"m":if(o=Cu.parse(v,"Contact"),o===-1)o=void 0;else{var b=Fc(o),E;try{for(b.s();!(E=b.n()).done;){var O=E.value;u.addHeader("contact",v.substring(O.possition,O.offset)),u.headers.Contact[u.getHeaders("contact").length-1].parsed=O.parsed}}catch(w){b.e(w)}finally{b.f()}}break;case"content-length":case"l":u.setHeader("content-length",v),o=u.parseHeader("content-length");break;case"content-type":case"c":u.setHeader("content-type",v),o=u.parseHeader("content-type");break;case"cseq":u.setHeader("cseq",v),o=u.parseHeader("cseq"),o&&(u.cseq=o.value),u instanceof Su.IncomingResponse&&(u.method=o.method);break;case"max-forwards":u.setHeader("max-forwards",v),o=u.parseHeader("max-forwards");break;case"www-authenticate":u.setHeader("www-authenticate",v),o=u.parseHeader("www-authenticate");break;case"proxy-authenticate":u.setHeader("proxy-authenticate",v),o=u.parseHeader("proxy-authenticate");break;case"session-expires":case"x":u.setHeader("session-expires",v),o=u.parseHeader("session-expires"),o&&(u.session_expires=o.expires,u.session_expires_refresher=o.refresher);break;case"refer-to":case"r":u.setHeader("refer-to",v),o=u.parseHeader("refer-to"),o&&(u.refer_to=o);break;case"replaces":u.setHeader("replaces",v),o=u.parseHeader("replaces"),o&&(u.replaces=o);break;case"event":case"o":u.setHeader("event",v),o=u.parseHeader("event"),o&&(u.event=o);break;default:u.addHeader(t,v),o=0}return o===void 0?{error:'error parsing header "'.concat(t,'"')}:!0}function Ba(u,n){var a;if(typeof Symbol>"u"||u[Symbol.iterator]==null){if(Array.isArray(u)||(a=Jp(u))||n&&u&&typeof u.length=="number"){a&&(u=a);var e=0,o=function(){};return{s:o,n:function(){return e>=u.length?{done:!0}:{done:!1,value:u[e++]}},e:function(l){throw l},f:o}}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 p=!0,t=!1,v;return{s:function(){a=u[Symbol.iterator]()},n:function(){var l=a.next();return p=l.done,l},e:function(l){t=!0,v=l},f:function(){try{!p&&a.return!=null&&a.return()}finally{if(t)throw v}}}}function Jp(u,n){if(u){if(typeof u=="string")return jc(u,n);var a=Object.prototype.toString.call(u).slice(8,-1);if(a==="Object"&&u.constructor&&(a=u.constructor.name),a==="Map"||a==="Set")return Array.from(u);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return jc(u,n)}}function jc(u,n){(n==null||n>u.length)&&(n=u.length);for(var a=0,e=new Array(n);a<n;a++)e[a]=u[a];return e}var Xp=yt,oh=vt,Vc=Vn,Lu=qt(),$u=new Xp("sanityCheck"),Qp=[om],Zp=[sm,nm,lm,rm],em=[im,am],Xe,un,uh,tm=function(u,n,a){Xe=u,un=n,uh=a;var e=Ba(Qp),o;try{for(e.s();!(o=e.n()).done;){var p=o.value;if(p()===!1)return!1}}catch(E){e.e(E)}finally{e.f()}if(Xe instanceof Vc.IncomingRequest){var t=Ba(Zp),v;try{for(t.s();!(v=t.n()).done;){var C=v.value;if(C()===!1)return!1}}catch(E){t.e(E)}finally{t.f()}}else if(Xe instanceof Vc.IncomingResponse){var l=Ba(em),A;try{for(l.s();!(A=l.n()).done;){var b=A.value;if(b()===!1)return!1}}catch(E){l.e(E)}finally{l.f()}}return!0};function sm(){if(Xe.s("to").uri.scheme!=="sip")return qi(416),!1}function nm(){if(!Xe.to_tag&&Xe.call_id.substr(0,5)===un.configuration.jssip_id)return qi(482),!1}function lm(){var u=Lu.str_utf8_length(Xe.body),n=Xe.getHeader("content-length");if(u<n)return qi(400),!1}function rm(){var u=Xe.from_tag,n=Xe.call_id,a=Xe.cseq,e;if(!Xe.to_tag)if(Xe.method===oh.INVITE){if(un._transactions.ist[Xe.via_branch])return!1;for(var o in un._transactions.ist)if(Object.prototype.hasOwnProperty.call(un._transactions.ist,o)&&(e=un._transactions.ist[o],e.request.from_tag===u&&e.request.call_id===n&&e.request.cseq===a))return qi(482),!1}else{if(un._transactions.nist[Xe.via_branch])return!1;for(var p in un._transactions.nist)if(Object.prototype.hasOwnProperty.call(un._transactions.nist,p)&&(e=un._transactions.nist[p],e.request.from_tag===u&&e.request.call_id===n&&e.request.cseq===a))return qi(482),!1}}function im(){if(Xe.getHeaders("via").length>1)return $u.debug("more than one Via header field present in the response, dropping the response"),!1}function am(){var u=Lu.str_utf8_length(Xe.body),n=Xe.getHeader("content-length");if(u<n)return $u.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function om(){for(var u=["from","to","call_id","cseq","via"],n=0,a=u;n<a.length;n++){var e=a[n];if(!Xe.hasHeader(e))return $u.debug("missing mandatory header field : ".concat(e,", dropping the response")),!1}}function qi(u){var n=Xe.getHeaders("via"),a,e="SIP/2.0 ".concat(u," ").concat(oh.REASON_PHRASE[u],`\r
65
+ `),o=Ba(n),p;try{for(o.s();!(p=o.n()).done;){var t=p.value;e+="Via: ".concat(t,`\r
66
+ `)}}catch(v){o.e(v)}finally{o.f()}a=Xe.getHeader("To"),Xe.to_tag||(a+=";tag=".concat(Lu.newTag())),e+="To: ".concat(a,`\r
67
+ `),e+="From: ".concat(Xe.getHeader("From"),`\r
68
+ `),e+="Call-ID: ".concat(Xe.call_id,`\r
69
+ `),e+="CSeq: ".concat(Xe.cseq," ").concat(Xe.method,`\r
70
+ `),e+=`\r
71
+ `,uh.send(e)}var Hu={};function Bc(u,n){var a;if(typeof Symbol>"u"||u[Symbol.iterator]==null){if(Array.isArray(u)||(a=um(u))||n&&u&&typeof u.length=="number"){a&&(u=a);var e=0,o=function(){};return{s:o,n:function(){return e>=u.length?{done:!0}:{done:!1,value:u[e++]}},e:function(l){throw l},f:o}}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 p=!0,t=!1,v;return{s:function(){a=u[Symbol.iterator]()},n:function(){var l=a.next();return p=l.done,l},e:function(l){t=!0,v=l},f:function(){try{!p&&a.return!=null&&a.return()}finally{if(t)throw v}}}}function um(u,n){if(u){if(typeof u=="string")return Gc(u,n);var a=Object.prototype.toString.call(u).slice(8,-1);if(a==="Object"&&u.constructor&&(a=u.constructor.name),a==="Map"||a==="Set")return Array.from(u);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Gc(u,n)}}function Gc(u,n){(n==null||n>u.length)&&(n=u.length);for(var a=0,e=new Array(n);a<n;a++)e[a]=u[a];return e}var ni=qt(),Ur=vt,Uo=_n(),Wc=Zl(),xo=ku,Po=Ql;Hu.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:Ur.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Ur.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Ur.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(ni.createRandomToken(12),".invalid")};var ha={mandatory:{sockets:function(n){var a=[];if(xo.isSocket(n))a.push({socket:n});else if(Array.isArray(n)&&n.length){var e=Bc(n),o;try{for(e.s();!(o=e.n()).done;){var p=o.value;Object.prototype.hasOwnProperty.call(p,"socket")&&xo.isSocket(p.socket)?a.push(p):xo.isSocket(p)&&a.push({socket:p})}}catch(t){e.e(t)}finally{e.f()}}else return;return a},uri:function(n){/^sip:/i.test(n)||(n="".concat(Ur.SIP,":").concat(n));var a=Wc.parse(n);if(a)return a.user?a:void 0}},optional:{authorization_user:function(n){if(Uo.parse('"'.concat(n,'"'),"quoted_string")!==-1)return n},authorization_jwt:function(n){if(typeof n=="string")return n},user_agent:function(n){if(typeof n=="string")return n},connection_recovery_max_interval:function(n){if(ni.isDecimal(n)){var a=Number(n);if(a>0)return a}},connection_recovery_min_interval:function(n){if(ni.isDecimal(n)){var a=Number(n);if(a>0)return a}},contact_uri:function(n){if(typeof n=="string"){var a=Uo.parse(n,"SIP_URI");if(a!==-1)return a}},display_name:function(n){return n},instance_id:function(n){if(/^uuid:/i.test(n)&&(n=n.substr(5)),Uo.parse(n,"uuid")!==-1)return n},no_answer_timeout:function(n){if(ni.isDecimal(n)){var a=Number(n);if(a>0)return a}},session_timers:function(n){if(typeof n=="boolean")return n},session_timers_refresh_method:function(n){if(typeof n=="string"&&(n=n.toUpperCase(),n===Ur.INVITE||n===Ur.UPDATE))return n},session_timers_force_refresher:function(n){if(typeof n=="boolean")return n},password:function(n){return String(n)},realm:function(n){return String(n)},ha1:function(n){return String(n)},register:function(n){if(typeof n=="boolean")return n},register_expires:function(n){if(ni.isDecimal(n)){var a=Number(n);if(a>0)return a}},registrar_server:function(n){/^sip:/i.test(n)||(n="".concat(Ur.SIP,":").concat(n));var a=Wc.parse(n);if(a)return a.user?void 0:a},use_preloaded_route:function(n){if(typeof n=="boolean")return n},extra_headers:function(n){var a=[];if(Array.isArray(n)&&n.length){var e=Bc(n),o;try{for(e.s();!(o=e.n()).done;){var p=o.value;typeof p=="string"&&a.push(p)}}catch(t){e.e(t)}finally{e.f()}}else return;return a}}};Hu.load=function(u,n){for(var a in ha.mandatory)if(n.hasOwnProperty(a)){var e=n[a],o=ha.mandatory[a](e);if(o!==void 0)u[a]=o;else throw new Po.ConfigurationError(a,e)}else throw new Po.ConfigurationError(a);for(var p in ha.optional)if(n.hasOwnProperty(p)){var t=n[p];if(ni.isEmpty(t))continue;var v=ha.optional[p](t);if(v!==void 0)u[p]=v;else throw new Po.ConfigurationError(p,t)}};function Ga(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ga=function(a){return typeof a}:Ga=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Ga(u)}function cm(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Kc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Yc(u,n,a){return n&&Kc(u.prototype,n),a&&Kc(u,a),u}function fm(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&Au(u,n)}function Au(u,n){return Au=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},Au(u,n)}function hm(u){var n=dm();return function(){var e=to(u),o;if(n){var p=to(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return _m(this,o)}}function _m(u,n){return n&&(Ga(n)==="object"||typeof n=="function")?n:ch(u)}function ch(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function dm(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function to(u){return to=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},to(u)}var pm=At.EventEmitter,mm=yt,bt=vt,gm=ld,zc=_p,Jc=bp,Xc=$p,Mo=Qi,vm=Gp,_a=qt(),Tm=Ql,Em=Zl(),Cm=ah,ko=Vn,Sm=tm,Lo=Hu,et=new mm("UA"),Ot={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Am=function(u){fm(a,u);var n=hm(a);Yc(a,null,[{key:"C",get:function(){return Ot}}]);function a(e){var o;if(cm(this,a),et.debug("new() [configuration:%o]",e),o=n.call(this),o._cache={credentials:{}},o._configuration=Object.assign({},Lo.settings),o._dynConfiguration={},o._dialogs={},o._applicants={},o._sessions={},o._transport=null,o._contact=null,o._status=Ot.STATUS_INIT,o._error=null,o._transactions={nist:{},nict:{},ist:{},ict:{}},o._data={},o._closeTimer=null,e===void 0)throw new TypeError("Not enough arguments");try{o._loadConfig(e)}catch(p){throw o._status=Ot.STATUS_NOT_READY,o._error=Ot.CONFIGURATION_ERROR,p}return o._registrator=new gm(ch(o)),o}return Yc(a,[{key:"start",value:function(){et.debug("start()"),this._status===Ot.STATUS_INIT?this._transport.connect():this._status===Ot.STATUS_USER_CLOSED?(et.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=Ot.STATUS_INIT,this._transport.connect()):this._status===Ot.STATUS_READY?et.debug("UA is in READY status, not restarted"):et.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){et.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(o){et.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(o)}},{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(o,p){et.debug("call()");var t=new zc(this);return t.connect(o,p),t}},{key:"sendMessage",value:function(o,p,t){et.debug("sendMessage()");var v=new Jc(this);return v.send(o,p,t),v}},{key:"sendOptions",value:function(o,p,t){et.debug("sendOptions()");var v=new Xc(this);return v.send(o,p,t),v}},{key:"terminateSessions",value:function(o){et.debug("terminateSessions()");for(var p in this._sessions)this._sessions[p].isEnded()||this._sessions[p].terminate(o)}},{key:"stop",value:function(){var o=this;if(et.debug("stop()"),this._dynConfiguration={},this._status===Ot.STATUS_USER_CLOSED){et.debug("UA already closed");return}this._registrator.close();var p=Object.keys(this._sessions).length;for(var t in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,t)){et.debug("closing session ".concat(t));try{this._sessions[t].terminate()}catch{}}for(var v in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,v))try{this._applicants[v].close()}catch{}this._status=Ot.STATUS_USER_CLOSED;var C=Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length;C===0&&p===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){o._closeTimer=null,o._transport.disconnect()},2e3)}},{key:"normalizeTarget",value:function(o){return _a.normalizeTarget(o,this._configuration.hostport_params)}},{key:"get",value:function(o){switch(o){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:et.warn('get() | cannot get "%s" parameter in runtime',o);return}}},{key:"set",value:function(o,p){switch(o){case"authorization_user":{this._configuration.authorization_user=String(p);break}case"password":{this._configuration.password=String(p);break}case"realm":{this._configuration.realm=String(p);break}case"ha1":{this._configuration.ha1=String(p),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(p);break}case"display_name":{this._configuration.display_name=p;break}default:return et.warn('set() | cannot set "%s" parameter in runtime',o),!1}return!0}},{key:"newTransaction",value:function(o){this._transactions[o.type][o.id]=o,this.emit("newTransaction",{transaction:o})}},{key:"destroyTransaction",value:function(o){delete this._transactions[o.type][o.id],this.emit("transactionDestroyed",{transaction:o})}},{key:"newDialog",value:function(o){this._dialogs[o.id]=o}},{key:"destroyDialog",value:function(o){delete this._dialogs[o.id]}},{key:"newMessage",value:function(o,p){this._applicants[o]=o,this.emit("newMessage",p)}},{key:"newOptions",value:function(o,p){this._applicants[o]=o,this.emit("newOptions",p)}},{key:"destroyMessage",value:function(o){delete this._applicants[o]}},{key:"newRTCSession",value:function(o,p){this._sessions[o.id]=o,this.emit("newRTCSession",p)}},{key:"destroyRTCSession",value:function(o){delete this._sessions[o.id]}},{key:"registered",value:function(o){this.emit("registered",o)}},{key:"unregistered",value:function(o){this.emit("unregistered",o)}},{key:"registrationFailed",value:function(o){this.emit("registrationFailed",o)}},{key:"receiveRequest",value:function(o){var p=o.method;if(o.ruri.user!==this._configuration.uri.user&&o.ruri.user!==this._contact.uri.user){et.debug("Request-URI does not point to us"),o.method!==bt.ACK&&o.reply_sl(404);return}if(o.ruri.scheme===bt.SIPS){o.reply_sl(416);return}if(!Mo.checkTransaction(this,o)){if(p===bt.INVITE?new Mo.InviteServerTransaction(this,this._transport,o):p!==bt.ACK&&p!==bt.CANCEL&&new Mo.NonInviteServerTransaction(this,this._transport,o),p===bt.OPTIONS){if(this.listeners("newOptions").length===0){o.reply(200);return}var t=new Xc(this);t.init_incoming(o)}else if(p===bt.MESSAGE){if(this.listeners("newMessage").length===0){o.reply(405);return}var v=new Jc(this);v.init_incoming(o)}else if(p===bt.INVITE&&!o.to_tag&&this.listeners("newRTCSession").length===0){o.reply(405);return}var C,l;if(o.to_tag)C=this._findDialog(o.call_id,o.from_tag,o.to_tag),C?C.receiveRequest(o):p===bt.NOTIFY?(l=this._findSession(o),l?l.receiveRequest(o):(et.debug("received NOTIFY request for a non existent subscription"),o.reply(481,"Subscription does not exist"))):p!==bt.ACK&&o.reply(481);else switch(p){case bt.INVITE:if(window.RTCPeerConnection)if(o.hasHeader("replaces")){var A=o.replaces;C=this._findDialog(A.call_id,A.from_tag,A.to_tag),C?(l=C.owner,l.isEnded()?o.reply(603):l.receiveRequest(o)):o.reply(481)}else l=new zc(this),l.init_incoming(o);else et.warn("INVITE received but WebRTC is not supported"),o.reply(488);break;case bt.BYE:o.reply(481);break;case bt.CANCEL:l=this._findSession(o),l?l.receiveRequest(o):et.debug("received CANCEL request for a non existent session");break;case bt.ACK:break;case bt.NOTIFY:this.emit("sipEvent",{event:o.event,request:o}),o.reply(200);break;default:o.reply(405);break}}}},{key:"_findSession",value:function(o){var p=o.call_id,t=o.from_tag,v=o.to_tag,C=p+t,l=this._sessions[C],A=p+v,b=this._sessions[A];return l||b||null}},{key:"_findDialog",value:function(o,p,t){var v=o+p+t,C=this._dialogs[v];return C||(v=o+t+p,C=this._dialogs[v],C||null)}},{key:"_loadConfig",value:function(o){try{Lo.load(this._configuration,o)}catch(A){throw A}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=_a.newUUID()),this._configuration.jssip_id=_a.createRandomToken(5);var p=this._configuration.uri.clone();p.user=null,this._configuration.hostport_params=p.toString().replace(/^sip:/i,"");try{this._transport=new vm(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=ym.bind(this),this._transport.onconnect=Rm.bind(this),this._transport.ondisconnect=bm.bind(this),this._transport.ondata=Im.bind(this)}catch(A){throw et.warn(A),new Tm.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 t=this._configuration.uri.clone();t.user=null,t.clearParams(),t.clearHeaders(),this._configuration.registrar_server=t}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Em("sip",_a.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 b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=b.anonymous||null,O=b.outbound||null,w="<";return E?w+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":w+=this.pub_gruu||this.uri.toString(),O&&(E?!this.temp_gruu:!this.pub_gruu)&&(w+=";ob"),w+=">",w}};var v=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var C in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,C)&&(v.indexOf(C)!==-1?Object.defineProperty(this._configuration,C,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,C,{writable:!1,configurable:!1}));et.debug("configuration parameters after validation:");for(var l in this._configuration)if(Object.prototype.hasOwnProperty.call(Lo.settings,l))switch(l){case"uri":case"registrar_server":et.debug("- ".concat(l,": ").concat(this._configuration[l]));break;case"password":case"ha1":case"authorization_jwt":et.debug("- ".concat(l,": NOT SHOWN"));break;default:et.debug("- ".concat(l,": ").concat(JSON.stringify(this._configuration[l])))}}},{key:"C",get:function(){return Ot}},{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}}]),a}(pm);function ym(u){this.emit("connecting",u)}function Rm(u){this._status!==Ot.STATUS_USER_CLOSED&&(this._status=Ot.STATUS_READY,this._error=null,this.emit("connected",u),this._dynConfiguration.register&&this._registrator.register())}function bm(u){for(var n=["nict","ict","nist","ist"],a=0,e=n;a<e.length;a++){var o=e[a];for(var p in this._transactions[o])Object.prototype.hasOwnProperty.call(this._transactions[o],p)&&this._transactions[o][p].onTransportError()}this.emit("disconnected",u),this._registrator.onTransportClosed(),this._status!==Ot.STATUS_USER_CLOSED&&(this._status=Ot.STATUS_NOT_READY,this._error=Ot.NETWORK_ERROR)}function Im(u){var n=u.transport,a=u.message;if(a=Cm.parseMessage(a,this),!!a&&!(this._status===Ot.STATUS_USER_CLOSED&&a instanceof ko.IncomingRequest)&&Sm(a,this,n)){if(a instanceof ko.IncomingRequest)a.transport=n,this.receiveRequest(a);else if(a instanceof ko.IncomingResponse){var e;switch(a.method){case bt.INVITE:e=this._transactions.ict[a.via_branch],e&&e.receiveResponse(a);break;case bt.ACK:break;default:e=this._transactions.nict[a.via_branch],e&&e.receiveResponse(a);break}}}}function wm(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Qc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Om(u,n,a){return n&&Qc(u.prototype,n),a&&Qc(u,a),u}var Dm=yt,Nm=_n(),Vt=new Dm("WebSocketInterface"),Um=function(){function u(n){wm(this,u),Vt.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;var a=Nm.parse(n,"absoluteURI");if(a===-1)throw Vt.warn("invalid WebSocket URI: ".concat(n)),new TypeError("Invalid argument: ".concat(n));if(a.scheme!=="wss"&&a.scheme!=="ws")throw Vt.warn("invalid WebSocket URI scheme: ".concat(a.scheme)),new TypeError("Invalid argument: ".concat(n));this._sip_uri="sip:".concat(a.host).concat(a.port?":".concat(a.port):"",";transport=ws"),this._via_transport=a.scheme.toUpperCase()}return Om(u,[{key:"connect",value:function(){if(Vt.debug("connect()"),this.isConnected()){Vt.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){Vt.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),Vt.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(a){this._onError(a)}}},{key:"disconnect",value:function(){Vt.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(a){return Vt.debug("send()"),this.isConnected()?(this._ws.send(a),!0):(Vt.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(){Vt.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(a){var e=a.wasClean,o=a.code,p=a.reason;Vt.debug("WebSocket ".concat(this._url," closed")),e===!1&&Vt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!e,o,p)}},{key:"_onMessage",value:function(a){var e=a.data;Vt.debug("received WebSocket message"),this.ondata(e)}},{key:"_onError",value:function(a){Vt.warn("WebSocket ".concat(this._url," error: "),a)}},{key:"via_transport",get:function(){return this._via_transport},set:function(a){this._via_transport=a.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),u}(),yu=lo,xm=vt,Pm=Ql,Mm=qt(),km=Am,Lm=Zl(),$m=Nu(),Hm=_n(),Fm=Um,qm=oi("JsSIP");qm("version %s",yu.version);var Zc={C:xm,Exceptions:Pm,Utils:Mm,UA:km,URI:Lm,NameAddrHeader:$m,WebSocketInterface:Fm,Grammar:Hm,debug:oi,get name(){return yu.title},get version(){return yu.version}};const Zr=oi,ei="JsSIP";var Et=class{constructor(n){n?(this._debug=Zr.default(`${ei}:${n}`),this._warn=Zr.default(`${ei}:WARN:${n}`),this._error=Zr.default(`${ei}:ERROR:${n}`)):(this._debug=Zr.default(ei),this._warn=Zr.default(`${ei}:WARN`),this._error=Zr.default(`${ei}: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 co=ot(Et),ef=lo;var Fe={USER_AGENT:`${ef.title} ${ef.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 z=ot(Fe);var dt={},tf={},$o,sf;function fo(){if(sf)return $o;sf=1;const u=Bn(),n=dn();return $o=class fh{static parse(e){if(e=n.parse(e,"Name_Addr_Header"),e!==-1)return e}constructor(e,o,p){if(!e||!(e instanceof u))throw new TypeError('missing or invalid "uri" parameter');this._uri=e,this._parameters={},this.display_name=o;for(const t in p)Object.prototype.hasOwnProperty.call(p,t)&&this.setParam(t,p[t])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(e){this._display_name=e===0?"0":e}setParam(e,o){e&&(this._parameters[e.toLowerCase()]=typeof o>"u"||o===null?null:o.toString())}getParam(e){if(e)return this._parameters[e.toLowerCase()]}hasParam(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}deleteParam(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){const o=this._parameters[e];return delete this._parameters[e],o}}clearParams(){this._parameters={}}clone(){return new fh(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let e=this._display_name?`"${this._quote(this._display_name)}" `:"";e+=`<${this._uri.toString()}>`;for(const o in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,o)&&(e+=`;${o}`,this._parameters[o]!==null&&(e+=`=${this._parameters[o]}`));return e}},$o}var nf;function dn(){if(nf)return tf;nf=1;function u(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(t,v){var C={CRLF:O,DIGIT:w,ALPHA:N,HEXDIG:U,WSP:Y,OCTET:j,DQUOTE:_e,SP:k,HTAB:H,alphanum:de,reserved:Ue,unreserved:B,mark:L,escaped:V,LWS:G,SWS:K,HCOLON:M,TEXT_UTF8_TRIM:te,TEXT_UTF8char:se,UTF8_NONASCII:$,UTF8_CONT:ne,LHEX:ct,token:P,token_nodot:Q,separators:oe,word:he,STAR:Re,SLASH:be,EQUAL:fe,LPAREN:qe,RPAREN:xe,RAQUOT:we,LAQUOT:st,COMMA:$e,SEMI:ue,COLON:Oe,LDQUOT:Pe,RDQUOT:Le,comment:ye,ctext:pe,quoted_string:Ce,quoted_string_clean:ke,qdtext:He,quoted_pair:Be,SIP_URI_noparams:Ve,SIP_URI:Mt,uri_scheme:ft,uri_scheme_sips:Gs,uri_scheme_sip:is,userinfo:As,user:ys,user_unreserved:as,password:Ws,hostport:os,host:Se,hostname:ht,domainlabel:Xt,toplabel:Ae,IPv6reference:pt,IPv6address:us,h16:me,ls32:Tt,IPv4address:Rs,dec_octet:cs,port:Wn,uri_parameters:Kn,uri_parameter:pn,transport_param:Yn,user_param:zn,method_param:Jn,ttl_param:bs,maddr_param:Xn,lr_param:Qn,other_param:Qt,pname:Zn,pvalue:el,paramchar:kt,param_unreserved:er,headers:tl,header:Zt,hname:sl,hvalue:nl,hnv_unreserved:Is,Request_Response:Ks,Request_Line:ll,Request_URI:ws,absoluteURI:Os,hier_part:rl,net_path:es,abs_path:Ds,opaque_part:Ns,uric:ts,uric_no_slash:mn,path_segments:Us,segment:Ys,param:gn,pchar:fs,scheme:il,authority:al,srvr:vn,reg_name:ol,query:ul,SIP_Version:Tn,INVITEm:cl,ACKm:fl,OPTIONSm:hl,BYEm:zs,CANCELm:_l,REGISTERm:dl,SUBSCRIBEm:Js,NOTIFYm:pl,REFERm:tr,Method:En,Status_Line:sr,Status_Code:Cn,extension_code:hs,Reason_Phrase:Sn,Allow_Events:Xs,Call_ID:_s,Contact:An,contact_param:Lt,name_addr:ss,display_name:Ke,contact_params:Gt,c_p_q:nr,c_p_expires:Je,delta_seconds:Wt,qvalue:lr,generic_param:Ze,gen_value:ml,Content_Disposition:$r,disp_type:rr,disp_param:gl,handling_param:ir,Content_Encoding:ar,Content_Length:yn,Content_Type:or,media_type:vl,m_type:xs,discrete_type:Tl,composite_type:ur,extension_token:Ps,x_token:cr,m_subtype:Hr,m_parameter:ds,m_value:Fr,CSeq:fr,CSeq_value:ps,Expires:fi,Event:hr,event_type:Ms,From:hi,from_param:Rn,tag_param:El,Max_Forwards:bn,Min_Expires:Qs,Name_Addr_Header:_r,Proxy_Authenticate:Zs,challenge:ks,other_challenge:en,auth_param:Ls,digest_cln:tn,realm:sn,realm_value:Cl,domain:Sl,URI:nn,nonce:ln,nonce_value:dr,opaque:pr,stale:ms,algorithm:qr,qop_options:Al,qop_value:gs,Proxy_Require:_i,Record_Route:mr,rec_route:vs,Reason:di,reason_param:yl,reason_cause:$s,Require:jr,Route:Vr,route_param:rn,Subscription_State:Br,substate_value:Rl,subexp_params:gr,event_reason_value:In,Subject:wn,Supported:Gr,To:On,to_param:an,Via:vr,via_param:on,via_params:Dn,via_ttl:bl,via_maddr:Il,via_received:wl,via_branch:Ol,response_port:Dl,rport:Nl,sent_protocol:Nn,protocol_name:Tr,transport:Er,sent_by:Un,via_host:Ul,via_port:Cr,ttl:xl,WWW_Authenticate:Pl,Session_Expires:Wr,s_e_expires:Kr,s_e_params:xn,s_e_refresher:Kt,extension_header:Yr,header_value:Ml,message_body:ns,uuid_URI:zr,uuid:kl,hex4:jt,hex8:Sr,hex12:Ll,Refer_To:$l,Replaces:Jr,call_id:Ar,replaces_param:x,to_tag:Hl,from_tag:Fl,early_flag:yr};if(v!==void 0){if(C[v]===void 0)throw new Error("Invalid rule name: "+u(v)+".")}else v="CRLF";var l=0,A=0,b=[];function E(s){l<A||(l>A&&(A=l,b=[]),b.push(s))}function O(){var s;return t.substr(l,2)===`\r
73
+ `?(s=`\r
74
+ `,l+=2):(s=null,E('"\\r\\n"')),s}function w(){var s;return/^[0-9]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[0-9]")),s}function N(){var s;return/^[a-zA-Z]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[a-zA-Z]")),s}function U(){var s;return/^[0-9a-fA-F]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[0-9a-fA-F]")),s}function Y(){var s;return s=k(),s===null&&(s=H()),s}function j(){var s;return/^[\0-\xFF]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\0-\\xFF]")),s}function _e(){var s;return/^["]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E('["]')),s}function k(){var s;return console.log("pos",l),console.log("input.charCodeAt(pos)",t.charAt(l)),t.charCodeAt(l)===32?(s=" ",l++):(s=null,E('" "')),s}function H(){var s;return t.charCodeAt(l)===9?(s=" ",l++):(s=null,E('"\\t"')),s}function de(){var s;return/^[a-zA-Z0-9]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[a-zA-Z0-9]")),s}function Ue(){var s;return t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","'))))))))))),s}function B(){var s;return s=de(),s===null&&(s=L()),s}function L(){var s;return t.charCodeAt(l)===45?(s="-",l++):(s=null,E('"-"')),s===null&&(t.charCodeAt(l)===95?(s="_",l++):(s=null,E('"_"')),s===null&&(t.charCodeAt(l)===46?(s=".",l++):(s=null,E('"."')),s===null&&(t.charCodeAt(l)===33?(s="!",l++):(s=null,E('"!"')),s===null&&(t.charCodeAt(l)===126?(s="~",l++):(s=null,E('"~"')),s===null&&(t.charCodeAt(l)===42?(s="*",l++):(s=null,E('"*"')),s===null&&(t.charCodeAt(l)===39?(s="'",l++):(s=null,E(`"'"`)),s===null&&(t.charCodeAt(l)===40?(s="(",l++):(s=null,E('"("')),s===null&&(t.charCodeAt(l)===41?(s=")",l++):(s=null,E('")"')))))))))),s}function V(){var s,c,h,g,S;return g=l,S=l,t.charCodeAt(l)===37?(s="%",l++):(s=null,E('"%"')),s!==null?(c=U(),c!==null?(h=U(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){return I.join("")}(g,s)),s===null&&(l=g),s}function G(){var s,c,h,g,S,R;for(g=l,S=l,R=l,s=[],c=Y();c!==null;)s.push(c),c=Y();if(s!==null?(c=O(),c!==null?s=[s,c]:(s=null,l=R)):(s=null,l=R),s=s!==null?s:"",s!==null){if(h=Y(),h!==null)for(c=[];h!==null;)c.push(h),h=Y();else c=null;c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s!==null&&(s=function(I){return" "}()),s===null&&(l=g),s}function K(){var s;return s=G(),s=s!==null?s:"",s}function M(){var s,c,h,g,S;for(g=l,S=l,s=[],c=k(),c===null&&(c=H());c!==null;)s.push(c),c=k(),c===null&&(c=H());return s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return":"}()),s===null&&(l=g),s}function te(){var s,c,h,g,S,R,I;if(S=l,R=l,c=se(),c!==null)for(s=[];c!==null;)s.push(c),c=se();else s=null;if(s!==null){for(c=[],I=l,h=[],g=G();g!==null;)h.push(g),g=G();for(h!==null?(g=se(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;){for(c.push(h),I=l,h=[],g=G();g!==null;)h.push(g),g=G();h!==null?(g=se(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I)}c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){return t.substring(l,D)}(S)),s===null&&(l=S),s}function se(){var s;return/^[!-~]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[!-~]")),s===null&&(s=$()),s}function $(){var s;return/^[\x80-\uFFFF]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\x80-\\uFFFF]")),s}function ne(){var s;return/^[\x80-\xBF]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\x80-\\xBF]")),s}function ct(){var s;return s=w(),s===null&&(/^[a-f]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[a-f]"))),s}function P(){var s,c,h;if(h=l,c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"'))))))))))));else s=null;return s!==null&&(s=function(g){return t.substring(l,g)}(h)),s===null&&(l=h),s}function Q(){var s,c,h;if(h=l,c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"'))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')))))))))));else s=null;return s!==null&&(s=function(g){return t.substring(l,g)}(h)),s===null&&(l=h),s}function oe(){var s;return t.charCodeAt(l)===40?(s="(",l++):(s=null,E('"("')),s===null&&(t.charCodeAt(l)===41?(s=")",l++):(s=null,E('")"')),s===null&&(t.charCodeAt(l)===60?(s="<",l++):(s=null,E('"<"')),s===null&&(t.charCodeAt(l)===62?(s=">",l++):(s=null,E('">"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')),s===null&&(t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===92?(s="\\",l++):(s=null,E('"\\\\"')),s===null&&(s=_e(),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s===null&&(t.charCodeAt(l)===93?(s="]",l++):(s=null,E('"]"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===123?(s="{",l++):(s=null,E('"{"')),s===null&&(t.charCodeAt(l)===125?(s="}",l++):(s=null,E('"}"')),s===null&&(s=k(),s===null&&(s=H())))))))))))))))))),s}function he(){var s,c,h;if(h=l,c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')),c===null&&(t.charCodeAt(l)===40?(c="(",l++):(c=null,E('"("')),c===null&&(t.charCodeAt(l)===41?(c=")",l++):(c=null,E('")"')),c===null&&(t.charCodeAt(l)===60?(c="<",l++):(c=null,E('"<"')),c===null&&(t.charCodeAt(l)===62?(c=">",l++):(c=null,E('">"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===92?(c="\\",l++):(c=null,E('"\\\\"')),c===null&&(c=_e(),c===null&&(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c===null&&(t.charCodeAt(l)===91?(c="[",l++):(c=null,E('"["')),c===null&&(t.charCodeAt(l)===93?(c="]",l++):(c=null,E('"]"')),c===null&&(t.charCodeAt(l)===63?(c="?",l++):(c=null,E('"?"')),c===null&&(t.charCodeAt(l)===123?(c="{",l++):(c=null,E('"{"')),c===null&&(t.charCodeAt(l)===125?(c="}",l++):(c=null,E('"}"'))))))))))))))))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')),c===null&&(t.charCodeAt(l)===40?(c="(",l++):(c=null,E('"("')),c===null&&(t.charCodeAt(l)===41?(c=")",l++):(c=null,E('")"')),c===null&&(t.charCodeAt(l)===60?(c="<",l++):(c=null,E('"<"')),c===null&&(t.charCodeAt(l)===62?(c=">",l++):(c=null,E('">"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===92?(c="\\",l++):(c=null,E('"\\\\"')),c===null&&(c=_e(),c===null&&(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c===null&&(t.charCodeAt(l)===91?(c="[",l++):(c=null,E('"["')),c===null&&(t.charCodeAt(l)===93?(c="]",l++):(c=null,E('"]"')),c===null&&(t.charCodeAt(l)===63?(c="?",l++):(c=null,E('"?"')),c===null&&(t.charCodeAt(l)===123?(c="{",l++):(c=null,E('"{"')),c===null&&(t.charCodeAt(l)===125?(c="}",l++):(c=null,E('"}"')))))))))))))))))))))))));else s=null;return s!==null&&(s=function(g){return t.substring(l,g)}(h)),s===null&&(l=h),s}function Re(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"*"}()),s===null&&(l=g),s}function be(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"/"}()),s===null&&(l=g),s}function fe(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"="}()),s===null&&(l=g),s}function qe(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===40?(c="(",l++):(c=null,E('"("')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"("}()),s===null&&(l=g),s}function xe(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===41?(c=")",l++):(c=null,E('")"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return")"}()),s===null&&(l=g),s}function we(){var s,c,h,g;return h=l,g=l,t.charCodeAt(l)===62?(s=">",l++):(s=null,E('">"')),s!==null?(c=K(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return">"}()),s===null&&(l=h),s}function st(){var s,c,h,g;return h=l,g=l,s=K(),s!==null?(t.charCodeAt(l)===60?(c="<",l++):(c=null,E('"<"')),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return"<"}()),s===null&&(l=h),s}function $e(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return","}()),s===null&&(l=g),s}function ue(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return";"}()),s===null&&(l=g),s}function Oe(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return":"}()),s===null&&(l=g),s}function Pe(){var s,c,h,g;return h=l,g=l,s=K(),s!==null?(c=_e(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return'"'}()),s===null&&(l=h),s}function Le(){var s,c,h,g;return h=l,g=l,s=_e(),s!==null?(c=K(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return'"'}()),s===null&&(l=h),s}function ye(){var s,c,h,g;if(g=l,s=qe(),s!==null){for(c=[],h=pe(),h===null&&(h=Be(),h===null&&(h=ye()));h!==null;)c.push(h),h=pe(),h===null&&(h=Be(),h===null&&(h=ye()));c!==null?(h=xe(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)}else s=null,l=g;return s}function pe(){var s;return/^[!-']/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[!-']")),s===null&&(/^[*-[]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[*-[]")),s===null&&(/^[\]-~]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\]-~]")),s===null&&(s=$(),s===null&&(s=G())))),s}function Ce(){var s,c,h,g,S,R;if(S=l,R=l,s=K(),s!==null)if(c=_e(),c!==null){for(h=[],g=He(),g===null&&(g=Be());g!==null;)h.push(g),g=He(),g===null&&(g=Be());h!==null?(g=_e(),g!==null?s=[s,c,h,g]:(s=null,l=R)):(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s!==null&&(s=function(I){return t.substring(l,I)}(S)),s===null&&(l=S),s}function ke(){var s,c,h,g,S,R;if(S=l,R=l,s=K(),s!==null)if(c=_e(),c!==null){for(h=[],g=He(),g===null&&(g=Be());g!==null;)h.push(g),g=He(),g===null&&(g=Be());h!==null?(g=_e(),g!==null?s=[s,c,h,g]:(s=null,l=R)):(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s!==null&&(s=function(I){var D=t.substring(l,I).trim();return D.substring(1,D.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(S)),s===null&&(l=S),s}function He(){var s;return s=G(),s===null&&(t.charCodeAt(l)===33?(s="!",l++):(s=null,E('"!"')),s===null&&(/^[#-[]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[#-[]")),s===null&&(/^[\]-~]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\]-~]")),s===null&&(s=$())))),s}function Be(){var s,c,h;return h=l,t.charCodeAt(l)===92?(s="\\",l++):(s=null,E('"\\\\"')),s!==null?(/^[\0-\t]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[\\0-\\t]")),c===null&&(/^[\x0B-\f]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[\\x0B-\\f]")),c===null&&(/^[\x0E-]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[\\x0E-]")))),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function Ve(){var s,c,h,g,S,R;return S=l,R=l,s=ft(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=As(),h=h!==null?h:"",h!==null?(g=os(),g!==null?s=[s,c,h,g]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s!==null&&(s=function(I){try{T.uri=new _(T.scheme,T.user,T.host,T.port),delete T.scheme,delete T.user,delete T.host,delete T.host_type,delete T.port}catch{T=-1}}()),s===null&&(l=S),s}function Mt(){var s,c,h,g,S,R,I,D;return I=l,D=l,s=ft(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=As(),h=h!==null?h:"",h!==null?(g=os(),g!==null?(S=Kn(),S!==null?(R=tl(),R=R!==null?R:"",R!==null?s=[s,c,h,g,S,R]:(s=null,l=D)):(s=null,l=D)):(s=null,l=D)):(s=null,l=D)):(s=null,l=D)):(s=null,l=D),s!==null&&(s=function(J){try{T.uri=new _(T.scheme,T.user,T.host,T.port,T.uri_params,T.uri_headers),delete T.scheme,delete T.user,delete T.host,delete T.host_type,delete T.port,delete T.uri_params,v==="SIP_URI"&&(T=T.uri)}catch{T=-1}}()),s===null&&(l=I),s}function ft(){var s;return s=Gs(),s===null&&(s=is()),s}function Gs(){var s,c;return c=l,t.substr(l,4).toLowerCase()==="sips"?(s=t.substr(l,4),l+=4):(s=null,E('"sips"')),s!==null&&(s=function(h,g){T.scheme=g.toLowerCase()}(c,s)),s===null&&(l=c),s}function is(){var s,c;return c=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"sip"')),s!==null&&(s=function(h,g){T.scheme=g.toLowerCase()}(c,s)),s===null&&(l=c),s}function As(){var s,c,h,g,S,R;return g=l,S=l,s=ys(),s!==null?(R=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ws(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?(t.charCodeAt(l)===64?(h="@",l++):(h=null,E('"@"')),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T.user=decodeURIComponent(t.substring(l-1,I))}(g)),s===null&&(l=g),s}function ys(){var s,c;if(c=B(),c===null&&(c=V(),c===null&&(c=as())),c!==null)for(s=[];c!==null;)s.push(c),c=B(),c===null&&(c=V(),c===null&&(c=as()));else s=null;return s}function as(){var s;return t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')),s===null&&(t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"'))))))))),s}function Ws(){var s,c,h;for(h=l,s=[],c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","'))))))));c!==null;)s.push(c),c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","'))))))));return s!==null&&(s=function(g){T.password=t.substring(l,g)}(h)),s===null&&(l=h),s}function os(){var s,c,h,g,S;return g=l,s=Se(),s!==null?(S=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Wn(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function Se(){var s,c;return c=l,s=ht(),s===null&&(s=Rs(),s===null&&(s=pt())),s!==null&&(s=function(h){return T.host=t.substring(l,h).toLowerCase(),T.host}(c)),s===null&&(l=c),s}function ht(){var s,c,h,g,S,R;for(g=l,S=l,s=[],R=l,c=Xt(),c!==null?(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R);c!==null;)s.push(c),R=l,c=Xt(),c!==null?(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R);return s!==null?(c=Ae(),c!==null?(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h=h!==null?h:"",h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){return T.host_type="domain",t.substring(l,I)}(g)),s===null&&(l=g),s}function Xt(){var s,c,h,g;if(g=l,s=de(),s!==null){for(c=[],h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));h!==null;)c.push(h),h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));c!==null?s=[s,c]:(s=null,l=g)}else s=null,l=g;return s}function Ae(){var s,c,h,g;if(g=l,s=N(),s!==null){for(c=[],h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));h!==null;)c.push(h),h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));c!==null?s=[s,c]:(s=null,l=g)}else s=null,l=g;return s}function pt(){var s,c,h,g,S;return g=l,S=l,t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s!==null?(c=us(),c!==null?(t.charCodeAt(l)===93?(h="]",l++):(h=null,E('"]"')),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return T.host_type="IPv6",t.substring(l,R)}(g)),s===null&&(l=g),s}function us(){var s,c,h,g,S,R,I,D,J,Ne,We,F,Ie,pi,W,De;return pi=l,W=l,s=me(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?(t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=me(),S!==null?(t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=me(),I!==null?(t.charCodeAt(l)===58?(D=":",l++):(D=null,E('":"')),D!==null?(J=me(),J!==null?(t.charCodeAt(l)===58?(Ne=":",l++):(Ne=null,E('":"')),Ne!==null?(We=me(),We!==null?(t.charCodeAt(l)===58?(F=":",l++):(F=null,E('":"')),F!==null?(Ie=Tt(),Ie!==null?s=[s,c,h,g,S,R,I,D,J,Ne,We,F,Ie]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=me(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=me(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=me(),D!==null?(t.charCodeAt(l)===58?(J=":",l++):(J=null,E('":"')),J!==null?(Ne=me(),Ne!==null?(t.charCodeAt(l)===58?(We=":",l++):(We=null,E('":"')),We!==null?(F=Tt(),F!==null?s=[s,c,h,g,S,R,I,D,J,Ne,We,F]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=me(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=me(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=me(),D!==null?(t.charCodeAt(l)===58?(J=":",l++):(J=null,E('":"')),J!==null?(Ne=Tt(),Ne!==null?s=[s,c,h,g,S,R,I,D,J,Ne]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=me(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=me(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Tt(),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=me(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Tt(),R!==null?s=[s,c,h,g,S,R]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=me(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Tt(),g!==null?s=[s,c,h,g]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Tt(),c!==null?s=[s,c]:(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=me(),c!==null?s=[s,c]:(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=me(),s!==null?(t.substr(l,2)==="::"?(c="::",l+=2):(c=null,E('"::"')),c!==null?(h=me(),h!==null?(t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=me(),S!==null?(t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=me(),I!==null?(t.charCodeAt(l)===58?(D=":",l++):(D=null,E('":"')),D!==null?(J=me(),J!==null?(t.charCodeAt(l)===58?(Ne=":",l++):(Ne=null,E('":"')),Ne!==null?(We=Tt(),We!==null?s=[s,c,h,g,S,R,I,D,J,Ne,We]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=me(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(t.substr(l,2)==="::"?(h="::",l+=2):(h=null,E('"::"')),h!==null?(g=me(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=me(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=me(),D!==null?(t.charCodeAt(l)===58?(J=":",l++):(J=null,E('":"')),J!==null?(Ne=Tt(),Ne!==null?s=[s,c,h,g,S,R,I,D,J,Ne]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=me(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(t.substr(l,2)==="::"?(g="::",l+=2):(g=null,E('"::"')),g!==null?(S=me(),S!==null?(t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=me(),I!==null?(t.charCodeAt(l)===58?(D=":",l++):(D=null,E('":"')),D!==null?(J=Tt(),J!==null?s=[s,c,h,g,S,R,I,D,J]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=me(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=me(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(t.substr(l,2)==="::"?(S="::",l+=2):(S=null,E('"::"')),S!==null?(R=me(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Tt(),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=me(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=me(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(De=l,t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=me(),R!==null?S=[S,R]:(S=null,l=De)):(S=null,l=De),S=S!==null?S:"",S!==null?(t.substr(l,2)==="::"?(R="::",l+=2):(R=null,E('"::"')),R!==null?(I=Tt(),I!==null?s=[s,c,h,g,S,R,I]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=me(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=me(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(De=l,t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=me(),R!==null?S=[S,R]:(S=null,l=De)):(S=null,l=De),S=S!==null?S:"",S!==null?(De=l,t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=me(),I!==null?R=[R,I]:(R=null,l=De)):(R=null,l=De),R=R!==null?R:"",R!==null?(t.substr(l,2)==="::"?(I="::",l+=2):(I=null,E('"::"')),I!==null?(D=me(),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=me(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=me(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=me(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(De=l,t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=me(),R!==null?S=[S,R]:(S=null,l=De)):(S=null,l=De),S=S!==null?S:"",S!==null?(De=l,t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=me(),I!==null?R=[R,I]:(R=null,l=De)):(R=null,l=De),R=R!==null?R:"",R!==null?(De=l,t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=me(),D!==null?I=[I,D]:(I=null,l=De)):(I=null,l=De),I=I!==null?I:"",I!==null?(t.substr(l,2)==="::"?(D="::",l+=2):(D=null,E('"::"')),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W))))))))))))))),s!==null&&(s=function($h){return T.host_type="IPv6",t.substring(l,$h)}(pi)),s===null&&(l=pi),s}function me(){var s,c,h,g,S;return S=l,s=U(),s!==null?(c=U(),c=c!==null?c:"",c!==null?(h=U(),h=h!==null?h:"",h!==null?(g=U(),g=g!==null?g:"",g!==null?s=[s,c,h,g]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s}function Tt(){var s,c,h,g;return g=l,s=me(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=me(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s===null&&(s=Rs()),s}function Rs(){var s,c,h,g,S,R,I,D,J;return D=l,J=l,s=cs(),s!==null?(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c!==null?(h=cs(),h!==null?(t.charCodeAt(l)===46?(g=".",l++):(g=null,E('"."')),g!==null?(S=cs(),S!==null?(t.charCodeAt(l)===46?(R=".",l++):(R=null,E('"."')),R!==null?(I=cs(),I!==null?s=[s,c,h,g,S,R,I]:(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J),s!==null&&(s=function(Ne){return T.host_type="IPv4",t.substring(l,Ne)}(D)),s===null&&(l=D),s}function cs(){var s,c,h,g;return g=l,t.substr(l,2)==="25"?(s="25",l+=2):(s=null,E('"25"')),s!==null?(/^[0-5]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[0-5]")),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s===null&&(g=l,t.charCodeAt(l)===50?(s="2",l++):(s=null,E('"2"')),s!==null?(/^[0-4]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[0-4]")),c!==null?(h=w(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s===null&&(g=l,t.charCodeAt(l)===49?(s="1",l++):(s=null,E('"1"')),s!==null?(c=w(),c!==null?(h=w(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s===null&&(g=l,/^[1-9]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[1-9]")),s!==null?(c=w(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s===null&&(s=w())))),s}function Wn(){var s,c,h,g,S,R,I;return R=l,I=l,s=w(),s=s!==null?s:"",s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?s=[s,c,h,g,S]:(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(D,J){return J=parseInt(J.join("")),T.port=J,J}(R,s)),s===null&&(l=R),s}function Kn(){var s,c,h,g;for(s=[],g=l,t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c!==null?(h=pn(),h!==null?c=[c,h]:(c=null,l=g)):(c=null,l=g);c!==null;)s.push(c),g=l,t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c!==null?(h=pn(),h!==null?c=[c,h]:(c=null,l=g)):(c=null,l=g);return s}function pn(){var s;return s=Yn(),s===null&&(s=zn(),s===null&&(s=Jn(),s===null&&(s=bs(),s===null&&(s=Xn(),s===null&&(s=Qn(),s===null&&(s=Qt())))))),s}function Yn(){var s,c,h,g;return h=l,g=l,t.substr(l,10).toLowerCase()==="transport="?(s=t.substr(l,10),l+=10):(s=null,E('"transport="')),s!==null?(t.substr(l,3).toLowerCase()==="udp"?(c=t.substr(l,3),l+=3):(c=null,E('"udp"')),c===null&&(t.substr(l,3).toLowerCase()==="tcp"?(c=t.substr(l,3),l+=3):(c=null,E('"tcp"')),c===null&&(t.substr(l,4).toLowerCase()==="sctp"?(c=t.substr(l,4),l+=4):(c=null,E('"sctp"')),c===null&&(t.substr(l,3).toLowerCase()==="tls"?(c=t.substr(l,3),l+=3):(c=null,E('"tls"')),c===null&&(c=P())))),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.transport=R.toLowerCase()}(h,s[1])),s===null&&(l=h),s}function zn(){var s,c,h,g;return h=l,g=l,t.substr(l,5).toLowerCase()==="user="?(s=t.substr(l,5),l+=5):(s=null,E('"user="')),s!==null?(t.substr(l,5).toLowerCase()==="phone"?(c=t.substr(l,5),l+=5):(c=null,E('"phone"')),c===null&&(t.substr(l,2).toLowerCase()==="ip"?(c=t.substr(l,2),l+=2):(c=null,E('"ip"')),c===null&&(c=P())),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.user=R.toLowerCase()}(h,s[1])),s===null&&(l=h),s}function Jn(){var s,c,h,g;return h=l,g=l,t.substr(l,7).toLowerCase()==="method="?(s=t.substr(l,7),l+=7):(s=null,E('"method="')),s!==null?(c=En(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.method=R}(h,s[1])),s===null&&(l=h),s}function bs(){var s,c,h,g;return h=l,g=l,t.substr(l,4).toLowerCase()==="ttl="?(s=t.substr(l,4),l+=4):(s=null,E('"ttl="')),s!==null?(c=xl(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.params||(T.params={}),T.params.ttl=R}(h,s[1])),s===null&&(l=h),s}function Xn(){var s,c,h,g;return h=l,g=l,t.substr(l,6).toLowerCase()==="maddr="?(s=t.substr(l,6),l+=6):(s=null,E('"maddr="')),s!==null?(c=Se(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.maddr=R}(h,s[1])),s===null&&(l=h),s}function Qn(){var s,c,h,g,S,R;return g=l,S=l,t.substr(l,2).toLowerCase()==="lr"?(s=t.substr(l,2),l+=2):(s=null,E('"lr"')),s!==null?(R=l,t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=P(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T.uri_params||(T.uri_params={}),T.uri_params.lr=void 0}()),s===null&&(l=g),s}function Qt(){var s,c,h,g,S,R;return g=l,S=l,s=Zn(),s!==null?(R=l,t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=el(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I,D,J){T.uri_params||(T.uri_params={}),typeof J>"u"?J=void 0:J=J[1],T.uri_params[D.toLowerCase()]=J}(g,s[0],s[1])),s===null&&(l=g),s}function Zn(){var s,c,h;if(h=l,c=kt(),c!==null)for(s=[];c!==null;)s.push(c),c=kt();else s=null;return s!==null&&(s=function(g,S){return S.join("")}(h,s)),s===null&&(l=h),s}function el(){var s,c,h;if(h=l,c=kt(),c!==null)for(s=[];c!==null;)s.push(c),c=kt();else s=null;return s!==null&&(s=function(g,S){return S.join("")}(h,s)),s===null&&(l=h),s}function kt(){var s;return s=er(),s===null&&(s=B(),s===null&&(s=V())),s}function er(){var s;return t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s===null&&(t.charCodeAt(l)===93?(s="]",l++):(s=null,E('"]"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')))))))),s}function tl(){var s,c,h,g,S,R,I;if(R=l,t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s!==null)if(c=Zt(),c!==null){for(h=[],I=l,t.charCodeAt(l)===38?(g="&",l++):(g=null,E('"&"')),g!==null?(S=Zt(),S!==null?g=[g,S]:(g=null,l=I)):(g=null,l=I);g!==null;)h.push(g),I=l,t.charCodeAt(l)===38?(g="&",l++):(g=null,E('"&"')),g!==null?(S=Zt(),S!==null?g=[g,S]:(g=null,l=I)):(g=null,l=I);h!==null?s=[s,c,h]:(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s}function Zt(){var s,c,h,g,S;return g=l,S=l,s=sl(),s!==null?(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=nl(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I,D){I=I.join("").toLowerCase(),D=D.join(""),T.uri_headers||(T.uri_headers={}),T.uri_headers[I]?T.uri_headers[I].push(D):T.uri_headers[I]=[D]}(g,s[0],s[2])),s===null&&(l=g),s}function sl(){var s,c;if(c=Is(),c===null&&(c=B(),c===null&&(c=V())),c!==null)for(s=[];c!==null;)s.push(c),c=Is(),c===null&&(c=B(),c===null&&(c=V()));else s=null;return s}function nl(){var s,c;for(s=[],c=Is(),c===null&&(c=B(),c===null&&(c=V()));c!==null;)s.push(c),c=Is(),c===null&&(c=B(),c===null&&(c=V()));return s}function Is(){var s;return t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s===null&&(t.charCodeAt(l)===93?(s="]",l++):(s=null,E('"]"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')))))))),s}function Ks(){var s;return s=sr(),console.log("result0",s),s===null&&(s=ll(),console.log("result0 2",s)),s}function ll(){var s,c,h,g,S,R;return R=l,s=En(),s!==null?(c=k(),console.log("parse_SP",c),c!==null?(h=ws(),console.log("parse_Request_URI",h),h!==null?(g=k(),console.log("parse_SP 2",g),g!==null?(S=Tn(),S!==null?s=[s,c,h,g,S]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s}function ws(){var s;return s=Mt(),s===null&&(s=Os()),s}function Os(){var s,c,h,g;return g=l,s=il(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=rl(),h===null&&(h=Ns()),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function rl(){var s,c,h,g,S;return g=l,s=es(),s===null&&(s=Ds()),s!==null?(S=l,t.charCodeAt(l)===63?(c="?",l++):(c=null,E('"?"')),c!==null?(h=ul(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function es(){var s,c,h,g;return g=l,t.substr(l,2)==="//"?(s="//",l+=2):(s=null,E('"//"')),s!==null?(c=al(),c!==null?(h=Ds(),h=h!==null?h:"",h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Ds(){var s,c,h;return h=l,t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s!==null?(c=Us(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function Ns(){var s,c,h,g;if(g=l,s=mn(),s!==null){for(c=[],h=ts();h!==null;)c.push(h),h=ts();c!==null?s=[s,c]:(s=null,l=g)}else s=null,l=g;return s}function ts(){var s;return s=Ue(),s===null&&(s=B(),s===null&&(s=V())),s}function mn(){var s;return s=B(),s===null&&(s=V(),s===null&&(t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')))))))))))),s}function Us(){var s,c,h,g,S,R;if(S=l,s=Ys(),s!==null){for(c=[],R=l,t.charCodeAt(l)===47?(h="/",l++):(h=null,E('"/"')),h!==null?(g=Ys(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,t.charCodeAt(l)===47?(h="/",l++):(h=null,E('"/"')),h!==null?(g=Ys(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Ys(){var s,c,h,g,S,R;for(S=l,s=[],c=fs();c!==null;)s.push(c),c=fs();if(s!==null){for(c=[],R=l,t.charCodeAt(l)===59?(h=";",l++):(h=null,E('";"')),h!==null?(g=gn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,t.charCodeAt(l)===59?(h=";",l++):(h=null,E('";"')),h!==null?(g=gn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function gn(){var s,c;for(s=[],c=fs();c!==null;)s.push(c),c=fs();return s}function fs(){var s;return s=B(),s===null&&(s=V(),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')))))))))),s}function il(){var s,c,h,g,S;if(g=l,S=l,s=N(),s!==null){for(c=[],h=N(),h===null&&(h=w(),h===null&&(t.charCodeAt(l)===43?(h="+",l++):(h=null,E('"+"')),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."'))))));h!==null;)c.push(h),h=N(),h===null&&(h=w(),h===null&&(t.charCodeAt(l)===43?(h="+",l++):(h=null,E('"+"')),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."'))))));c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s!==null&&(s=function(R){T.scheme=t.substring(l,R)}(g)),s===null&&(l=g),s}function al(){var s;return s=vn(),s===null&&(s=ol()),s}function vn(){var s,c,h,g;return h=l,g=l,s=As(),s!==null?(t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s=s!==null?s:"",s!==null?(c=os(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s=s!==null?s:"",s}function ol(){var s,c;if(c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","')),c===null&&(t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"'))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","')),c===null&&(t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')))))))))));else s=null;return s}function ul(){var s,c;for(s=[],c=ts();c!==null;)s.push(c),c=ts();return s}function Tn(){var s,c,h,g,S,R,I,D;if(I=l,D=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"SIP"')),s!==null)if(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c!==null){if(g=w(),g!==null)for(h=[];g!==null;)h.push(g),g=w();else h=null;if(h!==null)if(t.charCodeAt(l)===46?(g=".",l++):(g=null,E('"."')),g!==null){if(R=w(),R!==null)for(S=[];R!==null;)S.push(R),R=w();else S=null;S!==null?s=[s,c,h,g,S]:(s=null,l=D)}else s=null,l=D;else s=null,l=D}else s=null,l=D;else s=null,l=D;return s!==null&&(s=function(J){T.sip_version=t.substring(l,J)}(I)),s===null&&(l=I),s}function cl(){var s;return t.substr(l,6)==="INVITE"?(s="INVITE",l+=6):(s=null,E('"INVITE"')),s}function fl(){var s;return t.substr(l,3)==="ACK"?(s="ACK",l+=3):(s=null,E('"ACK"')),s}function hl(){var s;return t.substr(l,7)==="OPTIONS"?(s="OPTIONS",l+=7):(s=null,E('"OPTIONS"')),s}function zs(){var s;return t.substr(l,3)==="BYE"?(s="BYE",l+=3):(s=null,E('"BYE"')),s}function _l(){var s;return t.substr(l,6)==="CANCEL"?(s="CANCEL",l+=6):(s=null,E('"CANCEL"')),s}function dl(){var s;return t.substr(l,8)==="REGISTER"?(s="REGISTER",l+=8):(s=null,E('"REGISTER"')),s}function Js(){var s;return t.substr(l,9)==="SUBSCRIBE"?(s="SUBSCRIBE",l+=9):(s=null,E('"SUBSCRIBE"')),s}function pl(){var s;return t.substr(l,6)==="NOTIFY"?(s="NOTIFY",l+=6):(s=null,E('"NOTIFY"')),s}function tr(){var s;return t.substr(l,5)==="REFER"?(s="REFER",l+=5):(s=null,E('"REFER"')),s}function En(){var s,c;return c=l,s=cl(),s===null&&(s=fl(),s===null&&(s=hl(),s===null&&(s=zs(),s===null&&(s=_l(),s===null&&(s=dl(),s===null&&(s=Js(),s===null&&(s=pl(),s===null&&(s=tr(),s===null&&(s=P()))))))))),s!==null&&(s=function(h){return T.method=t.substring(l,h),T.method}(c)),s===null&&(l=c),s}function sr(){var s,c,h,g,S,R;return R=l,s=Tn(),s!==null?(c=k(),c!==null?(h=Cn(),h!==null?(g=k(),g!==null?(S=Sn(),S!==null?s=[s,c,h,g,S]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s}function Cn(){var s,c;return c=l,s=hs(),s!==null&&(s=function(h,g){T.status_code=parseInt(g.join(""))}(c,s)),s===null&&(l=c),s}function hs(){var s,c,h,g;return g=l,s=w(),s!==null?(c=w(),c!==null?(h=w(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Sn(){var s,c,h;for(h=l,s=[],c=Ue(),c===null&&(c=B(),c===null&&(c=V(),c===null&&(c=$(),c===null&&(c=ne(),c===null&&(c=k(),c===null&&(c=H()))))));c!==null;)s.push(c),c=Ue(),c===null&&(c=B(),c===null&&(c=V(),c===null&&(c=$(),c===null&&(c=ne(),c===null&&(c=k(),c===null&&(c=H()))))));return s!==null&&(s=function(g){T.reason_phrase=t.substring(l,g)}(h)),s===null&&(l=h),s}function Xs(){var s,c,h,g,S,R;if(S=l,s=Ms(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=Ms(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=Ms(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function _s(){var s,c,h,g,S,R;return g=l,S=l,s=he(),s!==null?(R=l,t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c!==null?(h=he(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T=t.substring(l,I)}(g)),s===null&&(l=g),s}function An(){var s,c,h,g,S,R,I;if(S=l,s=Re(),s===null)if(R=l,s=Lt(),s!==null){for(c=[],I=l,h=$e(),h!==null?(g=Lt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=$e(),h!==null?(g=Lt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J,Ne;for(Ne=T.multi_header.length,J=0;J<Ne;J++)if(T.multi_header[J].parsed===null){T=null;break}T!==null?T=T.multi_header:T=-1}()),s===null&&(l=S),s}function Lt(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ss()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Gt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Gt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J;T.multi_header||(T.multi_header=[]);try{J=new m(T.uri,T.display_name,T.params),delete T.uri,delete T.display_name,delete T.params}catch{J=null}T.multi_header.push({possition:l,offset:D,parsed:J})}(S)),s===null&&(l=S),s}function ss(){var s,c,h,g,S;return S=l,s=Ke(),s=s!==null?s:"",s!==null?(c=st(),c!==null?(h=Mt(),h!==null?(g=we(),g!==null?s=[s,c,h,g]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s}function Ke(){var s,c,h,g,S,R,I;if(S=l,R=l,s=P(),s!==null){for(c=[],I=l,h=G(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=G(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s===null&&(s=ke()),s!==null&&(s=function(D,J){typeof J=="string"?T.display_name=J:T.display_name=J[1].reduce(function(Ne,We){return Ne+We[0]+We[1]},J[0])}(S,s)),s===null&&(l=S),s}function Gt(){var s;return s=nr(),s===null&&(s=Je(),s===null&&(s=Ze())),s}function nr(){var s,c,h,g,S;return g=l,S=l,t.substr(l,1).toLowerCase()==="q"?(s=t.substr(l,1),l++):(s=null,E('"q"')),s!==null?(c=fe(),c!==null?(h=lr(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.params||(T.params={}),T.params.q=I}(g,s[2])),s===null&&(l=g),s}function Je(){var s,c,h,g,S;return g=l,S=l,t.substr(l,7).toLowerCase()==="expires"?(s=t.substr(l,7),l+=7):(s=null,E('"expires"')),s!==null?(c=fe(),c!==null?(h=Wt(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.params||(T.params={}),T.params.expires=I}(g,s[2])),s===null&&(l=g),s}function Wt(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){return parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function lr(){var s,c,h,g,S,R,I,D;return R=l,I=l,t.charCodeAt(l)===48?(s="0",l++):(s=null,E('"0"')),s!==null?(D=l,t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?c=[c,h,g,S]:(c=null,l=D)):(c=null,l=D)):(c=null,l=D)):(c=null,l=D),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(J){return parseFloat(t.substring(l,J))}(R)),s===null&&(l=R),s}function Ze(){var s,c,h,g,S,R;return g=l,S=l,s=P(),s!==null?(R=l,c=fe(),c!==null?(h=ml(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I,D,J){T.params||(T.params={}),typeof J>"u"?J=void 0:J=J[1],T.params[D.toLowerCase()]=J}(g,s[0],s[1])),s===null&&(l=g),s}function ml(){var s;return s=P(),s===null&&(s=Se(),s===null&&(s=Ce())),s}function $r(){var s,c,h,g,S,R;if(S=l,s=rr(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=gl(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=gl(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function rr(){var s;return t.substr(l,6).toLowerCase()==="render"?(s=t.substr(l,6),l+=6):(s=null,E('"render"')),s===null&&(t.substr(l,7).toLowerCase()==="session"?(s=t.substr(l,7),l+=7):(s=null,E('"session"')),s===null&&(t.substr(l,4).toLowerCase()==="icon"?(s=t.substr(l,4),l+=4):(s=null,E('"icon"')),s===null&&(t.substr(l,5).toLowerCase()==="alert"?(s=t.substr(l,5),l+=5):(s=null,E('"alert"')),s===null&&(s=P())))),s}function gl(){var s;return s=ir(),s===null&&(s=Ze()),s}function ir(){var s,c,h,g;return g=l,t.substr(l,8).toLowerCase()==="handling"?(s=t.substr(l,8),l+=8):(s=null,E('"handling"')),s!==null?(c=fe(),c!==null?(t.substr(l,8).toLowerCase()==="optional"?(h=t.substr(l,8),l+=8):(h=null,E('"optional"')),h===null&&(t.substr(l,8).toLowerCase()==="required"?(h=t.substr(l,8),l+=8):(h=null,E('"required"')),h===null&&(h=P())),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function ar(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function yn(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){T=parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function or(){var s,c;return c=l,s=vl(),s!==null&&(s=function(h){T=t.substring(l,h)}(c)),s===null&&(l=c),s}function vl(){var s,c,h,g,S,R,I,D;if(I=l,s=xs(),s!==null)if(c=be(),c!==null)if(h=Hr(),h!==null){for(g=[],D=l,S=ue(),S!==null?(R=ds(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=ue(),S!==null?(R=ds(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s}function xs(){var s;return s=Tl(),s===null&&(s=ur()),s}function Tl(){var s;return t.substr(l,4).toLowerCase()==="text"?(s=t.substr(l,4),l+=4):(s=null,E('"text"')),s===null&&(t.substr(l,5).toLowerCase()==="image"?(s=t.substr(l,5),l+=5):(s=null,E('"image"')),s===null&&(t.substr(l,5).toLowerCase()==="audio"?(s=t.substr(l,5),l+=5):(s=null,E('"audio"')),s===null&&(t.substr(l,5).toLowerCase()==="video"?(s=t.substr(l,5),l+=5):(s=null,E('"video"')),s===null&&(t.substr(l,11).toLowerCase()==="application"?(s=t.substr(l,11),l+=11):(s=null,E('"application"')),s===null&&(s=Ps()))))),s}function ur(){var s;return t.substr(l,7).toLowerCase()==="message"?(s=t.substr(l,7),l+=7):(s=null,E('"message"')),s===null&&(t.substr(l,9).toLowerCase()==="multipart"?(s=t.substr(l,9),l+=9):(s=null,E('"multipart"')),s===null&&(s=Ps())),s}function Ps(){var s;return s=P(),s===null&&(s=cr()),s}function cr(){var s,c,h;return h=l,t.substr(l,2).toLowerCase()==="x-"?(s=t.substr(l,2),l+=2):(s=null,E('"x-"')),s!==null?(c=P(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function Hr(){var s;return s=Ps(),s===null&&(s=P()),s}function ds(){var s,c,h,g;return g=l,s=P(),s!==null?(c=fe(),c!==null?(h=Fr(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Fr(){var s;return s=P(),s===null&&(s=Ce()),s}function fr(){var s,c,h,g;return g=l,s=ps(),s!==null?(c=G(),c!==null?(h=En(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function ps(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){T.value=parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function fi(){var s,c;return c=l,s=Wt(),s!==null&&(s=function(h,g){T=g}(c,s)),s===null&&(l=c),s}function hr(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ms(),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D,J){T.event=J.join("").toLowerCase()}(S,s[0])),s===null&&(l=S),s}function Ms(){var s,c,h,g,S,R;if(S=l,s=Q(),s!==null){for(c=[],R=l,t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?(g=Q(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?(g=Q(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function hi(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ss()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Rn(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Rn(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J=T.tag;try{T=new m(T.uri,T.display_name,T.params),J&&T.setParam("tag",J)}catch{T=-1}}()),s===null&&(l=S),s}function Rn(){var s;return s=El(),s===null&&(s=Ze()),s}function El(){var s,c,h,g,S;return g=l,S=l,t.substr(l,3).toLowerCase()==="tag"?(s=t.substr(l,3),l+=3):(s=null,E('"tag"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.tag=I}(g,s[2])),s===null&&(l=g),s}function bn(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){T=parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function Qs(){var s,c;return c=l,s=Wt(),s!==null&&(s=function(h,g){T=g}(c,s)),s===null&&(l=c),s}function _r(){var s,c,h,g,S,R,I,D,J,Ne;for(D=l,J=l,s=[],c=Ke();c!==null;)s.push(c),c=Ke();if(s!==null)if(c=st(),c!==null)if(h=Mt(),h!==null)if(g=we(),g!==null){for(S=[],Ne=l,R=ue(),R!==null?(I=Ze(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);R!==null;)S.push(R),Ne=l,R=ue(),R!==null?(I=Ze(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);S!==null?s=[s,c,h,g,S]:(s=null,l=J)}else s=null,l=J;else s=null,l=J;else s=null,l=J;else s=null,l=J;return s!==null&&(s=function(We){try{T=new m(T.uri,T.display_name,T.params)}catch{T=-1}}()),s===null&&(l=D),s}function Zs(){var s;return s=ks(),s}function ks(){var s,c,h,g,S,R,I,D;if(I=l,t.substr(l,6).toLowerCase()==="digest"?(s=t.substr(l,6),l+=6):(s=null,E('"Digest"')),s!==null)if(c=G(),c!==null)if(h=tn(),h!==null){for(g=[],D=l,S=$e(),S!==null?(R=tn(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=$e(),S!==null?(R=tn(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s===null&&(s=en()),s}function en(){var s,c,h,g,S,R,I,D;if(I=l,s=P(),s!==null)if(c=G(),c!==null)if(h=Ls(),h!==null){for(g=[],D=l,S=$e(),S!==null?(R=Ls(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=$e(),S!==null?(R=Ls(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s}function Ls(){var s,c,h,g;return g=l,s=P(),s!==null?(c=fe(),c!==null?(h=P(),h===null&&(h=Ce()),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function tn(){var s;return s=sn(),s===null&&(s=Sl(),s===null&&(s=ln(),s===null&&(s=pr(),s===null&&(s=ms(),s===null&&(s=qr(),s===null&&(s=Al(),s===null&&(s=Ls()))))))),s}function sn(){var s,c,h,g;return g=l,t.substr(l,5).toLowerCase()==="realm"?(s=t.substr(l,5),l+=5):(s=null,E('"realm"')),s!==null?(c=fe(),c!==null?(h=Cl(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Cl(){var s,c;return c=l,s=ke(),s!==null&&(s=function(h,g){T.realm=g}(c,s)),s===null&&(l=c),s}function Sl(){var s,c,h,g,S,R,I,D,J;if(D=l,t.substr(l,6).toLowerCase()==="domain"?(s=t.substr(l,6),l+=6):(s=null,E('"domain"')),s!==null)if(c=fe(),c!==null)if(h=Pe(),h!==null)if(g=nn(),g!==null){if(S=[],J=l,I=k(),I!==null)for(R=[];I!==null;)R.push(I),I=k();else R=null;for(R!==null?(I=nn(),I!==null?R=[R,I]:(R=null,l=J)):(R=null,l=J);R!==null;){if(S.push(R),J=l,I=k(),I!==null)for(R=[];I!==null;)R.push(I),I=k();else R=null;R!==null?(I=nn(),I!==null?R=[R,I]:(R=null,l=J)):(R=null,l=J)}S!==null?(R=Le(),R!==null?s=[s,c,h,g,S,R]:(s=null,l=D)):(s=null,l=D)}else s=null,l=D;else s=null,l=D;else s=null,l=D;else s=null,l=D;return s}function nn(){var s;return s=Os(),s===null&&(s=Ds()),s}function ln(){var s,c,h,g;return g=l,t.substr(l,5).toLowerCase()==="nonce"?(s=t.substr(l,5),l+=5):(s=null,E('"nonce"')),s!==null?(c=fe(),c!==null?(h=dr(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function dr(){var s,c;return c=l,s=ke(),s!==null&&(s=function(h,g){T.nonce=g}(c,s)),s===null&&(l=c),s}function pr(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6).toLowerCase()==="opaque"?(s=t.substr(l,6),l+=6):(s=null,E('"opaque"')),s!==null?(c=fe(),c!==null?(h=ke(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.opaque=I}(g,s[2])),s===null&&(l=g),s}function ms(){var s,c,h,g,S;return g=l,t.substr(l,5).toLowerCase()==="stale"?(s=t.substr(l,5),l+=5):(s=null,E('"stale"')),s!==null?(c=fe(),c!==null?(S=l,t.substr(l,4).toLowerCase()==="true"?(h=t.substr(l,4),l+=4):(h=null,E('"true"')),h!==null&&(h=function(R){T.stale=!0}()),h===null&&(l=S),h===null&&(S=l,t.substr(l,5).toLowerCase()==="false"?(h=t.substr(l,5),l+=5):(h=null,E('"false"')),h!==null&&(h=function(R){T.stale=!1}()),h===null&&(l=S)),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function qr(){var s,c,h,g,S;return g=l,S=l,t.substr(l,9).toLowerCase()==="algorithm"?(s=t.substr(l,9),l+=9):(s=null,E('"algorithm"')),s!==null?(c=fe(),c!==null?(t.substr(l,3).toLowerCase()==="md5"?(h=t.substr(l,3),l+=3):(h=null,E('"MD5"')),h===null&&(t.substr(l,8).toLowerCase()==="md5-sess"?(h=t.substr(l,8),l+=8):(h=null,E('"MD5-sess"')),h===null&&(h=P())),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.algorithm=I.toUpperCase()}(g,s[2])),s===null&&(l=g),s}function Al(){var s,c,h,g,S,R,I,D,J,Ne;if(D=l,t.substr(l,3).toLowerCase()==="qop"?(s=t.substr(l,3),l+=3):(s=null,E('"qop"')),s!==null)if(c=fe(),c!==null)if(h=Pe(),h!==null){if(J=l,g=gs(),g!==null){for(S=[],Ne=l,t.charCodeAt(l)===44?(R=",",l++):(R=null,E('","')),R!==null?(I=gs(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);R!==null;)S.push(R),Ne=l,t.charCodeAt(l)===44?(R=",",l++):(R=null,E('","')),R!==null?(I=gs(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);S!==null?g=[g,S]:(g=null,l=J)}else g=null,l=J;g!==null?(S=Le(),S!==null?s=[s,c,h,g,S]:(s=null,l=D)):(s=null,l=D)}else s=null,l=D;else s=null,l=D;else s=null,l=D;return s}function gs(){var s,c;return c=l,t.substr(l,8).toLowerCase()==="auth-int"?(s=t.substr(l,8),l+=8):(s=null,E('"auth-int"')),s===null&&(t.substr(l,4).toLowerCase()==="auth"?(s=t.substr(l,4),l+=4):(s=null,E('"auth"')),s===null&&(s=P())),s!==null&&(s=function(h,g){T.qop||(T.qop=[]),T.qop.push(g.toLowerCase())}(c,s)),s===null&&(l=c),s}function _i(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function mr(){var s,c,h,g,S,R,I;if(S=l,R=l,s=vs(),s!==null){for(c=[],I=l,h=$e(),h!==null?(g=vs(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=$e(),h!==null?(g=vs(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J,Ne;for(Ne=T.multi_header.length,J=0;J<Ne;J++)if(T.multi_header[J].parsed===null){T=null;break}T!==null?T=T.multi_header:T=-1}()),s===null&&(l=S),s}function vs(){var s,c,h,g,S,R,I;if(S=l,R=l,s=ss(),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J;T.multi_header||(T.multi_header=[]);try{J=new m(T.uri,T.display_name,T.params),delete T.uri,delete T.display_name,delete T.params}catch{J=null}T.multi_header.push({possition:l,offset:D,parsed:J})}(S)),s===null&&(l=S),s}function di(){var s,c,h,g,S,R,I;if(S=l,R=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"SIP"')),s===null&&(s=P()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=yl(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=yl(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D,J){if(T.protocol=J.toLowerCase(),T.params||(T.params={}),T.params.text&&T.params.text[0]==='"'){var Ne=T.params.text;T.text=Ne.substring(1,Ne.length-1),delete T.params.text}}(S,s[0])),s===null&&(l=S),s}function yl(){var s;return s=$s(),s===null&&(s=Ze()),s}function $s(){var s,c,h,g,S,R;if(S=l,R=l,t.substr(l,5).toLowerCase()==="cause"?(s=t.substr(l,5),l+=5):(s=null,E('"cause"')),s!==null)if(c=fe(),c!==null){if(g=w(),g!==null)for(h=[];g!==null;)h.push(g),g=w();else h=null;h!==null?s=[s,c,h]:(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s!==null&&(s=function(I,D){T.cause=parseInt(D.join(""))}(S,s[2])),s===null&&(l=S),s}function jr(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Vr(){var s,c,h,g,S,R;if(S=l,s=rn(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=rn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=rn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function rn(){var s,c,h,g,S,R;if(S=l,s=ss(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Br(){var s,c,h,g,S,R;if(S=l,s=Rl(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=gr(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=gr(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Rl(){var s,c;return c=l,t.substr(l,6).toLowerCase()==="active"?(s=t.substr(l,6),l+=6):(s=null,E('"active"')),s===null&&(t.substr(l,7).toLowerCase()==="pending"?(s=t.substr(l,7),l+=7):(s=null,E('"pending"')),s===null&&(t.substr(l,10).toLowerCase()==="terminated"?(s=t.substr(l,10),l+=10):(s=null,E('"terminated"')),s===null&&(s=P()))),s!==null&&(s=function(h){T.state=t.substring(l,h)}(c)),s===null&&(l=c),s}function gr(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6).toLowerCase()==="reason"?(s=t.substr(l,6),l+=6):(s=null,E('"reason"')),s!==null?(c=fe(),c!==null?(h=In(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){typeof I<"u"&&(T.reason=I)}(g,s[2])),s===null&&(l=g),s===null&&(g=l,S=l,t.substr(l,7).toLowerCase()==="expires"?(s=t.substr(l,7),l+=7):(s=null,E('"expires"')),s!==null?(c=fe(),c!==null?(h=Wt(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){typeof I<"u"&&(T.expires=I)}(g,s[2])),s===null&&(l=g),s===null&&(g=l,S=l,t.substr(l,11).toLowerCase()==="retry_after"?(s=t.substr(l,11),l+=11):(s=null,E('"retry_after"')),s!==null?(c=fe(),c!==null?(h=Wt(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){typeof I<"u"&&(T.retry_after=I)}(g,s[2])),s===null&&(l=g),s===null&&(s=Ze()))),s}function In(){var s;return t.substr(l,11).toLowerCase()==="deactivated"?(s=t.substr(l,11),l+=11):(s=null,E('"deactivated"')),s===null&&(t.substr(l,9).toLowerCase()==="probation"?(s=t.substr(l,9),l+=9):(s=null,E('"probation"')),s===null&&(t.substr(l,8).toLowerCase()==="rejected"?(s=t.substr(l,8),l+=8):(s=null,E('"rejected"')),s===null&&(t.substr(l,7).toLowerCase()==="timeout"?(s=t.substr(l,7),l+=7):(s=null,E('"timeout"')),s===null&&(t.substr(l,6).toLowerCase()==="giveup"?(s=t.substr(l,6),l+=6):(s=null,E('"giveup"')),s===null&&(t.substr(l,10).toLowerCase()==="noresource"?(s=t.substr(l,10),l+=10):(s=null,E('"noresource"')),s===null&&(t.substr(l,9).toLowerCase()==="invariant"?(s=t.substr(l,9),l+=9):(s=null,E('"invariant"')),s===null&&(s=P()))))))),s}function wn(){var s;return s=te(),s=s!==null?s:"",s}function Gr(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s=s!==null?s:"",s}function On(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ss()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=an(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=an(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J=T.tag;try{T=new m(T.uri,T.display_name,T.params),J&&T.setParam("tag",J)}catch{T=-1}}()),s===null&&(l=S),s}function an(){var s;return s=El(),s===null&&(s=Ze()),s}function vr(){var s,c,h,g,S,R;if(S=l,s=on(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=on(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=on(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function on(){var s,c,h,g,S,R,I,D;if(I=l,s=Nn(),s!==null)if(c=G(),c!==null)if(h=Un(),h!==null){for(g=[],D=l,S=ue(),S!==null?(R=Dn(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=ue(),S!==null?(R=Dn(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s}function Dn(){var s;return s=bl(),s===null&&(s=Il(),s===null&&(s=wl(),s===null&&(s=Ol(),s===null&&(s=Dl(),s===null&&(s=Ze()))))),s}function bl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,3).toLowerCase()==="ttl"?(s=t.substr(l,3),l+=3):(s=null,E('"ttl"')),s!==null?(c=fe(),c!==null?(h=xl(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.ttl=I}(g,s[2])),s===null&&(l=g),s}function Il(){var s,c,h,g,S;return g=l,S=l,t.substr(l,5).toLowerCase()==="maddr"?(s=t.substr(l,5),l+=5):(s=null,E('"maddr"')),s!==null?(c=fe(),c!==null?(h=Se(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.maddr=I}(g,s[2])),s===null&&(l=g),s}function wl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,8).toLowerCase()==="received"?(s=t.substr(l,8),l+=8):(s=null,E('"received"')),s!==null?(c=fe(),c!==null?(h=Rs(),h===null&&(h=us()),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.received=I}(g,s[2])),s===null&&(l=g),s}function Ol(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6).toLowerCase()==="branch"?(s=t.substr(l,6),l+=6):(s=null,E('"branch"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.branch=I}(g,s[2])),s===null&&(l=g),s}function Dl(){var s,c,h,g,S;return g=l,t.substr(l,5).toLowerCase()==="rport"?(s=t.substr(l,5),l+=5):(s=null,E('"rport"')),s!==null?(S=l,c=fe(),c!==null?(h=Nl(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function Nl(){var s,c,h,g,S,R,I;return R=l,I=l,s=w(),s=s!==null?s:"",s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?s=[s,c,h,g,S]:(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(D,J){T.rport=parseInt(J.join(""))}(R,s)),s===null&&(l=R),s}function Nn(){var s,c,h,g,S,R;return R=l,s=Tr(),s!==null?(c=be(),c!==null?(h=P(),h!==null?(g=be(),g!==null?(S=Er(),S!==null?s=[s,c,h,g,S]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s}function Tr(){var s,c;return c=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"SIP"')),s===null&&(s=P()),s!==null&&(s=function(h,g){T.protocol=g}(c,s)),s===null&&(l=c),s}function Er(){var s,c;return c=l,t.substr(l,3).toLowerCase()==="udp"?(s=t.substr(l,3),l+=3):(s=null,E('"UDP"')),s===null&&(t.substr(l,3).toLowerCase()==="tcp"?(s=t.substr(l,3),l+=3):(s=null,E('"TCP"')),s===null&&(t.substr(l,3).toLowerCase()==="tls"?(s=t.substr(l,3),l+=3):(s=null,E('"TLS"')),s===null&&(t.substr(l,4).toLowerCase()==="sctp"?(s=t.substr(l,4),l+=4):(s=null,E('"SCTP"')),s===null&&(s=P())))),s!==null&&(s=function(h,g){T.transport=g}(c,s)),s===null&&(l=c),s}function Un(){var s,c,h,g,S;return g=l,s=Ul(),s!==null?(S=l,c=Oe(),c!==null?(h=Cr(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function Ul(){var s,c;return c=l,s=Rs(),s===null&&(s=pt(),s===null&&(s=ht())),s!==null&&(s=function(h){T.host=t.substring(l,h)}(c)),s===null&&(l=c),s}function Cr(){var s,c,h,g,S,R,I;return R=l,I=l,s=w(),s=s!==null?s:"",s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?s=[s,c,h,g,S]:(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(D,J){T.port=parseInt(J.join(""))}(R,s)),s===null&&(l=R),s}function xl(){var s,c,h,g,S;return g=l,S=l,s=w(),s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){return parseInt(I.join(""))}(g,s)),s===null&&(l=g),s}function Pl(){var s;return s=ks(),s}function Wr(){var s,c,h,g,S,R;if(S=l,s=Kr(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=xn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=xn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Kr(){var s,c;return c=l,s=Wt(),s!==null&&(s=function(h,g){T.expires=g}(c,s)),s===null&&(l=c),s}function xn(){var s;return s=Kt(),s===null&&(s=Ze()),s}function Kt(){var s,c,h,g,S;return g=l,S=l,t.substr(l,9).toLowerCase()==="refresher"?(s=t.substr(l,9),l+=9):(s=null,E('"refresher"')),s!==null?(c=fe(),c!==null?(t.substr(l,3).toLowerCase()==="uac"?(h=t.substr(l,3),l+=3):(h=null,E('"uac"')),h===null&&(t.substr(l,3).toLowerCase()==="uas"?(h=t.substr(l,3),l+=3):(h=null,E('"uas"'))),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.refresher=I.toLowerCase()}(g,s[2])),s===null&&(l=g),s}function Yr(){var s,c,h,g;return g=l,s=P(),s!==null?(c=M(),c!==null?(h=Ml(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Ml(){var s,c;for(s=[],c=se(),c===null&&(c=ne(),c===null&&(c=G()));c!==null;)s.push(c),c=se(),c===null&&(c=ne(),c===null&&(c=G()));return s}function ns(){var s,c;for(s=[],c=j();c!==null;)s.push(c),c=j();return s}function zr(){var s,c,h;return h=l,t.substr(l,5)==="uuid:"?(s="uuid:",l+=5):(s=null,E('"uuid:"')),s!==null?(c=kl(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function kl(){var s,c,h,g,S,R,I,D,J,Ne,We;return Ne=l,We=l,s=Sr(),s!==null?(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c!==null?(h=jt(),h!==null?(t.charCodeAt(l)===45?(g="-",l++):(g=null,E('"-"')),g!==null?(S=jt(),S!==null?(t.charCodeAt(l)===45?(R="-",l++):(R=null,E('"-"')),R!==null?(I=jt(),I!==null?(t.charCodeAt(l)===45?(D="-",l++):(D=null,E('"-"')),D!==null?(J=Ll(),J!==null?s=[s,c,h,g,S,R,I,D,J]:(s=null,l=We)):(s=null,l=We)):(s=null,l=We)):(s=null,l=We)):(s=null,l=We)):(s=null,l=We)):(s=null,l=We)):(s=null,l=We)):(s=null,l=We),s!==null&&(s=function(F,Ie){T=t.substring(l+5,F)}(Ne,s[0])),s===null&&(l=Ne),s}function jt(){var s,c,h,g,S;return S=l,s=U(),s!==null?(c=U(),c!==null?(h=U(),h!==null?(g=U(),g!==null?s=[s,c,h,g]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s}function Sr(){var s,c,h;return h=l,s=jt(),s!==null?(c=jt(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function Ll(){var s,c,h,g;return g=l,s=jt(),s!==null?(c=jt(),c!==null?(h=jt(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function $l(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ss()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){try{T=new m(T.uri,T.display_name,T.params)}catch{T=-1}}()),s===null&&(l=S),s}function Jr(){var s,c,h,g,S,R;if(S=l,s=Ar(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=x(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=x(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Ar(){var s,c,h,g,S,R;return g=l,S=l,s=he(),s!==null?(R=l,t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c!==null?(h=he(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T.call_id=t.substring(l,I)}(g)),s===null&&(l=g),s}function x(){var s;return s=Hl(),s===null&&(s=Fl(),s===null&&(s=yr(),s===null&&(s=Ze()))),s}function Hl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6)==="to-tag"?(s="to-tag",l+=6):(s=null,E('"to-tag"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.to_tag=I}(g,s[2])),s===null&&(l=g),s}function Fl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,8)==="from-tag"?(s="from-tag",l+=8):(s=null,E('"from-tag"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.from_tag=I}(g,s[2])),s===null&&(l=g),s}function yr(){var s,c;return c=l,t.substr(l,10)==="early-only"?(s="early-only",l+=10):(s=null,E('"early-only"')),s!==null&&(s=function(h){T.early_only=!0}()),s===null&&(l=c),s}function Hs(s){s.sort();for(var c=null,h=[],g=0;g<s.length;g++)s[g]!==c&&(h.push(s[g]),c=s[g]);return h}function i(){for(var s=1,c=1,h=!1,g=0;g<Math.max(l,A);g++){var S=t.charAt(g);S===`
75
+ `?(h||s++,c=1,h=!1):S==="\r"||S==="\u2028"||S==="\u2029"?(s++,c=1,h=!0):(c++,h=!1)}return{line:s,column:c}}var _=Bn(),m=fo(),T={},y=C[v]();if(y===null||l!==t.length){var r=Math.max(l,A),f=r<t.length?t.charAt(r):null,d=i();return new this.SyntaxError(Hs(b),f,r,d.line,d.column),-1}return T},toSource:function(){return this._source}};n.SyntaxError=function(t,v,C,l,A){function b(E,O){var w,N;switch(E.length){case 0:w="end of input";break;case 1:w=E[0];break;default:w=E.slice(0,E.length-1).join(", ")+" or "+E[E.length-1]}return N=O?u(O):"end of input","Expected "+w+" but "+N+" found."}this.name="SyntaxError",this.expected=t,this.found=v,this.message=b(t,v),this.offset=C,this.line=l,this.column=A},n.SyntaxError.prototype=Error.prototype;const a='INVITE sip:ds881ehp@6ke7klp2hppe.invalid;transport=ws;+sip.ice;reg-id=1;+sip.instance="<urn:uuid:378e5fc1-d7b5-42a9-8bf3-2b796aa0c67e>" SIP/2.0',e="INVITE sip:gsfjq6nt@6itebkeio2hf.invalid;transport=ws SIP/2.0",o=n.parse(a,"Request_Response");console.log("newRes",o),console.log("#############################################");const p=n.parse(e,"Request_Response");return console.log("oldRes",p),tf}var Ho,lf;function Bn(){if(lf)return Ho;lf=1;const u=Fe,n=xt(),a=dn();return Ho=class hh{static parse(o){if(o=a.parse(o,"SIP_URI"),o!==-1)return o}constructor(o,p,t,v,C={},l={}){if(!t)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=o||u.SIP,this._user=p,this._host=t,this._port=v;for(const A in C)Object.prototype.hasOwnProperty.call(C,A)&&this.setParam(A,C[A]);for(const A in l)Object.prototype.hasOwnProperty.call(l,A)&&this.setHeader(A,l[A])}get scheme(){return this._scheme}set scheme(o){this._scheme=o.toLowerCase()}get user(){return this._user}set user(o){this._user=o}get host(){return this._host}set host(o){this._host=o.toLowerCase()}get port(){return this._port}set port(o){this._port=o===0?o:parseInt(o,10)||null}setParam(o,p){o&&(this._parameters[o.toLowerCase()]=typeof p>"u"||p===null?null:p.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 p=this._parameters[o];return delete this._parameters[o],p}}clearParams(){this._parameters={}}setHeader(o,p){this._headers[n.headerize(o)]=Array.isArray(p)?p:[p]}getHeader(o){if(o)return this._headers[n.headerize(o)]}hasHeader(o){if(o)return this._headers.hasOwnProperty(n.headerize(o))&&!0||!1}deleteHeader(o){if(o=n.headerize(o),this._headers.hasOwnProperty(o)){const p=this._headers[o];return delete this._headers[o],p}}clearHeaders(){this._headers={}}clone(){return new hh(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const o=[];let p=`${this._scheme}:`;this._user&&(p+=`${n.escapeUser(this._user)}@`),p+=this._host,(this._port||this._port===0)&&(p+=`:${this._port}`);for(const t in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(p+=`;${t}`,this._parameters[t]!==null&&(p+=`=${this._parameters[t]}`));for(const t in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,t))for(const v of this._headers[t])o.push(`${t}=${v}`);return o.length>0&&(p+=`?${o.join("&")}`),p}toAor(o){let p=`${this._scheme}:`;return this._user&&(p+=`${n.escapeUser(this._user)}@`),p+=this._host,o&&(this._port||this._port===0)&&(p+=`:${this._port}`),p}},Ho}var rf;function xt(){if(rf)return dt;rf=1;const u=Fe,n=Bn(),a=dn();dt.str_utf8_length=t=>unescape(encodeURIComponent(t)).length;const e=dt.isFunction=t=>t!==void 0?Object.prototype.toString.call(t)==="[object Function]":!1;dt.isString=t=>t!==void 0?Object.prototype.toString.call(t)==="[object String]":!1,dt.isDecimal=t=>!isNaN(t)&&parseFloat(t)===parseInt(t,10),dt.isEmpty=t=>t===null||t===""||t===void 0||Array.isArray(t)&&t.length===0||typeof t=="number"&&isNaN(t),dt.hasMethods=function(t,...v){for(const C of v)if(e(t[C]))return!1;return!0};const o=dt.createRandomToken=(t,v=32)=>{let C,l,A="";for(C=0;C<t;C++)l=Math.random()*v|0,A+=l.toString(v);return A};dt.newTag=()=>o(10),dt.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,v=>{const C=Math.random()*16|0;return(v==="x"?C:C&3|8).toString(16)}),dt.hostType=t=>{if(t){if(t=a.parse(t,"host"),t!==-1)return t.host_type}else return};const p=dt.escapeUser=t=>encodeURIComponent(decodeURIComponent(t)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return dt.normalizeTarget=(t,v)=>{if(t){if(t instanceof n)return t;if(typeof t=="string"){const C=t.split("@");let l,A;switch(C.length){case 1:if(!v)return;l=t,A=v;break;case 2:l=C[0],A=C[1];break;default:l=C.slice(0,C.length-1).join("@"),A=C[C.length-1]}l=l.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(l)&&(l=l.replace(/[-.()]/g,"")),t=`${u.SIP}:${p(l)}@${A}`;let b;return(b=n.parse(t))?b:void 0}else return}else return},dt.headerize=t=>{const v={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},C=t.toLowerCase().replace(/_/g,"-").split("-");let l="";const A=C.length;let b;for(b=0;b<A;b++)b!==0&&(l+="-"),l+=C[b].charAt(0).toUpperCase()+C[b].substring(1);return v[l]&&(l=v[l]),l},dt.sipErrorCause=t=>{for(const v in u.SIP_ERROR_CAUSES)if(u.SIP_ERROR_CAUSES[v].indexOf(t)!==-1)return u.causes[v];return u.causes.SIP_FAILURE_CODE},dt.getRandomTestNetIP=()=>{function t(v,C){return Math.floor(Math.random()*(C-v+1)+v)}return`192.0.2.${t(1,254)}`},dt.calculateMD5=t=>{function v(ue,Oe){return ue<<Oe|ue>>>32-Oe}function C(ue,Oe){const Pe=ue&2147483648,Le=Oe&2147483648,ye=ue&1073741824,pe=Oe&1073741824,Ce=(ue&1073741823)+(Oe&1073741823);return ye&pe?Ce^2147483648^Pe^Le:ye|pe?Ce&1073741824?Ce^3221225472^Pe^Le:Ce^1073741824^Pe^Le:Ce^Pe^Le}function l(ue,Oe,Pe){return ue&Oe|~ue&Pe}function A(ue,Oe,Pe){return ue&Pe|Oe&~Pe}function b(ue,Oe,Pe){return ue^Oe^Pe}function E(ue,Oe,Pe){return Oe^(ue|~Pe)}function O(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(l(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function w(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(A(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function N(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(b(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function U(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(E(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function Y(ue){let Oe;const Pe=ue.length,Le=Pe+8,pe=((Le-Le%64)/64+1)*16,Ce=new Array(pe-1);let ke=0,He=0;for(;He<Pe;)Oe=(He-He%4)/4,ke=He%4*8,Ce[Oe]=Ce[Oe]|ue.charCodeAt(He)<<ke,He++;return Oe=(He-He%4)/4,ke=He%4*8,Ce[Oe]=Ce[Oe]|128<<ke,Ce[pe-2]=Pe<<3,Ce[pe-1]=Pe>>>29,Ce}function j(ue){let Oe="",Pe="",Le,ye;for(ye=0;ye<=3;ye++)Le=ue>>>ye*8&255,Pe=`0${Le.toString(16)}`,Oe=Oe+Pe.substr(Pe.length-2,2);return Oe}function _e(ue){let Oe="";for(let Pe=0;Pe<ue.length;Pe++){const Le=ue.charCodeAt(Pe);Le<128?Oe+=String.fromCharCode(Le):Le>127&&Le<2048?(Oe+=String.fromCharCode(Le>>6|192),Oe+=String.fromCharCode(Le&63|128)):(Oe+=String.fromCharCode(Le>>12|224),Oe+=String.fromCharCode(Le>>6&63|128),Oe+=String.fromCharCode(Le&63|128))}return Oe}let k=[],H,de,Ue,B,L,V,G,K,M;const te=7,se=12,$=17,ne=22,ct=5,P=9,Q=14,oe=20,he=4,Re=11,be=16,fe=23,qe=6,xe=10,we=15,st=21;for(t=_e(t),k=Y(t),V=1732584193,G=4023233417,K=2562383102,M=271733878,H=0;H<k.length;H+=16)de=V,Ue=G,B=K,L=M,V=O(V,G,K,M,k[H+0],te,3614090360),M=O(M,V,G,K,k[H+1],se,3905402710),K=O(K,M,V,G,k[H+2],$,606105819),G=O(G,K,M,V,k[H+3],ne,3250441966),V=O(V,G,K,M,k[H+4],te,4118548399),M=O(M,V,G,K,k[H+5],se,1200080426),K=O(K,M,V,G,k[H+6],$,2821735955),G=O(G,K,M,V,k[H+7],ne,4249261313),V=O(V,G,K,M,k[H+8],te,1770035416),M=O(M,V,G,K,k[H+9],se,2336552879),K=O(K,M,V,G,k[H+10],$,4294925233),G=O(G,K,M,V,k[H+11],ne,2304563134),V=O(V,G,K,M,k[H+12],te,1804603682),M=O(M,V,G,K,k[H+13],se,4254626195),K=O(K,M,V,G,k[H+14],$,2792965006),G=O(G,K,M,V,k[H+15],ne,1236535329),V=w(V,G,K,M,k[H+1],ct,4129170786),M=w(M,V,G,K,k[H+6],P,3225465664),K=w(K,M,V,G,k[H+11],Q,643717713),G=w(G,K,M,V,k[H+0],oe,3921069994),V=w(V,G,K,M,k[H+5],ct,3593408605),M=w(M,V,G,K,k[H+10],P,38016083),K=w(K,M,V,G,k[H+15],Q,3634488961),G=w(G,K,M,V,k[H+4],oe,3889429448),V=w(V,G,K,M,k[H+9],ct,568446438),M=w(M,V,G,K,k[H+14],P,3275163606),K=w(K,M,V,G,k[H+3],Q,4107603335),G=w(G,K,M,V,k[H+8],oe,1163531501),V=w(V,G,K,M,k[H+13],ct,2850285829),M=w(M,V,G,K,k[H+2],P,4243563512),K=w(K,M,V,G,k[H+7],Q,1735328473),G=w(G,K,M,V,k[H+12],oe,2368359562),V=N(V,G,K,M,k[H+5],he,4294588738),M=N(M,V,G,K,k[H+8],Re,2272392833),K=N(K,M,V,G,k[H+11],be,1839030562),G=N(G,K,M,V,k[H+14],fe,4259657740),V=N(V,G,K,M,k[H+1],he,2763975236),M=N(M,V,G,K,k[H+4],Re,1272893353),K=N(K,M,V,G,k[H+7],be,4139469664),G=N(G,K,M,V,k[H+10],fe,3200236656),V=N(V,G,K,M,k[H+13],he,681279174),M=N(M,V,G,K,k[H+0],Re,3936430074),K=N(K,M,V,G,k[H+3],be,3572445317),G=N(G,K,M,V,k[H+6],fe,76029189),V=N(V,G,K,M,k[H+9],he,3654602809),M=N(M,V,G,K,k[H+12],Re,3873151461),K=N(K,M,V,G,k[H+15],be,530742520),G=N(G,K,M,V,k[H+2],fe,3299628645),V=U(V,G,K,M,k[H+0],qe,4096336452),M=U(M,V,G,K,k[H+7],xe,1126891415),K=U(K,M,V,G,k[H+14],we,2878612391),G=U(G,K,M,V,k[H+5],st,4237533241),V=U(V,G,K,M,k[H+12],qe,1700485571),M=U(M,V,G,K,k[H+3],xe,2399980690),K=U(K,M,V,G,k[H+10],we,4293915773),G=U(G,K,M,V,k[H+1],st,2240044497),V=U(V,G,K,M,k[H+8],qe,1873313359),M=U(M,V,G,K,k[H+15],xe,4264355552),K=U(K,M,V,G,k[H+6],we,2734768916),G=U(G,K,M,V,k[H+13],st,1309151649),V=U(V,G,K,M,k[H+4],qe,4149444226),M=U(M,V,G,K,k[H+11],xe,3174756917),K=U(K,M,V,G,k[H+2],we,718787259),G=U(G,K,M,V,k[H+9],st,3951481745),V=C(V,de),G=C(G,Ue),K=C(K,B),M=C(M,L);return(j(V)+j(G)+j(K)+j(M)).toLowerCase()},dt.closeMediaStream=t=>{if(t)try{let v;if(t.getTracks){v=t.getTracks();for(const C of v)C.stop()}else{v=t.getAudioTracks();for(const C of v)C.stop();v=t.getVideoTracks();for(const C of v)C.stop()}}catch{(typeof t.stop=="function"||typeof t.stop=="object")&&t.stop()}},dt.cloneArray=t=>t&&t.slice()||[],dt.cloneObject=(t,v={})=>t&&Object.assign({},t)||v,dt}const _h=Jt,jm=Et,Ut=Fe,gt=xt(),af=fo(),Vm=dn(),Fo=new jm("SIPMessage");class ho{constructor(n,a,e,o,p,t){if(!n||!a||!e)return null;o=o||{},this.ua=e,this.headers={},this.method=n,this.ruri=a,this.body=t,this.extraHeaders=gt.cloneArray(p),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),o.route_set?this.setHeader("route",o.route_set):e.configuration.use_preloaded_route&&this.setHeader("route",`<${e.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",Ut.MAX_FORWARDS);const v=o.to_uri||a,C=o.to_tag?{tag:o.to_tag}:null,l=typeof o.to_display_name<"u"?o.to_display_name:null;this.to=new af(v,l,C),this.setHeader("to",this.to.toString());const A=o.from_uri||e.configuration.uri,b={tag:o.from_tag||gt.newTag()};let E;typeof o.from_display_name<"u"?E=o.from_display_name:e.configuration.display_name?E=e.configuration.display_name:E=null,this.from=new af(A,E,b),this.setHeader("from",this.from.toString());const O=o.call_id||e.configuration.jssip_id+gt.createRandomToken(15);this.call_id=O,this.setHeader("call-id",O);const w=o.cseq||Math.floor(Math.random()*1e4);this.cseq=w,this.setHeader("cseq",`${w} ${n}`)}setHeader(n,a){const e=new RegExp(`^\\s*${n}\\s*:`,"i");for(let o=0;o<this.extraHeaders.length;o++)e.test(this.extraHeaders[o])&&this.extraHeaders.splice(o,1);this.headers[gt.headerize(n)]=Array.isArray(a)?a:[a]}getHeader(n){const a=this.headers[gt.headerize(n)];if(a){if(a[0])return a[0]}else{const e=new RegExp(`^\\s*${n}\\s*:`,"i");for(const o of this.extraHeaders)if(e.test(o))return o.substring(o.indexOf(":")+1).trim()}}getHeaders(n){const a=this.headers[gt.headerize(n)],e=[];if(a){for(const o of a)e.push(o);return e}else{const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(const p of this.extraHeaders)o.test(p)&&e.push(p.substring(p.indexOf(":")+1).trim());return e}}hasHeader(n){if(this.headers[gt.headerize(n)])return!0;{const a=new RegExp(`^\\s*${n}\\s*:`,"i");for(const e of this.extraHeaders)if(a.test(e))return!0}return!1}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=_h.parse(this.body||""),this.sdp)}toString(){let n=`${this.method} ${this.ruri} SIP/2.0\r
76
+ `;for(const o in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,o))for(const p of this.headers[o])n+=`${o}: ${p}\r
77
+ `;for(const o of this.extraHeaders)n+=`${o.trim()}\r
78
+ `;const a=[];switch(this.method){case Ut.REGISTER:a.push("path","gruu");break;case Ut.INVITE:this.ua.configuration.session_timers&&a.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&a.push("gruu"),a.push("ice","replaces");break;case Ut.UPDATE:this.ua.configuration.session_timers&&a.push("timer"),a.push("ice");break}a.push("outbound");const e=this.ua.configuration.user_agent||Ut.USER_AGENT;if(n+=`Allow: ${Ut.ALLOWED_METHODS}\r
79
+ `,n+=`Supported: ${a}\r
80
+ `,n+=`User-Agent: ${e}\r
81
+ `,this.body){const o=gt.str_utf8_length(this.body);n+=`Content-Length: ${o}\r
82
82
  \r
83
- `,s+=this.body}else s+=`Content-Length: 0\r
83
+ `,n+=this.body}else n+=`Content-Length: 0\r
84
84
  \r
85
- `;return s}clone(){const s=new Vo(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=rt.cloneArray(this.extraHeaders),s.to=this.to,s.from=this.from,s.call_id=this.call_id,s.cseq=this.cseq,s}}class Mu extends Vo{constructor(s,r,o,a,t){super(St.INVITE,s,r,o,a,t),this.transaction=null}cancel(s){this.transaction.cancel(s)}clone(){const s=new Mu(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=rt.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 u_{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=rt.headerize(s),this.headers[s]?this.headers[s].push(o):this.headers[s]=[o]}getHeader(s){const r=this.headers[rt.headerize(s)];if(r){if(r[0])return r[0].raw}else return}getHeaders(s){const r=this.headers[rt.headerize(s)],o=[];if(!r)return[];for(const a of r)o.push(a.raw);return o}hasHeader(s){return!!this.headers[rt.headerize(s)]}parseHeader(s,r=0){if(s=rt.headerize(s),this.headers[s]){if(r>=this.headers[s].length){Pa.debug(`not so many "${s}" headers present`);return}}else{Pa.debug(`header "${s}" not present`);return}const o=this.headers[s][r],a=o.raw;if(o.parsed)return o.parsed;const t=km.parse(a,s.replace(/-/g,"_"));if(t===-1){this.headers[s].splice(r,1),Pa.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[rt.headerize(s)]=[o]}parseSDP(s){return!s&&this.sdp?this.sdp:(this.sdp=a_.parse(this.body||""),this.sdp)}toString(){return this.data}}class Lm extends u_{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 d=[];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||St.REASON_PHRASE[s]||"",o=rt.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===St.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=${rt.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 St.INVITE:this.ua.configuration.session_timers&&d.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&d.push("gruu"),d.push("ice","replaces");break;case St.UPDATE:this.ua.configuration.session_timers&&d.push("timer"),a&&d.push("ice"),d.push("replaces")}if(d.push("outbound"),this.method===St.OPTIONS?(h+=`Allow: ${St.ALLOWED_METHODS}\r
94
- `,h+=`Accept: ${St.ACCEPTED_BODY_TYPES}\r
95
- `):s===405?h+=`Allow: ${St.ALLOWED_METHODS}\r
96
- `:s===415&&(h+=`Accept: ${St.ACCEPTED_BODY_TYPES}\r
97
- `),h+=`Supported: ${d}\r
98
- `,a){const T=rt.str_utf8_length(a);h+=`Content-Type: application/sdp\r
99
- `,h+=`Content-Length: ${T}\r
85
+ `;return n}clone(){const n=new ho(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(a){n.headers[a]=this.headers[a].slice()},this),n.body=this.body,n.extraHeaders=gt.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n}}class Fu extends ho{constructor(n,a,e,o,p){super(Ut.INVITE,n,a,e,o,p),this.transaction=null}cancel(n){this.transaction.cancel(n)}clone(){const n=new Fu(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(a){n.headers[a]=this.headers[a].slice()},this),n.body=this.body,n.extraHeaders=gt.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n.transaction=this.transaction,n}}class dh{constructor(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}addHeader(n,a){const e={raw:a};n=gt.headerize(n),this.headers[n]?this.headers[n].push(e):this.headers[n]=[e]}getHeader(n){const a=this.headers[gt.headerize(n)];if(a){if(a[0])return a[0].raw}else return}getHeaders(n){const a=this.headers[gt.headerize(n)],e=[];if(!a)return[];for(const o of a)e.push(o.raw);return e}hasHeader(n){return!!this.headers[gt.headerize(n)]}parseHeader(n,a=0){if(n=gt.headerize(n),this.headers[n]){if(a>=this.headers[n].length){Fo.debug(`not so many "${n}" headers present`);return}}else{Fo.debug(`header "${n}" not present`);return}const e=this.headers[n][a],o=e.raw;if(e.parsed)return e.parsed;const p=Vm.parse(o,n.replace(/-/g,"_"));if(p===-1){this.headers[n].splice(a,1),Fo.debug(`error parsing "${n}" header field with value "${o}"`);return}else return e.parsed=p,p}s(n,a){return this.parseHeader(n,a)}setHeader(n,a){const e={raw:a};this.headers[gt.headerize(n)]=[e]}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=_h.parse(this.body||""),this.sdp)}toString(){return this.data}}class Bm extends dh{constructor(n){super(),this.ua=n,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(n,a,e,o,p,t){const v=[];let C=this.getHeader("To");if(n=n||null,a=a||null,!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(a&&typeof a!="string"&&!(a instanceof String))throw new TypeError(`Invalid reason_phrase: ${a}`);a=a||Ut.REASON_PHRASE[n]||"",e=gt.cloneArray(e),this.ua.configuration.extra_headers&&(e=e.concat(this.ua.configuration.extra_headers));let l=`SIP/2.0 ${n} ${a}\r
86
+ `;if(this.method===Ut.INVITE&&n>100&&n<=200){const b=this.getHeaders("record-route");for(const E of b)l+=`Record-Route: ${E}\r
87
+ `}const A=this.getHeaders("via");for(const b of A)l+=`Via: ${b}\r
88
+ `;!this.to_tag&&n>100?C+=`;tag=${gt.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(C+=`;tag=${this.to_tag}`),l+=`To: ${C}\r
89
+ `,l+=`From: ${this.getHeader("From")}\r
90
+ `,l+=`Call-ID: ${this.call_id}\r
91
+ `,l+=`CSeq: ${this.cseq} ${this.method}\r
92
+ `;for(const b of e)l+=`${b.trim()}\r
93
+ `;switch(this.method){case Ut.INVITE:this.ua.configuration.session_timers&&v.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&v.push("gruu"),v.push("ice","replaces");break;case Ut.UPDATE:this.ua.configuration.session_timers&&v.push("timer"),o&&v.push("ice"),v.push("replaces")}if(v.push("outbound"),this.method===Ut.OPTIONS?(l+=`Allow: ${Ut.ALLOWED_METHODS}\r
94
+ `,l+=`Accept: ${Ut.ACCEPTED_BODY_TYPES}\r
95
+ `):n===405?l+=`Allow: ${Ut.ALLOWED_METHODS}\r
96
+ `:n===415&&(l+=`Accept: ${Ut.ACCEPTED_BODY_TYPES}\r
97
+ `),l+=`Supported: ${v}\r
98
+ `,o){const b=gt.str_utf8_length(o);l+=`Content-Type: application/sdp\r
99
+ `,l+=`Content-Length: ${b}\r
100
100
  \r
101
- `,h+=a}else h+=`Content-Length: 0\r
101
+ `,l+=o}else l+=`Content-Length: 0\r
102
102
  \r
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||St.REASON_PHRASE[s]||"";let a=`SIP/2.0 ${s} ${r}\r
104
- `;for(const n of o)a+=`Via: ${n}\r
105
- `;let t=this.getHeader("To");if(!this.to_tag&&s>100?t+=`;tag=${rt.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(t+=`;tag=${this.to_tag}`),a+=`To: ${t}\r
106
- `,a+=`From: ${this.getHeader("From")}\r
107
- `,a+=`Call-ID: ${this.call_id}\r
108
- `,a+=`CSeq: ${this.cseq} ${this.method}\r
109
- `,this.ua.configuration.extra_headers)for(const n of this.ua.configuration.extra_headers)a+=`${n.trim()}\r
110
- `;a+=`Content-Length: 0\r
103
+ `;this.server_transaction.receiveResponse(n,l,p,t)}reply_sl(n=null,a=null){const e=this.getHeaders("via");if(!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(a&&typeof a!="string"&&!(a instanceof String))throw new TypeError(`Invalid reason_phrase: ${a}`);a=a||Ut.REASON_PHRASE[n]||"";let o=`SIP/2.0 ${n} ${a}\r
104
+ `;for(const t of e)o+=`Via: ${t}\r
105
+ `;let p=this.getHeader("To");if(!this.to_tag&&n>100?p+=`;tag=${gt.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(p+=`;tag=${this.to_tag}`),o+=`To: ${p}\r
106
+ `,o+=`From: ${this.getHeader("From")}\r
107
+ `,o+=`Call-ID: ${this.call_id}\r
108
+ `,o+=`CSeq: ${this.cseq} ${this.method}\r
109
+ `,this.ua.configuration.extra_headers)for(const t of this.ua.configuration.extra_headers)o+=`${t.trim()}\r
110
+ `;o+=`Content-Length: 0\r
111
111
  \r
112
- `,this.transport.send(a)}}class $m extends u_{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var It={OutgoingRequest:Vo,InitialOutgoingInviteRequest:Mu,IncomingRequest:Lm,IncomingResponse:$m};const Wl=Xe(It),Hm=at,hs=yt(),Yt=new Hm("DigestAuthentication");var c_=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:Yt.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 Yt.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Yt.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Yt.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Yt.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Yt.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 Yt.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||hs.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=hs.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let d,_;return this._qop==="auth"?(d=`${this._method}:${this._uri}`,_=hs.calculateMD5(d),Yt.debug('authenticate() | using qop=auth [a2:"%s"]',d),this._response=hs.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${_}`)):this._qop==="auth-int"?(d=`${this._method}:${this._uri}:${hs.calculateMD5(o||"")}`,_=hs.calculateMD5(d),Yt.debug('authenticate() | using qop=auth-int [a2:"%s"]',d),this._response=hs.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${_}`)):this._qop===null&&(d=`${this._method}:${this._uri}`,_=hs.calculateMD5(d),Yt.debug('authenticate() | using qop=null [a2:"%s"]',d),this._response=hs.calculateMD5(`${this._ha1}:${this._nonce}:${_}`)),Yt.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 Fm=Xe(c_),ds=500,jm=4e3,sf=5e3;var ku={T1:ds,T2:jm,T4:sf,TIMER_B:64*ds,TIMER_D:0*ds,TIMER_F:64*ds,TIMER_H:64*ds,TIMER_I:0*ds,TIMER_J:0*ds,TIMER_K:0*sf,TIMER_L:64*ds,TIMER_M:64*ds,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Mi=Xe(ku),cl=ft.EventEmitter,fl=at,Yi=De,nf=It,rs=ku,rf=new fl("NonInviteClientTransaction"),Kl=new fl("InviteClientTransaction"),qm=new fl("AckClientTransaction"),lf=new fl("NonInviteServerTransaction"),Yl=new fl("InviteServerTransaction"),he={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"};class Vm extends cl{constructor(s,r,o,a){super(),this.type=he.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 he}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(he.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},rs.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){rf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){rf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(s){const r=s.status_code;if(r<200)switch(this.state){case he.STATUS_TRYING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break}else switch(this.state){case he.STATUS_TRYING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_COMPLETED),clearTimeout(this.F),r===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(s),this.K=setTimeout(()=>{this.timer_K()},rs.TIMER_K);break;case he.STATUS_COMPLETED:break}}}class Bm extends cl{constructor(s,r,o,a){super(),this.type=he.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 he}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(he.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},rs.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==he.STATUS_ACCEPTED&&(Kl.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){Kl.debug(`Timer M expired for transaction ${this.id}`),this.state===he.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){Kl.debug(`Timer B expired for transaction ${this.id}`),this.state===he.STATUS_CALLING&&(this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){Kl.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(s){const r=new nf.OutgoingRequest(Yi.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()},rs.TIMER_D),this.transport.send(r)}cancel(s){if(this.state!==he.STATUS_PROCEEDING)return;const r=new nf.OutgoingRequest(Yi.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 he.STATUS_CALLING:this.stateChanged(he.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break;case he.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(s);break}else if(r>=200&&r<=299)switch(this.state){case he.STATUS_CALLING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},rs.TIMER_M),this.eventHandlers.onReceiveResponse(s);break;case he.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(s);break}else if(r>=300&&r<=699)switch(this.state){case he.STATUS_CALLING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_COMPLETED),this.sendACK(s),this.eventHandlers.onReceiveResponse(s);break;case he.STATUS_COMPLETED:this.sendACK(s);break}}}class Gm extends cl{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 he}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){qm.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class Wm extends cl{constructor(s,r,o){super(),this.type=he.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=he.STATUS_TRYING,s.newTransaction(this)}get C(){return he}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_J(){lf.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,lf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(s,r,o,a){if(s===100)switch(this.state){case he.STATUS_TRYING:this.stateChanged(he.STATUS_PROCEEDING),this.transport.send(r)||this.onTransportError();break;case he.STATUS_PROCEEDING:this.last_response=r,this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(s>=200&&s<=699)switch(this.state){case he.STATUS_TRYING:case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_COMPLETED),this.last_response=r,this.J=setTimeout(()=>{this.timer_J()},rs.TIMER_J),this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break;case he.STATUS_COMPLETED:break}}}class Km extends cl{constructor(s,r,o){super(),this.type=he.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=he.STATUS_PROCEEDING,s.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return he}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_H(){Yl.debug(`Timer H expired for transaction ${this.id}`),this.state===he.STATUS_COMPLETED&&Yl.debug("ACK not received, dialog will be terminated"),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){Yl.debug(`Timer L expired for transaction ${this.id}`),this.state===he.STATUS_ACCEPTED&&(this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,Yl.debug(`transport error occurred, deleting transaction ${this.id}`),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(he.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(s,r,o,a){if(s>=100&&s<=199)switch(this.state){case he.STATUS_PROCEEDING:this.transport.send(r)||this.onTransportError(),this.last_response=r;break}if(s>100&&s<=199&&this.state===he.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},rs.PROVISIONAL_RESPONSE_INTERVAL));else if(s>=200&&s<=299)switch(this.state){case he.STATUS_PROCEEDING:this.stateChanged(he.STATUS_ACCEPTED),this.last_response=r,this.L=setTimeout(()=>{this.timer_L()},rs.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case he.STATUS_ACCEPTED:this.transport.send(r)?o&&o():(this.onTransportError(),a&&a());break}else if(s>=300&&s<=699)switch(this.state){case he.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(r)?(this.stateChanged(he.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},rs.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function Ym({_transactions:c},s){let r;switch(s.method){case Yi.INVITE:if(r=c.ist[s.via_branch],r){switch(r.state){case he.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case he.STATUS_ACCEPTED:break}return!0}break;case Yi.ACK:if(r=c.ist[s.via_branch],r){if(r.state===he.STATUS_ACCEPTED)return!1;if(r.state===he.STATUS_COMPLETED)return r.state=he.STATUS_CONFIRMED,r.I=setTimeout(()=>{r.timer_I()},rs.TIMER_I),!0}else return!1;break;case Yi.CANCEL:return r=c.ist[s.via_branch],r?(s.reply_sl(200),r.state!==he.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(r=c.nist[s.via_branch],r){switch(r.state){case he.STATUS_TRYING:break;case he.STATUS_PROCEEDING:case he.STATUS_COMPLETED:r.transport.send(r.last_response);break}return!0}break}}var pr={C:he,NonInviteClientTransaction:Vm,InviteClientTransaction:Bm,AckClientTransaction:Gm,NonInviteServerTransaction:Wm,InviteServerTransaction:Km,checkTransaction:Ym};const Bt=Xe(pr),Jm=at,of=De,zm=c_,xa=pr,Xm=new Jm("RequestSender"),Ma={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var mr=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 Ma)Object.prototype.hasOwnProperty.call(Ma,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Ma[a]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==of.BYE||this._method!==of.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 xa.InviteClientTransaction(this._ua,this._ua.transport,this._request,s);break;case"ACK":this.clientTransaction=new xa.AckClientTransaction(this._ua,this._ua.transport,this._request,s);break;default:this.clientTransaction=new xa.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){Xm.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 zm({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 Mo=Xe(mr),Qm=at,ka=yt(),mn=De,af=It,uf=mr,ki=new Qm("Registrator"),Jl=10;var Zm=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=ka.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){ki.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 af.OutgoingRequest(mn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s),o=new uf(this._ua,r,{onRequestTimeout:()=>{this._registrationFailure(null,mn.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,mn.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")){ki.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){ki.debug("no Contact header pointing to us, response ignored");break}let d=n.getParam("expires");!d&&a.hasHeader("expires")&&(d=a.getHeader("expires")),d||(d=this._expires),d=Number(d),d<Jl&&(d=Jl);const _=d>64?d*1e3/2+Math.floor((d/2-32)*1e3*Math.random()):d*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<Jl&&(this._expires=Jl),this.register()):(ki.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,mn.causes.SIP_FAILURE_CODE));break}default:{const t=ka.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(s={}){if(!this._registered){ki.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 af.OutgoingRequest(mn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r);new uf(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,mn.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,mn.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=ka.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 eg 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 tg extends Error{constructor(s){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=s,this.message=`Invalid status: ${s}`}}class sg extends Error{constructor(s){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=s}}class ng extends Error{constructor(s){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=s}}var Ss={ConfigurationError:eg,InvalidStateError:tg,NotSupportedError:sg,NotReadyError:ng};const Fs=Xe(Ss),La=De,zl=pr,rg=mr,$a={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var f_=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 $a)Object.prototype.hasOwnProperty.call($a,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=$a[a]))}get request(){return this._request}send(){const s=new rg(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===La.INVITE||this._request.method===La.UPDATE&&this._request.body)&&s.clientTransaction.state!==zl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const r=()=>{(s.clientTransaction.state===zl.C.STATUS_ACCEPTED||s.clientTransaction.state===zl.C.STATUS_COMPLETED||s.clientTransaction.state===zl.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===La.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 ig=Xe(f_),lg=at,cf=It,ks=De,Li=pr,og=f_,Ha=yt(),Fa=new lg("Dialog"),Ls={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var __=class{static get C(){return Ls}constructor(s,r,o,a=Ls.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 cf.IncomingResponse&&(a=r.status_code<200?Ls.STATUS_EARLY:Ls.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),Fa.debug(`new ${o} dialog created with status ${this._state===Ls.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===Ls.STATUS_TERMINATED}update(s,r){this._state=Ls.STATUS_CONFIRMED,Fa.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){Fa.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Ls.STATUS_TERMINATED}sendRequest(s,r={}){const o=Ha.cloneArray(r.extraHeaders),a=Ha.cloneObject(r.eventHandlers),t=r.body||null,n=this._createRequest(s,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new og(this,n,a).send(),n}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===ks.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===ks.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,r,o){r=Ha.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===ks.CANCEL||s===ks.ACK?this._local_seqnum:this._local_seqnum+=1;return new cf.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===ks.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===ks.INVITE||s.method===ks.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===Li.C.STATUS_ACCEPTED||s.server_transaction.state===Li.C.STATUS_COMPLETED||s.server_transaction.state===Li.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===Li.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===ks.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Li.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}};const Xl=Xe(__);var Lu={exports:{}};const ag=ft.EventEmitter,ug=at,cg=De,fg=Ss,ff=yt(),_g=new ug("RTCSession:DTMF"),h_={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Lu.exports=class extends ag{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 fg.InvalidStateError(this._session.status);const o=ff.cloneArray(r.extraHeaders);if(this.eventHandlers=ff.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(cg.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=h_.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:s}):_g.debug("invalid INFO DTMF received, discarded")}};Lu.exports.C=h_;var d_=Lu.exports;const hg=Xe(d_),dg=ft.EventEmitter,pg=De,mg=Ss,gg=yt();var p_=class extends dg{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 mg.InvalidStateError(this._session.status);this._contentType=s,this._body=r;const a=gg.cloneArray(o.extraHeaders);a.push(`Content-Type: ${s}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(pg.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 Tu=Xe(p_),Tg=at,_f=De,vg=new Tg("RTCSession:ReferNotifier"),ja={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var m_=class{constructor(s,r,o){this._session=s,this._id=r,this._expires=o||ja.expires,this._active=!0,this.notify(100)}notify(s,r){if(vg.debug("notify()"),this._active===!1)return;r=r||_f.REASON_PHRASE[s]||"";let o;s>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(_f.NOTIFY,{extraHeaders:[`Event: ${ja.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${ja.body_type}`],body:`SIP/2.0 ${s} ${r}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const Eg=Xe(m_),Sg=ft.EventEmitter,yg=at,$i=De,Ag=ls(),hf=yt(),gn=new yg("RTCSession:ReferSubscriber");var g_=class extends Sg{constructor(s){super(),this._id=null,this._session=s}get id(){return this._id}sendRefer(s,r={}){gn.debug("sendRefer()");const o=hf.cloneArray(r.extraHeaders),a=hf.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 d=this._session.sendRequest($i.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:_=>{this._requestSucceeded(_)},onErrorResponse:_=>{this._requestFailed(_,$i.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,$i.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,$i.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,$i.causes.DIALOG_ERROR)}}});this._id=d.cseq}receiveNotify(s){if(gn.debug("receiveNotify()"),!s.body)return;const r=Ag.parse(s.body.trim().split(`\r
115
- `,1)[0],"Status_Line");if(r===-1){gn.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){gn.debug("REFER succeeded"),gn.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:s})}_requestFailed(s,r){gn.debug("REFER failed"),gn.debug('emit "requestFailed"'),this.emit("requestFailed",{response:s||null,cause:r})}};const Cg=Xe(g_),Rg=ft.EventEmitter,df=Pt,Ig=at,fe=De,Tn=Ss,pf=pr,Be=yt(),Hi=ku,bg=It,Ql=__,wg=mr,Mt=d_,mf=p_,Og=m_,Dg=g_,gf=Es(),Y=new Ig("RTCSession"),Z={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},Zl=["audio","video"];var T_=class vu extends Rg{static get C(){return Z}constructor(s){Y.debug("new"),super(),this._id=null,this._ua=s,this._status=Z.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:fe.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return Z}get causes(){return fe.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(s){this._data=s}get status(){return this._status}isInProgress(){switch(this._status){case Z.STATUS_NULL:case Z.STATUS_INVITE_SENT:case Z.STATUS_1XX_RECEIVED:case Z.STATUS_INVITE_RECEIVED:case Z.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case Z.STATUS_ANSWERED:case Z.STATUS_WAITING_FOR_ACK:case Z.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case Z.STATUS_CANCELED:case Z.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){Y.debug("connect()");const a=s,t=Be.cloneObject(r.eventHandlers),n=Be.cloneArray(r.extraHeaders),d=Be.cloneObject(r.mediaConstraints,{audio:!0,video:!0}),_=r.mediaStream||null,h=Be.cloneObject(r.pcConfig,{iceServers:[]}),g=r.rtcConstraints||null,T=r.rtcOfferConstraints||null;if(this._rtcOfferConstraints=T,this._rtcAnswerConstraints=r.rtcAnswerConstraints||null,this._data=r.data||this._data,s===void 0)throw new TypeError("Not enough arguments");if(this._status!==Z.STATUS_NULL)throw new Tn.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Tn.NotSupportedError("WebRTC not supported");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&Be.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=fe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=fe.SESSION_EXPIRES);for(const A in t)Object.prototype.hasOwnProperty.call(t,A)&&this.on(A,t[A]);this._from_tag=Be.newTag();const E=r.anonymous||!1,y={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(y.from_display_name="Anonymous",y.from_uri=new gf("sip","anonymous","anonymous.invalid"),n.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),n.push("Privacy: id")):r.fromUserName&&(y.from_uri=new gf("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 bg.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(d,T,_)}init_incoming(s,r){Y.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=Z.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=Be.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=Z.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),this._failed("local",null,fe.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Z.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),this._failed("system",null,fe.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!==Z.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(s={}){Y.debug("answer()");const r=this._request,o=Be.cloneArray(s.extraHeaders),a=Be.cloneObject(s.mediaConstraints),t=s.mediaStream||null,n=Be.cloneObject(s.pcConfig,{iceServers:[]}),d=s.rtcConstraints||null,_=s.rtcAnswerConstraints||null,h=Be.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 Tn.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==Z.STATUS_WAITING_FOR_ANSWER)throw new Tn.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Be.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=fe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=fe.SESSION_EXPIRES),this._status=Z.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,d),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===Z.STATUS_TERMINATED?new Error("terminated"):(r.reply(480),this._failed("local",null,fe.causes.USER_DENIED_MEDIA_ACCESS),Y.warn('emit "getusermediafailed" [error:%o]',I),this.emit("getusermediafailed",I),new Error("getUserMedia() failed"))})}).then(I=>{if(this._status===Z.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=I,I&&I.getTracks().forEach(H=>{this._connection.addTrack(H,I)})}).then(()=>{if(this._late_sdp)return;const I={originator:"remote",type:"offer",sdp:r.body};Y.debug('emit "sdp"'),this.emit("sdp",I);const H=new RTCSessionDescription({type:"offer",sdp:I.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(H)).catch(L=>{throw r.reply(488),this._failed("system",null,fe.causes.WEBRTC_ERROR),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===Z.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===Z.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(r,o),r.reply(200,null,o,I,()=>{this._status=Z.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(r,I),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,fe.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==Z.STATUS_TERMINATED&&Y.warn(I)})}terminate(s={}){Y.debug("terminate()");const r=s.cause||fe.causes.BYE,o=Be.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,d=s.reason_phrase;if(this._status===Z.STATUS_TERMINATED)throw new Tn.InvalidStateError(this._status);switch(this._status){case Z.STATUS_NULL:case Z.STATUS_INVITE_SENT:case Z.STATUS_1XX_RECEIVED:if(Y.debug("canceling session"),n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(d=d||fe.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;text="${d}"`),this._status===Z.STATUS_NULL||this._status===Z.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===Z.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=Z.STATUS_CANCELED,this._failed("local",null,fe.causes.CANCELED);break;case Z.STATUS_WAITING_FOR_ANSWER:case Z.STATUS_ANSWERED:if(Y.debug("rejecting session"),n=n||480,n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._request.reply(n,d,o,a),this._failed("local",null,fe.causes.REJECTED);break;case Z.STATUS_WAITING_FOR_ACK:case Z.STATUS_CONFIRMED:if(Y.debug("terminating session"),d=s.reason_phrase||fe.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${d}"`),this._status===Z.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==pf.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:h})=>{h===fe.ACK&&(this.sendRequest(fe.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===pf.C.STATUS_TERMINATED&&(this.sendRequest(fe.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else this.sendRequest(fe.BYE,{extraHeaders:o,body:a}),this._ended("local",null,r)}}sendDTMF(s,r={}){Y.debug("sendDTMF() | tones: %s",s);let o=0,a=r.duration||null,t=r.interToneGap||null;const n=r.transportType||fe.DTMF_TRANSPORT.INFO;if(s===void 0)throw new TypeError("Not enough arguments");if(this._status!==Z.STATUS_CONFIRMED&&this._status!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_1XX_RECEIVED)throw new Tn.InvalidStateError(this._status);if(n!==fe.DTMF_TRANSPORT.INFO&&n!==fe.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&&!Be.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<Mt.C.MIN_DURATION?(Y.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?(Y.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&&!Be.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<Mt.C.MIN_INTER_TONE_GAP?(Y.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===fe.DTMF_TRANSPORT.RFC2833){const _=this._getDTMFRTPSender();_&&(s=_.toneBuffer+s,_.insertDTMF(s,a,t));return}if(this._tones){this._tones+=s;return}this._tones=s,d.call(this);function d(){let _;if(this._status===Z.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(d.bind(this),_)}}sendInfo(s,r,o={}){if(Y.debug("sendInfo()"),this._status!==Z.STATUS_CONFIRMED&&this._status!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_1XX_RECEIVED)throw new Tn.InvalidStateError(this._status);new mf(this).send(s,r,o)}mute(s={audio:!0,video:!1}){Y.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}){Y.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(Y.debug("hold()"),this._status!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:fe.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(Y.debug("unhold()"),this._status!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:fe.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){Y.debug("renegotiate()");const o=s.rtcOfferConstraints||null;if(this._status!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{r&&r()},failed:()=>{this.terminate({cause:fe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),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){Y.debug("refer()");const o=s;if(this._status!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_CONFIRMED)return!1;if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${o}`);const a=new Dg(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 Y.debug("sendRequest()"),this._dialog.sendRequest(s,r)}receiveRequest(s){if(Y.debug("receiveRequest()"),s.method===fe.CANCEL)(this._status===Z.STATUS_WAITING_FOR_ANSWER||this._status===Z.STATUS_ANSWERED)&&(this._status=Z.STATUS_CANCELED,this._request.reply(487),this._failed("remote",s,fe.causes.CANCELED));else switch(s.method){case fe.ACK:if(this._status!==Z.STATUS_WAITING_FOR_ACK)return;if(this._status=Z.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!s.body){this.terminate({cause:fe.causes.MISSING_SDP,status_code:400});break}const r={originator:"remote",type:"answer",sdp:s.body};Y.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",s)}).catch(a=>{this.terminate({cause:fe.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",s);break;case fe.BYE:this._status===Z.STATUS_CONFIRMED||this._status===Z.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,fe.causes.BYE)):this._status===Z.STATUS_INVITE_RECEIVED||this._status===Z.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,fe.causes.BYE)):s.reply(403,"Wrong Status");break;case fe.INVITE:this._status===Z.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case fe.INFO:if(this._status===Z.STATUS_1XX_RECEIVED||this._status===Z.STATUS_WAITING_FOR_ANSWER||this._status===Z.STATUS_ANSWERED||this._status===Z.STATUS_WAITING_FOR_ACK||this._status===Z.STATUS_CONFIRMED){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 mf(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case fe.UPDATE:this._status===Z.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case fe.REFER:this._status===Z.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case fe.NOTIFY:this._status===Z.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){Y.warn("onTransportError()"),this._status!==Z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:fe.causes.CONNECTION_ERROR,cause:fe.causes.CONNECTION_ERROR})}onRequestTimeout(){Y.warn("onRequestTimeout()"),this._status!==Z.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:fe.causes.REQUEST_TIMEOUT,cause:fe.causes.REQUEST_TIMEOUT})}onDialogError(){Y.warn("onDialogError()"),this._status!==Z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:fe.causes.DIALOG_ERROR,cause:fe.causes.DIALOG_ERROR})}newDTMF(s){Y.debug("newDTMF()"),this.emit("newDTMF",s)}newInfo(s){Y.debug("newInfo()"),this.emit("newInfo",s)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(Y.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(Y.debug("_isReadyToReOffer() | session not established yet"),!1):(Y.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(Y.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(Y.debug("close() | closing local MediaStream"),Be.closeMediaStream(this._localMediaStream)),this._status!==Z.STATUS_TERMINATED){if(this._status=Z.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){Y.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=Hi.T1;function a(){this._status===Z.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],r),o<Hi.T2&&(o=o*2,o>Hi.T2&&(o=Hi.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),o))}this._timers.invite2xxTimer=setTimeout(a.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===Z.STATUS_WAITING_FOR_ACK&&(Y.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(fe.BYE),this._ended("remote",null,fe.causes.NO_ACK))},Hi.TIMER_H)}_createRTCConnection(s,r){this._connection=new RTCPeerConnection(s,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:fe.causes.RTP_TIMEOUT,status_code:408,reason_phrase:fe.causes.RTP_TIMEOUT})}),Y.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(s,r){if(Y.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=>(Y.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(r).catch(a=>(Y.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>o.setLocalDescription(a).catch(t=>(this._rtcReady=!0,Y.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=r&&r.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:s,sdp:o.localDescription.sdp};return Y.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let n=!1,d,_;this._iceReady=!1;const h=()=>{o.removeEventListener("icecandidate",d),o.removeEventListener("icegatheringstatechange",_),n=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:s,sdp:o.localDescription.sdp};Y.debug('emit "sdp"'),this.emit("sdp",g),t(g.sdp)};o.addEventListener("icecandidate",d=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 d=this._earlyDialogs[n];if(o)return d?!0:(d=new Ql(this,s,r,Ql.C.STATUS_EARLY),d.error?(Y.debug(d.error),this._failed("remote",s,fe.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=d,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,d)return d.update(s,r),this._dialog=d,delete this._earlyDialogs[n],!0;const _=new Ql(this,s,r);return _.error?(Y.debug(_.error),this._failed("remote",s,fe.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_receiveReinvite(s){Y.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(d={}){a=!0;const _=d.status_code||403,h=d.reason_phrase||"",g=Be.cloneArray(d.extraHeaders);if(this._status!==Z.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(d=>{n.call(this,d)}).catch(()=>{s.reply(500)});return}if(r!=="application/sdp"){Y.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(d=>{this._status!==Z.STATUS_TERMINATED&&n.call(this,d)}).catch(d=>{Y.warn(d)});function n(d){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),this._late_sdp&&(d=this._mangleOffer(d)),s.reply(200,null,_,d,()=>{this._status=Z.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,d),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(s){Y.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(d={}){a=!0;const _=d.status_code||403,h=d.reason_phrase||"",g=Be.cloneArray(d.extraHeaders);if(this._status!==Z.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"){Y.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(d=>{this._status!==Z.STATUS_TERMINATED&&n.call(this,d)}).catch(d=>{Y.warn(d)});function n(d){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),s.reply(200,null,_,d),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(s){Y.debug("_processInDialogSdpOffer()");const r=s.parseSDP();let o=!1;for(const n of r.media){if(Zl.indexOf(n.type)===-1)continue;const d=n.direction||r.direction||"sendrecv";if(d==="sendonly"||d==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:s.body};Y.debug('emit "sdp"'),this.emit("sdp",a);const t=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===Z.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(n=>{throw s.reply(488),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),this.emit("peerconnection:setremotedescriptionfailed",n),n})}).then(()=>{if(this._status===Z.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===Z.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(n=>{throw s.reply(500),Y.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',n),n})}).catch(n=>{Y.warn("_processInDialogSdpOffer() failed [error: %o]",n)}),this._connectionPromiseQueue}_receiveRefer(s){if(Y.debug("receiveRefer()"),!s.refer_to){Y.debug("no Refer-To header field present in REFER"),s.reply(400);return}if(s.refer_to.uri.scheme!==fe.SIP){Y.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const r=new Og(this,s.cseq);Y.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!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_CONFIRMED)return!1;const d=new vu(this._ua);if(d.on("progress",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),d.on("accepted",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),d.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=Be.cloneArray(n.extraHeaders),n.extraHeaders.push(`Replaces: ${_}`)}d.connect(s.refer_to.uri.toAor(),n,t)}function a(){r.notify(603)}}_receiveNotify(s){switch(Y.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){Y.debug("receiveReplaces()");function r(a){if(this._status!==Z.STATUS_WAITING_FOR_ACK&&this._status!==Z.STATUS_CONFIRMED)return!1;const t=new vu(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(s,a)}function o(){Y.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 wg(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===Z.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,fe.causes.USER_DENIED_MEDIA_ACCESS),Y.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===Z.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,fe.causes.WEBRTC_ERROR),n})}).then(t=>{if(this._is_canceled||this._status===Z.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=Z.STATUS_INVITE_SENT,Y.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==Z.STATUS_TERMINATED&&Y.warn(t)})}_getDTMFRTPSender(){const s=this._connection.getSenders().find(r=>r.track&&r.track.kind==="audio");if(!(s&&s.dtmf)){Y.warn("sendDTMF() | no local audio track to send DTMF with");return}return s.dtmf}_receiveInviteResponse(s){if(Y.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(fe.ACK);return}else{const r=new Ql(this,s,"UAC");if(r.error!==void 0){Y.debug(r.error);return}this.sendRequest(fe.ACK),this.sendRequest(fe.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!==Z.STATUS_INVITE_SENT&&this._status!==Z.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(s.status_code):this._status=Z.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){Y.debug("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=Z.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const r={originator:"remote",type:"answer",sdp:s.body};Y.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",s)).catch(a=>{Y.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=Z.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,fe.causes.MISSING_SDP),this._failed("remote",s,fe.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;const r={originator:"remote",type:"answer",sdp:s.body};Y.debug('emit "sdp"'),this.emit("sdp",r);const o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(a=>this._connection.setLocalDescription(a)).catch(a=>{this._acceptAndTerminate(s,500,a.toString()),this._failed("local",s,fe.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest(fe.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(s,488,"Not Acceptable Here"),this._failed("remote",s,fe.causes.BAD_MEDIA_DESCRIPTION),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const r=Be.sipErrorCause(s.status_code);this._failed("remote",s,r)}}}_sendReinvite(s={}){Y.debug("sendReinvite()");const r=Be.cloneArray(s.extraHeaders),o=Be.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:_};Y.debug('emit "sdp"'),this.emit("sdp",h),this.sendRequest(fe.INVITE,{extraHeaders:r,body:_,eventHandlers:{onSuccessResponse:g=>{n.call(this,g),t=!0},onErrorResponse:g=>{d.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{d()});function n(_){if(this._status===Z.STATUS_TERMINATED||(this.sendRequest(fe.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(_),_.body){if(!_.hasHeader("Content-Type")||_.getHeader("Content-Type").toLowerCase()!=="application/sdp"){d.call(this);return}}else{d.call(this);return}const h={originator:"remote",type:"answer",sdp:_.body};Y.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=>{d.call(this),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',T),this.emit("peerconnection:setremotedescriptionfailed",T)})}function d(_){o.failed&&o.failed(_)}}_sendUpdate(s={}){Y.debug("sendUpdate()");const r=Be.cloneArray(s.extraHeaders),o=Be.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};Y.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(fe.UPDATE,{extraHeaders:r,body:h,eventHandlers:{onSuccessResponse:T=>{d.call(this,T),n=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(fe.UPDATE,{extraHeaders:r,eventHandlers:{onSuccessResponse:h=>{d.call(this,h)},onErrorResponse:h=>{_.call(this,h)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function d(h){if(this._status!==Z.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};Y.debug('emit "sdp"'),this.emit("sdp",g);const T=new RTCSessionDescription({type:"answer",sdp:g.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>{o.succeeded&&o.succeeded(h)}).catch(E=>{_.call(this),Y.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){Y.debug("acceptAndTerminate()");const a=[];r&&(o=o||fe.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest(fe.ACK),this.sendRequest(fe.BYE,{extraHeaders:a})),this._status=Z.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=df.parse(s),this._localHold&&!this._remoteHold){Y.debug("mangleOffer() | me on hold, mangling offer");for(const r of s.media)Zl.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="sendonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="sendonly")}else if(this._localHold&&this._remoteHold){Y.debug("mangleOffer() | both on hold, mangling offer");for(const r of s.media)Zl.indexOf(r.type)!==-1&&(r.direction="inactive")}else if(this._remoteHold){Y.debug("mangleOffer() | remote on hold, mangling offer");for(const r of s.media)Zl.indexOf(r.type)!==-1&&(r.direction?r.direction==="sendrecv"?r.direction="recvonly":r.direction==="recvonly"&&(r.direction="inactive"):r.direction="recvonly")}return df.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>=fe.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>=fe.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!==Z.STATUS_TERMINATED&&this._isReadyToReOffer()&&(Y.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===fe.UPDATE?this._sendUpdate():this._sendReinvite())},s*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==Z.STATUS_TERMINATED&&(Y.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:fe.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},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){Y.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:s,session:this,request:r})}_connecting(s){Y.debug("session connecting"),Y.debug('emit "connecting"'),this.emit("connecting",{request:s})}_progress(s,r){Y.debug("session progress"),Y.debug('emit "progress"'),this.emit("progress",{originator:s,response:r||null})}_accepted(s,r){Y.debug("session accepted"),this._start_time=new Date,Y.debug('emit "accepted"'),this.emit("accepted",{originator:s,response:r||null})}_confirmed(s,r){Y.debug("session confirmed"),this._is_confirmed=!0,Y.debug('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:r||null})}_ended(s,r,o){Y.debug("session ended"),this._end_time=new Date,this._close(),Y.debug('emit "ended"'),this.emit("ended",{originator:s,message:r||null,cause:o})}_failed(s,r,o){Y.debug("session failed"),Y.debug('emit "_failed"'),this.emit("_failed",{originator:s,message:r||null,cause:o}),this._close(),Y.debug('emit "failed"'),this.emit("failed",{originator:s,message:r||null,cause:o})}_onhold(s){Y.debug("session onhold"),this._setLocalMediaStatus(),Y.debug('emit "hold"'),this.emit("hold",{originator:s})}_onunhold(s){Y.debug("session onunhold"),this._setLocalMediaStatus(),Y.debug('emit "unhold"'),this.emit("unhold",{originator:s})}_onmute({audio:s,video:r}){Y.debug("session onmute"),this._setLocalMediaStatus(),Y.debug('emit "muted"'),this.emit("muted",{audio:s,video:r})}_onunmute({audio:s,video:r}){Y.debug("session onunmute"),this._setLocalMediaStatus(),Y.debug('emit "unmuted"'),this.emit("unmuted",{audio:s,video:r})}};const Ng=Xe(T_),Ug=ft.EventEmitter,Pg=at,qa=De,xg=It,Fi=yt(),Mg=mr,Tf=Ss,kg=Es(),eo=new Pg("Message");var Lg=class extends Ug{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=Fi.cloneArray(o.extraHeaders),n=Fi.cloneObject(o.eventHandlers),d=o.contentType||"text/plain",_={};o.fromUserName&&(_.from_uri=new kg("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: ${d}`),this._request=new xg.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=Fi.cloneArray(s.extraHeaders),o=s.body;if(this._direction!=="incoming")throw new Tf.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=Fi.cloneArray(s.extraHeaders),t=s.body;if(this._direction!=="incoming")throw new Tf.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=Fi.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){eo.debug("MESSAGE failed"),this._close(),eo.debug('emit "failed"'),this.emit("failed",{originator:s,response:r||null,cause:o})}_succeeded(s,r){eo.debug("MESSAGE succeeded"),this._close(),eo.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:r})}};const $g=ft.EventEmitter,Hg=at,Va=De,Fg=It,ji=yt(),jg=mr,vf=Ss,to=new Hg("Options");var qg=class extends $g{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=ji.cloneArray(o.extraHeaders),n=ji.cloneObject(o.eventHandlers),d=o.contentType||"application/sdp";for(const h in n)Object.prototype.hasOwnProperty.call(n,h)&&this.on(h,n[h]);t.push(`Content-Type: ${d}`),this._request=new Fg.OutgoingRequest(Va.OPTIONS,s,this._ua,null,t),r&&(this._request.body=r);const _=new jg(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=ji.cloneArray(s.extraHeaders),o=s.body;if(this._direction!=="incoming")throw new vf.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=ji.cloneArray(s.extraHeaders),t=s.body;if(this._direction!=="incoming")throw new vf.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=ji.sipErrorCause(s.status_code);this._failed("remote",s,r);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Va.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Va.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){to.debug("OPTIONS failed"),this._close(),to.debug('emit "failed"'),this.emit("failed",{originator:s,response:r||null,cause:o})}_succeeded(s,r){to.debug("OPTIONS succeeded"),this._close(),to.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:r})}},$u={};const Vg=at,Ba=yt(),Bg=ls(),qi=new Vg("Socket");$u.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return qi.warn("undefined JsSIP.Socket instance"),!1;try{if(!Ba.isString(c.url))throw qi.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!Ba.isString(c.via_transport))throw qi.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Bg.parse(c.sip_uri,"SIP_URI")===-1)throw qi.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(!Ba.isFunction(c[s]))throw qi.warn(`missing or invalid JsSIP.Socket method: ${s}`),new Error(`Missing or invalid JsSIP.Socket method: ${s}`)})}catch{return!1}return!0};const Gg=at,Wg=$u,Ef=De,Ut=new Gg("Transport"),qt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Ef.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Ef.CONNECTION_RECOVERY_MAX_INTERVAL}};var v_=class{constructor(s,r=qt.recovery_options){Ut.debug("new()"),this.status=qt.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){Ut.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:qt.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(Ut.debug("connect()"),this.isConnected()){Ut.debug("Transport is already connected");return}else if(this.isConnecting()){Ut.debug("Transport is connecting");return}this.close_requested=!1,this.status=qt.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(){Ut.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=qt.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(Ut.debug("send()"),!this.isConnected())return Ut.warn("unable to send message, transport is not connected"),!1;const r=s.toString();return Ut.debug(`sending message:
112
+ `,this.transport.send(o)}}class Gm extends dh{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var Ft={OutgoingRequest:ho,InitialOutgoingInviteRequest:Fu,IncomingRequest:Bm,IncomingResponse:Gm};const xr=ot(Ft),Wm=Et,Ln=xt(),js=new Wm("DigestAuthentication");var ph=class{constructor(n){this._credentials=n,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:js.warn('get() | cannot get "%s" parameter',n);return}}authenticate({method:n,ruri:a,body:e},o,p=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 js.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return js.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return js.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return js.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return js.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 js.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=n,this._uri=a,this._cnonce=p||Ln.createRandomToken(12),this._nc+=1;const t=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-t.length)+t,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=Ln.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let v,C;return this._qop==="auth"?(v=`${this._method}:${this._uri}`,C=Ln.calculateMD5(v),js.debug('authenticate() | using qop=auth [a2:"%s"]',v),this._response=Ln.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${C}`)):this._qop==="auth-int"?(v=`${this._method}:${this._uri}:${Ln.calculateMD5(e||"")}`,C=Ln.calculateMD5(v),js.debug('authenticate() | using qop=auth-int [a2:"%s"]',v),this._response=Ln.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${C}`)):this._qop===null&&(v=`${this._method}:${this._uri}`,C=Ln.calculateMD5(v),js.debug('authenticate() | using qop=null [a2:"%s"]',v),this._response=Ln.calculateMD5(`${this._ha1}:${this._nonce}:${C}`)),js.debug("authenticate() | response generated"),!0}toString(){const n=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return n.push(`algorithm=${this._algorithm}`),n.push(`username="${this._credentials.username}"`),n.push(`realm="${this._realm}"`),n.push(`nonce="${this._nonce}"`),n.push(`uri="${this._uri}"`),n.push(`response="${this._response}"`),this._opaque&&n.push(`opaque="${this._opaque}"`),this._qop&&(n.push(`qop=${this._qop}`),n.push(`cnonce="${this._cnonce}"`),n.push(`nc=${this._ncHex}`)),`Digest ${n.join(", ")}`}};const Km=ot(ph),$n=500,Ym=4e3,of=5e3;var qu={T1:$n,T2:Ym,T4:of,TIMER_B:64*$n,TIMER_D:0*$n,TIMER_F:64*$n,TIMER_H:64*$n,TIMER_I:0*$n,TIMER_J:0*$n,TIMER_K:0*of,TIMER_L:64*$n,TIMER_M:64*$n,PROVISIONAL_RESPONSE_INTERVAL:6e4};const yi=ot(qu),ea=At.EventEmitter,ta=Et,Li=Fe,uf=Ft,hn=qu,cf=new ta("NonInviteClientTransaction"),da=new ta("InviteClientTransaction"),zm=new ta("AckClientTransaction"),ff=new ta("NonInviteServerTransaction"),pa=new ta("InviteServerTransaction"),Ee={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 Jm extends ea{constructor(n,a,e,o){super(),this.type=Ee.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=a,this.request=e,this.eventHandlers=o;let p=`SIP/2.0/${a.via_transport}`;p+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",p),this.ua.newTransaction(this)}get C(){return Ee}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(Ee.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},hn.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){cf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){cf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(n){const a=n.status_code;if(a<200)switch(this.state){case Ee.STATUS_TRYING:case Ee.STATUS_PROCEEDING:this.stateChanged(Ee.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}else switch(this.state){case Ee.STATUS_TRYING:case Ee.STATUS_PROCEEDING:this.stateChanged(Ee.STATUS_COMPLETED),clearTimeout(this.F),a===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(n),this.K=setTimeout(()=>{this.timer_K()},hn.TIMER_K);break;case Ee.STATUS_COMPLETED:break}}}class Xm extends ea{constructor(n,a,e,o){super(),this.type=Ee.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=a,this.request=e,this.eventHandlers=o,e.transaction=this;let p=`SIP/2.0/${a.via_transport}`;p+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",p),this.ua.newTransaction(this)}get C(){return Ee}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(Ee.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},hn.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==Ee.STATUS_ACCEPTED&&(da.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){da.debug(`Timer M expired for transaction ${this.id}`),this.state===Ee.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){da.debug(`Timer B expired for transaction ${this.id}`),this.state===Ee.STATUS_CALLING&&(this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){da.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(n){const a=new uf.OutgoingRequest(Li.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});a.setHeader("from",this.request.getHeader("from")),a.setHeader("via",this.request.getHeader("via")),a.setHeader("to",n.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},hn.TIMER_D),this.transport.send(a)}cancel(n){if(this.state!==Ee.STATUS_PROCEEDING)return;const a=new uf.OutgoingRequest(Li.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});a.setHeader("from",this.request.getHeader("from")),a.setHeader("via",this.request.getHeader("via")),a.setHeader("to",this.request.getHeader("to")),n&&a.setHeader("reason",n),this.transport.send(a)}receiveResponse(n){const a=n.status_code;if(a>=100&&a<=199)switch(this.state){case Ee.STATUS_CALLING:this.stateChanged(Ee.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break;case Ee.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(n);break}else if(a>=200&&a<=299)switch(this.state){case Ee.STATUS_CALLING:case Ee.STATUS_PROCEEDING:this.stateChanged(Ee.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},hn.TIMER_M),this.eventHandlers.onReceiveResponse(n);break;case Ee.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(n);break}else if(a>=300&&a<=699)switch(this.state){case Ee.STATUS_CALLING:case Ee.STATUS_PROCEEDING:this.stateChanged(Ee.STATUS_COMPLETED),this.sendACK(n),this.eventHandlers.onReceiveResponse(n);break;case Ee.STATUS_COMPLETED:this.sendACK(n);break}}}class Qm extends ea{constructor(n,a,e,o){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=a,this.request=e,this.eventHandlers=o;let p=`SIP/2.0/${a.via_transport}`;p+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",p)}get C(){return Ee}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){zm.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class Zm extends ea{constructor(n,a,e){super(),this.type=Ee.NON_INVITE_SERVER,this.id=e.via_branch,this.ua=n,this.transport=a,this.request=e,this.last_response="",e.server_transaction=this,this.state=Ee.STATUS_TRYING,n.newTransaction(this)}get C(){return Ee}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_J(){ff.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,ff.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(n,a,e,o){if(n===100)switch(this.state){case Ee.STATUS_TRYING:this.stateChanged(Ee.STATUS_PROCEEDING),this.transport.send(a)||this.onTransportError();break;case Ee.STATUS_PROCEEDING:this.last_response=a,this.transport.send(a)?e&&e():(this.onTransportError(),o&&o());break}else if(n>=200&&n<=699)switch(this.state){case Ee.STATUS_TRYING:case Ee.STATUS_PROCEEDING:this.stateChanged(Ee.STATUS_COMPLETED),this.last_response=a,this.J=setTimeout(()=>{this.timer_J()},hn.TIMER_J),this.transport.send(a)?e&&e():(this.onTransportError(),o&&o());break;case Ee.STATUS_COMPLETED:break}}}class eg extends ea{constructor(n,a,e){super(),this.type=Ee.INVITE_SERVER,this.id=e.via_branch,this.ua=n,this.transport=a,this.request=e,this.last_response="",e.server_transaction=this,this.state=Ee.STATUS_PROCEEDING,n.newTransaction(this),this.resendProvisionalTimer=null,e.reply(100)}get C(){return Ee}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_H(){pa.debug(`Timer H expired for transaction ${this.id}`),this.state===Ee.STATUS_COMPLETED&&pa.debug("ACK not received, dialog will be terminated"),this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){pa.debug(`Timer L expired for transaction ${this.id}`),this.state===Ee.STATUS_ACCEPTED&&(this.stateChanged(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,pa.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(Ee.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(n,a,e,o){if(n>=100&&n<=199)switch(this.state){case Ee.STATUS_PROCEEDING:this.transport.send(a)||this.onTransportError(),this.last_response=a;break}if(n>100&&n<=199&&this.state===Ee.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},hn.PROVISIONAL_RESPONSE_INTERVAL));else if(n>=200&&n<=299)switch(this.state){case Ee.STATUS_PROCEEDING:this.stateChanged(Ee.STATUS_ACCEPTED),this.last_response=a,this.L=setTimeout(()=>{this.timer_L()},hn.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case Ee.STATUS_ACCEPTED:this.transport.send(a)?e&&e():(this.onTransportError(),o&&o());break}else if(n>=300&&n<=699)switch(this.state){case Ee.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(a)?(this.stateChanged(Ee.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},hn.TIMER_H),e&&e()):(this.onTransportError(),o&&o());break}}}function tg({_transactions:u},n){let a;switch(n.method){case Li.INVITE:if(a=u.ist[n.via_branch],a){switch(a.state){case Ee.STATUS_PROCEEDING:a.transport.send(a.last_response);break;case Ee.STATUS_ACCEPTED:break}return!0}break;case Li.ACK:if(a=u.ist[n.via_branch],a){if(a.state===Ee.STATUS_ACCEPTED)return!1;if(a.state===Ee.STATUS_COMPLETED)return a.state=Ee.STATUS_CONFIRMED,a.I=setTimeout(()=>{a.timer_I()},hn.TIMER_I),!0}else return!1;break;case Li.CANCEL:return a=u.ist[n.via_branch],a?(n.reply_sl(200),a.state!==Ee.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:if(a=u.nist[n.via_branch],a){switch(a.state){case Ee.STATUS_TRYING:break;case Ee.STATUS_PROCEEDING:case Ee.STATUS_COMPLETED:a.transport.send(a.last_response);break}return!0}break}}var ui={C:Ee,NonInviteClientTransaction:Jm,InviteClientTransaction:Xm,AckClientTransaction:Qm,NonInviteServerTransaction:Zm,InviteServerTransaction:eg,checkTransaction:tg};const Ss=ot(ui),sg=Et,hf=Fe,ng=ph,qo=ui,lg=new sg("RequestSender"),jo={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var ci=class{constructor(n,a,e){this._ua=n,this._eventHandlers=e,this._method=a.method,this._request=a,this._auth=null,this._challenged=!1,this._staled=!1;for(const o in jo)Object.prototype.hasOwnProperty.call(jo,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=jo[o]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==hf.BYE||this._method!==hf.ACK)&&this._eventHandlers.onTransportError()}send(){const n={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:a=>{this._receiveResponse(a)}};switch(this._method){case"INVITE":this.clientTransaction=new qo.InviteClientTransaction(this._ua,this._ua.transport,this._request,n);break;case"ACK":this.clientTransaction=new qo.AckClientTransaction(this._ua,this._ua.transport,this._request,n);break;default:this.clientTransaction=new qo.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,n)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(n){let a,e;const o=n.status_code;if((o===401||o===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(a=n.parseHeader("www-authenticate"),e="authorization"):(a=n.parseHeader("proxy-authenticate"),e="proxy-authorization"),!a){lg.debug(`${n.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&a.stale===!0){if(this._auth||(this._auth=new ng({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,a)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),a.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(e,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(n)}else this._eventHandlers.onReceiveResponse(n)}};const so=ot(ci),rg=Et,Vo=xt(),wr=Fe,_f=Ft,df=ci,Ri=new rg("Registrator"),ma=10;var ig=class{constructor(n,a){this._reg_id=1,this._ua=n,this._transport=a,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=Vo.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._extraContactParams+=";+sip.ice",this._extraHeaders=[],this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._extraContactParams+=`;reg-id=${this._reg_id}`,this._extraContactParams+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const e=n[a];this._extraContactParams+=`;${a}`,e&&(this._extraContactParams+=`=${e}`)}}register(){if(this._registering){Ri.debug("Register request in progress...");return}const n=this._extraHeaders.slice();n.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),n.push(`Expires: ${this._expires}`);const a=new _f.OutgoingRequest(wr.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n),e=new df(this._ua,a,{onRequestTimeout:()=>{this._registrationFailure(null,wr.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,wr.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:o=>{if(o.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):{if(this._registering=!1,!o.hasHeader("Contact")){Ri.debug("no Contact header in response to REGISTER, response ignored");break}const p=o.headers.Contact.reduce((l,A)=>l.concat(A.parsed),[]);let t=p.find(l=>this._sipInstance===l.getParam("+sip.instance")&&this._reg_id===parseInt(l.getParam("reg-id")));if(t||(t=p.find(l=>l.uri.user===this._ua.contact.uri.user)),!t){Ri.debug("no Contact header pointing to us, response ignored");break}let v=t.getParam("expires");!v&&o.hasHeader("expires")&&(v=o.getHeader("expires")),v||(v=this._expires),v=Number(v),v<ma&&(v=ma);const C=v>64?v*1e3/2+Math.floor((v/2-32)*1e3*Math.random()):v*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},C),t.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=t.getParam("temp-gruu").replace(/"/g,"")),t.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=t.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:o}));break}case/^423$/.test(o.status_code):{o.hasHeader("min-expires")?(this._expires=Number(o.getHeader("min-expires")),this._expires<ma&&(this._expires=ma),this.register()):(Ri.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(o,wr.causes.SIP_FAILURE_CODE));break}default:{const p=Vo.sipErrorCause(o.status_code);this._registrationFailure(o,p)}}}});this._registering=!0,e.send()}unregister(n={}){if(!this._registered){Ri.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const a=this._extraHeaders.slice();n.all?a.push(`Contact: *${this._extraContactParams}`):a.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),a.push("Expires: 0");const e=new _f.OutgoingRequest(wr.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a);new df(this._ua,e,{onRequestTimeout:()=>{this._unregistered(null,wr.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,wr.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:p=>{switch(!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):this._unregistered(p);break;default:{const t=Vo.sipErrorCause(p.status_code);this._unregistered(p,t)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(n,a){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:a}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:a}))}_unregistered(n,a){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:a||null})}};class ag extends Error{constructor(n,a){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=n,this.value=a,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class og extends Error{constructor(n){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=n,this.message=`Invalid status: ${n}`}}class ug extends Error{constructor(n){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=n}}class cg extends Error{constructor(n){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=n}}var Gn={ConfigurationError:ag,InvalidStateError:og,NotSupportedError:ug,NotReadyError:cg};const Kl=ot(Gn),Bo=Fe,ga=ui,fg=ci,Go={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var mh=class{constructor(n,a,e){this._dialog=n,this._ua=n._ua,this._request=a,this._eventHandlers=e,this._reattempt=!1,this._reattemptTimer=null;for(const o in Go)Object.prototype.hasOwnProperty.call(Go,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=Go[o]))}get request(){return this._request}send(){const n=new fg(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:a=>{this._eventHandlers.onAuthenticated(a)},onReceiveResponse:a=>{this._receiveResponse(a)}});if(n.send(),(this._request.method===Bo.INVITE||this._request.method===Bo.UPDATE&&this._request.body)&&n.clientTransaction.state!==ga.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const a=()=>{(n.clientTransaction.state===ga.C.STATUS_ACCEPTED||n.clientTransaction.state===ga.C.STATUS_COMPLETED||n.clientTransaction.state===ga.C.STATUS_TERMINATED)&&(n.clientTransaction.removeListener("stateChanged",a),this._dialog.uac_pending_reply=!1)};n.clientTransaction.on("stateChanged",a)}}_receiveResponse(n){n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===Bo.INVITE&&n.status_code===491?this._reattempt?n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n)}};const hg=ot(mh),_g=Et,pf=Ft,Vl=Fe,bi=ui,dg=mh,Wo=xt(),Ko=new _g("Dialog"),Bl={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var gh=class{static get C(){return Bl}constructor(n,a,e,o=Bl.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!a.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};a instanceof pf.IncomingResponse&&(o=a.status_code<200?Bl.STATUS_EARLY:Bl.STATUS_CONFIRMED);const p=a.parseHeader("contact");e==="UAS"?(this._id={call_id:a.call_id,local_tag:a.to_tag,remote_tag:a.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._remote_seqnum=a.cseq,this._local_uri=a.parseHeader("to").uri,this._remote_uri=a.parseHeader("from").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):e==="UAC"&&(this._id={call_id:a.call_id,local_tag:a.from_tag,remote_tag:a.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._local_seqnum=a.cseq,this._local_uri=a.parseHeader("from").uri,this._remote_uri=a.parseHeader("to").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Ko.debug(`new ${e} dialog created with status ${this._state===Bl.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(n){this._local_seqnum=n}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(n){this._uac_pending_reply=n}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Bl.STATUS_TERMINATED}update(n,a){this._state=Bl.STATUS_CONFIRMED,Ko.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),a==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){Ko.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Bl.STATUS_TERMINATED}sendRequest(n,a={}){const e=Wo.cloneArray(a.extraHeaders),o=Wo.cloneObject(a.eventHandlers),p=a.body||null,t=this._createRequest(n,e,p);return o.onAuthenticated=()=>{this._local_seqnum+=1},new dg(this,t,o).send(),t}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===Vl.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===Vl.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,a,e){a=Wo.cloneArray(a),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const o=n===Vl.CANCEL||n===Vl.ACK?this._local_seqnum:this._local_seqnum+=1;return new pf.OutgoingRequest(n,this._remote_target,this._ua,{cseq:o,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},a,e)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===Vl.ACK){if(this._ack_seqnum===null||n.cseq!==this._ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===Vl.INVITE||n.method===Vl.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const a=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${a}`]),!1}else{this._uas_pending_reply=!0;const a=()=>{(n.server_transaction.state===bi.C.STATUS_ACCEPTED||n.server_transaction.state===bi.C.STATUS_COMPLETED||n.server_transaction.state===bi.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",a),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",a)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===bi.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===Vl.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===bi.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}};const va=ot(gh);var ju={exports:{}};const pg=At.EventEmitter,mg=Et,gg=Fe,vg=Gn,mf=xt(),Tg=new mg("RTCSession:DTMF"),vh={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};ju.exports=class extends pg{constructor(n){super(),this._session=n,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(n,a={}){if(n===void 0)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new vg.InvalidStateError(this._session.status);const e=mf.cloneArray(a.extraHeaders);if(this.eventHandlers=mf.cloneObject(a.eventHandlers),typeof n=="string")n=n.toUpperCase();else if(typeof n=="number")n=n.toString();else throw new TypeError(`Invalid tone: ${n}`);if(n.match(/^[0-9A-DR#*]$/))this._tone=n;else throw new TypeError(`Invalid tone: ${n}`);this._duration=a.duration,e.push("Content-Type: application/dtmf-relay");let o=`Signal=${this._tone}\r
113
+ `;o+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(gg.INFO,{extraHeaders:e,eventHandlers:{onSuccessResponse:p=>{this.emit("succeeded",{originator:"remote",response:p})},onErrorResponse:p=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:p})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:o})}init_incoming(n){const a=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,e=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=n,n.reply(200),n.body){const o=n.body.split(`
114
+ `);o.length>=1&&a.test(o[0])&&(this._tone=o[0].replace(a,"$2")),o.length>=2&&e.test(o[1])&&(this._duration=parseInt(o[1].replace(e,"$2"),10))}this._duration||(this._duration=vh.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:n}):Tg.debug("invalid INFO DTMF received, discarded")}};ju.exports.C=vh;var Th=ju.exports;const Eg=ot(Th),Cg=At.EventEmitter,Sg=Fe,Ag=Gn,yg=xt();var Eh=class extends Cg{constructor(n){super(),this._session=n,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(n,a,e={}){if(this._direction="outgoing",n===void 0)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new Ag.InvalidStateError(this._session.status);this._contentType=n,this._body=a;const o=yg.cloneArray(e.extraHeaders);o.push(`Content-Type: ${n}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(Sg.INFO,{extraHeaders:o,eventHandlers:{onSuccessResponse:p=>{this.emit("succeeded",{originator:"remote",response:p})},onErrorResponse:p=>{this.emit("failed",{originator:"remote",response:p})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:a})}init_incoming(n){this._direction="incoming",this.request=n,n.reply(200),this._contentType=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,this._body=n.body,this._session.newInfo({originator:"remote",info:this,request:n})}};const Ru=ot(Eh),Rg=Et,gf=Fe,bg=new Rg("RTCSession:ReferNotifier"),Yo={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var Ch=class{constructor(n,a,e){this._session=n,this._id=a,this._expires=e||Yo.expires,this._active=!0,this.notify(100)}notify(n,a){if(bg.debug("notify()"),this._active===!1)return;a=a||gf.REASON_PHRASE[n]||"";let e;n>=200?e="terminated;reason=noresource":e=`active;expires=${this._expires}`,this._session.sendRequest(gf.NOTIFY,{extraHeaders:[`Event: ${Yo.event_type};id=${this._id}`,`Subscription-State: ${e}`,`Content-Type: ${Yo.body_type}`],body:`SIP/2.0 ${n} ${a}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const Ig=ot(Ch),wg=At.EventEmitter,Og=Et,Ii=Fe,Dg=dn(),vf=xt(),Or=new Og("RTCSession:ReferSubscriber");var Sh=class extends wg{constructor(n){super(),this._id=null,this._session=n}get id(){return this._id}sendRefer(n,a={}){Or.debug("sendRefer()");const e=vf.cloneArray(a.extraHeaders),o=vf.cloneObject(a.eventHandlers);for(const C in o)Object.prototype.hasOwnProperty.call(o,C)&&this.on(C,o[C]);let p=null;a.replaces&&(p=a.replaces._request.call_id,p+=`;to-tag=${a.replaces._to_tag}`,p+=`;from-tag=${a.replaces._from_tag}`,p=encodeURIComponent(p));const t=`Refer-To: <${n}${p?`?Replaces=${p}`:""}>`;if(e.push(t),!e.some(C=>C.toLowerCase().startsWith("referred-by:"))){const C=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;e.push(C)}e.push(`Contact: ${this._session.contact}`);const v=this._session.sendRequest(Ii.REFER,{extraHeaders:e,eventHandlers:{onSuccessResponse:C=>{this._requestSucceeded(C)},onErrorResponse:C=>{this._requestFailed(C,Ii.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Ii.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Ii.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Ii.causes.DIALOG_ERROR)}}});this._id=v.cseq}receiveNotify(n){if(Or.debug("receiveNotify()"),!n.body)return;const a=Dg.parse(n.body.trim().split(`\r
115
+ `,1)[0],"Status_Line");if(a===-1){Or.debug(`receiveNotify() | error parsing NOTIFY body: "${n.body}"`);return}switch(!0){case/^100$/.test(a.status_code):this.emit("trying",{request:n,status_line:a});break;case/^1[0-9]{2}$/.test(a.status_code):this.emit("progress",{request:n,status_line:a});break;case/^2[0-9]{2}$/.test(a.status_code):this.emit("accepted",{request:n,status_line:a});break;default:this.emit("failed",{request:n,status_line:a});break}}_requestSucceeded(n){Or.debug("REFER succeeded"),Or.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:n})}_requestFailed(n,a){Or.debug("REFER failed"),Or.debug('emit "requestFailed"'),this.emit("requestFailed",{response:n||null,cause:a})}};const Ng=ot(Sh),Ug=At.EventEmitter,Tf=Jt,xg=Et,ve=Fe,Dr=Gn,Ef=ui,lt=xt(),wi=qu,Pg=Ft,Ta=gh,Mg=ci,rs=Th,Cf=Eh,kg=Ch,Lg=Sh,Sf=Bn(),ee=new xg("RTCSession"),ie={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},Ea=["audio","video"];var Ah=class bu extends Ug{static get C(){return ie}constructor(n){ee.debug("new"),super(),this._id=null,this._ua=n,this._status=ie.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:ve.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return ie}get causes(){return ve.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(n){this._data=n}get status(){return this._status}isInProgress(){switch(this._status){case ie.STATUS_NULL:case ie.STATUS_INVITE_SENT:case ie.STATUS_1XX_RECEIVED:case ie.STATUS_INVITE_RECEIVED:case ie.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case ie.STATUS_ANSWERED:case ie.STATUS_WAITING_FOR_ACK:case ie.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case ie.STATUS_CANCELED:case ie.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(n,a={},e){ee.debug("connect()");const o=n,p=lt.cloneObject(a.eventHandlers),t=lt.cloneArray(a.extraHeaders),v=lt.cloneObject(a.mediaConstraints,{audio:!0,video:!0}),C=a.mediaStream||null,l=lt.cloneObject(a.pcConfig,{iceServers:[]}),A=a.rtcConstraints||null,b=a.rtcOfferConstraints||null;if(this._rtcOfferConstraints=b,this._rtcAnswerConstraints=a.rtcAnswerConstraints||null,this._data=a.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==ie.STATUS_NULL)throw new Dr.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Dr.NotSupportedError("WebRTC not supported");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);this._sessionTimers.enabled&&lt.isDecimal(a.sessionTimersExpires)&&(a.sessionTimersExpires>=ve.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=a.sessionTimersExpires:this._sessionTimers.defaultExpires=ve.SESSION_EXPIRES);for(const w in p)Object.prototype.hasOwnProperty.call(p,w)&&this.on(w,p[w]);this._from_tag=lt.newTag();const E=a.anonymous||!1,O={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(O.from_display_name="Anonymous",O.from_uri=new Sf("sip","anonymous","anonymous.invalid"),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),t.push("Privacy: id")):a.fromUserName&&(O.from_uri=new Sf("sip",a.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),a.fromDisplayName&&(O.from_display_name=a.fromDisplayName),t.push(`Contact: ${this._contact}`),t.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&t.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Pg.InitialOutgoingInviteRequest(n,this._ua,O,t),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(l,A),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,e&&e(this),this._newRTCSession("local",this._request),this._sendInitialRequest(v,b,C)}init_incoming(n,a){ee.debug("init_incoming()");let e;const o=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&o!=="application/sdp"){n.reply(415);return}if(this._status=ie.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(e=n.getHeader("expires")*1e3),n.to_tag=lt.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ie.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,ve.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),e&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ie.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,ve.causes.EXPIRES))},e)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,a&&a(this),this._newRTCSession("remote",n),this._status!==ie.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){ee.debug("answer()");const a=this._request,e=lt.cloneArray(n.extraHeaders),o=lt.cloneObject(n.mediaConstraints),p=n.mediaStream||null,t=lt.cloneObject(n.pcConfig,{iceServers:[]}),v=n.rtcConstraints||null,C=n.rtcAnswerConstraints||null,l=lt.cloneObject(n.rtcOfferConstraints);let A,b=!1,E=!1,O=!1,w=!1;if(this._rtcAnswerConstraints=C,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new Dr.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==ie.STATUS_WAITING_FOR_ANSWER)throw new Dr.InvalidStateError(this._status);if(this._sessionTimers.enabled&&lt.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=ve.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=ve.SESSION_EXPIRES),this._status=ie.STATUS_ANSWERED,!this._createDialog(a,"UAS")){a.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),e.unshift(`Contact: ${this._contact}`);const N=a.parseSDP();Array.isArray(N.media)||(N.media=[N.media]);for(const U of N.media)U.type==="audio"&&(b=!0,(!U.direction||U.direction==="sendrecv")&&(O=!0)),U.type==="video"&&(E=!0,(!U.direction||U.direction==="sendrecv")&&(w=!0));if(p&&o.audio===!1){A=p.getAudioTracks();for(const U of A)p.removeTrack(U)}if(p&&o.video===!1){A=p.getVideoTracks();for(const U of A)p.removeTrack(U)}!p&&o.audio===void 0&&(o.audio=O),!p&&o.video===void 0&&(o.video=w),!p&&!b&&!l.offerToReceiveAudio&&(o.audio=!1),!p&&!E&&!l.offerToReceiveVideo&&(o.video=!1),this._createRTCConnection(t,v),Promise.resolve().then(()=>{if(p)return p;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(U=>{throw this._status===ie.STATUS_TERMINATED?new Error("terminated"):(a.reply(480),this._failed("local",null,ve.causes.USER_DENIED_MEDIA_ACCESS),ee.warn('emit "getusermediafailed" [error:%o]',U),this.emit("getusermediafailed",U),new Error("getUserMedia() failed"))})}).then(U=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=U,U&&U.getTracks().forEach(Y=>{this._connection.addTrack(Y,U)})}).then(()=>{if(this._late_sdp)return;const U={originator:"remote",type:"offer",sdp:a.body};ee.debug('emit "sdp"'),this.emit("sdp",U);const Y=new RTCSessionDescription({type:"offer",sdp:U.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(Y)).catch(j=>{throw a.reply(488),this._failed("system",null,ve.causes.WEBRTC_ERROR),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',j),this.emit("peerconnection:setremotedescriptionfailed",j),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(a),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",C).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")})}).then(U=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(a,e),a.reply(200,null,e,U,()=>{this._status=ie.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(a,U),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,ve.causes.CONNECTION_ERROR)})}).catch(U=>{this._status!==ie.STATUS_TERMINATED&&ee.warn(U)})}terminate(n={}){ee.debug("terminate()");const a=n.cause||ve.causes.BYE,e=lt.cloneArray(n.extraHeaders),o=n.body;let p,t=n.status_code,v=n.reason_phrase;if(this._status===ie.STATUS_TERMINATED)throw new Dr.InvalidStateError(this._status);switch(this._status){case ie.STATUS_NULL:case ie.STATUS_INVITE_SENT:case ie.STATUS_1XX_RECEIVED:if(ee.debug("canceling session"),t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);t&&(v=v||ve.REASON_PHRASE[t]||"",p=`SIP ;cause=${t} ;text="${v}"`),this._status===ie.STATUS_NULL||this._status===ie.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=p):this._status===ie.STATUS_1XX_RECEIVED&&this._request.cancel(p),this._status=ie.STATUS_CANCELED,this._failed("local",null,ve.causes.CANCELED);break;case ie.STATUS_WAITING_FOR_ANSWER:case ie.STATUS_ANSWERED:if(ee.debug("rejecting session"),t=t||480,t<300||t>=700)throw new TypeError(`Invalid status_code: ${t}`);this._request.reply(t,v,e,o),this._failed("local",null,ve.causes.REJECTED);break;case ie.STATUS_WAITING_FOR_ACK:case ie.STATUS_CONFIRMED:if(ee.debug("terminating session"),v=n.reason_phrase||ve.REASON_PHRASE[t]||"",t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);if(t&&e.push(`Reason: SIP ;cause=${t}; text="${v}"`),this._status===ie.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ef.C.STATUS_TERMINATED){const C=this._dialog;this.receiveRequest=({method:l})=>{l===ve.ACK&&(this.sendRequest(ve.BYE,{extraHeaders:e,body:o}),C.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Ef.C.STATUS_TERMINATED&&(this.sendRequest(ve.BYE,{extraHeaders:e,body:o}),C.terminate())}),this._ended("local",null,a),this._dialog=C,this._ua.newDialog(C)}else this.sendRequest(ve.BYE,{extraHeaders:e,body:o}),this._ended("local",null,a)}}sendDTMF(n,a={}){ee.debug("sendDTMF() | tones: %s",n);let e=0,o=a.duration||null,p=a.interToneGap||null;const t=a.transportType||ve.DTMF_TRANSPORT.INFO;if(n===void 0)throw new TypeError("Not enough arguments");if(this._status!==ie.STATUS_CONFIRMED&&this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_1XX_RECEIVED)throw new Dr.InvalidStateError(this._status);if(t!==ve.DTMF_TRANSPORT.INFO&&t!==ve.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${t}`);if(typeof n=="number"&&(n=n.toString()),!n||typeof n!="string"||!n.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${n}`);if(o&&!lt.isDecimal(o))throw new TypeError(`Invalid tone duration: ${o}`);if(o?o<rs.C.MIN_DURATION?(ee.debug(`"duration" value is lower than the minimum allowed, setting it to ${rs.C.MIN_DURATION} milliseconds`),o=rs.C.MIN_DURATION):o>rs.C.MAX_DURATION?(ee.debug(`"duration" value is greater than the maximum allowed, setting it to ${rs.C.MAX_DURATION} milliseconds`),o=rs.C.MAX_DURATION):o=Math.abs(o):o=rs.C.DEFAULT_DURATION,a.duration=o,p&&!lt.isDecimal(p))throw new TypeError(`Invalid interToneGap: ${p}`);if(p?p<rs.C.MIN_INTER_TONE_GAP?(ee.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${rs.C.MIN_INTER_TONE_GAP} milliseconds`),p=rs.C.MIN_INTER_TONE_GAP):p=Math.abs(p):p=rs.C.DEFAULT_INTER_TONE_GAP,t===ve.DTMF_TRANSPORT.RFC2833){const C=this._getDTMFRTPSender();C&&(n=C.toneBuffer+n,C.insertDTMF(n,o,p));return}if(this._tones){this._tones+=n;return}this._tones=n,v.call(this);function v(){let C;if(this._status===ie.STATUS_TERMINATED||!this._tones||e>=this._tones.length){this._tones=null;return}const l=this._tones[e];if(e+=1,l===",")C=2e3;else{const A=new rs(this);a.eventHandlers={onFailed:()=>{this._tones=null}},A.send(l,a),C=o+p}setTimeout(v.bind(this),C)}}sendInfo(n,a,e={}){if(ee.debug("sendInfo()"),this._status!==ie.STATUS_CONFIRMED&&this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_1XX_RECEIVED)throw new Dr.InvalidStateError(this._status);new Cf(this).send(n,a,e)}mute(n={audio:!0,video:!1}){ee.debug("mute()");let a=!1,e=!1;this._audioMuted===!1&&n.audio&&(a=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(e=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(a===!0||e===!0)&&this._onmute({audio:a,video:e})}unmute(n={audio:!0,video:!0}){ee.debug("unmute()");let a=!1,e=!1;this._audioMuted===!0&&n.audio&&(a=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(e=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(a===!0||e===!0)&&this._onunmute({audio:a,video:e})}hold(n={},a){if(ee.debug("hold()"),this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:ve.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}unhold(n={},a){if(ee.debug("unhold()"),this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:ve.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},a){ee.debug("renegotiate()");const e=n.rtcOfferConstraints||null;if(this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const o={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:ve.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}),!0}refer(n,a){ee.debug("refer()");const e=n;if(this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${e}`);const o=new Lg(this);o.sendRefer(n,a);const p=o.id;return this._referSubscribers[p]=o,o.on("requestFailed",()=>{delete this._referSubscribers[p]}),o.on("accepted",()=>{delete this._referSubscribers[p]}),o.on("failed",()=>{delete this._referSubscribers[p]}),o}sendRequest(n,a){return ee.debug("sendRequest()"),this._dialog.sendRequest(n,a)}receiveRequest(n){if(ee.debug("receiveRequest()"),n.method===ve.CANCEL)(this._status===ie.STATUS_WAITING_FOR_ANSWER||this._status===ie.STATUS_ANSWERED)&&(this._status=ie.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,ve.causes.CANCELED));else switch(n.method){case ve.ACK:if(this._status!==ie.STATUS_WAITING_FOR_ACK)return;if(this._status=ie.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:ve.causes.MISSING_SDP,status_code:400});break}const a={originator:"remote",type:"answer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(o=>{this.terminate({cause:ve.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})}else this._is_confirmed||this._confirmed("remote",n);break;case ve.BYE:this._status===ie.STATUS_CONFIRMED||this._status===ie.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,ve.causes.BYE)):this._status===ie.STATUS_INVITE_RECEIVED||this._status===ie.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,ve.causes.BYE)):n.reply(403,"Wrong Status");break;case ve.INVITE:this._status===ie.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case ve.INFO:if(this._status===ie.STATUS_1XX_RECEIVED||this._status===ie.STATUS_WAITING_FOR_ANSWER||this._status===ie.STATUS_ANSWERED||this._status===ie.STATUS_WAITING_FOR_ACK||this._status===ie.STATUS_CONFIRMED){const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;a&&a.match(/^application\/dtmf-relay/i)?new rs(this).init_incoming(n):a!==void 0?new Cf(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break;case ve.UPDATE:this._status===ie.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case ve.REFER:this._status===ie.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case ve.NOTIFY:this._status===ie.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){ee.warn("onTransportError()"),this._status!==ie.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ve.causes.CONNECTION_ERROR,cause:ve.causes.CONNECTION_ERROR})}onRequestTimeout(){ee.warn("onRequestTimeout()"),this._status!==ie.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ve.causes.REQUEST_TIMEOUT,cause:ve.causes.REQUEST_TIMEOUT})}onDialogError(){ee.warn("onDialogError()"),this._status!==ie.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ve.causes.DIALOG_ERROR,cause:ve.causes.DIALOG_ERROR})}newDTMF(n){ee.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){ee.debug("newInfo()"),this.emit("newInfo",n)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(ee.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(ee.debug("_isReadyToReOffer() | session not established yet"),!1):(ee.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(ee.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(ee.debug("close() | closing local MediaStream"),lt.closeMediaStream(this._localMediaStream)),this._status!==ie.STATUS_TERMINATED){if(this._status=ie.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){ee.warn("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(n,a){let e=wi.T1;function o(){this._status===ie.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],a),e<wi.T2&&(e=e*2,e>wi.T2&&(e=wi.T2)),this._timers.invite2xxTimer=setTimeout(o.bind(this),e))}this._timers.invite2xxTimer=setTimeout(o.bind(this),e)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===ie.STATUS_WAITING_FOR_ACK&&(ee.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(ve.BYE),this._ended("remote",null,ve.causes.NO_ACK))},wi.TIMER_H)}_createRTCConnection(n,a){this._connection=new RTCPeerConnection(n,a),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:ve.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ve.causes.RTP_TIMEOUT})}),ee.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,a){if(ee.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const e=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?e.createOffer(a).catch(o=>(ee.warn('emit "peerconnection:createofferfailed" [error:%o]',o),this.emit("peerconnection:createofferfailed",o),Promise.reject(o))):e.createAnswer(a).catch(o=>(ee.warn('emit "peerconnection:createanswerfailed" [error:%o]',o),this.emit("peerconnection:createanswerfailed",o),Promise.reject(o)))).then(o=>e.setLocalDescription(o).catch(p=>(this._rtcReady=!0,ee.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',p),this.emit("peerconnection:setlocaldescriptionfailed",p),Promise.reject(p)))).then(()=>{const o=a&&a.iceRestart;if(e.iceGatheringState==="complete"&&!o||e.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const p={originator:"local",type:n,sdp:e.localDescription.sdp};return ee.debug('emit "sdp"'),this.emit("sdp",p),Promise.resolve(p.sdp)}return new Promise(p=>{let t=!1,v,C;this._iceReady=!1;const l=()=>{e.removeEventListener("icecandidate",v),e.removeEventListener("icegatheringstatechange",C),t=!0,this._rtcReady=!0,this._iceReady=!0;const A={originator:"local",type:n,sdp:e.localDescription.sdp};ee.debug('emit "sdp"'),this.emit("sdp",A),p(A.sdp)};e.addEventListener("icecandidate",v=A=>{const b=A.candidate;b?this.emit("icecandidate",{candidate:b,ready:l}):t||l()}),e.addEventListener("icegatheringstatechange",C=()=>{e.iceGatheringState==="complete"&&!t&&l()})})})}_createDialog(n,a,e){const o=a==="UAS"?n.to_tag:n.from_tag,p=a==="UAS"?n.from_tag:n.to_tag,t=n.call_id+o+p;let v=this._earlyDialogs[t];if(e)return v?!0:(v=new Ta(this,n,a,Ta.C.STATUS_EARLY),v.error?(ee.debug(v.error),this._failed("remote",n,ve.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[t]=v,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,v)return v.update(n,a),this._dialog=v,delete this._earlyDialogs[t],!0;const C=new Ta(this,n,a);return C.error?(ee.debug(C.error),this._failed("remote",n,ve.causes.INTERNAL_ERROR),!1):(this._dialog=C,!0)}}_receiveReinvite(n){ee.debug("receiveReinvite()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=lt.cloneArray(v.extraHeaders);if(this._status!==ie.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("reinvite",e),o)return;if(this._late_sdp=!1,!n.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(v=>{t.call(this,v)}).catch(()=>{n.reply(500)});return}if(a!=="application/sdp"){ee.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ie.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{ee.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),this._late_sdp&&(v=this._mangleOffer(v)),n.reply(200,null,C,v,()=>{this._status=ie.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,v),this._setACKTimer()}),typeof e.callback=="function"&&e.callback()}}_receiveUpdate(n){ee.debug("receiveUpdate()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=lt.cloneArray(v.extraHeaders);if(this._status!==ie.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("update",e),o)return;if(!n.body){t.call(this,null);return}if(a!=="application/sdp"){ee.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ie.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{ee.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),n.reply(200,null,C,v),typeof e.callback=="function"&&e.callback()}}_processInDialogSdpOffer(n){ee.debug("_processInDialogSdpOffer()");const a=n.parseSDP();let e=!1;for(const t of a.media){if(Ea.indexOf(t.type)===-1)continue;const v=t.direction||a.direction||"sendrecv";if(v==="sendonly"||v==="inactive")e=!0;else{e=!1;break}}const o={originator:"remote",type:"offer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",o);const p=new RTCSessionDescription({type:"offer",sdp:o.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(p).catch(t=>{throw n.reply(488),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),this.emit("peerconnection:setremotedescriptionfailed",t),t})}).then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&e===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&e===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(t=>{throw n.reply(500),ee.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t})}).catch(t=>{ee.warn("_processInDialogSdpOffer() failed [error: %o]",t)}),this._connectionPromiseQueue}_receiveRefer(n){if(ee.debug("receiveRefer()"),!n.refer_to){ee.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==ve.SIP){ee.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const a=new kg(this,n.cseq);ee.debug('emit "refer"'),this.emit("refer",{request:n,accept:(p,t)=>{e.call(this,p,t)},reject:()=>{o.call(this)}});function e(p,t={}){if(p=typeof p=="function"?p:null,this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED)return!1;const v=new bu(this._ua);if(v.on("progress",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("accepted",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("_failed",({message:C,cause:l})=>{C?a.notify(C.status_code,C.reason_phrase):a.notify(487,l)}),n.refer_to.uri.hasHeader("replaces")){const C=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));t.extraHeaders=lt.cloneArray(t.extraHeaders),t.extraHeaders.push(`Replaces: ${C}`)}v.connect(n.refer_to.uri.toAor(),t,p)}function o(){a.notify(603)}}_receiveNotify(n){switch(ee.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let a,e;if(n.event.params&&n.event.params.id)a=n.event.params.id,e=this._referSubscribers[a];else if(Object.keys(this._referSubscribers).length===1)e=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!e){n.reply(481,"Subscription does not exist");return}e.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){ee.debug("receiveReplaces()");function a(o){if(this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED)return!1;const p=new bu(this._ua);p.on("confirmed",()=>{this.terminate()}),p.init_incoming(n,o)}function e(){ee.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:o=>{a.call(this,o)},reject:()=>{e.call(this)}})}_sendInitialRequest(n,a,e){const o=new Mg(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:p=>{this._request=p},onReceiveResponse:p=>{this._receiveInviteResponse(p)}});Promise.resolve().then(()=>{if(e)return e;if(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(p=>{throw this._status===ie.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,ve.causes.USER_DENIED_MEDIA_ACCESS),ee.warn('emit "getusermediafailed" [error:%o]',p),this.emit("getusermediafailed",p),p)})}).then(p=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=p,p&&p.getTracks().forEach(t=>{this._connection.addTrack(t,p)}),this._connecting(this._request),this._createLocalDescription("offer",a).catch(t=>{throw this._failed("local",null,ve.causes.WEBRTC_ERROR),t})}).then(p=>{if(this._is_canceled||this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._request.body=p,this._status=ie.STATUS_INVITE_SENT,ee.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),o.send()}).catch(p=>{this._status!==ie.STATUS_TERMINATED&&ee.warn(p)})}_getDTMFRTPSender(){const n=this._connection.getSenders().find(a=>a.track&&a.track.kind==="audio");if(!(n&&n.dtmf)){ee.warn("sendDTMF() | no local audio track to send DTMF with");return}return n.dtmf}_receiveInviteResponse(n){if(ee.debug("receiveInviteResponse()"),this._dialog&&n.status_code>=200&&n.status_code<=299)if(this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.sendRequest(ve.ACK);return}else{const a=new Ta(this,n,"UAC");if(a.error!==void 0){ee.debug(a.error);return}this.sendRequest(ve.ACK),this.sendRequest(ve.BYE);return}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==ie.STATUS_INVITE_SENT&&this._status!==ie.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):this._status=ie.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){ee.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=ie.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const a={originator:"remote",type:"answer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>this._progress("remote",n)).catch(o=>{ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=ie.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,ve.causes.MISSING_SDP),this._failed("remote",n,ve.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const a={originator:"remote",type:"answer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(o=>this._connection.setLocalDescription(o)).catch(o=>{this._acceptAndTerminate(n,500,o.toString()),this._failed("local",n,ve.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(e).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(ve.ACK),this._confirmed("local",null)}).catch(o=>{this._acceptAndTerminate(n,488,"Not Acceptable Here"),this._failed("remote",n,ve.causes.BAD_MEDIA_DESCRIPTION),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})});break}default:{const a=lt.sipErrorCause(n.status_code);this._failed("remote",n,a)}}}_sendReinvite(n={}){ee.debug("sendReinvite()");const a=lt.cloneArray(n.extraHeaders),e=lt.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let p=!1;a.push(`Contact: ${this._contact}`),a.push("Content-Type: application/sdp"),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(C=>{C=this._mangleOffer(C);const l={originator:"local",type:"offer",sdp:C};ee.debug('emit "sdp"'),this.emit("sdp",l),this.sendRequest(ve.INVITE,{extraHeaders:a,body:C,eventHandlers:{onSuccessResponse:A=>{t.call(this,A),p=!0},onErrorResponse:A=>{v.call(this,A)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function t(C){if(this._status===ie.STATUS_TERMINATED||(this.sendRequest(ve.ACK),p))return;if(this._handleSessionTimersInIncomingResponse(C),C.body){if(!C.hasHeader("Content-Type")||C.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const l={originator:"remote",type:"answer",sdp:C.body};ee.debug('emit "sdp"'),this.emit("sdp",l);const A=new RTCSessionDescription({type:"answer",sdp:l.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(A)).then(()=>{e.succeeded&&e.succeeded(C)}).catch(b=>{v.call(this),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',b),this.emit("peerconnection:setremotedescriptionfailed",b)})}function v(C){e.failed&&e.failed(C)}}_sendUpdate(n={}){ee.debug("sendUpdate()");const a=lt.cloneArray(n.extraHeaders),e=lt.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null,p=n.sdpOffer||!1;let t=!1;a.push(`Contact: ${this._contact}`),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),p?(a.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(l=>{l=this._mangleOffer(l);const A={originator:"local",type:"offer",sdp:l};ee.debug('emit "sdp"'),this.emit("sdp",A),this.sendRequest(ve.UPDATE,{extraHeaders:a,body:l,eventHandlers:{onSuccessResponse:b=>{v.call(this,b),t=!0},onErrorResponse:b=>{C.call(this,b)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{C.call(this)})):this.sendRequest(ve.UPDATE,{extraHeaders:a,eventHandlers:{onSuccessResponse:l=>{v.call(this,l)},onErrorResponse:l=>{C.call(this,l)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(l){if(this._status!==ie.STATUS_TERMINATED&&!t)if(this._handleSessionTimersInIncomingResponse(l),p){if(l.body){if(!l.hasHeader("Content-Type")||l.getHeader("Content-Type").toLowerCase()!=="application/sdp"){C.call(this);return}}else{C.call(this);return}const A={originator:"remote",type:"answer",sdp:l.body};ee.debug('emit "sdp"'),this.emit("sdp",A);const b=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(b)).then(()=>{e.succeeded&&e.succeeded(l)}).catch(E=>{C.call(this),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else e.succeeded&&e.succeeded(l)}function C(l){e.failed&&e.failed(l)}}_acceptAndTerminate(n,a,e){ee.debug("acceptAndTerminate()");const o=[];a&&(e=e||ve.REASON_PHRASE[a]||"",o.push(`Reason: SIP ;cause=${a}; text="${e}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(ve.ACK),this.sendRequest(ve.BYE,{extraHeaders:o})),this._status=ie.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=Tf.parse(n),this._localHold&&!this._remoteHold){ee.debug("mangleOffer() | me on hold, mangling offer");for(const a of n.media)Ea.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="sendonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="sendonly")}else if(this._localHold&&this._remoteHold){ee.debug("mangleOffer() | both on hold, mangling offer");for(const a of n.media)Ea.indexOf(a.type)!==-1&&(a.direction="inactive")}else if(this._remoteHold){ee.debug("mangleOffer() | remote on hold, mangling offer");for(const a of n.media)Ea.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="recvonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="recvonly")}return Tf.write(n)}_setLocalMediaStatus(){let n=!0,a=!0;(this._localHold||this._remoteHold)&&(n=!1,a=!1),this._audioMuted&&(n=!1),this._videoMuted&&(a=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!a)}_handleSessionTimersInIncomingRequest(n,a){if(!this._sessionTimers.enabled)return;let e;n.session_expires&&n.session_expires>=ve.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,e=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,e="uas"),a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${e}`),this._sessionTimers.refresher=e==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let a;n.session_expires&&n.session_expires>=ve.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,a=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,a="uac"),this._sessionTimers.refresher=a==="uac",this._runSessionTimer()}_runSessionTimer(){const n=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==ie.STATUS_TERMINATED&&this._isReadyToReOffer()&&(ee.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===ve.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==ie.STATUS_TERMINATED&&(ee.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:ve.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="audio");for(const e of a)e.track.enabled=!n}_toggleMuteVideo(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="video");for(const e of a)e.track.enabled=!n}_newRTCSession(n,a){ee.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:n,session:this,request:a})}_connecting(n){ee.debug("session connecting"),ee.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,a){ee.debug("session progress"),ee.debug('emit "progress"'),this.emit("progress",{originator:n,response:a||null})}_accepted(n,a){ee.debug("session accepted"),this._start_time=new Date,ee.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:a||null})}_confirmed(n,a){ee.debug("session confirmed"),this._is_confirmed=!0,ee.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:a||null})}_ended(n,a,e){ee.debug("session ended"),this._end_time=new Date,this._close(),ee.debug('emit "ended"'),this.emit("ended",{originator:n,message:a||null,cause:e})}_failed(n,a,e){ee.debug("session failed"),ee.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:a||null,cause:e}),this._close(),ee.debug('emit "failed"'),this.emit("failed",{originator:n,message:a||null,cause:e})}_onhold(n){ee.debug("session onhold"),this._setLocalMediaStatus(),ee.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){ee.debug("session onunhold"),this._setLocalMediaStatus(),ee.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:a}){ee.debug("session onmute"),this._setLocalMediaStatus(),ee.debug('emit "muted"'),this.emit("muted",{audio:n,video:a})}_onunmute({audio:n,video:a}){ee.debug("session onunmute"),this._setLocalMediaStatus(),ee.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:a})}};const $g=ot(Ah),Hg=At.EventEmitter,Fg=Et,zo=Fe,qg=Ft,Oi=xt(),jg=ci,Af=Gn,Vg=Bn(),Ca=new Fg("Message");var Bg=class extends Hg{constructor(n){super(),this._ua=n,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(n,a,e={}){const o=n;if(n===void 0||a===void 0)throw new TypeError("Not enough arguments");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const p=Oi.cloneArray(e.extraHeaders),t=Oi.cloneObject(e.eventHandlers),v=e.contentType||"text/plain",C={};e.fromUserName&&(C.from_uri=new Vg("sip",e.fromUserName,this._ua.configuration.uri.host),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),e.fromDisplayName&&(C.from_display_name=e.fromDisplayName);for(const A in t)Object.prototype.hasOwnProperty.call(t,A)&&this.on(A,t[A]);p.push(`Content-Type: ${v}`),this._request=new qg.OutgoingRequest(zo.MESSAGE,n,this._ua,C,p),a&&(this._request.body=a);const l=new jg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:A=>{this._receiveResponse(A)}});this._newMessage("local",this._request),l.send()}init_incoming(n){this._request=n,this._newMessage("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const a=Oi.cloneArray(n.extraHeaders),e=n.body;if(this._direction!=="incoming")throw new Af.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,a,e)}reject(n={}){const a=n.status_code||480,e=n.reason_phrase,o=Oi.cloneArray(n.extraHeaders),p=n.body;if(this._direction!=="incoming")throw new Af.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);this._is_replied=!0,this._request.reply(a,e,o,p)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):this._succeeded("remote",n);break;default:{const a=Oi.sipErrorCause(n.status_code);this._failed("remote",n,a);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,zo.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,zo.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(n,a){n==="remote"?(this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from):n==="local"&&(this._direction="outgoing",this._local_identity=a.from,this._remote_identity=a.to),this._ua.newMessage(this,{originator:n,message:this,request:a})}_failed(n,a,e){Ca.debug("MESSAGE failed"),this._close(),Ca.debug('emit "failed"'),this.emit("failed",{originator:n,response:a||null,cause:e})}_succeeded(n,a){Ca.debug("MESSAGE succeeded"),this._close(),Ca.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:a})}};const Gg=At.EventEmitter,Wg=Et,Jo=Fe,Kg=Ft,Di=xt(),Yg=ci,yf=Gn,Sa=new Wg("Options");var zg=class extends Gg{constructor(n){super(),this._ua=n,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(n,a,e={}){const o=n;if(n===void 0)throw new TypeError("A target is required for OPTIONS");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const p=Di.cloneArray(e.extraHeaders),t=Di.cloneObject(e.eventHandlers),v=e.contentType||"application/sdp";for(const l in t)Object.prototype.hasOwnProperty.call(t,l)&&this.on(l,t[l]);p.push(`Content-Type: ${v}`),this._request=new Kg.OutgoingRequest(Jo.OPTIONS,n,this._ua,null,p),a&&(this._request.body=a);const C=new Yg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:l=>{this._receiveResponse(l)}});this._newOptions("local",this._request),C.send()}init_incoming(n){this._request=n,this._newOptions("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const a=Di.cloneArray(n.extraHeaders),e=n.body;if(this._direction!=="incoming")throw new yf.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,a,e)}reject(n={}){const a=n.status_code||480,e=n.reason_phrase,o=Di.cloneArray(n.extraHeaders),p=n.body;if(this._direction!=="incoming")throw new yf.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);this._is_replied=!0,this._request.reply(a,e,o,p)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):this._succeeded("remote",n);break;default:{const a=Di.sipErrorCause(n.status_code);this._failed("remote",n,a);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Jo.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Jo.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(n,a){n==="remote"?(this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from):n==="local"&&(this._direction="outgoing",this._local_identity=a.from,this._remote_identity=a.to),this._ua.newOptions(this,{originator:n,message:this,request:a})}_failed(n,a,e){Sa.debug("OPTIONS failed"),this._close(),Sa.debug('emit "failed"'),this.emit("failed",{originator:n,response:a||null,cause:e})}_succeeded(n,a){Sa.debug("OPTIONS succeeded"),this._close(),Sa.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:a})}},Vu={};const Jg=Et,Xo=xt(),Xg=dn(),Ni=new Jg("Socket");Vu.isSocket=u=>{if(Array.isArray(u))return!1;if(typeof u>"u")return Ni.warn("undefined JsSIP.Socket instance"),!1;try{if(!Xo.isString(u.url))throw Ni.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!Xo.isString(u.via_transport))throw Ni.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Xg.parse(u.sip_uri,"SIP_URI")===-1)throw Ni.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(n=>{if(!Xo.isFunction(u[n]))throw Ni.warn(`missing or invalid JsSIP.Socket method: ${n}`),new Error(`Missing or invalid JsSIP.Socket method: ${n}`)})}catch{return!1}return!0};const Qg=Et,Zg=Vu,Rf=Fe,zt=new Qg("Transport"),Es={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Rf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Rf.CONNECTION_RECOVERY_MAX_INTERVAL}};var yh=class{constructor(n,a=Es.recovery_options){zt.debug("new()"),this.status=Es.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=a,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(e){zt.warn(`cannot use TextDecoder: ${e}`)}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(e){if(!Zg.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:Es.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(zt.debug("connect()"),this.isConnected()){zt.debug("Transport is already connected");return}else if(this.isConnecting()){zt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Es.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(){zt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Es.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(n){if(zt.debug("send()"),!this.isConnected())return zt.warn("unable to send message, transport is not connected"),!1;const a=n.toString();return zt.debug(`sending message:
116
116
 
117
- ${r}
118
- `),this.socket.send(r)}isConnected(){return this.status===qt.STATUS_CONNECTED}isConnecting(){return this.status===qt.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),Ut.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!==qt.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=qt.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=qt.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(s,r,o){this.status=qt.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=qt.SOCKET_STATUS_ERROR)},this),this._reconnect(s))}_onData(s){if(s===`\r
119
- `){Ut.debug("received message with CRLF Keep Alive response");return}else if(typeof s!="string"){try{this.textDecoder?s=this.textDecoder.decode(s):s=String.fromCharCode.apply(null,new Uint8Array(s))}catch{Ut.debug("received binary message failed to be converted into string, message discarded");return}Ut.debug(`received binary message:
117
+ ${a}
118
+ `),this.socket.send(a)}isConnected(){return this.status===Es.STATUS_CONNECTED}isConnecting(){return this.status===Es.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let n=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);n<this.recovery_options.min_interval?n=this.recovery_options.min_interval:n>this.recovery_options.max_interval&&(n=this.recovery_options.max_interval),zt.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${n} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},n*1e3)}_getSocket(){let n=[];if(this.sockets.forEach(e=>{e.status!==Es.SOCKET_STATUS_ERROR&&(n.length===0?n.push(e):e.weight>n[0].weight?n=[e]:e.weight===n[0].weight&&n.push(e))}),n.length===0){this.sockets.forEach(e=>{e.status=Es.SOCKET_STATUS_READY}),this._getSocket();return}const a=Math.floor(Math.random()*n.length);this.socket=n[a].socket}_onConnect(){this.recover_attempts=0,this.status=Es.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(n,a,e){this.status=Es.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:n,code:a,reason:e}),!this.close_requested&&(this.sockets.forEach(function(o){this.socket===o.socket&&(o.status=Es.SOCKET_STATUS_ERROR)},this),this._reconnect(n))}_onData(n){if(n===`\r
119
+ `){zt.debug("received message with CRLF Keep Alive response");return}else if(typeof n!="string"){try{this.textDecoder?n=this.textDecoder.decode(n):n=String.fromCharCode.apply(null,new Uint8Array(n))}catch{zt.debug("received binary message failed to be converted into string, message discarded");return}zt.debug(`received binary message:
120
120
 
121
- ${s}
122
- `)}else Ut.debug(`received text message:
121
+ ${n}
122
+ `)}else zt.debug(`received text message:
123
123
 
124
- ${s}
125
- `);this.ondata({transport:this,message:s})}};const Kg=Xe(v_);var Hu={};const Yg=at,Eu=ls(),Su=It,so=new Yg("Parser");Hu.parseMessage=(c,s)=>{let r,o,a=c.indexOf(`\r
126
- `);if(a===-1){so.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=c.substring(0,a);let n=Eu.parse(t,"Request_Response");if(n===-1){so.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else n.status_code?(r=new Su.IncomingResponse,r.status_code=n.status_code,r.reason_phrase=n.reason_phrase):(r=new Su.IncomingRequest(s),r.method=n.method,r.ruri=n.uri);r.data=c;let d=a+2;for(;;){if(a=Jg(c,d),a===-2){o=d+2;break}else if(a===-1){so.warn("parseMessage() | malformed message");return}if(n=zg(r,c,d,a),n!==!0){so.warn("parseMessage() |",n.error);return}d=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 Jg(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 zg(c,s,r,o){let a;const t=s.indexOf(":",r),n=s.substring(r,t).trim(),d=s.substring(t+1,o).trim();switch(n.toLowerCase()){case"via":case"v":c.addHeader("via",d),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",d),a=c.parseHeader("from"),a&&(c.from=a,c.from_tag=a.getParam("tag"));break;case"to":case"t":c.setHeader("to",d),a=c.parseHeader("to"),a&&(c.to=a,c.to_tag=a.getParam("tag"));break;case"record-route":if(a=Eu.parse(d,"Record_Route"),a===-1)a=void 0;else for(const _ of a)c.addHeader("record-route",d.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",d),a=c.parseHeader("call-id"),a&&(c.call_id=d);break;case"contact":case"m":if(a=Eu.parse(d,"Contact"),a===-1)a=void 0;else for(const _ of a)c.addHeader("contact",d.substring(_.possition,_.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=_.parsed;break;case"content-length":case"l":c.setHeader("content-length",d),a=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",d),a=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",d),a=c.parseHeader("cseq"),a&&(c.cseq=a.value),c instanceof Su.IncomingResponse&&(c.method=a.method);break;case"max-forwards":c.setHeader("max-forwards",d),a=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",d),a=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",d),a=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",d),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",d),a=c.parseHeader("refer-to"),a&&(c.refer_to=a);break;case"replaces":c.setHeader("replaces",d),a=c.parseHeader("replaces"),a&&(c.replaces=a);break;case"event":case"o":c.setHeader("event",d),a=c.parseHeader("event"),a&&(c.event=a);break;default:c.addHeader(n,d),a=0}return a===void 0?{error:`error parsing header "${n}"`}:!0}const Xg=at,E_=De,Sf=It,Fu=yt(),ju=new Xg("sanityCheck"),Qg=[oT],Zg=[tT,sT,nT,rT],eT=[iT,lT];let Fe,ss,S_;var y_=(c,s,r)=>{Fe=c,ss=s,S_=r;for(const o of Qg)if(o()===!1)return!1;if(Fe instanceof Sf.IncomingRequest){for(const o of Zg)if(o()===!1)return!1}else if(Fe instanceof Sf.IncomingResponse){for(const o of eT)if(o()===!1)return!1}return!0};function tT(){if(Fe.s("to").uri.scheme!=="sip")return Zi(416),!1}function sT(){if(!Fe.to_tag&&Fe.call_id.substr(0,5)===ss.configuration.jssip_id)return Zi(482),!1}function nT(){const c=Fu.str_utf8_length(Fe.body),s=Fe.getHeader("content-length");if(c<s)return Zi(400),!1}function rT(){const c=Fe.from_tag,s=Fe.call_id,r=Fe.cseq;let o;if(!Fe.to_tag)if(Fe.method===E_.INVITE){if(ss._transactions.ist[Fe.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 Zi(482),!1}else{if(ss._transactions.nist[Fe.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 Zi(482),!1}}function iT(){if(Fe.getHeaders("via").length>1)return ju.debug("more than one Via header field present in the response, dropping the response"),!1}function lT(){const c=Fu.str_utf8_length(Fe.body),s=Fe.getHeader("content-length");if(c<s)return ju.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function oT(){const c=["from","to","call_id","cseq","via"];for(const s of c)if(!Fe.hasHeader(s))return ju.debug(`missing mandatory header field : ${s}, dropping the response`),!1}function Zi(c){const s=Fe.getHeaders("via");let r,o=`SIP/2.0 ${c} ${E_.REASON_PHRASE[c]}\r
128
- `;for(const a of s)o+=`Via: ${a}\r
129
- `;r=Fe.getHeader("To"),Fe.to_tag||(r+=`;tag=${Fu.newTag()}`),o+=`To: ${r}\r
130
- `,o+=`From: ${Fe.getHeader("From")}\r
131
- `,o+=`Call-ID: ${Fe.call_id}\r
132
- `,o+=`CSeq: ${Fe.cseq} ${Fe.method}\r
133
- `,o+=`\r
134
- `,S_.send(o)}const aT=Xe(y_);var el={};const ur=yt(),Sn=De,Ga=ls(),yf=Es(),Wa=$u,Ka=Ss;el.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:Sn.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Sn.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Sn.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${ur.createRandomToken(12)}.invalid`};const no={mandatory:{sockets(c){const s=[];if(Wa.isSocket(c))s.push({socket:c});else if(Array.isArray(c)&&c.length)for(const r of c)Object.prototype.hasOwnProperty.call(r,"socket")&&Wa.isSocket(r.socket)?s.push(r):Wa.isSocket(r)&&s.push({socket:r});else return;return s},uri(c){/^sip:/i.test(c)||(c=`${Sn.SIP}:${c}`);const s=yf.parse(c);if(s)return s.user?s:void 0}},optional:{authorization_user(c){if(Ga.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(ur.isDecimal(c)){const s=Number(c);if(s>0)return s}},connection_recovery_min_interval(c){if(ur.isDecimal(c)){const s=Number(c);if(s>0)return s}},contact_uri(c){if(typeof c=="string"){const s=Ga.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)),Ga.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(ur.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===Sn.INVITE||c===Sn.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(ur.isDecimal(c)){const s=Number(c);if(s>0)return s}},registrar_server(c){/^sip:/i.test(c)||(c=`${Sn.SIP}:${c}`);const s=yf.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}}};el.load=(c,s)=>{for(const r in no.mandatory)if(s.hasOwnProperty(r)){const o=s[r],a=no.mandatory[r](o);if(a!==void 0)c[r]=a;else throw new Ka.ConfigurationError(r,o)}else throw new Ka.ConfigurationError(r);for(const r in no.optional)if(s.hasOwnProperty(r)){const o=s[r];if(ur.isEmpty(o))continue;const a=no.optional[r](o);if(a!==void 0)c[r]=a;else throw new Ka.ConfigurationError(r,o)}};const uT=ft.EventEmitter,cT=at,mt=De,fT=Zm,Af=T_,Cf=Lg,Rf=qg,Ya=pr,_T=v_,ro=yt(),hT=Ss,dT=Es(),pT=Hu,Ja=It,mT=y_,za=el,qe=new cT("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 uT{static get C(){return vt}constructor(s){if(qe.debug("new() [configuration:%o]",s),super(),this._cache={credentials:{}},this._configuration=Object.assign({},za.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 fT(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 Af(this);return o.connect(s,r),o}sendMessage(s,r,o){qe.debug("sendMessage()");const a=new Cf(this);return a.send(s,r,o),a}sendOptions(s,r,o){qe.debug("sendOptions()");const a=new Rf(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 ro.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!==mt.ACK&&s.reply_sl(404);return}if(s.ruri.scheme===mt.SIPS){s.reply_sl(416);return}if(Ya.checkTransaction(this,s))return;if(r===mt.INVITE?new Ya.InviteServerTransaction(this,this._transport,s):r!==mt.ACK&&r!==mt.CANCEL&&new Ya.NonInviteServerTransaction(this,this._transport,s),r===mt.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new Rf(this).init_incoming(s)}else if(r===mt.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new Cf(this).init_incoming(s)}else if(r===mt.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===mt.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!==mt.ACK&&s.reply(481);else switch(r){case mt.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 Af(this),a.init_incoming(s);else qe.warn("INVITE received but WebRTC is not supported"),s.reply(488);break;case mt.BYE:s.reply(481);break;case mt.CANCEL:a=this._findSession(s),a?a.receiveRequest(s):qe.debug("received CANCEL request for a non existent session");break;case mt.ACK:break;case mt.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,d=this._sessions[n];return t||d||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{za.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=ro.newUUID()),this._configuration.jssip_id=ro.createRandomToken(5);const r=this._configuration.uri.clone();r.user=null,this._configuration.hostport_params=r.toString().replace(/^sip:/i,"");try{this._transport=new _T(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=gT.bind(this),this._transport.onconnect=TT.bind(this),this._transport.ondisconnect=vT.bind(this),this._transport.ondata=ET.bind(this)}catch(a){throw qe.warn(a),new hT.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 dT("sip",ro.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 d="<";return t?d+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":d+=this.pub_gruu||this.uri.toString(),n&&(t?!this.temp_gruu:!this.pub_gruu)&&(d+=";ob"),d+=">",d}};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(za.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 gT(c){this.emit("connecting",c)}function TT(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 vT(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 ET(c){console.log("onTransportData",c);const s=c.transport;let r=c.message;if(r=pT.parseMessage(r,this),!!r&&!(this._status===vt.STATUS_USER_CLOSED&&r instanceof Ja.IncomingRequest)&&mT(r,this,s)){if(r instanceof Ja.IncomingRequest)r.transport=s,this.receiveRequest(r);else if(r instanceof Ja.IncomingResponse){let o;switch(r.method){case mt.INVITE:o=this._transactions.ict[r.via_branch],o&&o.receiveResponse(r);break;case mt.ACK:break;default:o=this._transactions.nict[r.via_branch],o&&o.receiveResponse(r);break}}}}const ST=Xe(A_);var dt=[];for(var Xa=0;Xa<256;++Xa)dt.push((Xa+256).toString(16).slice(1));function yT(c,s=0){return(dt[c[s+0]]+dt[c[s+1]]+dt[c[s+2]]+dt[c[s+3]]+"-"+dt[c[s+4]]+dt[c[s+5]]+"-"+dt[c[s+6]]+dt[c[s+7]]+"-"+dt[c[s+8]]+dt[c[s+9]]+"-"+dt[c[s+10]]+dt[c[s+11]]+dt[c[s+12]]+dt[c[s+13]]+dt[c[s+14]]+dt[c[s+15]]).toLowerCase()}var io,AT=new Uint8Array(16);function CT(){if(!io&&(io=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!io))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return io(AT)}var RT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const If={randomUUID:RT};function bf(c,s,r){if(If.randomUUID&&!s&&!c)return If.randomUUID();c=c||{};var o=c.random||(c.rng||CT)();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 yT(o)}var Me=yt();const ms=Xe(Me),Qa=new Pu("Dialog"),$s={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};class lo{static get C(){return $s}constructor(s,r,o,a=$s.STATUS_CONFIRMED){if(this._owner=s,this._ua=s._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,r instanceof It.IncomingResponse&&(a=r.status_code<200?$s.STATUS_EARLY:$s.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),Qa.debug(`new ${o} dialog created with status ${this._state===$s.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===$s.STATUS_TERMINATED}update(s,r){this._state=$s.STATUS_CONFIRMED,Qa.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),r==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){Qa.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=$s.STATUS_TERMINATED}sendRequest(s,r={}){const o=ms.cloneArray(r.extraHeaders),a=ms.cloneObject(r.eventHandlers),t=r.body||null,n=this._createRequest(s,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new ig(this,n,a).send(),n}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===$.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===$.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,r,o){r=ms.cloneArray(r),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===$.CANCEL||s===$.ACK?this._local_seqnum:this._local_seqnum+=1;return new It.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===$.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===$.INVITE||s.method===$.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===Bt.C.STATUS_ACCEPTED||s.server_transaction.state===Bt.C.STATUS_COMPLETED||s.server_transaction.state===Bt.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===Bt.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===$.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Bt.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}}class IT{constructor(s,r){Wt(this,"plugin",null);Wt(this,"rtcpPeer",null);Wt(this,"handleId",0);Wt(this,"info",null);Wt(this,"joinResult",null);Wt(this,"state",{});Wt(this,"stream",null);Wt(this,"loaded",!1);Wt(this,"aTracks",[]);Wt(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,d,_;const r=(n=(t=s==null?void 0:s.plugindata)==null?void 0:t.data)==null?void 0:n.newStatePublisher,a=((_=(d=s==null?void 0:s.plugindata)==null?void 0:d.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 bT=Es();const _r=Xe(bT),z=new Pu("JanusSession"),wT="/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},oo=["audio","video"];class ko extends ft.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:$.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=bf().replace(/-/g,"").slice(0,12);this.opaque_id=`videoroomtest-${r}`,this._data={}}get C(){return te}get causes(){return $.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),d=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 Fs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Fs.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>=$.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=o.sessionTimersExpires:this._sessionTimers.defaultExpires=$.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 _r("sip","anonymous","anonymous.invalid"),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),d.push("Privacy: id")):o.fromUserName&&(A.from_uri=new _r("sip",o.fromUserName,this._ua.configuration.uri.host),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(A.from_display_name=o.fromDisplayName),d.push(`Contact: ${this._contact}`),d.push("Content-Type: application/json"),this._sessionTimers.enabled&&d.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new It.InitialOutgoingInviteRequest(s,this._ua,A,d),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,$.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,$.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:[]}),d=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 Fs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==te.STATUS_WAITING_FOR_ANSWER)throw new Fs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Me.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=$.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=$.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,d),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,$.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(H=>{this._connection.addTrack(H,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 H=new RTCSessionDescription({type:"offer",sdp:I.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(H)).catch(L=>{throw r.reply(488),this._failed("system",null,$.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,$.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==te.STATUS_TERMINATED&&z.warn(I)})}terminate(s={}){z.debug("terminate()");const r=s.cause||$.causes.BYE,o=Me.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,d=s.reason_phrase;if(this._status===te.STATUS_TERMINATED)throw new Fs.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&&(d=d||$.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;text="${d}"`),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,$.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,d,o,a),this._failed("local",null,$.causes.REJECTED);break;case te.STATUS_WAITING_FOR_ACK:case te.STATUS_CONFIRMED:if(z.debug("terminating session"),d=s.reason_phrase||$.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${d}"`),this._status===te.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Bt.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:h})=>{h===$.ACK&&(this.sendRequest($.BYE,{extraHeaders:o,body:a}),_.terminate(),this.closeSession())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Bt.C.STATUS_TERMINATED&&(this.sendRequest($.BYE,{extraHeaders:o,body:a}),_.terminate(),this.closeSession())}),this._ended("local",null,r),this._dialog=_,console.log("SET DIALOG terminate"),this._ua.newDialog(_)}else{const _={request:"leave"},h=["Content-Type: application/json","PTYPE: Leave"];this.sendRequest($.BYE,{extraHeaders:h,body:JSON.stringify(_)}),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 Fs.InvalidStateError(this._status);new Tu(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:$.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:$.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:$.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 Cg(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===$.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,$.causes.CANCELED));else switch(s.method){case $.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:$.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:$.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 $.BYE:this._status===te.STATUS_CONFIRMED||this._status===te.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,$.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,$.causes.BYE)):s.reply(403,"Wrong Status");break;case $.INVITE:this._status===te.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case $.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 hg(this).init_incoming(s):r!==void 0?new Tu(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case $.UPDATE:this._status===te.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case $.REFER:this._status===te.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case $.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:$.causes.CONNECTION_ERROR,cause:$.causes.CONNECTION_ERROR})}onRequestTimeout(){z.warn("onRequestTimeout()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:$.causes.REQUEST_TIMEOUT,cause:$.causes.REQUEST_TIMEOUT})}onDialogError(){z.warn("onDialogError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:$.causes.DIALOG_ERROR,cause:$.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=Mi.T1;function a(){this._status===te.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],r),o<Mi.T2&&(o=o*2,o>Mi.T2&&(o=Mi.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($.BYE),this._ended("remote",null,$.causes.NO_ACK))},Mi.TIMER_H)}_createRTCConnection(s,r){this.stunServers,this._connection=new RTCPeerConnection(s,r),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:$.causes.RTP_TIMEOUT,status_code:408,reason_phrase:$.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,d,_;this._iceReady=!1;const h=()=>{o.removeEventListener("icecandidate",d),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",d=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 d=this._earlyDialogs[n];if(o)return d?!0:(d=new lo(this,s,r,lo.C.STATUS_EARLY),console.log("SET DIALOG early"),d.error?(console.log("early_dialog error",d.error),z.debug(d.error),this._failed("remote",s,$.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=d,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,d)return d.update(s,r),console.log("SET DIALOG 1"),this._dialog=d,delete this._earlyDialogs[n],!0;const _=new lo(this,s,r);return _.error?(console.log("dialog.error",_.error),z.debug(_.error),this._failed("remote",s,$.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(d={}){a=!0;const _=d.status_code||403,h=d.reason_phrase||"",g=Me.cloneArray(d.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(d=>{n.call(this,d)}).catch(()=>{s.reply(500)});return}if(r!=="application/sdp"){z.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(d=>{this._status!==te.STATUS_TERMINATED&&n.call(this,d)}).catch(d=>{z.warn(d)});function n(d){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),this._late_sdp&&(d=this._mangleOffer(d)),s.reply(200,null,_,d,()=>{this._status=te.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,d),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(d={}){a=!0;const _=d.status_code||403,h=d.reason_phrase||"",g=Me.cloneArray(d.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(d=>{this._status!==te.STATUS_TERMINATED&&n.call(this,d)}).catch(d=>{z.warn(d)});function n(d){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,_),s.reply(200,null,_,d),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(oo.indexOf(n.type)===-1)continue;const d=n.direction||r.direction||"sendrecv";if(d==="sendonly"||d==="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!==$.SIP){z.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const r=new Eg(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 d=new ko(this._ua);if(d.on("progress",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),d.on("accepted",({response:_})=>{r.notify(_.status_code,_.reason_phrase)}),d.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: ${_}`)}d.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 ko(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 Mo(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,$.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,$.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},d=JSON.stringify(n);this._request.body=d,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 wT+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]},d=["Content-Type: application/json","PTYPE: Ice"];this.sendRequest($.INFO,{extraHeaders:d,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($.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($.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 d=_=>{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=d,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($.SUBSCRIBE,{extraHeaders:o,body:JSON.stringify(r),eventHandlers:{onSuccessResponse:async a=>{var t,n;if(a.status_code===200){const d=JSON.parse(a.body);(n=(t=d==null?void 0:d.plugindata)==null?void 0:t.data)!=null&&n.id&&await this._answerAttachedStream(s,d)}}}})}_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($.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($.INFO,{extraHeaders:o,body:JSON.stringify(r)}),this._ua.emit("memberHangup",s.memberInfo)}receivePublishers(s){var o,a,t,n,d,_,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 IT(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=(_=(d=s==null?void 0:s.plugindata)==null?void 0:d.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($.ACK);return}else{const r=new lo(this,s,"UAC");if(r.error!==void 0){z.debug(r.error);return}this.sendRequest($.ACK),this.sendRequest($.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=bf();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($.SUBSCRIBE,{extraHeaders:a,body:JSON.stringify(o),eventHandlers:{onSuccessResponse:async t=>{var n,d;if(t.status_code===200){if(this.subscribeSent=!0,t.body)try{const _=JSON.parse(t.body)||{};(d=(n=_.plugindata)==null?void 0:n.data)!=null&&d.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,$.causes.MISSING_SDP),this._failed("remote",s,$.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($.INVITE,{extraHeaders:r,body:_,eventHandlers:{onSuccessResponse:g=>{n.call(this,g),t=!0},onErrorResponse:g=>{d.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{d()});function n(_){if(this._status===te.STATUS_TERMINATED||(this.sendRequest($.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(_),_.body){if(!_.hasHeader("Content-Type")||_.getHeader("Content-Type").toLowerCase()!=="application/sdp"){d.call(this);return}}else{d.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=>{d.call(this),z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',T),this.emit("peerconnection:setremotedescriptionfailed",T)})}function d(_){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($.UPDATE,{extraHeaders:r,body:h,eventHandlers:{onSuccessResponse:T=>{d.call(this,T),n=!0},onErrorResponse:T=>{_.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest($.UPDATE,{extraHeaders:r,eventHandlers:{onSuccessResponse:h=>{d.call(this,h)},onErrorResponse:h=>{_.call(this,h)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function d(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||$.REASON_PHRASE[r]||"",a.push(`Reason: SIP ;cause=${r}; text="${o}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest($.ACK),this.sendRequest($.BYE,{extraHeaders:a})),this._status=te.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=Pt.parse(s),this._localHold&&!this._remoteHold){z.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){z.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){z.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 Pt.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>=$.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>=$.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===$.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:$.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 or{constructor(s){if(this.headers={},s.length>0){let r=!1;const o=s.split(`\r
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
- `;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
- `;for(const r in this.headers)s+=`${r}: ${this.headers[r]}\r
139
- `;return this.body&&(s+=`\r
124
+ ${n}
125
+ `);this.ondata({transport:this,message:n})}};const ev=ot(yh);var Rh={};const tv=Et,Iu=dn(),wu=Ft,Aa=new tv("Parser");Rh.parseMessage=(u,n)=>{let a,e,o=u.indexOf(`\r
126
+ `);if(o===-1){Aa.warn("parseMessage() | no CRLF found, not a SIP message");return}const p=u.substring(0,o);let t=Iu.parse(p,"Request_Response");if(t===-1){Aa.warn(`parseMessage() | error parsing first line of SIP message: "${p}"`);return}else t.status_code?(a=new wu.IncomingResponse,a.status_code=t.status_code,a.reason_phrase=t.reason_phrase):(a=new wu.IncomingRequest(n),a.method=t.method,a.ruri=t.uri);a.data=u;let v=o+2;for(;;){if(o=sv(u,v),o===-2){e=v+2;break}else if(o===-1){Aa.warn("parseMessage() | malformed message");return}if(t=nv(a,u,v,o),t!==!0){Aa.warn("parseMessage() |",t.error);return}v=o+2}if(a.hasHeader("content-length")){const C=a.getHeader("content-length");a.body=u.substr(e,C)}else a.body=u.substring(e);return a};function sv(u,n){let a=n,e=0,o=0;if(u.substring(a,a+2).match(/(^\r\n)/))return-2;for(;e===0;){if(o=u.indexOf(`\r
127
+ `,a),o===-1)return o;!u.substring(o+2,o+4).match(/(^\r\n)/)&&u.charAt(o+2).match(/(^\s+)/)?a=o+2:e=o}return e}function nv(u,n,a,e){let o;const p=n.indexOf(":",a),t=n.substring(a,p).trim(),v=n.substring(p+1,e).trim();switch(t.toLowerCase()){case"via":case"v":u.addHeader("via",v),u.getHeaders("via").length===1?(o=u.parseHeader("Via"),o&&(u.via=o,u.via_branch=o.branch)):o=0;break;case"from":case"f":u.setHeader("from",v),o=u.parseHeader("from"),o&&(u.from=o,u.from_tag=o.getParam("tag"));break;case"to":case"t":u.setHeader("to",v),o=u.parseHeader("to"),o&&(u.to=o,u.to_tag=o.getParam("tag"));break;case"record-route":if(o=Iu.parse(v,"Record_Route"),o===-1)o=void 0;else for(const C of o)u.addHeader("record-route",v.substring(C.possition,C.offset)),u.headers["Record-Route"][u.getHeaders("record-route").length-1].parsed=C.parsed;break;case"call-id":case"i":u.setHeader("call-id",v),o=u.parseHeader("call-id"),o&&(u.call_id=v);break;case"contact":case"m":if(o=Iu.parse(v,"Contact"),o===-1)o=void 0;else for(const C of o)u.addHeader("contact",v.substring(C.possition,C.offset)),u.headers.Contact[u.getHeaders("contact").length-1].parsed=C.parsed;break;case"content-length":case"l":u.setHeader("content-length",v),o=u.parseHeader("content-length");break;case"content-type":case"c":u.setHeader("content-type",v),o=u.parseHeader("content-type");break;case"cseq":u.setHeader("cseq",v),o=u.parseHeader("cseq"),o&&(u.cseq=o.value),u instanceof wu.IncomingResponse&&(u.method=o.method);break;case"max-forwards":u.setHeader("max-forwards",v),o=u.parseHeader("max-forwards");break;case"www-authenticate":u.setHeader("www-authenticate",v),o=u.parseHeader("www-authenticate");break;case"proxy-authenticate":u.setHeader("proxy-authenticate",v),o=u.parseHeader("proxy-authenticate");break;case"session-expires":case"x":u.setHeader("session-expires",v),o=u.parseHeader("session-expires"),o&&(u.session_expires=o.expires,u.session_expires_refresher=o.refresher);break;case"refer-to":case"r":u.setHeader("refer-to",v),o=u.parseHeader("refer-to"),o&&(u.refer_to=o);break;case"replaces":u.setHeader("replaces",v),o=u.parseHeader("replaces"),o&&(u.replaces=o);break;case"event":case"o":u.setHeader("event",v),o=u.parseHeader("event"),o&&(u.event=o);break;default:u.addHeader(t,v),o=0}return o===void 0?{error:`error parsing header "${t}"`}:!0}const lv=Et,bh=Fe,bf=Ft,Bu=xt(),Gu=new lv("sanityCheck"),rv=[dv],iv=[ov,uv,cv,fv],av=[hv,_v];let Qe,cn,Ih;var wh=(u,n,a)=>{Qe=u,cn=n,Ih=a;for(const e of rv)if(e()===!1)return!1;if(Qe instanceof bf.IncomingRequest){for(const e of iv)if(e()===!1)return!1}else if(Qe instanceof bf.IncomingResponse){for(const e of av)if(e()===!1)return!1}return!0};function ov(){if(Qe.s("to").uri.scheme!=="sip")return ji(416),!1}function uv(){if(!Qe.to_tag&&Qe.call_id.substr(0,5)===cn.configuration.jssip_id)return ji(482),!1}function cv(){const u=Bu.str_utf8_length(Qe.body),n=Qe.getHeader("content-length");if(u<n)return ji(400),!1}function fv(){const u=Qe.from_tag,n=Qe.call_id,a=Qe.cseq;let e;if(!Qe.to_tag)if(Qe.method===bh.INVITE){if(cn._transactions.ist[Qe.via_branch])return!1;for(const o in cn._transactions.ist)if(Object.prototype.hasOwnProperty.call(cn._transactions.ist,o)&&(e=cn._transactions.ist[o],e.request.from_tag===u&&e.request.call_id===n&&e.request.cseq===a))return ji(482),!1}else{if(cn._transactions.nist[Qe.via_branch])return!1;for(const o in cn._transactions.nist)if(Object.prototype.hasOwnProperty.call(cn._transactions.nist,o)&&(e=cn._transactions.nist[o],e.request.from_tag===u&&e.request.call_id===n&&e.request.cseq===a))return ji(482),!1}}function hv(){if(Qe.getHeaders("via").length>1)return Gu.debug("more than one Via header field present in the response, dropping the response"),!1}function _v(){const u=Bu.str_utf8_length(Qe.body),n=Qe.getHeader("content-length");if(u<n)return Gu.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function dv(){const u=["from","to","call_id","cseq","via"];for(const n of u)if(!Qe.hasHeader(n))return Gu.debug(`missing mandatory header field : ${n}, dropping the response`),!1}function ji(u){const n=Qe.getHeaders("via");let a,e=`SIP/2.0 ${u} ${bh.REASON_PHRASE[u]}\r
128
+ `;for(const o of n)e+=`Via: ${o}\r
129
+ `;a=Qe.getHeader("To"),Qe.to_tag||(a+=`;tag=${Bu.newTag()}`),e+=`To: ${a}\r
130
+ `,e+=`From: ${Qe.getHeader("From")}\r
131
+ `,e+=`Call-ID: ${Qe.call_id}\r
132
+ `,e+=`CSeq: ${Qe.cseq} ${Qe.method}\r
133
+ `,e+=`\r
134
+ `,Ih.send(e)}const pv=ot(wh);var Vi={};const li=xt(),Pr=Fe,Qo=dn(),If=Bn(),Zo=Vu,eu=Gn;Vi.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:Pr.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Pr.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Pr.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${li.createRandomToken(12)}.invalid`};const ya={mandatory:{sockets(u){const n=[];if(Zo.isSocket(u))n.push({socket:u});else if(Array.isArray(u)&&u.length)for(const a of u)Object.prototype.hasOwnProperty.call(a,"socket")&&Zo.isSocket(a.socket)?n.push(a):Zo.isSocket(a)&&n.push({socket:a});else return;return n},uri(u){/^sip:/i.test(u)||(u=`${Pr.SIP}:${u}`);const n=If.parse(u);if(n)return n.user?n:void 0}},optional:{authorization_user(u){if(Qo.parse(`"${u}"`,"quoted_string")!==-1)return u},authorization_jwt(u){if(typeof u=="string")return u},user_agent(u){if(typeof u=="string")return u},connection_recovery_max_interval(u){if(li.isDecimal(u)){const n=Number(u);if(n>0)return n}},connection_recovery_min_interval(u){if(li.isDecimal(u)){const n=Number(u);if(n>0)return n}},contact_uri(u){if(typeof u=="string"){const n=Qo.parse(u,"SIP_URI");if(n!==-1)return n}},display_name(u){return u},instance_id(u){if(/^uuid:/i.test(u)&&(u=u.substr(5)),Qo.parse(u,"uuid")!==-1)return u},no_answer_timeout(u){if(li.isDecimal(u)){const n=Number(u);if(n>0)return n}},session_timers(u){if(typeof u=="boolean")return u},session_timers_refresh_method(u){if(typeof u=="string"&&(u=u.toUpperCase(),u===Pr.INVITE||u===Pr.UPDATE))return u},session_timers_force_refresher(u){if(typeof u=="boolean")return u},password(u){return String(u)},realm(u){return String(u)},ha1(u){return String(u)},register(u){if(typeof u=="boolean")return u},register_expires(u){if(li.isDecimal(u)){const n=Number(u);if(n>0)return n}},registrar_server(u){/^sip:/i.test(u)||(u=`${Pr.SIP}:${u}`);const n=If.parse(u);if(n)return n.user?void 0:n},use_preloaded_route(u){if(typeof u=="boolean")return u},extra_headers(u){const n=[];if(Array.isArray(u)&&u.length)for(const a of u)typeof a=="string"&&n.push(a);else return;return n}}};Vi.load=(u,n)=>{for(const a in ya.mandatory)if(n.hasOwnProperty(a)){const e=n[a],o=ya.mandatory[a](e);if(o!==void 0)u[a]=o;else throw new eu.ConfigurationError(a,e)}else throw new eu.ConfigurationError(a);for(const a in ya.optional)if(n.hasOwnProperty(a)){const e=n[a];if(li.isEmpty(e))continue;const o=ya.optional[a](e);if(o!==void 0)u[a]=o;else throw new eu.ConfigurationError(a,e)}};const mv=At.EventEmitter,gv=Et,It=Fe,vv=ig,wf=Ah,Of=Bg,Df=zg,tu=ui,Tv=yh,Ra=xt(),Ev=Gn,Cv=Bn(),Sv=Rh,su=Ft,Av=wh,nu=Vi,tt=new gv("UA"),Dt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var Oh=class extends mv{static get C(){return Dt}constructor(n){if(tt.debug("new() [configuration:%o]",n),super(),this._cache={credentials:{}},this._configuration=Object.assign({},nu.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=Dt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,n===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(n)}catch(a){throw this._status=Dt.STATUS_NOT_READY,this._error=Dt.CONFIGURATION_ERROR,a}this._registrator=new vv(this)}get C(){return Dt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){tt.debug("start()"),this._status===Dt.STATUS_INIT?this._transport.connect():this._status===Dt.STATUS_USER_CLOSED?(tt.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=Dt.STATUS_INIT,this._transport.connect()):this._status===Dt.STATUS_READY?tt.debug("UA is in READY status, not restarted"):tt.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){tt.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(n){tt.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(n)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(n,a){tt.debug("call()");const e=new wf(this);return e.connect(n,a),e}sendMessage(n,a,e){tt.debug("sendMessage()");const o=new Of(this);return o.send(n,a,e),o}sendOptions(n,a,e){tt.debug("sendOptions()");const o=new Df(this);return o.send(n,a,e),o}terminateSessions(n){tt.debug("terminateSessions()");for(const a in this._sessions)this._sessions[a].isEnded()||this._sessions[a].terminate(n)}stop(){if(tt.debug("stop()"),this._dynConfiguration={},this._status===Dt.STATUS_USER_CLOSED){tt.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const e in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,e)){tt.debug(`closing session ${e}`);try{this._sessions[e].terminate()}catch{}}for(const e in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,e))try{this._applicants[e].close()}catch{}this._status=Dt.STATUS_USER_CLOSED,Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length===0&&n===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(n){return Ra.normalizeTarget(n,this._configuration.hostport_params)}get(n){switch(n){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:tt.warn('get() | cannot get "%s" parameter in runtime',n);return}}set(n,a){switch(n){case"authorization_user":{this._configuration.authorization_user=String(a);break}case"password":{this._configuration.password=String(a);break}case"realm":{this._configuration.realm=String(a);break}case"ha1":{this._configuration.ha1=String(a),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(a);break}case"display_name":{this._configuration.display_name=a;break}default:return tt.warn('set() | cannot set "%s" parameter in runtime',n),!1}return!0}newTransaction(n){this._transactions[n.type][n.id]=n,this.emit("newTransaction",{transaction:n})}destroyTransaction(n){delete this._transactions[n.type][n.id],this.emit("transactionDestroyed",{transaction:n})}newDialog(n){this._dialogs[n.id]=n}destroyDialog(n){delete this._dialogs[n.id]}newMessage(n,a){this._applicants[n]=n,this.emit("newMessage",a)}newOptions(n,a){this._applicants[n]=n,this.emit("newOptions",a)}destroyMessage(n){delete this._applicants[n]}newRTCSession(n,a){this._sessions[n.id]=n,this.emit("newRTCSession",a)}destroyRTCSession(n){delete this._sessions[n.id]}registered(n){this.emit("registered",n)}unregistered(n){this.emit("unregistered",n)}registrationFailed(n){this.emit("registrationFailed",n)}receiveRequest(n){const a=n.method;if(n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){tt.debug("Request-URI does not point to us"),n.method!==It.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===It.SIPS){n.reply_sl(416);return}if(tu.checkTransaction(this,n))return;if(a===It.INVITE?new tu.InviteServerTransaction(this,this._transport,n):a!==It.ACK&&a!==It.CANCEL&&new tu.NonInviteServerTransaction(this,this._transport,n),a===It.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new Df(this).init_incoming(n)}else if(a===It.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new Of(this).init_incoming(n)}else if(a===It.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let e,o;if(n.to_tag)e=this._findDialog(n.call_id,n.from_tag,n.to_tag),e?e.receiveRequest(n):a===It.NOTIFY?(o=this._findSession(n),o?o.receiveRequest(n):(tt.debug("received NOTIFY request for a non existent subscription"),n.reply(481,"Subscription does not exist"))):a!==It.ACK&&n.reply(481);else switch(a){case It.INVITE:if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const p=n.replaces;e=this._findDialog(p.call_id,p.from_tag,p.to_tag),e?(o=e.owner,o.isEnded()?n.reply(603):o.receiveRequest(n)):n.reply(481)}else o=new wf(this),o.init_incoming(n);else tt.warn("INVITE received but WebRTC is not supported"),n.reply(488);break;case It.BYE:n.reply(481);break;case It.CANCEL:o=this._findSession(n),o?o.receiveRequest(n):tt.debug("received CANCEL request for a non existent session");break;case It.ACK:break;case It.NOTIFY:this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break;default:n.reply(405);break}}_findSession({call_id:n,from_tag:a,to_tag:e}){const o=n+a,p=this._sessions[o],t=n+e,v=this._sessions[t];return p||v||null}_findDialog(n,a,e){let o=n+a+e,p=this._dialogs[o];return p||(o=n+e+a,p=this._dialogs[o],p||null)}_loadConfig(n){try{nu.load(this._configuration,n)}catch(o){throw o}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Ra.newUUID()),this._configuration.jssip_id=Ra.createRandomToken(5);const a=this._configuration.uri.clone();a.user=null,this._configuration.hostport_params=a.toString().replace(/^sip:/i,"");try{this._transport=new Tv(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=yv.bind(this),this._transport.onconnect=Rv.bind(this),this._transport.ondisconnect=bv.bind(this),this._transport.ondata=Iv.bind(this)}catch(o){throw tt.warn(o),new Ev.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 o=this._configuration.uri.clone();o.user=null,o.clearParams(),o.clearHeaders(),this._configuration.registrar_server=o}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Cv("sip",Ra.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(o={}){const p=o.anonymous||null,t=o.outbound||null;let v="<";return p?v+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":v+=this.pub_gruu||this.uri.toString(),t&&(p?!this.temp_gruu:!this.pub_gruu)&&(v+=";ob"),v+=">",v}};const e=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const o in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,o)&&(e.indexOf(o)!==-1?Object.defineProperty(this._configuration,o,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,o,{writable:!1,configurable:!1}));tt.debug("configuration parameters after validation:");for(const o in this._configuration)if(Object.prototype.hasOwnProperty.call(nu.settings,o))switch(o){case"uri":case"registrar_server":tt.debug(`- ${o}: ${this._configuration[o]}`);break;case"password":case"ha1":case"authorization_jwt":tt.debug(`- ${o}: NOT SHOWN`);break;default:tt.debug(`- ${o}: ${JSON.stringify(this._configuration[o])}`)}}};function yv(u){this.emit("connecting",u)}function Rv(u){this._status!==Dt.STATUS_USER_CLOSED&&(this._status=Dt.STATUS_READY,this._error=null,this.emit("connected",u),this._dynConfiguration.register&&this._registrator.register())}function bv(u){const n=["nict","ict","nist","ist"];for(const a of n)for(const e in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],e)&&this._transactions[a][e].onTransportError();this.emit("disconnected",u),this._registrator.onTransportClosed(),this._status!==Dt.STATUS_USER_CLOSED&&(this._status=Dt.STATUS_NOT_READY,this._error=Dt.NETWORK_ERROR)}function Iv(u){console.log("onTransportData",u);const n=u.transport;let a=u.message;if(a=Sv.parseMessage(a,this),!!a&&!(this._status===Dt.STATUS_USER_CLOSED&&a instanceof su.IncomingRequest)&&Av(a,this,n)){if(a instanceof su.IncomingRequest)a.transport=n,this.receiveRequest(a);else if(a instanceof su.IncomingResponse){let e;switch(a.method){case It.INVITE:e=this._transactions.ict[a.via_branch],e&&e.receiveResponse(a);break;case It.ACK:break;default:e=this._transactions.nict[a.via_branch],e&&e.receiveResponse(a);break}}}}const wv=ot(Oh);var Rt=[];for(var lu=0;lu<256;++lu)Rt.push((lu+256).toString(16).slice(1));function Ov(u,n=0){return(Rt[u[n+0]]+Rt[u[n+1]]+Rt[u[n+2]]+Rt[u[n+3]]+"-"+Rt[u[n+4]]+Rt[u[n+5]]+"-"+Rt[u[n+6]]+Rt[u[n+7]]+"-"+Rt[u[n+8]]+Rt[u[n+9]]+"-"+Rt[u[n+10]]+Rt[u[n+11]]+Rt[u[n+12]]+Rt[u[n+13]]+Rt[u[n+14]]+Rt[u[n+15]]).toLowerCase()}var ba,Dv=new Uint8Array(16);function Nv(){if(!ba&&(ba=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ba))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ba(Dv)}var Uv=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Nf={randomUUID:Uv};function Uf(u,n,a){if(Nf.randomUUID&&!n&&!u)return Nf.randomUUID();u=u||{};var e=u.random||(u.rng||Nv)();if(e[6]=e[6]&15|64,e[8]=e[8]&63|128,n){a=a||0;for(var o=0;o<16;++o)n[a+o]=e[o];return n}return Ov(e)}var Ge=xt();const Fn=ot(Ge),ru=new co("Dialog"),Gl={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};class Ia{static get C(){return Gl}constructor(n,a,e,o=Gl.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,a instanceof Ft.IncomingResponse&&(o=a.status_code<200?Gl.STATUS_EARLY:Gl.STATUS_CONFIRMED),e==="UAS"){this._id={call_id:a.call_id,local_tag:a.to_tag,remote_tag:a.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._remote_seqnum=a.cseq,this._local_uri=a.parseHeader("to").uri,this._remote_uri=a.parseHeader("from").uri;let p=a.getHeaders("to")[0].split(";")[0];p=p.match(/<([^>]*)>/)[1],this._remote_target=p,this._route_set=a.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum}else if(e==="UAC"){this._id={call_id:a.call_id,local_tag:a.from_tag,remote_tag:a.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._local_seqnum=a.cseq,this._local_uri=a.parseHeader("from").uri,this._remote_uri=a.parseHeader("to").uri;let p=a.getHeaders("to")[0].split(";")[0];p=p.match(/<([^>]*)>/)[1],this._remote_target=p,this._route_set=a.getHeaders("record-route").reverse(),this._ack_seqnum=null}this._ua.newDialog(this),ru.debug(`new ${e} dialog created with status ${this._state===Gl.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(n){this._local_seqnum=n}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(n){this._uac_pending_reply=n}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Gl.STATUS_TERMINATED}update(n,a){this._state=Gl.STATUS_CONFIRMED,ru.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),a==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){ru.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Gl.STATUS_TERMINATED}sendRequest(n,a={}){const e=Fn.cloneArray(a.extraHeaders),o=Fn.cloneObject(a.eventHandlers),p=a.body||null,t=this._createRequest(n,e,p);return o.onAuthenticated=()=>{this._local_seqnum+=1},new hg(this,t,o).send(),t}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===z.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===z.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,a,e){a=Fn.cloneArray(a),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const o=n===z.CANCEL||n===z.ACK?this._local_seqnum:this._local_seqnum+=1;return new Ft.OutgoingRequest(n,this._remote_target,this._ua,{cseq:o,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},a,e)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===z.ACK){if(this._ack_seqnum===null||n.cseq!==this._ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===z.INVITE||n.method===z.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const a=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${a}`]),!1}else{this._uas_pending_reply=!0;const a=()=>{(n.server_transaction.state===Ss.C.STATUS_ACCEPTED||n.server_transaction.state===Ss.C.STATUS_COMPLETED||n.server_transaction.state===Ss.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",a),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",a)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Ss.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===z.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Ss.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}}class xv{constructor(n,a){Fs(this,"plugin",null);Fs(this,"rtcpPeer",null);Fs(this,"handleId",0);Fs(this,"info",null);Fs(this,"joinResult",null);Fs(this,"state",{});Fs(this,"stream",null);Fs(this,"loaded",!1);Fs(this,"aTracks",[]);Fs(this,"vTracks",[]);this.info=n,this.plugin=a,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(n){var a;this.state={...this.state,...n||{}},(a=this.plugin)==null||a.session.emit("member:update",this.memberInfo)}updateMemberStateFromMessage(n){var p,t,v,C;const a=(t=(p=n==null?void 0:n.plugindata)==null?void 0:p.data)==null?void 0:t.newStatePublisher,o=((C=(v=n==null?void 0:n.plugindata)==null?void 0:v.data)==null?void 0:C.publisher_state).find(l=>l.id===a);this.updateMemberState(o==null?void 0:o.state)}hangup(){this.rtcpPeer&&(this.rtcpPeer.close(),this.rtcpPeer=null),this.stream&&this.stream.getTracks().forEach(n=>{n.stop()})}}var Pv=Bn();const Yl=ot(Pv),le=new co("JanusSession"),Mv="/opt/recordings/",ae={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},wa=["audio","video"];class no extends At.EventEmitter{static get C(){return ae}constructor(n){le.debug("new"),super(),console.log("constructor call"),this._id=null,this._ua=n,this._status=ae.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:z.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 a=Uf().replace(/-/g,"").slice(0,12);this.opaque_id=`videoroomtest-${a}`,this._data={}}get C(){return ae}get causes(){return z.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(n){this._data=n}get status(){return this._status}isInProgress(){switch(this._status){case ae.STATUS_NULL:case ae.STATUS_INVITE_SENT:case ae.STATUS_1XX_RECEIVED:case ae.STATUS_INVITE_RECEIVED:case ae.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case ae.STATUS_ANSWERED:case ae.STATUS_WAITING_FOR_ACK:case ae.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case ae.STATUS_CANCELED:case ae.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(n,a,e={},o){le.debug("connect()"),this.display_name=a;const p=n,t=Ge.cloneObject(e.eventHandlers),v=Ge.cloneArray(e.extraHeaders),C=Ge.cloneObject(e.mediaConstraints,{audio:!0,video:!0}),l=e.mediaStream||null,A=Ge.cloneObject(e.pcConfig,{iceServers:[]}),b=e.rtcConstraints||null,E=e.rtcOfferConstraints||null;if(this._rtcOfferConstraints=E,this._rtcAnswerConstraints=e.rtcAnswerConstraints||null,this._data=e.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==ae.STATUS_NULL)throw new Kl.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Kl.NotSupportedError("WebRTC not supported");if(console.log("target",n),n=this._ua.normalizeTarget(n),console.log("normalizeTarget target",n),this.room_id=n.user,!n)throw new TypeError(`Invalid target: ${p}`);this._sessionTimers.enabled&&Ge.isDecimal(e.sessionTimersExpires)&&(e.sessionTimersExpires>=z.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=e.sessionTimersExpires:this._sessionTimers.defaultExpires=z.SESSION_EXPIRES);for(const N in t)Object.prototype.hasOwnProperty.call(t,N)&&this.on(N,t[N]);this._from_tag=Ge.newTag();const O=e.anonymous||!1,w={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:O,outbound:!0}),O?(w.from_display_name="Anonymous",w.from_uri=new Yl("sip","anonymous","anonymous.invalid"),v.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),v.push("Privacy: id")):e.fromUserName&&(w.from_uri=new Yl("sip",e.fromUserName,this._ua.configuration.uri.host),v.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),e.fromDisplayName&&(w.from_display_name=e.fromDisplayName),v.push(`Contact: ${this._contact}`),v.push("Content-Type: application/json"),this._sessionTimers.enabled&&v.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Ft.InitialOutgoingInviteRequest(n,this._ua,w,v),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(A,b),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,console.log("this._remote_identity",this._remote_identity),o&&o(this),this._newJanusSession("local",this._request),this._sendInitialRequest(C,E,l)}init_incoming(n,a){le.debug("init_incoming()");let e;const o=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&o!=="application/sdp"){n.reply(415);return}if(this._status=ae.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(e=n.getHeader("expires")*1e3),n.to_tag=Ge.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ae.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,z.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),e&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ae.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,z.causes.EXPIRES))},e)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,a&&a(this),this._newJanusSession("remote",n),this._status!==ae.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){le.debug("answer()");const a=this._request,e=Ge.cloneArray(n.extraHeaders),o=Ge.cloneObject(n.mediaConstraints),p=n.mediaStream||null,t=Ge.cloneObject(n.pcConfig,{iceServers:[]}),v=n.rtcConstraints||null,C=n.rtcAnswerConstraints||null,l=Ge.cloneObject(n.rtcOfferConstraints);let A,b=!1,E=!1,O=!1,w=!1;if(this._rtcAnswerConstraints=C,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new Kl.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==ae.STATUS_WAITING_FOR_ANSWER)throw new Kl.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Ge.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=z.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=z.SESSION_EXPIRES),this._status=ae.STATUS_ANSWERED,!this._createDialog(a,"UAS")){a.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),e.unshift(`Contact: ${this._contact}`);const N=a.parseSDP();Array.isArray(N.media)||(N.media=[N.media]);for(const U of N.media)U.type==="audio"&&(b=!0,(!U.direction||U.direction==="sendrecv")&&(O=!0)),U.type==="video"&&(E=!0,(!U.direction||U.direction==="sendrecv")&&(w=!0));if(p&&o.audio===!1){A=p.getAudioTracks();for(const U of A)p.removeTrack(U)}if(p&&o.video===!1){A=p.getVideoTracks();for(const U of A)p.removeTrack(U)}!p&&o.audio===void 0&&(o.audio=O),!p&&o.video===void 0&&(o.video=w),!p&&!b&&!l.offerToReceiveAudio&&(o.audio=!1),!p&&!E&&!l.offerToReceiveVideo&&(o.video=!1),this._createRTCConnection(t,v),Promise.resolve().then(()=>{if(p)return p;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(U=>{throw this._status===ae.STATUS_TERMINATED?new Error("terminated"):(a.reply(480),this._failed("local",null,z.causes.USER_DENIED_MEDIA_ACCESS),le.warn('emit "getusermediafailed" [error:%o]',U),this.emit("getusermediafailed",U),new Error("getUserMedia() failed"))})}).then(U=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=U,U&&U.getTracks().forEach(Y=>{this._connection.addTrack(Y,U)})}).then(()=>{if(this._late_sdp)return;const U={originator:"remote",type:"offer",sdp:a.body};le.debug('emit "sdp"'),this.emit("sdp",U);const Y=new RTCSessionDescription({type:"offer",sdp:U.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(Y)).catch(j=>{throw a.reply(488),this._failed("system",null,z.causes.WEBRTC_ERROR),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',j),this.emit("peerconnection:setremotedescriptionfailed",j),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(a),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",C).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")})}).then(U=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(a,e),a.reply(200,null,e,U,()=>{this._status=ae.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(a,U),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,z.causes.CONNECTION_ERROR)})}).catch(U=>{this._status!==ae.STATUS_TERMINATED&&le.warn(U)})}terminate(n={}){le.debug("terminate()");const a=n.cause||z.causes.BYE,e=Ge.cloneArray(n.extraHeaders),o=n.body;let p,t=n.status_code,v=n.reason_phrase;if(this._status===ae.STATUS_TERMINATED)throw new Kl.InvalidStateError(this._status);switch(this._status){case ae.STATUS_NULL:case ae.STATUS_INVITE_SENT:case ae.STATUS_1XX_RECEIVED:if(le.debug("canceling session"),t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);t&&(v=v||z.REASON_PHRASE[t]||"",p=`SIP ;cause=${t} ;text="${v}"`),this._status===ae.STATUS_NULL||this._status===ae.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=p):this._status===ae.STATUS_1XX_RECEIVED&&this._request.cancel(p),this._status=ae.STATUS_CANCELED,this._failed("local",null,z.causes.CANCELED);break;case ae.STATUS_WAITING_FOR_ANSWER:case ae.STATUS_ANSWERED:if(le.debug("rejecting session"),t=t||480,t<300||t>=700)throw new TypeError(`Invalid status_code: ${t}`);this._request.reply(t,v,e,o),this._failed("local",null,z.causes.REJECTED);break;case ae.STATUS_WAITING_FOR_ACK:case ae.STATUS_CONFIRMED:if(le.debug("terminating session"),v=n.reason_phrase||z.REASON_PHRASE[t]||"",t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);if(t&&e.push(`Reason: SIP ;cause=${t}; text="${v}"`),this._status===ae.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ss.C.STATUS_TERMINATED){const C=this._dialog;this.receiveRequest=({method:l})=>{l===z.ACK&&(this.sendRequest(z.BYE,{extraHeaders:e,body:o}),C.terminate(),this.closeSession())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Ss.C.STATUS_TERMINATED&&(this.sendRequest(z.BYE,{extraHeaders:e,body:o}),C.terminate(),this.closeSession())}),this._ended("local",null,a),this._dialog=C,console.log("SET DIALOG terminate"),this._ua.newDialog(C)}else{const C={janus:"leave"},l=["Content-Type: application/json","PTYPE: Leave"];this.sendRequest(z.BYE,{extraHeaders:l,body:JSON.stringify(C)}),this.closeSession(),this._ended("local",null,a)}}}sendInfo(n,a,e={}){if(le.debug("sendInfo()"),this._status!==ae.STATUS_CONFIRMED&&this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_1XX_RECEIVED)throw new Kl.InvalidStateError(this._status);new Ru(this).send(n,a,e)}mute(n={audio:!0,video:!1}){le.debug("mute()");let a=!1,e=!1;this._audioMuted===!1&&n.audio&&(a=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(e=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(a===!0||e===!0)&&this._onmute({audio:a,video:e})}unmute(n={audio:!0,video:!0}){le.debug("unmute()");let a=!1,e=!1;this._audioMuted===!0&&n.audio&&(a=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(e=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(a===!0||e===!0)&&this._onunmute({audio:a,video:e})}hold(n={},a){if(le.debug("hold()"),this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:z.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}unhold(n={},a){if(le.debug("unhold()"),this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:z.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},a){le.debug("renegotiate()");const e=n.rtcOfferConstraints||null;if(this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const o={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:z.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}),!0}refer(n,a){le.debug("refer()");const e=n;if(this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${e}`);const o=new Ng(this);o.sendRefer(n,a);const p=o.id;return this._referSubscribers[p]=o,o.on("requestFailed",()=>{delete this._referSubscribers[p]}),o.on("accepted",()=>{delete this._referSubscribers[p]}),o.on("failed",()=>{delete this._referSubscribers[p]}),o}sendRequest(n,a){return le.debug("sendRequest()"),this._dialog.sendRequest(n,a)}receiveNotify(n){le.debug("receiveRequest()")}receiveRequest(n){if(le.debug("receiveRequest()"),n.method===z.CANCEL)(this._status===ae.STATUS_WAITING_FOR_ANSWER||this._status===ae.STATUS_ANSWERED)&&(this._status=ae.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,z.causes.CANCELED));else switch(n.method){case z.ACK:if(this._status!==ae.STATUS_WAITING_FOR_ACK)return;if(this._status=ae.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:z.causes.MISSING_SDP,status_code:400});break}const a={originator:"remote",type:"answer",sdp:n.body};le.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(o=>{this.terminate({cause:z.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})}else this._is_confirmed||this._confirmed("remote",n);break;case z.BYE:this._status===ae.STATUS_CONFIRMED||this._status===ae.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,z.causes.BYE)):this._status===ae.STATUS_INVITE_RECEIVED||this._status===ae.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,z.causes.BYE)):n.reply(403,"Wrong Status");break;case z.INVITE:this._status===ae.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case z.INFO:if(this._status===ae.STATUS_1XX_RECEIVED||this._status===ae.STATUS_WAITING_FOR_ANSWER||this._status===ae.STATUS_ANSWERED||this._status===ae.STATUS_WAITING_FOR_ACK||this._status===ae.STATUS_CONFIRMED){const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;a&&a.match(/^application\/dtmf-relay/i)?new Eg(this).init_incoming(n):a!==void 0?new Ru(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break;case z.UPDATE:this._status===ae.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case z.REFER:this._status===ae.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case z.NOTIFY:this._status===ae.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){le.warn("onTransportError()"),this._status!==ae.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:z.causes.CONNECTION_ERROR,cause:z.causes.CONNECTION_ERROR})}onRequestTimeout(){le.warn("onRequestTimeout()"),this._status!==ae.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:z.causes.REQUEST_TIMEOUT,cause:z.causes.REQUEST_TIMEOUT})}onDialogError(){le.warn("onDialogError()"),this._status!==ae.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:z.causes.DIALOG_ERROR,cause:z.causes.DIALOG_ERROR})}newDTMF(n){le.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){le.debug("newInfo()"),this.emit("newInfo",n)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(le.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(le.debug("_isReadyToReOffer() | session not established yet"),!1):(le.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(le.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(le.debug("close() | closing local MediaStream"),Ge.closeMediaStream(this._localMediaStream)),this._status!==ae.STATUS_TERMINATED){if(this._status=ae.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){le.warn("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(n,a){let e=yi.T1;function o(){this._status===ae.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],a),e<yi.T2&&(e=e*2,e>yi.T2&&(e=yi.T2)),this._timers.invite2xxTimer=setTimeout(o.bind(this),e))}this._timers.invite2xxTimer=setTimeout(o.bind(this),e)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===ae.STATUS_WAITING_FOR_ACK&&(le.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(z.BYE),this._ended("remote",null,z.causes.NO_ACK))},yi.TIMER_H)}_createRTCConnection(n,a){this.stunServers,this._connection=new RTCPeerConnection(n,a),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:z.causes.RTP_TIMEOUT,status_code:408,reason_phrase:z.causes.RTP_TIMEOUT})});let e;const o=p=>{this._connection.signalingState!=="stable"&&this._connection.signalingState!=="have-local-offer"||p.candidate&&(this._candidates.push(p.candidate),clearTimeout(e),e=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=o,le.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,a){if(le.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const e=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?e.createOffer(a).catch(o=>(le.warn('emit "peerconnection:createofferfailed" [error:%o]',o),this.emit("peerconnection:createofferfailed",o),Promise.reject(o))):e.createAnswer(a).catch(o=>(le.warn('emit "peerconnection:createanswerfailed" [error:%o]',o),this.emit("peerconnection:createanswerfailed",o),Promise.reject(o)))).then(o=>e.setLocalDescription(o).catch(p=>(this._rtcReady=!0,le.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',p),this.emit("peerconnection:setlocaldescriptionfailed",p),Promise.reject(p)))).then(()=>{const o=a&&a.iceRestart;if(e.iceGatheringState==="complete"&&!o||e.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const p={originator:"local",type:n,sdp:e.localDescription.sdp};return le.debug('emit "sdp"'),this.emit("sdp",p),Promise.resolve(p.sdp)}return new Promise(p=>{let t=!1,v,C;this._iceReady=!1;const l=()=>{e.removeEventListener("icecandidate",v),e.removeEventListener("icegatheringstatechange",C),t=!0,this._rtcReady=!0,this._iceReady=!0;const A={originator:"local",type:n,sdp:e.localDescription.sdp};le.debug('emit "sdp"'),this.emit("sdp",A),p(A.sdp)};e.addEventListener("icecandidate",v=A=>{const b=A.candidate;b?this.emit("icecandidate",{candidate:b,ready:l}):t||l()}),e.addEventListener("icegatheringstatechange",C=()=>{e.iceGatheringState==="complete"&&!t&&l()})})})}_createDialog(n,a,e){console.log("_createDialog",n);const o=a==="UAS"?n.to_tag:n.from_tag,p=a==="UAS"?n.from_tag:n.to_tag,t=n.call_id+o+p;console.log("remote_tag",p);let v=this._earlyDialogs[t];if(e)return v?!0:(v=new Ia(this,n,a,Ia.C.STATUS_EARLY),console.log("SET DIALOG early"),v.error?(console.log("early_dialog error",v.error),le.debug(v.error),this._failed("remote",n,z.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[t]=v,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,v)return v.update(n,a),console.log("SET DIALOG 1"),this._dialog=v,delete this._earlyDialogs[t],!0;const C=new Ia(this,n,a);return C.error?(console.log("dialog.error",C.error),le.debug(C.error),this._failed("remote",n,z.causes.INTERNAL_ERROR),!1):(console.log("AAA SET DIALOG 2"),this._dialog=C,!0)}}_receiveReinvite(n){le.debug("receiveReinvite()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=Ge.cloneArray(v.extraHeaders);if(this._status!==ae.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("reinvite",e),o)return;if(this._late_sdp=!1,!n.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(v=>{t.call(this,v)}).catch(()=>{n.reply(500)});return}if(a!=="application/sdp"){le.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ae.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{le.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),this._late_sdp&&(v=this._mangleOffer(v)),n.reply(200,null,C,v,()=>{this._status=ae.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,v),this._setACKTimer()}),typeof e.callback=="function"&&e.callback()}}_receiveUpdate(n){le.debug("receiveUpdate()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=Ge.cloneArray(v.extraHeaders);if(this._status!==ae.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("update",e),o)return;if(!n.body){t.call(this,null);return}if(a!=="application/sdp"){le.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ae.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{le.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),n.reply(200,null,C,v),typeof e.callback=="function"&&e.callback()}}_processInDialogSdpOffer(n){le.debug("_processInDialogSdpOffer()");const a=n.parseSDP();let e=!1;for(const t of a.media){if(wa.indexOf(t.type)===-1)continue;const v=t.direction||a.direction||"sendrecv";if(v==="sendonly"||v==="inactive")e=!0;else{e=!1;break}}const o={originator:"remote",type:"offer",sdp:n.body};le.debug('emit "sdp"'),this.emit("sdp",o);const p=new RTCSessionDescription({type:"offer",sdp:o.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(p).catch(t=>{throw n.reply(488),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),this.emit("peerconnection:setremotedescriptionfailed",t),t})}).then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&e===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&e===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(t=>{throw n.reply(500),le.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t})}).catch(t=>{le.warn("_processInDialogSdpOffer() failed [error: %o]",t)}),this._connectionPromiseQueue}_receiveRefer(n){if(le.debug("receiveRefer()"),!n.refer_to){le.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==z.SIP){le.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const a=new Ig(this,n.cseq);le.debug('emit "refer"'),this.emit("refer",{request:n,accept:(p,t)=>{e.call(this,p,t)},reject:()=>{o.call(this)}});function e(p,t={}){if(p=typeof p=="function"?p:null,this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED)return!1;const v=new no(this._ua);if(v.on("progress",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("accepted",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("_failed",({message:C,cause:l})=>{C?a.notify(C.status_code,C.reason_phrase):a.notify(487,l)}),n.refer_to.uri.hasHeader("replaces")){const C=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));t.extraHeaders=Ge.cloneArray(t.extraHeaders),t.extraHeaders.push(`Replaces: ${C}`)}v.connect(n.refer_to.uri.toAor(),t,p)}function o(){a.notify(603)}}_receiveNotify(n){switch(le.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let a,e;if(n.event.params&&n.event.params.id)a=n.event.params.id,e=this._referSubscribers[a];else if(Object.keys(this._referSubscribers).length===1)e=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!e){n.reply(481,"Subscription does not exist");return}e.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){le.debug("receiveReplaces()");function a(o){if(this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED)return!1;const p=new no(this._ua);p.on("confirmed",()=>{this.terminate()}),p.init_incoming(n,o)}function e(){le.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:o=>{a.call(this,o)},reject:()=>{e.call(this)}})}_getNextTransactionId(){return(this.lastTransaction+1).toString()}_sendInitialRequest(n,a,e){this.ackSent=!1,this.publisherSubscribeSent=!1;const o=new so(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:p=>{this._request=p},onReceiveResponse:p=>{this._receiveInviteResponse(p)}});Promise.resolve().then(()=>{if(e)return e;if(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(p=>{throw this._status===ae.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,z.causes.USER_DENIED_MEDIA_ACCESS),le.warn('emit "getusermediafailed" [error:%o]',p),this.emit("getusermediafailed",p),p)})}).then(p=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=p,p&&p.getTracks().forEach(t=>{this._connection.addTrack(t,p)}),this._connecting(this._request),this._createLocalDescription("offer",a).catch(t=>{throw this._failed("local",null,z.causes.WEBRTC_ERROR),t})}).then(p=>{if(this._is_canceled||this._status===ae.STATUS_TERMINATED)throw new Error("terminated");const t={janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:this.opaque_id},v=JSON.stringify(t);this._request.body=v,this._status=ae.STATUS_INVITE_SENT,le.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),o.send()}).catch(p=>{this._status!==ae.STATUS_TERMINATED&&le.warn(p)})}requestAudioAndVideoPermissions(){return this.loadStream()}async loadStream(){const n={audio:!0,video:!0};try{this.stream=await navigator.mediaDevices.getUserMedia(n)}catch{try{n.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(n)}catch{n.audio=!1,n.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(n)}}return{stream:this.stream,options:n}}addTracks(n){n.forEach(a=>{this._connection.addTrack(a)})}getRecordFileName(){return Mv+this.room_id+btoa(unescape(encodeURIComponent(this.displayName)))+Date.now()}async processIceCandidates(){for(let n=0;n<this.iceCandidates.length;n++)await this._connection.addIceCandidate(this.iceCandidates[n]);this.iceCandidates=[]}async _sendConfigureMessage(n){const a={offerToReceiveAudio:!1,offerToReceiveVideo:!1},e=await this._connection.createOffer(a);await this._connection.setLocalDescription(e);const o=this._candidates.map(C=>({janus:"trickle",candidate:C,handle_id:this.handle_id,session_id:this.session_id})),t={configure:{janus:"message",body:{request:"configure",record:!0,filename:this.getRecordFileName(),...n},jsep:e,handle_id:this.handle_id,session_id:this.session_id},trickles:[...o]},v=["Content-Type: application/json","PTYPE: Ice"];this.sendRequest(z.INFO,{extraHeaders:v,body:JSON.stringify(t),eventHandlers:{onSuccessResponse:async C=>{this.isConfigureSent=!0;const A=C.data.split(`\r
135
+ `),b=A[A.length-1],E=JSON.parse(b);await this._connection.setRemoteDescription(E.jsep),this._candidates=[]}}})}_sendMemberStartMessage(n,a){const e={janus:"message",body:{request:"start",room:this.room_id},handle_id:n.handleId,session_id:this.session_id,jsep:a},o=["Content-Type: application/json","PTYPE: Configure"];this.sendRequest(z.INFO,{extraHeaders:o,body:JSON.stringify(e),eventHandlers:{onSuccessResponse:async p=>{p.status_code===200&&await n.rtcpPeer.setLocalDescription(a)}}})}_sendTrickleMessage(n){const e={trickles:[...n.map(p=>({janus:"trickle",candidate:p,handle_id:this.handle_id,session_id:this.session_id}))]},o=["PTYPE: Trickle"];this.sendRequest(z.INFO,{extraHeaders:o,body:JSON.stringify(e),eventHandlers:{onSuccessResponse:async p=>{console.log("_sendTrickleMessage",p)}}})}async _answerAttachedStream(n,a){let e=null;const o=async C=>{if(!n.rtcpPeer||n.loaded)return;{n.loaded=!0;const O={audio:!0,video:!0};await new Promise(w=>{setTimeout(w,100)}),e=await n.rtcpPeer.createAnswer(O),this._sendMemberStartMessage(n,e)}const l=C.streams[0].getAudioTracks(),A=C.streams[0].getVideoTracks(),b=[];l[0]&&b.push(l[0]),A[0]&&b.push(A[0]);const E=new MediaStream(b);n.stream=E,this._ua.emit("memberJoin",n.memberInfo)};let p,t=[];const v=C=>{n.rtcpPeer.signalingState!=="stable"&&n.rtcpPeer.signalingState!=="have-local-offer"||(t.push(C.candidate||null),clearTimeout(p),p=setTimeout(()=>{this._sendTrickleMessage(t)},500))};n.rtcpPeer=new RTCPeerConnection,n.rtcpPeer.ontrack=o,n.rtcpPeer.onicecandidate=v,n.rtcpPeer.sender=a.sender,await n.rtcpPeer.setRemoteDescription(a.jsep)}_sendJoinMemberRequest(n){const a={janus:"message",body:{request:"join",room:this.room_id,feed:n.info.id,ptype:"subscriber"},handle_id:n.handleId,session_id:this.session_id},e=["PTYPE: Subscriber"];this.sendRequest(z.SUBSCRIBE,{extraHeaders:e,body:JSON.stringify(a),eventHandlers:{onSuccessResponse:async o=>{var p,t;if(o.status_code===200){const v=JSON.parse(o.body);(t=(p=v==null?void 0:v.plugindata)==null?void 0:p.data)!=null&&t.id&&await this._answerAttachedStream(n,v)}}}})}_attachMember(n){const a={janus:"attach",opaque_id:this.opaque_id,plugin:"janus.plugin.videoroom",session_id:this.session_id},e=["PTYPE: Subscriber"];this.sendRequest(z.INFO,{extraHeaders:e,body:JSON.stringify(a),eventHandlers:{onSuccessResponse:async o=>{if(o.status_code===200){const t=JSON.parse(o.body).data.id;n.handleId=t,this._sendJoinMemberRequest(n)}}}})}_detachMember(n){const a={janus:"detach",handle_id:n.handleId,session_id:this.session_id},e=["PTYPE: Subscriber"];this.sendRequest(z.INFO,{extraHeaders:e,body:JSON.stringify(a)}),this._ua.emit("memberHangup",n.memberInfo)}receivePublishers(n){var e,o,p,t,v,C,l,A;const a={...this.memberList};(o=(e=n==null?void 0:n.plugindata)==null?void 0:e.data)==null||o.publishers.forEach(b=>{delete a[b.id],!this.memberList[b.id]&&!this.myFeedList.includes(b.id)&&b.clientID!==this.client_id&&(this.memberList[b.id]=new xv(b,this),this._attachMember(this.memberList[b.id]))}),((t=(p=n==null?void 0:n.plugindata)==null?void 0:p.data)==null?void 0:t.videoroom)==="synced"&&Object.keys(a).forEach(b=>{a[b].hangup(),delete this.memberList[b]}),this.publishers=(C=(v=n==null?void 0:n.plugindata)==null?void 0:v.data)==null?void 0:C.publishers,this.private_id=(A=(l=n==null?void 0:n.plugindata)==null?void 0:l.data)==null?void 0:A.private_id}receiveUnpublished(n){const a=this.memberList[n];a&&(a.hangup(),this._detachMember(a),delete this.memberList[n])}closeSession(){this.stream&&this.stream.getTracks().forEach(a=>{a.stop()}),Object.values(this.memberList).forEach(a=>{a.hangup(),this._detachMember(a)})}_receiveInviteResponse(n){if(le.debug("receiveInviteResponse()"),console.log("_receiveInviteResponse response",n),console.log("dialog",this._dialog),this._dialog&&n.status_code>=200&&n.status_code<=299&&!this.ackSent)if(console.log("IF 1 dialog"),this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.ackSent=!0,this.sendRequest(z.ACK);return}else{const a=new Ia(this,n,"UAC");if(a.error!==void 0){le.debug(a.error);return}this.sendRequest(z.ACK),this.sendRequest(z.BYE);return}if(this.ackSent&&!this.publisherSubscribeSent){const a=JSON.parse(n.body);this.requestAudioAndVideoPermissions().then(()=>{this.session_id=a.session_id,this.handle_id=a.data.id,this.client_id=Uf();const e={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},o=["PTYPE: Publisher"];this.sendRequest(z.SUBSCRIBE,{extraHeaders:o,body:JSON.stringify(e),eventHandlers:{onSuccessResponse:async p=>{var t,v;if(p.status_code===200){if(this.subscribeSent=!0,p.body)try{const C=JSON.parse(p.body)||{};(v=(t=C.plugindata)==null?void 0:t.data)!=null&&v.publishers&&this.receivePublishers(C)}catch(C){console.error(C)}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){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==ae.STATUS_INVITE_SENT&&this._status!==ae.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):this._status=ae.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){le.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=ae.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const a={originator:"remote",type:"answer",sdp:n.body};le.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>this._progress("remote",n)).catch(o=>{le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=ae.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,z.causes.MISSING_SDP),this._failed("remote",n,z.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;break}default:{const a=Ge.sipErrorCause(n.status_code);this._failed("remote",n,a)}}}_sendReinvite(n={}){le.debug("sendReinvite()");const a=Ge.cloneArray(n.extraHeaders),e=Ge.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let p=!1;a.push(`Contact: ${this._contact}`),a.push("Content-Type: application/sdp"),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(C=>{C=this._mangleOffer(C);const l={originator:"local",type:"offer",sdp:C};le.debug('emit "sdp"'),this.emit("sdp",l),this.sendRequest(z.INVITE,{extraHeaders:a,body:C,eventHandlers:{onSuccessResponse:A=>{t.call(this,A),p=!0},onErrorResponse:A=>{v.call(this,A)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function t(C){if(this._status===ae.STATUS_TERMINATED||(this.sendRequest(z.ACK),p))return;if(this._handleSessionTimersInIncomingResponse(C),C.body){if(!C.hasHeader("Content-Type")||C.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const l={originator:"remote",type:"answer",sdp:C.body};le.debug('emit "sdp"'),this.emit("sdp",l);const A=new RTCSessionDescription({type:"answer",sdp:l.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(A)).then(()=>{e.succeeded&&e.succeeded(C)}).catch(b=>{v.call(this),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',b),this.emit("peerconnection:setremotedescriptionfailed",b)})}function v(C){e.failed&&e.failed(C)}}_sendUpdate(n={}){le.debug("sendUpdate()");const a=Ge.cloneArray(n.extraHeaders),e=Ge.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null,p=n.sdpOffer||!1;let t=!1;a.push(`Contact: ${this._contact}`),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),p?(a.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(l=>{l=this._mangleOffer(l);const A={originator:"local",type:"offer",sdp:l};le.debug('emit "sdp"'),this.emit("sdp",A),this.sendRequest(z.UPDATE,{extraHeaders:a,body:l,eventHandlers:{onSuccessResponse:b=>{v.call(this,b),t=!0},onErrorResponse:b=>{C.call(this,b)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{C.call(this)})):this.sendRequest(z.UPDATE,{extraHeaders:a,eventHandlers:{onSuccessResponse:l=>{v.call(this,l)},onErrorResponse:l=>{C.call(this,l)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(l){if(this._status!==ae.STATUS_TERMINATED&&!t)if(this._handleSessionTimersInIncomingResponse(l),p){if(l.body){if(!l.hasHeader("Content-Type")||l.getHeader("Content-Type").toLowerCase()!=="application/sdp"){C.call(this);return}}else{C.call(this);return}const A={originator:"remote",type:"answer",sdp:l.body};le.debug('emit "sdp"'),this.emit("sdp",A);const b=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(b)).then(()=>{e.succeeded&&e.succeeded(l)}).catch(E=>{C.call(this),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else e.succeeded&&e.succeeded(l)}function C(l){e.failed&&e.failed(l)}}_acceptAndTerminate(n,a,e){le.debug("acceptAndTerminate()");const o=[];a&&(e=e||z.REASON_PHRASE[a]||"",o.push(`Reason: SIP ;cause=${a}; text="${e}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(z.ACK),this.sendRequest(z.BYE,{extraHeaders:o})),this._status=ae.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=Jt.parse(n),this._localHold&&!this._remoteHold){le.debug("mangleOffer() | me on hold, mangling offer");for(const a of n.media)wa.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="sendonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="sendonly")}else if(this._localHold&&this._remoteHold){le.debug("mangleOffer() | both on hold, mangling offer");for(const a of n.media)wa.indexOf(a.type)!==-1&&(a.direction="inactive")}else if(this._remoteHold){le.debug("mangleOffer() | remote on hold, mangling offer");for(const a of n.media)wa.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="recvonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="recvonly")}return Jt.write(n)}_setLocalMediaStatus(){let n=!0,a=!0;(this._localHold||this._remoteHold)&&(n=!1,a=!1),this._audioMuted&&(n=!1),this._videoMuted&&(a=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!a)}_handleSessionTimersInIncomingRequest(n,a){if(!this._sessionTimers.enabled)return;let e;n.session_expires&&n.session_expires>=z.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,e=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,e="uas"),a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${e}`),this._sessionTimers.refresher=e==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let a;n.session_expires&&n.session_expires>=z.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,a=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,a="uac"),this._sessionTimers.refresher=a==="uac",this._runSessionTimer()}_runSessionTimer(){const n=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==ae.STATUS_TERMINATED&&this._isReadyToReOffer()&&(le.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===z.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==ae.STATUS_TERMINATED&&(le.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:z.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="audio");for(const e of a)e.track.enabled=!n}_toggleMuteVideo(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="video");for(const e of a)e.track.enabled=!n}_newJanusSession(n,a){le.debug("newRTCSession()"),this._ua.newJanusSession(this,{originator:n,session:this,request:a})}_connecting(n){le.debug("session connecting"),le.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,a){le.debug("session progress"),le.debug('emit "progress"'),this.emit("progress",{originator:n,response:a||null})}_accepted(n,a){le.debug("session accepted"),this._start_time=new Date,le.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:a||null})}_confirmed(n,a){le.debug("session confirmed"),this._is_confirmed=!0,le.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:a||null})}_ended(n,a,e){le.debug("session ended"),this._end_time=new Date,this._close(),le.debug('emit "ended"'),this.emit("ended",{originator:n,message:a||null,cause:e})}_failed(n,a,e){le.debug("session failed"),le.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:a||null,cause:e}),this._close(),le.debug('emit "failed"'),this.emit("failed",{originator:n,message:a||null,cause:e})}_onhold(n){le.debug("session onhold"),this._setLocalMediaStatus(),le.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){le.debug("session onunhold"),this._setLocalMediaStatus(),le.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:a}){le.debug("session onmute"),this._setLocalMediaStatus(),le.debug('emit "muted"'),this.emit("muted",{audio:n,video:a})}_onunmute({audio:n,video:a}){le.debug("session onunmute"),this._setLocalMediaStatus(),le.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:a})}}class ti{constructor(n){if(this.headers={},n.length>0){let a=!1;const e=n.split(`\r
136
+ `),o=e.shift().split(/\s/);this.protocol=o[0],this.ident=o[1],this.code=o.length>3?parseInt(o[2]):0,this.method=o.length>3?o[3]:o[2],this.body="";for(const p of e){if(p==`-------${this.ident}$`)break;if(p===""){a=!0;continue}if(p&&a)this.body+=`${p}\r
137
+ `;else{const t=p.split(": ");this.addHeader(t[0],t[1].trim())}}}else this.ident=Ge.createRandomToken(12),this.protocol="MSRP"}addHeader(n,a){this.headers[n]=a}getHeader(n){return this.headers[n]}toString(){let n=`${this.protocol} ${this.ident} ${this.code} ${this.method}`.replaceAll(/null\s|undefined\s/ig,"")+`\r
138
+ `;for(const a in this.headers)n+=`${a}: ${this.headers[a]}\r
139
+ `;return this.body&&(n+=`\r
140
140
  ${this.body}\r
141
- `),s+=`-------${this.ident}$\r
142
- `,s}}const Re={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9};class Za extends ft.EventEmitter{constructor(s){super(),this._id=null,this.my_ip="127.0.0.1",this._ua=s,this.auth_id=Me.createRandomToken(10),this._status=Re.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._msgHistory=[],this.target_addr=[],this.my_addr=[],this.credentials={username:s._configuration.authorization_user,ha1:s._configuration.ha1,realm:s._configuration.realm},this._request=null,this.status="new",this.target="",this.message="",this._connectionPromiseQueue=Promise.resolve(),this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:$.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._msrpKeepAliveTimer=null}static get C(){return Re}get direction(){return this._direction}get connection(){return this._connection}get id(){return this._id}connect(s=""){s!==""&&(this._direction="outgoing"),this.target=s,this._connection=new WebSocket(`wss://${this._ua._configuration.realm}`,"msrp"),this._connection.binaryType="arraybuffer",this._connection.onopen=r=>{console.log("open",r),this.onopen()},this._connection.onclose=r=>{console.log("close",r),this.onclose()},this._connection.onmessage=r=>{console.log("msg",r),this.onmessage(r)},this._connection.onerror=r=>{console.log("error",r),this.onerror()}}_sendKeepAlive(){const s=new or("");s.method="SEND",s.addHeader("To-Path",`${this.my_addr[1]}`),s.addHeader("From-Path",`${this.my_addr[0]}`),s.addHeader("Message-ID",Me.createRandomToken(10)),this._connection.send(s.toString())}answer(){if(!this._createDialog(this._request,"UAS")){this._request.reply(500,"Error creating dialog");return}this._status=Re.STATUS_ANSWERED,clearTimeout(this._timers.userNoAnswerTimer),this.connect()}acceptParty(s){this._request.parseSDP(!0),this._request.reply(200,"OK",[],`v=0
141
+ `),n+=`-------${this.ident}$\r
142
+ `,n}}const Me={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9};class iu extends At.EventEmitter{constructor(n){super(),this._id=null,this.my_ip="127.0.0.1",this._ua=n,this.auth_id=Ge.createRandomToken(10),this._status=Me.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._msgHistory=[],this.target_addr=[],this.my_addr=[],this.credentials={username:n._configuration.authorization_user,ha1:n._configuration.ha1,realm:n._configuration.realm},this._request=null,this.status="new",this.target="",this.message="",this._connectionPromiseQueue=Promise.resolve(),this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:z.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._msrpKeepAliveTimer=null}static get C(){return Me}get direction(){return this._direction}get connection(){return this._connection}get id(){return this._id}connect(n=""){n!==""&&(this._direction="outgoing"),this.target=n,this._connection=new WebSocket(`wss://${this._ua._configuration.realm}`,"msrp"),this._connection.binaryType="arraybuffer",this._connection.onopen=a=>{console.log("open",a),this.onopen()},this._connection.onclose=a=>{console.log("close",a),this.onclose()},this._connection.onmessage=a=>{console.log("msg",a),this.onmessage(a)},this._connection.onerror=a=>{console.log("error",a),this.onerror()}}_sendKeepAlive(){const n=new ti("");n.method="SEND",n.addHeader("To-Path",`${this.my_addr[1]}`),n.addHeader("From-Path",`${this.my_addr[0]}`),n.addHeader("Message-ID",Ge.createRandomToken(10)),this._connection.send(n.toString())}answer(){if(!this._createDialog(this._request,"UAS")){this._request.reply(500,"Error creating dialog");return}this._status=Me.STATUS_ANSWERED,clearTimeout(this._timers.userNoAnswerTimer),this.connect()}acceptParty(n){this._request.parseSDP(!0),this._request.reply(200,"OK",[],`v=0
143
143
  o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
144
144
  c=IN IP4 ${this.my_ip}
145
145
  t=0 0
146
146
  m=message 2856 TCP/TLS/MSRP *
147
147
  a=accept-types:text/plain text/html
148
- a=path: ${s.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
149
- `)}inviteParty(s){const r={},o=[];r.to_uri=new _r("sip",this.target,this._ua._configuration.realm),r.from_uri=new _r("sip",this._ua._configuration.uri.user,this._ua._configuration.uri.host),o.push(`Contact: ${this._ua.contact.toString({outbound:!0})}`),o.push("Content-Type: application/sdp"),this._request=new It.InitialOutgoingInviteRequest(new _r("sip",this.target,this._ua._configuration.realm).clone(),this._ua,r,o,`v=0
148
+ a=path: ${n.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
149
+ `)}inviteParty(n){const a={},e=[];a.to_uri=new Yl("sip",this.target,this._ua._configuration.realm),a.from_uri=new Yl("sip",this._ua._configuration.uri.user,this._ua._configuration.uri.host),e.push(`Contact: ${this._ua.contact.toString({outbound:!0})}`),e.push("Content-Type: application/sdp"),this._request=new Ft.InitialOutgoingInviteRequest(new Yl("sip",this.target,this._ua._configuration.realm).clone(),this._ua,a,e,`v=0
150
150
  o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
151
151
  c=IN IP4 ${this.my_ip}
152
152
  t=0 0
153
153
  m=message 2856 TCP/TLS/MSRP *
154
154
  a=accept-types:text/plain text/html
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 Mo(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:t=>{this.onTransportError(),console.log(t)},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t),console.log("dialog af",this._dialog),t.status_code===200&&(t.parseSDP(!0),this._status=Re.STATUS_CONFIRMED,this.target_addr=t.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=Re.STATUS_INVITE_SENT}terminate(s={}){console.log("terminate",this);const r=s.cause||$.causes.BYE,o=Me.cloneArray(s.extraHeaders),a=s.body;let t,n=s.status_code,d=s.reason_phrase;if(this._status===Re.STATUS_TERMINATED)throw new Fs.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Re.STATUS_NULL:case Re.STATUS_INVITE_SENT:case Re.STATUS_1XX_RECEIVED:if(n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);n&&(d=d||$.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;text="${d}"`),this._status===Re.STATUS_NULL||this._status===Re.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===Re.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=Re.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,$.causes.CANCELED);break;case Re.STATUS_WAITING_FOR_ANSWER:case Re.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,d,o,a),console.log("failed 2"),this._failed("local",null,$.causes.REJECTED);break;case Re.STATUS_WAITING_FOR_ACK:case Re.STATUS_CONFIRMED:if(d=s.reason_phrase||$.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw new TypeError(`Invalid status_code: ${n}`);if(n&&o.push(`Reason: SIP ;cause=${n}; text="${d}"`),this._status===Re.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Bt.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:h})=>{h===$.ACK&&(this.sendRequest($.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Bt.C.STATUS_TERMINATED&&(this.sendRequest($.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,r),this._dialog=_,this._ua.newDialog(_)}else console.log("here it is"),this.sendRequest($.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 or("");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 or(s.data);if(this.status==="auth"&&r.code===401){const o=this.parseAuth(r.getHeader("WWW-Authenticate")),a=new Fm(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($.ACK);return}else{const r=new Xl(this,s,"UAC");if(r.error!==void 0){console.log(r.error);return}this.sendRequest($.ACK),this.sendRequest($.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!==Re.STATUS_INVITE_SENT&&this._status!==Re.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(s.status_code):this._status=Re.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=Re.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=Re.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,$.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",s,$.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,$.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest($.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 or("");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 or("");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 d=0;d<t.length;d++)n.push(t.charCodeAt(d).toString(16));console.log(n),this._connection.send(a.toString())}_sendReport(s){let r=s.ident,o=s.getHeader("Message-ID"),a=new or("");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 d=0;d<t.length;d++)n.push(t.charCodeAt(d).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=Re.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=Re.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),console.log("failed 6"),this._failed("local",null,$.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Re.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),console.log("failed 7"),this._failed("system",null,$.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!==Re.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!==Re.STATUS_TERMINATED){if(this._status=Re.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 d=this._earlyDialogs[n];if(o)return d?!0:(d=new Xl(this,s,r,Xl.C.STATUS_EARLY),d.error?(console.log("failed 8"),this._failed("remote",s,$.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=d,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,d)return d.update(s,r),this._dialog=d,delete this._earlyDialogs[n],!0;const _=new Xl(this,s,r);return _.error?(console.log("failed 9"),this._failed("remote",s,$.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 Re.STATUS_CANCELED:case Re.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>=$.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===$.CANCEL)(this._status===Re.STATUS_WAITING_FOR_ANSWER||this._status===Re.STATUS_ANSWERED)&&(this._status=Re.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",s,$.causes.CANCELED));else switch(s.method){case $.ACK:if(this._status!==Re.STATUS_WAITING_FOR_ACK)return;if(this._status=Re.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!s.body){this.terminate({cause:$.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:$.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 $.BYE:this._status===Re.STATUS_CONFIRMED||this._status===Re.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,$.causes.BYE)):this._status===Re.STATUS_INVITE_RECEIVED||this._status===Re.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,$.causes.BYE)):s.reply(403,"Wrong Status");break;case $.INVITE:this._status===Re.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case $.INFO:this._status===Re.STATUS_1XX_RECEIVED||this._status===Re.STATUS_WAITING_FOR_ANSWER||this._status===Re.STATUS_ANSWERED||this._status===Re.STATUS_WAITING_FOR_ACK||this._status===Re.STATUS_CONFIRMED?(s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new Tu(this).init_incoming(s):s.reply(415):s.reply(403,"Wrong Status");break;case $.UPDATE:this._status===Re.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case $.REFER:this._status===Re.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case $.NOTIFY:this._status===Re.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:$.causes.CONNECTION_ERROR,cause:$.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Re.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:$.causes.REQUEST_TIMEOUT,cause:$.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:$.causes.DIALOG_ERROR,cause:$.causes.DIALOG_ERROR})}}const Vi=new Pu("Registrator"),ao=10;class OT{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=ms.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();const o=this._contact.indexOf(">");if(o!==-1){const a=this._contact.slice(0,o)+this._contact.slice(o+1,this._contact.length);this._contact=a}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}`)}}setExtraContactUriParams(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){Vi.debug("Register request in progress...");return}const s=this._extraHeaders.slice();s.push(`Contact: ${this._contact}${this._extraContactParams}>;expires=${this._expires}`),s.push(`Expires: ${this._expires}`);const r=new It.OutgoingRequest($.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s),o=new Mo(this._ua,r,{onRequestTimeout:()=>{this._registrationFailure(null,$.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,$.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")){Vi.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){Vi.debug("no Contact header pointing to us, response ignored");break}let d=n.getParam("expires");!d&&a.hasHeader("expires")&&(d=a.getHeader("expires")),d||(d=this._expires),d=Number(d),d<ao&&(d=ao);const _=d>64?d*1e3/2+Math.floor((d/2-32)*1e3*Math.random()):d*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<ao&&(this._expires=ao),this.register()):(Vi.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,$.causes.SIP_FAILURE_CODE));break}default:{const t=ms.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(s={}){if(!this._registered){Vi.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}${this._extraContactParams}>;expires=0`),r.push("Expires: 0");const o=new It.OutgoingRequest($.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r);new Mo(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,$.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,$.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=ms.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})}}const ut=console,js={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},DT=ST;class NT extends DT{constructor(s){super(s),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[],this._registrator=new OT(this)}call(s,r){return super.call(s,r)}joinVideoCall(s,r,o){ut.debug("call()");const a=new ko(this);return a.connect(s,r,o),a}_loadConfig(s){try{el.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=ms.newUUID()),this._configuration.jssip_id=ms.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=UT.bind(this),this._transport.onconnect=PT.bind(this),this._transport.ondisconnect=xT.bind(this),this._transport.ondata=MT.bind(this)}catch(a){throw ut.warn(a),new Fs.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 _r("sip",ms.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 d="<";return t?d+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":d+=this.pub_gruu||this.uri.toString(),n&&(t?!this.temp_gruu:!this.pub_gruu)&&(d+=";ob"),d+=">",d}};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}));ut.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(el.settings,a))switch(a){case"uri":case"registrar_server":ut.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":ut.debug(`- ${a}: NOT SHOWN`);break;default:ut.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,d,_;const r=s.method;if(console.log("-----------"),s.ruri.user!==this._configuration.uri.user&&s.ruri.user!==this._contact.uri.user){ut.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(Bt.checkTransaction(this,s))return;if(r===De.INVITE?new Bt.InviteServerTransaction(this,this._transport,s):r!==De.ACK&&r!==De.CANCEL&&new Bt.NonInviteServerTransaction(this,this._transport,s),r===De.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new Jc.Options(this).init_incoming(s)}else if(r===De.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new Jc.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),(_=(d=h.plugindata)==null?void 0:d.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 Za(this),a.init_incoming(s)):s.body.search(/JANUS/ig)>-1||(a=new Ng(this),a.init_incoming(s));else ut.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):ut.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){ut.debug("startMSRP()",r);const o=new Za(this);return o.connect(s),o}startJanus(s,r){ut.debug("startJanus()",r);const o=new Za(this);return o.connect(s),o}terminateMSRPSessions(s){ut.debug("terminateSessions()");for(const r in this._msrp_sessions)this._msrp_sessions[r].isEnded()||this._msrp_sessions[r].terminate(s)}terminateJanusSessions(s){ut.debug("terminateSessions()");for(const r in this._janus_sessions)this._janus_sessions[r].isEnded()||this._janus_sessions[r].terminate(s)}stop(){if(ut.debug("stop()"),this._dynConfiguration={},this._status===js.STATUS_USER_CLOSED){ut.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)){ut.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)){ut.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)){ut.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=js.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 UT(c){this.emit("connecting",c)}function PT(c){this._status!==js.STATUS_USER_CLOSED&&(this._status=js.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function xT(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!==js.STATUS_USER_CLOSED&&(this._status=js.STATUS_NOT_READY,this._error=js.NETWORK_ERROR)}function MT(c){console.log("onTransportData",c);const s=c.transport;let r=c.message;if(r=Hu.parseMessage(r,this),!r){console.log("if 1 return");return}if(this._status===js.STATUS_USER_CLOSED&&r instanceof Wl.IncomingRequest){console.log("if 2 return");return}if(!aT(r,this,s)){console.log("if 3 return");return}if(console.log("onTransportData message",r),console.log("onTransportData instanceof",r instanceof Wl.IncomingRequest),r instanceof Wl.IncomingRequest)r.transport=s,console.log("onTransportData receiveRequest"),this.receiveRequest(r);else if(r instanceof Wl.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 kT=["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"],LT=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function wf(c){const s={};return kT.forEach(r=>{c[r]!==void 0&&(s[r]=c[r])}),s.localHold=c._localHold,s}function Of(c){const s={};return LT.forEach(r=>{c[r]!==void 0&&(s[r]=c[r])}),s}function Df(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 $T(c,s,r,o){const a=document.createElement("audio");a.id=s._id,a.className="audioTag",a.srcObject=c,C_()||(a.setSinkId(r),a.volume=o),a.play(),s.audioTag=a}function HT(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}function C_(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}const FT=at,jT=ls(),Dt=new FT("WebSocketInterface");var qT=class{constructor(s){Dt.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;const r=jT.parse(s,"absoluteURI");if(r===-1)throw Dt.warn(`invalid WebSocket URI: ${s}`),new TypeError(`Invalid argument: ${s}`);if(r.scheme!=="wss"&&r.scheme!=="ws")throw Dt.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(Dt.debug("connect()"),this.isConnected()){Dt.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Dt.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Dt.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(){Dt.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 Dt.debug("send()"),this.isConnected()?(this._ws.send(s),!0):(Dt.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(){Dt.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:s,code:r,reason:o}){Dt.debug(`WebSocket ${this._url} closed`),s===!1&&Dt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!s,r,o)}_onMessage({data:s}){Dt.debug("received WebSocket message"),this.ondata(s)}_onError(s){Dt.warn(`WebSocket ${this._url} error: `,s)}};const yu=Lo,VT=De,BT=Ss,GT=yt(),WT=A_,KT=Es(),YT=xu(),JT=ls(),zT=qT,XT=dr("JsSIP");XT("version %s",yu.version);var QT={C:VT,Exceptions:BT,Utils:GT,UA:WT,URI:KT,NameAddrHeader:YT,WebSocketInterface:zT,Grammar:JT,debug:dr,get name(){return yu.title},get version(){return yu.version}};const ZT=Xe(QT);function eu(c){return c<10?`0${c}`:`${c}`}function ev(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=`${eu(s)}:${eu(r)}:${eu(o)}`;return{seconds:o,minutes:r,hours:s,formatted:a}}var At={};At.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)};At.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)};At.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)};At.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};At.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 d=_=>{_?o(c[n]):t===c.length&&o(),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(d).catch(a)}});At.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]};At.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 d=_=>{_?o(n):t===c.length&&o(-1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(d).catch(a)}});At.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};At.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 d=_=>{_?o(!0):t===c.length&&o(!1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(d).catch(a)}});At.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};At.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 d=_=>{_?t===c.length&&o(!0):o(!1),t++};Promise.resolve(c[n]).then(_=>s.call(r||globalThis,_,n,c)).then(d).catch(a)}});At.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};At.filter=(c,s,r)=>new Promise(async(o,a)=>{const t=[];for(let d=0;d<c.length;d++)d in c&&(t[d]=Promise.resolve(c[d]).then(_=>s.call(r||globalThis,_,d,c)).catch(a));const n=[];for(let d=0;d<t.length;d++)await t[d]&&n.push(await c[d]);o(n)});At.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};At.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 R_={};(function(c){const s=At;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)}})})(R_);const tv=At,sv=R_;var nv=Object.assign(tv,{instanceMethods:sv});const yn=new AudioContext,zt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var rv={exports:{}};(function(c){var s=function(r){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(ee,W,G){ee[W]=G.value},n,d=typeof Symbol=="function"?Symbol:{},_=d.iterator||"@@iterator",h=d.asyncIterator||"@@asyncIterator",g=d.toStringTag||"@@toStringTag";function T(ee,W,G){return Object.defineProperty(ee,W,{value:G,enumerable:!0,configurable:!0,writable:!0}),ee[W]}try{T({},"")}catch{T=function(W,G,re){return W[G]=re}}function E(ee,W,G,re){var ge=W&&W.prototype instanceof ae?W: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,W,G){try{return{type:"normal",arg:ee.call(W,G)}}catch(re){return{type:"throw",arg:re}}}var A="suspendedStart",C="suspendedYield",I="executing",H="completed",L={};function ae(){}function N(){}function j(){}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=j.prototype=ae.prototype=Object.create(Se);N.prototype=j,t(D,"constructor",{value:j,configurable:!0}),t(j,"constructor",{value:N,configurable:!0}),N.displayName=T(j,g,"GeneratorFunction");function B(ee){["next","throw","return"].forEach(function(W){T(ee,W,function(G){return this._invoke(W,G)})})}r.isGeneratorFunction=function(ee){var W=typeof ee=="function"&&ee.constructor;return W?W===N||(W.displayName||W.name)==="GeneratorFunction":!1},r.mark=function(ee){return Object.setPrototypeOf?Object.setPrototypeOf(ee,j):(ee.__proto__=j,T(ee,g,"GeneratorFunction")),ee.prototype=Object.create(D),ee},r.awrap=function(ee){return{__await:ee}};function V(ee,W){function G(be,xe,Ce,le){var ye=y(ee[be],ee,xe);if(ye.type==="throw")le(ye.arg);else{var st=ye.arg,lt=st.value;return lt&&typeof lt=="object"&&a.call(lt,"__await")?W.resolve(lt.__await).then(function(Ee){G("next",Ee,Ce,le)},function(Ee){G("throw",Ee,Ce,le)}):W.resolve(lt).then(function(Ee){st.value=Ee,Ce(st)},function(Ee){return G("throw",Ee,Ce,le)})}}var re;function ge(be,xe){function Ce(){return new W(function(le,ye){G(be,xe,le,ye)})}return re=re?re.then(Ce,Ce):Ce()}t(this,"_invoke",{value:ge})}B(V.prototype),T(V.prototype,h,function(){return this}),r.AsyncIterator=V,r.async=function(ee,W,G,re,ge){ge===void 0&&(ge=Promise);var be=new V(E(ee,W,G,re),ge);return r.isGeneratorFunction(W)?be:be.next().then(function(xe){return xe.done?xe.value:be.next()})};function J(ee,W,G){var re=A;return function(be,xe){if(re===I)throw new Error("Generator is already running");if(re===H){if(be==="throw")throw xe;return tt()}for(G.method=be,G.arg=xe;;){var Ce=G.delegate;if(Ce){var le=F(Ce,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=H,G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);re=I;var ye=y(ee,W,G);if(ye.type==="normal"){if(re=G.done?H:C,ye.arg===L)continue;return{value:ye.arg,done:G.done}}else ye.type==="throw"&&(re=H,G.method="throw",G.arg=ye.arg)}}}function F(ee,W){var G=W.method,re=ee.iterator[G];if(re===n)return W.delegate=null,G==="throw"&&ee.iterator.return&&(W.method="return",W.arg=n,F(ee,W),W.method==="throw")||G!=="return"&&(W.method="throw",W.arg=new TypeError("The iterator does not provide a '"+G+"' method")),L;var ge=y(re,ee.iterator,W.arg);if(ge.type==="throw")return W.method="throw",W.arg=ge.arg,W.delegate=null,L;var be=ge.arg;if(!be)return W.method="throw",W.arg=new TypeError("iterator result is not an object"),W.delegate=null,L;if(be.done)W[ee.resultName]=be.value,W.next=ee.nextLoc,W.method!=="return"&&(W.method="next",W.arg=n);else return be;return W.delegate=null,L}B(D),T(D,g,"Generator"),T(D,_,function(){return this}),T(D,"toString",function(){return"[object Generator]"});function X(ee){var W={tryLoc:ee[0]};1 in ee&&(W.catchLoc=ee[1]),2 in ee&&(W.finallyLoc=ee[2],W.afterLoc=ee[3]),this.tryEntries.push(W)}function U(ee){var W=ee.completion||{};W.type="normal",delete W.arg,ee.completion=W}function P(ee){this.tryEntries=[{tryLoc:"root"}],ee.forEach(X,this),this.reset(!0)}r.keys=function(ee){var W=Object(ee),G=[];for(var re in W)G.push(re);return G.reverse(),function ge(){for(;G.length;){var be=G.pop();if(be in W)return ge.value=be,ge.done=!1,ge}return ge.done=!0,ge}};function se(ee){if(ee){var W=ee[_];if(W)return W.call(ee);if(typeof ee.next=="function")return ee;if(!isNaN(ee.length)){var 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:tt}}r.values=se;function tt(){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 W in this)W.charAt(0)==="t"&&a.call(this,W)&&!isNaN(+W.slice(1))&&(this[W]=n)},stop:function(){this.done=!0;var ee=this.tryEntries[0],W=ee.completion;if(W.type==="throw")throw W.arg;return this.rval},dispatchException:function(ee){if(this.done)throw ee;var W=this;function G(le,ye){return be.type="throw",be.arg=ee,W.next=le,ye&&(W.method="next",W.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"),Ce=a.call(ge,"finallyLoc");if(xe&&Ce){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(Ce){if(this.prev<ge.finallyLoc)return G(ge.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(ee,W){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<=W&&W<=ge.finallyLoc&&(ge=null);var be=ge?ge.completion:{};return be.type=ee,be.arg=W,ge?(this.method="next",this.next=ge.finallyLoc,L):this.complete(be)},complete:function(ee,W){if(ee.type==="throw")throw ee.arg;return ee.type==="break"||ee.type==="continue"?this.next=ee.arg:ee.type==="return"?(this.rval=this.arg=ee.arg,this.method="return",this.next="end"):ee.type==="normal"&&W&&(this.next=W),L},finish:function(ee){for(var W=this.tryEntries.length-1;W>=0;--W){var G=this.tryEntries[W];if(G.finallyLoc===ee)return this.complete(G.completion,G.afterLoc),U(G),L}},catch:function(ee){for(var W=this.tryEntries.length-1;W>=0;--W){var G=this.tryEntries[W];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,W,G){return this.delegate={iterator:se(ee),resultName:W,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)}})(rv);var I_={exports:{}};(function(c){(function(s,r){c.exports?c.exports=r():s.log=r()})(x_,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 H=C[I];if(typeof H.bind=="function")return H.bind(C);try{return Function.prototype.bind.call(H,C)}catch{return function(){return Function.prototype.apply.apply(H,[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 d(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 H=0;H<a.length;H++){var L=a[H];this[L]=H<C?s:this.methodFactory(L,C,I)}this.log=this.debug}function h(C,I,H){return function(){typeof console!==r&&(_.call(this,I,H),this[C].apply(this,arguments))}}function g(C,I,H){return d(C)||h.apply(this,arguments)}function T(C,I,H){var L=this,ae;I=I??"WARN";var N="loglevel";typeof C=="string"?N+=":"+C:typeof C=="symbol"&&(N=void 0);function j(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,V=B.indexOf(encodeURIComponent(N)+"=");V!==-1&&(D=/^([^;]+)/.exec(B.slice(V))[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=H||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&&j(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 H=y[I];return H||(H=y[I]=new T(I,E.getLevel(),E.methodFactory)),H};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})})(I_);var Rt=I_.exports;const gs=()=>`${new Date().toISOString()} | metrics`,Ts=(c,s,r)=>`${c} | ${s} | ${r}`;Rt.setDefaultLevel(Rt.levels.TRACE);const iv=c=>{Rt.info(Ts(gs(),"log ",`set log level to ${c?"verbose":"info"}`)),Rt.setLevel(c?Rt.levels.TRACE:Rt.levels.INFO)},lv=c=>{const s=[...Object.keys(Rt.levels)];s.includes(c)?(Rt.info(Ts(gs(),"log ",`update log level to ${c.toLowerCase()}`)),Rt.setLevel(c)):Rt.warn(Ts(gs(),"log ","Incorrect log level please choose one of "),s)},Pe=(c,s,r)=>{r?Rt.debug(Ts(gs(),c,s),r):Rt.debug(Ts(gs(),c,s))},tu=(c,s)=>{Rt.info(Ts(gs(),c,s))},An=(c,s)=>{Rt.info(Ts(gs(),c,s))},Ro=(c,s)=>{Rt.warn(Ts(gs(),c,s))},cr=(c,s)=>{Rt.error(Ts(gs(),c,s))};function ov(c){return Math.floor(Math.random()*c).toString()}function Nf(c,s){let r=s;return c.forEach(o=>{r=r.replace(o,"")}),r}function av(c,s){let r="";for(let o=0;o<s;o+=1)r+=c[ov(c.length)];return r}function uv({length:c=20,useLetters:s=!0,useNumbers:r=!0,includeSymbols:o=[],excludeSymbols:a=[]}={}){let t="abcdefghijklmnopqrstuvwxyz",n="0123456789",d=[],_=[],h=[];return s&&(a.length&&(t=Nf(a,t)),_=t.split("")),r&&(a.length&&(n=Nf(a,n)),h=n.split("")),d=[..._,...h,...o],av(d,c)}var cv=uv;const Ji=Xe(cv),fv=()=>"WebRTCMetrics",_v=()=>"5.0.3",$e={INBOUND:"inbound",OUTBOUND:"outbound"},ps={IDLE:"idle",RUNNING:"running",MUTED:"muted"},Bi={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},hv=()=>({...{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:[]}}),b_={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},w_={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},O_={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},D_={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},dv=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}}},pv={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${Ji()}`,cid:`c-${Ji()}`,uid:`u-${Ji()}`,record:!1,ticket:!0},Jt={CANDIDATE_PAIR:"candidate-pair",CODEC:"codec",INBOUND_RTP:"inbound-rtp",LOCAL_CANDIDATE:"local-candidate",MEDIA_SOURCE:"media-source",OUTBOUND_RTP:"outbound-rtp",REMOTE_CANDIDATE:"remote-candidate",REMOTE_INBOUND_RTP:"remote-inbound-rtp",TRACK:"track"},q={AUDIO_LEVEL:"audioLevel",AVAILABLE_OUTGOING_BITRATE:"availableOutgoingBitrate",AVAILABLE_INCOMING_BITRATE:"availableIncomingBitrate",BYTES_RECEIVED:"bytesReceived",BYTES_SENT:"bytesSent",CANDIDATE_TYPE:"candidateType",CHANNELS:"channels",CLOCK_RATE:"clockRate",CODEC_ID:"codecId",CURRENT_ROUND_TRIP_TIME:"currentRoundTripTime",ROUND_TRIP_TIME:"roundTripTime",FRACTION_LOST:"fractionLost",FRAME_HEIGHT:"frameHeight",FRAME_WIDTH:"frameWidth",QUALITY_LIMITATION_REASON:"qualityLimitationReason",QUALITY_LIMITATION_DURATIONS:"qualityLimitationDurations",QUALITY_LIMITATION_RESOLUTION_CHANGES:"qualityLimitationResolutionChanges",ID:"id",JITTER:"jitter",KIND:"kind",MEDIA_TYPE:"mediaType",MIME_TYPE:"mimeType",LOCAL_CANDIDATE_ID:"localCandidateId",NETWORK_TYPE:"networkType",RELAY_PROTOCOL:"relayProtocol",NOMINATED:"nominated",PACKETS_LOST:"packetsLost",PACKETS_RECEIVED:"packetsReceived",PACKETS_SENT:"packetsSent",PROTOCOL:"protocol",PORT:"port",REMOTE_CANDIDATE_ID:"remoteCandidateId",REMOTE_SOURCE:"remoteSource",RESPONSES_RECEIVED:"responsesReceived",SDP_FMTP_LINE:"sdpFmtpLine",SSRC:"ssrc",SELECTED:"selected",STATE:"state",TIMESTAMP:"timestamp",TOTAL_ROUND_TRIP_TIME:"totalRoundTripTime",TOTAL_ROUND_TRIP_TIME_MEASUREMENTS:"roundTripTimeMeasurements",TYPE:"type",DECODER_IMPLEMENTATION:"decoderImplementation",ENCODER_IMPLEMENTATION:"encoderImplementation",FRAMES_DECODED:"framesDecoded",FRAMES_ENCODED:"framesEncoded",FRAMES_PER_SECOND:"framesPerSecond",TOTAL_DECODE_TIME:"totalDecodeTime",TOTAL_ENCODE_TIME:"totalEncodeTime",PLI:"pliCount",NACK:"nackCount"},x={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},Gi={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},su={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ne={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},nu="config ",mv=(c,s={},r)=>{const o={...r,...s};return s.pname||Ro(nu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${r.pname}'`),s.cid||Ro(nu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${r.cid}'`),s.uid||Ro(nu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${r.uid}'`),o.pc=c,o},gv=(c={})=>{const s={...pv,...c};return s.name=fv(),s.version=_v(),s},_l=(c,s,r,o=!1,a)=>{let t=c.map(n=>{if(!r)return n[s];if(!a)return n[s][r];const d=n[s][a];return d?d[r]:null});return t=t.filter(n=>o?Number.isFinite(n)&&n>0:Number.isFinite(n)),t.length===0?[]:t},Vs=c=>c.reduce((s,r)=>s+r,0)/c.length,Tv=()=>`probe-${Ji()}`,vv=()=>`coltr-${Ji()}`,Uf=c=>new Promise(s=>setTimeout(s,c)),Au=(c,s,r)=>{s?c.call(s,r):c(r)},Ke=(c,s,r,o)=>{const a=_l(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},ze=(c,s,r,o=!1,a)=>{const t=_l(c,s,r,o,a);return t.length===0?null:t.reduce((n,d)=>n+d,0)/t.length},vn=(c,s,r)=>_l(c,s,r).reduce((a,t)=>a+t,0),Ye=(c,s,r,o)=>{const a=_l(c,s,r,!0,o);return a.length===0?null:Math.min(...a)},Je=(c,s,r,o)=>{const a=_l(c,s,r,!1,o);return a.length===0?null:Math.max(...a)},gt=(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},Ev=c=>c.slice().pop(),ct=(c,s,r)=>{if(!s)return null;const o={};let a=s[x.AUDIO][c];a||(a=r===$e.INBOUND?{...b_}:{...w_}),o[x.AUDIO]=a;let t=s[x.VIDEO][c];return t||(t=r===$e.INBOUND?{...O_}:{...D_}),o[x.VIDEO]=t,o},Wi="exporter ",Sv="2.0",Pf=(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?ze(c,s,"delta_rtt_ms_out",!1,r):Number(t/n)}return null},yv=(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?ze(c,s,"delta_rtt_connectivity_ms"):Number(o/a)},Av=c=>gt(c,"network","local_candidate_type")!=="relay"?`direct/${gt(c,"network","local_candidate_protocol")}`:`turn/${gt(c,"network","local_candidate_relay_protocol")}`,Cv=c=>{const s=gt(c,"network","remote_candidate_type"),r=gt(c,"network","remote_candidate_protocol");return s!=="relay"?`direct/${r}`:`turn/${r}`};class Rv{constructor(s){this._start=null,this._end=null,this._cfg=s,this._referenceReport=null,this._reports=[],this._events=[]}start(){tu(Wi,"start() - start exporter...");const s=new Date;return this._start=s.toJSON(),s}stop(){tu(Wi,"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(Wi,`addReport() - add report to exporter at ${s.timestamp}`),this._reports.push(s))}addCustomEvent(s){this._events.push(s)}reset(){tu(Wi,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Pe(Wi,"ticket() - generate ticket");const s=gt(this._reports,"audio","total_packets_lost_in"),r=gt(this._reports,"audio","total_packets_in"),o=gt(this._reports,"video","total_packets_lost_in"),a=gt(this._reports,"video","total_packets_in"),t={},n=Ev(this._reports);return n&&(Object.keys(n[x.AUDIO]).forEach(d=>{const _=n[x.AUDIO][d];if(t[_.ssrc]={type:x.AUDIO,direction:_.direction},_.direction===$e.INBOUND){const h={avg:ze(this._reports,x.AUDIO,"delta_jitter_ms_in",!1,d),min:Ye(this._reports,x.AUDIO,"delta_jitter_ms_in",d),max:Je(this._reports,x.AUDIO,"delta_jitter_ms_in",d),volatility:Ke(this._reports,x.AUDIO,"delta_jitter_ms_in",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:ze(this._reports,x.AUDIO,"delta_kbs_in",!1,d),min:Ye(this._reports,x.AUDIO,"delta_kbs_in",d),max:Je(this._reports,x.AUDIO,"delta_kbs_in",d),volatility:Ke(this._reports,x.AUDIO,"delta_kbs_in",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:ze(this._reports,x.AUDIO,"delta_KBytes_in",!1,d),min:Ye(this._reports,x.AUDIO,"delta_KBytes_in",d),max:Je(this._reports,x.AUDIO,"delta_KBytes_in",d),volatility:Ke(this._reports,x.AUDIO,"delta_KBytes_in",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:ze(this._reports,x.AUDIO,"mos_emodel_in",!1,d),min:Ye(this._reports,x.AUDIO,"mos_emodel_in",d),max:Je(this._reports,x.AUDIO,"mos_emodel_in",d),volatility:Ke(this._reports,x.AUDIO,"mos_emodel_in",d)},effective:{avg:ze(this._reports,x.AUDIO,"mos_in",!1,d),min:Ye(this._reports,x.AUDIO,"mos_in",d),max:Je(this._reports,x.AUDIO,"mos_in",d),volatility:Ke(this._reports,x.AUDIO,"mos_in",d)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},y=gt(this._reports,x.AUDIO,"total_packets_lost_in",d),A=gt(this._reports,x.AUDIO,"total_packets_in",d),C={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[d].jitter=h,t[d].mos=E,t[d].traffic=T,t[d].bitrate=g,t[d].loss=C}else{const h={avg:ze(this._reports,x.AUDIO,"delta_jitter_ms_out",!1,d),min:Ye(this._reports,x.AUDIO,"delta_jitter_ms_out",d),max:Je(this._reports,x.AUDIO,"delta_jitter_ms_out",d),volatility:Ke(this._reports,x.AUDIO,"delta_jitter_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:ze(this._reports,x.AUDIO,"delta_kbs_out",!1,d),min:Ye(this._reports,x.AUDIO,"delta_kbs_out",d),max:Je(this._reports,x.AUDIO,"delta_kbs_out",d),volatility:Ke(this._reports,x.AUDIO,"delta_kbs_out",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:ze(this._reports,x.AUDIO,"delta_KBytes_out",!1,d),min:Ye(this._reports,x.AUDIO,"delta_KBytes_out",d),max:Je(this._reports,x.AUDIO,"delta_KBytes_out",d),volatility:Ke(this._reports,x.AUDIO,"delta_KBytes_out",d),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:Pf(this._reports,x.AUDIO,d),min:Ye(this._reports,x.AUDIO,"delta_rtt_ms_out",d),max:Je(this._reports,x.AUDIO,"delta_rtt_ms_out",d),volatility:Ke(this._reports,x.AUDIO,"delta_rtt_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=gt(this._reports,x.AUDIO,"total_packets_lost_out",d),A=gt(this._reports,x.AUDIO,"total_packets_out",d),C={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},I={emodel:{avg:ze(this._reports,x.AUDIO,"mos_emodel_out",!1,d),min:Ye(this._reports,x.AUDIO,"mos_emodel_out",d),max:Je(this._reports,x.AUDIO,"mos_emodel_out",d),volatility:Ke(this._reports,x.AUDIO,"mos_emodel_out",d)},effective:{avg:ze(this._reports,x.AUDIO,"mos_out",!1,d),min:Ye(this._reports,x.AUDIO,"mos_out",d),max:Je(this._reports,x.AUDIO,"mos_out",d),volatility:Ke(this._reports,x.AUDIO,"mos_out",d)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};t[d].jitter=h,t[d].rtt=E,t[d].traffic=T,t[d].bitrate=g,t[d].loss=C,t[d].mos=I}}),Object.keys(n[x.VIDEO]).forEach(d=>{const _=n[x.VIDEO][d];if(t[d]={type:x.VIDEO,direction:_.direction},_.direction===$e.INBOUND){const h={avg:ze(this._reports,x.VIDEO,"delta_jitter_ms_in",!1,d),min:Ye(this._reports,x.VIDEO,"delta_jitter_ms_in",d),max:Je(this._reports,x.VIDEO,"delta_jitter_ms_in",d),volatility:Ke(this._reports,x.VIDEO,"delta_jitter_ms_in",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:ze(this._reports,x.VIDEO,"delta_kbs_in",!1,d),min:Ye(this._reports,x.VIDEO,"delta_kbs_in",d),max:Je(this._reports,x.VIDEO,"delta_kbs_in",d),volatility:Ke(this._reports,x.VIDEO,"delta_kbs_in",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:ze(this._reports,x.VIDEO,"delta_KBytes_in",!1,d),min:Ye(this._reports,x.VIDEO,"delta_KBytes_in",d),max:Je(this._reports,x.VIDEO,"delta_KBytes_in",d),volatility:Ke(this._reports,x.VIDEO,"delta_KBytes_in",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=gt(this._reports,x.VIDEO,"total_packets_lost_in",d),y=gt(this._reports,x.VIDEO,"total_packets_in",d),A={lost:E,avg:Math.round((E/(E+y)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[d].jitter=h,t[d].traffic=T,t[d].bitrate=g,t[d].loss=A}else{const h={avg:ze(this._reports,x.VIDEO,"delta_jitter_ms_out",!1,d),min:Ye(this._reports,x.VIDEO,"delta_jitter_ms_out",d),max:Je(this._reports,x.VIDEO,"delta_jitter_ms_out",d),volatility:Ke(this._reports,x.VIDEO,"delta_jitter_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:ze(this._reports,x.VIDEO,"delta_kbs_out",!1,d),min:Ye(this._reports,x.VIDEO,"delta_kbs_out",d),max:Je(this._reports,x.VIDEO,"delta_kbs_out",d),volatility:Ke(this._reports,x.VIDEO,"delta_kbs_out",d),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},T={avg:ze(this._reports,x.VIDEO,"delta_KBytes_out",!1,d),min:Ye(this._reports,x.VIDEO,"delta_KBytes_out",d),max:Je(this._reports,x.VIDEO,"delta_KBytes_out",d),volatility:Ke(this._reports,x.VIDEO,"delta_KBytes_out",d),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:Pf(this._reports,x.VIDEO,d),min:Ye(this._reports,x.VIDEO,"delta_rtt_ms_out",d),max:Je(this._reports,x.VIDEO,"delta_rtt_ms_out",d),volatility:Ke(this._reports,x.VIDEO,"delta_rtt_ms_out",d),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},y=gt(this._reports,x.VIDEO,"total_packets_lost_out",d),A=gt(this._reports,x.VIDEO,"total_packets_out",d),C={lost:y,avg:Math.round((y/(y+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[d].jitter=h,t[d].rtt=E,t[d].traffic=T,t[d].bitrate=g,t[d].loss=C}})),{version:Sv,configuration:{frequency:this._cfg.refreshEvery},started:this._start,ended:this._end,ua:{agent:navigator.userAgent,pname:this._cfg.pname,user_id:this._cfg.uid},call:{call_id:this._cfg.cid,events:this._events},details:{count:this._reports.length,reports:this._cfg.record?this._reports:[],reference:this._referenceReport||null},ssrc:t,data:{rtt:{avg:yv(this._reports,"data"),min:Ye(this._reports,"data","delta_rtt_connectivity_ms"),max:Je(this._reports,"data","delta_rtt_connectivity_ms"),volatility:Ke(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((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:ze(this._reports,"data","delta_kbs_in"),min:Ye(this._reports,"data","delta_kbs_in"),max:Je(this._reports,"data","delta_kbs_in"),volatility:Ke(this._reports,"data","delta_kbs_in")},out:{avg:ze(this._reports,"data","delta_kbs_out"),min:Ye(this._reports,"data","delta_kbs_out"),max:Je(this._reports,"data","delta_kbs_out"),volatility:Ke(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:ze(this._reports,"data","delta_KBytes_in"),min:Ye(this._reports,"data","delta_KBytes_in"),max:Je(this._reports,"data","delta_KBytes_in"),volatility:Ke(this._reports,"data","delta_KBytes_in")},out:{avg:ze(this._reports,"data","delta_KBytes_out"),min:Ye(this._reports,"data","delta_KBytes_out"),max:Je(this._reports,"data","delta_KBytes_out"),volatility:Ke(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:Av(this._reports),remoteConnection:Cv(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 Hs="extractor ",xf=(c,s,r,o)=>{let a=!1;const t=o[s].total_rtt_ms_out,n=o[s].total_rtt_measure_out,d=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[q.TIMESTAMP]===o[s].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(a=!0,Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-_===n))return h;const g=1e3*Number(c[q.ROUND_TRIP_TIME]);let T=t+g,E=n+1;return a&&(T=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-d,E=Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-_),{rtt:g,totalRTT:T,totalRTTMeasurements:E}},Iv=(c,s,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.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[q.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,q.TOTAL_ROUND_TRIP_TIME)&&(t=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-(r?r[s].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,q.RESPONSES_RECEIVED)&&(n=Number(c[q.RESPONSES_RECEIVED])-(r?r[s].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:t,totalRTTMeasurements:n}},uo=(c,s,r)=>c[q.TIMESTAMP]===r[s].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.JITTER)?null:1e3*(Number(c[q.JITTER])||0),bv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,q.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[q.FRAMES_DECODED],o=c[q.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}},wv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,q.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[q.FRAMES_ENCODED],o=c[q.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}},Mf=(c,s,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,q.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[q.PACKETS_SENT])||0-(o?o[s].total_packets_out:0),t=a-r[s].total_packets_out,n=Number(c[q.BYTES_SENT])/1024-(o?o[s].total_KBytes_out:0),d=n-r[s].total_KBytes_out,_=c[q.TIMESTAMP]||Date.now(),h=o?o.timestamp:null;let g=r.timestamp;!g&&h&&(g=h);const T=g?_-g:0,E=T>0?d*.008*1024/T*1e3:0;return{packetsSent:a,deltaPacketsSent:t,KBytesSent:n,deltaKBytesSent:d,kbsSent:E}},kf=(c,s,r,o)=>{let a=r[s].total_packets_lost_out,t=0,n=0;return Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)&&(a=Number(c[q.PACKETS_LOST])||0-(o?o[s].total_packets_lost_out:0),t=a-r[s].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,q.FRACTION_LOST)&&(n=Number(100*c[q.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:t,fractionLost:n}},Lf=(c,s,r,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,q.BYTES_RECEIVED))return{percent_packets_lost: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[q.PACKETS_RECEIVED])||0-(o?o[s].total_packets_in:0),t=Number(c[q.PACKETS_LOST])||0-(o?o[s].total_packets_lost_in:0),n=t-r[s].total_packets_lost_in,d=a-r[s].total_packets_in,_=a!==r[s].total_packets_in?n*100/(n+d):0,h=Number(c[q.BYTES_RECEIVED])/1024-(o?o[s].total_KBytes_in:0),g=h-r[s].total_KBytes_in,T=c[q.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:d,packetsLost:t,deltaPacketsLost:n,KBytesReceived:h,deltaKBytesReceived:g,kbsReceived:C}},Ov=c=>c[q.CANDIDATE_TYPE]!=="relay"?"":c[q.RELAY_PROTOCOL]||"",Dv=c=>{if(!Object.prototype.hasOwnProperty.call(c,q.NETWORK_TYPE))return Gi.WIFI;switch(c[q.NETWORK_TYPE]){case su.ETHERNET:return Gi.ETHERNET;case su.CELLULAR_4G:return Gi.CELLULAR_4G;case su.WIFI:return Gi.WIFI;default:return Gi.CELLULAR}},$f=c=>!Object.prototype.hasOwnProperty.call(c,q.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,q.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[q.FRAME_WIDTH]||null,height:c[q.FRAME_HEIGHT]||null,framerate:c[q.FRAMES_PER_SECOND]},Nv=c=>{const s=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_REASON)?c[q.QUALITY_LIMITATION_REASON]:null,r=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[q.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,o=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_DURATIONS)?c[q.QUALITY_LIMITATION_DURATIONS]:null;return o&&Object.keys(o).forEach(a=>{o[a]>1e3&&(o[a]=Number(o[a]/1e3))}),{reason:s,durations:o,resolutionChanges:r}},Uv=(c,s,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:s.total_pli_sent_in,nackCount:s.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(r?r[x.VIDEO].total_pli_sent_in:0),a=(c[q.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}},Pv=(c,s,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:s.total_pli_received_out,nackCount:s.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(r?r[x.VIDEO].total_pli_received_out:0),a=(c[q.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}},xv=c=>({channels:c[q.CHANNELS]||null,clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null,sdp_fmtp_line:c[q.SDP_FMTP_LINE]||null}),Mv=c=>({clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null}),kv=(c,s,r)=>{const o=(c[q.BYTES_RECEIVED]||0)/1024-(r?r.data.total_KBytes_in:0),a=(c[q.BYTES_SENT]||0)/1024-(r?r.data.total_KBytes_out:0),t=c[q.TIMESTAMP]||Date.now(),n=o-s.data.total_KBytes_in,d=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?d*.008*1024/g*1e3:0;return{total_KBytes_received:o,total_KBytes_sent:a,delta_KBytes_received:n,delta_KBytes_sent:d,kbs_speed_received:T,kbs_speed_sent:E}},Lv=c=>{const s=c[q.AVAILABLE_INCOMING_BITRATE]/1024||0,r=c[q.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:s,kbs_outgoing_bandwidth:r}},$v=(c,s,r,o)=>{if(!c)return[];switch(c[q.TYPE]){case Jt.CANDIDATE_PAIR:let a=!1;if(c[q.NOMINATED]&&c[q.STATE]===x.SUCCEEDED&&(a=!0,Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c),q.SELECTED in c&&!c[q.SELECTED]&&(a=!1)),a){const n=c[q.LOCAL_CANDIDATE_ID],d=c[q.REMOTE_CANDIDATE_ID],_=kv(c,s,o),h=Lv(c),g=Iv(c,"data",o,s);return[{type:ne.NETWORK,value:{local_candidate_id:n}},{type:ne.NETWORK,value:{remote_candidate_id:d}},{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 Jt.LOCAL_CANDIDATE:if(c[q.ID]===s.network.local_candidate_id)return[{type:ne.NETWORK,value:{infrastructure:Dv(c)}},{type:ne.NETWORK,value:{local_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{local_candidate_protocol:c[q.PROTOCOL]||""}},{type:ne.NETWORK,value:{local_candidate_relay_protocol:Ov(c)}}];break;case Jt.REMOTE_CANDIDATE:if(c[q.ID]===s.network.remote_candidate_id)return[{type:ne.NETWORK,value:{remote_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ne.NETWORK,value:{remote_candidate_protocol:c[q.PROTOCOL]||""}}];break;case Jt.INBOUND_RTP:{Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c);const n=c[q.SSRC],d=ct(n,s,$e.INBOUND);d&&(d.timestamp=s.timestamp);const _=ct(n,o,$e.INBOUND);if(_&&(_.timestamp=o.timestamp),c[q.MEDIA_TYPE]===x.AUDIO){const h=Lf(c,x.AUDIO,d,_),g=uo(c,x.AUDIO,d),T=c[q.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[q.MEDIA_TYPE]===x.VIDEO){const h=bv(c,d),g=Lf(c,x.VIDEO,d,_),T=uo(c,x.VIDEO,d),E=c[q.DECODER_IMPLEMENTATION]||null,y=c[q.CODEC_ID]||null,A=$f(c),C=Uv(c,d,_);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 Jt.OUTBOUND_RTP:{Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c);const n=c[q.SSRC],d=ct(n,s,$e.OUTBOUND);d&&(d.timestamp=s.timestamp);const _=ct(n,o,$e.OUTBOUND);if(_&&(_.timestamp=o.timestamp),c[q.MEDIA_TYPE]===x.AUDIO){const h=c[q.CODEC_ID]||null,g=Mf(c,x.AUDIO,d,_);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[q.MEDIA_TYPE]===x.VIDEO){const h=c[q.ENCODER_IMPLEMENTATION]||null,g=c[q.CODEC_ID]||null,T=wv(c,d),E=$f(c),y=Nv(c),A=Pv(c,d,_),C=Mf(c,x.VIDEO,d,_);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 Jt.MEDIA_SOURCE:{Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c);break}case Jt.TRACK:{Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c);break}case Jt.CODEC:const t=[];return Object.keys(s[x.AUDIO]).forEach(n=>{const d=s[x.AUDIO][n];if(d.codec_id_in===c[q.ID]||d.codec_id_out===c[q.ID]){Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c);const _=xv(c);c[q.ID]===d.codec_id_in?t.push({ssrc:d.ssrc,type:ne.AUDIO,value:{codec_in:_}}):t.push({ssrc:d.ssrc,type:ne.AUDIO,value:{codec_out:_}})}}),Object.keys(s[x.VIDEO]).forEach(n=>{const d=s[x.VIDEO][n];if(d.codec_id_in===c[q.ID]||d.codec_id_out===c[q.ID]){Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c);const _=Mv(c);c[q.ID]===d.codec_id_in?t.push({ssrc:d.ssrc,type:ne.VIDEO,value:{codec_in:_}}):t.push({ssrc:d.ssrc,type:ne.VIDEO,value:{codec_out:_}})}}),t;case Jt.REMOTE_INBOUND_RTP:{Pe(Hs,`analyze() - got stats ${c[q.TYPE]} for ${r}`,c);const n=c[q.SSRC],d=ct(n,s,$e.OUTBOUND),_=ct(n,o,$e.OUTBOUND);if(c[q.KIND]===x.AUDIO){const h=xf(c,x.AUDIO,_,d),g=uo(c,x.AUDIO,d),T=kf(c,x.AUDIO,d,_);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[q.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[q.KIND]===x.VIDEO){const h=xf(c,x.VIDEO,_,d),g=uo(c,x.VIDEO,d),T=kf(c,x.VIDEO,d,_);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[q.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[]},Bo=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Hv=(c,s=x.AUDIO,r,o,a)=>{const t=ct(a,c,$e.INBOUND),n=ct(a,r,$e.INBOUND),d=ct(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=d&&d[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 H=_.length>0?Vs(_):100,L=h.length>0?Vs(h):10,ae=93.2-g,N=.18*ae*ae-27.9*ae+1126.62,j=(H+L)/2,Se=j-177.3<0?0:1,ve=.024*j+.11*(j-177.3)*Se,M=N-ve;return Bo(M)},Fv=(c,s=x.AUDIO,r,o,a)=>{const t=ct(a,c,$e.OUTBOUND),n=ct(a,r,$e.OUTBOUND),d=ct(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=d&&d[s].delta_rtt_ms_out||null,A=t[s].delta_jitter_ms_out,C=n&&n[s].delta_jitter_ms_out||null,I=d&&d[s].delta_jitter_ms_out||null,H=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):H&&_.push(H),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?Vs(_):100,j=h.length>0?Vs(h):10,Se=93.2-g,ve=.18*Se*Se-27.9*Se+1126.62,M=(N+j)/2,D=M-177.3<0?0:1,B=.024*M+.11*(M-177.3)*D,V=ve-B;return Bo(V)},jv=(c,s=x.AUDIO,r,o,a)=>{const t=ct(a,c,$e.INBOUND),n=ct(a,r,$e.INBOUND),d=ct(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=d&&d[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),d&&y&&h.push(y);const H=_.length>0?Vs(_):100,L=h.length>0?Vs(h):10,ae=0,N=19.8,j=29.7,Se=30,ve=(H+L)/2+Se,M=ve-177.3<0?0:1,D=.024*ve+.11*(ve-177.3)*M,V=93.2-(ae+N*Math.log(1+j*g)+D);return Bo(V)},qv=(c,s=x.AUDIO,r,o,a)=>{const t=ct(a,c,$e.OUTBOUND),n=ct(a,r,$e.OUTBOUND),d=ct(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=d&&d[s].delta_rtt_ms_out||null,A=t[s].delta_jitter_ms_out,C=n&&n[s].delta_jitter_ms_out||null,I=d&&d[s].delta_jitter_ms_out||null,H=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):H&&_.push(H),E?_.push(E):L&&_.push(L),y?_.push(y):ae&&_.push(ae),A&&h.push(A),n&&C&&h.push(C),d&&I&&h.push(I);const N=_.length>0?Vs(_):100,j=h.length>0?Vs(h):10,Se=0,ve=19.8,M=29.7,D=30,B=(N+j)/2+D,V=B-177.3<0?0:1,J=.024*B+.11*(B-177.3)*V,X=93.2-(Se+ve*Math.log(1+M*g)+J);return Bo(X)};class Vv{constructor(s,r){this._callbacks={onreport:null,onticket:null},this._id=vv(),this._moduleName=this._id,this._probeId=r,this._config=s,this._exporter=new Rv(s),this._state=ps.IDLE,this.registerToPCEvents(),An(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(s,r,o,a){const t=(_,h)=>_===x.AUDIO?h===Jt.INBOUND_RTP?{...b_}:{...w_}:h===Jt.INBOUND_RTP?{...O_}:{...D_},n=dv(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 d=null;return s.forEach(_=>{!d&&_.timestamp&&(d=_.timestamp),$v(_,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=d,Object.keys(n[x.AUDIO]).forEach(_=>{const h=n[x.AUDIO][_];h.direction===$e.INBOUND?(h.mos_emodel_in=Hv(n,x.AUDIO,r,o,h.ssrc),h.mos_in=jv(n,x.AUDIO,r,o,h.ssrc)):(h.mos_emodel_out=Fv(n,x.AUDIO,r,o,h.ssrc),h.mos_out=qv(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(),d=this.analyze(n,null,null,null),_=Date.now();d.experimental.time_to_measure_ms=_-t,d.experimental.time_to_wait_ms=a,this._exporter.saveReferenceReport(d),Pe(this._moduleName,`got reference report for probe ${this._probeId}`),s()}catch(a){r(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==ps.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 cr(this._moduleName,`got error ${s}`),null}}async start(){Pe(this._moduleName,"starting"),this.state=ps.RUNNING,this._startedTime=this._exporter.start(),Pe(this._moduleName,"started")}async mute(){this.state=ps.MUTED,Pe(this._moduleName,"muted")}async unmute(){this.state=ps.RUNNING,Pe(this._moduleName,"unmuted")}async stop(s){if(Pe(this._moduleName,`stopping${s?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=ps.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}'`)):cr(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}'`)):cr(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReport(s){this._callbacks.onreport&&Au(this._callbacks.onreport.callback,this._callbacks.onreport.context,s)}fireOnTicket(s){this._callbacks.onticket&&Au(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{cr(this._moduleName,"can't get devices")}},s){s.oniceconnectionstatechange=()=>{const o=s.iceConnectionState;o===Bi.CONNECTED||o===Bi.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Bi.DISCONNECTED||o===Bi.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Bi.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 Bv{constructor(s){this._id=s.pname&&s.pname.substr(0,12).padEnd(12," ")||Tv(),this._moduleName=this._id,An(this._moduleName,"probe created"),this._config=s,this._collector=new Vv(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===ps.RUNNING}get isIdle(){return this._collector.state===ps.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){Ro(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 Ct="engine ";class Gv{constructor(s){this._config=s,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},An(Ct,`configured for probing every ${this._config.refreshEvery}ms`),An(Ct,`configured for starting after ${this._config.startAfter}ms`),An(Ct,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Pe(Ct,"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=mv(s,r,this._config),a=new Bv(o);return this._probes.push(a),Pe(Ct,`${this._probes.length} probes registered`),a}removeExistingProbe(s){if(!s)throw new Error("undefined probe");s.state===ps.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=hv(),n=this._probes.filter(d=>d.isRunning);for(const d of n){const _=await d.collectStats();_&&t.probes.push(_),Pe(Ct,`got probe ${d.id}`),await Uf(0)}return t.delta_time_to_measure_probes_ms=vn(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=vn(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=vn(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=vn(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=vn(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=vn(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=vn(t.probes,"video","total_time_encoded_out"),t};for(Pe(Ct,"starting to collect"),s(),Pe(Ct,"generating reference reports..."),await r(),Pe(Ct,"reference reports generated"),this._startedTime=Date.now();o();)if(Pe(Ct,`wait ${this._config.refreshEvery}ms before collecting`),await Uf(this._config.refreshEvery),o()){Pe(Ct,"collecting...");const t=Date.now(),n=await a(),d=Date.now();n.delta_time_consumed_to_measure_ms=d-t,this.fireOnReports(n),Pe(Ct,"collected")}Pe(Ct,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(s){const r=o=>{this._probes.forEach(a=>{a.stop(o)})};An(Ct,"stop collecting"),r(s)}registerCallback(s,r,o){s in this._callbacks?(this._callbacks[s]={callback:r,context:o},Pe(Ct,`registered callback '${s}'`)):cr(Ct,`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}'`)):cr(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReports(s){this._callbacks.onresult&&s.probes.length>0&&Au(this._callbacks.onresult.callback,this._callbacks.onresult.context,s)}}const Wv="interface ";class Kv{constructor(s){this._config=gv(s),An(Wv,`welcome to ${this._config.name} version ${this._config.version}`),iv(this._config.verbose||!1),this._engine=new Gv(this._config)}setupLogLevel(s){lv(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 Yv(c,s){return Object.keys(c).filter(r=>s.includes(r)).reduce((r,o)=>{const a=o;return{...r,[a]:c[a]}},{})}const Jv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"];class zv{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=yn.createAnalyser(),a=yn.createMediaStreamSource(s),t=yn.createScriptProcessor(2048,1,1);o.smoothingTimeConstant=.8,o.fftSize=1024,a.connect(o),o.connect(t),t.connect(yn.destination),this.intervals[r]=setInterval(()=>{const n=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(n);let d=0;const _=n.length;for(let g=0;g<_;g++)d+=n[g];const h=d/_;this.onChangeFunction(r,h)},this.emitInterval)}}const co={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},Xv=0;class Qv{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 zv({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 C_()?{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(co.SELECTED_INPUT_DEVICE)||"default",r=localStorage.getItem(co.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(d=>{const _=()=>{d()};r?a.hold({},_):a.unhold({},_)}),this.updateCall(a);const n=Object.values(this.extendedCalls).filter(d=>d.roomId===this.currentActiveRoomId&&(r?s!==d._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===Xv).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]=wf(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]:wf(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=Df(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 nv.forEach(s,async o=>{var n;if(o==null)return;const a=new MediaStream,t=yn.createMediaStreamDestination();if(o.connection.getReceivers().forEach(d=>{r.forEach(_=>{a.addTrack(d.track),d.track.id!==_.id&&yn.createMediaStreamSource(new MediaStream([_])).connect(t)})}),s[0].roomId===this.currentActiveRoomId){const d=this.getActiveStream();yn.createMediaStreamSource(d).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=ev(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(zt.CALL_CONFIRMED,T=>{r.id===T.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(r.id))}),this.context.subscribe(zt.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,d=this.hasAutoAnswerHeaders(s),_=n.direction==="incoming"&&!this.hasActiveCalls&&(d||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:zt.NEW_CALL,session:r,event:s}),r.on("ended",o=>{var t,n,d;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:zt.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),(d=this.initialStreamValue)==null||d.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:zt.CALL_PROGRESS,session:r,event:o})}),r.on("failed",o=>{var t,n,d;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:zt.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),(d=this.initialStreamValue)==null||d.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:zt.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(co.SELECTED_INPUT_DEVICE,s),this.selectedMediaDevices.input=s,this.context.emit("changeActiveInputMediaDevice",s)}setSelectedOutputDevice(s){localStorage.setItem(co.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 Kv(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 d=n.audio[t];if(!d)return;const _=Yv(d,Jv);_.callId=s._id,this.setCallMetrics(_)},this.context.subscribe(zt.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=Df(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]);$T(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 Zv{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 eE{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]=Of(s),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(s){this.activeMessages={...this.activeMessages,[s._id]:Of(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:zt.CALL_ENDED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("failed",o=>{this.triggerMSRPListener({listenerType:zt.CALL_FAILED,session:r,event:o});const a=this.getActiveMessages[r.id];this.activeMessageListRemove(a)}),r.on("confirmed",o=>{this.triggerMSRPListener({listenerType:zt.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 ru={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class tE extends NT{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 ZT.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().setExtraContactUriParams(s.pnExtraHeaders),this.options=s,this.modules=s.modules,r&&HT(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(ru.AUDIO)&&(this.audio=new Qv(this)),this.modules.includes(ru.MSRP)&&(this.msrp=new eE(this)),this.modules.includes(ru.VIDEO)&&(this.video=new Zv(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)}}module.exports=tE;
155
+ a=path:${n.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 so(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:p=>{this.onTransportError(),console.log(p)},onAuthenticated:p=>{this._request=p},onReceiveResponse:p=>{this._receiveInviteResponse(p),console.log("dialog af",this._dialog),p.status_code===200&&(p.parseSDP(!0),this._status=Me.STATUS_CONFIRMED,this.target_addr=p.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=Me.STATUS_INVITE_SENT}terminate(n={}){console.log("terminate",this);const a=n.cause||z.causes.BYE,e=Ge.cloneArray(n.extraHeaders),o=n.body;let p,t=n.status_code,v=n.reason_phrase;if(this._status===Me.STATUS_TERMINATED)throw new Kl.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Me.STATUS_NULL:case Me.STATUS_INVITE_SENT:case Me.STATUS_1XX_RECEIVED:if(t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);t&&(v=v||z.REASON_PHRASE[t]||"",p=`SIP ;cause=${t} ;text="${v}"`),this._status===Me.STATUS_NULL||this._status===Me.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=p):this._status===Me.STATUS_1XX_RECEIVED&&this._request.cancel(p),this._status=Me.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,z.causes.CANCELED);break;case Me.STATUS_WAITING_FOR_ANSWER:case Me.STATUS_ANSWERED:if(t=t||480,console.log("REPLY 480"),t<300||t>=700)throw new TypeError(`Invalid status_code: ${t}`);this._request.reply(t,v,e,o),console.log("failed 2"),this._failed("local",null,z.causes.REJECTED);break;case Me.STATUS_WAITING_FOR_ACK:case Me.STATUS_CONFIRMED:if(v=n.reason_phrase||z.REASON_PHRASE[t]||"",t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);if(t&&e.push(`Reason: SIP ;cause=${t}; text="${v}"`),this._status===Me.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ss.C.STATUS_TERMINATED){const C=this._dialog;this.receiveRequest=({method:l})=>{l===z.ACK&&(this.sendRequest(z.BYE,{extraHeaders:e,body:o}),C.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Ss.C.STATUS_TERMINATED&&(this.sendRequest(z.BYE,{extraHeaders:e,body:o}),C.terminate())}),this._ended("local",null,a),this._dialog=C,this._ua.newDialog(C)}else console.log("here it is"),this.sendRequest(z.BYE,{extraHeaders:e,body:o}),this._ended("local",null,a)}}sendRequest(n,a){return this._dialog.sendRequest(n,a)}authenticate(n){this.status="auth";let a=new ti("");a.method="AUTH",a.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),a.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),n&&a.addHeader("Authorization",n.toString());let e=a.toString();console.log(e);let o=[];for(var p=0;p<e.length;p++)o.push(e.charCodeAt(p).toString(16));console.log(o),this._connection.send(a.toString())}onmessage(n){console.log("onmessage",n);const a=new ti(n.data);if(this.status==="auth"&&a.code===401){const e=this.parseAuth(a.getHeader("WWW-Authenticate")),o=new Km(this.credentials);o.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},e,Ge.createRandomToken(12)),this.authenticate(o)}this.status==="auth"&&a.code===200&&this._direction==="outgoing"?(this.my_addr.push(a.getHeader("To-Path")),this.my_addr.push(a.getHeader("Use-Path")),this.status="active",this.inviteParty(a)):this.status==="auth"&&a.code===200&&this._direction==="incoming"?(this.my_addr.push(a.getHeader("To-Path")),this.my_addr.push(a.getHeader("Use-Path")),this.status="active",this.acceptParty(a),this.emit("confirmed")):a.method==="SEND"&&(this._sendOk(a),this._sendReport(a),a.direction="incoming",this.emit("newMessage",a),this._msgHistory.push(a),this.emit("msgHistoryUpdate",this._msgHistory),console.log("======================================================================")),a.code===480&&this._close()}onclose(){console.log("close")}onopen(){const n=new RTCPeerConnection({iceServers:[]});n.createDataChannel(""),n.createOffer().then(n.setLocalDescription.bind(n)),n.onicecandidate=a=>{if(!a||!a.candidate||!a.candidate.candidate)return;const e=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,o=a.candidate.candidate.match(e);this.my_ip=o&&o[1],n.onicecandidate=()=>{},this.authenticate(null)}}onerror(n){console.log(n)}_receiveInviteResponse(n){if(console.log("resp0000000000000",n),this._dialog&&n.status_code>=200&&n.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.sendRequest(z.ACK);return}else{const a=new va(this,n,"UAC");if(a.error!==void 0){console.log(a.error);return}this.sendRequest(z.ACK),this.sendRequest(z.BYE);return}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==Me.STATUS_INVITE_SENT&&this._status!==Me.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(n.status_code):this._status=Me.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){console.log("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=Me.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const a={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>this._progress("remote",n)).catch(o=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(console.log("maybe here???"),this._status=Me.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,z.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",n,z.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const a={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",a),new RTCSessionDescription({type:"answer",sdp:a.sdp}),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(e=>this._connection.setLocalDescription(e)).catch(e=>{this._acceptAndTerminate(n,500,e.toString()),console.log("failed 4"),this._failed("local",n,z.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(z.ACK),this._confirmed("local",null)});break}default:{const a=Ge.sipErrorCause(n.status_code);console.log("failed 5"),this._failed("remote",n,a)}}}sendMSRP(n){const a=new ti("");a.method="SEND",a.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",Ge.createRandomToken(10)),a.addHeader("Byte-Range","1-25/25"),a.addHeader("Content-Type","text/plain"),a.addHeader("Success-Report","yes"),a.addHeader("Failure-Report","yes"),a.body=n;let e=a.toString();console.log(e);let o=[];for(var p=0;p<e.length;p++)o.push(e.charCodeAt(p).toString(16));console.log(o),this._connection.send(a.toString()),a.direction="outgoing",this.emit("newMessage",a),this._msgHistory.push(a),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(n){let a=n.ident,e=n.getHeader("Message-ID"),o=new ti("");o.method="200 OK",o.addHeader("To-Path",`${this.my_addr[1]}`),o.addHeader("From-Path",`${this.my_addr[0]}`),o.addHeader("Message-ID",e),o.ident=a;let p=o.toString();console.log(p);let t=[];for(var v=0;v<p.length;v++)t.push(p.charCodeAt(v).toString(16));console.log(t),this._connection.send(o.toString())}_sendReport(n){let a=n.ident,e=n.getHeader("Message-ID"),o=new ti("");o.method="REPORT",o.addHeader("To-Path",`${n.getHeader("From-Path")}`),o.addHeader("From-Path",`${this.my_addr[0]}`),o.addHeader("Message-ID",e),o.addHeader("Byte-Range","1-25/25"),o.addHeader("Status","000 200 OK"),o.ident=a;let p=o.toString();console.log(p);let t=[];for(var v=0;v<p.length;v++)t.push(p.charCodeAt(v).toString(16));console.log(t),this._connection.send(o.toString())}parseAuth(n){const a={},e=n.replace("Digest","").split(",");for(const o of e){const p=o.trim().split("=");a[p[0]]=p[1].match('^"(.+)"$')[1]}return a}init_incoming(n,a){let e;const o=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&o!=="application/sdp"){n.reply(415);return}if(this._status=Me.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(e=n.getHeader("expires")*1e3),n.to_tag=Ge.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Me.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),console.log("failed 6"),this._failed("local",null,z.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),e&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Me.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),console.log("failed 7"),this._failed("system",null,z.causes.EXPIRES))},e)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,a&&a(this),n.parseSDP(!0),this.target_addr=n.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",n),this._status!==Me.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(n,a,e){this.emit("_failed",{originator:n,message:a||null,cause:e}),this._close(),this.emit("failed",{originator:n,message:a||null,cause:e})}_close(){if(console.log("CLOSE SESSION"),this._status!==Me.STATUS_TERMINATED){if(this._status=Me.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){console.log("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyMSRPSession(this)}}_createDialog(n,a,e){const o=a==="UAS"?n.to_tag:n.from_tag,p=a==="UAS"?n.from_tag:n.to_tag,t=n.call_id+o+p;let v=this._earlyDialogs[t];if(e)return v?!0:(v=new va(this,n,a,va.C.STATUS_EARLY),v.error?(console.log("failed 8"),this._failed("remote",n,z.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[t]=v,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,v)return v.update(n,a),this._dialog=v,delete this._earlyDialogs[t],!0;const C=new va(this,n,a);return C.error?(console.log("failed 9"),this._failed("remote",n,z.causes.INTERNAL_ERROR),!1):(this._dialog=C,!0)}}_newMSRPSession(n,a){this._ua.newMSRPSession(this,{originator:n,session:this,request:a})}_progress(n,a){this.emit("progress",{originator:n,response:a||null})}isEnded(){switch(this._status){case Me.STATUS_CANCELED:case Me.STATUS_TERMINATED:return!0;default:return!1}}_accepted(n,a){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:n,response:a||null})}_confirmed(n,a){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:a||null})}_ended(n,a,e){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:n,message:a||null,cause:e})}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let a;n.session_expires&&n.session_expires>=z.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,a=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,a="uac"),this._sessionTimers.refresher=a==="uac",this._runSessionTimer()}receiveRequest(n){if(console.log("receiveRequest()"),n.method===z.CANCEL)(this._status===Me.STATUS_WAITING_FOR_ANSWER||this._status===Me.STATUS_ANSWERED)&&(this._status=Me.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",n,z.causes.CANCELED));else switch(n.method){case z.ACK:if(this._status!==Me.STATUS_WAITING_FOR_ACK)return;if(this._status=Me.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:z.causes.MISSING_SDP,status_code:400});break}const a={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(o=>{this.terminate({cause:z.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})}else this._is_confirmed||this._confirmed("remote",n);break;case z.BYE:this._status===Me.STATUS_CONFIRMED||this._status===Me.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,z.causes.BYE)):this._status===Me.STATUS_INVITE_RECEIVED||this._status===Me.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,z.causes.BYE)):n.reply(403,"Wrong Status");break;case z.INVITE:this._status===Me.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case z.INFO:this._status===Me.STATUS_1XX_RECEIVED||this._status===Me.STATUS_WAITING_FOR_ANSWER||this._status===Me.STATUS_ANSWERED||this._status===Me.STATUS_WAITING_FOR_ACK||this._status===Me.STATUS_CONFIRMED?(n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new Ru(this).init_incoming(n):n.reply(415):n.reply(403,"Wrong Status");break;case z.UPDATE:this._status===Me.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case z.REFER:this._status===Me.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case z.NOTIFY:this._status===Me.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Me.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:z.causes.CONNECTION_ERROR,cause:z.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Me.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:z.causes.REQUEST_TIMEOUT,cause:z.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Me.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:z.causes.DIALOG_ERROR,cause:z.causes.DIALOG_ERROR})}}var kv=fo();const si=ot(kv);function Dh(u){return'"'+u.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 Bi={parse:function(u,n){var a={CRLF:v,DIGIT:C,ALPHA:l,HEXDIG:A,WSP:b,OCTET:E,DQUOTE:O,SP:w,HTAB:N,alphanum:U,reserved:Y,unreserved:j,mark:_e,escaped:k,LWS:H,SWS:de,HCOLON:Ue,TEXT_UTF8_TRIM:B,TEXT_UTF8char:L,UTF8_NONASCII:V,UTF8_CONT:G,LHEX:K,token:M,token_nodot:te,separators:se,word:$,STAR:ne,SLASH:ct,EQUAL:P,LPAREN:Q,RPAREN:oe,RAQUOT:he,LAQUOT:Re,COMMA:be,SEMI:fe,COLON:qe,LDQUOT:xe,RDQUOT:we,comment:st,ctext:$e,quoted_string:ue,quoted_string_clean:Oe,qdtext:Pe,quoted_pair:Le,SIP_URI_noparams:ye,SIP_URI:pe,uri_scheme:Ce,uri_scheme_sips:ke,uri_scheme_sip:He,userinfo:Be,user:Ve,user_unreserved:Mt,password:ft,hostport:Gs,host:is,hostname:As,domainlabel:ys,toplabel:as,IPv6reference:Ws,IPv6address:os,h16:Se,ls32:ht,IPv4address:Xt,dec_octet:Ae,port:pt,uri_parameters:us,uri_parameter:me,transport_param:Tt,user_param:Rs,method_param:cs,ttl_param:Wn,maddr_param:Kn,lr_param:pn,other_param:Yn,pname:zn,pvalue:Jn,paramchar:bs,param_unreserved:Xn,headers:Qn,header:Qt,hname:Zn,hvalue:el,hnv_unreserved:kt,Request_Response:er,Request_Line:tl,Request_URI:Zt,absoluteURI:sl,hier_part:nl,net_path:Is,abs_path:Ks,opaque_part:ll,uric:ws,uric_no_slash:Os,path_segments:rl,segment:es,param:Ds,pchar:Ns,scheme:ts,authority:mn,srvr:Us,reg_name:Ys,query:gn,SIP_Version:fs,INVITEm:il,ACKm:al,OPTIONSm:vn,BYEm:ol,CANCELm:ul,REGISTERm:Tn,SUBSCRIBEm:cl,NOTIFYm:fl,REFERm:hl,Method:zs,Status_Line:_l,Status_Code:dl,extension_code:Js,Reason_Phrase:pl,Allow_Events:tr,Call_ID:En,Contact:sr,contact_param:Cn,name_addr:hs,display_name:Sn,contact_params:Xs,c_p_q:_s,c_p_expires:An,delta_seconds:Lt,qvalue:ss,generic_param:Ke,gen_value:Gt,Content_Disposition:nr,disp_type:Je,disp_param:Wt,handling_param:lr,Content_Encoding:Ze,Content_Length:ml,Content_Type:$r,media_type:rr,m_type:gl,discrete_type:ir,composite_type:ar,extension_token:yn,x_token:or,m_subtype:vl,m_parameter:xs,m_value:Tl,CSeq:ur,CSeq_value:Ps,Expires:cr,Event:Hr,event_type:ds,From:Fr,from_param:fr,tag_param:ps,Max_Forwards:fi,Min_Expires:hr,Name_Addr_Header:Ms,Proxy_Authenticate:hi,challenge:Rn,other_challenge:El,auth_param:bn,digest_cln:Qs,realm:_r,realm_value:Zs,domain:ks,URI:en,nonce:Ls,nonce_value:tn,opaque:sn,stale:Cl,algorithm:Sl,qop_options:nn,qop_value:ln,Proxy_Require:dr,Record_Route:pr,rec_route:ms,Reason:qr,reason_param:Al,reason_cause:gs,Require:_i,Route:mr,route_param:vs,Subscription_State:di,substate_value:yl,subexp_params:$s,event_reason_value:jr,Subject:Vr,Supported:rn,To:Br,to_param:Rl,Via:gr,via_param:In,via_params:wn,via_ttl:Gr,via_maddr:On,via_received:an,via_branch:vr,response_port:on,rport:Dn,sent_protocol:bl,protocol_name:Il,transport:wl,sent_by:Ol,via_host:Dl,via_port:Nl,ttl:Nn,WWW_Authenticate:Tr,Session_Expires:Er,s_e_expires:Un,s_e_params:Ul,s_e_refresher:Cr,extension_header:xl,header_value:Pl,message_body:Wr,uuid_URI:Kr,uuid:xn,hex4:Kt,hex8:Yr,hex12:Ml,Refer_To:ns,Replaces:zr,call_id:kl,replaces_param:jt,to_tag:Sr,from_tag:Ll,early_flag:$l};if(n!==void 0){if(a[n]===void 0)throw new Error("Invalid rule name: "+Dh(n)+".")}else n="CRLF";var e=0,o=0,p=[];function t(i){e<o||(e>o&&(o=e,p=[]),p.push(i))}function v(){var i;return u.substr(e,2)===`\r
157
+ `?(i=`\r
158
+ `,e+=2):(i=null,t('"\\r\\n"')),i}function C(){var i;return/^[0-9]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[0-9]")),i}function l(){var i;return/^[a-zA-Z]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[a-zA-Z]")),i}function A(){var i;return/^[0-9a-fA-F]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[0-9a-fA-F]")),i}function b(){var i;return i=w(),i===null&&(i=N()),i}function E(){var i;return/^[\0-\xFF]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\0-\\xFF]")),i}function O(){var i;return/^["]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t('["]')),i}function w(){var i;return u.charCodeAt(e)===32?(i=" ",e++):(i=null,t('" "')),i}function N(){var i;return u.charCodeAt(e)===9?(i=" ",e++):(i=null,t('"\\t"')),i}function U(){var i;return/^[a-zA-Z0-9]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[a-zA-Z0-9]")),i}function Y(){var i;return u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","'))))))))))),i}function j(){var i;return i=U(),i===null&&(i=_e()),i}function _e(){var i;return u.charCodeAt(e)===45?(i="-",e++):(i=null,t('"-"')),i===null&&(u.charCodeAt(e)===95?(i="_",e++):(i=null,t('"_"')),i===null&&(u.charCodeAt(e)===46?(i=".",e++):(i=null,t('"."')),i===null&&(u.charCodeAt(e)===33?(i="!",e++):(i=null,t('"!"')),i===null&&(u.charCodeAt(e)===126?(i="~",e++):(i=null,t('"~"')),i===null&&(u.charCodeAt(e)===42?(i="*",e++):(i=null,t('"*"')),i===null&&(u.charCodeAt(e)===39?(i="'",e++):(i=null,t(`"'"`)),i===null&&(u.charCodeAt(e)===40?(i="(",e++):(i=null,t('"("')),i===null&&(u.charCodeAt(e)===41?(i=")",e++):(i=null,t('")"')))))))))),i}function k(){var i,_,m,T,y;return T=e,y=e,u.charCodeAt(e)===37?(i="%",e++):(i=null,t('"%"')),i!==null?(_=A(),_!==null?(m=A(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){return f.join("")}(T,i)),i===null&&(e=T),i}function H(){var i,_,m,T,y,r;for(T=e,y=e,r=e,i=[],_=b();_!==null;)i.push(_),_=b();if(i!==null?(_=v(),_!==null?i=[i,_]:(i=null,e=r)):(i=null,e=r),i=i!==null?i:"",i!==null){if(m=b(),m!==null)for(_=[];m!==null;)_.push(m),m=b();else _=null;_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i!==null&&(i=function(f){return" "}()),i===null&&(e=T),i}function de(){var i;return i=H(),i=i!==null?i:"",i}function Ue(){var i,_,m,T,y;for(T=e,y=e,i=[],_=w(),_===null&&(_=N());_!==null;)i.push(_),_=w(),_===null&&(_=N());return i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return":"}()),i===null&&(e=T),i}function B(){var i,_,m,T,y,r,f;if(y=e,r=e,_=L(),_!==null)for(i=[];_!==null;)i.push(_),_=L();else i=null;if(i!==null){for(_=[],f=e,m=[],T=H();T!==null;)m.push(T),T=H();for(m!==null?(T=L(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;){for(_.push(m),f=e,m=[],T=H();T!==null;)m.push(T),T=H();m!==null?(T=L(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f)}_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){return u.substring(e,d)}(y)),i===null&&(e=y),i}function L(){var i;return/^[!-~]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[!-~]")),i===null&&(i=V()),i}function V(){var i;return/^[\x80-\uFFFF]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\x80-\\uFFFF]")),i}function G(){var i;return/^[\x80-\xBF]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\x80-\\xBF]")),i}function K(){var i;return i=C(),i===null&&(/^[a-f]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[a-f]"))),i}function M(){var i,_,m;if(m=e,_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"'))))))))))));else i=null;return i!==null&&(i=function(T){return u.substring(e,T)}(m)),i===null&&(e=m),i}function te(){var i,_,m;if(m=e,_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"'))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')))))))))));else i=null;return i!==null&&(i=function(T){return u.substring(e,T)}(m)),i===null&&(e=m),i}function se(){var i;return u.charCodeAt(e)===40?(i="(",e++):(i=null,t('"("')),i===null&&(u.charCodeAt(e)===41?(i=")",e++):(i=null,t('")"')),i===null&&(u.charCodeAt(e)===60?(i="<",e++):(i=null,t('"<"')),i===null&&(u.charCodeAt(e)===62?(i=">",e++):(i=null,t('">"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')),i===null&&(u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===92?(i="\\",e++):(i=null,t('"\\\\"')),i===null&&(i=O(),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i===null&&(u.charCodeAt(e)===93?(i="]",e++):(i=null,t('"]"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===123?(i="{",e++):(i=null,t('"{"')),i===null&&(u.charCodeAt(e)===125?(i="}",e++):(i=null,t('"}"')),i===null&&(i=w(),i===null&&(i=N())))))))))))))))))),i}function $(){var i,_,m;if(m=e,_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')),_===null&&(u.charCodeAt(e)===40?(_="(",e++):(_=null,t('"("')),_===null&&(u.charCodeAt(e)===41?(_=")",e++):(_=null,t('")"')),_===null&&(u.charCodeAt(e)===60?(_="<",e++):(_=null,t('"<"')),_===null&&(u.charCodeAt(e)===62?(_=">",e++):(_=null,t('">"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===92?(_="\\",e++):(_=null,t('"\\\\"')),_===null&&(_=O(),_===null&&(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_===null&&(u.charCodeAt(e)===91?(_="[",e++):(_=null,t('"["')),_===null&&(u.charCodeAt(e)===93?(_="]",e++):(_=null,t('"]"')),_===null&&(u.charCodeAt(e)===63?(_="?",e++):(_=null,t('"?"')),_===null&&(u.charCodeAt(e)===123?(_="{",e++):(_=null,t('"{"')),_===null&&(u.charCodeAt(e)===125?(_="}",e++):(_=null,t('"}"'))))))))))))))))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')),_===null&&(u.charCodeAt(e)===40?(_="(",e++):(_=null,t('"("')),_===null&&(u.charCodeAt(e)===41?(_=")",e++):(_=null,t('")"')),_===null&&(u.charCodeAt(e)===60?(_="<",e++):(_=null,t('"<"')),_===null&&(u.charCodeAt(e)===62?(_=">",e++):(_=null,t('">"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===92?(_="\\",e++):(_=null,t('"\\\\"')),_===null&&(_=O(),_===null&&(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_===null&&(u.charCodeAt(e)===91?(_="[",e++):(_=null,t('"["')),_===null&&(u.charCodeAt(e)===93?(_="]",e++):(_=null,t('"]"')),_===null&&(u.charCodeAt(e)===63?(_="?",e++):(_=null,t('"?"')),_===null&&(u.charCodeAt(e)===123?(_="{",e++):(_=null,t('"{"')),_===null&&(u.charCodeAt(e)===125?(_="}",e++):(_=null,t('"}"')))))))))))))))))))))))));else i=null;return i!==null&&(i=function(T){return u.substring(e,T)}(m)),i===null&&(e=m),i}function ne(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"*"}()),i===null&&(e=T),i}function ct(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"/"}()),i===null&&(e=T),i}function P(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"="}()),i===null&&(e=T),i}function Q(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===40?(_="(",e++):(_=null,t('"("')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"("}()),i===null&&(e=T),i}function oe(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===41?(_=")",e++):(_=null,t('")"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return")"}()),i===null&&(e=T),i}function he(){var i,_,m,T;return m=e,T=e,u.charCodeAt(e)===62?(i=">",e++):(i=null,t('">"')),i!==null?(_=de(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return">"}()),i===null&&(e=m),i}function Re(){var i,_,m,T;return m=e,T=e,i=de(),i!==null?(u.charCodeAt(e)===60?(_="<",e++):(_=null,t('"<"')),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return"<"}()),i===null&&(e=m),i}function be(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return","}()),i===null&&(e=T),i}function fe(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return";"}()),i===null&&(e=T),i}function qe(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return":"}()),i===null&&(e=T),i}function xe(){var i,_,m,T;return m=e,T=e,i=de(),i!==null?(_=O(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return'"'}()),i===null&&(e=m),i}function we(){var i,_,m,T;return m=e,T=e,i=O(),i!==null?(_=de(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return'"'}()),i===null&&(e=m),i}function st(){var i,_,m,T;if(T=e,i=Q(),i!==null){for(_=[],m=$e(),m===null&&(m=Le(),m===null&&(m=st()));m!==null;)_.push(m),m=$e(),m===null&&(m=Le(),m===null&&(m=st()));_!==null?(m=oe(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)}else i=null,e=T;return i}function $e(){var i;return/^[!-']/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[!-']")),i===null&&(/^[*-[]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[*-[]")),i===null&&(/^[\]-~]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\]-~]")),i===null&&(i=V(),i===null&&(i=H())))),i}function ue(){var i,_,m,T,y,r;if(y=e,r=e,i=de(),i!==null)if(_=O(),_!==null){for(m=[],T=Pe(),T===null&&(T=Le());T!==null;)m.push(T),T=Pe(),T===null&&(T=Le());m!==null?(T=O(),T!==null?i=[i,_,m,T]:(i=null,e=r)):(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i!==null&&(i=function(f){return u.substring(e,f)}(y)),i===null&&(e=y),i}function Oe(){var i,_,m,T,y,r;if(y=e,r=e,i=de(),i!==null)if(_=O(),_!==null){for(m=[],T=Pe(),T===null&&(T=Le());T!==null;)m.push(T),T=Pe(),T===null&&(T=Le());m!==null?(T=O(),T!==null?i=[i,_,m,T]:(i=null,e=r)):(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i!==null&&(i=function(f){var d=u.substring(e,f).trim();return d.substring(1,d.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(y)),i===null&&(e=y),i}function Pe(){var i;return i=H(),i===null&&(u.charCodeAt(e)===33?(i="!",e++):(i=null,t('"!"')),i===null&&(/^[#-[]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[#-[]")),i===null&&(/^[\]-~]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\]-~]")),i===null&&(i=V())))),i}function Le(){var i,_,m;return m=e,u.charCodeAt(e)===92?(i="\\",e++):(i=null,t('"\\\\"')),i!==null?(/^[\0-\t]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[\\0-\\t]")),_===null&&(/^[\x0B-\f]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[\\x0B-\\f]")),_===null&&(/^[\x0E-]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[\\x0E-]")))),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function ye(){var i,_,m,T,y,r;return y=e,r=e,i=Ce(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Be(),m=m!==null?m:"",m!==null?(T=Gs(),T!==null?i=[i,_,m,T]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i!==null&&(i=function(f){try{x.uri=new Yl(x.scheme,x.user,x.host,x.port),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port}catch{x=-1}}()),i===null&&(e=y),i}function pe(){var i,_,m,T,y,r,f,d;return f=e,d=e,i=Ce(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Be(),m=m!==null?m:"",m!==null?(T=Gs(),T!==null?(y=us(),y!==null?(r=Qn(),r=r!==null?r:"",r!==null?i=[i,_,m,T,y,r]:(i=null,e=d)):(i=null,e=d)):(i=null,e=d)):(i=null,e=d)):(i=null,e=d)):(i=null,e=d),i!==null&&(i=function(c){try{x.uri=new Yl(x.scheme,x.user,x.host,x.port,x.uri_params,x.uri_headers),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port,delete x.uri_params,n==="SIP_URI"&&(x=x.uri)}catch{x=-1}}()),i===null&&(e=f),i}function Ce(){var i;return i=ke(),i===null&&(i=He()),i}function ke(){var i,_;return _=e,u.substr(e,4).toLowerCase()==="sips"?(i=u.substr(e,4),e+=4):(i=null,t('"sips"')),i!==null&&(i=function(m,T){x.scheme=T.toLowerCase()}(_,i)),i===null&&(e=_),i}function He(){var i,_;return _=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"sip"')),i!==null&&(i=function(T,y){x.scheme=y.toLowerCase()}(_,i)),i===null&&(e=_),i}function Be(){var i,_,m,T,y,r;return T=e,y=e,i=Ve(),i!==null?(r=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=ft(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?(u.charCodeAt(e)===64?(m="@",e++):(m=null,t('"@"')),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x.user=decodeURIComponent(u.substring(e-1,f))}(T)),i===null&&(e=T),i}function Ve(){var i,_;if(_=j(),_===null&&(_=k(),_===null&&(_=Mt())),_!==null)for(i=[];_!==null;)i.push(_),_=j(),_===null&&(_=k(),_===null&&(_=Mt()));else i=null;return i}function Mt(){var i;return u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')),i===null&&(u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"'))))))))),i}function ft(){var i,_,m;for(m=e,i=[],_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","'))))))));_!==null;)i.push(_),_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","'))))))));return i!==null&&(i=function(T){x.password=u.substring(e,T)}(m)),i===null&&(e=m),i}function Gs(){var i,_,m,T,y;return T=e,i=is(),i!==null?(y=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=pt(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function is(){var i,_;return _=e,i=As(),i===null&&(i=Xt(),i===null&&(i=Ws())),i!==null&&(i=function(m){return x.host=u.substring(e,m).toLowerCase(),x.host}(_)),i===null&&(e=_),i}function As(){var i,_,m,T,y,r;for(T=e,y=e,i=[],r=e,_=ys(),_!==null?(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r);_!==null;)i.push(_),r=e,_=ys(),_!==null?(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r);return i!==null?(_=as(),_!==null?(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m=m!==null?m:"",m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){return x.host_type="domain",u.substring(e,f)}(T)),i===null&&(e=T),i}function ys(){var i,_,m,T;if(T=e,i=U(),i!==null){for(_=[],m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));m!==null;)_.push(m),m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));_!==null?i=[i,_]:(i=null,e=T)}else i=null,e=T;return i}function as(){var i,_,m,T;if(T=e,i=l(),i!==null){for(_=[],m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));m!==null;)_.push(m),m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));_!==null?i=[i,_]:(i=null,e=T)}else i=null,e=T;return i}function Ws(){var i,_,m,T,y;return T=e,y=e,u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i!==null?(_=os(),_!==null?(u.charCodeAt(e)===93?(m="]",e++):(m=null,t('"]"')),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return x.host_type="IPv6",u.substring(e,r)}(T)),i===null&&(e=T),i}function os(){var i,_,m,T,y,r,f,d,s,c,h,g,S,R,I,D;return R=e,I=e,i=Se(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?(u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?(u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?(u.charCodeAt(e)===58?(d=":",e++):(d=null,t('":"')),d!==null?(s=Se(),s!==null?(u.charCodeAt(e)===58?(c=":",e++):(c=null,t('":"')),c!==null?(h=Se(),h!==null?(u.charCodeAt(e)===58?(g=":",e++):(g=null,t('":"')),g!==null?(S=ht(),S!==null?i=[i,_,m,T,y,r,f,d,s,c,h,g,S]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?(u.charCodeAt(e)===58?(s=":",e++):(s=null,t('":"')),s!==null?(c=Se(),c!==null?(u.charCodeAt(e)===58?(h=":",e++):(h=null,t('":"')),h!==null?(g=ht(),g!==null?i=[i,_,m,T,y,r,f,d,s,c,h,g]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?(u.charCodeAt(e)===58?(s=":",e++):(s=null,t('":"')),s!==null?(c=ht(),c!==null?i=[i,_,m,T,y,r,f,d,s,c]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=ht(),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=ht(),r!==null?i=[i,_,m,T,y,r]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=ht(),T!==null?i=[i,_,m,T]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=ht(),_!==null?i=[i,_]:(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?i=[i,_]:(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(u.substr(e,2)==="::"?(_="::",e+=2):(_=null,t('"::"')),_!==null?(m=Se(),m!==null?(u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?(u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?(u.charCodeAt(e)===58?(d=":",e++):(d=null,t('":"')),d!==null?(s=Se(),s!==null?(u.charCodeAt(e)===58?(c=":",e++):(c=null,t('":"')),c!==null?(h=ht(),h!==null?i=[i,_,m,T,y,r,f,d,s,c,h]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(u.substr(e,2)==="::"?(m="::",e+=2):(m=null,t('"::"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?(u.charCodeAt(e)===58?(s=":",e++):(s=null,t('":"')),s!==null?(c=ht(),c!==null?i=[i,_,m,T,y,r,f,d,s,c]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(u.substr(e,2)==="::"?(T="::",e+=2):(T=null,t('"::"')),T!==null?(y=Se(),y!==null?(u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?(u.charCodeAt(e)===58?(d=":",e++):(d=null,t('":"')),d!==null?(s=ht(),s!==null?i=[i,_,m,T,y,r,f,d,s]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(u.substr(e,2)==="::"?(y="::",e+=2):(y=null,t('"::"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=ht(),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(D=e,u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?y=[y,r]:(y=null,e=D)):(y=null,e=D),y=y!==null?y:"",y!==null?(u.substr(e,2)==="::"?(r="::",e+=2):(r=null,t('"::"')),r!==null?(f=ht(),f!==null?i=[i,_,m,T,y,r,f]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(D=e,u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?y=[y,r]:(y=null,e=D)):(y=null,e=D),y=y!==null?y:"",y!==null?(D=e,u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?r=[r,f]:(r=null,e=D)):(r=null,e=D),r=r!==null?r:"",r!==null?(u.substr(e,2)==="::"?(f="::",e+=2):(f=null,t('"::"')),f!==null?(d=Se(),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(D=e,u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?y=[y,r]:(y=null,e=D)):(y=null,e=D),y=y!==null?y:"",y!==null?(D=e,u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?r=[r,f]:(r=null,e=D)):(r=null,e=D),r=r!==null?r:"",r!==null?(D=e,u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?f=[f,d]:(f=null,e=D)):(f=null,e=D),f=f!==null?f:"",f!==null?(u.substr(e,2)==="::"?(d="::",e+=2):(d=null,t('"::"')),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I))))))))))))))),i!==null&&(i=function(J){return x.host_type="IPv6",u.substring(e,J)}(R)),i===null&&(e=R),i}function Se(){var i,_,m,T,y;return y=e,i=A(),i!==null?(_=A(),_=_!==null?_:"",_!==null?(m=A(),m=m!==null?m:"",m!==null?(T=A(),T=T!==null?T:"",T!==null?i=[i,_,m,T]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i}function ht(){var i,_,m,T;return T=e,i=Se(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i===null&&(i=Xt()),i}function Xt(){var i,_,m,T,y,r,f,d,s;return d=e,s=e,i=Ae(),i!==null?(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_!==null?(m=Ae(),m!==null?(u.charCodeAt(e)===46?(T=".",e++):(T=null,t('"."')),T!==null?(y=Ae(),y!==null?(u.charCodeAt(e)===46?(r=".",e++):(r=null,t('"."')),r!==null?(f=Ae(),f!==null?i=[i,_,m,T,y,r,f]:(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s),i!==null&&(i=function(c){return x.host_type="IPv4",u.substring(e,c)}(d)),i===null&&(e=d),i}function Ae(){var i,_,m,T;return T=e,u.substr(e,2)==="25"?(i="25",e+=2):(i=null,t('"25"')),i!==null?(/^[0-5]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[0-5]")),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i===null&&(T=e,u.charCodeAt(e)===50?(i="2",e++):(i=null,t('"2"')),i!==null?(/^[0-4]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[0-4]")),_!==null?(m=C(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i===null&&(T=e,u.charCodeAt(e)===49?(i="1",e++):(i=null,t('"1"')),i!==null?(_=C(),_!==null?(m=C(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i===null&&(T=e,/^[1-9]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[1-9]")),i!==null?(_=C(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i===null&&(i=C())))),i}function pt(){var i,_,m,T,y,r,f;return r=e,f=e,i=C(),i=i!==null?i:"",i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?i=[i,_,m,T,y]:(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(d,s){return s=parseInt(s.join("")),x.port=s,s}(r,i)),i===null&&(e=r),i}function us(){var i,_,m,T;for(i=[],T=e,u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_!==null?(m=me(),m!==null?_=[_,m]:(_=null,e=T)):(_=null,e=T);_!==null;)i.push(_),T=e,u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_!==null?(m=me(),m!==null?_=[_,m]:(_=null,e=T)):(_=null,e=T);return i}function me(){var i;return i=Tt(),i===null&&(i=Rs(),i===null&&(i=cs(),i===null&&(i=Wn(),i===null&&(i=Kn(),i===null&&(i=pn(),i===null&&(i=Yn())))))),i}function Tt(){var i,_,m,T;return m=e,T=e,u.substr(e,10).toLowerCase()==="transport="?(i=u.substr(e,10),e+=10):(i=null,t('"transport="')),i!==null?(u.substr(e,3).toLowerCase()==="udp"?(_=u.substr(e,3),e+=3):(_=null,t('"udp"')),_===null&&(u.substr(e,3).toLowerCase()==="tcp"?(_=u.substr(e,3),e+=3):(_=null,t('"tcp"')),_===null&&(u.substr(e,4).toLowerCase()==="sctp"?(_=u.substr(e,4),e+=4):(_=null,t('"sctp"')),_===null&&(u.substr(e,3).toLowerCase()==="tls"?(_=u.substr(e,3),e+=3):(_=null,t('"tls"')),_===null&&(_=M())))),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.transport=r.toLowerCase()}(m,i[1])),i===null&&(e=m),i}function Rs(){var i,_,m,T;return m=e,T=e,u.substr(e,5).toLowerCase()==="user="?(i=u.substr(e,5),e+=5):(i=null,t('"user="')),i!==null?(u.substr(e,5).toLowerCase()==="phone"?(_=u.substr(e,5),e+=5):(_=null,t('"phone"')),_===null&&(u.substr(e,2).toLowerCase()==="ip"?(_=u.substr(e,2),e+=2):(_=null,t('"ip"')),_===null&&(_=M())),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.user=r.toLowerCase()}(m,i[1])),i===null&&(e=m),i}function cs(){var i,_,m,T;return m=e,T=e,u.substr(e,7).toLowerCase()==="method="?(i=u.substr(e,7),e+=7):(i=null,t('"method="')),i!==null?(_=zs(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.method=r}(m,i[1])),i===null&&(e=m),i}function Wn(){var i,_,m,T;return m=e,T=e,u.substr(e,4).toLowerCase()==="ttl="?(i=u.substr(e,4),e+=4):(i=null,t('"ttl="')),i!==null?(_=Nn(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.params||(x.params={}),x.params.ttl=r}(m,i[1])),i===null&&(e=m),i}function Kn(){var i,_,m,T;return m=e,T=e,u.substr(e,6).toLowerCase()==="maddr="?(i=u.substr(e,6),e+=6):(i=null,t('"maddr="')),i!==null?(_=is(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.maddr=r}(m,i[1])),i===null&&(e=m),i}function pn(){var i,_,m,T,y,r;return T=e,y=e,u.substr(e,2).toLowerCase()==="lr"?(i=u.substr(e,2),e+=2):(i=null,t('"lr"')),i!==null?(r=e,u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=M(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x.uri_params||(x.uri_params={}),x.uri_params.lr=void 0}()),i===null&&(e=T),i}function Yn(){var i,_,m,T,y,r;return T=e,y=e,i=zn(),i!==null?(r=e,u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=Jn(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f,d,s){x.uri_params||(x.uri_params={}),typeof s>"u"?s=void 0:s=s[1],x.uri_params[d.toLowerCase()]=s}(T,i[0],i[1])),i===null&&(e=T),i}function zn(){var i,_,m;if(m=e,_=bs(),_!==null)for(i=[];_!==null;)i.push(_),_=bs();else i=null;return i!==null&&(i=function(T,y){return y.join("")}(m,i)),i===null&&(e=m),i}function Jn(){var i,_,m;if(m=e,_=bs(),_!==null)for(i=[];_!==null;)i.push(_),_=bs();else i=null;return i!==null&&(i=function(T,y){return y.join("")}(m,i)),i===null&&(e=m),i}function bs(){var i;return i=Xn(),i===null&&(i=j(),i===null&&(i=k())),i}function Xn(){var i;return u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i===null&&(u.charCodeAt(e)===93?(i="]",e++):(i=null,t('"]"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')))))))),i}function Qn(){var i,_,m,T,y,r,f;if(r=e,u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i!==null)if(_=Qt(),_!==null){for(m=[],f=e,u.charCodeAt(e)===38?(T="&",e++):(T=null,t('"&"')),T!==null?(y=Qt(),y!==null?T=[T,y]:(T=null,e=f)):(T=null,e=f);T!==null;)m.push(T),f=e,u.charCodeAt(e)===38?(T="&",e++):(T=null,t('"&"')),T!==null?(y=Qt(),y!==null?T=[T,y]:(T=null,e=f)):(T=null,e=f);m!==null?i=[i,_,m]:(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i}function Qt(){var i,_,m,T,y;return T=e,y=e,i=Zn(),i!==null?(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=el(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f,d){f=f.join("").toLowerCase(),d=d.join(""),x.uri_headers||(x.uri_headers={}),x.uri_headers[f]?x.uri_headers[f].push(d):x.uri_headers[f]=[d]}(T,i[0],i[2])),i===null&&(e=T),i}function Zn(){var i,_;if(_=kt(),_===null&&(_=j(),_===null&&(_=k())),_!==null)for(i=[];_!==null;)i.push(_),_=kt(),_===null&&(_=j(),_===null&&(_=k()));else i=null;return i}function el(){var i,_;for(i=[],_=kt(),_===null&&(_=j(),_===null&&(_=k()));_!==null;)i.push(_),_=kt(),_===null&&(_=j(),_===null&&(_=k()));return i}function kt(){var i;return u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i===null&&(u.charCodeAt(e)===93?(i="]",e++):(i=null,t('"]"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')))))))),i}function er(){var i;return i=_l(),i===null&&(i=tl()),i}function tl(){var i,_,m,T,y,r;return r=e,i=zs(),i!==null?(_=w(),_!==null?(m=Zt(),m!==null?(T=w(),T!==null?(y=fs(),y!==null?i=[i,_,m,T,y]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i}function Zt(){var i;return i=pe(),i===null&&(i=sl()),i}function sl(){var i,_,m,T;return T=e,i=ts(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=nl(),m===null&&(m=ll()),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function nl(){var i,_,m,T,y;return T=e,i=Is(),i===null&&(i=Ks()),i!==null?(y=e,u.charCodeAt(e)===63?(_="?",e++):(_=null,t('"?"')),_!==null?(m=gn(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function Is(){var i,_,m,T;return T=e,u.substr(e,2)==="//"?(i="//",e+=2):(i=null,t('"//"')),i!==null?(_=mn(),_!==null?(m=Ks(),m=m!==null?m:"",m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Ks(){var i,_,m;return m=e,u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i!==null?(_=rl(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function ll(){var i,_,m,T;if(T=e,i=Os(),i!==null){for(_=[],m=ws();m!==null;)_.push(m),m=ws();_!==null?i=[i,_]:(i=null,e=T)}else i=null,e=T;return i}function ws(){var i;return i=Y(),i===null&&(i=j(),i===null&&(i=k())),i}function Os(){var i;return i=j(),i===null&&(i=k(),i===null&&(u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')))))))))))),i}function rl(){var i,_,m,T,y,r;if(y=e,i=es(),i!==null){for(_=[],r=e,u.charCodeAt(e)===47?(m="/",e++):(m=null,t('"/"')),m!==null?(T=es(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,u.charCodeAt(e)===47?(m="/",e++):(m=null,t('"/"')),m!==null?(T=es(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function es(){var i,_,m,T,y,r;for(y=e,i=[],_=Ns();_!==null;)i.push(_),_=Ns();if(i!==null){for(_=[],r=e,u.charCodeAt(e)===59?(m=";",e++):(m=null,t('";"')),m!==null?(T=Ds(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,u.charCodeAt(e)===59?(m=";",e++):(m=null,t('";"')),m!==null?(T=Ds(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Ds(){var i,_;for(i=[],_=Ns();_!==null;)i.push(_),_=Ns();return i}function Ns(){var i;return i=j(),i===null&&(i=k(),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')))))))))),i}function ts(){var i,_,m,T,y;if(T=e,y=e,i=l(),i!==null){for(_=[],m=l(),m===null&&(m=C(),m===null&&(u.charCodeAt(e)===43?(m="+",e++):(m=null,t('"+"')),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."'))))));m!==null;)_.push(m),m=l(),m===null&&(m=C(),m===null&&(u.charCodeAt(e)===43?(m="+",e++):(m=null,t('"+"')),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."'))))));_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i!==null&&(i=function(r){x.scheme=u.substring(e,r)}(T)),i===null&&(e=T),i}function mn(){var i;return i=Us(),i===null&&(i=Ys()),i}function Us(){var i,_,m,T;return m=e,T=e,i=Be(),i!==null?(u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i=i!==null?i:"",i!==null?(_=Gs(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i=i!==null?i:"",i}function Ys(){var i,_;if(_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","')),_===null&&(u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"'))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","')),_===null&&(u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')))))))))));else i=null;return i}function gn(){var i,_;for(i=[],_=ws();_!==null;)i.push(_),_=ws();return i}function fs(){var i,_,m,T,y,r,f,d;if(f=e,d=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"SIP"')),i!==null)if(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_!==null){if(T=C(),T!==null)for(m=[];T!==null;)m.push(T),T=C();else m=null;if(m!==null)if(u.charCodeAt(e)===46?(T=".",e++):(T=null,t('"."')),T!==null){if(r=C(),r!==null)for(y=[];r!==null;)y.push(r),r=C();else y=null;y!==null?i=[i,_,m,T,y]:(i=null,e=d)}else i=null,e=d;else i=null,e=d}else i=null,e=d;else i=null,e=d;return i!==null&&(i=function(s){x.sip_version=u.substring(e,s)}(f)),i===null&&(e=f),i}function il(){var i;return u.substr(e,6)==="INVITE"?(i="INVITE",e+=6):(i=null,t('"INVITE"')),i}function al(){var i;return u.substr(e,3)==="ACK"?(i="ACK",e+=3):(i=null,t('"ACK"')),i}function vn(){var i;return u.substr(e,7)==="OPTIONS"?(i="OPTIONS",e+=7):(i=null,t('"OPTIONS"')),i}function ol(){var i;return u.substr(e,3)==="BYE"?(i="BYE",e+=3):(i=null,t('"BYE"')),i}function ul(){var i;return u.substr(e,6)==="CANCEL"?(i="CANCEL",e+=6):(i=null,t('"CANCEL"')),i}function Tn(){var i;return u.substr(e,8)==="REGISTER"?(i="REGISTER",e+=8):(i=null,t('"REGISTER"')),i}function cl(){var i;return u.substr(e,9)==="SUBSCRIBE"?(i="SUBSCRIBE",e+=9):(i=null,t('"SUBSCRIBE"')),i}function fl(){var i;return u.substr(e,6)==="NOTIFY"?(i="NOTIFY",e+=6):(i=null,t('"NOTIFY"')),i}function hl(){var i;return u.substr(e,5)==="REFER"?(i="REFER",e+=5):(i=null,t('"REFER"')),i}function zs(){var i,_;return _=e,i=il(),i===null&&(i=al(),i===null&&(i=vn(),i===null&&(i=ol(),i===null&&(i=ul(),i===null&&(i=Tn(),i===null&&(i=cl(),i===null&&(i=fl(),i===null&&(i=hl(),i===null&&(i=M()))))))))),i!==null&&(i=function(m){return x.method=u.substring(e,m),x.method}(_)),i===null&&(e=_),i}function _l(){var i,_,m,T,y,r;return r=e,i=fs(),i!==null?(_=w(),_!==null?(m=dl(),m!==null?(T=w(),T!==null?(y=pl(),y!==null?i=[i,_,m,T,y]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i}function dl(){var i,_;return _=e,i=Js(),i!==null&&(i=function(m,T){x.status_code=parseInt(T.join(""))}(_,i)),i===null&&(e=_),i}function Js(){var i,_,m,T;return T=e,i=C(),i!==null?(_=C(),_!==null?(m=C(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function pl(){var i,_,m;for(m=e,i=[],_=Y(),_===null&&(_=j(),_===null&&(_=k(),_===null&&(_=V(),_===null&&(_=G(),_===null&&(_=w(),_===null&&(_=N()))))));_!==null;)i.push(_),_=Y(),_===null&&(_=j(),_===null&&(_=k(),_===null&&(_=V(),_===null&&(_=G(),_===null&&(_=w(),_===null&&(_=N()))))));return i!==null&&(i=function(T){x.reason_phrase=u.substring(e,T)}(m)),i===null&&(e=m),i}function tr(){var i,_,m,T,y,r;if(y=e,i=ds(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=ds(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=ds(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function En(){var i,_,m,T,y,r;return T=e,y=e,i=$(),i!==null?(r=e,u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_!==null?(m=$(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x=u.substring(e,f)}(T)),i===null&&(e=T),i}function sr(){var i,_,m,T,y,r,f;if(y=e,i=ne(),i===null)if(r=e,i=Cn(),i!==null){for(_=[],f=e,m=be(),m!==null?(T=Cn(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=be(),m!==null?(T=Cn(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s,c;for(c=x.multi_header.length,s=0;s<c;s++)if(x.multi_header[s].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1}()),i===null&&(e=y),i}function Cn(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=hs()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=Xs(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=Xs(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s;x.multi_header||(x.multi_header=[]);try{s=new si(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{s=null}x.multi_header.push({possition:e,offset:d,parsed:s})}(y)),i===null&&(e=y),i}function hs(){var i,_,m,T,y;return y=e,i=Sn(),i=i!==null?i:"",i!==null?(_=Re(),_!==null?(m=pe(),m!==null?(T=he(),T!==null?i=[i,_,m,T]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i}function Sn(){var i,_,m,T,y,r,f;if(y=e,r=e,i=M(),i!==null){for(_=[],f=e,m=H(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=H(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i===null&&(i=Oe()),i!==null&&(i=function(d,s){typeof s=="string"?x.display_name=s:x.display_name=s[1].reduce(function(c,h){return c+h[0]+h[1]},s[0])}(y,i)),i===null&&(e=y),i}function Xs(){var i;return i=_s(),i===null&&(i=An(),i===null&&(i=Ke())),i}function _s(){var i,_,m,T,y;return T=e,y=e,u.substr(e,1).toLowerCase()==="q"?(i=u.substr(e,1),e++):(i=null,t('"q"')),i!==null?(_=P(),_!==null?(m=ss(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.params||(x.params={}),x.params.q=f}(T,i[2])),i===null&&(e=T),i}function An(){var i,_,m,T,y;return T=e,y=e,u.substr(e,7).toLowerCase()==="expires"?(i=u.substr(e,7),e+=7):(i=null,t('"expires"')),i!==null?(_=P(),_!==null?(m=Lt(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.params||(x.params={}),x.params.expires=f}(T,i[2])),i===null&&(e=T),i}function Lt(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){return parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function ss(){var i,_,m,T,y,r,f,d;return r=e,f=e,u.charCodeAt(e)===48?(i="0",e++):(i=null,t('"0"')),i!==null?(d=e,u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?_=[_,m,T,y]:(_=null,e=d)):(_=null,e=d)):(_=null,e=d)):(_=null,e=d),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(s){return parseFloat(u.substring(e,s))}(r)),i===null&&(e=r),i}function Ke(){var i,_,m,T,y,r;return T=e,y=e,i=M(),i!==null?(r=e,_=P(),_!==null?(m=Gt(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f,d,s){x.params||(x.params={}),typeof s>"u"?s=void 0:s=s[1],x.params[d.toLowerCase()]=s}(T,i[0],i[1])),i===null&&(e=T),i}function Gt(){var i;return i=M(),i===null&&(i=is(),i===null&&(i=ue())),i}function nr(){var i,_,m,T,y,r;if(y=e,i=Je(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=Wt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=Wt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Je(){var i;return u.substr(e,6).toLowerCase()==="render"?(i=u.substr(e,6),e+=6):(i=null,t('"render"')),i===null&&(u.substr(e,7).toLowerCase()==="session"?(i=u.substr(e,7),e+=7):(i=null,t('"session"')),i===null&&(u.substr(e,4).toLowerCase()==="icon"?(i=u.substr(e,4),e+=4):(i=null,t('"icon"')),i===null&&(u.substr(e,5).toLowerCase()==="alert"?(i=u.substr(e,5),e+=5):(i=null,t('"alert"')),i===null&&(i=M())))),i}function Wt(){var i;return i=lr(),i===null&&(i=Ke()),i}function lr(){var i,_,m,T;return T=e,u.substr(e,8).toLowerCase()==="handling"?(i=u.substr(e,8),e+=8):(i=null,t('"handling"')),i!==null?(_=P(),_!==null?(u.substr(e,8).toLowerCase()==="optional"?(m=u.substr(e,8),e+=8):(m=null,t('"optional"')),m===null&&(u.substr(e,8).toLowerCase()==="required"?(m=u.substr(e,8),e+=8):(m=null,t('"required"')),m===null&&(m=M())),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Ze(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function ml(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){x=parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function $r(){var i,_;return _=e,i=rr(),i!==null&&(i=function(m){x=u.substring(e,m)}(_)),i===null&&(e=_),i}function rr(){var i,_,m,T,y,r,f,d;if(f=e,i=gl(),i!==null)if(_=ct(),_!==null)if(m=vl(),m!==null){for(T=[],d=e,y=fe(),y!==null?(r=xs(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=fe(),y!==null?(r=xs(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i}function gl(){var i;return i=ir(),i===null&&(i=ar()),i}function ir(){var i;return u.substr(e,4).toLowerCase()==="text"?(i=u.substr(e,4),e+=4):(i=null,t('"text"')),i===null&&(u.substr(e,5).toLowerCase()==="image"?(i=u.substr(e,5),e+=5):(i=null,t('"image"')),i===null&&(u.substr(e,5).toLowerCase()==="audio"?(i=u.substr(e,5),e+=5):(i=null,t('"audio"')),i===null&&(u.substr(e,5).toLowerCase()==="video"?(i=u.substr(e,5),e+=5):(i=null,t('"video"')),i===null&&(u.substr(e,11).toLowerCase()==="application"?(i=u.substr(e,11),e+=11):(i=null,t('"application"')),i===null&&(i=yn()))))),i}function ar(){var i;return u.substr(e,7).toLowerCase()==="message"?(i=u.substr(e,7),e+=7):(i=null,t('"message"')),i===null&&(u.substr(e,9).toLowerCase()==="multipart"?(i=u.substr(e,9),e+=9):(i=null,t('"multipart"')),i===null&&(i=yn())),i}function yn(){var i;return i=M(),i===null&&(i=or()),i}function or(){var i,_,m;return m=e,u.substr(e,2).toLowerCase()==="x-"?(i=u.substr(e,2),e+=2):(i=null,t('"x-"')),i!==null?(_=M(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function vl(){var i;return i=yn(),i===null&&(i=M()),i}function xs(){var i,_,m,T;return T=e,i=M(),i!==null?(_=P(),_!==null?(m=Tl(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Tl(){var i;return i=M(),i===null&&(i=ue()),i}function ur(){var i,_,m,T;return T=e,i=Ps(),i!==null?(_=H(),_!==null?(m=zs(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Ps(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){x.value=parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function cr(){var i,_;return _=e,i=Lt(),i!==null&&(i=function(m,T){x=T}(_,i)),i===null&&(e=_),i}function Hr(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ds(),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d,s){x.event=s.join("").toLowerCase()}(y,i[0])),i===null&&(e=y),i}function ds(){var i,_,m,T,y,r;if(y=e,i=te(),i!==null){for(_=[],r=e,u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?(T=te(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?(T=te(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Fr(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=hs()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=fr(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=fr(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s=x.tag;try{x=new si(x.uri,x.display_name,x.params),s&&x.setParam("tag",s)}catch{x=-1}}()),i===null&&(e=y),i}function fr(){var i;return i=ps(),i===null&&(i=Ke()),i}function ps(){var i,_,m,T,y;return T=e,y=e,u.substr(e,3).toLowerCase()==="tag"?(i=u.substr(e,3),e+=3):(i=null,t('"tag"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.tag=f}(T,i[2])),i===null&&(e=T),i}function fi(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){x=parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function hr(){var i,_;return _=e,i=Lt(),i!==null&&(i=function(m,T){x=T}(_,i)),i===null&&(e=_),i}function Ms(){var i,_,m,T,y,r,f,d,s,c;for(d=e,s=e,i=[],_=Sn();_!==null;)i.push(_),_=Sn();if(i!==null)if(_=Re(),_!==null)if(m=pe(),m!==null)if(T=he(),T!==null){for(y=[],c=e,r=fe(),r!==null?(f=Ke(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);r!==null;)y.push(r),c=e,r=fe(),r!==null?(f=Ke(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);y!==null?i=[i,_,m,T,y]:(i=null,e=s)}else i=null,e=s;else i=null,e=s;else i=null,e=s;else i=null,e=s;return i!==null&&(i=function(h){try{x=new si(x.uri,x.display_name,x.params)}catch{x=-1}}()),i===null&&(e=d),i}function hi(){var i;return i=Rn(),i}function Rn(){var i,_,m,T,y,r,f,d;if(f=e,u.substr(e,6).toLowerCase()==="digest"?(i=u.substr(e,6),e+=6):(i=null,t('"Digest"')),i!==null)if(_=H(),_!==null)if(m=Qs(),m!==null){for(T=[],d=e,y=be(),y!==null?(r=Qs(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=be(),y!==null?(r=Qs(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i===null&&(i=El()),i}function El(){var i,_,m,T,y,r,f,d;if(f=e,i=M(),i!==null)if(_=H(),_!==null)if(m=bn(),m!==null){for(T=[],d=e,y=be(),y!==null?(r=bn(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=be(),y!==null?(r=bn(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i}function bn(){var i,_,m,T;return T=e,i=M(),i!==null?(_=P(),_!==null?(m=M(),m===null&&(m=ue()),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Qs(){var i;return i=_r(),i===null&&(i=ks(),i===null&&(i=Ls(),i===null&&(i=sn(),i===null&&(i=Cl(),i===null&&(i=Sl(),i===null&&(i=nn(),i===null&&(i=bn()))))))),i}function _r(){var i,_,m,T;return T=e,u.substr(e,5).toLowerCase()==="realm"?(i=u.substr(e,5),e+=5):(i=null,t('"realm"')),i!==null?(_=P(),_!==null?(m=Zs(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Zs(){var i,_;return _=e,i=Oe(),i!==null&&(i=function(m,T){x.realm=T}(_,i)),i===null&&(e=_),i}function ks(){var i,_,m,T,y,r,f,d,s;if(d=e,u.substr(e,6).toLowerCase()==="domain"?(i=u.substr(e,6),e+=6):(i=null,t('"domain"')),i!==null)if(_=P(),_!==null)if(m=xe(),m!==null)if(T=en(),T!==null){if(y=[],s=e,f=w(),f!==null)for(r=[];f!==null;)r.push(f),f=w();else r=null;for(r!==null?(f=en(),f!==null?r=[r,f]:(r=null,e=s)):(r=null,e=s);r!==null;){if(y.push(r),s=e,f=w(),f!==null)for(r=[];f!==null;)r.push(f),f=w();else r=null;r!==null?(f=en(),f!==null?r=[r,f]:(r=null,e=s)):(r=null,e=s)}y!==null?(r=we(),r!==null?i=[i,_,m,T,y,r]:(i=null,e=d)):(i=null,e=d)}else i=null,e=d;else i=null,e=d;else i=null,e=d;else i=null,e=d;return i}function en(){var i;return i=sl(),i===null&&(i=Ks()),i}function Ls(){var i,_,m,T;return T=e,u.substr(e,5).toLowerCase()==="nonce"?(i=u.substr(e,5),e+=5):(i=null,t('"nonce"')),i!==null?(_=P(),_!==null?(m=tn(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function tn(){var i,_;return _=e,i=Oe(),i!==null&&(i=function(m,T){x.nonce=T}(_,i)),i===null&&(e=_),i}function sn(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6).toLowerCase()==="opaque"?(i=u.substr(e,6),e+=6):(i=null,t('"opaque"')),i!==null?(_=P(),_!==null?(m=Oe(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.opaque=f}(T,i[2])),i===null&&(e=T),i}function Cl(){var i,_,m,T,y;return T=e,u.substr(e,5).toLowerCase()==="stale"?(i=u.substr(e,5),e+=5):(i=null,t('"stale"')),i!==null?(_=P(),_!==null?(y=e,u.substr(e,4).toLowerCase()==="true"?(m=u.substr(e,4),e+=4):(m=null,t('"true"')),m!==null&&(m=function(r){x.stale=!0}()),m===null&&(e=y),m===null&&(y=e,u.substr(e,5).toLowerCase()==="false"?(m=u.substr(e,5),e+=5):(m=null,t('"false"')),m!==null&&(m=function(r){x.stale=!1}()),m===null&&(e=y)),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Sl(){var i,_,m,T,y;return T=e,y=e,u.substr(e,9).toLowerCase()==="algorithm"?(i=u.substr(e,9),e+=9):(i=null,t('"algorithm"')),i!==null?(_=P(),_!==null?(u.substr(e,3).toLowerCase()==="md5"?(m=u.substr(e,3),e+=3):(m=null,t('"MD5"')),m===null&&(u.substr(e,8).toLowerCase()==="md5-sess"?(m=u.substr(e,8),e+=8):(m=null,t('"MD5-sess"')),m===null&&(m=M())),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.algorithm=f.toUpperCase()}(T,i[2])),i===null&&(e=T),i}function nn(){var i,_,m,T,y,r,f,d,s,c;if(d=e,u.substr(e,3).toLowerCase()==="qop"?(i=u.substr(e,3),e+=3):(i=null,t('"qop"')),i!==null)if(_=P(),_!==null)if(m=xe(),m!==null){if(s=e,T=ln(),T!==null){for(y=[],c=e,u.charCodeAt(e)===44?(r=",",e++):(r=null,t('","')),r!==null?(f=ln(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);r!==null;)y.push(r),c=e,u.charCodeAt(e)===44?(r=",",e++):(r=null,t('","')),r!==null?(f=ln(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);y!==null?T=[T,y]:(T=null,e=s)}else T=null,e=s;T!==null?(y=we(),y!==null?i=[i,_,m,T,y]:(i=null,e=d)):(i=null,e=d)}else i=null,e=d;else i=null,e=d;else i=null,e=d;return i}function ln(){var i,_;return _=e,u.substr(e,8).toLowerCase()==="auth-int"?(i=u.substr(e,8),e+=8):(i=null,t('"auth-int"')),i===null&&(u.substr(e,4).toLowerCase()==="auth"?(i=u.substr(e,4),e+=4):(i=null,t('"auth"')),i===null&&(i=M())),i!==null&&(i=function(m,T){x.qop||(x.qop=[]),x.qop.push(T.toLowerCase())}(_,i)),i===null&&(e=_),i}function dr(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function pr(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ms(),i!==null){for(_=[],f=e,m=be(),m!==null?(T=ms(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=be(),m!==null?(T=ms(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s,c;for(c=x.multi_header.length,s=0;s<c;s++)if(x.multi_header[s].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1}()),i===null&&(e=y),i}function ms(){var i,_,m,T,y,r,f;if(y=e,r=e,i=hs(),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s;x.multi_header||(x.multi_header=[]);try{s=new si(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{s=null}x.multi_header.push({possition:e,offset:d,parsed:s})}(y)),i===null&&(e=y),i}function qr(){var i,_,m,T,y,r,f;if(y=e,r=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"SIP"')),i===null&&(i=M()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=Al(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=Al(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d,s){if(x.protocol=s.toLowerCase(),x.params||(x.params={}),x.params.text&&x.params.text[0]==='"'){var c=x.params.text;x.text=c.substring(1,c.length-1),delete x.params.text}}(y,i[0])),i===null&&(e=y),i}function Al(){var i;return i=gs(),i===null&&(i=Ke()),i}function gs(){var i,_,m,T,y,r;if(y=e,r=e,u.substr(e,5).toLowerCase()==="cause"?(i=u.substr(e,5),e+=5):(i=null,t('"cause"')),i!==null)if(_=P(),_!==null){if(T=C(),T!==null)for(m=[];T!==null;)m.push(T),T=C();else m=null;m!==null?i=[i,_,m]:(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i!==null&&(i=function(f,d){x.cause=parseInt(d.join(""))}(y,i[2])),i===null&&(e=y),i}function _i(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function mr(){var i,_,m,T,y,r;if(y=e,i=vs(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=vs(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=vs(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function vs(){var i,_,m,T,y,r;if(y=e,i=hs(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function di(){var i,_,m,T,y,r;if(y=e,i=yl(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=$s(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=$s(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function yl(){var i,_;return _=e,u.substr(e,6).toLowerCase()==="active"?(i=u.substr(e,6),e+=6):(i=null,t('"active"')),i===null&&(u.substr(e,7).toLowerCase()==="pending"?(i=u.substr(e,7),e+=7):(i=null,t('"pending"')),i===null&&(u.substr(e,10).toLowerCase()==="terminated"?(i=u.substr(e,10),e+=10):(i=null,t('"terminated"')),i===null&&(i=M()))),i!==null&&(i=function(m){x.state=u.substring(e,m)}(_)),i===null&&(e=_),i}function $s(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6).toLowerCase()==="reason"?(i=u.substr(e,6),e+=6):(i=null,t('"reason"')),i!==null?(_=P(),_!==null?(m=jr(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){typeof f<"u"&&(x.reason=f)}(T,i[2])),i===null&&(e=T),i===null&&(T=e,y=e,u.substr(e,7).toLowerCase()==="expires"?(i=u.substr(e,7),e+=7):(i=null,t('"expires"')),i!==null?(_=P(),_!==null?(m=Lt(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){typeof f<"u"&&(x.expires=f)}(T,i[2])),i===null&&(e=T),i===null&&(T=e,y=e,u.substr(e,11).toLowerCase()==="retry_after"?(i=u.substr(e,11),e+=11):(i=null,t('"retry_after"')),i!==null?(_=P(),_!==null?(m=Lt(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){typeof f<"u"&&(x.retry_after=f)}(T,i[2])),i===null&&(e=T),i===null&&(i=Ke()))),i}function jr(){var i;return u.substr(e,11).toLowerCase()==="deactivated"?(i=u.substr(e,11),e+=11):(i=null,t('"deactivated"')),i===null&&(u.substr(e,9).toLowerCase()==="probation"?(i=u.substr(e,9),e+=9):(i=null,t('"probation"')),i===null&&(u.substr(e,8).toLowerCase()==="rejected"?(i=u.substr(e,8),e+=8):(i=null,t('"rejected"')),i===null&&(u.substr(e,7).toLowerCase()==="timeout"?(i=u.substr(e,7),e+=7):(i=null,t('"timeout"')),i===null&&(u.substr(e,6).toLowerCase()==="giveup"?(i=u.substr(e,6),e+=6):(i=null,t('"giveup"')),i===null&&(u.substr(e,10).toLowerCase()==="noresource"?(i=u.substr(e,10),e+=10):(i=null,t('"noresource"')),i===null&&(u.substr(e,9).toLowerCase()==="invariant"?(i=u.substr(e,9),e+=9):(i=null,t('"invariant"')),i===null&&(i=M()))))))),i}function Vr(){var i;return i=B(),i=i!==null?i:"",i}function rn(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i=i!==null?i:"",i}function Br(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=hs()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=Rl(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=Rl(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s=x.tag;try{x=new si(x.uri,x.display_name,x.params),s&&x.setParam("tag",s)}catch{x=-1}}()),i===null&&(e=y),i}function Rl(){var i;return i=ps(),i===null&&(i=Ke()),i}function gr(){var i,_,m,T,y,r;if(y=e,i=In(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=In(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=In(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function In(){var i,_,m,T,y,r,f,d;if(f=e,i=bl(),i!==null)if(_=H(),_!==null)if(m=Ol(),m!==null){for(T=[],d=e,y=fe(),y!==null?(r=wn(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=fe(),y!==null?(r=wn(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i}function wn(){var i;return i=Gr(),i===null&&(i=On(),i===null&&(i=an(),i===null&&(i=vr(),i===null&&(i=on(),i===null&&(i=Ke()))))),i}function Gr(){var i,_,m,T,y;return T=e,y=e,u.substr(e,3).toLowerCase()==="ttl"?(i=u.substr(e,3),e+=3):(i=null,t('"ttl"')),i!==null?(_=P(),_!==null?(m=Nn(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.ttl=f}(T,i[2])),i===null&&(e=T),i}function On(){var i,_,m,T,y;return T=e,y=e,u.substr(e,5).toLowerCase()==="maddr"?(i=u.substr(e,5),e+=5):(i=null,t('"maddr"')),i!==null?(_=P(),_!==null?(m=is(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.maddr=f}(T,i[2])),i===null&&(e=T),i}function an(){var i,_,m,T,y;return T=e,y=e,u.substr(e,8).toLowerCase()==="received"?(i=u.substr(e,8),e+=8):(i=null,t('"received"')),i!==null?(_=P(),_!==null?(m=Xt(),m===null&&(m=os()),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.received=f}(T,i[2])),i===null&&(e=T),i}function vr(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6).toLowerCase()==="branch"?(i=u.substr(e,6),e+=6):(i=null,t('"branch"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.branch=f}(T,i[2])),i===null&&(e=T),i}function on(){var i,_,m,T,y;return T=e,u.substr(e,5).toLowerCase()==="rport"?(i=u.substr(e,5),e+=5):(i=null,t('"rport"')),i!==null?(y=e,_=P(),_!==null?(m=Dn(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function Dn(){var i,_,m,T,y,r,f;return r=e,f=e,i=C(),i=i!==null?i:"",i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?i=[i,_,m,T,y]:(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(d,s){x.rport=parseInt(s.join(""))}(r,i)),i===null&&(e=r),i}function bl(){var i,_,m,T,y,r;return r=e,i=Il(),i!==null?(_=ct(),_!==null?(m=M(),m!==null?(T=ct(),T!==null?(y=wl(),y!==null?i=[i,_,m,T,y]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i}function Il(){var i,_;return _=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"SIP"')),i===null&&(i=M()),i!==null&&(i=function(m,T){x.protocol=T}(_,i)),i===null&&(e=_),i}function wl(){var i,_;return _=e,u.substr(e,3).toLowerCase()==="udp"?(i=u.substr(e,3),e+=3):(i=null,t('"UDP"')),i===null&&(u.substr(e,3).toLowerCase()==="tcp"?(i=u.substr(e,3),e+=3):(i=null,t('"TCP"')),i===null&&(u.substr(e,3).toLowerCase()==="tls"?(i=u.substr(e,3),e+=3):(i=null,t('"TLS"')),i===null&&(u.substr(e,4).toLowerCase()==="sctp"?(i=u.substr(e,4),e+=4):(i=null,t('"SCTP"')),i===null&&(i=M())))),i!==null&&(i=function(m,T){x.transport=T}(_,i)),i===null&&(e=_),i}function Ol(){var i,_,m,T,y;return T=e,i=Dl(),i!==null?(y=e,_=qe(),_!==null?(m=Nl(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function Dl(){var i,_;return _=e,i=Xt(),i===null&&(i=Ws(),i===null&&(i=As())),i!==null&&(i=function(m){x.host=u.substring(e,m)}(_)),i===null&&(e=_),i}function Nl(){var i,_,m,T,y,r,f;return r=e,f=e,i=C(),i=i!==null?i:"",i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?i=[i,_,m,T,y]:(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(d,s){x.port=parseInt(s.join(""))}(r,i)),i===null&&(e=r),i}function Nn(){var i,_,m,T,y;return T=e,y=e,i=C(),i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){return parseInt(f.join(""))}(T,i)),i===null&&(e=T),i}function Tr(){var i;return i=Rn(),i}function Er(){var i,_,m,T,y,r;if(y=e,i=Un(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=Ul(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=Ul(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Un(){var i,_;return _=e,i=Lt(),i!==null&&(i=function(m,T){x.expires=T}(_,i)),i===null&&(e=_),i}function Ul(){var i;return i=Cr(),i===null&&(i=Ke()),i}function Cr(){var i,_,m,T,y;return T=e,y=e,u.substr(e,9).toLowerCase()==="refresher"?(i=u.substr(e,9),e+=9):(i=null,t('"refresher"')),i!==null?(_=P(),_!==null?(u.substr(e,3).toLowerCase()==="uac"?(m=u.substr(e,3),e+=3):(m=null,t('"uac"')),m===null&&(u.substr(e,3).toLowerCase()==="uas"?(m=u.substr(e,3),e+=3):(m=null,t('"uas"'))),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.refresher=f.toLowerCase()}(T,i[2])),i===null&&(e=T),i}function xl(){var i,_,m,T;return T=e,i=M(),i!==null?(_=Ue(),_!==null?(m=Pl(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Pl(){var i,_;for(i=[],_=L(),_===null&&(_=G(),_===null&&(_=H()));_!==null;)i.push(_),_=L(),_===null&&(_=G(),_===null&&(_=H()));return i}function Wr(){var i,_;for(i=[],_=E();_!==null;)i.push(_),_=E();return i}function Kr(){var i,_,m;return m=e,u.substr(e,5)==="uuid:"?(i="uuid:",e+=5):(i=null,t('"uuid:"')),i!==null?(_=xn(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function xn(){var i,_,m,T,y,r,f,d,s,c,h;return c=e,h=e,i=Yr(),i!==null?(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_!==null?(m=Kt(),m!==null?(u.charCodeAt(e)===45?(T="-",e++):(T=null,t('"-"')),T!==null?(y=Kt(),y!==null?(u.charCodeAt(e)===45?(r="-",e++):(r=null,t('"-"')),r!==null?(f=Kt(),f!==null?(u.charCodeAt(e)===45?(d="-",e++):(d=null,t('"-"')),d!==null?(s=Ml(),s!==null?i=[i,_,m,T,y,r,f,d,s]:(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h),i!==null&&(i=function(g,S){x=u.substring(e+5,g)}(c,i[0])),i===null&&(e=c),i}function Kt(){var i,_,m,T,y;return y=e,i=A(),i!==null?(_=A(),_!==null?(m=A(),m!==null?(T=A(),T!==null?i=[i,_,m,T]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i}function Yr(){var i,_,m;return m=e,i=Kt(),i!==null?(_=Kt(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function Ml(){var i,_,m,T;return T=e,i=Kt(),i!==null?(_=Kt(),_!==null?(m=Kt(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function ns(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=hs()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){try{x=new si(x.uri,x.display_name,x.params)}catch{x=-1}}()),i===null&&(e=y),i}function zr(){var i,_,m,T,y,r;if(y=e,i=kl(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=jt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=jt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function kl(){var i,_,m,T,y,r;return T=e,y=e,i=$(),i!==null?(r=e,u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_!==null?(m=$(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x.call_id=u.substring(e,f)}(T)),i===null&&(e=T),i}function jt(){var i;return i=Sr(),i===null&&(i=Ll(),i===null&&(i=$l(),i===null&&(i=Ke()))),i}function Sr(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6)==="to-tag"?(i="to-tag",e+=6):(i=null,t('"to-tag"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.to_tag=f}(T,i[2])),i===null&&(e=T),i}function Ll(){var i,_,m,T,y;return T=e,y=e,u.substr(e,8)==="from-tag"?(i="from-tag",e+=8):(i=null,t('"from-tag"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.from_tag=f}(T,i[2])),i===null&&(e=T),i}function $l(){var i,_;return _=e,u.substr(e,10)==="early-only"?(i="early-only",e+=10):(i=null,t('"early-only"')),i!==null&&(i=function(m){x.early_only=!0}()),i===null&&(e=_),i}function Jr(i){i.sort();for(var _=null,m=[],T=0;T<i.length;T++)i[T]!==_&&(m.push(i[T]),_=i[T]);return m}function Ar(){for(var i=1,_=1,m=!1,T=0;T<Math.max(e,o);T++){var y=u.charAt(T);y===`
159
+ `?(m||i++,_=1,m=!1):y==="\r"||y==="\u2028"||y==="\u2029"?(i++,_=1,m=!0):(_++,m=!1)}return{line:i,column:_}}var x={},Hl=a[n]();if(console.log("Grammar result",n,Hl),console.log("Grammar return",Hl),Hl===null||e!==u.length){var Fl=Math.max(e,o),yr=Fl<u.length?u.charAt(Fl):null,Hs=Ar();return new this.SyntaxError(Jr(p),yr,Fl,Hs.line,Hs.column),console.log("Grammar return -1"),-1}return x},toSource:function(){return this._source}};Bi.SyntaxError=function(u,n,a,e,o){function p(t,v){var C,l;switch(t.length){case 0:C="end of input";break;case 1:C=t[0];break;default:C=t.slice(0,t.length-1).join(", ")+" or "+t[t.length-1]}return l=v?Dh(v):"end of input","Expected "+C+" but "+l+" found."}this.name="SyntaxError",this.expected=u,this.found=n,this.message=p(u,n),this.offset=a,this.line=e,this.column=o};Bi.SyntaxError.prototype=Error.prototype;const Oa=new co("Parser"),Lv=(u,n)=>{let a,e,o=u.indexOf(`\r
160
+ `);if(o===-1){Oa.warn("parseMessage() | no CRLF found, not a SIP message");return}const p=u.substring(0,o);let t=Bi.parse(p,"Request_Response");if(t===-1){Oa.warn(`parseMessage() | error parsing first line of SIP message: "${p}"`);return}else t.status_code?(a=new xr.IncomingResponse,a.status_code=t.status_code,a.reason_phrase=t.reason_phrase):(a=new xr.IncomingRequest(n),a.method=t.method,a.ruri=t.uri);a.data=u;let v=o+2;for(;;){if(o=$v(u,v),o===-2){e=v+2;break}else if(o===-1){Oa.warn("parseMessage() | malformed message");return}if(t=Hv(a,u,v,o),t!==!0){Oa.warn("parseMessage() |",t.error);return}v=o+2}if(a.hasHeader("content-length")){const C=a.getHeader("content-length");a.body=u.substr(e,C)}else a.body=u.substring(e);return a};function $v(u,n){let a=n,e=0,o=0;if(u.substring(a,a+2).match(/(^\r\n)/))return-2;for(;e===0;){if(o=u.indexOf(`\r
161
+ `,a),o===-1)return o;!u.substring(o+2,o+4).match(/(^\r\n)/)&&u.charAt(o+2).match(/(^\s+)/)?a=o+2:e=o}return e}function Hv(u,n,a,e){let o;const p=n.indexOf(":",a),t=n.substring(a,p).trim(),v=n.substring(p+1,e).trim();switch(t.toLowerCase()){case"via":case"v":u.addHeader("via",v),u.getHeaders("via").length===1?(o=u.parseHeader("Via"),o&&(u.via=o,u.via_branch=o.branch)):o=0;break;case"from":case"f":u.setHeader("from",v),o=u.parseHeader("from"),o&&(u.from=o,u.from_tag=o.getParam("tag"));break;case"to":case"t":u.setHeader("to",v),o=u.parseHeader("to"),o&&(u.to=o,u.to_tag=o.getParam("tag"));break;case"record-route":if(o=Bi.parse(v,"Record_Route"),o===-1)o=void 0;else for(const C of o)u.addHeader("record-route",v.substring(C.possition,C.offset)),u.headers["Record-Route"][u.getHeaders("record-route").length-1].parsed=C.parsed;break;case"call-id":case"i":u.setHeader("call-id",v),o=u.parseHeader("call-id"),o&&(u.call_id=v);break;case"contact":case"m":if(o=Bi.parse(v,"Contact"),o===-1)o=void 0;else for(const C of o)u.addHeader("contact",v.substring(C.possition,C.offset)),u.headers.Contact[u.getHeaders("contact").length-1].parsed=C.parsed;break;case"content-length":case"l":u.setHeader("content-length",v),o=u.parseHeader("content-length");break;case"content-type":case"c":u.setHeader("content-type",v),o=u.parseHeader("content-type");break;case"cseq":u.setHeader("cseq",v),o=u.parseHeader("cseq"),o&&(u.cseq=o.value),u instanceof xr.IncomingResponse&&(u.method=o.method);break;case"max-forwards":u.setHeader("max-forwards",v),o=u.parseHeader("max-forwards");break;case"www-authenticate":u.setHeader("www-authenticate",v),o=u.parseHeader("www-authenticate");break;case"proxy-authenticate":u.setHeader("proxy-authenticate",v),o=u.parseHeader("proxy-authenticate");break;case"session-expires":case"x":u.setHeader("session-expires",v),o=u.parseHeader("session-expires"),o&&(u.session_expires=o.expires,u.session_expires_refresher=o.refresher);break;case"refer-to":case"r":u.setHeader("refer-to",v),o=u.parseHeader("refer-to"),o&&(u.refer_to=o);break;case"replaces":u.setHeader("replaces",v),o=u.parseHeader("replaces"),o&&(u.replaces=o);break;case"event":case"o":u.setHeader("event",v),o=u.parseHeader("event"),o&&(u.event=o);break;default:u.addHeader(t,v),o=0}return o===void 0?{error:`error parsing header "${t}"`}:!0}const Fv={parseMessage:Lv},Ui=new co("Registrator"),Da=10;class qv{constructor(n,a){this._reg_id=1,this._ua=n,this._transport=a,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=Fn.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString();const e=this._contact.indexOf(">");if(e!==-1){const o=this._contact.slice(0,e)+this._contact.slice(e+1,this._contact.length);this._contact=o}this._extra_contact="",this._extraContactParams="",this._extra_contact+=";+sip.ice",this._extraHeaders=[],this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._extra_contact+=`;reg-id=${this._reg_id}`,this._extra_contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const e=n[a];this._extraContactParams+=`;${a}`,e&&(this._extraContactParams+=`=${e}`)}}setExtraContactUriParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const e=n[a];this._extraContactParams+=`;${a}`,e&&(this._extraContactParams+=`=${e}`)}}register(){if(this._registering){Ui.debug("Register request in progress...");return}const n=this._extraHeaders.slice();n.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=${this._expires}`),n.push(`Expires: ${this._expires}`);const a=new Ft.OutgoingRequest(z.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n),e=new so(this._ua,a,{onRequestTimeout:()=>{this._registrationFailure(null,z.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,z.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:o=>{if(o.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):{if(this._registering=!1,!o.hasHeader("Contact")){Ui.debug("no Contact header in response to REGISTER, response ignored");break}const p=o.headers.Contact.reduce((l,A)=>l.concat(A.parsed),[]);let t=p.find(l=>this._sipInstance===l.getParam("+sip.instance")&&this._reg_id===parseInt(l.getParam("reg-id")));if(t||(t=p.find(l=>l.uri.user===this._ua.contact.uri.user)),!t){Ui.debug("no Contact header pointing to us, response ignored");break}let v=t.getParam("expires");!v&&o.hasHeader("expires")&&(v=o.getHeader("expires")),v||(v=this._expires),v=Number(v),v<Da&&(v=Da);const C=v>64?v*1e3/2+Math.floor((v/2-32)*1e3*Math.random()):v*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},C),t.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=t.getParam("temp-gruu").replace(/"/g,"")),t.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=t.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:o}));break}case/^423$/.test(o.status_code):{o.hasHeader("min-expires")?(this._expires=Number(o.getHeader("min-expires")),this._expires<Da&&(this._expires=Da),this.register()):(Ui.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(o,z.causes.SIP_FAILURE_CODE));break}default:{const p=Fn.sipErrorCause(o.status_code);this._registrationFailure(o,p)}}}});this._registering=!0,e.send()}unregister(n={}){if(!this._registered){Ui.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const a=this._extraHeaders.slice();n.all?a.push(`Contact: *${this._extraContactParams}`):a.push(`Contact: ${this._contact}${this._extraContactParams}>;expires=0`),a.push("Expires: 0");const e=new Ft.OutgoingRequest(z.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a);new so(this._ua,e,{onRequestTimeout:()=>{this._unregistered(null,z.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,z.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:p=>{switch(!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):this._unregistered(p);break;default:{const t=Fn.sipErrorCause(p.status_code);this._unregistered(p,t)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(n,a){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:a}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:a}))}_unregistered(n,a){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:a||null})}}const Ct=console,zl={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},jv=wv;class Vv extends jv{constructor(n){super(n),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[],this._registrator=new qv(this)}call(n,a){return super.call(n,a)}joinVideoCall(n,a,e){Ct.debug("call()");const o=new no(this);return o.connect(n,a,e),o}_loadConfig(n){try{Vi.load(this._configuration,n)}catch(o){throw o}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Fn.newUUID()),this._configuration.jssip_id=Fn.createRandomToken(5);const a=this._configuration.uri.clone();a.user=null,this._configuration.hostport_params=a.toString().replace(/^sip:/i,"");try{this._transport=new ev(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Bv.bind(this),this._transport.onconnect=Gv.bind(this),this._transport.ondisconnect=Wv.bind(this),this._transport.ondata=Kv.bind(this)}catch(o){throw Ct.warn(o),new Kl.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 o=this._configuration.uri.clone();o.user=null,o.clearParams(),o.clearHeaders(),this._configuration.registrar_server=o}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Yl("sip",Fn.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(o={}){const p=o.anonymous||null,t=o.outbound||null;let v="<";return p?v+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":v+=this.pub_gruu||this.uri.toString(),t&&(p?!this.temp_gruu:!this.pub_gruu)&&(v+=";ob"),v+=">",v}};const e=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const o in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,o)&&(e.indexOf(o)!==-1?Object.defineProperty(this._configuration,o,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,o,{writable:!1,configurable:!1}));Ct.debug("configuration parameters after validation:");for(const o in this._configuration)if(Object.prototype.hasOwnProperty.call(Vi.settings,o))switch(o){case"uri":case"registrar_server":Ct.debug(`- ${o}: ${this._configuration[o]}`);break;case"password":case"ha1":case"authorization_jwt":Ct.debug(`- ${o}: NOT SHOWN`);break;default:Ct.debug(`- ${o}: ${JSON.stringify(this._configuration[o])}`)}}newMSRPSession(n,a){n.on("msgHistoryUpdate",e=>{console.log(e)}),this._msrp_sessions[n.id]=n,this.emit("newMSRPSession",a)}newJanusSession(n,a){this._janus_sessions[n.id]=n,this.emit("newJanusSession",a)}destroyMSRPSession(n){delete this._msrp_sessions[n.id]}destroyJanusSession(n){delete this._janus_sessions[n.id]}receiveRequest(n){var p,t,v,C;const a=n.method;if(console.log("-----------"),n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){Ct.debug("Request-URI does not point to us"),n.method!==Fe.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===Fe.SIPS){n.reply_sl(416);return}if(Ss.checkTransaction(this,n))return;if(a===Fe.INVITE?new Ss.InviteServerTransaction(this,this._transport,n):a!==Fe.ACK&&a!==Fe.CANCEL&&new Ss.NonInviteServerTransaction(this,this._transport,n),a===Fe.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new Zc.Options(this).init_incoming(n)}else if(a===Fe.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new Zc.Message(this).init_incoming(n)}else if(a===Fe.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let e,o;if(n.to_tag)if(e=this._findDialog(n.call_id,n.from_tag,n.to_tag),e)e.receiveRequest(n);else if(a===Fe.NOTIFY)if(o=this._findSession(n),o)o.receiveRequest(n);else{if(n.body)try{const l=JSON.parse(n.body)||{};(t=(p=l.plugindata)==null?void 0:p.data)!=null&&t.publishers&&Object.values(this._janus_sessions)[0].receivePublishers(l),(C=(v=l.plugindata)==null?void 0:v.data)!=null&&C.unpublished&&Object.values(this._janus_sessions)[0].receiveUnpublished(l.plugindata.data.unpublished)}catch(l){console.error(l)}n.reply(200)}else a!==Fe.ACK&&n.reply(481);else switch(a){case Fe.INVITE:if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const l=n.replaces;e=this._findDialog(l.call_id,l.from_tag,l.to_tag),e?(o=e.owner,o.isEnded()?n.reply(603):o.receiveRequest(n)):n.reply(481)}else n.body.search(/MSRP/ig)>-1?(o=new iu(this),o.init_incoming(n)):n.body.search(/JANUS/ig)>-1||(o=new $g(this),o.init_incoming(n));else Ct.warn("INVITE received but WebRTC is not supported"),n.reply(488);break;case Fe.BYE:n.reply(481);break;case Fe.CANCEL:o=this._findSession(n),o?o.receiveRequest(n):Ct.debug("received CANCEL request for a non existent session");break;case Fe.ACK:break;case Fe.NOTIFY:this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break;default:n.reply(405);break}}startMSRP(n,a){Ct.debug("startMSRP()",a);const e=new iu(this);return e.connect(n),e}startJanus(n,a){Ct.debug("startJanus()",a);const e=new iu(this);return e.connect(n),e}terminateMSRPSessions(n){Ct.debug("terminateSessions()");for(const a in this._msrp_sessions)this._msrp_sessions[a].isEnded()||this._msrp_sessions[a].terminate(n)}terminateJanusSessions(n){Ct.debug("terminateSessions()");for(const a in this._janus_sessions)this._janus_sessions[a].isEnded()||this._janus_sessions[a].terminate(n)}stop(){if(Ct.debug("stop()"),this._dynConfiguration={},this._status===zl.STATUS_USER_CLOSED){Ct.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const e in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,e)){Ct.debug(`closing session ${e}`);try{this._sessions[e].terminate()}catch(o){console.error(o)}}for(const e in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,e)){Ct.debug(`closing session ${e}`);try{this._msrp_sessions[e].terminate()}catch(o){console.error(o)}}for(const e in this._janus_sessions)if(Object.prototype.hasOwnProperty.call(this._janus_sessions,e)){Ct.debug(`closing session ${e}`);try{this._janus_sessions[e].terminate()}catch(o){console.error(o)}}for(const e in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,e))try{this._applicants[e].close()}catch(o){console.error(o)}this._status=zl.STATUS_USER_CLOSED,Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length===0&&n===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}function Bv(u){this.emit("connecting",u)}function Gv(u){this._status!==zl.STATUS_USER_CLOSED&&(this._status=zl.STATUS_READY,this._error=null,this.emit("connected",u),this._dynConfiguration.register&&this._registrator.register())}function Wv(u){const n=["nict","ict","nist","ist"];for(const a of n)for(const e in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],e)&&this._transactions[a][e].onTransportError();this.emit("disconnected",u),this._registrator.onTransportClosed(),this._status!==zl.STATUS_USER_CLOSED&&(this._status=zl.STATUS_NOT_READY,this._error=zl.NETWORK_ERROR)}function Kv(u){console.log("onTransportData",u);const n=u.transport;let a=u.message;if(a=Fv.parseMessage(a,this),!a){console.log("if 1 return");return}if(this._status===zl.STATUS_USER_CLOSED&&a instanceof xr.IncomingRequest){console.log("if 2 return");return}if(!pv(a,this,n)){console.log("if 3 return");return}if(console.log("onTransportData message",a),console.log("onTransportData instanceof",a instanceof xr.IncomingRequest),a instanceof xr.IncomingRequest)a.transport=n,console.log("onTransportData receiveRequest"),this.receiveRequest(a);else if(a instanceof xr.IncomingResponse){let e;switch(a.method){case Fe.INVITE:e=this._transactions.ict[a.via_branch],e&&e.receiveResponse(a);break;case Fe.ACK:break;default:e=this._transactions.nict[a.via_branch],e&&e.receiveResponse(a);break}}}const Yv=["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"],zv=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function xf(u){const n={};return Yv.forEach(a=>{u[a]!==void 0&&(n[a]=u[a])}),n.localHold=u._localHold,n}function Pf(u){const n={};return zv.forEach(a=>{u[a]!==void 0&&(n[a]=u[a])}),n}function Mf(u,n){const a=new AudioContext,e=a.createMediaStreamSource(u),o=a.createMediaStreamDestination(),p=a.createGain();return e.connect(p),p.connect(o),p.gain.value=n,o.stream}function Jv(u,n,a,e){const o=document.createElement("audio");o.id=n._id,o.className="audioTag",o.srcObject=u,Nh()||(o.setSinkId(a),o.volume=e),o.play(),n.audioTag=o}function Xv(u){if(u&&typeof u.log=="function"&&typeof u.warn=="function"&&typeof u.error=="function")return!0}function Nh(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}const Qv=Et,Zv=dn(),Bt=new Qv("WebSocketInterface");var eT=class{constructor(n){Bt.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;const a=Zv.parse(n,"absoluteURI");if(a===-1)throw Bt.warn(`invalid WebSocket URI: ${n}`),new TypeError(`Invalid argument: ${n}`);if(a.scheme!=="wss"&&a.scheme!=="ws")throw Bt.warn(`invalid WebSocket URI scheme: ${a.scheme}`),new TypeError(`Invalid argument: ${n}`);this._sip_uri=`sip:${a.host}${a.port?`:${a.port}`:""};transport=ws`,this._via_transport=a.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(n){this._via_transport=n.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(Bt.debug("connect()"),this.isConnected()){Bt.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Bt.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Bt.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(n){this._onError(n)}}disconnect(){Bt.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(n){return Bt.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(Bt.warn("unable to send message, WebSocket is not open"),!1)}isConnected(){return this._ws&&this._ws.readyState===this._ws.OPEN}isConnecting(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}_onOpen(){Bt.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:n,code:a,reason:e}){Bt.debug(`WebSocket ${this._url} closed`),n===!1&&Bt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!n,a,e)}_onMessage({data:n}){Bt.debug("received WebSocket message"),this.ondata(n)}_onError(n){Bt.warn(`WebSocket ${this._url} error: `,n)}};const Ou=lo,tT=Fe,sT=Gn,nT=xt(),lT=Oh,rT=Bn(),iT=fo(),aT=dn(),oT=eT,uT=oi("JsSIP");uT("version %s",Ou.version);var cT={C:tT,Exceptions:sT,Utils:nT,UA:lT,URI:rT,NameAddrHeader:iT,WebSocketInterface:oT,Grammar:aT,debug:oi,get name(){return Ou.title},get version(){return Ou.version}};const fT=ot(cT);function au(u){return u<10?`0${u}`:`${u}`}function hT(u){let n=u.hours||0,a=u.minutes||0,e=u.seconds||0;e++,e===60&&(e=0,a++,a===60&&(a=0,n++));const o=`${au(n)}:${au(a)}:${au(e)}`;return{seconds:e,minutes:a,hours:n,formatted:o}}var Pt={};Pt.forEach=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)if(o in u){const p=Promise.resolve(u[o]).then(t=>n.call(a||globalThis,t,o,u));e.push(p)}await Promise.all(e)};Pt.forEachSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)e in u&&await n.call(a||globalThis,await u[e],e,u)};Pt.map=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)o in u&&(e[o]=Promise.resolve(u[o]).then(p=>n.call(a||globalThis,p,o,u)));return Promise.all(e)};Pt.mapSeries=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)o in u&&(e[o]=await n.call(a||globalThis,await u[o],o,u));return e};Pt.find=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e();let p=1;for(let t=0;t<u.length;t++){const v=C=>{C?e(u[t]):p===u.length&&e(),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}});Pt.findSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(await n.call(a||globalThis,await u[e],e,u))return u[e]};Pt.findIndex=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e(-1);let p=1;for(let t=0;t<u.length;t++){const v=C=>{C?e(t):p===u.length&&e(-1),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}});Pt.findIndexSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(await n.call(a||globalThis,await u[e],e,u))return e};Pt.some=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e(!1);let p=1;for(let t=0;t<u.length;t++){if(!(t in u)){p++;continue}const v=C=>{C?e(!0):p===u.length&&e(!1),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}});Pt.someSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(e in u&&await n.call(a||globalThis,await u[e],e,u))return!0;return!1};Pt.every=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e(!0);let p=1;for(let t=0;t<u.length;t++){if(!(t in u)){p++;continue}const v=C=>{C?p===u.length&&e(!0):e(!1),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}});Pt.everySeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(e in u&&!await n.call(a||globalThis,await u[e],e,u))return!1;return!0};Pt.filter=(u,n,a)=>new Promise(async(e,o)=>{const p=[];for(let v=0;v<u.length;v++)v in u&&(p[v]=Promise.resolve(u[v]).then(C=>n.call(a||globalThis,C,v,u)).catch(o));const t=[];for(let v=0;v<p.length;v++)await p[v]&&t.push(await u[v]);e(t)});Pt.filterSeries=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)o in u&&await n.call(a||globalThis,await u[o],o,u)&&e.push(await u[o]);return e};Pt.reduce=async(u,n,a)=>{if(u.length===0&&a===void 0)throw TypeError("Reduce of empty array with no initial value");let e,o;for(a!==void 0?(o=a,e=0):(o=u[0],e=1),e;e<u.length;e++)e in u&&(o=await n(await o,await u[e],e,u));return o};var Uh={};(function(u){const n=Pt;Object.keys(n).forEach(a=>{const e=a.charAt(0).toUpperCase()+a.slice(1);u[`async${e}`]=async function(...o){return n[a](this,...o)}})})(Uh);const _T=Pt,dT=Uh;var pT=Object.assign(_T,{instanceMethods:dT});const Mr=new AudioContext,Bs={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var mT={exports:{}};(function(u){var n=function(a){var e=Object.prototype,o=e.hasOwnProperty,p=Object.defineProperty||function(P,Q,oe){P[Q]=oe.value},t,v=typeof Symbol=="function"?Symbol:{},C=v.iterator||"@@iterator",l=v.asyncIterator||"@@asyncIterator",A=v.toStringTag||"@@toStringTag";function b(P,Q,oe){return Object.defineProperty(P,Q,{value:oe,enumerable:!0,configurable:!0,writable:!0}),P[Q]}try{b({},"")}catch{b=function(Q,oe,he){return Q[oe]=he}}function E(P,Q,oe,he){var Re=Q&&Q.prototype instanceof _e?Q:_e,be=Object.create(Re.prototype),fe=new $(he||[]);return p(be,"_invoke",{value:K(P,oe,fe)}),be}a.wrap=E;function O(P,Q,oe){try{return{type:"normal",arg:P.call(Q,oe)}}catch(he){return{type:"throw",arg:he}}}var w="suspendedStart",N="suspendedYield",U="executing",Y="completed",j={};function _e(){}function k(){}function H(){}var de={};b(de,C,function(){return this});var Ue=Object.getPrototypeOf,B=Ue&&Ue(Ue(ne([])));B&&B!==e&&o.call(B,C)&&(de=B);var L=H.prototype=_e.prototype=Object.create(de);k.prototype=H,p(L,"constructor",{value:H,configurable:!0}),p(H,"constructor",{value:k,configurable:!0}),k.displayName=b(H,A,"GeneratorFunction");function V(P){["next","throw","return"].forEach(function(Q){b(P,Q,function(oe){return this._invoke(Q,oe)})})}a.isGeneratorFunction=function(P){var Q=typeof P=="function"&&P.constructor;return Q?Q===k||(Q.displayName||Q.name)==="GeneratorFunction":!1},a.mark=function(P){return Object.setPrototypeOf?Object.setPrototypeOf(P,H):(P.__proto__=H,b(P,A,"GeneratorFunction")),P.prototype=Object.create(L),P},a.awrap=function(P){return{__await:P}};function G(P,Q){function oe(be,fe,qe,xe){var we=O(P[be],P,fe);if(we.type==="throw")xe(we.arg);else{var st=we.arg,$e=st.value;return $e&&typeof $e=="object"&&o.call($e,"__await")?Q.resolve($e.__await).then(function(ue){oe("next",ue,qe,xe)},function(ue){oe("throw",ue,qe,xe)}):Q.resolve($e).then(function(ue){st.value=ue,qe(st)},function(ue){return oe("throw",ue,qe,xe)})}}var he;function Re(be,fe){function qe(){return new Q(function(xe,we){oe(be,fe,xe,we)})}return he=he?he.then(qe,qe):qe()}p(this,"_invoke",{value:Re})}V(G.prototype),b(G.prototype,l,function(){return this}),a.AsyncIterator=G,a.async=function(P,Q,oe,he,Re){Re===void 0&&(Re=Promise);var be=new G(E(P,Q,oe,he),Re);return a.isGeneratorFunction(Q)?be:be.next().then(function(fe){return fe.done?fe.value:be.next()})};function K(P,Q,oe){var he=w;return function(be,fe){if(he===U)throw new Error("Generator is already running");if(he===Y){if(be==="throw")throw fe;return ct()}for(oe.method=be,oe.arg=fe;;){var qe=oe.delegate;if(qe){var xe=M(qe,oe);if(xe){if(xe===j)continue;return xe}}if(oe.method==="next")oe.sent=oe._sent=oe.arg;else if(oe.method==="throw"){if(he===w)throw he=Y,oe.arg;oe.dispatchException(oe.arg)}else oe.method==="return"&&oe.abrupt("return",oe.arg);he=U;var we=O(P,Q,oe);if(we.type==="normal"){if(he=oe.done?Y:N,we.arg===j)continue;return{value:we.arg,done:oe.done}}else we.type==="throw"&&(he=Y,oe.method="throw",oe.arg=we.arg)}}}function M(P,Q){var oe=Q.method,he=P.iterator[oe];if(he===t)return Q.delegate=null,oe==="throw"&&P.iterator.return&&(Q.method="return",Q.arg=t,M(P,Q),Q.method==="throw")||oe!=="return"&&(Q.method="throw",Q.arg=new TypeError("The iterator does not provide a '"+oe+"' method")),j;var Re=O(he,P.iterator,Q.arg);if(Re.type==="throw")return Q.method="throw",Q.arg=Re.arg,Q.delegate=null,j;var be=Re.arg;if(!be)return Q.method="throw",Q.arg=new TypeError("iterator result is not an object"),Q.delegate=null,j;if(be.done)Q[P.resultName]=be.value,Q.next=P.nextLoc,Q.method!=="return"&&(Q.method="next",Q.arg=t);else return be;return Q.delegate=null,j}V(L),b(L,A,"Generator"),b(L,C,function(){return this}),b(L,"toString",function(){return"[object Generator]"});function te(P){var Q={tryLoc:P[0]};1 in P&&(Q.catchLoc=P[1]),2 in P&&(Q.finallyLoc=P[2],Q.afterLoc=P[3]),this.tryEntries.push(Q)}function se(P){var Q=P.completion||{};Q.type="normal",delete Q.arg,P.completion=Q}function $(P){this.tryEntries=[{tryLoc:"root"}],P.forEach(te,this),this.reset(!0)}a.keys=function(P){var Q=Object(P),oe=[];for(var he in Q)oe.push(he);return oe.reverse(),function Re(){for(;oe.length;){var be=oe.pop();if(be in Q)return Re.value=be,Re.done=!1,Re}return Re.done=!0,Re}};function ne(P){if(P){var Q=P[C];if(Q)return Q.call(P);if(typeof P.next=="function")return P;if(!isNaN(P.length)){var oe=-1,he=function Re(){for(;++oe<P.length;)if(o.call(P,oe))return Re.value=P[oe],Re.done=!1,Re;return Re.value=t,Re.done=!0,Re};return he.next=he}}return{next:ct}}a.values=ne;function ct(){return{value:t,done:!0}}return $.prototype={constructor:$,reset:function(P){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(se),!P)for(var Q in this)Q.charAt(0)==="t"&&o.call(this,Q)&&!isNaN(+Q.slice(1))&&(this[Q]=t)},stop:function(){this.done=!0;var P=this.tryEntries[0],Q=P.completion;if(Q.type==="throw")throw Q.arg;return this.rval},dispatchException:function(P){if(this.done)throw P;var Q=this;function oe(xe,we){return be.type="throw",be.arg=P,Q.next=xe,we&&(Q.method="next",Q.arg=t),!!we}for(var he=this.tryEntries.length-1;he>=0;--he){var Re=this.tryEntries[he],be=Re.completion;if(Re.tryLoc==="root")return oe("end");if(Re.tryLoc<=this.prev){var fe=o.call(Re,"catchLoc"),qe=o.call(Re,"finallyLoc");if(fe&&qe){if(this.prev<Re.catchLoc)return oe(Re.catchLoc,!0);if(this.prev<Re.finallyLoc)return oe(Re.finallyLoc)}else if(fe){if(this.prev<Re.catchLoc)return oe(Re.catchLoc,!0)}else if(qe){if(this.prev<Re.finallyLoc)return oe(Re.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(P,Q){for(var oe=this.tryEntries.length-1;oe>=0;--oe){var he=this.tryEntries[oe];if(he.tryLoc<=this.prev&&o.call(he,"finallyLoc")&&this.prev<he.finallyLoc){var Re=he;break}}Re&&(P==="break"||P==="continue")&&Re.tryLoc<=Q&&Q<=Re.finallyLoc&&(Re=null);var be=Re?Re.completion:{};return be.type=P,be.arg=Q,Re?(this.method="next",this.next=Re.finallyLoc,j):this.complete(be)},complete:function(P,Q){if(P.type==="throw")throw P.arg;return P.type==="break"||P.type==="continue"?this.next=P.arg:P.type==="return"?(this.rval=this.arg=P.arg,this.method="return",this.next="end"):P.type==="normal"&&Q&&(this.next=Q),j},finish:function(P){for(var Q=this.tryEntries.length-1;Q>=0;--Q){var oe=this.tryEntries[Q];if(oe.finallyLoc===P)return this.complete(oe.completion,oe.afterLoc),se(oe),j}},catch:function(P){for(var Q=this.tryEntries.length-1;Q>=0;--Q){var oe=this.tryEntries[Q];if(oe.tryLoc===P){var he=oe.completion;if(he.type==="throw"){var Re=he.arg;se(oe)}return Re}}throw new Error("illegal catch attempt")},delegateYield:function(P,Q,oe){return this.delegate={iterator:ne(P),resultName:Q,nextLoc:oe},this.method==="next"&&(this.arg=t),j}},a}(u.exports);try{regeneratorRuntime=n}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}})(mT);var xh={exports:{}};(function(u){(function(n,a){u.exports?u.exports=a():n.log=a()})(qh,function(){var n=function(){},a="undefined",e=typeof window!==a&&typeof window.navigator!==a&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function p(N,U){var Y=N[U];if(typeof Y.bind=="function")return Y.bind(N);try{return Function.prototype.bind.call(Y,N)}catch{return function(){return Function.prototype.apply.apply(Y,[N,arguments])}}}function t(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function v(N){return N==="debug"&&(N="log"),typeof console===a?!1:N==="trace"&&e?t:console[N]!==void 0?p(console,N):console.log!==void 0?p(console,"log"):n}function C(N,U){for(var Y=0;Y<o.length;Y++){var j=o[Y];this[j]=Y<N?n:this.methodFactory(j,N,U)}this.log=this.debug}function l(N,U,Y){return function(){typeof console!==a&&(C.call(this,U,Y),this[N].apply(this,arguments))}}function A(N,U,Y){return v(N)||l.apply(this,arguments)}function b(N,U,Y){var j=this,_e;U=U??"WARN";var k="loglevel";typeof N=="string"?k+=":"+N:typeof N=="symbol"&&(k=void 0);function H(L){var V=(o[L]||"silent").toUpperCase();if(!(typeof window===a||!k)){try{window.localStorage[k]=V;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+V+";"}catch{}}}function de(){var L;if(!(typeof window===a||!k)){try{L=window.localStorage[k]}catch{}if(typeof L===a)try{var V=window.document.cookie,G=V.indexOf(encodeURIComponent(k)+"=");G!==-1&&(L=/^([^;]+)/.exec(V.slice(G))[1])}catch{}return j.levels[L]===void 0&&(L=void 0),L}}function Ue(){if(!(typeof window===a||!k)){try{window.localStorage.removeItem(k);return}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}j.name=N,j.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},j.methodFactory=Y||A,j.getLevel=function(){return _e},j.setLevel=function(L,V){if(typeof L=="string"&&j.levels[L.toUpperCase()]!==void 0&&(L=j.levels[L.toUpperCase()]),typeof L=="number"&&L>=0&&L<=j.levels.SILENT){if(_e=L,V!==!1&&H(L),C.call(j,L,N),typeof console===a&&L<j.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+L},j.setDefaultLevel=function(L){U=L,de()||j.setLevel(L,!1)},j.resetLevel=function(){j.setLevel(U,!1),Ue()},j.enableAll=function(L){j.setLevel(j.levels.TRACE,L)},j.disableAll=function(L){j.setLevel(j.levels.SILENT,L)};var B=de();B==null&&(B=U),j.setLevel(B,!1)}var E=new b,O={};E.getLogger=function(U){if(typeof U!="symbol"&&typeof U!="string"||U==="")throw new TypeError("You must supply a name when creating a logger.");var Y=O[U];return Y||(Y=O[U]=new b(U,E.getLevel(),E.methodFactory)),Y};var w=typeof window!==a?window.log:void 0;return E.noConflict=function(){return typeof window!==a&&window.log===E&&(window.log=w),E},E.getLoggers=function(){return O},E.default=E,E})})(xh);var Ht=xh.exports;const qn=()=>`${new Date().toISOString()} | metrics`,jn=(u,n,a)=>`${u} | ${n} | ${a}`;Ht.setDefaultLevel(Ht.levels.TRACE);const gT=u=>{Ht.info(jn(qn(),"log ",`set log level to ${u?"verbose":"info"}`)),Ht.setLevel(u?Ht.levels.TRACE:Ht.levels.INFO)},vT=u=>{const n=[...Object.keys(Ht.levels)];n.includes(u)?(Ht.info(jn(qn(),"log ",`update log level to ${u.toLowerCase()}`)),Ht.setLevel(u)):Ht.warn(jn(qn(),"log ","Incorrect log level please choose one of "),n)},je=(u,n,a)=>{a?Ht.debug(jn(qn(),u,n),a):Ht.debug(jn(qn(),u,n))},ou=(u,n)=>{Ht.info(jn(qn(),u,n))},kr=(u,n)=>{Ht.info(jn(qn(),u,n))},Wa=(u,n)=>{Ht.warn(jn(qn(),u,n))},ri=(u,n)=>{Ht.error(jn(qn(),u,n))};function TT(u){return Math.floor(Math.random()*u).toString()}function kf(u,n){let a=n;return u.forEach(e=>{a=a.replace(e,"")}),a}function ET(u,n){let a="";for(let e=0;e<n;e+=1)a+=u[TT(u.length)];return a}function CT({length:u=20,useLetters:n=!0,useNumbers:a=!0,includeSymbols:e=[],excludeSymbols:o=[]}={}){let p="abcdefghijklmnopqrstuvwxyz",t="0123456789",v=[],C=[],l=[];return n&&(o.length&&(p=kf(o,p)),C=p.split("")),a&&(o.length&&(t=kf(o,t)),l=t.split("")),v=[...C,...l,...e],ET(v,u)}var ST=CT;const $i=ot(ST),AT=()=>"WebRTCMetrics",yT=()=>"5.0.3",ze={INBOUND:"inbound",OUTBOUND:"outbound"},Hn={IDLE:"idle",RUNNING:"running",MUTED:"muted"},xi={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},RT=()=>({...{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:[]}}),Ph={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:ze.INBOUND},Mh={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:ze.OUTBOUND},kh={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:ze.INBOUND},Lh={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:ze.OUTBOUND},bT=u=>{const n={pname:"",call_id:"",user_id:"",timestamp:null,count:0,audio:{},video:{},network:{infrastructure:3,local_candidate_id:"",local_candidate_type:"",local_candidate_protocol:"",local_candidate_relay_protocol:"",remote_candidate_id:"",remote_candidate_type:"",remote_candidate_protocol:""},data:{total_KBytes_in:0,total_KBytes_out:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,delta_kbs_bandwidth_in:0,delta_kbs_bandwidth_out:0,delta_rtt_connectivity_ms:null,total_rtt_connectivity_ms:0,total_rtt_connectivity_measure:0},experimental:{time_to_measure_ms:0}};if(u){const a={...u,audio:{},video:{},data:{...u.data},network:{...u.network},experimental:{...u.experimental}};return Object.keys(u.audio).forEach(e=>{a.audio[e]={...u.audio[e]}}),Object.keys(u.video).forEach(e=>{a.video[e]={...u.video[e]}}),a}return{...n,audio:{},video:{},data:{...n.data},network:{...n.network},experimental:{...n.experimental}}},IT={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${$i()}`,cid:`c-${$i()}`,uid:`u-${$i()}`,record:!1,ticket:!0},Vs={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"},X={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"},q={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},Pi={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},uu={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ce={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},cu="config ",wT=(u,n={},a)=>{const e={...a,...n};return n.pname||Wa(cu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${a.pname}'`),n.cid||Wa(cu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${a.cid}'`),n.uid||Wa(cu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${a.uid}'`),e.pc=u,e},OT=(u={})=>{const n={...IT,...u};return n.name=AT(),n.version=yT(),n},sa=(u,n,a,e=!1,o)=>{let p=u.map(t=>{if(!a)return t[n];if(!o)return t[n][a];const v=t[n][o];return v?v[a]:null});return p=p.filter(t=>e?Number.isFinite(t)&&t>0:Number.isFinite(t)),p.length===0?[]:p},Xl=u=>u.reduce((n,a)=>n+a,0)/u.length,DT=()=>`probe-${$i()}`,NT=()=>`coltr-${$i()}`,Lf=u=>new Promise(n=>setTimeout(n,u)),Du=(u,n,a)=>{n?u.call(n,a):u(a)},rt=(u,n,a,e)=>{const o=sa(u,n,a,!0,e);if(o.length===0)return null;const p=o.reduce((l,A)=>l+A,0)/o.length;return p===0?null:o.map(l=>Math.abs(p-l)).reduce((l,A)=>l+A,0)/o.length*100/p},ut=(u,n,a,e=!1,o)=>{const p=sa(u,n,a,e,o);return p.length===0?null:p.reduce((t,v)=>t+v,0)/p.length},Nr=(u,n,a)=>sa(u,n,a).reduce((o,p)=>o+p,0),it=(u,n,a,e)=>{const o=sa(u,n,a,!0,e);return o.length===0?null:Math.min(...o)},at=(u,n,a,e)=>{const o=sa(u,n,a,!1,e);return o.length===0?null:Math.max(...o)},wt=(u,n,a,e)=>{const o=u.slice().pop();if(!o)return null;if(!a)return o[n];if(!e)return o[n][a];const p=o[n][e];return p?p[a]:null},UT=u=>u.slice().pop(),St=(u,n,a)=>{if(!n)return null;const e={};let o=n[q.AUDIO][u];o||(o=a===ze.INBOUND?{...Ph}:{...Mh}),e[q.AUDIO]=o;let p=n[q.VIDEO][u];return p||(p=a===ze.INBOUND?{...kh}:{...Lh}),e[q.VIDEO]=p,e},Mi="exporter ",xT="2.0",$f=(u,n,a)=>{if(!u||u.length===0)return 0;const e=u[u.length-1];if(!e)return 0;const o=e[n][a];if(o){const p=o.total_rtt_ms_out,t=o.total_rtt_measure_out;return!t||!p?ut(u,n,"delta_rtt_ms_out",!1,a):Number(p/t)}return null},PT=(u,n)=>{if(!u||u.length===0)return 0;const a=u[u.length-1];if(!a)return 0;const e=a[n].total_rtt_connectivity_ms,o=a[n].total_rtt_connectivity_measure;return!o||!e?ut(u,n,"delta_rtt_connectivity_ms"):Number(e/o)},MT=u=>wt(u,"network","local_candidate_type")!=="relay"?`direct/${wt(u,"network","local_candidate_protocol")}`:`turn/${wt(u,"network","local_candidate_relay_protocol")}`,kT=u=>{const n=wt(u,"network","remote_candidate_type"),a=wt(u,"network","remote_candidate_protocol");return n!=="relay"?`direct/${a}`:`turn/${a}`};class LT{constructor(n){this._start=null,this._end=null,this._cfg=n,this._referenceReport=null,this._reports=[],this._events=[]}start(){ou(Mi,"start() - start exporter...");const n=new Date;return this._start=n.toJSON(),n}stop(){ou(Mi,"stop() - stop exporter...");const n=new Date;return this._end=n.toJSON(),n}saveReferenceReport(n){this._referenceReport=n}getReferenceReport(){return this._referenceReport}addReport(n){this._cfg.ticket&&(je(Mi,`addReport() - add report to exporter at ${n.timestamp}`),this._reports.push(n))}addCustomEvent(n){this._events.push(n)}reset(){ou(Mi,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){je(Mi,"ticket() - generate ticket");const n=wt(this._reports,"audio","total_packets_lost_in"),a=wt(this._reports,"audio","total_packets_in"),e=wt(this._reports,"video","total_packets_lost_in"),o=wt(this._reports,"video","total_packets_in"),p={},t=UT(this._reports);return t&&(Object.keys(t[q.AUDIO]).forEach(v=>{const C=t[q.AUDIO][v];if(p[C.ssrc]={type:q.AUDIO,direction:C.direction},C.direction===ze.INBOUND){const l={avg:ut(this._reports,q.AUDIO,"delta_jitter_ms_in",!1,v),min:it(this._reports,q.AUDIO,"delta_jitter_ms_in",v),max:at(this._reports,q.AUDIO,"delta_jitter_ms_in",v),volatility:rt(this._reports,q.AUDIO,"delta_jitter_ms_in",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.AUDIO,"delta_kbs_in",!1,v),min:it(this._reports,q.AUDIO,"delta_kbs_in",v),max:at(this._reports,q.AUDIO,"delta_kbs_in",v),volatility:rt(this._reports,q.AUDIO,"delta_kbs_in",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.AUDIO,"delta_KBytes_in",!1,v),min:it(this._reports,q.AUDIO,"delta_KBytes_in",v),max:at(this._reports,q.AUDIO,"delta_KBytes_in",v),volatility:rt(this._reports,q.AUDIO,"delta_KBytes_in",v),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:ut(this._reports,q.AUDIO,"mos_emodel_in",!1,v),min:it(this._reports,q.AUDIO,"mos_emodel_in",v),max:at(this._reports,q.AUDIO,"mos_emodel_in",v),volatility:rt(this._reports,q.AUDIO,"mos_emodel_in",v)},effective:{avg:ut(this._reports,q.AUDIO,"mos_in",!1,v),min:it(this._reports,q.AUDIO,"mos_in",v),max:at(this._reports,q.AUDIO,"mos_in",v),volatility:rt(this._reports,q.AUDIO,"mos_in",v)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},O=wt(this._reports,q.AUDIO,"total_packets_lost_in",v),w=wt(this._reports,q.AUDIO,"total_packets_in",v),N={lost:O,avg:Math.round((O/(O+w)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};p[v].jitter=l,p[v].mos=E,p[v].traffic=b,p[v].bitrate=A,p[v].loss=N}else{const l={avg:ut(this._reports,q.AUDIO,"delta_jitter_ms_out",!1,v),min:it(this._reports,q.AUDIO,"delta_jitter_ms_out",v),max:at(this._reports,q.AUDIO,"delta_jitter_ms_out",v),volatility:rt(this._reports,q.AUDIO,"delta_jitter_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.AUDIO,"delta_kbs_out",!1,v),min:it(this._reports,q.AUDIO,"delta_kbs_out",v),max:at(this._reports,q.AUDIO,"delta_kbs_out",v),volatility:rt(this._reports,q.AUDIO,"delta_kbs_out",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.AUDIO,"delta_KBytes_out",!1,v),min:it(this._reports,q.AUDIO,"delta_KBytes_out",v),max:at(this._reports,q.AUDIO,"delta_KBytes_out",v),volatility:rt(this._reports,q.AUDIO,"delta_KBytes_out",v),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:$f(this._reports,q.AUDIO,v),min:it(this._reports,q.AUDIO,"delta_rtt_ms_out",v),max:at(this._reports,q.AUDIO,"delta_rtt_ms_out",v),volatility:rt(this._reports,q.AUDIO,"delta_rtt_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},O=wt(this._reports,q.AUDIO,"total_packets_lost_out",v),w=wt(this._reports,q.AUDIO,"total_packets_out",v),N={lost:O,avg:Math.round((O/(O+w)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},U={emodel:{avg:ut(this._reports,q.AUDIO,"mos_emodel_out",!1,v),min:it(this._reports,q.AUDIO,"mos_emodel_out",v),max:at(this._reports,q.AUDIO,"mos_emodel_out",v),volatility:rt(this._reports,q.AUDIO,"mos_emodel_out",v)},effective:{avg:ut(this._reports,q.AUDIO,"mos_out",!1,v),min:it(this._reports,q.AUDIO,"mos_out",v),max:at(this._reports,q.AUDIO,"mos_out",v),volatility:rt(this._reports,q.AUDIO,"mos_out",v)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};p[v].jitter=l,p[v].rtt=E,p[v].traffic=b,p[v].bitrate=A,p[v].loss=N,p[v].mos=U}}),Object.keys(t[q.VIDEO]).forEach(v=>{const C=t[q.VIDEO][v];if(p[v]={type:q.VIDEO,direction:C.direction},C.direction===ze.INBOUND){const l={avg:ut(this._reports,q.VIDEO,"delta_jitter_ms_in",!1,v),min:it(this._reports,q.VIDEO,"delta_jitter_ms_in",v),max:at(this._reports,q.VIDEO,"delta_jitter_ms_in",v),volatility:rt(this._reports,q.VIDEO,"delta_jitter_ms_in",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.VIDEO,"delta_kbs_in",!1,v),min:it(this._reports,q.VIDEO,"delta_kbs_in",v),max:at(this._reports,q.VIDEO,"delta_kbs_in",v),volatility:rt(this._reports,q.VIDEO,"delta_kbs_in",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.VIDEO,"delta_KBytes_in",!1,v),min:it(this._reports,q.VIDEO,"delta_KBytes_in",v),max:at(this._reports,q.VIDEO,"delta_KBytes_in",v),volatility:rt(this._reports,q.VIDEO,"delta_KBytes_in",v),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=wt(this._reports,q.VIDEO,"total_packets_lost_in",v),O=wt(this._reports,q.VIDEO,"total_packets_in",v),w={lost:E,avg:Math.round((E/(E+O)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};p[v].jitter=l,p[v].traffic=b,p[v].bitrate=A,p[v].loss=w}else{const l={avg:ut(this._reports,q.VIDEO,"delta_jitter_ms_out",!1,v),min:it(this._reports,q.VIDEO,"delta_jitter_ms_out",v),max:at(this._reports,q.VIDEO,"delta_jitter_ms_out",v),volatility:rt(this._reports,q.VIDEO,"delta_jitter_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.VIDEO,"delta_kbs_out",!1,v),min:it(this._reports,q.VIDEO,"delta_kbs_out",v),max:at(this._reports,q.VIDEO,"delta_kbs_out",v),volatility:rt(this._reports,q.VIDEO,"delta_kbs_out",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.VIDEO,"delta_KBytes_out",!1,v),min:it(this._reports,q.VIDEO,"delta_KBytes_out",v),max:at(this._reports,q.VIDEO,"delta_KBytes_out",v),volatility:rt(this._reports,q.VIDEO,"delta_KBytes_out",v),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:$f(this._reports,q.VIDEO,v),min:it(this._reports,q.VIDEO,"delta_rtt_ms_out",v),max:at(this._reports,q.VIDEO,"delta_rtt_ms_out",v),volatility:rt(this._reports,q.VIDEO,"delta_rtt_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},O=wt(this._reports,q.VIDEO,"total_packets_lost_out",v),w=wt(this._reports,q.VIDEO,"total_packets_out",v),N={lost:O,avg:Math.round((O/(O+w)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};p[v].jitter=l,p[v].rtt=E,p[v].traffic=b,p[v].bitrate=A,p[v].loss=N}})),{version:xT,configuration:{frequency:this._cfg.refreshEvery},started:this._start,ended:this._end,ua:{agent:navigator.userAgent,pname:this._cfg.pname,user_id:this._cfg.uid},call:{call_id:this._cfg.cid,events:this._events},details:{count:this._reports.length,reports:this._cfg.record?this._reports:[],reference:this._referenceReport||null},ssrc:p,data:{rtt:{avg:PT(this._reports,"data"),min:it(this._reports,"data","delta_rtt_connectivity_ms"),max:at(this._reports,"data","delta_rtt_connectivity_ms"),volatility:rt(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((n/(n+a)*100||0)*100)/100}},video:{in:{avg:Math.round((e/(e+o)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:ut(this._reports,"data","delta_kbs_in"),min:it(this._reports,"data","delta_kbs_in"),max:at(this._reports,"data","delta_kbs_in"),volatility:rt(this._reports,"data","delta_kbs_in")},out:{avg:ut(this._reports,"data","delta_kbs_out"),min:it(this._reports,"data","delta_kbs_out"),max:at(this._reports,"data","delta_kbs_out"),volatility:rt(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:ut(this._reports,"data","delta_KBytes_in"),min:it(this._reports,"data","delta_KBytes_in"),max:at(this._reports,"data","delta_KBytes_in"),volatility:rt(this._reports,"data","delta_KBytes_in")},out:{avg:ut(this._reports,"data","delta_KBytes_out"),min:it(this._reports,"data","delta_KBytes_out"),max:at(this._reports,"data","delta_KBytes_out"),volatility:rt(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:MT(this._reports),remoteConnection:kT(this._reports)}}}}updateConfig(n){this._cfg=n}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const n=this._reports.slice();return n.pop(),n.pop()||null}getReportsNumber(){return this._reports.length}}const Wl="extractor ",Hf=(u,n,a,e)=>{let o=!1;const p=e[n].total_rtt_ms_out,t=e[n].total_rtt_measure_out,v=a?a[n].total_rtt_ms_out:0,C=a?a[n].total_rtt_measure_out:0,l={rtt:null,totalRTT:p,totalRTTMeasurements:t};if(u[X.TIMESTAMP]===e[n].timestamp_out||!Object.prototype.hasOwnProperty.call(u,X.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(u,X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(o=!0,Number(u[X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(u[X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-C===t))return l;const A=1e3*Number(u[X.ROUND_TRIP_TIME]);let b=p+A,E=t+1;return o&&(b=1e3*Number(u[X.TOTAL_ROUND_TRIP_TIME])-v,E=Number(u[X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-C),{rtt:A,totalRTT:b,totalRTTMeasurements:E}},$T=(u,n,a,e)=>{if(!Object.prototype.hasOwnProperty.call(u,X.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:e[n].total_rtt_connectivity_ms,totalRTTMeasurements:e[n].total_rtt_connectivity_measure};const o=1e3*Number(u[X.CURRENT_ROUND_TRIP_TIME]);let p=e[n].total_rtt_connectivity_ms+o,t=e[n].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(u,X.TOTAL_ROUND_TRIP_TIME)&&(p=1e3*Number(u[X.TOTAL_ROUND_TRIP_TIME])-(a?a[n].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(u,X.RESPONSES_RECEIVED)&&(t=Number(u[X.RESPONSES_RECEIVED])-(a?a[n].total_rtt_connectivity_measure:0)),{rtt:o,totalRTT:p,totalRTTMeasurements:t}},Na=(u,n,a)=>u[X.TIMESTAMP]===a[n].timestamp_out||!Object.prototype.hasOwnProperty.call(u,X.JITTER)?null:1e3*(Number(u[X.JITTER])||0),HT=(u,n)=>{if(!Object.prototype.hasOwnProperty.call(u,X.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(u,X.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:n[q.VIDEO].delta_ms_decode_frame_in,frames_decoded:n[q.VIDEO].total_frames_decoded_in,total_decode_time:n[q.VIDEO].total_time_decoded_in};const a=u[X.FRAMES_DECODED],e=u[X.TOTAL_DECODE_TIME],o=e-n[q.VIDEO].total_time_decoded_in,p=a-n[q.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:p>0?o*1e3/p:0,frames_decoded:a,total_decode_time:e}},FT=(u,n)=>{if(!Object.prototype.hasOwnProperty.call(u,X.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(u,X.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:n[q.VIDEO].delta_ms_encode_frame_out,frames_encoded:n[q.VIDEO].total_frames_encoded_out,total_encode_time:n[q.VIDEO].total_time_encoded_out};const a=u[X.FRAMES_ENCODED],e=u[X.TOTAL_ENCODE_TIME],o=e-n[q.VIDEO].total_time_encoded_out,p=a-n[q.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:p>0&&o?o*1e3/p:0,frames_encoded:a,total_encode_time:e}},Ff=(u,n,a,e)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(u,X.BYTES_SENT))return{packetsSent:a[n].total_packets_out,packetsLost:a[n].total_packets_lost_out,bytesSent:a[n].total_KBytes_out};const o=Number(u[X.PACKETS_SENT])||0-(e?e[n].total_packets_out:0),p=o-a[n].total_packets_out,t=Number(u[X.BYTES_SENT])/1024-(e?e[n].total_KBytes_out:0),v=t-a[n].total_KBytes_out,C=u[X.TIMESTAMP]||Date.now(),l=e?e.timestamp:null;let A=a.timestamp;!A&&l&&(A=l);const b=A?C-A:0,E=b>0?v*.008*1024/b*1e3:0;return{packetsSent:o,deltaPacketsSent:p,KBytesSent:t,deltaKBytesSent:v,kbsSent:E}},qf=(u,n,a,e)=>{let o=a[n].total_packets_lost_out,p=0,t=0;return Object.prototype.hasOwnProperty.call(u,X.PACKETS_LOST)&&(o=Number(u[X.PACKETS_LOST])||0-(e?e[n].total_packets_lost_out:0),p=o-a[n].total_packets_lost_out),Object.prototype.hasOwnProperty.call(u,X.FRACTION_LOST)&&(t=Number(100*u[X.FRACTION_LOST])),{packetsLost:o,deltaPacketsLost:p,fractionLost:t}},jf=(u,n,a,e)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(u,X.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(u,X.BYTES_RECEIVED))return{percent_packets_lost:a[n].percent_packets_lost_in,packetsReceived:a[n].total_packets_in,packetsLost:a[n].total_packets_lost_in,bytesReceived:a[n].total_KBytes_in};const o=Number(u[X.PACKETS_RECEIVED])||0-(e?e[n].total_packets_in:0),p=Number(u[X.PACKETS_LOST])||0-(e?e[n].total_packets_lost_in:0),t=p-a[n].total_packets_lost_in,v=o-a[n].total_packets_in,C=o!==a[n].total_packets_in?t*100/(t+v):0,l=Number(u[X.BYTES_RECEIVED])/1024-(e?e[n].total_KBytes_in:0),A=l-a[n].total_KBytes_in,b=u[X.TIMESTAMP]||Date.now(),E=e?e.timestamp:null;let O=a.timestamp;!O&&E&&(O=E);const w=O?b-O:0,N=w>0?A*.008*1024/w*1e3:0;return{percentPacketsLost:C,packetsReceived:o,deltaPacketsReceived:v,packetsLost:p,deltaPacketsLost:t,KBytesReceived:l,deltaKBytesReceived:A,kbsReceived:N}},qT=u=>u[X.CANDIDATE_TYPE]!=="relay"?"":u[X.RELAY_PROTOCOL]||"",jT=u=>{if(!Object.prototype.hasOwnProperty.call(u,X.NETWORK_TYPE))return Pi.WIFI;switch(u[X.NETWORK_TYPE]){case uu.ETHERNET:return Pi.ETHERNET;case uu.CELLULAR_4G:return Pi.CELLULAR_4G;case uu.WIFI:return Pi.WIFI;default:return Pi.CELLULAR}},Vf=u=>!Object.prototype.hasOwnProperty.call(u,X.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(u,X.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:u[X.FRAME_WIDTH]||null,height:u[X.FRAME_HEIGHT]||null,framerate:u[X.FRAMES_PER_SECOND]},VT=u=>{const n=Object.prototype.hasOwnProperty.call(u,X.QUALITY_LIMITATION_REASON)?u[X.QUALITY_LIMITATION_REASON]:null,a=Object.prototype.hasOwnProperty.call(u,X.QUALITY_LIMITATION_RESOLUTION_CHANGES)?u[X.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,e=Object.prototype.hasOwnProperty.call(u,X.QUALITY_LIMITATION_DURATIONS)?u[X.QUALITY_LIMITATION_DURATIONS]:null;return e&&Object.keys(e).forEach(o=>{e[o]>1e3&&(e[o]=Number(e[o]/1e3))}),{reason:n,durations:e,resolutionChanges:a}},BT=(u,n,a)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PLI)||!Object.prototype.hasOwnProperty.call(u,X.NACK))return{pliCount:n.total_pli_sent_in,nackCount:n.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const e=(u[X.PLI]||0)-(a?a[q.VIDEO].total_pli_sent_in:0),o=(u[X.NACK]||0)-(a?a[q.VIDEO].total_nack_sent_in:0);return{pliCount:e,nackCount:o,deltaPliCount:e-n[q.VIDEO].total_pli_sent_in,deltaNackCount:o-n[q.VIDEO].total_nack_sent_in}},GT=(u,n,a)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PLI)||!Object.prototype.hasOwnProperty.call(u,X.NACK))return{pliCount:n.total_pli_received_out,nackCount:n.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const e=(u[X.PLI]||0)-(a?a[q.VIDEO].total_pli_received_out:0),o=(u[X.NACK]||0)-(a?a[q.VIDEO].total_nack_received_out:0);return{pliCount:e,nackCount:o,deltaPliCount:e-n[q.VIDEO].total_pli_received_out,deltaNackCount:o-n[q.VIDEO].total_nack_received_out}},WT=u=>({channels:u[X.CHANNELS]||null,clock_rate:u[X.CLOCK_RATE]||null,mime_type:u[X.MIME_TYPE]||null,sdp_fmtp_line:u[X.SDP_FMTP_LINE]||null}),KT=u=>({clock_rate:u[X.CLOCK_RATE]||null,mime_type:u[X.MIME_TYPE]||null}),YT=(u,n,a)=>{const e=(u[X.BYTES_RECEIVED]||0)/1024-(a?a.data.total_KBytes_in:0),o=(u[X.BYTES_SENT]||0)/1024-(a?a.data.total_KBytes_out:0),p=u[X.TIMESTAMP]||Date.now(),t=e-n.data.total_KBytes_in,v=o-n.data.total_KBytes_out,C=a?a.timestamp:null;let l=n.timestamp;!l&&C&&(l=C);const A=l?p-l:0,b=A>0?t*.008*1024/A*1e3:0,E=A>0?v*.008*1024/A*1e3:0;return{total_KBytes_received:e,total_KBytes_sent:o,delta_KBytes_received:t,delta_KBytes_sent:v,kbs_speed_received:b,kbs_speed_sent:E}},zT=u=>{const n=u[X.AVAILABLE_INCOMING_BITRATE]/1024||0,a=u[X.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:n,kbs_outgoing_bandwidth:a}},JT=(u,n,a,e)=>{if(!u)return[];switch(u[X.TYPE]){case Vs.CANDIDATE_PAIR:let o=!1;if(u[X.NOMINATED]&&u[X.STATE]===q.SUCCEEDED&&(o=!0,je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u),X.SELECTED in u&&!u[X.SELECTED]&&(o=!1)),o){const t=u[X.LOCAL_CANDIDATE_ID],v=u[X.REMOTE_CANDIDATE_ID],C=YT(u,n,e),l=zT(u),A=$T(u,"data",e,n);return[{type:ce.NETWORK,value:{local_candidate_id:t}},{type:ce.NETWORK,value:{remote_candidate_id:v}},{type:ce.DATA,value:{total_KBytes_in:C.total_KBytes_received}},{type:ce.DATA,value:{total_KBytes_out:C.total_KBytes_sent}},{type:ce.DATA,value:{delta_KBytes_in:C.delta_KBytes_received}},{type:ce.DATA,value:{delta_KBytes_out:C.delta_KBytes_sent}},{type:ce.DATA,value:{delta_kbs_in:C.kbs_speed_received}},{type:ce.DATA,value:{delta_kbs_out:C.kbs_speed_sent}},{type:ce.DATA,value:{delta_kbs_bandwidth_in:l.kbs_incoming_bandwidth}},{type:ce.DATA,value:{delta_kbs_bandwidth_out:l.kbs_outgoing_bandwidth}},{type:ce.DATA,value:{delta_rtt_connectivity_ms:A.rtt}},{type:ce.DATA,value:{total_rtt_connectivity_ms:A.totalRTT}},{type:ce.DATA,value:{total_rtt_connectivity_measure:A.totalRTTMeasurements}}]}break;case Vs.LOCAL_CANDIDATE:if(u[X.ID]===n.network.local_candidate_id)return[{type:ce.NETWORK,value:{infrastructure:jT(u)}},{type:ce.NETWORK,value:{local_candidate_type:u[X.CANDIDATE_TYPE]||""}},{type:ce.NETWORK,value:{local_candidate_protocol:u[X.PROTOCOL]||""}},{type:ce.NETWORK,value:{local_candidate_relay_protocol:qT(u)}}];break;case Vs.REMOTE_CANDIDATE:if(u[X.ID]===n.network.remote_candidate_id)return[{type:ce.NETWORK,value:{remote_candidate_type:u[X.CANDIDATE_TYPE]||""}},{type:ce.NETWORK,value:{remote_candidate_protocol:u[X.PROTOCOL]||""}}];break;case Vs.INBOUND_RTP:{je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const t=u[X.SSRC],v=St(t,n,ze.INBOUND);v&&(v.timestamp=n.timestamp);const C=St(t,e,ze.INBOUND);if(C&&(C.timestamp=e.timestamp),u[X.MEDIA_TYPE]===q.AUDIO){const l=jf(u,q.AUDIO,v,C),A=Na(u,q.AUDIO,v),b=u[X.CODEC_ID]||"";return[{ssrc:t,type:ce.AUDIO,value:{codec_id_in:b}},{ssrc:t,type:ce.AUDIO,value:{total_packets_in:l.packetsReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_in:l.deltaPacketsReceived}},{ssrc:t,type:ce.AUDIO,value:{total_packets_lost_in:l.packetsLost}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_lost_in:l.deltaPacketsLost}},{ssrc:t,type:ce.AUDIO,value:{percent_packets_lost_in:l.percentPacketsLost}},{ssrc:t,type:ce.AUDIO,value:{total_KBytes_in:l.KBytesReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_KBytes_in:l.deltaKBytesReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_kbs_in:l.kbsReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_jitter_ms_in:A}}]}if(u[X.MEDIA_TYPE]===q.VIDEO){const l=HT(u,v),A=jf(u,q.VIDEO,v,C),b=Na(u,q.VIDEO,v),E=u[X.DECODER_IMPLEMENTATION]||null,O=u[X.CODEC_ID]||null,w=Vf(u),N=BT(u,v,C);return[{ssrc:t,type:ce.VIDEO,value:{codec_id_in:O}},{ssrc:t,type:ce.VIDEO,value:{total_packets_in:A.packetsReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_in:A.deltaPacketsReceived}},{ssrc:t,type:ce.VIDEO,value:{total_packets_lost_in:A.packetsLost}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_lost_in:A.deltaPacketsLost}},{ssrc:t,type:ce.VIDEO,value:{percent_packets_lost_in:A.percentPacketsLost}},{ssrc:t,type:ce.VIDEO,value:{total_KBytes_in:A.KBytesReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_KBytes_in:A.deltaKBytesReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_kbs_in:A.kbsReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_jitter_ms_in:b}},{ssrc:t,type:ce.VIDEO,value:{decoder_in:E}},{ssrc:t,type:ce.VIDEO,value:{delta_ms_decode_frame_in:l.delta_ms_decode_frame}},{ssrc:t,type:ce.VIDEO,value:{total_frames_decoded_in:l.frames_decoded}},{ssrc:t,type:ce.VIDEO,value:{total_time_decoded_in:l.total_decode_time}},{ssrc:t,type:ce.VIDEO,value:{total_nack_sent_in:N.nackCount}},{ssrc:t,type:ce.VIDEO,value:{delta_nack_sent_in:N.deltaNackCount}},{ssrc:t,type:ce.VIDEO,value:{total_pli_sent_in:N.pliCount}},{ssrc:t,type:ce.VIDEO,value:{delta_pli_sent_in:N.deltaPliCount}},{ssrc:t,type:ce.VIDEO,value:{size_in:w}}]}break}case Vs.OUTBOUND_RTP:{je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const t=u[X.SSRC],v=St(t,n,ze.OUTBOUND);v&&(v.timestamp=n.timestamp);const C=St(t,e,ze.OUTBOUND);if(C&&(C.timestamp=e.timestamp),u[X.MEDIA_TYPE]===q.AUDIO){const l=u[X.CODEC_ID]||null,A=Ff(u,q.AUDIO,v,C);return[{ssrc:t,type:ce.AUDIO,value:{codec_id_out:l}},{ssrc:t,type:ce.AUDIO,value:{total_packets_out:A.packetsSent}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_out:A.deltaPacketsSent}},{ssrc:t,type:ce.AUDIO,value:{total_KBytes_out:A.KBytesSent}},{ssrc:t,type:ce.AUDIO,value:{delta_KBytes_out:A.deltaKBytesSent}},{ssrc:t,type:ce.AUDIO,value:{delta_kbs_out:A.kbsSent}}]}if(u[X.MEDIA_TYPE]===q.VIDEO){const l=u[X.ENCODER_IMPLEMENTATION]||null,A=u[X.CODEC_ID]||null,b=FT(u,v),E=Vf(u),O=VT(u),w=GT(u,v,C),N=Ff(u,q.VIDEO,v,C);return[{ssrc:t,type:ce.VIDEO,value:{codec_id_out:A}},{ssrc:t,type:ce.VIDEO,value:{total_packets_out:N.packetsSent}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_out:N.deltaPacketsSent}},{ssrc:t,type:ce.VIDEO,value:{total_KBytes_out:N.KBytesSent}},{ssrc:t,type:ce.VIDEO,value:{delta_KBytes_out:N.deltaKBytesSent}},{ssrc:t,type:ce.VIDEO,value:{delta_kbs_out:N.kbsSent}},{ssrc:t,type:ce.VIDEO,value:{encoder_out:l}},{ssrc:t,type:ce.VIDEO,value:{delta_ms_encode_frame_out:b.delta_ms_encode_frame}},{ssrc:t,type:ce.VIDEO,value:{total_frames_encoded_out:b.frames_encoded}},{ssrc:t,type:ce.VIDEO,value:{total_time_encoded_out:b.total_encode_time}},{ssrc:t,type:ce.VIDEO,value:{total_nack_received_out:w.nackCount}},{ssrc:t,type:ce.VIDEO,value:{delta_nack_received_out:w.deltaNackCount}},{ssrc:t,type:ce.VIDEO,value:{total_pli_received_out:w.pliCount}},{ssrc:t,type:ce.VIDEO,value:{delta_pli_received_out:w.deltaPliCount}},{ssrc:t,type:ce.VIDEO,value:{size_out:E}},{ssrc:t,type:ce.VIDEO,value:{limitation_out:O}}]}break}case Vs.MEDIA_SOURCE:{je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);break}case Vs.TRACK:{je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);break}case Vs.CODEC:const p=[];return Object.keys(n[q.AUDIO]).forEach(t=>{const v=n[q.AUDIO][t];if(v.codec_id_in===u[X.ID]||v.codec_id_out===u[X.ID]){je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const C=WT(u);u[X.ID]===v.codec_id_in?p.push({ssrc:v.ssrc,type:ce.AUDIO,value:{codec_in:C}}):p.push({ssrc:v.ssrc,type:ce.AUDIO,value:{codec_out:C}})}}),Object.keys(n[q.VIDEO]).forEach(t=>{const v=n[q.VIDEO][t];if(v.codec_id_in===u[X.ID]||v.codec_id_out===u[X.ID]){je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const C=KT(u);u[X.ID]===v.codec_id_in?p.push({ssrc:v.ssrc,type:ce.VIDEO,value:{codec_in:C}}):p.push({ssrc:v.ssrc,type:ce.VIDEO,value:{codec_out:C}})}}),p;case Vs.REMOTE_INBOUND_RTP:{je(Wl,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const t=u[X.SSRC],v=St(t,n,ze.OUTBOUND),C=St(t,e,ze.OUTBOUND);if(u[X.KIND]===q.AUDIO){const l=Hf(u,q.AUDIO,C,v),A=Na(u,q.AUDIO,v),b=qf(u,q.AUDIO,v,C);return[{ssrc:t,type:ce.AUDIO,value:{delta_rtt_ms_out:l.rtt}},{ssrc:t,type:ce.AUDIO,value:{total_rtt_ms_out:l.totalRTT}},{ssrc:t,type:ce.AUDIO,value:{total_rtt_measure_out:l.totalRTTMeasurements}},{ssrc:t,type:ce.AUDIO,value:{delta_jitter_ms_out:A}},{ssrc:t,type:ce.AUDIO,value:{timestamp_out:u[X.TIMESTAMP]}},{ssrc:t,type:ce.AUDIO,value:{total_packets_lost_out:b.packetsLost}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_lost_out:b.deltaPacketsLost}},{ssrc:t,type:ce.AUDIO,value:{percent_packets_lost_out:b.fractionLost}}]}if(u[X.KIND]===q.VIDEO){const l=Hf(u,q.VIDEO,C,v),A=Na(u,q.VIDEO,v),b=qf(u,q.VIDEO,v,C);return[{ssrc:t,type:ce.VIDEO,value:{delta_rtt_ms_out:l.rtt}},{ssrc:t,type:ce.VIDEO,value:{total_rtt_ms_out:l.totalRTT}},{ssrc:t,type:ce.VIDEO,value:{total_rtt_measure_out:l.totalRTTMeasurements}},{ssrc:t,type:ce.VIDEO,value:{delta_jitter_ms_out:A}},{ssrc:t,type:ce.VIDEO,value:{timestamp_out:u[X.TIMESTAMP]}},{ssrc:t,type:ce.VIDEO,value:{total_packets_lost_out:b.packetsLost}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_lost_out:b.deltaPacketsLost}},{ssrc:t,type:ce.VIDEO,value:{percent_packets_lost_out:b.fractionLost}}]}break}}return[]},_o=u=>u<0?1:u>100?4.5:1+.035*u+7/1e6*u*(u-60)*(100-u),XT=(u,n=q.AUDIO,a,e,o)=>{const p=St(o,u,ze.INBOUND),t=St(o,a,ze.INBOUND),v=St(o,e,ze.INBOUND),C=[],l=[],A=p[n].percent_packets_lost_in,b=p[n].delta_jitter_ms_in,E=t&&t[n].delta_jitter_ms_in||null,O=v&&v[n].delta_jitter_ms_in||null,w=u.data.delta_rtt_connectivity_ms,N=a&&a.data.delta_rtt_connectivity_ms||null,U=e&&e.data.delta_rtt_connectivity_ms||null;w&&C.push(w),N&&C.push(N),U&&C.push(U),b&&l.push(b),a&&E&&l.push(E),e&&O&&l.push(O);const Y=C.length>0?Xl(C):100,j=l.length>0?Xl(l):10,_e=93.2-A,k=.18*_e*_e-27.9*_e+1126.62,H=(Y+j)/2,de=H-177.3<0?0:1,Ue=.024*H+.11*(H-177.3)*de,B=k-Ue;return _o(B)},QT=(u,n=q.AUDIO,a,e,o)=>{const p=St(o,u,ze.OUTBOUND),t=St(o,a,ze.OUTBOUND),v=St(o,e,ze.OUTBOUND),C=[],l=[],A=p[n].percent_packets_lost_out,b=p[n].delta_rtt_ms_out,E=t&&t[n].delta_rtt_ms_out||null,O=v&&v[n].delta_rtt_ms_out||null,w=p[n].delta_jitter_ms_out,N=t&&t[n].delta_jitter_ms_out||null,U=v&&v[n].delta_jitter_ms_out||null,Y=u.data.delta_rtt_connectivity_ms,j=a&&a.data.delta_rtt_connectivity_ms||null,_e=e&&e.data.delta_rtt_connectivity_ms||null;b?C.push(b):Y&&C.push(Y),E?C.push(E):j&&C.push(j),O?C.push(O):_e&&C.push(_e),w&&l.push(w),a&&N&&l.push(N),e&&U&&l.push(U);const k=C.length>0?Xl(C):100,H=l.length>0?Xl(l):10,de=93.2-A,Ue=.18*de*de-27.9*de+1126.62,B=(k+H)/2,L=B-177.3<0?0:1,V=.024*B+.11*(B-177.3)*L,G=Ue-V;return _o(G)},ZT=(u,n=q.AUDIO,a,e,o)=>{const p=St(o,u,ze.INBOUND),t=St(o,a,ze.INBOUND),v=St(o,e,ze.INBOUND),C=[],l=[],A=p[n].percent_packets_lost_in/100,b=p[n].delta_jitter_ms_in,E=t&&t[n].delta_jitter_ms_in||null,O=v&&v[n].delta_jitter_ms_in||null,w=u.data.delta_rtt_connectivity_ms,N=a&&a.data.delta_rtt_connectivity_ms||null,U=e&&e.data.delta_rtt_connectivity_ms||null;w&&C.push(w),N&&C.push(N),U&&C.push(U),b&&l.push(b),t&&E&&l.push(E),v&&O&&l.push(O);const Y=C.length>0?Xl(C):100,j=l.length>0?Xl(l):10,_e=0,k=19.8,H=29.7,de=30,Ue=(Y+j)/2+de,B=Ue-177.3<0?0:1,L=.024*Ue+.11*(Ue-177.3)*B,G=93.2-(_e+k*Math.log(1+H*A)+L);return _o(G)},eE=(u,n=q.AUDIO,a,e,o)=>{const p=St(o,u,ze.OUTBOUND),t=St(o,a,ze.OUTBOUND),v=St(o,e,ze.OUTBOUND),C=[],l=[],A=p[n].percent_packets_lost_out/100,b=p[n].delta_rtt_ms_out,E=t&&t[n].delta_rtt_ms_out||null,O=v&&v[n].delta_rtt_ms_out||null,w=p[n].delta_jitter_ms_out,N=t&&t[n].delta_jitter_ms_out||null,U=v&&v[n].delta_jitter_ms_out||null,Y=u.data.delta_rtt_connectivity_ms,j=a&&a.data.delta_rtt_connectivity_ms||null,_e=e&&e.data.delta_rtt_connectivity_ms||null;b?C.push(b):Y&&C.push(Y),E?C.push(E):j&&C.push(j),O?C.push(O):_e&&C.push(_e),w&&l.push(w),t&&N&&l.push(N),v&&U&&l.push(U);const k=C.length>0?Xl(C):100,H=l.length>0?Xl(l):10,de=0,Ue=19.8,B=29.7,L=30,V=(k+H)/2+L,G=V-177.3<0?0:1,K=.024*V+.11*(V-177.3)*G,te=93.2-(de+Ue*Math.log(1+B*A)+K);return _o(te)};class tE{constructor(n,a){this._callbacks={onreport:null,onticket:null},this._id=NT(),this._moduleName=this._id,this._probeId=a,this._config=n,this._exporter=new LT(n),this._state=Hn.IDLE,this.registerToPCEvents(),kr(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(n,a,e,o){const p=(C,l)=>C===q.AUDIO?l===Vs.INBOUND_RTP?{...Ph}:{...Mh}:l===Vs.INBOUND_RTP?{...kh}:{...Lh},t=bT(a);t.pname=this._config.pname,t.call_id=this._config.cid,t.user_id=this._config.uid,t.count=a?a.count+1:1;let v=null;return n.forEach(C=>{!v&&C.timestamp&&(v=C.timestamp),JT(C,t,t.pname,o).forEach(A=>{if(A.value&&A.type)if(A.ssrc){let b=t[A.type][A.ssrc];b||(b=p(A.type,C.type),b.ssrc=A.ssrc,t[A.type][A.ssrc]=b),Object.keys(A.value).forEach(E=>{b[E]=A.value[E]})}else Object.keys(A.value).forEach(b=>{t[A.type][b]=A.value[b]})})}),t.timestamp=v,Object.keys(t[q.AUDIO]).forEach(C=>{const l=t[q.AUDIO][C];l.direction===ze.INBOUND?(l.mos_emodel_in=XT(t,q.AUDIO,a,e,l.ssrc),l.mos_in=ZT(t,q.AUDIO,a,e,l.ssrc)):(l.mos_emodel_out=QT(t,q.AUDIO,a,e,l.ssrc),l.mos_out=eE(t,q.AUDIO,a,e,l.ssrc))}),t}async takeReferenceStats(){return new Promise((n,a)=>{const e=Date.now();setTimeout(async()=>{try{const o=Date.now()-e,p=Date.now(),t=await this._config.pc.getStats(),v=this.analyze(t,null,null,null),C=Date.now();v.experimental.time_to_measure_ms=C-p,v.experimental.time_to_wait_ms=o,this._exporter.saveReferenceReport(v),je(this._moduleName,`got reference report for probe ${this._probeId}`),n()}catch(o){a(o)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==Hn.RUNNING||!this._config.pc)return je(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const n=Date.now(),a=await this._config.pc.getStats(),e=this.analyze(a,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),o=Date.now();return e.experimental.time_to_measure_ms=o-n,this._exporter.addReport(e),je(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(e),e}catch(n){return ri(this._moduleName,`got error ${n}`),null}}async start(){je(this._moduleName,"starting"),this.state=Hn.RUNNING,this._startedTime=this._exporter.start(),je(this._moduleName,"started")}async mute(){this.state=Hn.MUTED,je(this._moduleName,"muted")}async unmute(){this.state=Hn.RUNNING,je(this._moduleName,"unmuted")}async stop(n){if(je(this._moduleName,`stopping${n?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=Hn.IDLE,this._config.ticket){const{ticket:a}=this._exporter;this.fireOnTicket(a)}this._exporter.reset(),je(this._moduleName,"stopped")}registerCallback(n,a,e){n in this._callbacks?(this._callbacks[n]={callback:a,context:e},je(this._moduleName,`registered callback '${n}'`)):ri(this._moduleName,`can't register callback for '${n}' - not found`)}unregisterCallback(n){n in this._callbacks?(this._callbacks[n]=null,delete this._callbacks[n],je(this._moduleName,`unregistered callback '${n}'`)):ri(this._moduleName,`can't unregister callback for '${n}' - not found`)}fireOnReport(n){this._callbacks.onreport&&Du(this._callbacks.onreport.callback,this._callbacks.onreport.context,n)}fireOnTicket(n){this._callbacks.onticket&&Du(this._callbacks.onticket.callback,this._callbacks.onticket.context,n)}updateConfig(n){this._config=n,this._exporter.updateConfig(n)}get state(){return this._state}set state(n){this._state=n,je(this._moduleName,`state changed to ${n}`)}addCustomEvent(n,a,e,o){this._exporter.addCustomEvent({at:typeof n=="object"?n.toJSON():n,category:a,name:e,description:o})}async registerToPCEvents(){const{pc:n}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const a=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${a.length} devices found`,"Media Devices state")}catch{ri(this._moduleName,"can't get devices")}},n){n.oniceconnectionstatechange=()=>{const e=n.iceConnectionState;e===xi.CONNECTED||e===xi.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",e,"ICE connection state"):e===xi.DISCONNECTED||e===xi.FAILED?this.addCustomEvent(new Date().toJSON(),"call",e,"ICE connection state"):e===xi.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},n.onicegatheringstatechange=()=>{const e=n.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",e,"ICE gathering state")},n.ontrack=e=>{this.addCustomEvent(new Date().toJSON(),"call",`${e.track.kind}track`,"MediaStreamTrack received")},n.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const a=n.getReceivers();if(a&&a.length>0){const e=a[0],{transport:o}=e;if(o){const{iceTransport:p}=o;p&&(p.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class sE{constructor(n){this._id=n.pname&&n.pname.substr(0,12).padEnd(12," ")||DT(),this._moduleName=this._id,kr(this._moduleName,"probe created"),this._config=n,this._collector=new tE(this._config,this._id)}set onreport(n){n?this._collector.registerCallback("onreport",n):this._collector.unregisterCallback("onreport")}set onticket(n){n?this._collector.registerCallback("onticket",n):this._collector.unregisterCallback("onticket")}get id(){return this._id}get pname(){return this._config.pname}get cid(){return this._config.cid}get uid(){return this._config.uid}get state(){return this._collector.state}set state(n){this._collector.state=n}addCustomEvent(n,a,e,o=new Date().toJSON()){this._collector.addCustomEvent(o,a,n,e)}get isRunning(){return this._collector.state===Hn.RUNNING}get isIdle(){return this._collector.state===Hn.IDLE}updateUserId(n){this._config.uid=n,this._collector.updateConfig(this._config)}updateCallId(n){this._config.cid=n,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){Wa(this._moduleName,"probe is already running");return}this._collector.start()}stop(n=!1){this.isRunning&&this._collector.stop(n)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const $t="engine ";class nE{constructor(n){this._config=n,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},kr($t,`configured for probing every ${this._config.refreshEvery}ms`),kr($t,`configured for starting after ${this._config.startAfter}ms`),kr($t,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),je($t,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(n=>n.isRunning)}get isIdle(){return this._probes.every(n=>n.isIdle)}addNewProbe(n,a){if(!n)throw new Error("undefined peer connection");const e=wT(n,a,this._config),o=new sE(e);return this._probes.push(o),je($t,`${this._probes.length} probes registered`),o}removeExistingProbe(n){if(!n)throw new Error("undefined probe");n.state===Hn.RUNNING&&n.stop(),this._probes=this._probes.filter(a=>n.id!==a.id)}async start(){const n=()=>{this._probes.forEach(p=>p.start())},a=async()=>Promise.all(this._probes.map(p=>p.takeReferenceStats())),e=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,o=async()=>{const p=RT(),t=this._probes.filter(v=>v.isRunning);for(const v of t){const C=await v.collectStats();C&&p.probes.push(C),je($t,`got probe ${v.id}`),await Lf(0)}return p.delta_time_to_measure_probes_ms=Nr(p.probes,"experimental","time_to_measure_ms"),p.delta_KBytes_in=Nr(p.probes,"data","delta_KBytes_in"),p.delta_KBytes_out=Nr(p.probes,"data","delta_KBytes_out"),p.delta_kbs_in=Nr(p.probes,"data","delta_kbs_in"),p.delta_kbs_out=Nr(p.probes,"data","delta_kbs_out"),p.total_time_decoded_in=Nr(p.probes,"video","total_time_decoded_in"),p.total_time_encoded_out=Nr(p.probes,"video","total_time_encoded_out"),p};for(je($t,"starting to collect"),n(),je($t,"generating reference reports..."),await a(),je($t,"reference reports generated"),this._startedTime=Date.now();e();)if(je($t,`wait ${this._config.refreshEvery}ms before collecting`),await Lf(this._config.refreshEvery),e()){je($t,"collecting...");const p=Date.now(),t=await o(),v=Date.now();t.delta_time_consumed_to_measure_ms=v-p,this.fireOnReports(t),je($t,"collected")}je($t,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(n){const a=e=>{this._probes.forEach(o=>{o.stop(e)})};kr($t,"stop collecting"),a(n)}registerCallback(n,a,e){n in this._callbacks?(this._callbacks[n]={callback:a,context:e},je($t,`registered callback '${n}'`)):ri($t,`can't register callback for '${n}' - not found`)}unregisterCallback(n){n in this._callbacks?(this._callbacks[n]=null,delete this._callbacks[n],je(this._moduleName,`unregistered callback '${n}'`)):ri(this._moduleName,`can't unregister callback for '${n}' - not found`)}fireOnReports(n){this._callbacks.onresult&&n.probes.length>0&&Du(this._callbacks.onresult.callback,this._callbacks.onresult.context,n)}}const lE="interface ";class rE{constructor(n){this._config=OT(n),kr(lE,`welcome to ${this._config.name} version ${this._config.version}`),gT(this._config.verbose||!1),this._engine=new nE(this._config)}setupLogLevel(n){vT(n)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(n,a){return this._engine.addNewProbe(n,a)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(n){this._engine.removeExistingProbe(n)}set onresult(n){n?this._engine.registerCallback("onresult",n):this._engine.unregisterCallback("onresult")}}function iE(u,n){return Object.keys(u).filter(a=>n.includes(a)).reduce((a,e)=>{const o=e;return{...a,[o]:u[o]}},{})}const aE=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"];class oE{constructor(n){this.intervals={},this.emitInterval=n.emitInterval||200,this.onChangeFunction=n.onChangeFunction}start(n,a){n&&n.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(n,a))}stop(n){this.clearVolumeInterval(n)}clearVolumeInterval(n){console.log("clearVolumeInterval",n),clearInterval(this.intervals[n]),delete this.intervals[n]}clearAllIntervals(){Object.keys(this.intervals).forEach(n=>{clearInterval(this.intervals[n])}),this.intervals={}}beginCalculation(n,a){this.clearVolumeInterval(a);const e=Mr.createAnalyser(),o=Mr.createMediaStreamSource(n),p=Mr.createScriptProcessor(2048,1,1);e.smoothingTimeConstant=.8,e.fftSize=1024,o.connect(e),e.connect(p),p.connect(Mr.destination),this.intervals[a]=setInterval(()=>{const t=new Uint8Array(e.frequencyBinCount);e.getByteFrequencyData(t);let v=0;const C=t.length;for(let A=0;A<C;A++)v+=t[A];const l=v/C;this.onChangeFunction(a,l)},this.emitInterval)}}const Ua={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},uE=0;class cE{constructor(n){this.isAutoAnswer=!1,this.muteWhenJoinEnabled=!1,this.isDNDEnabled=!1,this.muted=!1,this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},this.availableMediaDevices=[],this.selectedMediaDevices={input:"default",output:"default"},this.callStatus={},this.callTime={},this.callMetrics={},this.timeIntervals={},this.metricConfig={refreshEvery:1e3},this.activeStreamValue=null,this.initialStreamValue=null,this.context=n,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new oE({onChangeFunction:this.emitVolumeChange.bind(this)}),this.initializeMediaDevices()}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(n){this.currentActiveRoomIdValue=n,this.context.emit("currentActiveRoomChanged",n)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(n){this.isCallAddingInProgress=n,this.context.emit("callAddingInProgressChanged",n)}get muteWhenJoin(){return this.muteWhenJoinEnabled}get isDND(){return this.isDNDEnabled}get speakerVolume(){return this.speakerVolumeValue}get microphoneInputLevel(){return this.microphoneInputLevelValue}get getActiveCalls(){return this.activeCalls}get hasActiveCalls(){return Object.values(this.extendedCalls).length>0}get getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(n=>n.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(n=>n.kind==="audiooutput")}get getUserMediaConstraints(){return Nh()?{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(n){this.availableMediaDevices=n,this.context.emit("changeAvailableDeviceList",n)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const n=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(n)}async initializeMediaDevices(){const n=localStorage.getItem(Ua.SELECTED_INPUT_DEVICE)||"default",a=localStorage.getItem(Ua.SELECTED_OUTPUT_DEVICE)||"default";try{const e=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),o=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(o),await this.setMicrophone(n),await this.setSpeaker(a),navigator.mediaDevices.addEventListener("devicechange",async()=>{const p=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(p)}),e.getTracks().forEach(p=>p.stop())}catch(e){console.error(e)}}setCallTime(n){const a={...n};delete a.callId,this.callTime={...this.callTime,[n.callId]:a},this.context.emit("changeCallTime",this.callTime)}removeCallTime(n){const a={...this.callTime};delete a[n],this.callTime={...a},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(n,a){this.timeIntervals={...this.timeIntervals,[n]:a}}removeTimeInterval(n){const a={...this.timeIntervals};a[n]&&(clearInterval(a[n]),delete a[n],this.timeIntervals={...a})}stopCallTimer(n){this.removeTimeInterval(n),this.removeCallTime(n)}emitVolumeChange(n,a){this.context.emit("changeCallVolume",{callId:n,volume:a})}setMetricsConfig(n){this.metricConfig={...this.metricConfig,...n}}sendDTMF(n,a){if(!/^[A-D0-9]+$/g.test(a))throw new Error("Not allowed character in DTMF input");this.extendedCalls[n].sendDTMF(a)}setIsMuted(n){this.muted=n,this.context.emit("changeIsMuted",n)}processMute(n){const a=this.currentActiveRoomId;this.setIsMuted(n),this.initialStreamValue.getTracks().forEach(e=>e.enabled=!n),this.roomReconfigure(a)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:n,toHold:a,automatic:e}){const o=this.extendedCalls[n];o._automaticHold=e??!1,await new Promise(v=>{const C=()=>{v()};a?o.hold({},C):o.unhold({},C)}),this.updateCall(o);const t=Object.values(this.extendedCalls).filter(v=>v.roomId===this.currentActiveRoomId&&(a?n!==v._id:!0));t.length>1&&await this.doConference(t)}holdCall(n,a=!1){return this.processHold({callId:n,automatic:a,toHold:!0})}unholdCall(n){return this.processHold({callId:n,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(n=>n.direction==="outgoing"&&n.status===uE).forEach(n=>this.terminateCall(n._id))}answerCall(n){const a=this.extendedCalls[n];this.cancelAllOutgoingUnanswered(),a.answer(this.sipOptions),this.updateCall(a),this.setActiveRoom(a.roomId),a.connection.addEventListener("track",e=>{this.triggerAddStream(e,a)})}async moveCall(n,a){this.updateCallStatus({callId:n,isMoving:!0}),await this.processRoomChange({callId:n,roomId:a}),this.updateCallStatus({callId:n,isMoving:!1})}updateCall(n){this.activeCalls[n._id]=xf(n),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(n){const e={...this.activeRooms[n.roomId],...n};this.activeRooms={...this.activeRooms,[n.roomId]:{...e}},this.context.emit("updateRoom",{room:e,roomList:this.activeRooms})}hasAutoAnswerHeaders(n){const a=/answer-after=0/,o=n.request.getHeader("Call-Info");return o&&a.test(o)}addCall(n,a=!0){this.activeCalls={...this.activeCalls,[n._id]:xf(n)},this.extendedCalls[n._id]=n,a&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(n){this.callStatus={...this.callStatus,[n]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(n){const e={...{...this.callStatus[n.callId]}};n.isMoving!==void 0&&(e.isMoving=n.isMoving),n.isTransferring!==void 0&&(e.isTransferring=n.isTransferring),n.isMerging!==void 0&&(e.isMerging=n.isMerging),this.callStatus={...this.callStatus,[n.callId]:{...e}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(n){const a={...this.callStatus};delete a[n],this.callStatus={...a},this.context.emit("changeCallStatus",this.callStatus)}addRoom(n){this.activeRooms={...this.activeRooms,[n.roomId]:n},this.context.emit("addRoom",{room:n,roomList:this.activeRooms})}getActiveStream(){const n=Mf(this.initialStreamValue,this.microphoneInputLevel*2);return n.getTracks().forEach(a=>a.enabled=!this.isMuted),this.setActiveStream(n),n}async setMicrophone(n){if(!this.getInputDeviceList.find(({deviceId:e})=>e===n)||(this.setSelectedInputDevice(n),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const a=Object.values(this.extendedCalls).filter(e=>e.roomId===this.currentActiveRoomId);a.length===1?Object.values(a).forEach(async e=>{const o=this.getActiveStream();e.connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.updateCall(e)}):await this.doConference(a)}setActiveStream(n){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(n,"origin"),this.activeStreamValue=n,this.context.emit("changeActiveStream",n)}async setSpeaker(n){if(!this.getOutputDeviceList.find(({deviceId:o})=>o===n))return;this.setSelectedOutputDevice(n);const a=Object.values(this.extendedCalls);if(a.length===0)return;const e=a.filter(o=>o.roomId===this.currentActiveRoomId);e.length===1?a.forEach(o=>{var p;(p=o.audioTag)==null||p.setSinkId(n),this.updateCall(o)}):await this.doConference(e)}removeRoom(n){const a={...this.activeRooms},e={...a[n]};delete a[n],this.activeRooms={...a},this.context.emit("removeRoom",{room:e,roomList:this.activeRooms})}deleteRoomIfEmpty(n){n!==void 0&&Object.values(this.extendedCalls).filter(a=>a.roomId===n).length===0&&(this.removeRoom(n),this.currentActiveRoomId===n&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(n){this.muted?n.mute({audio:!0}):n.unmute({audio:!0})}async roomReconfigure(n){var e;if(n===void 0)return;const a=Object.values(this.extendedCalls).filter(o=>o.roomId===n);if(this.currentActiveRoomId===n?a.forEach(o=>{o.audioTag&&(this.muteReconfigure(o),o.audioTag.muted=!1,this.updateCall(o))}):a.forEach(o=>{o.audioTag&&(o.audioTag.muted=!0,this.updateCall(o))}),a.length===0)this.deleteRoomIfEmpty(n);else if(a.length===1&&this.currentActiveRoomId!==n)a[0].isOnHold().local||await this.holdCall(a[0].id,!0);else if(a.length===1&&this.currentActiveRoomId===n){if(a[0].isOnHold().local&&a[0]._automaticHold&&await this.unholdCall(a[0].id),a[0].connection&&((e=a[0].connection)!=null&&e.getSenders()[0])){const o=this.getActiveStream();await a[0].connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.muteReconfigure(a[0])}}else a.length>1&&await this.doConference(a)}async doConference(n){const a=[];n.forEach(e=>{e!=null&&e.connection.getReceivers().forEach(o=>{a.push(o.track)})}),await pT.forEach(n,async e=>{var t;if(e==null)return;const o=new MediaStream,p=Mr.createMediaStreamDestination();if(e.connection.getReceivers().forEach(v=>{a.forEach(C=>{o.addTrack(v.track),v.track.id!==C.id&&Mr.createMediaStreamSource(new MediaStream([C])).connect(p)})}),n[0].roomId===this.currentActiveRoomId){const v=this.getActiveStream();Mr.createMediaStreamSource(v).connect(p)}(t=e.connection)!=null&&t.getSenders()[0]&&(await e.connection.getSenders()[0].replaceTrack(p.stream.getTracks()[0]),this.muteReconfigure(e))})}processCallerMute(n,a){const e=this.extendedCalls[n];e&&e.connection.getReceivers().length&&(e.localMuted=a,e.connection.getReceivers().forEach(o=>{o.track.enabled=!a}),this.updateCall(e))}muteCaller(n){this.processCallerMute(n,!0)}unmuteCaller(n){this.processCallerMute(n,!1)}terminateCall(n){const a=this.extendedCalls[n];a._status!==8&&a.terminate()}transferCall(n,a){if(a.toString().length===0)return new Error("Target must be passed");const e=this.extendedCalls[n];if(!e._is_confirmed&&!e._is_canceled){const o=`sip:${a}@${this.context.sipDomain}`;e.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${o}`]});return}this.updateCallStatus({callId:n,isTransferring:!0}),e.refer(`sip:${a}@${this.context.sipDomain}`),this.updateCall(e)}mergeCall(n){const a=Object.values(this.extendedCalls).filter(p=>p.roomId===n);if(a.length!==2)return;const e=a[0],o=a[1];!e||!o||(this.updateCallStatus({callId:e._id,isMerging:!0}),this.updateCallStatus({callId:o._id,isMerging:!0}),e.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(e))}mergeCallByIds(n,a){const e=Object.values(this.extendedCalls).find(p=>p._id===n),o=Object.values(this.extendedCalls).find(p=>p._id===a);if(!e||!o)throw new Error("Call ID is not provided");this.updateCallStatus({callId:n,isMerging:!0}),this.updateCallStatus({callId:a,isMerging:!0}),e.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(e)}setDND(n){this.isDNDEnabled=n,this.context.emit("changeIsDND",n)}startCallTimer(n){this.removeTimeInterval(n);const a={callId:n,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(a);const e=setInterval(()=>{const o={...this.callTime[n]},p=hT(o);this.setCallTime({callId:n,...p})},1e3);this.setTimeInterval(n,e)}async setActiveRoom(n){const a=this.currentActiveRoomId;n!==a&&(this.currentActiveRoomId=n,await this.roomReconfigure(a),await this.roomReconfigure(n))}getNewRoomId(){const n=Object.keys(this.activeRooms);return n.length===0?1:parseInt(n.sort()[n.length-1])+1}async setupCall(n){var l,A;const a=n.session;if(this.getActiveCalls[a.id]!==void 0)return;const o=this.getNewRoomId(),p={started:new Date,incomingInProgress:!1,roomId:o};a.direction==="incoming"?(this.context.logger.log("New incoming call from",(A=(l=a._remote_identity)==null?void 0:l._uri)==null?void 0:A._user),p.incomingInProgress=!0,this.context.subscribe(Bs.CALL_CONFIRMED,b=>{a.id===b.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.startCallTimer(a.id))}),this.context.subscribe(Bs.CALL_FAILED,b=>{a.id===b.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.deleteRoomIfEmpty(o))})):a.direction==="outgoing"&&(a.once("confirmed",()=>{this.startCallTimer(a.id)}),this.startCallTimer(a.id));const t=a,v=this.hasAutoAnswerHeaders(n),C=t.direction==="incoming"&&!this.hasActiveCalls&&(v||this.autoAnswer);t.roomId=o,t.localMuted=!1,t.autoAnswer=C,C?this.addCall(t,!1):this.addCall(t),this.addCallStatus(a.id),this.addRoom(p),C&&this.answerCall(t._id)}removeCall(n){const a={...this.activeCalls};delete a[n],this.activeCalls={...a};const e={...this.extendedCalls};delete e[n],this.extendedCalls={...e},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(n){var o;const a=this.extendedCalls[n._id];this.stopVUMeter("origin"),(o=a.connection)==null||o.getSenders().forEach(p=>{p.track.stop()});const e=a.roomId;this.removeCall(n._id),this.roomReconfigure(e)}async newRTCSessionCallback(n){const a=n.session;if(this.isDND){a.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(this.context.triggerListener({listenerType:Bs.NEW_CALL,session:a,event:n}),a.on("ended",e=>{var p,t,v;this.stopVUMeter(a.id),this.context.logger.log("Session ended for",(t=(p=a._remote_identity)==null?void 0:p._uri)==null?void 0:t._user),this.context.triggerListener({listenerType:Bs.CALL_ENDED,session:a,event:e});const o=this.getActiveCalls[a.id];o&&this.activeCallListRemove(o),this.stopCallTimer(a.id),this.removeCallStatus(a.id),this.removeCallMetrics(a.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(v=this.initialStreamValue)==null||v.getTracks().forEach(C=>C.stop()),this.initialStreamValue=null)}),a.on("progress",e=>{var o,p;this.context.logger.log("Session in progress for",(p=(o=a._remote_identity)==null?void 0:o._uri)==null?void 0:p._user),this.context.triggerListener({listenerType:Bs.CALL_PROGRESS,session:a,event:e})}),a.on("failed",e=>{var p,t,v;this.stopVUMeter(a.id),this.context.logger.log("Session failed for",(t=(p=a._remote_identity)==null?void 0:p._uri)==null?void 0:t._user),this.context.triggerListener({listenerType:Bs.CALL_FAILED,session:a,event:e}),a.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const o=this.getActiveCalls[a.id];o&&this.activeCallListRemove(o),this.stopCallTimer(a.id),this.removeCallStatus(a.id),this.removeCallMetrics(a.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(v=this.initialStreamValue)==null||v.getTracks().forEach(C=>C.stop()),this.initialStreamValue=null)}),a.on("confirmed",e=>{var o,p;this.context.logger.log("Session confirmed for",(p=(o=a._remote_identity)==null?void 0:o._uri)==null?void 0:p._user),this.context.triggerListener({listenerType:Bs.CALL_CONFIRMED,session:a,event:e}),this.updateCall(a),a.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(n),a.direction==="outgoing"){const e=this.getActiveCalls[a.id].roomId;this.setActiveRoom(e)}}setMuteWhenJoin(n){this.muteWhenJoinEnabled=n,this.context.emit("changeMuteWhenJoin",n)}setMicrophoneSensitivity(n){if(n<0||n>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=n,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(n){this.speakerVolumeValue=n,Object.values(this.extendedCalls).forEach(a=>{a.audioTag&&(a.audioTag.volume=n,this.updateCall(a))})}setAutoAnswer(n){this.isAutoAnswer=n}setSelectedInputDevice(n){localStorage.setItem(Ua.SELECTED_INPUT_DEVICE,n),this.selectedMediaDevices.input=n,this.context.emit("changeActiveInputMediaDevice",n)}setSelectedOutputDevice(n){localStorage.setItem(Ua.SELECTED_OUTPUT_DEVICE,n),this.selectedMediaDevices.output=n,this.context.emit("changeActiveOutputMediaDevice",n)}setCallMetrics(n){const a={...n};delete a.callId,this.callMetrics={...this.callMetrics,[n.callId]:a},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(n){const a={...this.callMetrics};delete a[n],this.callMetrics={...a},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(n){const a=new rE(this.metricConfig),e=a.createProbe(n.connection,{cid:n._id}),o=[];let p;e.onreport=t=>{Object.entries(t.audio).forEach(([l,A])=>{A.direction==="inbound"&&!o.includes(l)&&(o.push(l),p=l)});const v=t.audio[p];if(!v)return;const C=iE(v,aE);C.callId=n._id,this.setCallMetrics(C)},this.context.subscribe(Bs.CALL_ENDED,t=>{t._id===n._id&&a.stopAllProbes()}),a.startAllProbes()}setupVUMeter(n,a){this.VUMeter.start(n,a)}stopVUMeter(n){this.VUMeter.stop(n)}async setupStream(){const n=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(a=>a.stop()),this.initialStreamValue=null),this.initialStreamValue=n}async triggerAddStream(n,a){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const e=Mf(this.initialStreamValue,this.microphoneInputLevel*2),o=this.isMuted||this.muteWhenJoin;e.getTracks().forEach(t=>t.enabled=!o),this.setActiveStream(e),await a.connection.getSenders()[0].replaceTrack(e.getTracks()[0]);const p=new MediaStream([n.track]);Jv(p,a,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(p,a._id),this.getCallQuality(a),this.updateCall(a)}initCall(n,a){if(n.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${n}@${this.context.sipDomain}...`);const e=this.context.call(`sip:${n}@${this.context.sipDomain}`,this.sipOptions);this.callAddingInProgress=e.id,a&&this.currentActiveRoomId!==void 0&&this.processRoomChange({callId:e.id,roomId:this.currentActiveRoomId}),e.connection.addEventListener("track",o=>{this.triggerAddStream(o,e)})}async processRoomChange({callId:n,roomId:a}){const e=this.extendedCalls[n].roomId;this.extendedCalls[n].roomId=a;const o=this.extendedCalls[n];return this.updateCall(o),await this.setActiveRoom(a),Promise.all([this.roomReconfigure(e),this.roomReconfigure(a)]).then(()=>{this.deleteRoomIfEmpty(e),this.deleteRoomIfEmpty(a)})}}class fE{constructor(n){this.context=n}get sipOptions(){return{...this.context.options.sipOptions}}initCall(n,a){if(n.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${n}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${n}@${this.context.sipDomain}`,a,this.sipOptions)}stop(n={}){this.context.terminateJanusSessions(n)}}class hE{constructor(n){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=n,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(n){const a=this.extendedMessages[n];this.updateMSRPSession(a)}updateMSRPSession(n){this.activeMessages[n._id]=Pf(n),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(n){this.activeMessages={...this.activeMessages,[n._id]:Pf(n)},this.extendedMessages[n._id]=n,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(n,a){const e=this.msrpHistory[a.id]||[];e.push(n),this.msrpHistory={...this.msrpHistory,[a.id]:[...e]},this.context.emit("newMSRPMessage",{message:n,session:a})}messageTerminate(n){const a=this.extendedMessages[n];a._status!==8&&a.terminate()}addMessageSession(n){if(!n._id||this.getActiveMessages[n._id]!==void 0)return;const e=n;this.addMMSRPSession(e)}triggerMSRPListener({listenerType:n,session:a,event:e}){const o=this.context.listenersList[n];!o||!o.length||o.forEach(p=>{p(a,e)})}removeMMSRPSession(n){const a={...this.activeMessages};delete a[n],this.activeMessages={...a};const e={...this.extendedMessages};delete e[n],this.extendedMessages={...e},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(n){this.removeMMSRPSession(n._id)}newMSRPSessionCallback(n){const a=n.session;a.on("ended",e=>{this.triggerMSRPListener({listenerType:Bs.CALL_ENDED,session:a,event:e});const o=this.getActiveMessages[a.id];this.activeMessageListRemove(o)}),a.on("failed",e=>{this.triggerMSRPListener({listenerType:Bs.CALL_FAILED,session:a,event:e});const o=this.getActiveMessages[a.id];this.activeMessageListRemove(o)}),a.on("confirmed",e=>{this.triggerMSRPListener({listenerType:Bs.CALL_CONFIRMED,session:a,event:e}),this.updateMSRPSession(a)}),a.on("newMessage",e=>{this.addMSRPMessage(e,a)}),this.addMessageSession(a)}setIsMSRPInitializing(n){this.isMSRPInitializingValue=n,this.context.emit("isMSRPInitializingChanged",n)}initMSRP(n,a,e){if(n.length===0)return console.error("Target must be a valid string");const o=this.context.startMSRP(n,e);o.on("active",()=>{this.addMessageSession(o),o.sendMSRP(a),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(n,a){const e=this.extendedMessages[n];if(!e)throw new Error(`MSRP session with id ${n} doesn't exist!`);e.sendMSRP(a)}}const fu={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class _E extends Vv{constructor(n,a){if(!n.modules.length)throw new Error("options.modules should include at least 1 module");const e={...n.configuration,sockets:n.socketInterfaces.map(o=>new fT.WebSocketInterface(o))};super(e),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=[],n.pnExtraHeaders&&Object.keys(n.pnExtraHeaders).length&&this.registrator().setExtraContactUriParams(n.pnExtraHeaders),this.options=n,this.modules=n.modules,a&&Xv(a)&&(this.logger=a)}on(n,a){return super.on(n,a)}off(n,a){return super.off(n,a)}emit(n,a){return super.emit(n,a)}get sipDomain(){return this.options.sipDomain}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(fu.AUDIO)&&(this.audio=new cE(this)),this.modules.includes(fu.MSRP)&&(this.msrp=new hE(this)),this.modules.includes(fu.VIDEO)&&(this.video=new fE(this)),this.on(this.registeredEventName,()=>{this.logger.log("Successfully registered to",this.options.socketInterfaces[0]),this.setInitialized(!0)}),this.on(this.unregisteredEventName,()=>{this.logger.log("Unregistered from",this.options.socketInterfaces[0]),this.setInitialized(!1)}),this.on(this.connectedEventName,()=>{this.logger.log("Connected to",this.options.socketInterfaces[0]),this.isReconnecting=!1}),this.on(this.disconnectedEventName,()=>{this.isReconnecting||(this.logger.log("Disconnected from",this.options.socketInterfaces[0]),this.logger.log("Reconnecting to",this.options.socketInterfaces[0]),this.isReconnecting=!0,this.stop(),this.setInitialized(!1),setTimeout(this.start.bind(this),5e3))}),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this}subscribe(n,a){const o=!this.listenersList[n]||!this.listenersList[n].length?[a]:[...this.listenersList[n],a];this.listenersList={...this.listenersList,[n]:o}}removeIListener(n){const a={...this.listenersList};delete a[n],this.listenersList={...a}}triggerListener({listenerType:n,session:a,event:e}){const o=this.listenersList[n];!o||!o.length||o.forEach(p=>{p(a,e)})}setInitialized(n){this.initialized=n,this.emit("ready",n)}}module.exports=_E;