voxnix 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- (function(Tt,Ot){typeof exports=="object"&&typeof module<"u"?Ot(exports):typeof define=="function"&&define.amd?define(["exports"],Ot):(Tt=typeof globalThis<"u"?globalThis:Tt||self,Ot(Tt.OmnixWidget={}))})(this,function(Tt){"use strict";class Ot{constructor(){this.listeners={}}on(n,s){return this.listeners[n]||(this.listeners[n]=[]),this.listeners[n].push(s),()=>this.off(n,s)}off(n,s){this.listeners[n]&&(this.listeners[n]=this.listeners[n].filter(o=>o!==s))}emitLocal(n,s){this.listeners[n]&&this.listeners[n].forEach(o=>{try{o(s)}catch(c){console.error(`Error in event listener for ${n}:`,c)}})}emitToParent(n,s){this.emitLocal(n,s)}}const ts=new Ot;function Ji(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}const zr={title:"JsSIP",version:"3.13.8"},Xr=zr;var oe={USER_AGENT:`${Xr.title} ${Xr.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,SUBSCRIBE",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};class Qi extends Error{constructor(n,s){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=n,this.value=s,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class Zi extends Error{constructor(n){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=n,this.message=`Invalid status: ${n}`}}class ea extends Error{constructor(n){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=n}}class ta extends Error{constructor(n){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=n}}var He={ConfigurationError:Qi,InvalidStateError:Zi,NotSupportedError:ea,NotReadyError:ta},fe={},$s,Jr;function Ps(){if(Jr)return $s;Jr=1;const f=Ze(),n=$e();return $s=class zi{static parse(o){if(o=n.parse(o,"Name_Addr_Header"),o!==-1)return o}constructor(o,c,t){if(!o||!(o instanceof f))throw new TypeError('missing or invalid "uri" parameter');this._uri=o,this._parameters={},this.display_name=c;for(const d in t)Object.prototype.hasOwnProperty.call(t,d)&&this.setParam(d,t[d])}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,c){o&&(this._parameters[o.toLowerCase()]=typeof c>"u"||c===null?null:c.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 c=this._parameters[o];return delete this._parameters[o],c}}clearParams(){this._parameters={}}clone(){return new zi(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 c in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,c)&&(o+=`;${c}`,this._parameters[c]!==null&&(o+=`=${this._parameters[c]}`));return o}},$s}var Ms,Qr;function $e(){return Qr||(Qr=1,Ms=function(){function f(s){return'"'+s.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(s,o){var c={CRLF:T,DIGIT:m,ALPHA:S,HEXDIG:O,WSP:H,OCTET:B,DQUOTE:k,SP:U,HTAB:de,alphanum:ne,reserved:tt,unreserved:y,mark:$,escaped:ae,LWS:_e,SWS:X,HCOLON:ft,TEXT_UTF8_TRIM:N,TEXT_UTF8char:I,UTF8_NONASCII:b,UTF8_CONT:w,LHEX:wt,token:q,token_nodot:ze,separators:yt,word:We,STAR:ht,SLASH:Xe,EQUAL:z,LPAREN:dt,RPAREN:_t,RAQUOT:st,LAQUOT:rt,COMMA:Q,SEMI:j,COLON:pt,LDQUOT:nt,RDQUOT:gs,comment:W,ctext:G,quoted_string:V,quoted_string_clean:K,qdtext:ue,quoted_pair:ce,SIP_URI_noparams:te,SIP_URI:Je,uri_scheme:Oe,uri_scheme_sips:al,uri_scheme_sip:ol,userinfo:Ts,user:ul,user_unreserved:vr,password:cl,hostport:Es,host:jt,hostname:Rr,domainlabel:Ir,toplabel:fl,IPv6reference:br,IPv6address:wr,h16:P,ls32:xe,IPv4address:Yt,dec_octet:Kt,port:hl,uri_parameters:dl,uri_parameter:yr,transport_param:_l,user_param:pl,method_param:ml,ttl_param:gl,maddr_param:Tl,lr_param:El,other_param:Sl,pname:Cl,pvalue:Al,paramchar:zt,param_unreserved:vl,headers:Rl,header:Ss,hname:Il,hvalue:bl,hnv_unreserved:Xt,Request_Response:Yu,Request_Line:wl,Request_URI:yl,absoluteURI:Nr,hier_part:Nl,net_path:Ol,abs_path:Cs,opaque_part:xl,uric:Jt,uric_no_slash:Dl,path_segments:Ul,segment:As,param:Or,pchar:Qt,scheme:$l,authority:Pl,srvr:Ml,reg_name:Ll,query:Hl,SIP_Version:xr,INVITEm:Fl,ACKm:kl,OPTIONSm:ql,BYEm:Gl,CANCELm:Bl,REGISTERm:Wl,SUBSCRIBEm:Vl,NOTIFYm:jl,REFERm:Yl,Method:vs,Status_Line:Kl,Status_Code:zl,extension_code:Xl,Reason_Phrase:Jl,Allow_Events:Ku,Call_ID:zu,Contact:Xu,contact_param:Rs,name_addr:mt,display_name:Is,contact_params:Dr,c_p_q:Ql,c_p_expires:Zl,delta_seconds:gt,qvalue:ei,generic_param:ge,gen_value:ti,Content_Disposition:Ju,disp_type:si,disp_param:Ur,handling_param:ri,Content_Encoding:Qu,Content_Length:Zu,Content_Type:ec,media_type:ni,m_type:li,discrete_type:ii,composite_type:ai,extension_token:bs,x_token:oi,m_subtype:ui,m_parameter:$r,m_value:ci,CSeq:tc,CSeq_value:fi,Expires:sc,Event:rc,event_type:Zt,From:nc,from_param:Pr,tag_param:Mr,Max_Forwards:lc,Min_Expires:ic,Name_Addr_Header:ac,Proxy_Authenticate:oc,challenge:Lr,other_challenge:hi,auth_param:es,digest_cln:ws,realm:di,realm_value:_i,domain:pi,URI:ys,nonce:mi,nonce_value:gi,opaque:Ti,stale:Ei,algorithm:Si,qop_options:Ci,qop_value:Ns,Proxy_Require:uc,Record_Route:cc,rec_route:Os,Reason:fc,reason_param:Hr,reason_cause:Ai,Require:hc,Route:dc,route_param:xs,Subscription_State:_c,substate_value:vi,subexp_params:Fr,event_reason_value:Ri,Subject:pc,Supported:mc,To:gc,to_param:kr,Via:Tc,via_param:Ds,via_params:qr,via_ttl:Ii,via_maddr:bi,via_received:wi,via_branch:yi,response_port:Ni,rport:Oi,sent_protocol:xi,protocol_name:Di,transport:Ui,sent_by:$i,via_host:Pi,via_port:Mi,ttl:Gr,WWW_Authenticate:Ec,Session_Expires:Sc,s_e_expires:Li,s_e_params:Br,s_e_refresher:Hi,extension_header:Cc,header_value:Fi,message_body:Ac,uuid_URI:vc,uuid:ki,hex4:Qe,hex8:qi,hex12:Gi,Refer_To:Rc,Replaces:Ic,call_id:Bi,replaces_param:Wr,to_tag:Wi,from_tag:Vi,early_flag:ji};if(o!==void 0){if(c[o]===void 0)throw new Error("Invalid rule name: "+f(o)+".")}else o="CRLF";var t=0,d=0,p=[];function a(e){t<d||(t>d&&(d=t,p=[]),p.push(e))}function T(){var e;return s.substr(t,2)===`\r
1
+ (function(Tt,Ot){typeof exports=="object"&&typeof module<"u"?Ot(exports):typeof define=="function"&&define.amd?define(["exports"],Ot):(Tt=typeof globalThis<"u"?globalThis:Tt||self,Ot(Tt.OmnixWidget={}))})(this,function(Tt){"use strict";class Ot{constructor(){this.listeners={}}on(n,s){return this.listeners[n]||(this.listeners[n]=[]),this.listeners[n].push(s),()=>this.off(n,s)}off(n,s){this.listeners[n]&&(this.listeners[n]=this.listeners[n].filter(o=>o!==s))}emitLocal(n,s){this.listeners[n]&&this.listeners[n].forEach(o=>{try{o(s)}catch(c){console.error(`Error in event listener for ${n}:`,c)}})}emitToParent(n,s){this.emitLocal(n,s)}}const ts=new Ot;function Zi(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}const Qr={title:"JsSIP",version:"3.13.8"},Zr=Qr;var oe={USER_AGENT:`${Zr.title} ${Zr.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,SUBSCRIBE",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};class ea extends Error{constructor(n,s){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=n,this.value=s,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class ta extends Error{constructor(n){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=n,this.message=`Invalid status: ${n}`}}class sa extends Error{constructor(n){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=n}}class ra extends Error{constructor(n){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=n}}var He={ConfigurationError:ea,InvalidStateError:ta,NotSupportedError:sa,NotReadyError:ra},fe={},$s,en;function Ps(){if(en)return $s;en=1;const f=Ze(),n=$e();return $s=class Ji{static parse(o){if(o=n.parse(o,"Name_Addr_Header"),o!==-1)return o}constructor(o,c,t){if(!o||!(o instanceof f))throw new TypeError('missing or invalid "uri" parameter');this._uri=o,this._parameters={},this.display_name=c;for(const d in t)Object.prototype.hasOwnProperty.call(t,d)&&this.setParam(d,t[d])}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,c){o&&(this._parameters[o.toLowerCase()]=typeof c>"u"||c===null?null:c.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 c=this._parameters[o];return delete this._parameters[o],c}}clearParams(){this._parameters={}}clone(){return new Ji(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 c in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,c)&&(o+=`;${c}`,this._parameters[c]!==null&&(o+=`=${this._parameters[c]}`));return o}},$s}var Ms,tn;function $e(){return tn||(tn=1,Ms=function(){function f(s){return'"'+s.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(s,o){var c={CRLF:g,DIGIT:m,ALPHA:S,HEXDIG:O,WSP:H,OCTET:B,DQUOTE:k,SP:U,HTAB:de,alphanum:ne,reserved:tt,unreserved:w,mark:$,escaped:ae,LWS:_e,SWS:X,HCOLON:ft,TEXT_UTF8_TRIM:N,TEXT_UTF8char:I,UTF8_NONASCII:b,UTF8_CONT:y,LHEX:yt,token:q,token_nodot:ze,separators:wt,word:We,STAR:ht,SLASH:Xe,EQUAL:z,LPAREN:dt,RPAREN:_t,RAQUOT:st,LAQUOT:rt,COMMA:Z,SEMI:j,COLON:pt,LDQUOT:nt,RDQUOT:gs,comment:W,ctext:G,quoted_string:V,quoted_string_clean:K,qdtext:ue,quoted_pair:ce,SIP_URI_noparams:te,SIP_URI:Je,uri_scheme:Oe,uri_scheme_sips:ul,uri_scheme_sip:cl,userinfo:Ts,user:fl,user_unreserved:br,password:hl,hostport:Es,host:jt,hostname:yr,domainlabel:wr,toplabel:dl,IPv6reference:Nr,IPv6address:Or,h16:P,ls32:xe,IPv4address:Yt,dec_octet:Kt,port:_l,uri_parameters:pl,uri_parameter:xr,transport_param:ml,user_param:gl,method_param:Tl,ttl_param:El,maddr_param:Sl,lr_param:Cl,other_param:Al,pname:vl,pvalue:Rl,paramchar:zt,param_unreserved:Il,headers:bl,header:Ss,hname:yl,hvalue:wl,hnv_unreserved:Xt,Request_Response:Ju,Request_Line:Nl,Request_URI:Ol,absoluteURI:Dr,hier_part:xl,net_path:Dl,abs_path:Cs,opaque_part:Ul,uric:Jt,uric_no_slash:$l,path_segments:Pl,segment:As,param:Ur,pchar:Qt,scheme:Ml,authority:Ll,srvr:Hl,reg_name:Fl,query:kl,SIP_Version:$r,INVITEm:ql,ACKm:Gl,OPTIONSm:Bl,BYEm:Wl,CANCELm:Vl,REGISTERm:jl,SUBSCRIBEm:Yl,NOTIFYm:Kl,REFERm:zl,Method:vs,Status_Line:Xl,Status_Code:Jl,extension_code:Ql,Reason_Phrase:Zl,Allow_Events:Qu,Call_ID:Zu,Contact:ec,contact_param:Rs,name_addr:mt,display_name:Is,contact_params:Pr,c_p_q:ei,c_p_expires:ti,delta_seconds:gt,qvalue:si,generic_param:Te,gen_value:ri,Content_Disposition:tc,disp_type:ni,disp_param:Mr,handling_param:li,Content_Encoding:sc,Content_Length:rc,Content_Type:nc,media_type:ii,m_type:ai,discrete_type:oi,composite_type:ui,extension_token:bs,x_token:ci,m_subtype:fi,m_parameter:Lr,m_value:hi,CSeq:lc,CSeq_value:di,Expires:ic,Event:ac,event_type:Zt,From:oc,from_param:Hr,tag_param:Fr,Max_Forwards:uc,Min_Expires:cc,Name_Addr_Header:fc,Proxy_Authenticate:hc,challenge:kr,other_challenge:_i,auth_param:es,digest_cln:ys,realm:pi,realm_value:mi,domain:gi,URI:ws,nonce:Ti,nonce_value:Ei,opaque:Si,stale:Ci,algorithm:Ai,qop_options:vi,qop_value:Ns,Proxy_Require:dc,Record_Route:_c,rec_route:Os,Reason:pc,reason_param:qr,reason_cause:Ri,Require:mc,Route:gc,route_param:xs,Subscription_State:Tc,substate_value:Ii,subexp_params:Gr,event_reason_value:bi,Subject:Ec,Supported:Sc,To:Cc,to_param:Br,Via:Ac,via_param:Ds,via_params:Wr,via_ttl:yi,via_maddr:wi,via_received:Ni,via_branch:Oi,response_port:xi,rport:Di,sent_protocol:Ui,protocol_name:$i,transport:Pi,sent_by:Mi,via_host:Li,via_port:Hi,ttl:Vr,WWW_Authenticate:vc,Session_Expires:Rc,s_e_expires:Fi,s_e_params:jr,s_e_refresher:ki,extension_header:Ic,header_value:qi,message_body:bc,uuid_URI:yc,uuid:Gi,hex4:Qe,hex8:Bi,hex12:Wi,Refer_To:wc,Replaces:Nc,call_id:Vi,replaces_param:Yr,to_tag:ji,from_tag:Yi,early_flag:Ki};if(o!==void 0){if(c[o]===void 0)throw new Error("Invalid rule name: "+f(o)+".")}else o="CRLF";var t=0,d=0,p=[];function a(e){t<d||(t>d&&(d=t,p=[]),p.push(e))}function g(){var e;return s.substr(t,2)===`\r
2
2
  `?(e=`\r
3
- `,t+=2):(e=null,a('"\\r\\n"')),e}function m(){var e;return/^[0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[0-9]")),e}function S(){var e;return/^[a-zA-Z]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-zA-Z]")),e}function O(){var e;return/^[0-9a-fA-F]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[0-9a-fA-F]")),e}function H(){var e;return e=U(),e===null&&(e=de()),e}function B(){var e;return/^[\0-\xFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\0-\\xFF]")),e}function k(){var e;return/^["]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a('["]')),e}function U(){var e;return s.charCodeAt(t)===32?(e=" ",t++):(e=null,a('" "')),e}function de(){var e;return s.charCodeAt(t)===9?(e=" ",t++):(e=null,a('"\\t"')),e}function ne(){var e;return/^[a-zA-Z0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-zA-Z0-9]")),e}function tt(){var e;return s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","'))))))))))),e}function y(){var e;return e=ne(),e===null&&(e=$()),e}function $(){var e;return s.charCodeAt(t)===45?(e="-",t++):(e=null,a('"-"')),e===null&&(s.charCodeAt(t)===95?(e="_",t++):(e=null,a('"_"')),e===null&&(s.charCodeAt(t)===46?(e=".",t++):(e=null,a('"."')),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,a('"!"')),e===null&&(s.charCodeAt(t)===126?(e="~",t++):(e=null,a('"~"')),e===null&&(s.charCodeAt(t)===42?(e="*",t++):(e=null,a('"*"')),e===null&&(s.charCodeAt(t)===39?(e="'",t++):(e=null,a(`"'"`)),e===null&&(s.charCodeAt(t)===40?(e="(",t++):(e=null,a('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,a('")"')))))))))),e}function ae(){var e,r,l,i,u;return i=t,u=t,s.charCodeAt(t)===37?(e="%",t++):(e=null,a('"%"')),e!==null?(r=O(),r!==null?(l=O(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){return _.join("")}(i,e)),e===null&&(t=i),e}function _e(){var e,r,l,i,u,h;for(i=t,u=t,h=t,e=[],r=H();r!==null;)e.push(r),r=H();if(e!==null?(r=T(),r!==null?e=[e,r]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null){if(l=H(),l!==null)for(r=[];l!==null;)r.push(l),l=H();else r=null;r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=function(_){return" "}()),e===null&&(t=i),e}function X(){var e;return e=_e(),e=e!==null?e:"",e}function ft(){var e,r,l,i,u;for(i=t,u=t,e=[],r=U(),r===null&&(r=de());r!==null;)e.push(r),r=U(),r===null&&(r=de());return e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function N(){var e,r,l,i,u,h,_;if(u=t,h=t,r=I(),r!==null)for(e=[];r!==null;)e.push(r),r=I();else e=null;if(e!==null){for(r=[],_=t,l=[],i=_e();i!==null;)l.push(i),i=_e();for(l!==null?(i=I(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;){for(r.push(l),_=t,l=[],i=_e();i!==null;)l.push(i),i=_e();l!==null?(i=I(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_)}r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){return s.substring(t,E)}(u)),e===null&&(t=u),e}function I(){var e;return/^[!-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[!-~]")),e===null&&(e=b()),e}function b(){var e;return/^[\x80-\uFFFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\x80-\\uFFFF]")),e}function w(){var e;return/^[\x80-\xBF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\x80-\\xBF]")),e}function wt(){var e;return e=m(),e===null&&(/^[a-f]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-f]"))),e}function q(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"'))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function ze(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"'))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function yt(){var e;return s.charCodeAt(t)===40?(e="(",t++):(e=null,a('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,a('")"')),e===null&&(s.charCodeAt(t)===60?(e="<",t++):(e=null,a('"<"')),e===null&&(s.charCodeAt(t)===62?(e=">",t++):(e=null,a('">"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===92?(e="\\",t++):(e=null,a('"\\\\"')),e===null&&(e=k(),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===123?(e="{",t++):(e=null,a('"{"')),e===null&&(s.charCodeAt(t)===125?(e="}",t++):(e=null,a('"}"')),e===null&&(e=U(),e===null&&(e=de())))))))))))))))))),e}function We(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,a('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,a('"\\\\"')),r===null&&(r=k(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,a('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,a('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,a('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,a('"}"'))))))))))))))))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,a('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,a('"\\\\"')),r===null&&(r=k(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,a('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,a('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,a('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,a('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function ht(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"*"}()),e===null&&(t=i),e}function Xe(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"/"}()),e===null&&(t=i),e}function z(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"="}()),e===null&&(t=i),e}function dt(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"("}()),e===null&&(t=i),e}function _t(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return")"}()),e===null&&(t=i),e}function st(){var e,r,l,i;return l=t,i=t,s.charCodeAt(t)===62?(e=">",t++):(e=null,a('">"')),e!==null?(r=X(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return">"}()),e===null&&(t=l),e}function rt(){var e,r,l,i;return l=t,i=t,e=X(),e!==null?(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return"<"}()),e===null&&(t=l),e}function Q(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return","}()),e===null&&(t=i),e}function j(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return";"}()),e===null&&(t=i),e}function pt(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function nt(){var e,r,l,i;return l=t,i=t,e=X(),e!==null?(r=k(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return'"'}()),e===null&&(t=l),e}function gs(){var e,r,l,i;return l=t,i=t,e=k(),e!==null?(r=X(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return'"'}()),e===null&&(t=l),e}function W(){var e,r,l,i;if(i=t,e=dt(),e!==null){for(r=[],l=G(),l===null&&(l=ce(),l===null&&(l=W()));l!==null;)r.push(l),l=G(),l===null&&(l=ce(),l===null&&(l=W()));r!==null?(l=_t(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)}else e=null,t=i;return e}function G(){var e;return/^[!-']/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[!-']")),e===null&&(/^[*-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[*-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\]-~]")),e===null&&(e=b(),e===null&&(e=_e())))),e}function V(){var e,r,l,i,u,h;if(u=t,h=t,e=X(),e!==null)if(r=k(),r!==null){for(l=[],i=ue(),i===null&&(i=ce());i!==null;)l.push(i),i=ue(),i===null&&(i=ce());l!==null?(i=k(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_){return s.substring(t,_)}(u)),e===null&&(t=u),e}function K(){var e,r,l,i,u,h;if(u=t,h=t,e=X(),e!==null)if(r=k(),r!==null){for(l=[],i=ue(),i===null&&(i=ce());i!==null;)l.push(i),i=ue(),i===null&&(i=ce());l!==null?(i=k(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_){var E=s.substring(t,_).trim();return E.substring(1,E.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(u)),e===null&&(t=u),e}function ue(){var e;return e=_e(),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,a('"!"')),e===null&&(/^[#-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[#-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\]-~]")),e===null&&(e=b())))),e}function ce(){var e,r,l;return l=t,s.charCodeAt(t)===92?(e="\\",t++):(e=null,a('"\\\\"')),e!==null?(/^[\0-\t]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\0-\\t]")),r===null&&(/^[\x0B-\f]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\x0B-\\f]")),r===null&&(/^[\x0E-]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\x0E-]")))),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function te(){var e,r,l,i,u,h;return u=t,h=t,e=Oe(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Ts(),l=l!==null?l:"",l!==null?(i=Es(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e!==null&&(e=function(_){try{g.uri=new Yi(g.scheme,g.user,g.host,g.port),delete g.scheme,delete g.user,delete g.host,delete g.host_type,delete g.port}catch{g=-1}}()),e===null&&(t=u),e}function Je(){var e,r,l,i,u,h,_,E;return _=t,E=t,e=Oe(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Ts(),l=l!==null?l:"",l!==null?(i=Es(),i!==null?(u=dl(),u!==null?(h=Rl(),h=h!==null?h:"",h!==null?e=[e,r,l,i,u,h]:(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E),e!==null&&(e=function(v){try{g.uri=new Yi(g.scheme,g.user,g.host,g.port,g.uri_params,g.uri_headers),delete g.scheme,delete g.user,delete g.host,delete g.host_type,delete g.port,delete g.uri_params,o==="SIP_URI"&&(g=g.uri)}catch{g=-1}}()),e===null&&(t=_),e}function Oe(){var e;return e=al(),e===null&&(e=ol()),e}function al(){var e,r;return r=t,s.substr(t,4).toLowerCase()==="sips"?(e=s.substr(t,4),t+=4):(e=null,a('"sips"')),e!==null&&(e=function(l,i){g.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function ol(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"sip"')),e!==null&&(e=function(l,i){g.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function Ts(){var e,r,l,i,u,h;return i=t,u=t,e=ul(),e!==null?(h=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=cl(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?(s.charCodeAt(t)===64?(l="@",t++):(l=null,a('"@"')),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g.user=decodeURIComponent(s.substring(t-1,_))}(i)),e===null&&(t=i),e}function ul(){var e,r;if(r=y(),r===null&&(r=ae(),r===null&&(r=vr())),r!==null)for(e=[];r!==null;)e.push(r),r=y(),r===null&&(r=ae(),r===null&&(r=vr()));else e=null;return e}function vr(){var e;return s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"'))))))))),e}function cl(){var e,r,l;for(l=t,e=[],r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","'))))))));r!==null;)e.push(r),r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","'))))))));return e!==null&&(e=function(i){g.password=s.substring(t,i)}(l)),e===null&&(t=l),e}function Es(){var e,r,l,i,u;return i=t,e=jt(),e!==null?(u=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=hl(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function jt(){var e,r;return r=t,e=Rr(),e===null&&(e=Yt(),e===null&&(e=br())),e!==null&&(e=function(l){return g.host=s.substring(t,l).toLowerCase(),g.host}(r)),e===null&&(t=r),e}function Rr(){var e,r,l,i,u,h;for(i=t,u=t,e=[],h=t,r=Ir(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);r!==null;)e.push(r),h=t,r=Ir(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);return e!==null?(r=fl(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){return g.host_type="domain",s.substring(t,_)}(i)),e===null&&(t=i),e}function Ir(){var e,r,l,i;if(i=t,e=ne(),e!==null){for(r=[],l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));l!==null;)r.push(l),l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function fl(){var e,r,l,i;if(i=t,e=S(),e!==null){for(r=[],l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));l!==null;)r.push(l),l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function br(){var e,r,l,i,u;return i=t,u=t,s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e!==null?(r=wr(),r!==null?(s.charCodeAt(t)===93?(l="]",t++):(l=null,a('"]"')),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return g.host_type="IPv6",s.substring(t,h)}(i)),e===null&&(t=i),e}function wr(){var e,r,l,i,u,h,_,E,v,F,le,Ve,Us,jr,C,M;return jr=t,C=t,e=P(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?(s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=P(),v!==null?(s.charCodeAt(t)===58?(F=":",t++):(F=null,a('":"')),F!==null?(le=P(),le!==null?(s.charCodeAt(t)===58?(Ve=":",t++):(Ve=null,a('":"')),Ve!==null?(Us=xe(),Us!==null?e=[e,r,l,i,u,h,_,E,v,F,le,Ve,Us]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=P(),F!==null?(s.charCodeAt(t)===58?(le=":",t++):(le=null,a('":"')),le!==null?(Ve=xe(),Ve!==null?e=[e,r,l,i,u,h,_,E,v,F,le,Ve]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=xe(),F!==null?e=[e,r,l,i,u,h,_,E,v,F]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=xe(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=xe(),h!==null?e=[e,r,l,i,u,h]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=xe(),i!==null?e=[e,r,l,i]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=xe(),r!==null?e=[e,r]:(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?e=[e,r]:(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(s.substr(t,2)==="::"?(r="::",t+=2):(r=null,a('"::"')),r!==null?(l=P(),l!==null?(s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=P(),v!==null?(s.charCodeAt(t)===58?(F=":",t++):(F=null,a('":"')),F!==null?(le=xe(),le!==null?e=[e,r,l,i,u,h,_,E,v,F,le]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(s.substr(t,2)==="::"?(l="::",t+=2):(l=null,a('"::"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=xe(),F!==null?e=[e,r,l,i,u,h,_,E,v,F]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(s.substr(t,2)==="::"?(i="::",t+=2):(i=null,a('"::"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=xe(),v!==null?e=[e,r,l,i,u,h,_,E,v]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(s.substr(t,2)==="::"?(u="::",t+=2):(u=null,a('"::"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=xe(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(s.substr(t,2)==="::"?(h="::",t+=2):(h=null,a('"::"')),h!==null?(_=xe(),_!==null?e=[e,r,l,i,u,h,_]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(M=t,s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?h=[h,_]:(h=null,t=M)):(h=null,t=M),h=h!==null?h:"",h!==null?(s.substr(t,2)==="::"?(_="::",t+=2):(_=null,a('"::"')),_!==null?(E=P(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(M=t,s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?h=[h,_]:(h=null,t=M)):(h=null,t=M),h=h!==null?h:"",h!==null?(M=t,s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?_=[_,E]:(_=null,t=M)):(_=null,t=M),_=_!==null?_:"",_!==null?(s.substr(t,2)==="::"?(E="::",t+=2):(E=null,a('"::"')),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C))))))))))))))),e!==null&&(e=function(Oc){return g.host_type="IPv6",s.substring(t,Oc)}(jr)),e===null&&(t=jr),e}function P(){var e,r,l,i,u;return u=t,e=O(),e!==null?(r=O(),r=r!==null?r:"",r!==null?(l=O(),l=l!==null?l:"",l!==null?(i=O(),i=i!==null?i:"",i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function xe(){var e,r,l,i;return i=t,e=P(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(e=Yt()),e}function Yt(){var e,r,l,i,u,h,_,E,v;return E=t,v=t,e=Kt(),e!==null?(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r!==null?(l=Kt(),l!==null?(s.charCodeAt(t)===46?(i=".",t++):(i=null,a('"."')),i!==null?(u=Kt(),u!==null?(s.charCodeAt(t)===46?(h=".",t++):(h=null,a('"."')),h!==null?(_=Kt(),_!==null?e=[e,r,l,i,u,h,_]:(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v),e!==null&&(e=function(F){return g.host_type="IPv4",s.substring(t,F)}(E)),e===null&&(t=E),e}function Kt(){var e,r,l,i;return i=t,s.substr(t,2)==="25"?(e="25",t+=2):(e=null,a('"25"')),e!==null?(/^[0-5]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[0-5]")),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e===null&&(i=t,s.charCodeAt(t)===50?(e="2",t++):(e=null,a('"2"')),e!==null?(/^[0-4]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[0-4]")),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(i=t,s.charCodeAt(t)===49?(e="1",t++):(e=null,a('"1"')),e!==null?(r=m(),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(i=t,/^[1-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[1-9]")),e!==null?(r=m(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e===null&&(e=m())))),e}function hl(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){return v=parseInt(v.join("")),g.port=v,v}(h,e)),e===null&&(t=h),e}function dl(){var e,r,l,i;for(e=[],i=t,s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=yr(),l!==null?r=[r,l]:(r=null,t=i)):(r=null,t=i);r!==null;)e.push(r),i=t,s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=yr(),l!==null?r=[r,l]:(r=null,t=i)):(r=null,t=i);return e}function yr(){var e;return e=_l(),e===null&&(e=pl(),e===null&&(e=ml(),e===null&&(e=gl(),e===null&&(e=Tl(),e===null&&(e=El(),e===null&&(e=Sl())))))),e}function _l(){var e,r,l,i;return l=t,i=t,s.substr(t,10).toLowerCase()==="transport="?(e=s.substr(t,10),t+=10):(e=null,a('"transport="')),e!==null?(s.substr(t,3).toLowerCase()==="udp"?(r=s.substr(t,3),t+=3):(r=null,a('"udp"')),r===null&&(s.substr(t,3).toLowerCase()==="tcp"?(r=s.substr(t,3),t+=3):(r=null,a('"tcp"')),r===null&&(s.substr(t,4).toLowerCase()==="sctp"?(r=s.substr(t,4),t+=4):(r=null,a('"sctp"')),r===null&&(s.substr(t,3).toLowerCase()==="tls"?(r=s.substr(t,3),t+=3):(r=null,a('"tls"')),r===null&&(r=q())))),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.transport=h.toLowerCase()}(l,e[1])),e===null&&(t=l),e}function pl(){var e,r,l,i;return l=t,i=t,s.substr(t,5).toLowerCase()==="user="?(e=s.substr(t,5),t+=5):(e=null,a('"user="')),e!==null?(s.substr(t,5).toLowerCase()==="phone"?(r=s.substr(t,5),t+=5):(r=null,a('"phone"')),r===null&&(s.substr(t,2).toLowerCase()==="ip"?(r=s.substr(t,2),t+=2):(r=null,a('"ip"')),r===null&&(r=q())),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.user=h.toLowerCase()}(l,e[1])),e===null&&(t=l),e}function ml(){var e,r,l,i;return l=t,i=t,s.substr(t,7).toLowerCase()==="method="?(e=s.substr(t,7),t+=7):(e=null,a('"method="')),e!==null?(r=vs(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.method=h}(l,e[1])),e===null&&(t=l),e}function gl(){var e,r,l,i;return l=t,i=t,s.substr(t,4).toLowerCase()==="ttl="?(e=s.substr(t,4),t+=4):(e=null,a('"ttl="')),e!==null?(r=Gr(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.params||(g.params={}),g.params.ttl=h}(l,e[1])),e===null&&(t=l),e}function Tl(){var e,r,l,i;return l=t,i=t,s.substr(t,6).toLowerCase()==="maddr="?(e=s.substr(t,6),t+=6):(e=null,a('"maddr="')),e!==null?(r=jt(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){g.uri_params||(g.uri_params={}),g.uri_params.maddr=h}(l,e[1])),e===null&&(t=l),e}function El(){var e,r,l,i,u,h;return i=t,u=t,s.substr(t,2).toLowerCase()==="lr"?(e=s.substr(t,2),t+=2):(e=null,a('"lr"')),e!==null?(h=t,s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=q(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g.uri_params||(g.uri_params={}),g.uri_params.lr=void 0}()),e===null&&(t=i),e}function Sl(){var e,r,l,i,u,h;return i=t,u=t,e=Cl(),e!==null?(h=t,s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=Al(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_,E,v){g.uri_params||(g.uri_params={}),typeof v>"u"?v=void 0:v=v[1],g.uri_params[E.toLowerCase()]=v}(i,e[0],e[1])),e===null&&(t=i),e}function Cl(){var e,r,l;if(l=t,r=zt(),r!==null)for(e=[];r!==null;)e.push(r),r=zt();else e=null;return e!==null&&(e=function(i,u){return u.join("")}(l,e)),e===null&&(t=l),e}function Al(){var e,r,l;if(l=t,r=zt(),r!==null)for(e=[];r!==null;)e.push(r),r=zt();else e=null;return e!==null&&(e=function(i,u){return u.join("")}(l,e)),e===null&&(t=l),e}function zt(){var e;return e=vl(),e===null&&(e=y(),e===null&&(e=ae())),e}function vl(){var e;return s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')))))))),e}function Rl(){var e,r,l,i,u,h,_;if(h=t,s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e!==null)if(r=Ss(),r!==null){for(l=[],_=t,s.charCodeAt(t)===38?(i="&",t++):(i=null,a('"&"')),i!==null?(u=Ss(),u!==null?i=[i,u]:(i=null,t=_)):(i=null,t=_);i!==null;)l.push(i),_=t,s.charCodeAt(t)===38?(i="&",t++):(i=null,a('"&"')),i!==null?(u=Ss(),u!==null?i=[i,u]:(i=null,t=_)):(i=null,t=_);l!==null?e=[e,r,l]:(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e}function Ss(){var e,r,l,i,u;return i=t,u=t,e=Il(),e!==null?(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=bl(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_,E){_=_.join("").toLowerCase(),E=E.join(""),g.uri_headers||(g.uri_headers={}),g.uri_headers[_]?g.uri_headers[_].push(E):g.uri_headers[_]=[E]}(i,e[0],e[2])),e===null&&(t=i),e}function Il(){var e,r;if(r=Xt(),r===null&&(r=y(),r===null&&(r=ae())),r!==null)for(e=[];r!==null;)e.push(r),r=Xt(),r===null&&(r=y(),r===null&&(r=ae()));else e=null;return e}function bl(){var e,r;for(e=[],r=Xt(),r===null&&(r=y(),r===null&&(r=ae()));r!==null;)e.push(r),r=Xt(),r===null&&(r=y(),r===null&&(r=ae()));return e}function Xt(){var e;return s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')))))))),e}function Yu(){var e;return e=Kl(),e===null&&(e=wl()),e}function wl(){var e,r,l,i,u,h;return h=t,e=vs(),e!==null?(r=U(),r!==null?(l=yl(),l!==null?(i=U(),i!==null?(u=xr(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function yl(){var e;return e=Je(),e===null&&(e=Nr()),e}function Nr(){var e,r,l,i;return i=t,e=$l(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Nl(),l===null&&(l=xl()),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Nl(){var e,r,l,i,u;return i=t,e=Ol(),e===null&&(e=Cs()),e!==null?(u=t,s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r!==null?(l=Hl(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Ol(){var e,r,l,i;return i=t,s.substr(t,2)==="//"?(e="//",t+=2):(e=null,a('"//"')),e!==null?(r=Pl(),r!==null?(l=Cs(),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Cs(){var e,r,l;return l=t,s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e!==null?(r=Ul(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function xl(){var e,r,l,i;if(i=t,e=Dl(),e!==null){for(r=[],l=Jt();l!==null;)r.push(l),l=Jt();r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function Jt(){var e;return e=tt(),e===null&&(e=y(),e===null&&(e=ae())),e}function Dl(){var e;return e=y(),e===null&&(e=ae(),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')))))))))))),e}function Ul(){var e,r,l,i,u,h;if(u=t,e=As(),e!==null){for(r=[],h=t,s.charCodeAt(t)===47?(l="/",t++):(l=null,a('"/"')),l!==null?(i=As(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===47?(l="/",t++):(l=null,a('"/"')),l!==null?(i=As(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function As(){var e,r,l,i,u,h;for(u=t,e=[],r=Qt();r!==null;)e.push(r),r=Qt();if(e!==null){for(r=[],h=t,s.charCodeAt(t)===59?(l=";",t++):(l=null,a('";"')),l!==null?(i=Or(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===59?(l=";",t++):(l=null,a('";"')),l!==null?(i=Or(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Or(){var e,r;for(e=[],r=Qt();r!==null;)e.push(r),r=Qt();return e}function Qt(){var e;return e=y(),e===null&&(e=ae(),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')))))))))),e}function $l(){var e,r,l,i,u;if(i=t,u=t,e=S(),e!==null){for(r=[],l=S(),l===null&&(l=m(),l===null&&(s.charCodeAt(t)===43?(l="+",t++):(l=null,a('"+"')),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."'))))));l!==null;)r.push(l),l=S(),l===null&&(l=m(),l===null&&(s.charCodeAt(t)===43?(l="+",t++):(l=null,a('"+"')),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."'))))));r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=function(h){g.scheme=s.substring(t,h)}(i)),e===null&&(t=i),e}function Pl(){var e;return e=Ml(),e===null&&(e=Ll()),e}function Ml(){var e,r,l,i;return l=t,i=t,e=Ts(),e!==null?(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e=e!==null?e:"",e!==null?(r=Es(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e=e!==null?e:"",e}function Ll(){var e,r;if(r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r===null&&(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"'))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=y(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r===null&&(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')))))))))));else e=null;return e}function Hl(){var e,r;for(e=[],r=Jt();r!==null;)e.push(r),r=Jt();return e}function xr(){var e,r,l,i,u,h,_,E;if(_=t,E=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e!==null)if(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r!==null){if(i=m(),i!==null)for(l=[];i!==null;)l.push(i),i=m();else l=null;if(l!==null)if(s.charCodeAt(t)===46?(i=".",t++):(i=null,a('"."')),i!==null){if(h=m(),h!==null)for(u=[];h!==null;)u.push(h),h=m();else u=null;u!==null?e=[e,r,l,i,u]:(e=null,t=E)}else e=null,t=E;else e=null,t=E}else e=null,t=E;else e=null,t=E;return e!==null&&(e=function(v){g.sip_version=s.substring(t,v)}(_)),e===null&&(t=_),e}function Fl(){var e;return s.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,a('"INVITE"')),e}function kl(){var e;return s.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,a('"ACK"')),e}function ql(){var e;return s.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,a('"OPTIONS"')),e}function Gl(){var e;return s.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,a('"BYE"')),e}function Bl(){var e;return s.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,a('"CANCEL"')),e}function Wl(){var e;return s.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,a('"REGISTER"')),e}function Vl(){var e;return s.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,a('"SUBSCRIBE"')),e}function jl(){var e;return s.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,a('"NOTIFY"')),e}function Yl(){var e;return s.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,a('"REFER"')),e}function vs(){var e,r;return r=t,e=Fl(),e===null&&(e=kl(),e===null&&(e=ql(),e===null&&(e=Gl(),e===null&&(e=Bl(),e===null&&(e=Wl(),e===null&&(e=Vl(),e===null&&(e=jl(),e===null&&(e=Yl(),e===null&&(e=q()))))))))),e!==null&&(e=function(l){return g.method=s.substring(t,l),g.method}(r)),e===null&&(t=r),e}function Kl(){var e,r,l,i,u,h;return h=t,e=xr(),e!==null?(r=U(),r!==null?(l=zl(),l!==null?(i=U(),i!==null?(u=Jl(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function zl(){var e,r;return r=t,e=Xl(),e!==null&&(e=function(l,i){g.status_code=parseInt(i.join(""))}(r,e)),e===null&&(t=r),e}function Xl(){var e,r,l,i;return i=t,e=m(),e!==null?(r=m(),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Jl(){var e,r,l;for(l=t,e=[],r=tt(),r===null&&(r=y(),r===null&&(r=ae(),r===null&&(r=b(),r===null&&(r=w(),r===null&&(r=U(),r===null&&(r=de()))))));r!==null;)e.push(r),r=tt(),r===null&&(r=y(),r===null&&(r=ae(),r===null&&(r=b(),r===null&&(r=w(),r===null&&(r=U(),r===null&&(r=de()))))));return e!==null&&(e=function(i){g.reason_phrase=s.substring(t,i)}(l)),e===null&&(t=l),e}function Ku(){var e,r,l,i,u,h;if(u=t,e=Zt(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=Zt(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=Zt(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function zu(){var e,r,l,i,u,h;return i=t,u=t,e=We(),e!==null?(h=t,s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?(l=We(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g=s.substring(t,_)}(i)),e===null&&(t=i),e}function Xu(){var e,r,l,i,u,h,_;if(u=t,e=ht(),e===null)if(h=t,e=Rs(),e!==null){for(r=[],_=t,l=Q(),l!==null?(i=Rs(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=Q(),l!==null?(i=Rs(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v,F;for(F=g.multi_header.length,v=0;v<F;v++)if(g.multi_header[v].parsed===null){g=null;break}g!==null?g=g.multi_header:g=-1}()),e===null&&(t=u),e}function Rs(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Dr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Dr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v;g.multi_header||(g.multi_header=[]);try{v=new Nt(g.uri,g.display_name,g.params),delete g.uri,delete g.display_name,delete g.params}catch{v=null}g.multi_header.push({possition:t,offset:E,parsed:v})}(u)),e===null&&(t=u),e}function mt(){var e,r,l,i,u;return u=t,e=Is(),e=e!==null?e:"",e!==null?(r=rt(),r!==null?(l=Je(),l!==null?(i=st(),i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Is(){var e,r,l,i,u,h,_;if(u=t,h=t,e=q(),e!==null){for(r=[],_=t,l=_e(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=_e(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e===null&&(e=K()),e!==null&&(e=function(E,v){typeof v=="string"?g.display_name=v:g.display_name=v[1].reduce(function(F,le){return F+le[0]+le[1]},v[0])}(u,e)),e===null&&(t=u),e}function Dr(){var e;return e=Ql(),e===null&&(e=Zl(),e===null&&(e=ge())),e}function Ql(){var e,r,l,i,u;return i=t,u=t,s.substr(t,1).toLowerCase()==="q"?(e=s.substr(t,1),t++):(e=null,a('"q"')),e!==null?(r=z(),r!==null?(l=ei(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.params||(g.params={}),g.params.q=_}(i,e[2])),e===null&&(t=i),e}function Zl(){var e,r,l,i,u;return i=t,u=t,s.substr(t,7).toLowerCase()==="expires"?(e=s.substr(t,7),t+=7):(e=null,a('"expires"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.params||(g.params={}),g.params.expires=_}(i,e[2])),e===null&&(t=i),e}function gt(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){return parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function ei(){var e,r,l,i,u,h,_,E;return h=t,_=t,s.charCodeAt(t)===48?(e="0",t++):(e=null,a('"0"')),e!==null?(E=t,s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?r=[r,l,i,u]:(r=null,t=E)):(r=null,t=E)):(r=null,t=E)):(r=null,t=E),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(v){return parseFloat(s.substring(t,v))}(h)),e===null&&(t=h),e}function ge(){var e,r,l,i,u,h;return i=t,u=t,e=q(),e!==null?(h=t,r=z(),r!==null?(l=ti(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_,E,v){g.params||(g.params={}),typeof v>"u"?v=void 0:v=v[1],g.params[E.toLowerCase()]=v}(i,e[0],e[1])),e===null&&(t=i),e}function ti(){var e;return e=q(),e===null&&(e=jt(),e===null&&(e=V())),e}function Ju(){var e,r,l,i,u,h;if(u=t,e=si(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Ur(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Ur(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function si(){var e;return s.substr(t,6).toLowerCase()==="render"?(e=s.substr(t,6),t+=6):(e=null,a('"render"')),e===null&&(s.substr(t,7).toLowerCase()==="session"?(e=s.substr(t,7),t+=7):(e=null,a('"session"')),e===null&&(s.substr(t,4).toLowerCase()==="icon"?(e=s.substr(t,4),t+=4):(e=null,a('"icon"')),e===null&&(s.substr(t,5).toLowerCase()==="alert"?(e=s.substr(t,5),t+=5):(e=null,a('"alert"')),e===null&&(e=q())))),e}function Ur(){var e;return e=ri(),e===null&&(e=ge()),e}function ri(){var e,r,l,i;return i=t,s.substr(t,8).toLowerCase()==="handling"?(e=s.substr(t,8),t+=8):(e=null,a('"handling"')),e!==null?(r=z(),r!==null?(s.substr(t,8).toLowerCase()==="optional"?(l=s.substr(t,8),t+=8):(l=null,a('"optional"')),l===null&&(s.substr(t,8).toLowerCase()==="required"?(l=s.substr(t,8),t+=8):(l=null,a('"required"')),l===null&&(l=q())),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Qu(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Zu(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){g=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function ec(){var e,r;return r=t,e=ni(),e!==null&&(e=function(l){g=s.substring(t,l)}(r)),e===null&&(t=r),e}function ni(){var e,r,l,i,u,h,_,E;if(_=t,e=li(),e!==null)if(r=Xe(),r!==null)if(l=ui(),l!==null){for(i=[],E=t,u=j(),u!==null?(h=$r(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=j(),u!==null?(h=$r(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function li(){var e;return e=ii(),e===null&&(e=ai()),e}function ii(){var e;return s.substr(t,4).toLowerCase()==="text"?(e=s.substr(t,4),t+=4):(e=null,a('"text"')),e===null&&(s.substr(t,5).toLowerCase()==="image"?(e=s.substr(t,5),t+=5):(e=null,a('"image"')),e===null&&(s.substr(t,5).toLowerCase()==="audio"?(e=s.substr(t,5),t+=5):(e=null,a('"audio"')),e===null&&(s.substr(t,5).toLowerCase()==="video"?(e=s.substr(t,5),t+=5):(e=null,a('"video"')),e===null&&(s.substr(t,11).toLowerCase()==="application"?(e=s.substr(t,11),t+=11):(e=null,a('"application"')),e===null&&(e=bs()))))),e}function ai(){var e;return s.substr(t,7).toLowerCase()==="message"?(e=s.substr(t,7),t+=7):(e=null,a('"message"')),e===null&&(s.substr(t,9).toLowerCase()==="multipart"?(e=s.substr(t,9),t+=9):(e=null,a('"multipart"')),e===null&&(e=bs())),e}function bs(){var e;return e=q(),e===null&&(e=oi()),e}function oi(){var e,r,l;return l=t,s.substr(t,2).toLowerCase()==="x-"?(e=s.substr(t,2),t+=2):(e=null,a('"x-"')),e!==null?(r=q(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function ui(){var e;return e=bs(),e===null&&(e=q()),e}function $r(){var e,r,l,i;return i=t,e=q(),e!==null?(r=z(),r!==null?(l=ci(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function ci(){var e;return e=q(),e===null&&(e=V()),e}function tc(){var e,r,l,i;return i=t,e=fi(),e!==null?(r=_e(),r!==null?(l=vs(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function fi(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){g.value=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function sc(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){g=i}(r,e)),e===null&&(t=r),e}function rc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=Zt(),e!==null){for(r=[],_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E,v){g.event=v.join("").toLowerCase()}(u,e[0])),e===null&&(t=u),e}function Zt(){var e,r,l,i,u,h;if(u=t,e=ze(),e!==null){for(r=[],h=t,s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?(i=ze(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?(i=ze(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function nc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Pr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Pr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v=g.tag;try{g=new Nt(g.uri,g.display_name,g.params),v&&g.setParam("tag",v)}catch{g=-1}}()),e===null&&(t=u),e}function Pr(){var e;return e=Mr(),e===null&&(e=ge()),e}function Mr(){var e,r,l,i,u;return i=t,u=t,s.substr(t,3).toLowerCase()==="tag"?(e=s.substr(t,3),t+=3):(e=null,a('"tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.tag=_}(i,e[2])),e===null&&(t=i),e}function lc(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){g=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function ic(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){g=i}(r,e)),e===null&&(t=r),e}function ac(){var e,r,l,i,u,h,_,E,v,F;for(E=t,v=t,e=[],r=Is();r!==null;)e.push(r),r=Is();if(e!==null)if(r=rt(),r!==null)if(l=Je(),l!==null)if(i=st(),i!==null){for(u=[],F=t,h=j(),h!==null?(_=ge(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);h!==null;)u.push(h),F=t,h=j(),h!==null?(_=ge(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);u!==null?e=[e,r,l,i,u]:(e=null,t=v)}else e=null,t=v;else e=null,t=v;else e=null,t=v;else e=null,t=v;return e!==null&&(e=function(le){try{g=new Nt(g.uri,g.display_name,g.params)}catch{g=-1}}()),e===null&&(t=E),e}function oc(){var e;return e=Lr(),e}function Lr(){var e,r,l,i,u,h,_,E;if(_=t,s.substr(t,6).toLowerCase()==="digest"?(e=s.substr(t,6),t+=6):(e=null,a('"Digest"')),e!==null)if(r=_e(),r!==null)if(l=ws(),l!==null){for(i=[],E=t,u=Q(),u!==null?(h=ws(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=Q(),u!==null?(h=ws(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e===null&&(e=hi()),e}function hi(){var e,r,l,i,u,h,_,E;if(_=t,e=q(),e!==null)if(r=_e(),r!==null)if(l=es(),l!==null){for(i=[],E=t,u=Q(),u!==null?(h=es(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=Q(),u!==null?(h=es(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function es(){var e,r,l,i;return i=t,e=q(),e!==null?(r=z(),r!==null?(l=q(),l===null&&(l=V()),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function ws(){var e;return e=di(),e===null&&(e=pi(),e===null&&(e=mi(),e===null&&(e=Ti(),e===null&&(e=Ei(),e===null&&(e=Si(),e===null&&(e=Ci(),e===null&&(e=es()))))))),e}function di(){var e,r,l,i;return i=t,s.substr(t,5).toLowerCase()==="realm"?(e=s.substr(t,5),t+=5):(e=null,a('"realm"')),e!==null?(r=z(),r!==null?(l=_i(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function _i(){var e,r;return r=t,e=K(),e!==null&&(e=function(l,i){g.realm=i}(r,e)),e===null&&(t=r),e}function pi(){var e,r,l,i,u,h,_,E,v;if(E=t,s.substr(t,6).toLowerCase()==="domain"?(e=s.substr(t,6),t+=6):(e=null,a('"domain"')),e!==null)if(r=z(),r!==null)if(l=nt(),l!==null)if(i=ys(),i!==null){if(u=[],v=t,_=U(),_!==null)for(h=[];_!==null;)h.push(_),_=U();else h=null;for(h!==null?(_=ys(),_!==null?h=[h,_]:(h=null,t=v)):(h=null,t=v);h!==null;){if(u.push(h),v=t,_=U(),_!==null)for(h=[];_!==null;)h.push(_),_=U();else h=null;h!==null?(_=ys(),_!==null?h=[h,_]:(h=null,t=v)):(h=null,t=v)}u!==null?(h=gs(),h!==null?e=[e,r,l,i,u,h]:(e=null,t=E)):(e=null,t=E)}else e=null,t=E;else e=null,t=E;else e=null,t=E;else e=null,t=E;return e}function ys(){var e;return e=Nr(),e===null&&(e=Cs()),e}function mi(){var e,r,l,i;return i=t,s.substr(t,5).toLowerCase()==="nonce"?(e=s.substr(t,5),t+=5):(e=null,a('"nonce"')),e!==null?(r=z(),r!==null?(l=gi(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function gi(){var e,r;return r=t,e=K(),e!==null&&(e=function(l,i){g.nonce=i}(r,e)),e===null&&(t=r),e}function Ti(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="opaque"?(e=s.substr(t,6),t+=6):(e=null,a('"opaque"')),e!==null?(r=z(),r!==null?(l=K(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.opaque=_}(i,e[2])),e===null&&(t=i),e}function Ei(){var e,r,l,i,u;return i=t,s.substr(t,5).toLowerCase()==="stale"?(e=s.substr(t,5),t+=5):(e=null,a('"stale"')),e!==null?(r=z(),r!==null?(u=t,s.substr(t,4).toLowerCase()==="true"?(l=s.substr(t,4),t+=4):(l=null,a('"true"')),l!==null&&(l=function(h){g.stale=!0}()),l===null&&(t=u),l===null&&(u=t,s.substr(t,5).toLowerCase()==="false"?(l=s.substr(t,5),t+=5):(l=null,a('"false"')),l!==null&&(l=function(h){g.stale=!1}()),l===null&&(t=u)),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Si(){var e,r,l,i,u;return i=t,u=t,s.substr(t,9).toLowerCase()==="algorithm"?(e=s.substr(t,9),t+=9):(e=null,a('"algorithm"')),e!==null?(r=z(),r!==null?(s.substr(t,3).toLowerCase()==="md5"?(l=s.substr(t,3),t+=3):(l=null,a('"MD5"')),l===null&&(s.substr(t,8).toLowerCase()==="md5-sess"?(l=s.substr(t,8),t+=8):(l=null,a('"MD5-sess"')),l===null&&(l=q())),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.algorithm=_.toUpperCase()}(i,e[2])),e===null&&(t=i),e}function Ci(){var e,r,l,i,u,h,_,E,v,F;if(E=t,s.substr(t,3).toLowerCase()==="qop"?(e=s.substr(t,3),t+=3):(e=null,a('"qop"')),e!==null)if(r=z(),r!==null)if(l=nt(),l!==null){if(v=t,i=Ns(),i!==null){for(u=[],F=t,s.charCodeAt(t)===44?(h=",",t++):(h=null,a('","')),h!==null?(_=Ns(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);h!==null;)u.push(h),F=t,s.charCodeAt(t)===44?(h=",",t++):(h=null,a('","')),h!==null?(_=Ns(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);u!==null?i=[i,u]:(i=null,t=v)}else i=null,t=v;i!==null?(u=gs(),u!==null?e=[e,r,l,i,u]:(e=null,t=E)):(e=null,t=E)}else e=null,t=E;else e=null,t=E;else e=null,t=E;return e}function Ns(){var e,r;return r=t,s.substr(t,8).toLowerCase()==="auth-int"?(e=s.substr(t,8),t+=8):(e=null,a('"auth-int"')),e===null&&(s.substr(t,4).toLowerCase()==="auth"?(e=s.substr(t,4),t+=4):(e=null,a('"auth"')),e===null&&(e=q())),e!==null&&(e=function(l,i){g.qop||(g.qop=[]),g.qop.push(i.toLowerCase())}(r,e)),e===null&&(t=r),e}function uc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function cc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=Os(),e!==null){for(r=[],_=t,l=Q(),l!==null?(i=Os(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=Q(),l!==null?(i=Os(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v,F;for(F=g.multi_header.length,v=0;v<F;v++)if(g.multi_header[v].parsed===null){g=null;break}g!==null?g=g.multi_header:g=-1}()),e===null&&(t=u),e}function Os(){var e,r,l,i,u,h,_;if(u=t,h=t,e=mt(),e!==null){for(r=[],_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v;g.multi_header||(g.multi_header=[]);try{v=new Nt(g.uri,g.display_name,g.params),delete g.uri,delete g.display_name,delete g.params}catch{v=null}g.multi_header.push({possition:t,offset:E,parsed:v})}(u)),e===null&&(t=u),e}function fc(){var e,r,l,i,u,h,_;if(u=t,h=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e===null&&(e=q()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Hr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Hr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E,v){if(g.protocol=v.toLowerCase(),g.params||(g.params={}),g.params.text&&g.params.text[0]==='"'){var F=g.params.text;g.text=F.substring(1,F.length-1),delete g.params.text}}(u,e[0])),e===null&&(t=u),e}function Hr(){var e;return e=Ai(),e===null&&(e=ge()),e}function Ai(){var e,r,l,i,u,h;if(u=t,h=t,s.substr(t,5).toLowerCase()==="cause"?(e=s.substr(t,5),t+=5):(e=null,a('"cause"')),e!==null)if(r=z(),r!==null){if(i=m(),i!==null)for(l=[];i!==null;)l.push(i),i=m();else l=null;l!==null?e=[e,r,l]:(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_,E){g.cause=parseInt(E.join(""))}(u,e[2])),e===null&&(t=u),e}function hc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function dc(){var e,r,l,i,u,h;if(u=t,e=xs(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=xs(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=xs(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function xs(){var e,r,l,i,u,h;if(u=t,e=mt(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function _c(){var e,r,l,i,u,h;if(u=t,e=vi(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Fr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Fr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function vi(){var e,r;return r=t,s.substr(t,6).toLowerCase()==="active"?(e=s.substr(t,6),t+=6):(e=null,a('"active"')),e===null&&(s.substr(t,7).toLowerCase()==="pending"?(e=s.substr(t,7),t+=7):(e=null,a('"pending"')),e===null&&(s.substr(t,10).toLowerCase()==="terminated"?(e=s.substr(t,10),t+=10):(e=null,a('"terminated"')),e===null&&(e=q()))),e!==null&&(e=function(l){g.state=s.substring(t,l)}(r)),e===null&&(t=r),e}function Fr(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="reason"?(e=s.substr(t,6),t+=6):(e=null,a('"reason"')),e!==null?(r=z(),r!==null?(l=Ri(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(g.reason=_)}(i,e[2])),e===null&&(t=i),e===null&&(i=t,u=t,s.substr(t,7).toLowerCase()==="expires"?(e=s.substr(t,7),t+=7):(e=null,a('"expires"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(g.expires=_)}(i,e[2])),e===null&&(t=i),e===null&&(i=t,u=t,s.substr(t,11).toLowerCase()==="retry_after"?(e=s.substr(t,11),t+=11):(e=null,a('"retry_after"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(g.retry_after=_)}(i,e[2])),e===null&&(t=i),e===null&&(e=ge()))),e}function Ri(){var e;return s.substr(t,11).toLowerCase()==="deactivated"?(e=s.substr(t,11),t+=11):(e=null,a('"deactivated"')),e===null&&(s.substr(t,9).toLowerCase()==="probation"?(e=s.substr(t,9),t+=9):(e=null,a('"probation"')),e===null&&(s.substr(t,8).toLowerCase()==="rejected"?(e=s.substr(t,8),t+=8):(e=null,a('"rejected"')),e===null&&(s.substr(t,7).toLowerCase()==="timeout"?(e=s.substr(t,7),t+=7):(e=null,a('"timeout"')),e===null&&(s.substr(t,6).toLowerCase()==="giveup"?(e=s.substr(t,6),t+=6):(e=null,a('"giveup"')),e===null&&(s.substr(t,10).toLowerCase()==="noresource"?(e=s.substr(t,10),t+=10):(e=null,a('"noresource"')),e===null&&(s.substr(t,9).toLowerCase()==="invariant"?(e=s.substr(t,9),t+=9):(e=null,a('"invariant"')),e===null&&(e=q()))))))),e}function pc(){var e;return e=N(),e=e!==null?e:"",e}function mc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e=e!==null?e:"",e}function gc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=kr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=kr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v=g.tag;try{g=new Nt(g.uri,g.display_name,g.params),v&&g.setParam("tag",v)}catch{g=-1}}()),e===null&&(t=u),e}function kr(){var e;return e=Mr(),e===null&&(e=ge()),e}function Tc(){var e,r,l,i,u,h;if(u=t,e=Ds(),e!==null){for(r=[],h=t,l=Q(),l!==null?(i=Ds(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Q(),l!==null?(i=Ds(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Ds(){var e,r,l,i,u,h,_,E;if(_=t,e=xi(),e!==null)if(r=_e(),r!==null)if(l=$i(),l!==null){for(i=[],E=t,u=j(),u!==null?(h=qr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=j(),u!==null?(h=qr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function qr(){var e;return e=Ii(),e===null&&(e=bi(),e===null&&(e=wi(),e===null&&(e=yi(),e===null&&(e=Ni(),e===null&&(e=ge()))))),e}function Ii(){var e,r,l,i,u;return i=t,u=t,s.substr(t,3).toLowerCase()==="ttl"?(e=s.substr(t,3),t+=3):(e=null,a('"ttl"')),e!==null?(r=z(),r!==null?(l=Gr(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.ttl=_}(i,e[2])),e===null&&(t=i),e}function bi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,5).toLowerCase()==="maddr"?(e=s.substr(t,5),t+=5):(e=null,a('"maddr"')),e!==null?(r=z(),r!==null?(l=jt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.maddr=_}(i,e[2])),e===null&&(t=i),e}function wi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,8).toLowerCase()==="received"?(e=s.substr(t,8),t+=8):(e=null,a('"received"')),e!==null?(r=z(),r!==null?(l=Yt(),l===null&&(l=wr()),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.received=_}(i,e[2])),e===null&&(t=i),e}function yi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="branch"?(e=s.substr(t,6),t+=6):(e=null,a('"branch"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.branch=_}(i,e[2])),e===null&&(t=i),e}function Ni(){var e,r,l,i,u;return i=t,s.substr(t,5).toLowerCase()==="rport"?(e=s.substr(t,5),t+=5):(e=null,a('"rport"')),e!==null?(u=t,r=z(),r!==null?(l=Oi(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Oi(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){g.rport=parseInt(v.join(""))}(h,e)),e===null&&(t=h),e}function xi(){var e,r,l,i,u,h;return h=t,e=Di(),e!==null?(r=Xe(),r!==null?(l=q(),l!==null?(i=Xe(),i!==null?(u=Ui(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function Di(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e===null&&(e=q()),e!==null&&(e=function(l,i){g.protocol=i}(r,e)),e===null&&(t=r),e}function Ui(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="udp"?(e=s.substr(t,3),t+=3):(e=null,a('"UDP"')),e===null&&(s.substr(t,3).toLowerCase()==="tcp"?(e=s.substr(t,3),t+=3):(e=null,a('"TCP"')),e===null&&(s.substr(t,3).toLowerCase()==="tls"?(e=s.substr(t,3),t+=3):(e=null,a('"TLS"')),e===null&&(s.substr(t,4).toLowerCase()==="sctp"?(e=s.substr(t,4),t+=4):(e=null,a('"SCTP"')),e===null&&(e=q())))),e!==null&&(e=function(l,i){g.transport=i}(r,e)),e===null&&(t=r),e}function $i(){var e,r,l,i,u;return i=t,e=Pi(),e!==null?(u=t,r=pt(),r!==null?(l=Mi(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Pi(){var e,r;return r=t,e=Yt(),e===null&&(e=br(),e===null&&(e=Rr())),e!==null&&(e=function(l){g.host=s.substring(t,l)}(r)),e===null&&(t=r),e}function Mi(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){g.port=parseInt(v.join(""))}(h,e)),e===null&&(t=h),e}function Gr(){var e,r,l,i,u;return i=t,u=t,e=m(),e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){return parseInt(_.join(""))}(i,e)),e===null&&(t=i),e}function Ec(){var e;return e=Lr(),e}function Sc(){var e,r,l,i,u,h;if(u=t,e=Li(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Br(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Br(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Li(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){g.expires=i}(r,e)),e===null&&(t=r),e}function Br(){var e;return e=Hi(),e===null&&(e=ge()),e}function Hi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,9).toLowerCase()==="refresher"?(e=s.substr(t,9),t+=9):(e=null,a('"refresher"')),e!==null?(r=z(),r!==null?(s.substr(t,3).toLowerCase()==="uac"?(l=s.substr(t,3),t+=3):(l=null,a('"uac"')),l===null&&(s.substr(t,3).toLowerCase()==="uas"?(l=s.substr(t,3),t+=3):(l=null,a('"uas"'))),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.refresher=_.toLowerCase()}(i,e[2])),e===null&&(t=i),e}function Cc(){var e,r,l,i;return i=t,e=q(),e!==null?(r=ft(),r!==null?(l=Fi(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Fi(){var e,r;for(e=[],r=I(),r===null&&(r=w(),r===null&&(r=_e()));r!==null;)e.push(r),r=I(),r===null&&(r=w(),r===null&&(r=_e()));return e}function Ac(){var e,r;for(e=[],r=B();r!==null;)e.push(r),r=B();return e}function vc(){var e,r,l;return l=t,s.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,a('"uuid:"')),e!==null?(r=ki(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function ki(){var e,r,l,i,u,h,_,E,v,F,le;return F=t,le=t,e=qi(),e!==null?(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r!==null?(l=Qe(),l!==null?(s.charCodeAt(t)===45?(i="-",t++):(i=null,a('"-"')),i!==null?(u=Qe(),u!==null?(s.charCodeAt(t)===45?(h="-",t++):(h=null,a('"-"')),h!==null?(_=Qe(),_!==null?(s.charCodeAt(t)===45?(E="-",t++):(E=null,a('"-"')),E!==null?(v=Gi(),v!==null?e=[e,r,l,i,u,h,_,E,v]:(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le),e!==null&&(e=function(Ve,Us){g=s.substring(t+5,Ve)}(F,e[0])),e===null&&(t=F),e}function Qe(){var e,r,l,i,u;return u=t,e=O(),e!==null?(r=O(),r!==null?(l=O(),l!==null?(i=O(),i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function qi(){var e,r,l;return l=t,e=Qe(),e!==null?(r=Qe(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function Gi(){var e,r,l,i;return i=t,e=Qe(),e!==null?(r=Qe(),r!==null?(l=Qe(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Rc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=ge(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){try{g=new Nt(g.uri,g.display_name,g.params)}catch{g=-1}}()),e===null&&(t=u),e}function Ic(){var e,r,l,i,u,h;if(u=t,e=Bi(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Wr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Wr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Bi(){var e,r,l,i,u,h;return i=t,u=t,e=We(),e!==null?(h=t,s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?(l=We(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){g.call_id=s.substring(t,_)}(i)),e===null&&(t=i),e}function Wr(){var e;return e=Wi(),e===null&&(e=Vi(),e===null&&(e=ji(),e===null&&(e=ge()))),e}function Wi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6)==="to-tag"?(e="to-tag",t+=6):(e=null,a('"to-tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.to_tag=_}(i,e[2])),e===null&&(t=i),e}function Vi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,8)==="from-tag"?(e="from-tag",t+=8):(e=null,a('"from-tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){g.from_tag=_}(i,e[2])),e===null&&(t=i),e}function ji(){var e,r;return r=t,s.substr(t,10)==="early-only"?(e="early-only",t+=10):(e=null,a('"early-only"')),e!==null&&(e=function(l){g.early_only=!0}()),e===null&&(t=r),e}function bc(e){e.sort();for(var r=null,l=[],i=0;i<e.length;i++)e[i]!==r&&(l.push(e[i]),r=e[i]);return l}function wc(){for(var e=1,r=1,l=!1,i=0;i<Math.max(t,d);i++){var u=s.charAt(i);u===`
4
- `?(l||e++,r=1,l=!1):u==="\r"||u==="\u2028"||u==="\u2029"?(e++,r=1,l=!0):(r++,l=!1)}return{line:e,column:r}}var Yi=Ze(),Nt=Ps(),g={},yc=c[o]();if(yc===null||t!==s.length){var Vr=Math.max(t,d),Nc=Vr<s.length?s.charAt(Vr):null,Ki=wc();return new this.SyntaxError(bc(p),Nc,Vr,Ki.line,Ki.column),-1}return g},toSource:function(){return this._source}};return n.SyntaxError=function(s,o,c,t,d){function p(a,T){var m,S;switch(a.length){case 0:m="end of input";break;case 1:m=a[0];break;default:m=a.slice(0,a.length-1).join(", ")+" or "+a[a.length-1]}return S=T?f(T):"end of input","Expected "+m+" but "+S+" found."}this.name="SyntaxError",this.expected=s,this.found=o,this.message=p(s,o),this.offset=c,this.line=t,this.column=d},n.SyntaxError.prototype=Error.prototype,n}()),Ms}var Ls,Zr;function Ze(){if(Zr)return Ls;Zr=1;const f=oe,n=Ce(),s=$e();return Ls=class Xi{static parse(c){if(c=s.parse(c,"SIP_URI"),c!==-1)return c}constructor(c,t,d,p,a={},T={}){if(!d)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=c||f.SIP,this._user=t,this._host=d,this._port=p;for(const m in a)Object.prototype.hasOwnProperty.call(a,m)&&this.setParam(m,a[m]);for(const m in T)Object.prototype.hasOwnProperty.call(T,m)&&this.setHeader(m,T[m])}get scheme(){return this._scheme}set scheme(c){this._scheme=c.toLowerCase()}get user(){return this._user}set user(c){this._user=c}get host(){return this._host}set host(c){this._host=c.toLowerCase()}get port(){return this._port}set port(c){this._port=c===0?c:parseInt(c,10)||null}setParam(c,t){c&&(this._parameters[c.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(c){if(c)return this._parameters[c.toLowerCase()]}hasParam(c){if(c)return this._parameters.hasOwnProperty(c.toLowerCase())&&!0||!1}deleteParam(c){if(c=c.toLowerCase(),this._parameters.hasOwnProperty(c)){const t=this._parameters[c];return delete this._parameters[c],t}}clearParams(){this._parameters={}}setHeader(c,t){this._headers[n.headerize(c)]=Array.isArray(t)?t:[t]}getHeader(c){if(c)return this._headers[n.headerize(c)]}hasHeader(c){if(c)return this._headers.hasOwnProperty(n.headerize(c))&&!0||!1}deleteHeader(c){if(c=n.headerize(c),this._headers.hasOwnProperty(c)){const t=this._headers[c];return delete this._headers[c],t}}clearHeaders(){this._headers={}}clone(){return new Xi(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const c=[];let t=`${this._scheme}:`;this._user&&(t+=`${n.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const d in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,d)&&(t+=`;${d}`,this._parameters[d]!==null&&(t+=`=${this._parameters[d]}`));for(const d in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,d))for(const p of this._headers[d])c.push(`${d}=${p}`);return c.length>0&&(t+=`?${c.join("&")}`),t}toAor(c){let t=`${this._scheme}:`;return this._user&&(t+=`${n.escapeUser(this._user)}@`),t+=this._host,c&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},Ls}var en;function Ce(){if(en)return fe;en=1;const f=oe,n=Ze(),s=$e();fe.str_utf8_length=d=>unescape(encodeURIComponent(d)).length;const o=fe.isFunction=d=>d!==void 0?Object.prototype.toString.call(d)==="[object Function]":!1;fe.isString=d=>d!==void 0?Object.prototype.toString.call(d)==="[object String]":!1,fe.isDecimal=d=>!isNaN(d)&&parseFloat(d)===parseInt(d,10),fe.isEmpty=d=>d===null||d===""||d===void 0||Array.isArray(d)&&d.length===0||typeof d=="number"&&isNaN(d),fe.hasMethods=function(d,...p){for(const a of p)if(o(d[a]))return!1;return!0};const c=fe.createRandomToken=(d,p=32)=>{let a,T,m="";for(a=0;a<d;a++)T=Math.random()*p|0,m+=T.toString(p);return m};fe.newTag=()=>c(10),fe.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const a=Math.random()*16|0;return(p==="x"?a:a&3|8).toString(16)}),fe.hostType=d=>{if(d){if(d=s.parse(d,"host"),d!==-1)return d.host_type}else return};const t=fe.escapeUser=d=>encodeURIComponent(decodeURIComponent(d)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/");return fe.normalizeTarget=(d,p)=>{if(d){if(d instanceof n)return d;if(typeof d=="string"){const a=d.split("@");let T,m;switch(a.length){case 1:{if(!p)return;T=d,m=p;break}case 2:{T=a[0],m=a[1];break}default:T=a.slice(0,a.length-1).join("@"),m=a[a.length-1]}T=T.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(T)&&(T=T.replace(/[-.()]/g,"")),d=`${f.SIP}:${t(T)}@${m}`;let S;return(S=n.parse(d))?S:void 0}else return}else return},fe.headerize=d=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},a=d.toLowerCase().replace(/_/g,"-").split("-");let T="";const m=a.length;let S;for(S=0;S<m;S++)S!==0&&(T+="-"),T+=a[S].charAt(0).toUpperCase()+a[S].substring(1);return p[T]&&(T=p[T]),T},fe.sipErrorCause=d=>{for(const p in f.SIP_ERROR_CAUSES)if(f.SIP_ERROR_CAUSES[p].indexOf(d)!==-1)return f.causes[p];return f.causes.SIP_FAILURE_CODE},fe.getRandomTestNetIP=()=>{function d(p,a){return Math.floor(Math.random()*(a-p+1)+p)}return`192.0.2.${d(1,254)}`},fe.calculateMD5=d=>{function p(W,G){return W<<G|W>>>32-G}function a(W,G){const V=W&2147483648,K=G&2147483648,ue=W&1073741824,ce=G&1073741824,te=(W&1073741823)+(G&1073741823);return ue&ce?te^2147483648^V^K:ue|ce?te&1073741824?te^3221225472^V^K:te^1073741824^V^K:te^V^K}function T(W,G,V){return W&G|~W&V}function m(W,G,V){return W&V|G&~V}function S(W,G,V){return W^G^V}function O(W,G,V){return G^(W|~V)}function H(W,G,V,K,ue,ce,te){return W=a(W,a(a(T(G,V,K),ue),te)),a(p(W,ce),G)}function B(W,G,V,K,ue,ce,te){return W=a(W,a(a(m(G,V,K),ue),te)),a(p(W,ce),G)}function k(W,G,V,K,ue,ce,te){return W=a(W,a(a(S(G,V,K),ue),te)),a(p(W,ce),G)}function U(W,G,V,K,ue,ce,te){return W=a(W,a(a(O(G,V,K),ue),te)),a(p(W,ce),G)}function de(W){let G;const V=W.length,K=V+8,ce=((K-K%64)/64+1)*16,te=new Array(ce-1);let Je=0,Oe=0;for(;Oe<V;)G=(Oe-Oe%4)/4,Je=Oe%4*8,te[G]=te[G]|W.charCodeAt(Oe)<<Je,Oe++;return G=(Oe-Oe%4)/4,Je=Oe%4*8,te[G]=te[G]|128<<Je,te[ce-2]=V<<3,te[ce-1]=V>>>29,te}function ne(W){let G="",V="",K,ue;for(ue=0;ue<=3;ue++)K=W>>>ue*8&255,V=`0${K.toString(16)}`,G=G+V.substr(V.length-2,2);return G}function tt(W){let G="";for(let V=0;V<W.length;V++){const K=W.charCodeAt(V);K<128?G+=String.fromCharCode(K):K>127&&K<2048?(G+=String.fromCharCode(K>>6|192),G+=String.fromCharCode(K&63|128)):(G+=String.fromCharCode(K>>12|224),G+=String.fromCharCode(K>>6&63|128),G+=String.fromCharCode(K&63|128))}return G}let y=[],$,ae,_e,X,ft,N,I,b,w;const wt=7,q=12,ze=17,yt=22,We=5,ht=9,Xe=14,z=20,dt=4,_t=11,st=16,rt=23,Q=6,j=10,pt=15,nt=21;for(d=tt(d),y=de(d),N=1732584193,I=4023233417,b=2562383102,w=271733878,$=0;$<y.length;$+=16)ae=N,_e=I,X=b,ft=w,N=H(N,I,b,w,y[$+0],wt,3614090360),w=H(w,N,I,b,y[$+1],q,3905402710),b=H(b,w,N,I,y[$+2],ze,606105819),I=H(I,b,w,N,y[$+3],yt,3250441966),N=H(N,I,b,w,y[$+4],wt,4118548399),w=H(w,N,I,b,y[$+5],q,1200080426),b=H(b,w,N,I,y[$+6],ze,2821735955),I=H(I,b,w,N,y[$+7],yt,4249261313),N=H(N,I,b,w,y[$+8],wt,1770035416),w=H(w,N,I,b,y[$+9],q,2336552879),b=H(b,w,N,I,y[$+10],ze,4294925233),I=H(I,b,w,N,y[$+11],yt,2304563134),N=H(N,I,b,w,y[$+12],wt,1804603682),w=H(w,N,I,b,y[$+13],q,4254626195),b=H(b,w,N,I,y[$+14],ze,2792965006),I=H(I,b,w,N,y[$+15],yt,1236535329),N=B(N,I,b,w,y[$+1],We,4129170786),w=B(w,N,I,b,y[$+6],ht,3225465664),b=B(b,w,N,I,y[$+11],Xe,643717713),I=B(I,b,w,N,y[$+0],z,3921069994),N=B(N,I,b,w,y[$+5],We,3593408605),w=B(w,N,I,b,y[$+10],ht,38016083),b=B(b,w,N,I,y[$+15],Xe,3634488961),I=B(I,b,w,N,y[$+4],z,3889429448),N=B(N,I,b,w,y[$+9],We,568446438),w=B(w,N,I,b,y[$+14],ht,3275163606),b=B(b,w,N,I,y[$+3],Xe,4107603335),I=B(I,b,w,N,y[$+8],z,1163531501),N=B(N,I,b,w,y[$+13],We,2850285829),w=B(w,N,I,b,y[$+2],ht,4243563512),b=B(b,w,N,I,y[$+7],Xe,1735328473),I=B(I,b,w,N,y[$+12],z,2368359562),N=k(N,I,b,w,y[$+5],dt,4294588738),w=k(w,N,I,b,y[$+8],_t,2272392833),b=k(b,w,N,I,y[$+11],st,1839030562),I=k(I,b,w,N,y[$+14],rt,4259657740),N=k(N,I,b,w,y[$+1],dt,2763975236),w=k(w,N,I,b,y[$+4],_t,1272893353),b=k(b,w,N,I,y[$+7],st,4139469664),I=k(I,b,w,N,y[$+10],rt,3200236656),N=k(N,I,b,w,y[$+13],dt,681279174),w=k(w,N,I,b,y[$+0],_t,3936430074),b=k(b,w,N,I,y[$+3],st,3572445317),I=k(I,b,w,N,y[$+6],rt,76029189),N=k(N,I,b,w,y[$+9],dt,3654602809),w=k(w,N,I,b,y[$+12],_t,3873151461),b=k(b,w,N,I,y[$+15],st,530742520),I=k(I,b,w,N,y[$+2],rt,3299628645),N=U(N,I,b,w,y[$+0],Q,4096336452),w=U(w,N,I,b,y[$+7],j,1126891415),b=U(b,w,N,I,y[$+14],pt,2878612391),I=U(I,b,w,N,y[$+5],nt,4237533241),N=U(N,I,b,w,y[$+12],Q,1700485571),w=U(w,N,I,b,y[$+3],j,2399980690),b=U(b,w,N,I,y[$+10],pt,4293915773),I=U(I,b,w,N,y[$+1],nt,2240044497),N=U(N,I,b,w,y[$+8],Q,1873313359),w=U(w,N,I,b,y[$+15],j,4264355552),b=U(b,w,N,I,y[$+6],pt,2734768916),I=U(I,b,w,N,y[$+13],nt,1309151649),N=U(N,I,b,w,y[$+4],Q,4149444226),w=U(w,N,I,b,y[$+11],j,3174756917),b=U(b,w,N,I,y[$+2],pt,718787259),I=U(I,b,w,N,y[$+9],nt,3951481745),N=a(N,ae),I=a(I,_e),b=a(b,X),w=a(w,ft);return(ne(N)+ne(I)+ne(b)+ne(w)).toLowerCase()},fe.closeMediaStream=d=>{if(d)try{let p;if(d.getTracks){p=d.getTracks();for(const a of p)a.stop()}else{p=d.getAudioTracks();for(const a of p)a.stop();p=d.getVideoTracks();for(const a of p)a.stop()}}catch{(typeof d.stop=="function"||typeof d.stop=="object")&&d.stop()}},fe.cloneArray=d=>d&&d.slice()||[],fe.cloneObject=(d,p={})=>d&&Object.assign({},d)||p,fe}var Hs={exports:{}},Et=typeof Reflect=="object"?Reflect:null,tn=Et&&typeof Et.apply=="function"?Et.apply:function(n,s,o){return Function.prototype.apply.call(n,s,o)},ss;Et&&typeof Et.ownKeys=="function"?ss=Et.ownKeys:Object.getOwnPropertySymbols?ss=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:ss=function(n){return Object.getOwnPropertyNames(n)};function sa(f){console&&console.warn&&console.warn(f)}var sn=Number.isNaN||function(n){return n!==n};function J(){J.init.call(this)}Hs.exports=J,Hs.exports.once=ia,J.EventEmitter=J,J.prototype._events=void 0,J.prototype._eventsCount=0,J.prototype._maxListeners=void 0;var rn=10;function rs(f){if(typeof f!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof f)}Object.defineProperty(J,"defaultMaxListeners",{enumerable:!0,get:function(){return rn},set:function(f){if(typeof f!="number"||f<0||sn(f))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+f+".");rn=f}}),J.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},J.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||sn(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 nn(f){return f._maxListeners===void 0?J.defaultMaxListeners:f._maxListeners}J.prototype.getMaxListeners=function(){return nn(this)},J.prototype.emit=function(n){for(var s=[],o=1;o<arguments.length;o++)s.push(arguments[o]);var c=n==="error",t=this._events;if(t!==void 0)c=c&&t.error===void 0;else if(!c)return!1;if(c){var d;if(s.length>0&&(d=s[0]),d instanceof Error)throw d;var p=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw p.context=d,p}var a=t[n];if(a===void 0)return!1;if(typeof a=="function")tn(a,this,s);else for(var T=a.length,m=cn(a,T),o=0;o<T;++o)tn(m[o],this,s);return!0};function ln(f,n,s,o){var c,t,d;if(rs(s),t=f._events,t===void 0?(t=f._events=Object.create(null),f._eventsCount=0):(t.newListener!==void 0&&(f.emit("newListener",n,s.listener?s.listener:s),t=f._events),d=t[n]),d===void 0)d=t[n]=s,++f._eventsCount;else if(typeof d=="function"?d=t[n]=o?[s,d]:[d,s]:o?d.unshift(s):d.push(s),c=nn(f),c>0&&d.length>c&&!d.warned){d.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+d.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=f,p.type=n,p.count=d.length,sa(p)}return f}J.prototype.addListener=function(n,s){return ln(this,n,s,!1)},J.prototype.on=J.prototype.addListener,J.prototype.prependListener=function(n,s){return ln(this,n,s,!0)};function ra(){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 an(f,n,s){var o={fired:!1,wrapFn:void 0,target:f,type:n,listener:s},c=ra.bind(o);return c.listener=s,o.wrapFn=c,c}J.prototype.once=function(n,s){return rs(s),this.on(n,an(this,n,s)),this},J.prototype.prependOnceListener=function(n,s){return rs(s),this.prependListener(n,an(this,n,s)),this},J.prototype.removeListener=function(n,s){var o,c,t,d,p;if(rs(s),c=this._events,c===void 0)return this;if(o=c[n],o===void 0)return this;if(o===s||o.listener===s)--this._eventsCount===0?this._events=Object.create(null):(delete c[n],c.removeListener&&this.emit("removeListener",n,o.listener||s));else if(typeof o!="function"){for(t=-1,d=o.length-1;d>=0;d--)if(o[d]===s||o[d].listener===s){p=o[d].listener,t=d;break}if(t<0)return this;t===0?o.shift():na(o,t),o.length===1&&(c[n]=o[0]),c.removeListener!==void 0&&this.emit("removeListener",n,p||s)}return this},J.prototype.off=J.prototype.removeListener,J.prototype.removeAllListeners=function(n){var s,o,c;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[n]),this;if(arguments.length===0){var t=Object.keys(o),d;for(c=0;c<t.length;++c)d=t[c],d!=="removeListener"&&this.removeAllListeners(d);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(s=o[n],typeof s=="function")this.removeListener(n,s);else if(s!==void 0)for(c=s.length-1;c>=0;c--)this.removeListener(n,s[c]);return this};function on(f,n,s){var o=f._events;if(o===void 0)return[];var c=o[n];return c===void 0?[]:typeof c=="function"?s?[c.listener||c]:[c]:s?la(c):cn(c,c.length)}J.prototype.listeners=function(n){return on(this,n,!0)},J.prototype.rawListeners=function(n){return on(this,n,!1)},J.listenerCount=function(f,n){return typeof f.listenerCount=="function"?f.listenerCount(n):un.call(f,n)},J.prototype.listenerCount=un;function un(f){var n=this._events;if(n!==void 0){var s=n[f];if(typeof s=="function")return 1;if(s!==void 0)return s.length}return 0}J.prototype.eventNames=function(){return this._eventsCount>0?ss(this._events):[]};function cn(f,n){for(var s=new Array(n),o=0;o<n;++o)s[o]=f[o];return s}function na(f,n){for(;n+1<f.length;n++)f[n]=f[n+1];f.pop()}function la(f){for(var n=new Array(f.length),s=0;s<n.length;++s)n[s]=f[s].listener||f[s];return n}function ia(f,n){return new Promise(function(s,o){function c(d){f.removeListener(n,t),o(d)}function t(){typeof f.removeListener=="function"&&f.removeListener("error",c),s([].slice.call(arguments))}fn(f,n,t,{once:!0}),n!=="error"&&aa(f,c,{once:!0})})}function aa(f,n,s){typeof f.on=="function"&&fn(f,"error",n,s)}function fn(f,n,s,o){if(typeof f.on=="function")o.once?f.once(n,s):f.on(n,s);else if(typeof f.addEventListener=="function")f.addEventListener(n,function c(t){o.once&&f.removeEventListener(n,c),s(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof f)}var Fe=Hs.exports,Fs={exports:{}},ks,hn;function oa(){if(hn)return ks;hn=1;var f=1e3,n=f*60,s=n*60,o=s*24,c=o*7,t=o*365.25;ks=function(m,S){S=S||{};var O=typeof m;if(O==="string"&&m.length>0)return d(m);if(O==="number"&&isFinite(m))return S.long?a(m):p(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function d(m){if(m=String(m),!(m.length>100)){var S=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(S){var O=parseFloat(S[1]),H=(S[2]||"ms").toLowerCase();switch(H){case"years":case"year":case"yrs":case"yr":case"y":return O*t;case"weeks":case"week":case"w":return O*c;case"days":case"day":case"d":return O*o;case"hours":case"hour":case"hrs":case"hr":case"h":return O*s;case"minutes":case"minute":case"mins":case"min":case"m":return O*n;case"seconds":case"second":case"secs":case"sec":case"s":return O*f;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return O;default:return}}}}function p(m){var S=Math.abs(m);return S>=o?Math.round(m/o)+"d":S>=s?Math.round(m/s)+"h":S>=n?Math.round(m/n)+"m":S>=f?Math.round(m/f)+"s":m+"ms"}function a(m){var S=Math.abs(m);return S>=o?T(m,S,o,"day"):S>=s?T(m,S,s,"hour"):S>=n?T(m,S,n,"minute"):S>=f?T(m,S,f,"second"):m+" ms"}function T(m,S,O,H){var B=S>=O*1.5;return Math.round(m/O)+" "+H+(B?"s":"")}return ks}function ua(f){s.debug=s,s.default=s,s.coerce=a,s.disable=d,s.enable=c,s.enabled=p,s.humanize=oa(),s.destroy=T,Object.keys(f).forEach(m=>{s[m]=f[m]}),s.names=[],s.skips=[],s.formatters={};function n(m){let S=0;for(let O=0;O<m.length;O++)S=(S<<5)-S+m.charCodeAt(O),S|=0;return s.colors[Math.abs(S)%s.colors.length]}s.selectColor=n;function s(m){let S,O=null,H,B;function k(...U){if(!k.enabled)return;const de=k,ne=Number(new Date),tt=ne-(S||ne);de.diff=tt,de.prev=S,de.curr=ne,S=ne,U[0]=s.coerce(U[0]),typeof U[0]!="string"&&U.unshift("%O");let y=0;U[0]=U[0].replace(/%([a-zA-Z%])/g,(ae,_e)=>{if(ae==="%%")return"%";y++;const X=s.formatters[_e];if(typeof X=="function"){const ft=U[y];ae=X.call(de,ft),U.splice(y,1),y--}return ae}),s.formatArgs.call(de,U),(de.log||s.log).apply(de,U)}return k.namespace=m,k.useColors=s.useColors(),k.color=s.selectColor(m),k.extend=o,k.destroy=s.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>O!==null?O:(H!==s.namespaces&&(H=s.namespaces,B=s.enabled(m)),B),set:U=>{O=U}}),typeof s.init=="function"&&s.init(k),k}function o(m,S){const O=s(this.namespace+(typeof S>"u"?":":S)+m);return O.log=this.log,O}function c(m){s.save(m),s.namespaces=m,s.names=[],s.skips=[];const S=(typeof m=="string"?m:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const O of S)O[0]==="-"?s.skips.push(O.slice(1)):s.names.push(O)}function t(m,S){let O=0,H=0,B=-1,k=0;for(;O<m.length;)if(H<S.length&&(S[H]===m[O]||S[H]==="*"))S[H]==="*"?(B=H,k=O,H++):(O++,H++);else if(B!==-1)H=B+1,k++,O=k;else return!1;for(;H<S.length&&S[H]==="*";)H++;return H===S.length}function d(){const m=[...s.names,...s.skips.map(S=>"-"+S)].join(",");return s.enable(""),m}function p(m){for(const S of s.skips)if(t(m,S))return!1;for(const S of s.names)if(t(m,S))return!0;return!1}function a(m){return m instanceof Error?m.stack||m.message:m}function T(){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 s.enable(s.load()),s}var ca=ua;(function(f,n){n.formatArgs=o,n.save=c,n.load=t,n.useColors=s,n.storage=d(),n.destroy=(()=>{let a=!1;return()=>{a||(a=!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 s(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return 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&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+f.exports.humanize(this.diff),!this.useColors)return;const T="color: "+this.color;a.splice(1,0,T,"color: inherit");let m=0,S=0;a[0].replace(/%[a-zA-Z%]/g,O=>{O!=="%%"&&(m++,O==="%c"&&(S=m))}),a.splice(S,0,T)}n.log=console.debug||console.log||(()=>{});function c(a){try{a?n.storage.setItem("debug",a):n.storage.removeItem("debug")}catch{}}function t(){let a;try{a=n.storage.getItem("debug")||n.storage.getItem("DEBUG")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function d(){try{return localStorage}catch{}}f.exports=ca(n);const{formatters:p}=f.exports;p.j=function(a){try{return JSON.stringify(a)}catch(T){return"[UnexpectedJSONParseError]: "+T.message}}})(Fs,Fs.exports);var qs=Fs.exports;const St=qs,Ct="JsSIP";var pe=class{constructor(n){n?(this._debug=St.default(`${Ct}:${n}`),this._warn=St.default(`${Ct}:WARN:${n}`),this._error=St.default(`${Ct}:ERROR:${n}`)):(this._debug=St.default(Ct),this._warn=St.default(`${Ct}:WARN`),this._error=St.default(`${Ct}: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}},Pe={},dn={},_n={exports:{}},pn=_n.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(f){return f.encoding?"rtpmap:%d %s/%s/%s":f.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(f){return f.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(f){return f.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(f){return"extmap:%d"+(f.direction?"/%s":"%v")+(f["encrypt-uri"]?" %s":"%v")+" %s"+(f.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(f){return f.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(f){var n="candidate:%s %d %s %d %s %d typ %s";return n+=f.raddr!=null?" raddr %s rport %d":"%v%v",n+=f.tcptype!=null?" tcptype %s":"%v",f.generation!=null&&(n+=" generation %d"),n+=f["network-id"]!=null?" network-id %d":"%v",n+=f["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(f){var n="ssrc:%d";return f.attribute!=null&&(n+=" %s",f.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(f){return f.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(f){return f.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(f){return"imageattr:%s %s %s"+(f.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(f){return"simulcast:%s %s"+(f.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(f){return"ts-refclk:%s"+(f.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(f){var n="mediaclk:";return n+=f.id!=null?"id=%s %s":"%v%s",n+=f.mediaClockValue!=null?"=%s":"",n+=f.rateNumerator!=null?" rate=%s":"",n+=f.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(pn).forEach(function(f){var n=pn[f];n.forEach(function(s){s.reg||(s.reg=/(.*)/),s.format||(s.format="%s")})});var Gs=_n.exports;(function(f){var n=function(p){return String(Number(p))===p?Number(p):p},s=function(p,a,T,m){if(m&&!T)a[m]=n(p[1]);else for(var S=0;S<T.length;S+=1)p[S+1]!=null&&(a[T[S]]=n(p[S+1]))},o=function(p,a,T){var m=p.name&&p.names;p.push&&!a[p.push]?a[p.push]=[]:m&&!a[p.name]&&(a[p.name]={});var S=p.push?{}:m?a[p.name]:a;s(T.match(p.reg),S,p.names,p.name),p.push&&a[p.push].push(S)},c=Gs,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);f.parse=function(p){var a={},T=[],m=a;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(S){var O=S[0],H=S.slice(2);O==="m"&&(T.push({rtp:[],fmtp:[]}),m=T[T.length-1]);for(var B=0;B<(c[O]||[]).length;B+=1){var k=c[O][B];if(k.reg.test(H))return o(k,m,H)}}),a.media=T,a};var d=function(p,a){var T=a.split(/=(.+)/,2);return T.length===2?p[T[0]]=n(T[1]):T.length===1&&a.length>1&&(p[T[0]]=void 0),p};f.parseParams=function(p){return p.split(/;\s?/).reduce(d,{})},f.parseFmtpConfig=f.parseParams,f.parsePayloads=function(p){return p.toString().split(" ").map(Number)},f.parseRemoteCandidates=function(p){for(var a=[],T=p.split(" ").map(n),m=0;m<T.length;m+=3)a.push({component:T[m],ip:T[m+1],port:T[m+2]});return a},f.parseImageAttributes=function(p){return p.split(" ").map(function(a){return a.substring(1,a.length-1).split(",").reduce(d,{})})},f.parseSimulcastStreamList=function(p){return p.split(";").map(function(a){return a.split(",").map(function(T){var m,S=!1;return T[0]!=="~"?m=n(T):(m=n(T.substring(1,T.length)),S=!0),{scid:m,paused:S}})})}})(dn);var Bs=Gs,fa=/%[sdv%]/g,ha=function(f){var n=1,s=arguments,o=s.length;return f.replace(fa,function(c){if(n>=o)return c;var t=s[n];switch(n+=1,c){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},xt=function(f,n,s){var o=n.format instanceof Function?n.format(n.push?s:s[n.name]):n.format,c=[f+"="+o];if(n.names)for(var t=0;t<n.names.length;t+=1){var d=n.names[t];n.name?c.push(s[n.name][d]):c.push(s[n.names[t]])}else c.push(s[n.name]);return ha.apply(null,c)},da=["v","o","s","i","u","e","p","c","b","t","r","z","a"],_a=["i","c","b","a"],pa=function(f,n){n=n||{},f.version==null&&(f.version=0),f.name==null&&(f.name=" "),f.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var s=n.outerOrder||da,o=n.innerOrder||_a,c=[];return s.forEach(function(t){Bs[t].forEach(function(d){d.name in f&&f[d.name]!=null?c.push(xt(t,d,f)):d.push in f&&f[d.push]!=null&&f[d.push].forEach(function(p){c.push(xt(t,d,p))})})}),f.media.forEach(function(t){c.push(xt("m",Bs.m[0],t)),o.forEach(function(d){Bs[d].forEach(function(p){p.name in t&&t[p.name]!=null?c.push(xt(d,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(a){c.push(xt(d,p,a))})})})}),c.join(`\r
3
+ `,t+=2):(e=null,a('"\\r\\n"')),e}function m(){var e;return/^[0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[0-9]")),e}function S(){var e;return/^[a-zA-Z]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-zA-Z]")),e}function O(){var e;return/^[0-9a-fA-F]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[0-9a-fA-F]")),e}function H(){var e;return e=U(),e===null&&(e=de()),e}function B(){var e;return/^[\0-\xFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\0-\\xFF]")),e}function k(){var e;return/^["]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a('["]')),e}function U(){var e;return s.charCodeAt(t)===32?(e=" ",t++):(e=null,a('" "')),e}function de(){var e;return s.charCodeAt(t)===9?(e=" ",t++):(e=null,a('"\\t"')),e}function ne(){var e;return/^[a-zA-Z0-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-zA-Z0-9]")),e}function tt(){var e;return s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","'))))))))))),e}function w(){var e;return e=ne(),e===null&&(e=$()),e}function $(){var e;return s.charCodeAt(t)===45?(e="-",t++):(e=null,a('"-"')),e===null&&(s.charCodeAt(t)===95?(e="_",t++):(e=null,a('"_"')),e===null&&(s.charCodeAt(t)===46?(e=".",t++):(e=null,a('"."')),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,a('"!"')),e===null&&(s.charCodeAt(t)===126?(e="~",t++):(e=null,a('"~"')),e===null&&(s.charCodeAt(t)===42?(e="*",t++):(e=null,a('"*"')),e===null&&(s.charCodeAt(t)===39?(e="'",t++):(e=null,a(`"'"`)),e===null&&(s.charCodeAt(t)===40?(e="(",t++):(e=null,a('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,a('")"')))))))))),e}function ae(){var e,r,l,i,u;return i=t,u=t,s.charCodeAt(t)===37?(e="%",t++):(e=null,a('"%"')),e!==null?(r=O(),r!==null?(l=O(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){return _.join("")}(i,e)),e===null&&(t=i),e}function _e(){var e,r,l,i,u,h;for(i=t,u=t,h=t,e=[],r=H();r!==null;)e.push(r),r=H();if(e!==null?(r=g(),r!==null?e=[e,r]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null){if(l=H(),l!==null)for(r=[];l!==null;)r.push(l),l=H();else r=null;r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=function(_){return" "}()),e===null&&(t=i),e}function X(){var e;return e=_e(),e=e!==null?e:"",e}function ft(){var e,r,l,i,u;for(i=t,u=t,e=[],r=U(),r===null&&(r=de());r!==null;)e.push(r),r=U(),r===null&&(r=de());return e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function N(){var e,r,l,i,u,h,_;if(u=t,h=t,r=I(),r!==null)for(e=[];r!==null;)e.push(r),r=I();else e=null;if(e!==null){for(r=[],_=t,l=[],i=_e();i!==null;)l.push(i),i=_e();for(l!==null?(i=I(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;){for(r.push(l),_=t,l=[],i=_e();i!==null;)l.push(i),i=_e();l!==null?(i=I(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_)}r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){return s.substring(t,E)}(u)),e===null&&(t=u),e}function I(){var e;return/^[!-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[!-~]")),e===null&&(e=b()),e}function b(){var e;return/^[\x80-\uFFFF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\x80-\\uFFFF]")),e}function y(){var e;return/^[\x80-\xBF]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\x80-\\xBF]")),e}function yt(){var e;return e=m(),e===null&&(/^[a-f]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[a-f]"))),e}function q(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"'))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function ze(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"'))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function wt(){var e;return s.charCodeAt(t)===40?(e="(",t++):(e=null,a('"("')),e===null&&(s.charCodeAt(t)===41?(e=")",t++):(e=null,a('")"')),e===null&&(s.charCodeAt(t)===60?(e="<",t++):(e=null,a('"<"')),e===null&&(s.charCodeAt(t)===62?(e=">",t++):(e=null,a('">"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===92?(e="\\",t++):(e=null,a('"\\\\"')),e===null&&(e=k(),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===123?(e="{",t++):(e=null,a('"{"')),e===null&&(s.charCodeAt(t)===125?(e="}",t++):(e=null,a('"}"')),e===null&&(e=U(),e===null&&(e=de())))))))))))))))))),e}function We(){var e,r,l;if(l=t,r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,a('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,a('"\\\\"')),r===null&&(r=k(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,a('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,a('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,a('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,a('"}"'))))))))))))))))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=ne(),r===null&&(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r===null&&(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r===null&&(s.charCodeAt(t)===33?(r="!",t++):(r=null,a('"!"')),r===null&&(s.charCodeAt(t)===37?(r="%",t++):(r=null,a('"%"')),r===null&&(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r===null&&(s.charCodeAt(t)===95?(r="_",t++):(r=null,a('"_"')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===96?(r="`",t++):(r=null,a('"`"')),r===null&&(s.charCodeAt(t)===39?(r="'",t++):(r=null,a(`"'"`)),r===null&&(s.charCodeAt(t)===126?(r="~",t++):(r=null,a('"~"')),r===null&&(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r===null&&(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r===null&&(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r===null&&(s.charCodeAt(t)===62?(r=">",t++):(r=null,a('">"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===92?(r="\\",t++):(r=null,a('"\\\\"')),r===null&&(r=k(),r===null&&(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r===null&&(s.charCodeAt(t)===91?(r="[",t++):(r=null,a('"["')),r===null&&(s.charCodeAt(t)===93?(r="]",t++):(r=null,a('"]"')),r===null&&(s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r===null&&(s.charCodeAt(t)===123?(r="{",t++):(r=null,a('"{"')),r===null&&(s.charCodeAt(t)===125?(r="}",t++):(r=null,a('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(i){return s.substring(t,i)}(l)),e===null&&(t=l),e}function ht(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===42?(r="*",t++):(r=null,a('"*"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"*"}()),e===null&&(t=i),e}function Xe(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"/"}()),e===null&&(t=i),e}function z(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"="}()),e===null&&(t=i),e}function dt(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===40?(r="(",t++):(r=null,a('"("')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return"("}()),e===null&&(t=i),e}function _t(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===41?(r=")",t++):(r=null,a('")"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return")"}()),e===null&&(t=i),e}function st(){var e,r,l,i;return l=t,i=t,s.charCodeAt(t)===62?(e=">",t++):(e=null,a('">"')),e!==null?(r=X(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return">"}()),e===null&&(t=l),e}function rt(){var e,r,l,i;return l=t,i=t,e=X(),e!==null?(s.charCodeAt(t)===60?(r="<",t++):(r=null,a('"<"')),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return"<"}()),e===null&&(t=l),e}function Z(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return","}()),e===null&&(t=i),e}function j(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return";"}()),e===null&&(t=i),e}function pt(){var e,r,l,i,u;return i=t,u=t,e=X(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=X(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return":"}()),e===null&&(t=i),e}function nt(){var e,r,l,i;return l=t,i=t,e=X(),e!==null?(r=k(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return'"'}()),e===null&&(t=l),e}function gs(){var e,r,l,i;return l=t,i=t,e=k(),e!==null?(r=X(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u){return'"'}()),e===null&&(t=l),e}function W(){var e,r,l,i;if(i=t,e=dt(),e!==null){for(r=[],l=G(),l===null&&(l=ce(),l===null&&(l=W()));l!==null;)r.push(l),l=G(),l===null&&(l=ce(),l===null&&(l=W()));r!==null?(l=_t(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)}else e=null,t=i;return e}function G(){var e;return/^[!-']/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[!-']")),e===null&&(/^[*-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[*-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\]-~]")),e===null&&(e=b(),e===null&&(e=_e())))),e}function V(){var e,r,l,i,u,h;if(u=t,h=t,e=X(),e!==null)if(r=k(),r!==null){for(l=[],i=ue(),i===null&&(i=ce());i!==null;)l.push(i),i=ue(),i===null&&(i=ce());l!==null?(i=k(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_){return s.substring(t,_)}(u)),e===null&&(t=u),e}function K(){var e,r,l,i,u,h;if(u=t,h=t,e=X(),e!==null)if(r=k(),r!==null){for(l=[],i=ue(),i===null&&(i=ce());i!==null;)l.push(i),i=ue(),i===null&&(i=ce());l!==null?(i=k(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_){var E=s.substring(t,_).trim();return E.substring(1,E.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(u)),e===null&&(t=u),e}function ue(){var e;return e=_e(),e===null&&(s.charCodeAt(t)===33?(e="!",t++):(e=null,a('"!"')),e===null&&(/^[#-[]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[#-[]")),e===null&&(/^[\]-~]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[\\]-~]")),e===null&&(e=b())))),e}function ce(){var e,r,l;return l=t,s.charCodeAt(t)===92?(e="\\",t++):(e=null,a('"\\\\"')),e!==null?(/^[\0-\t]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\0-\\t]")),r===null&&(/^[\x0B-\f]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\x0B-\\f]")),r===null&&(/^[\x0E-]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[\\x0E-]")))),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function te(){var e,r,l,i,u,h;return u=t,h=t,e=Oe(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Ts(),l=l!==null?l:"",l!==null?(i=Es(),i!==null?e=[e,r,l,i]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e!==null&&(e=function(_){try{T.uri=new zi(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}}()),e===null&&(t=u),e}function Je(){var e,r,l,i,u,h,_,E;return _=t,E=t,e=Oe(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=Ts(),l=l!==null?l:"",l!==null?(i=Es(),i!==null?(u=pl(),u!==null?(h=bl(),h=h!==null?h:"",h!==null?e=[e,r,l,i,u,h]:(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E)):(e=null,t=E),e!==null&&(e=function(v){try{T.uri=new zi(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,o==="SIP_URI"&&(T=T.uri)}catch{T=-1}}()),e===null&&(t=_),e}function Oe(){var e;return e=ul(),e===null&&(e=cl()),e}function ul(){var e,r;return r=t,s.substr(t,4).toLowerCase()==="sips"?(e=s.substr(t,4),t+=4):(e=null,a('"sips"')),e!==null&&(e=function(l,i){T.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function cl(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"sip"')),e!==null&&(e=function(l,i){T.scheme=i.toLowerCase()}(r,e)),e===null&&(t=r),e}function Ts(){var e,r,l,i,u,h;return i=t,u=t,e=fl(),e!==null?(h=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=hl(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?(s.charCodeAt(t)===64?(l="@",t++):(l=null,a('"@"')),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){T.user=decodeURIComponent(s.substring(t-1,_))}(i)),e===null&&(t=i),e}function fl(){var e,r;if(r=w(),r===null&&(r=ae(),r===null&&(r=br())),r!==null)for(e=[];r!==null;)e.push(r),r=w(),r===null&&(r=ae(),r===null&&(r=br()));else e=null;return e}function br(){var e;return s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"'))))))))),e}function hl(){var e,r,l;for(l=t,e=[],r=w(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","'))))))));r!==null;)e.push(r),r=w(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","'))))))));return e!==null&&(e=function(i){T.password=s.substring(t,i)}(l)),e===null&&(t=l),e}function Es(){var e,r,l,i,u;return i=t,e=jt(),e!==null?(u=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=_l(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function jt(){var e,r;return r=t,e=yr(),e===null&&(e=Yt(),e===null&&(e=Nr())),e!==null&&(e=function(l){return T.host=s.substring(t,l).toLowerCase(),T.host}(r)),e===null&&(t=r),e}function yr(){var e,r,l,i,u,h;for(i=t,u=t,e=[],h=t,r=wr(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);r!==null;)e.push(r),h=t,r=wr(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h);return e!==null?(r=dl(),r!==null?(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){return T.host_type="domain",s.substring(t,_)}(i)),e===null&&(t=i),e}function wr(){var e,r,l,i;if(i=t,e=ne(),e!==null){for(r=[],l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));l!==null;)r.push(l),l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function dl(){var e,r,l,i;if(i=t,e=S(),e!==null){for(r=[],l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));l!==null;)r.push(l),l=ne(),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===95?(l="_",t++):(l=null,a('"_"'))));r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function Nr(){var e,r,l,i,u;return i=t,u=t,s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e!==null?(r=Or(),r!==null?(s.charCodeAt(t)===93?(l="]",t++):(l=null,a('"]"')),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h){return T.host_type="IPv6",s.substring(t,h)}(i)),e===null&&(t=i),e}function Or(){var e,r,l,i,u,h,_,E,v,F,le,Ve,Us,zr,C,M;return zr=t,C=t,e=P(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?(s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=P(),v!==null?(s.charCodeAt(t)===58?(F=":",t++):(F=null,a('":"')),F!==null?(le=P(),le!==null?(s.charCodeAt(t)===58?(Ve=":",t++):(Ve=null,a('":"')),Ve!==null?(Us=xe(),Us!==null?e=[e,r,l,i,u,h,_,E,v,F,le,Ve,Us]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=P(),F!==null?(s.charCodeAt(t)===58?(le=":",t++):(le=null,a('":"')),le!==null?(Ve=xe(),Ve!==null?e=[e,r,l,i,u,h,_,E,v,F,le,Ve]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=xe(),F!==null?e=[e,r,l,i,u,h,_,E,v,F]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=xe(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=xe(),h!==null?e=[e,r,l,i,u,h]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?(s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=xe(),i!==null?e=[e,r,l,i]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=xe(),r!==null?e=[e,r]:(e=null,t=C)):(e=null,t=C),e===null&&(C=t,s.substr(t,2)==="::"?(e="::",t+=2):(e=null,a('"::"')),e!==null?(r=P(),r!==null?e=[e,r]:(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(s.substr(t,2)==="::"?(r="::",t+=2):(r=null,a('"::"')),r!==null?(l=P(),l!==null?(s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=P(),v!==null?(s.charCodeAt(t)===58?(F=":",t++):(F=null,a('":"')),F!==null?(le=xe(),le!==null?e=[e,r,l,i,u,h,_,E,v,F,le]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(s.substr(t,2)==="::"?(l="::",t+=2):(l=null,a('"::"')),l!==null?(i=P(),i!==null?(s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?(s.charCodeAt(t)===58?(v=":",t++):(v=null,a('":"')),v!==null?(F=xe(),F!==null?e=[e,r,l,i,u,h,_,E,v,F]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(s.substr(t,2)==="::"?(i="::",t+=2):(i=null,a('"::"')),i!==null?(u=P(),u!==null?(s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?(s.charCodeAt(t)===58?(E=":",t++):(E=null,a('":"')),E!==null?(v=xe(),v!==null?e=[e,r,l,i,u,h,_,E,v]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(s.substr(t,2)==="::"?(u="::",t+=2):(u=null,a('"::"')),u!==null?(h=P(),h!==null?(s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=xe(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(s.substr(t,2)==="::"?(h="::",t+=2):(h=null,a('"::"')),h!==null?(_=xe(),_!==null?e=[e,r,l,i,u,h,_]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(M=t,s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?h=[h,_]:(h=null,t=M)):(h=null,t=M),h=h!==null?h:"",h!==null?(s.substr(t,2)==="::"?(_="::",t+=2):(_=null,a('"::"')),_!==null?(E=P(),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C),e===null&&(C=t,e=P(),e!==null?(M=t,s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?r=[r,l]:(r=null,t=M)):(r=null,t=M),r=r!==null?r:"",r!==null?(M=t,s.charCodeAt(t)===58?(l=":",t++):(l=null,a('":"')),l!==null?(i=P(),i!==null?l=[l,i]:(l=null,t=M)):(l=null,t=M),l=l!==null?l:"",l!==null?(M=t,s.charCodeAt(t)===58?(i=":",t++):(i=null,a('":"')),i!==null?(u=P(),u!==null?i=[i,u]:(i=null,t=M)):(i=null,t=M),i=i!==null?i:"",i!==null?(M=t,s.charCodeAt(t)===58?(u=":",t++):(u=null,a('":"')),u!==null?(h=P(),h!==null?u=[u,h]:(u=null,t=M)):(u=null,t=M),u=u!==null?u:"",u!==null?(M=t,s.charCodeAt(t)===58?(h=":",t++):(h=null,a('":"')),h!==null?(_=P(),_!==null?h=[h,_]:(h=null,t=M)):(h=null,t=M),h=h!==null?h:"",h!==null?(M=t,s.charCodeAt(t)===58?(_=":",t++):(_=null,a('":"')),_!==null?(E=P(),E!==null?_=[_,E]:(_=null,t=M)):(_=null,t=M),_=_!==null?_:"",_!==null?(s.substr(t,2)==="::"?(E="::",t+=2):(E=null,a('"::"')),E!==null?e=[e,r,l,i,u,h,_,E]:(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C)):(e=null,t=C))))))))))))))),e!==null&&(e=function($c){return T.host_type="IPv6",s.substring(t,$c)}(zr)),e===null&&(t=zr),e}function P(){var e,r,l,i,u;return u=t,e=O(),e!==null?(r=O(),r=r!==null?r:"",r!==null?(l=O(),l=l!==null?l:"",l!==null?(i=O(),i=i!==null?i:"",i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function xe(){var e,r,l,i;return i=t,e=P(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=P(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(e=Yt()),e}function Yt(){var e,r,l,i,u,h,_,E,v;return E=t,v=t,e=Kt(),e!==null?(s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r!==null?(l=Kt(),l!==null?(s.charCodeAt(t)===46?(i=".",t++):(i=null,a('"."')),i!==null?(u=Kt(),u!==null?(s.charCodeAt(t)===46?(h=".",t++):(h=null,a('"."')),h!==null?(_=Kt(),_!==null?e=[e,r,l,i,u,h,_]:(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v)):(e=null,t=v),e!==null&&(e=function(F){return T.host_type="IPv4",s.substring(t,F)}(E)),e===null&&(t=E),e}function Kt(){var e,r,l,i;return i=t,s.substr(t,2)==="25"?(e="25",t+=2):(e=null,a('"25"')),e!==null?(/^[0-5]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[0-5]")),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e===null&&(i=t,s.charCodeAt(t)===50?(e="2",t++):(e=null,a('"2"')),e!==null?(/^[0-4]/.test(s.charAt(t))?(r=s.charAt(t),t++):(r=null,a("[0-4]")),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(i=t,s.charCodeAt(t)===49?(e="1",t++):(e=null,a('"1"')),e!==null?(r=m(),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e===null&&(i=t,/^[1-9]/.test(s.charAt(t))?(e=s.charAt(t),t++):(e=null,a("[1-9]")),e!==null?(r=m(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e===null&&(e=m())))),e}function _l(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){return v=parseInt(v.join("")),T.port=v,v}(h,e)),e===null&&(t=h),e}function pl(){var e,r,l,i;for(e=[],i=t,s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=xr(),l!==null?r=[r,l]:(r=null,t=i)):(r=null,t=i);r!==null;)e.push(r),i=t,s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r!==null?(l=xr(),l!==null?r=[r,l]:(r=null,t=i)):(r=null,t=i);return e}function xr(){var e;return e=ml(),e===null&&(e=gl(),e===null&&(e=Tl(),e===null&&(e=El(),e===null&&(e=Sl(),e===null&&(e=Cl(),e===null&&(e=Al())))))),e}function ml(){var e,r,l,i;return l=t,i=t,s.substr(t,10).toLowerCase()==="transport="?(e=s.substr(t,10),t+=10):(e=null,a('"transport="')),e!==null?(s.substr(t,3).toLowerCase()==="udp"?(r=s.substr(t,3),t+=3):(r=null,a('"udp"')),r===null&&(s.substr(t,3).toLowerCase()==="tcp"?(r=s.substr(t,3),t+=3):(r=null,a('"tcp"')),r===null&&(s.substr(t,4).toLowerCase()==="sctp"?(r=s.substr(t,4),t+=4):(r=null,a('"sctp"')),r===null&&(s.substr(t,3).toLowerCase()==="tls"?(r=s.substr(t,3),t+=3):(r=null,a('"tls"')),r===null&&(r=q())))),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){T.uri_params||(T.uri_params={}),T.uri_params.transport=h.toLowerCase()}(l,e[1])),e===null&&(t=l),e}function gl(){var e,r,l,i;return l=t,i=t,s.substr(t,5).toLowerCase()==="user="?(e=s.substr(t,5),t+=5):(e=null,a('"user="')),e!==null?(s.substr(t,5).toLowerCase()==="phone"?(r=s.substr(t,5),t+=5):(r=null,a('"phone"')),r===null&&(s.substr(t,2).toLowerCase()==="ip"?(r=s.substr(t,2),t+=2):(r=null,a('"ip"')),r===null&&(r=q())),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){T.uri_params||(T.uri_params={}),T.uri_params.user=h.toLowerCase()}(l,e[1])),e===null&&(t=l),e}function Tl(){var e,r,l,i;return l=t,i=t,s.substr(t,7).toLowerCase()==="method="?(e=s.substr(t,7),t+=7):(e=null,a('"method="')),e!==null?(r=vs(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){T.uri_params||(T.uri_params={}),T.uri_params.method=h}(l,e[1])),e===null&&(t=l),e}function El(){var e,r,l,i;return l=t,i=t,s.substr(t,4).toLowerCase()==="ttl="?(e=s.substr(t,4),t+=4):(e=null,a('"ttl="')),e!==null?(r=Vr(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){T.params||(T.params={}),T.params.ttl=h}(l,e[1])),e===null&&(t=l),e}function Sl(){var e,r,l,i;return l=t,i=t,s.substr(t,6).toLowerCase()==="maddr="?(e=s.substr(t,6),t+=6):(e=null,a('"maddr="')),e!==null?(r=jt(),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e!==null&&(e=function(u,h){T.uri_params||(T.uri_params={}),T.uri_params.maddr=h}(l,e[1])),e===null&&(t=l),e}function Cl(){var e,r,l,i,u,h;return i=t,u=t,s.substr(t,2).toLowerCase()==="lr"?(e=s.substr(t,2),t+=2):(e=null,a('"lr"')),e!==null?(h=t,s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=q(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){T.uri_params||(T.uri_params={}),T.uri_params.lr=void 0}()),e===null&&(t=i),e}function Al(){var e,r,l,i,u,h;return i=t,u=t,e=vl(),e!==null?(h=t,s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=Rl(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_,E,v){T.uri_params||(T.uri_params={}),typeof v>"u"?v=void 0:v=v[1],T.uri_params[E.toLowerCase()]=v}(i,e[0],e[1])),e===null&&(t=i),e}function vl(){var e,r,l;if(l=t,r=zt(),r!==null)for(e=[];r!==null;)e.push(r),r=zt();else e=null;return e!==null&&(e=function(i,u){return u.join("")}(l,e)),e===null&&(t=l),e}function Rl(){var e,r,l;if(l=t,r=zt(),r!==null)for(e=[];r!==null;)e.push(r),r=zt();else e=null;return e!==null&&(e=function(i,u){return u.join("")}(l,e)),e===null&&(t=l),e}function zt(){var e;return e=Il(),e===null&&(e=w(),e===null&&(e=ae())),e}function Il(){var e;return s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')))))))),e}function bl(){var e,r,l,i,u,h,_;if(h=t,s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e!==null)if(r=Ss(),r!==null){for(l=[],_=t,s.charCodeAt(t)===38?(i="&",t++):(i=null,a('"&"')),i!==null?(u=Ss(),u!==null?i=[i,u]:(i=null,t=_)):(i=null,t=_);i!==null;)l.push(i),_=t,s.charCodeAt(t)===38?(i="&",t++):(i=null,a('"&"')),i!==null?(u=Ss(),u!==null?i=[i,u]:(i=null,t=_)):(i=null,t=_);l!==null?e=[e,r,l]:(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e}function Ss(){var e,r,l,i,u;return i=t,u=t,e=yl(),e!==null?(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r!==null?(l=wl(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_,E){_=_.join("").toLowerCase(),E=E.join(""),T.uri_headers||(T.uri_headers={}),T.uri_headers[_]?T.uri_headers[_].push(E):T.uri_headers[_]=[E]}(i,e[0],e[2])),e===null&&(t=i),e}function yl(){var e,r;if(r=Xt(),r===null&&(r=w(),r===null&&(r=ae())),r!==null)for(e=[];r!==null;)e.push(r),r=Xt(),r===null&&(r=w(),r===null&&(r=ae()));else e=null;return e}function wl(){var e,r;for(e=[],r=Xt(),r===null&&(r=w(),r===null&&(r=ae()));r!==null;)e.push(r),r=Xt(),r===null&&(r=w(),r===null&&(r=ae()));return e}function Xt(){var e;return s.charCodeAt(t)===91?(e="[",t++):(e=null,a('"["')),e===null&&(s.charCodeAt(t)===93?(e="]",t++):(e=null,a('"]"')),e===null&&(s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')))))))),e}function Ju(){var e;return e=Xl(),e===null&&(e=Nl()),e}function Nl(){var e,r,l,i,u,h;return h=t,e=vs(),e!==null?(r=U(),r!==null?(l=Ol(),l!==null?(i=U(),i!==null?(u=$r(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function Ol(){var e;return e=Je(),e===null&&(e=Dr()),e}function Dr(){var e,r,l,i;return i=t,e=Ml(),e!==null?(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r!==null?(l=xl(),l===null&&(l=Ul()),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function xl(){var e,r,l,i,u;return i=t,e=Dl(),e===null&&(e=Cs()),e!==null?(u=t,s.charCodeAt(t)===63?(r="?",t++):(r=null,a('"?"')),r!==null?(l=kl(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Dl(){var e,r,l,i;return i=t,s.substr(t,2)==="//"?(e="//",t+=2):(e=null,a('"//"')),e!==null?(r=Ll(),r!==null?(l=Cs(),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Cs(){var e,r,l;return l=t,s.charCodeAt(t)===47?(e="/",t++):(e=null,a('"/"')),e!==null?(r=Pl(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function Ul(){var e,r,l,i;if(i=t,e=$l(),e!==null){for(r=[],l=Jt();l!==null;)r.push(l),l=Jt();r!==null?e=[e,r]:(e=null,t=i)}else e=null,t=i;return e}function Jt(){var e;return e=tt(),e===null&&(e=w(),e===null&&(e=ae())),e}function $l(){var e;return e=w(),e===null&&(e=ae(),e===null&&(s.charCodeAt(t)===59?(e=";",t++):(e=null,a('";"')),e===null&&(s.charCodeAt(t)===63?(e="?",t++):(e=null,a('"?"')),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')))))))))))),e}function Pl(){var e,r,l,i,u,h;if(u=t,e=As(),e!==null){for(r=[],h=t,s.charCodeAt(t)===47?(l="/",t++):(l=null,a('"/"')),l!==null?(i=As(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===47?(l="/",t++):(l=null,a('"/"')),l!==null?(i=As(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function As(){var e,r,l,i,u,h;for(u=t,e=[],r=Qt();r!==null;)e.push(r),r=Qt();if(e!==null){for(r=[],h=t,s.charCodeAt(t)===59?(l=";",t++):(l=null,a('";"')),l!==null?(i=Ur(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===59?(l=";",t++):(l=null,a('";"')),l!==null?(i=Ur(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Ur(){var e,r;for(e=[],r=Qt();r!==null;)e.push(r),r=Qt();return e}function Qt(){var e;return e=w(),e===null&&(e=ae(),e===null&&(s.charCodeAt(t)===58?(e=":",t++):(e=null,a('":"')),e===null&&(s.charCodeAt(t)===64?(e="@",t++):(e=null,a('"@"')),e===null&&(s.charCodeAt(t)===38?(e="&",t++):(e=null,a('"&"')),e===null&&(s.charCodeAt(t)===61?(e="=",t++):(e=null,a('"="')),e===null&&(s.charCodeAt(t)===43?(e="+",t++):(e=null,a('"+"')),e===null&&(s.charCodeAt(t)===36?(e="$",t++):(e=null,a('"$"')),e===null&&(s.charCodeAt(t)===44?(e=",",t++):(e=null,a('","')))))))))),e}function Ml(){var e,r,l,i,u;if(i=t,u=t,e=S(),e!==null){for(r=[],l=S(),l===null&&(l=m(),l===null&&(s.charCodeAt(t)===43?(l="+",t++):(l=null,a('"+"')),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."'))))));l!==null;)r.push(l),l=S(),l===null&&(l=m(),l===null&&(s.charCodeAt(t)===43?(l="+",t++):(l=null,a('"+"')),l===null&&(s.charCodeAt(t)===45?(l="-",t++):(l=null,a('"-"')),l===null&&(s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."'))))));r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=function(h){T.scheme=s.substring(t,h)}(i)),e===null&&(t=i),e}function Ll(){var e;return e=Hl(),e===null&&(e=Fl()),e}function Hl(){var e,r,l,i;return l=t,i=t,e=Ts(),e!==null?(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e=e!==null?e:"",e!==null?(r=Es(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e=e!==null?e:"",e}function Fl(){var e,r;if(r=w(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r===null&&(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"'))))))))))),r!==null)for(e=[];r!==null;)e.push(r),r=w(),r===null&&(r=ae(),r===null&&(s.charCodeAt(t)===36?(r="$",t++):(r=null,a('"$"')),r===null&&(s.charCodeAt(t)===44?(r=",",t++):(r=null,a('","')),r===null&&(s.charCodeAt(t)===59?(r=";",t++):(r=null,a('";"')),r===null&&(s.charCodeAt(t)===58?(r=":",t++):(r=null,a('":"')),r===null&&(s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r===null&&(s.charCodeAt(t)===38?(r="&",t++):(r=null,a('"&"')),r===null&&(s.charCodeAt(t)===61?(r="=",t++):(r=null,a('"="')),r===null&&(s.charCodeAt(t)===43?(r="+",t++):(r=null,a('"+"')))))))))));else e=null;return e}function kl(){var e,r;for(e=[],r=Jt();r!==null;)e.push(r),r=Jt();return e}function $r(){var e,r,l,i,u,h,_,E;if(_=t,E=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e!==null)if(s.charCodeAt(t)===47?(r="/",t++):(r=null,a('"/"')),r!==null){if(i=m(),i!==null)for(l=[];i!==null;)l.push(i),i=m();else l=null;if(l!==null)if(s.charCodeAt(t)===46?(i=".",t++):(i=null,a('"."')),i!==null){if(h=m(),h!==null)for(u=[];h!==null;)u.push(h),h=m();else u=null;u!==null?e=[e,r,l,i,u]:(e=null,t=E)}else e=null,t=E;else e=null,t=E}else e=null,t=E;else e=null,t=E;return e!==null&&(e=function(v){T.sip_version=s.substring(t,v)}(_)),e===null&&(t=_),e}function ql(){var e;return s.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,a('"INVITE"')),e}function Gl(){var e;return s.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,a('"ACK"')),e}function Bl(){var e;return s.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,a('"OPTIONS"')),e}function Wl(){var e;return s.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,a('"BYE"')),e}function Vl(){var e;return s.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,a('"CANCEL"')),e}function jl(){var e;return s.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,a('"REGISTER"')),e}function Yl(){var e;return s.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,a('"SUBSCRIBE"')),e}function Kl(){var e;return s.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,a('"NOTIFY"')),e}function zl(){var e;return s.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,a('"REFER"')),e}function vs(){var e,r;return r=t,e=ql(),e===null&&(e=Gl(),e===null&&(e=Bl(),e===null&&(e=Wl(),e===null&&(e=Vl(),e===null&&(e=jl(),e===null&&(e=Yl(),e===null&&(e=Kl(),e===null&&(e=zl(),e===null&&(e=q()))))))))),e!==null&&(e=function(l){return T.method=s.substring(t,l),T.method}(r)),e===null&&(t=r),e}function Xl(){var e,r,l,i,u,h;return h=t,e=$r(),e!==null?(r=U(),r!==null?(l=Jl(),l!==null?(i=U(),i!==null?(u=Zl(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function Jl(){var e,r;return r=t,e=Ql(),e!==null&&(e=function(l,i){T.status_code=parseInt(i.join(""))}(r,e)),e===null&&(t=r),e}function Ql(){var e,r,l,i;return i=t,e=m(),e!==null?(r=m(),r!==null?(l=m(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Zl(){var e,r,l;for(l=t,e=[],r=tt(),r===null&&(r=w(),r===null&&(r=ae(),r===null&&(r=b(),r===null&&(r=y(),r===null&&(r=U(),r===null&&(r=de()))))));r!==null;)e.push(r),r=tt(),r===null&&(r=w(),r===null&&(r=ae(),r===null&&(r=b(),r===null&&(r=y(),r===null&&(r=U(),r===null&&(r=de()))))));return e!==null&&(e=function(i){T.reason_phrase=s.substring(t,i)}(l)),e===null&&(t=l),e}function Qu(){var e,r,l,i,u,h;if(u=t,e=Zt(),e!==null){for(r=[],h=t,l=Z(),l!==null?(i=Zt(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Z(),l!==null?(i=Zt(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Zu(){var e,r,l,i,u,h;return i=t,u=t,e=We(),e!==null?(h=t,s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?(l=We(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){T=s.substring(t,_)}(i)),e===null&&(t=i),e}function ec(){var e,r,l,i,u,h,_;if(u=t,e=ht(),e===null)if(h=t,e=Rs(),e!==null){for(r=[],_=t,l=Z(),l!==null?(i=Rs(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=Z(),l!==null?(i=Rs(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v,F;for(F=T.multi_header.length,v=0;v<F;v++)if(T.multi_header[v].parsed===null){T=null;break}T!==null?T=T.multi_header:T=-1}()),e===null&&(t=u),e}function Rs(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Pr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Pr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v;T.multi_header||(T.multi_header=[]);try{v=new Nt(T.uri,T.display_name,T.params),delete T.uri,delete T.display_name,delete T.params}catch{v=null}T.multi_header.push({possition:t,offset:E,parsed:v})}(u)),e===null&&(t=u),e}function mt(){var e,r,l,i,u;return u=t,e=Is(),e=e!==null?e:"",e!==null?(r=rt(),r!==null?(l=Je(),l!==null?(i=st(),i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Is(){var e,r,l,i,u,h,_;if(u=t,h=t,e=q(),e!==null){for(r=[],_=t,l=_e(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=_e(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e===null&&(e=K()),e!==null&&(e=function(E,v){typeof v=="string"?T.display_name=v:T.display_name=v[1].reduce(function(F,le){return F+le[0]+le[1]},v[0])}(u,e)),e===null&&(t=u),e}function Pr(){var e;return e=ei(),e===null&&(e=ti(),e===null&&(e=Te())),e}function ei(){var e,r,l,i,u;return i=t,u=t,s.substr(t,1).toLowerCase()==="q"?(e=s.substr(t,1),t++):(e=null,a('"q"')),e!==null?(r=z(),r!==null?(l=si(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.params||(T.params={}),T.params.q=_}(i,e[2])),e===null&&(t=i),e}function ti(){var e,r,l,i,u;return i=t,u=t,s.substr(t,7).toLowerCase()==="expires"?(e=s.substr(t,7),t+=7):(e=null,a('"expires"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.params||(T.params={}),T.params.expires=_}(i,e[2])),e===null&&(t=i),e}function gt(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){return parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function si(){var e,r,l,i,u,h,_,E;return h=t,_=t,s.charCodeAt(t)===48?(e="0",t++):(e=null,a('"0"')),e!==null?(E=t,s.charCodeAt(t)===46?(r=".",t++):(r=null,a('"."')),r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?r=[r,l,i,u]:(r=null,t=E)):(r=null,t=E)):(r=null,t=E)):(r=null,t=E),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(v){return parseFloat(s.substring(t,v))}(h)),e===null&&(t=h),e}function Te(){var e,r,l,i,u,h;return i=t,u=t,e=q(),e!==null?(h=t,r=z(),r!==null?(l=ri(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_,E,v){T.params||(T.params={}),typeof v>"u"?v=void 0:v=v[1],T.params[E.toLowerCase()]=v}(i,e[0],e[1])),e===null&&(t=i),e}function ri(){var e;return e=q(),e===null&&(e=jt(),e===null&&(e=V())),e}function tc(){var e,r,l,i,u,h;if(u=t,e=ni(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Mr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Mr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function ni(){var e;return s.substr(t,6).toLowerCase()==="render"?(e=s.substr(t,6),t+=6):(e=null,a('"render"')),e===null&&(s.substr(t,7).toLowerCase()==="session"?(e=s.substr(t,7),t+=7):(e=null,a('"session"')),e===null&&(s.substr(t,4).toLowerCase()==="icon"?(e=s.substr(t,4),t+=4):(e=null,a('"icon"')),e===null&&(s.substr(t,5).toLowerCase()==="alert"?(e=s.substr(t,5),t+=5):(e=null,a('"alert"')),e===null&&(e=q())))),e}function Mr(){var e;return e=li(),e===null&&(e=Te()),e}function li(){var e,r,l,i;return i=t,s.substr(t,8).toLowerCase()==="handling"?(e=s.substr(t,8),t+=8):(e=null,a('"handling"')),e!==null?(r=z(),r!==null?(s.substr(t,8).toLowerCase()==="optional"?(l=s.substr(t,8),t+=8):(l=null,a('"optional"')),l===null&&(s.substr(t,8).toLowerCase()==="required"?(l=s.substr(t,8),t+=8):(l=null,a('"required"')),l===null&&(l=q())),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function sc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function rc(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){T=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function nc(){var e,r;return r=t,e=ii(),e!==null&&(e=function(l){T=s.substring(t,l)}(r)),e===null&&(t=r),e}function ii(){var e,r,l,i,u,h,_,E;if(_=t,e=ai(),e!==null)if(r=Xe(),r!==null)if(l=fi(),l!==null){for(i=[],E=t,u=j(),u!==null?(h=Lr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=j(),u!==null?(h=Lr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function ai(){var e;return e=oi(),e===null&&(e=ui()),e}function oi(){var e;return s.substr(t,4).toLowerCase()==="text"?(e=s.substr(t,4),t+=4):(e=null,a('"text"')),e===null&&(s.substr(t,5).toLowerCase()==="image"?(e=s.substr(t,5),t+=5):(e=null,a('"image"')),e===null&&(s.substr(t,5).toLowerCase()==="audio"?(e=s.substr(t,5),t+=5):(e=null,a('"audio"')),e===null&&(s.substr(t,5).toLowerCase()==="video"?(e=s.substr(t,5),t+=5):(e=null,a('"video"')),e===null&&(s.substr(t,11).toLowerCase()==="application"?(e=s.substr(t,11),t+=11):(e=null,a('"application"')),e===null&&(e=bs()))))),e}function ui(){var e;return s.substr(t,7).toLowerCase()==="message"?(e=s.substr(t,7),t+=7):(e=null,a('"message"')),e===null&&(s.substr(t,9).toLowerCase()==="multipart"?(e=s.substr(t,9),t+=9):(e=null,a('"multipart"')),e===null&&(e=bs())),e}function bs(){var e;return e=q(),e===null&&(e=ci()),e}function ci(){var e,r,l;return l=t,s.substr(t,2).toLowerCase()==="x-"?(e=s.substr(t,2),t+=2):(e=null,a('"x-"')),e!==null?(r=q(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function fi(){var e;return e=bs(),e===null&&(e=q()),e}function Lr(){var e,r,l,i;return i=t,e=q(),e!==null?(r=z(),r!==null?(l=hi(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function hi(){var e;return e=q(),e===null&&(e=V()),e}function lc(){var e,r,l,i;return i=t,e=di(),e!==null?(r=_e(),r!==null?(l=vs(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function di(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){T.value=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function ic(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){T=i}(r,e)),e===null&&(t=r),e}function ac(){var e,r,l,i,u,h,_;if(u=t,h=t,e=Zt(),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E,v){T.event=v.join("").toLowerCase()}(u,e[0])),e===null&&(t=u),e}function Zt(){var e,r,l,i,u,h;if(u=t,e=ze(),e!==null){for(r=[],h=t,s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?(i=ze(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,s.charCodeAt(t)===46?(l=".",t++):(l=null,a('"."')),l!==null?(i=ze(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function oc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Hr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Hr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v=T.tag;try{T=new Nt(T.uri,T.display_name,T.params),v&&T.setParam("tag",v)}catch{T=-1}}()),e===null&&(t=u),e}function Hr(){var e;return e=Fr(),e===null&&(e=Te()),e}function Fr(){var e,r,l,i,u;return i=t,u=t,s.substr(t,3).toLowerCase()==="tag"?(e=s.substr(t,3),t+=3):(e=null,a('"tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.tag=_}(i,e[2])),e===null&&(t=i),e}function uc(){var e,r,l;if(l=t,r=m(),r!==null)for(e=[];r!==null;)e.push(r),r=m();else e=null;return e!==null&&(e=function(i,u){T=parseInt(u.join(""))}(l,e)),e===null&&(t=l),e}function cc(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){T=i}(r,e)),e===null&&(t=r),e}function fc(){var e,r,l,i,u,h,_,E,v,F;for(E=t,v=t,e=[],r=Is();r!==null;)e.push(r),r=Is();if(e!==null)if(r=rt(),r!==null)if(l=Je(),l!==null)if(i=st(),i!==null){for(u=[],F=t,h=j(),h!==null?(_=Te(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);h!==null;)u.push(h),F=t,h=j(),h!==null?(_=Te(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);u!==null?e=[e,r,l,i,u]:(e=null,t=v)}else e=null,t=v;else e=null,t=v;else e=null,t=v;else e=null,t=v;return e!==null&&(e=function(le){try{T=new Nt(T.uri,T.display_name,T.params)}catch{T=-1}}()),e===null&&(t=E),e}function hc(){var e;return e=kr(),e}function kr(){var e,r,l,i,u,h,_,E;if(_=t,s.substr(t,6).toLowerCase()==="digest"?(e=s.substr(t,6),t+=6):(e=null,a('"Digest"')),e!==null)if(r=_e(),r!==null)if(l=ys(),l!==null){for(i=[],E=t,u=Z(),u!==null?(h=ys(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=Z(),u!==null?(h=ys(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e===null&&(e=_i()),e}function _i(){var e,r,l,i,u,h,_,E;if(_=t,e=q(),e!==null)if(r=_e(),r!==null)if(l=es(),l!==null){for(i=[],E=t,u=Z(),u!==null?(h=es(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=Z(),u!==null?(h=es(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function es(){var e,r,l,i;return i=t,e=q(),e!==null?(r=z(),r!==null?(l=q(),l===null&&(l=V()),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function ys(){var e;return e=pi(),e===null&&(e=gi(),e===null&&(e=Ti(),e===null&&(e=Si(),e===null&&(e=Ci(),e===null&&(e=Ai(),e===null&&(e=vi(),e===null&&(e=es()))))))),e}function pi(){var e,r,l,i;return i=t,s.substr(t,5).toLowerCase()==="realm"?(e=s.substr(t,5),t+=5):(e=null,a('"realm"')),e!==null?(r=z(),r!==null?(l=mi(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function mi(){var e,r;return r=t,e=K(),e!==null&&(e=function(l,i){T.realm=i}(r,e)),e===null&&(t=r),e}function gi(){var e,r,l,i,u,h,_,E,v;if(E=t,s.substr(t,6).toLowerCase()==="domain"?(e=s.substr(t,6),t+=6):(e=null,a('"domain"')),e!==null)if(r=z(),r!==null)if(l=nt(),l!==null)if(i=ws(),i!==null){if(u=[],v=t,_=U(),_!==null)for(h=[];_!==null;)h.push(_),_=U();else h=null;for(h!==null?(_=ws(),_!==null?h=[h,_]:(h=null,t=v)):(h=null,t=v);h!==null;){if(u.push(h),v=t,_=U(),_!==null)for(h=[];_!==null;)h.push(_),_=U();else h=null;h!==null?(_=ws(),_!==null?h=[h,_]:(h=null,t=v)):(h=null,t=v)}u!==null?(h=gs(),h!==null?e=[e,r,l,i,u,h]:(e=null,t=E)):(e=null,t=E)}else e=null,t=E;else e=null,t=E;else e=null,t=E;else e=null,t=E;return e}function ws(){var e;return e=Dr(),e===null&&(e=Cs()),e}function Ti(){var e,r,l,i;return i=t,s.substr(t,5).toLowerCase()==="nonce"?(e=s.substr(t,5),t+=5):(e=null,a('"nonce"')),e!==null?(r=z(),r!==null?(l=Ei(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Ei(){var e,r;return r=t,e=K(),e!==null&&(e=function(l,i){T.nonce=i}(r,e)),e===null&&(t=r),e}function Si(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="opaque"?(e=s.substr(t,6),t+=6):(e=null,a('"opaque"')),e!==null?(r=z(),r!==null?(l=K(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.opaque=_}(i,e[2])),e===null&&(t=i),e}function Ci(){var e,r,l,i,u;return i=t,s.substr(t,5).toLowerCase()==="stale"?(e=s.substr(t,5),t+=5):(e=null,a('"stale"')),e!==null?(r=z(),r!==null?(u=t,s.substr(t,4).toLowerCase()==="true"?(l=s.substr(t,4),t+=4):(l=null,a('"true"')),l!==null&&(l=function(h){T.stale=!0}()),l===null&&(t=u),l===null&&(u=t,s.substr(t,5).toLowerCase()==="false"?(l=s.substr(t,5),t+=5):(l=null,a('"false"')),l!==null&&(l=function(h){T.stale=!1}()),l===null&&(t=u)),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function Ai(){var e,r,l,i,u;return i=t,u=t,s.substr(t,9).toLowerCase()==="algorithm"?(e=s.substr(t,9),t+=9):(e=null,a('"algorithm"')),e!==null?(r=z(),r!==null?(s.substr(t,3).toLowerCase()==="md5"?(l=s.substr(t,3),t+=3):(l=null,a('"MD5"')),l===null&&(s.substr(t,8).toLowerCase()==="md5-sess"?(l=s.substr(t,8),t+=8):(l=null,a('"MD5-sess"')),l===null&&(l=q())),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.algorithm=_.toUpperCase()}(i,e[2])),e===null&&(t=i),e}function vi(){var e,r,l,i,u,h,_,E,v,F;if(E=t,s.substr(t,3).toLowerCase()==="qop"?(e=s.substr(t,3),t+=3):(e=null,a('"qop"')),e!==null)if(r=z(),r!==null)if(l=nt(),l!==null){if(v=t,i=Ns(),i!==null){for(u=[],F=t,s.charCodeAt(t)===44?(h=",",t++):(h=null,a('","')),h!==null?(_=Ns(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);h!==null;)u.push(h),F=t,s.charCodeAt(t)===44?(h=",",t++):(h=null,a('","')),h!==null?(_=Ns(),_!==null?h=[h,_]:(h=null,t=F)):(h=null,t=F);u!==null?i=[i,u]:(i=null,t=v)}else i=null,t=v;i!==null?(u=gs(),u!==null?e=[e,r,l,i,u]:(e=null,t=E)):(e=null,t=E)}else e=null,t=E;else e=null,t=E;else e=null,t=E;return e}function Ns(){var e,r;return r=t,s.substr(t,8).toLowerCase()==="auth-int"?(e=s.substr(t,8),t+=8):(e=null,a('"auth-int"')),e===null&&(s.substr(t,4).toLowerCase()==="auth"?(e=s.substr(t,4),t+=4):(e=null,a('"auth"')),e===null&&(e=q())),e!==null&&(e=function(l,i){T.qop||(T.qop=[]),T.qop.push(i.toLowerCase())}(r,e)),e===null&&(t=r),e}function dc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function _c(){var e,r,l,i,u,h,_;if(u=t,h=t,e=Os(),e!==null){for(r=[],_=t,l=Z(),l!==null?(i=Os(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=Z(),l!==null?(i=Os(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v,F;for(F=T.multi_header.length,v=0;v<F;v++)if(T.multi_header[v].parsed===null){T=null;break}T!==null?T=T.multi_header:T=-1}()),e===null&&(t=u),e}function Os(){var e,r,l,i,u,h,_;if(u=t,h=t,e=mt(),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v;T.multi_header||(T.multi_header=[]);try{v=new Nt(T.uri,T.display_name,T.params),delete T.uri,delete T.display_name,delete T.params}catch{v=null}T.multi_header.push({possition:t,offset:E,parsed:v})}(u)),e===null&&(t=u),e}function pc(){var e,r,l,i,u,h,_;if(u=t,h=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e===null&&(e=q()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=qr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=qr(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E,v){if(T.protocol=v.toLowerCase(),T.params||(T.params={}),T.params.text&&T.params.text[0]==='"'){var F=T.params.text;T.text=F.substring(1,F.length-1),delete T.params.text}}(u,e[0])),e===null&&(t=u),e}function qr(){var e;return e=Ri(),e===null&&(e=Te()),e}function Ri(){var e,r,l,i,u,h;if(u=t,h=t,s.substr(t,5).toLowerCase()==="cause"?(e=s.substr(t,5),t+=5):(e=null,a('"cause"')),e!==null)if(r=z(),r!==null){if(i=m(),i!==null)for(l=[];i!==null;)l.push(i),i=m();else l=null;l!==null?e=[e,r,l]:(e=null,t=h)}else e=null,t=h;else e=null,t=h;return e!==null&&(e=function(_,E){T.cause=parseInt(E.join(""))}(u,e[2])),e===null&&(t=u),e}function mc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function gc(){var e,r,l,i,u,h;if(u=t,e=xs(),e!==null){for(r=[],h=t,l=Z(),l!==null?(i=xs(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Z(),l!==null?(i=xs(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function xs(){var e,r,l,i,u,h;if(u=t,e=mt(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Tc(){var e,r,l,i,u,h;if(u=t,e=Ii(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Gr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Gr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Ii(){var e,r;return r=t,s.substr(t,6).toLowerCase()==="active"?(e=s.substr(t,6),t+=6):(e=null,a('"active"')),e===null&&(s.substr(t,7).toLowerCase()==="pending"?(e=s.substr(t,7),t+=7):(e=null,a('"pending"')),e===null&&(s.substr(t,10).toLowerCase()==="terminated"?(e=s.substr(t,10),t+=10):(e=null,a('"terminated"')),e===null&&(e=q()))),e!==null&&(e=function(l){T.state=s.substring(t,l)}(r)),e===null&&(t=r),e}function Gr(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="reason"?(e=s.substr(t,6),t+=6):(e=null,a('"reason"')),e!==null?(r=z(),r!==null?(l=bi(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(T.reason=_)}(i,e[2])),e===null&&(t=i),e===null&&(i=t,u=t,s.substr(t,7).toLowerCase()==="expires"?(e=s.substr(t,7),t+=7):(e=null,a('"expires"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(T.expires=_)}(i,e[2])),e===null&&(t=i),e===null&&(i=t,u=t,s.substr(t,11).toLowerCase()==="retry_after"?(e=s.substr(t,11),t+=11):(e=null,a('"retry_after"')),e!==null?(r=z(),r!==null?(l=gt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){typeof _<"u"&&(T.retry_after=_)}(i,e[2])),e===null&&(t=i),e===null&&(e=Te()))),e}function bi(){var e;return s.substr(t,11).toLowerCase()==="deactivated"?(e=s.substr(t,11),t+=11):(e=null,a('"deactivated"')),e===null&&(s.substr(t,9).toLowerCase()==="probation"?(e=s.substr(t,9),t+=9):(e=null,a('"probation"')),e===null&&(s.substr(t,8).toLowerCase()==="rejected"?(e=s.substr(t,8),t+=8):(e=null,a('"rejected"')),e===null&&(s.substr(t,7).toLowerCase()==="timeout"?(e=s.substr(t,7),t+=7):(e=null,a('"timeout"')),e===null&&(s.substr(t,6).toLowerCase()==="giveup"?(e=s.substr(t,6),t+=6):(e=null,a('"giveup"')),e===null&&(s.substr(t,10).toLowerCase()==="noresource"?(e=s.substr(t,10),t+=10):(e=null,a('"noresource"')),e===null&&(s.substr(t,9).toLowerCase()==="invariant"?(e=s.substr(t,9),t+=9):(e=null,a('"invariant"')),e===null&&(e=q()))))))),e}function Ec(){var e;return e=N(),e=e!==null?e:"",e}function Sc(){var e,r,l,i,u,h;if(u=t,e=q(),e!==null){for(r=[],h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Z(),l!==null?(i=q(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e=e!==null?e:"",e}function Cc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Br(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Br(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){var v=T.tag;try{T=new Nt(T.uri,T.display_name,T.params),v&&T.setParam("tag",v)}catch{T=-1}}()),e===null&&(t=u),e}function Br(){var e;return e=Fr(),e===null&&(e=Te()),e}function Ac(){var e,r,l,i,u,h;if(u=t,e=Ds(),e!==null){for(r=[],h=t,l=Z(),l!==null?(i=Ds(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=Z(),l!==null?(i=Ds(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Ds(){var e,r,l,i,u,h,_,E;if(_=t,e=Ui(),e!==null)if(r=_e(),r!==null)if(l=Mi(),l!==null){for(i=[],E=t,u=j(),u!==null?(h=Wr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);u!==null;)i.push(u),E=t,u=j(),u!==null?(h=Wr(),h!==null?u=[u,h]:(u=null,t=E)):(u=null,t=E);i!==null?e=[e,r,l,i]:(e=null,t=_)}else e=null,t=_;else e=null,t=_;else e=null,t=_;return e}function Wr(){var e;return e=yi(),e===null&&(e=wi(),e===null&&(e=Ni(),e===null&&(e=Oi(),e===null&&(e=xi(),e===null&&(e=Te()))))),e}function yi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,3).toLowerCase()==="ttl"?(e=s.substr(t,3),t+=3):(e=null,a('"ttl"')),e!==null?(r=z(),r!==null?(l=Vr(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.ttl=_}(i,e[2])),e===null&&(t=i),e}function wi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,5).toLowerCase()==="maddr"?(e=s.substr(t,5),t+=5):(e=null,a('"maddr"')),e!==null?(r=z(),r!==null?(l=jt(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.maddr=_}(i,e[2])),e===null&&(t=i),e}function Ni(){var e,r,l,i,u;return i=t,u=t,s.substr(t,8).toLowerCase()==="received"?(e=s.substr(t,8),t+=8):(e=null,a('"received"')),e!==null?(r=z(),r!==null?(l=Yt(),l===null&&(l=Or()),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.received=_}(i,e[2])),e===null&&(t=i),e}function Oi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6).toLowerCase()==="branch"?(e=s.substr(t,6),t+=6):(e=null,a('"branch"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.branch=_}(i,e[2])),e===null&&(t=i),e}function xi(){var e,r,l,i,u;return i=t,s.substr(t,5).toLowerCase()==="rport"?(e=s.substr(t,5),t+=5):(e=null,a('"rport"')),e!==null?(u=t,r=z(),r!==null?(l=Di(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Di(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){T.rport=parseInt(v.join(""))}(h,e)),e===null&&(t=h),e}function Ui(){var e,r,l,i,u,h;return h=t,e=$i(),e!==null?(r=Xe(),r!==null?(l=q(),l!==null?(i=Xe(),i!==null?(u=Pi(),u!==null?e=[e,r,l,i,u]:(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h)):(e=null,t=h),e}function $i(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="sip"?(e=s.substr(t,3),t+=3):(e=null,a('"SIP"')),e===null&&(e=q()),e!==null&&(e=function(l,i){T.protocol=i}(r,e)),e===null&&(t=r),e}function Pi(){var e,r;return r=t,s.substr(t,3).toLowerCase()==="udp"?(e=s.substr(t,3),t+=3):(e=null,a('"UDP"')),e===null&&(s.substr(t,3).toLowerCase()==="tcp"?(e=s.substr(t,3),t+=3):(e=null,a('"TCP"')),e===null&&(s.substr(t,3).toLowerCase()==="tls"?(e=s.substr(t,3),t+=3):(e=null,a('"TLS"')),e===null&&(s.substr(t,4).toLowerCase()==="sctp"?(e=s.substr(t,4),t+=4):(e=null,a('"SCTP"')),e===null&&(e=q())))),e!==null&&(e=function(l,i){T.transport=i}(r,e)),e===null&&(t=r),e}function Mi(){var e,r,l,i,u;return i=t,e=Li(),e!==null?(u=t,r=pt(),r!==null?(l=Hi(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=i)):(e=null,t=i),e}function Li(){var e,r;return r=t,e=Yt(),e===null&&(e=Nr(),e===null&&(e=yr())),e!==null&&(e=function(l){T.host=s.substring(t,l)}(r)),e===null&&(t=r),e}function Hi(){var e,r,l,i,u,h,_;return h=t,_=t,e=m(),e=e!==null?e:"",e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?(i=m(),i=i!==null?i:"",i!==null?(u=m(),u=u!==null?u:"",u!==null?e=[e,r,l,i,u]:(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_)):(e=null,t=_),e!==null&&(e=function(E,v){T.port=parseInt(v.join(""))}(h,e)),e===null&&(t=h),e}function Vr(){var e,r,l,i,u;return i=t,u=t,e=m(),e!==null?(r=m(),r=r!==null?r:"",r!==null?(l=m(),l=l!==null?l:"",l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){return parseInt(_.join(""))}(i,e)),e===null&&(t=i),e}function vc(){var e;return e=kr(),e}function Rc(){var e,r,l,i,u,h;if(u=t,e=Fi(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=jr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=jr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Fi(){var e,r;return r=t,e=gt(),e!==null&&(e=function(l,i){T.expires=i}(r,e)),e===null&&(t=r),e}function jr(){var e;return e=ki(),e===null&&(e=Te()),e}function ki(){var e,r,l,i,u;return i=t,u=t,s.substr(t,9).toLowerCase()==="refresher"?(e=s.substr(t,9),t+=9):(e=null,a('"refresher"')),e!==null?(r=z(),r!==null?(s.substr(t,3).toLowerCase()==="uac"?(l=s.substr(t,3),t+=3):(l=null,a('"uac"')),l===null&&(s.substr(t,3).toLowerCase()==="uas"?(l=s.substr(t,3),t+=3):(l=null,a('"uas"'))),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.refresher=_.toLowerCase()}(i,e[2])),e===null&&(t=i),e}function Ic(){var e,r,l,i;return i=t,e=q(),e!==null?(r=ft(),r!==null?(l=qi(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function qi(){var e,r;for(e=[],r=I(),r===null&&(r=y(),r===null&&(r=_e()));r!==null;)e.push(r),r=I(),r===null&&(r=y(),r===null&&(r=_e()));return e}function bc(){var e,r;for(e=[],r=B();r!==null;)e.push(r),r=B();return e}function yc(){var e,r,l;return l=t,s.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,a('"uuid:"')),e!==null?(r=Gi(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function Gi(){var e,r,l,i,u,h,_,E,v,F,le;return F=t,le=t,e=Bi(),e!==null?(s.charCodeAt(t)===45?(r="-",t++):(r=null,a('"-"')),r!==null?(l=Qe(),l!==null?(s.charCodeAt(t)===45?(i="-",t++):(i=null,a('"-"')),i!==null?(u=Qe(),u!==null?(s.charCodeAt(t)===45?(h="-",t++):(h=null,a('"-"')),h!==null?(_=Qe(),_!==null?(s.charCodeAt(t)===45?(E="-",t++):(E=null,a('"-"')),E!==null?(v=Wi(),v!==null?e=[e,r,l,i,u,h,_,E,v]:(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le)):(e=null,t=le),e!==null&&(e=function(Ve,Us){T=s.substring(t+5,Ve)}(F,e[0])),e===null&&(t=F),e}function Qe(){var e,r,l,i,u;return u=t,e=O(),e!==null?(r=O(),r!==null?(l=O(),l!==null?(i=O(),i!==null?e=[e,r,l,i]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Bi(){var e,r,l;return l=t,e=Qe(),e!==null?(r=Qe(),r!==null?e=[e,r]:(e=null,t=l)):(e=null,t=l),e}function Wi(){var e,r,l,i;return i=t,e=Qe(),e!==null?(r=Qe(),r!==null?(l=Qe(),l!==null?e=[e,r,l]:(e=null,t=i)):(e=null,t=i)):(e=null,t=i),e}function wc(){var e,r,l,i,u,h,_;if(u=t,h=t,e=te(),e===null&&(e=mt()),e!==null){for(r=[],_=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);l!==null;)r.push(l),_=t,l=j(),l!==null?(i=Te(),i!==null?l=[l,i]:(l=null,t=_)):(l=null,t=_);r!==null?e=[e,r]:(e=null,t=h)}else e=null,t=h;return e!==null&&(e=function(E){try{T=new Nt(T.uri,T.display_name,T.params)}catch{T=-1}}()),e===null&&(t=u),e}function Nc(){var e,r,l,i,u,h;if(u=t,e=Vi(),e!==null){for(r=[],h=t,l=j(),l!==null?(i=Yr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);l!==null;)r.push(l),h=t,l=j(),l!==null?(i=Yr(),i!==null?l=[l,i]:(l=null,t=h)):(l=null,t=h);r!==null?e=[e,r]:(e=null,t=u)}else e=null,t=u;return e}function Vi(){var e,r,l,i,u,h;return i=t,u=t,e=We(),e!==null?(h=t,s.charCodeAt(t)===64?(r="@",t++):(r=null,a('"@"')),r!==null?(l=We(),l!==null?r=[r,l]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null?e=[e,r]:(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(_){T.call_id=s.substring(t,_)}(i)),e===null&&(t=i),e}function Yr(){var e;return e=ji(),e===null&&(e=Yi(),e===null&&(e=Ki(),e===null&&(e=Te()))),e}function ji(){var e,r,l,i,u;return i=t,u=t,s.substr(t,6)==="to-tag"?(e="to-tag",t+=6):(e=null,a('"to-tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.to_tag=_}(i,e[2])),e===null&&(t=i),e}function Yi(){var e,r,l,i,u;return i=t,u=t,s.substr(t,8)==="from-tag"?(e="from-tag",t+=8):(e=null,a('"from-tag"')),e!==null?(r=z(),r!==null?(l=q(),l!==null?e=[e,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=function(h,_){T.from_tag=_}(i,e[2])),e===null&&(t=i),e}function Ki(){var e,r;return r=t,s.substr(t,10)==="early-only"?(e="early-only",t+=10):(e=null,a('"early-only"')),e!==null&&(e=function(l){T.early_only=!0}()),e===null&&(t=r),e}function Oc(e){e.sort();for(var r=null,l=[],i=0;i<e.length;i++)e[i]!==r&&(l.push(e[i]),r=e[i]);return l}function xc(){for(var e=1,r=1,l=!1,i=0;i<Math.max(t,d);i++){var u=s.charAt(i);u===`
4
+ `?(l||e++,r=1,l=!1):u==="\r"||u==="\u2028"||u==="\u2029"?(e++,r=1,l=!0):(r++,l=!1)}return{line:e,column:r}}var zi=Ze(),Nt=Ps(),T={},Dc=c[o]();if(Dc===null||t!==s.length){var Kr=Math.max(t,d),Uc=Kr<s.length?s.charAt(Kr):null,Xi=xc();return new this.SyntaxError(Oc(p),Uc,Kr,Xi.line,Xi.column),-1}return T},toSource:function(){return this._source}};return n.SyntaxError=function(s,o,c,t,d){function p(a,g){var m,S;switch(a.length){case 0:m="end of input";break;case 1:m=a[0];break;default:m=a.slice(0,a.length-1).join(", ")+" or "+a[a.length-1]}return S=g?f(g):"end of input","Expected "+m+" but "+S+" found."}this.name="SyntaxError",this.expected=s,this.found=o,this.message=p(s,o),this.offset=c,this.line=t,this.column=d},n.SyntaxError.prototype=Error.prototype,n}()),Ms}var Ls,sn;function Ze(){if(sn)return Ls;sn=1;const f=oe,n=Ce(),s=$e();return Ls=class Qi{static parse(c){if(c=s.parse(c,"SIP_URI"),c!==-1)return c}constructor(c,t,d,p,a={},g={}){if(!d)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=c||f.SIP,this._user=t,this._host=d,this._port=p;for(const m in a)Object.prototype.hasOwnProperty.call(a,m)&&this.setParam(m,a[m]);for(const m in g)Object.prototype.hasOwnProperty.call(g,m)&&this.setHeader(m,g[m])}get scheme(){return this._scheme}set scheme(c){this._scheme=c.toLowerCase()}get user(){return this._user}set user(c){this._user=c}get host(){return this._host}set host(c){this._host=c.toLowerCase()}get port(){return this._port}set port(c){this._port=c===0?c:parseInt(c,10)||null}setParam(c,t){c&&(this._parameters[c.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(c){if(c)return this._parameters[c.toLowerCase()]}hasParam(c){if(c)return this._parameters.hasOwnProperty(c.toLowerCase())&&!0||!1}deleteParam(c){if(c=c.toLowerCase(),this._parameters.hasOwnProperty(c)){const t=this._parameters[c];return delete this._parameters[c],t}}clearParams(){this._parameters={}}setHeader(c,t){this._headers[n.headerize(c)]=Array.isArray(t)?t:[t]}getHeader(c){if(c)return this._headers[n.headerize(c)]}hasHeader(c){if(c)return this._headers.hasOwnProperty(n.headerize(c))&&!0||!1}deleteHeader(c){if(c=n.headerize(c),this._headers.hasOwnProperty(c)){const t=this._headers[c];return delete this._headers[c],t}}clearHeaders(){this._headers={}}clone(){return new Qi(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const c=[];let t=`${this._scheme}:`;this._user&&(t+=`${n.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const d in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,d)&&(t+=`;${d}`,this._parameters[d]!==null&&(t+=`=${this._parameters[d]}`));for(const d in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,d))for(const p of this._headers[d])c.push(`${d}=${p}`);return c.length>0&&(t+=`?${c.join("&")}`),t}toAor(c){let t=`${this._scheme}:`;return this._user&&(t+=`${n.escapeUser(this._user)}@`),t+=this._host,c&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},Ls}var rn;function Ce(){if(rn)return fe;rn=1;const f=oe,n=Ze(),s=$e();fe.str_utf8_length=d=>unescape(encodeURIComponent(d)).length;const o=fe.isFunction=d=>d!==void 0?Object.prototype.toString.call(d)==="[object Function]":!1;fe.isString=d=>d!==void 0?Object.prototype.toString.call(d)==="[object String]":!1,fe.isDecimal=d=>!isNaN(d)&&parseFloat(d)===parseInt(d,10),fe.isEmpty=d=>d===null||d===""||d===void 0||Array.isArray(d)&&d.length===0||typeof d=="number"&&isNaN(d),fe.hasMethods=function(d,...p){for(const a of p)if(o(d[a]))return!1;return!0};const c=fe.createRandomToken=(d,p=32)=>{let a,g,m="";for(a=0;a<d;a++)g=Math.random()*p|0,m+=g.toString(p);return m};fe.newTag=()=>c(10),fe.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const a=Math.random()*16|0;return(p==="x"?a:a&3|8).toString(16)}),fe.hostType=d=>{if(d){if(d=s.parse(d,"host"),d!==-1)return d.host_type}else return};const t=fe.escapeUser=d=>encodeURIComponent(decodeURIComponent(d)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/");return fe.normalizeTarget=(d,p)=>{if(d){if(d instanceof n)return d;if(typeof d=="string"){const a=d.split("@");let g,m;switch(a.length){case 1:{if(!p)return;g=d,m=p;break}case 2:{g=a[0],m=a[1];break}default:g=a.slice(0,a.length-1).join("@"),m=a[a.length-1]}g=g.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(g)&&(g=g.replace(/[-.()]/g,"")),d=`${f.SIP}:${t(g)}@${m}`;let S;return(S=n.parse(d))?S:void 0}else return}else return},fe.headerize=d=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},a=d.toLowerCase().replace(/_/g,"-").split("-");let g="";const m=a.length;let S;for(S=0;S<m;S++)S!==0&&(g+="-"),g+=a[S].charAt(0).toUpperCase()+a[S].substring(1);return p[g]&&(g=p[g]),g},fe.sipErrorCause=d=>{for(const p in f.SIP_ERROR_CAUSES)if(f.SIP_ERROR_CAUSES[p].indexOf(d)!==-1)return f.causes[p];return f.causes.SIP_FAILURE_CODE},fe.getRandomTestNetIP=()=>{function d(p,a){return Math.floor(Math.random()*(a-p+1)+p)}return`192.0.2.${d(1,254)}`},fe.calculateMD5=d=>{function p(W,G){return W<<G|W>>>32-G}function a(W,G){const V=W&2147483648,K=G&2147483648,ue=W&1073741824,ce=G&1073741824,te=(W&1073741823)+(G&1073741823);return ue&ce?te^2147483648^V^K:ue|ce?te&1073741824?te^3221225472^V^K:te^1073741824^V^K:te^V^K}function g(W,G,V){return W&G|~W&V}function m(W,G,V){return W&V|G&~V}function S(W,G,V){return W^G^V}function O(W,G,V){return G^(W|~V)}function H(W,G,V,K,ue,ce,te){return W=a(W,a(a(g(G,V,K),ue),te)),a(p(W,ce),G)}function B(W,G,V,K,ue,ce,te){return W=a(W,a(a(m(G,V,K),ue),te)),a(p(W,ce),G)}function k(W,G,V,K,ue,ce,te){return W=a(W,a(a(S(G,V,K),ue),te)),a(p(W,ce),G)}function U(W,G,V,K,ue,ce,te){return W=a(W,a(a(O(G,V,K),ue),te)),a(p(W,ce),G)}function de(W){let G;const V=W.length,K=V+8,ce=((K-K%64)/64+1)*16,te=new Array(ce-1);let Je=0,Oe=0;for(;Oe<V;)G=(Oe-Oe%4)/4,Je=Oe%4*8,te[G]=te[G]|W.charCodeAt(Oe)<<Je,Oe++;return G=(Oe-Oe%4)/4,Je=Oe%4*8,te[G]=te[G]|128<<Je,te[ce-2]=V<<3,te[ce-1]=V>>>29,te}function ne(W){let G="",V="",K,ue;for(ue=0;ue<=3;ue++)K=W>>>ue*8&255,V=`0${K.toString(16)}`,G=G+V.substr(V.length-2,2);return G}function tt(W){let G="";for(let V=0;V<W.length;V++){const K=W.charCodeAt(V);K<128?G+=String.fromCharCode(K):K>127&&K<2048?(G+=String.fromCharCode(K>>6|192),G+=String.fromCharCode(K&63|128)):(G+=String.fromCharCode(K>>12|224),G+=String.fromCharCode(K>>6&63|128),G+=String.fromCharCode(K&63|128))}return G}let w=[],$,ae,_e,X,ft,N,I,b,y;const yt=7,q=12,ze=17,wt=22,We=5,ht=9,Xe=14,z=20,dt=4,_t=11,st=16,rt=23,Z=6,j=10,pt=15,nt=21;for(d=tt(d),w=de(d),N=1732584193,I=4023233417,b=2562383102,y=271733878,$=0;$<w.length;$+=16)ae=N,_e=I,X=b,ft=y,N=H(N,I,b,y,w[$+0],yt,3614090360),y=H(y,N,I,b,w[$+1],q,3905402710),b=H(b,y,N,I,w[$+2],ze,606105819),I=H(I,b,y,N,w[$+3],wt,3250441966),N=H(N,I,b,y,w[$+4],yt,4118548399),y=H(y,N,I,b,w[$+5],q,1200080426),b=H(b,y,N,I,w[$+6],ze,2821735955),I=H(I,b,y,N,w[$+7],wt,4249261313),N=H(N,I,b,y,w[$+8],yt,1770035416),y=H(y,N,I,b,w[$+9],q,2336552879),b=H(b,y,N,I,w[$+10],ze,4294925233),I=H(I,b,y,N,w[$+11],wt,2304563134),N=H(N,I,b,y,w[$+12],yt,1804603682),y=H(y,N,I,b,w[$+13],q,4254626195),b=H(b,y,N,I,w[$+14],ze,2792965006),I=H(I,b,y,N,w[$+15],wt,1236535329),N=B(N,I,b,y,w[$+1],We,4129170786),y=B(y,N,I,b,w[$+6],ht,3225465664),b=B(b,y,N,I,w[$+11],Xe,643717713),I=B(I,b,y,N,w[$+0],z,3921069994),N=B(N,I,b,y,w[$+5],We,3593408605),y=B(y,N,I,b,w[$+10],ht,38016083),b=B(b,y,N,I,w[$+15],Xe,3634488961),I=B(I,b,y,N,w[$+4],z,3889429448),N=B(N,I,b,y,w[$+9],We,568446438),y=B(y,N,I,b,w[$+14],ht,3275163606),b=B(b,y,N,I,w[$+3],Xe,4107603335),I=B(I,b,y,N,w[$+8],z,1163531501),N=B(N,I,b,y,w[$+13],We,2850285829),y=B(y,N,I,b,w[$+2],ht,4243563512),b=B(b,y,N,I,w[$+7],Xe,1735328473),I=B(I,b,y,N,w[$+12],z,2368359562),N=k(N,I,b,y,w[$+5],dt,4294588738),y=k(y,N,I,b,w[$+8],_t,2272392833),b=k(b,y,N,I,w[$+11],st,1839030562),I=k(I,b,y,N,w[$+14],rt,4259657740),N=k(N,I,b,y,w[$+1],dt,2763975236),y=k(y,N,I,b,w[$+4],_t,1272893353),b=k(b,y,N,I,w[$+7],st,4139469664),I=k(I,b,y,N,w[$+10],rt,3200236656),N=k(N,I,b,y,w[$+13],dt,681279174),y=k(y,N,I,b,w[$+0],_t,3936430074),b=k(b,y,N,I,w[$+3],st,3572445317),I=k(I,b,y,N,w[$+6],rt,76029189),N=k(N,I,b,y,w[$+9],dt,3654602809),y=k(y,N,I,b,w[$+12],_t,3873151461),b=k(b,y,N,I,w[$+15],st,530742520),I=k(I,b,y,N,w[$+2],rt,3299628645),N=U(N,I,b,y,w[$+0],Z,4096336452),y=U(y,N,I,b,w[$+7],j,1126891415),b=U(b,y,N,I,w[$+14],pt,2878612391),I=U(I,b,y,N,w[$+5],nt,4237533241),N=U(N,I,b,y,w[$+12],Z,1700485571),y=U(y,N,I,b,w[$+3],j,2399980690),b=U(b,y,N,I,w[$+10],pt,4293915773),I=U(I,b,y,N,w[$+1],nt,2240044497),N=U(N,I,b,y,w[$+8],Z,1873313359),y=U(y,N,I,b,w[$+15],j,4264355552),b=U(b,y,N,I,w[$+6],pt,2734768916),I=U(I,b,y,N,w[$+13],nt,1309151649),N=U(N,I,b,y,w[$+4],Z,4149444226),y=U(y,N,I,b,w[$+11],j,3174756917),b=U(b,y,N,I,w[$+2],pt,718787259),I=U(I,b,y,N,w[$+9],nt,3951481745),N=a(N,ae),I=a(I,_e),b=a(b,X),y=a(y,ft);return(ne(N)+ne(I)+ne(b)+ne(y)).toLowerCase()},fe.closeMediaStream=d=>{if(d)try{let p;if(d.getTracks){p=d.getTracks();for(const a of p)a.stop()}else{p=d.getAudioTracks();for(const a of p)a.stop();p=d.getVideoTracks();for(const a of p)a.stop()}}catch{(typeof d.stop=="function"||typeof d.stop=="object")&&d.stop()}},fe.cloneArray=d=>d&&d.slice()||[],fe.cloneObject=(d,p={})=>d&&Object.assign({},d)||p,fe}var Hs={exports:{}},Et=typeof Reflect=="object"?Reflect:null,nn=Et&&typeof Et.apply=="function"?Et.apply:function(n,s,o){return Function.prototype.apply.call(n,s,o)},ss;Et&&typeof Et.ownKeys=="function"?ss=Et.ownKeys:Object.getOwnPropertySymbols?ss=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:ss=function(n){return Object.getOwnPropertyNames(n)};function na(f){console&&console.warn&&console.warn(f)}var ln=Number.isNaN||function(n){return n!==n};function J(){J.init.call(this)}Hs.exports=J,Hs.exports.once=oa,J.EventEmitter=J,J.prototype._events=void 0,J.prototype._eventsCount=0,J.prototype._maxListeners=void 0;var an=10;function rs(f){if(typeof f!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof f)}Object.defineProperty(J,"defaultMaxListeners",{enumerable:!0,get:function(){return an},set:function(f){if(typeof f!="number"||f<0||ln(f))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+f+".");an=f}}),J.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},J.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||ln(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 on(f){return f._maxListeners===void 0?J.defaultMaxListeners:f._maxListeners}J.prototype.getMaxListeners=function(){return on(this)},J.prototype.emit=function(n){for(var s=[],o=1;o<arguments.length;o++)s.push(arguments[o]);var c=n==="error",t=this._events;if(t!==void 0)c=c&&t.error===void 0;else if(!c)return!1;if(c){var d;if(s.length>0&&(d=s[0]),d instanceof Error)throw d;var p=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw p.context=d,p}var a=t[n];if(a===void 0)return!1;if(typeof a=="function")nn(a,this,s);else for(var g=a.length,m=dn(a,g),o=0;o<g;++o)nn(m[o],this,s);return!0};function un(f,n,s,o){var c,t,d;if(rs(s),t=f._events,t===void 0?(t=f._events=Object.create(null),f._eventsCount=0):(t.newListener!==void 0&&(f.emit("newListener",n,s.listener?s.listener:s),t=f._events),d=t[n]),d===void 0)d=t[n]=s,++f._eventsCount;else if(typeof d=="function"?d=t[n]=o?[s,d]:[d,s]:o?d.unshift(s):d.push(s),c=on(f),c>0&&d.length>c&&!d.warned){d.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+d.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=f,p.type=n,p.count=d.length,na(p)}return f}J.prototype.addListener=function(n,s){return un(this,n,s,!1)},J.prototype.on=J.prototype.addListener,J.prototype.prependListener=function(n,s){return un(this,n,s,!0)};function la(){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 cn(f,n,s){var o={fired:!1,wrapFn:void 0,target:f,type:n,listener:s},c=la.bind(o);return c.listener=s,o.wrapFn=c,c}J.prototype.once=function(n,s){return rs(s),this.on(n,cn(this,n,s)),this},J.prototype.prependOnceListener=function(n,s){return rs(s),this.prependListener(n,cn(this,n,s)),this},J.prototype.removeListener=function(n,s){var o,c,t,d,p;if(rs(s),c=this._events,c===void 0)return this;if(o=c[n],o===void 0)return this;if(o===s||o.listener===s)--this._eventsCount===0?this._events=Object.create(null):(delete c[n],c.removeListener&&this.emit("removeListener",n,o.listener||s));else if(typeof o!="function"){for(t=-1,d=o.length-1;d>=0;d--)if(o[d]===s||o[d].listener===s){p=o[d].listener,t=d;break}if(t<0)return this;t===0?o.shift():ia(o,t),o.length===1&&(c[n]=o[0]),c.removeListener!==void 0&&this.emit("removeListener",n,p||s)}return this},J.prototype.off=J.prototype.removeListener,J.prototype.removeAllListeners=function(n){var s,o,c;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[n]),this;if(arguments.length===0){var t=Object.keys(o),d;for(c=0;c<t.length;++c)d=t[c],d!=="removeListener"&&this.removeAllListeners(d);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(s=o[n],typeof s=="function")this.removeListener(n,s);else if(s!==void 0)for(c=s.length-1;c>=0;c--)this.removeListener(n,s[c]);return this};function fn(f,n,s){var o=f._events;if(o===void 0)return[];var c=o[n];return c===void 0?[]:typeof c=="function"?s?[c.listener||c]:[c]:s?aa(c):dn(c,c.length)}J.prototype.listeners=function(n){return fn(this,n,!0)},J.prototype.rawListeners=function(n){return fn(this,n,!1)},J.listenerCount=function(f,n){return typeof f.listenerCount=="function"?f.listenerCount(n):hn.call(f,n)},J.prototype.listenerCount=hn;function hn(f){var n=this._events;if(n!==void 0){var s=n[f];if(typeof s=="function")return 1;if(s!==void 0)return s.length}return 0}J.prototype.eventNames=function(){return this._eventsCount>0?ss(this._events):[]};function dn(f,n){for(var s=new Array(n),o=0;o<n;++o)s[o]=f[o];return s}function ia(f,n){for(;n+1<f.length;n++)f[n]=f[n+1];f.pop()}function aa(f){for(var n=new Array(f.length),s=0;s<n.length;++s)n[s]=f[s].listener||f[s];return n}function oa(f,n){return new Promise(function(s,o){function c(d){f.removeListener(n,t),o(d)}function t(){typeof f.removeListener=="function"&&f.removeListener("error",c),s([].slice.call(arguments))}_n(f,n,t,{once:!0}),n!=="error"&&ua(f,c,{once:!0})})}function ua(f,n,s){typeof f.on=="function"&&_n(f,"error",n,s)}function _n(f,n,s,o){if(typeof f.on=="function")o.once?f.once(n,s):f.on(n,s);else if(typeof f.addEventListener=="function")f.addEventListener(n,function c(t){o.once&&f.removeEventListener(n,c),s(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof f)}var Fe=Hs.exports,Fs={exports:{}},ks,pn;function ca(){if(pn)return ks;pn=1;var f=1e3,n=f*60,s=n*60,o=s*24,c=o*7,t=o*365.25;ks=function(m,S){S=S||{};var O=typeof m;if(O==="string"&&m.length>0)return d(m);if(O==="number"&&isFinite(m))return S.long?a(m):p(m);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(m))};function d(m){if(m=String(m),!(m.length>100)){var S=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(m);if(S){var O=parseFloat(S[1]),H=(S[2]||"ms").toLowerCase();switch(H){case"years":case"year":case"yrs":case"yr":case"y":return O*t;case"weeks":case"week":case"w":return O*c;case"days":case"day":case"d":return O*o;case"hours":case"hour":case"hrs":case"hr":case"h":return O*s;case"minutes":case"minute":case"mins":case"min":case"m":return O*n;case"seconds":case"second":case"secs":case"sec":case"s":return O*f;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return O;default:return}}}}function p(m){var S=Math.abs(m);return S>=o?Math.round(m/o)+"d":S>=s?Math.round(m/s)+"h":S>=n?Math.round(m/n)+"m":S>=f?Math.round(m/f)+"s":m+"ms"}function a(m){var S=Math.abs(m);return S>=o?g(m,S,o,"day"):S>=s?g(m,S,s,"hour"):S>=n?g(m,S,n,"minute"):S>=f?g(m,S,f,"second"):m+" ms"}function g(m,S,O,H){var B=S>=O*1.5;return Math.round(m/O)+" "+H+(B?"s":"")}return ks}function fa(f){s.debug=s,s.default=s,s.coerce=a,s.disable=d,s.enable=c,s.enabled=p,s.humanize=ca(),s.destroy=g,Object.keys(f).forEach(m=>{s[m]=f[m]}),s.names=[],s.skips=[],s.formatters={};function n(m){let S=0;for(let O=0;O<m.length;O++)S=(S<<5)-S+m.charCodeAt(O),S|=0;return s.colors[Math.abs(S)%s.colors.length]}s.selectColor=n;function s(m){let S,O=null,H,B;function k(...U){if(!k.enabled)return;const de=k,ne=Number(new Date),tt=ne-(S||ne);de.diff=tt,de.prev=S,de.curr=ne,S=ne,U[0]=s.coerce(U[0]),typeof U[0]!="string"&&U.unshift("%O");let w=0;U[0]=U[0].replace(/%([a-zA-Z%])/g,(ae,_e)=>{if(ae==="%%")return"%";w++;const X=s.formatters[_e];if(typeof X=="function"){const ft=U[w];ae=X.call(de,ft),U.splice(w,1),w--}return ae}),s.formatArgs.call(de,U),(de.log||s.log).apply(de,U)}return k.namespace=m,k.useColors=s.useColors(),k.color=s.selectColor(m),k.extend=o,k.destroy=s.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>O!==null?O:(H!==s.namespaces&&(H=s.namespaces,B=s.enabled(m)),B),set:U=>{O=U}}),typeof s.init=="function"&&s.init(k),k}function o(m,S){const O=s(this.namespace+(typeof S>"u"?":":S)+m);return O.log=this.log,O}function c(m){s.save(m),s.namespaces=m,s.names=[],s.skips=[];const S=(typeof m=="string"?m:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const O of S)O[0]==="-"?s.skips.push(O.slice(1)):s.names.push(O)}function t(m,S){let O=0,H=0,B=-1,k=0;for(;O<m.length;)if(H<S.length&&(S[H]===m[O]||S[H]==="*"))S[H]==="*"?(B=H,k=O,H++):(O++,H++);else if(B!==-1)H=B+1,k++,O=k;else return!1;for(;H<S.length&&S[H]==="*";)H++;return H===S.length}function d(){const m=[...s.names,...s.skips.map(S=>"-"+S)].join(",");return s.enable(""),m}function p(m){for(const S of s.skips)if(t(m,S))return!1;for(const S of s.names)if(t(m,S))return!0;return!1}function a(m){return m instanceof Error?m.stack||m.message:m}function g(){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 s.enable(s.load()),s}var ha=fa;(function(f,n){n.formatArgs=o,n.save=c,n.load=t,n.useColors=s,n.storage=d(),n.destroy=(()=>{let a=!1;return()=>{a||(a=!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 s(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return 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&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+f.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;a.splice(1,0,g,"color: inherit");let m=0,S=0;a[0].replace(/%[a-zA-Z%]/g,O=>{O!=="%%"&&(m++,O==="%c"&&(S=m))}),a.splice(S,0,g)}n.log=console.debug||console.log||(()=>{});function c(a){try{a?n.storage.setItem("debug",a):n.storage.removeItem("debug")}catch{}}function t(){let a;try{a=n.storage.getItem("debug")||n.storage.getItem("DEBUG")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function d(){try{return localStorage}catch{}}f.exports=ha(n);const{formatters:p}=f.exports;p.j=function(a){try{return JSON.stringify(a)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}})(Fs,Fs.exports);var qs=Fs.exports;const St=qs,Ct="JsSIP";var pe=class{constructor(n){n?(this._debug=St.default(`${Ct}:${n}`),this._warn=St.default(`${Ct}:WARN:${n}`),this._error=St.default(`${Ct}:ERROR:${n}`)):(this._debug=St.default(Ct),this._warn=St.default(`${Ct}:WARN`),this._error=St.default(`${Ct}: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}},Pe={},mn={},gn={exports:{}},Tn=gn.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(f){return f.encoding?"rtpmap:%d %s/%s/%s":f.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(f){return f.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(f){return f.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(f){return"extmap:%d"+(f.direction?"/%s":"%v")+(f["encrypt-uri"]?" %s":"%v")+" %s"+(f.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(f){return f.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(f){var n="candidate:%s %d %s %d %s %d typ %s";return n+=f.raddr!=null?" raddr %s rport %d":"%v%v",n+=f.tcptype!=null?" tcptype %s":"%v",f.generation!=null&&(n+=" generation %d"),n+=f["network-id"]!=null?" network-id %d":"%v",n+=f["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(f){var n="ssrc:%d";return f.attribute!=null&&(n+=" %s",f.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(f){return f.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(f){return f.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(f){return"imageattr:%s %s %s"+(f.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(f){return"simulcast:%s %s"+(f.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(f){return"ts-refclk:%s"+(f.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(f){var n="mediaclk:";return n+=f.id!=null?"id=%s %s":"%v%s",n+=f.mediaClockValue!=null?"=%s":"",n+=f.rateNumerator!=null?" rate=%s":"",n+=f.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(Tn).forEach(function(f){var n=Tn[f];n.forEach(function(s){s.reg||(s.reg=/(.*)/),s.format||(s.format="%s")})});var Gs=gn.exports;(function(f){var n=function(p){return String(Number(p))===p?Number(p):p},s=function(p,a,g,m){if(m&&!g)a[m]=n(p[1]);else for(var S=0;S<g.length;S+=1)p[S+1]!=null&&(a[g[S]]=n(p[S+1]))},o=function(p,a,g){var m=p.name&&p.names;p.push&&!a[p.push]?a[p.push]=[]:m&&!a[p.name]&&(a[p.name]={});var S=p.push?{}:m?a[p.name]:a;s(g.match(p.reg),S,p.names,p.name),p.push&&a[p.push].push(S)},c=Gs,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);f.parse=function(p){var a={},g=[],m=a;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(S){var O=S[0],H=S.slice(2);O==="m"&&(g.push({rtp:[],fmtp:[]}),m=g[g.length-1]);for(var B=0;B<(c[O]||[]).length;B+=1){var k=c[O][B];if(k.reg.test(H))return o(k,m,H)}}),a.media=g,a};var d=function(p,a){var g=a.split(/=(.+)/,2);return g.length===2?p[g[0]]=n(g[1]):g.length===1&&a.length>1&&(p[g[0]]=void 0),p};f.parseParams=function(p){return p.split(/;\s?/).reduce(d,{})},f.parseFmtpConfig=f.parseParams,f.parsePayloads=function(p){return p.toString().split(" ").map(Number)},f.parseRemoteCandidates=function(p){for(var a=[],g=p.split(" ").map(n),m=0;m<g.length;m+=3)a.push({component:g[m],ip:g[m+1],port:g[m+2]});return a},f.parseImageAttributes=function(p){return p.split(" ").map(function(a){return a.substring(1,a.length-1).split(",").reduce(d,{})})},f.parseSimulcastStreamList=function(p){return p.split(";").map(function(a){return a.split(",").map(function(g){var m,S=!1;return g[0]!=="~"?m=n(g):(m=n(g.substring(1,g.length)),S=!0),{scid:m,paused:S}})})}})(mn);var Bs=Gs,da=/%[sdv%]/g,_a=function(f){var n=1,s=arguments,o=s.length;return f.replace(da,function(c){if(n>=o)return c;var t=s[n];switch(n+=1,c){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},xt=function(f,n,s){var o=n.format instanceof Function?n.format(n.push?s:s[n.name]):n.format,c=[f+"="+o];if(n.names)for(var t=0;t<n.names.length;t+=1){var d=n.names[t];n.name?c.push(s[n.name][d]):c.push(s[n.names[t]])}else c.push(s[n.name]);return _a.apply(null,c)},pa=["v","o","s","i","u","e","p","c","b","t","r","z","a"],ma=["i","c","b","a"],ga=function(f,n){n=n||{},f.version==null&&(f.version=0),f.name==null&&(f.name=" "),f.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var s=n.outerOrder||pa,o=n.innerOrder||ma,c=[];return s.forEach(function(t){Bs[t].forEach(function(d){d.name in f&&f[d.name]!=null?c.push(xt(t,d,f)):d.push in f&&f[d.push]!=null&&f[d.push].forEach(function(p){c.push(xt(t,d,p))})})}),f.media.forEach(function(t){c.push(xt("m",Bs.m[0],t)),o.forEach(function(d){Bs[d].forEach(function(p){p.name in t&&t[p.name]!=null?c.push(xt(d,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(a){c.push(xt(d,p,a))})})})}),c.join(`\r
5
5
  `)+`\r
6
- `},lt=dn,ma=pa,ga=Gs;Pe.grammar=ga,Pe.write=ma,Pe.parse=lt.parse,Pe.parseParams=lt.parseParams,Pe.parseFmtpConfig=lt.parseFmtpConfig,Pe.parsePayloads=lt.parsePayloads,Pe.parseRemoteCandidates=lt.parseRemoteCandidates,Pe.parseImageAttributes=lt.parseImageAttributes,Pe.parseSimulcastStreamList=lt.parseSimulcastStreamList;const mn=Pe,Ta=pe,Ae=oe,me=Ce(),gn=Ps(),Ea=$e(),Ws=new Ta("SIPMessage");class ns{constructor(n,s,o,c,t,d){if(!n||!s||!o)return null;c=c||{},this.ua=o,this.headers={},this.method=n,this.ruri=s,this.body=d,this.extraHeaders=me.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),c.route_set?this.setHeader("route",c.route_set):o.configuration.use_preloaded_route&&this.setHeader("route",`<${o.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",Ae.MAX_FORWARDS);const p=c.to_uri||s,a=c.to_tag?{tag:c.to_tag}:null,T=typeof c.to_display_name<"u"?c.to_display_name:null;this.to=new gn(p,T,a),this.setHeader("to",this.to.toString());const m=c.from_uri||o.configuration.uri,S={tag:c.from_tag||me.newTag()};let O;typeof c.from_display_name<"u"?O=c.from_display_name:o.configuration.display_name?O=o.configuration.display_name:O=null,this.from=new gn(m,O,S),this.setHeader("from",this.from.toString());const H=c.call_id||o.configuration.jssip_id+me.createRandomToken(15);this.call_id=H,this.setHeader("call-id",H);const B=c.cseq||Math.floor(Math.random()*1e4);this.cseq=B,this.setHeader("cseq",`${B} ${n}`)}setHeader(n,s){const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(let c=0;c<this.extraHeaders.length;c++)o.test(this.extraHeaders[c])&&this.extraHeaders.splice(c,1);this.headers[me.headerize(n)]=Array.isArray(s)?s:[s]}getHeader(n){const s=this.headers[me.headerize(n)];if(s){if(s[0])return s[0]}else{const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(const c of this.extraHeaders)if(o.test(c))return c.substring(c.indexOf(":")+1).trim()}}getHeaders(n){const s=this.headers[me.headerize(n)],o=[];if(s){for(const c of s)o.push(c);return o}else{const c=new RegExp(`^\\s*${n}\\s*:`,"i");for(const t of this.extraHeaders)c.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(n){if(this.headers[me.headerize(n)])return!0;{const s=new RegExp(`^\\s*${n}\\s*:`,"i");for(const o of this.extraHeaders)if(s.test(o))return!0}return!1}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=mn.parse(this.body||""),this.sdp)}toString(){let n=`${this.method} ${this.ruri} SIP/2.0\r
6
+ `},lt=mn,Ta=ga,Ea=Gs;Pe.grammar=Ea,Pe.write=Ta,Pe.parse=lt.parse,Pe.parseParams=lt.parseParams,Pe.parseFmtpConfig=lt.parseFmtpConfig,Pe.parsePayloads=lt.parsePayloads,Pe.parseRemoteCandidates=lt.parseRemoteCandidates,Pe.parseImageAttributes=lt.parseImageAttributes,Pe.parseSimulcastStreamList=lt.parseSimulcastStreamList;const En=Pe,Sa=pe,Ae=oe,me=Ce(),Sn=Ps(),Ca=$e(),Ws=new Sa("SIPMessage");class ns{constructor(n,s,o,c,t,d){if(!n||!s||!o)return null;c=c||{},this.ua=o,this.headers={},this.method=n,this.ruri=s,this.body=d,this.extraHeaders=me.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),c.route_set?this.setHeader("route",c.route_set):o.configuration.use_preloaded_route&&this.setHeader("route",`<${o.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",Ae.MAX_FORWARDS);const p=c.to_uri||s,a=c.to_tag?{tag:c.to_tag}:null,g=typeof c.to_display_name<"u"?c.to_display_name:null;this.to=new Sn(p,g,a),this.setHeader("to",this.to.toString());const m=c.from_uri||o.configuration.uri,S={tag:c.from_tag||me.newTag()};let O;typeof c.from_display_name<"u"?O=c.from_display_name:o.configuration.display_name?O=o.configuration.display_name:O=null,this.from=new Sn(m,O,S),this.setHeader("from",this.from.toString());const H=c.call_id||o.configuration.jssip_id+me.createRandomToken(15);this.call_id=H,this.setHeader("call-id",H);const B=c.cseq||Math.floor(Math.random()*1e4);this.cseq=B,this.setHeader("cseq",`${B} ${n}`)}setHeader(n,s){const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(let c=0;c<this.extraHeaders.length;c++)o.test(this.extraHeaders[c])&&this.extraHeaders.splice(c,1);this.headers[me.headerize(n)]=Array.isArray(s)?s:[s]}getHeader(n){const s=this.headers[me.headerize(n)];if(s){if(s[0])return s[0]}else{const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(const c of this.extraHeaders)if(o.test(c))return c.substring(c.indexOf(":")+1).trim()}}getHeaders(n){const s=this.headers[me.headerize(n)],o=[];if(s){for(const c of s)o.push(c);return o}else{const c=new RegExp(`^\\s*${n}\\s*:`,"i");for(const t of this.extraHeaders)c.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(n){if(this.headers[me.headerize(n)])return!0;{const s=new RegExp(`^\\s*${n}\\s*:`,"i");for(const o of this.extraHeaders)if(s.test(o))return!0}return!1}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=En.parse(this.body||""),this.sdp)}toString(){let n=`${this.method} ${this.ruri} SIP/2.0\r
7
7
  `;for(const c in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,c))for(const t of this.headers[c])n+=`${c}: ${t}\r
8
8
  `;for(const c of this.extraHeaders)n+=`${c.trim()}\r
9
9
  `;const s=[];switch(this.method){case Ae.REGISTER:{s.push("path","gruu");break}case Ae.INVITE:{this.ua.configuration.session_timers&&s.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&s.push("gruu"),s.push("ice","replaces");break}case Ae.UPDATE:{this.ua.configuration.session_timers&&s.push("timer"),s.push("ice");break}}s.push("outbound");const o=this.ua.configuration.user_agent||Ae.USER_AGENT;if(n+=`Allow: ${Ae.ALLOWED_METHODS}\r
@@ -13,25 +13,25 @@
13
13
  \r
14
14
  `,n+=this.body}else n+=`Content-Length: 0\r
15
15
  \r
16
- `;return n}clone(){const n=new ns(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(s){n.headers[s]=this.headers[s].slice()},this),n.body=this.body,n.extraHeaders=me.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n}}class Vs extends ns{constructor(n,s,o,c,t){super(Ae.INVITE,n,s,o,c,t),this.transaction=null}cancel(n){this.transaction.cancel(n)}clone(){const n=new Vs(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(s){n.headers[s]=this.headers[s].slice()},this),n.body=this.body,n.extraHeaders=me.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 Tn{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,s){const o={raw:s};n=me.headerize(n),this.headers[n]?this.headers[n].push(o):this.headers[n]=[o]}getHeader(n){const s=this.headers[me.headerize(n)];if(s){if(s[0])return s[0].raw}else return}getHeaders(n){const s=this.headers[me.headerize(n)],o=[];if(!s)return[];for(const c of s)o.push(c.raw);return o}hasHeader(n){return!!this.headers[me.headerize(n)]}parseHeader(n,s=0){if(n=me.headerize(n),this.headers[n]){if(s>=this.headers[n].length){Ws.debug(`not so many "${n}" headers present`);return}}else{Ws.debug(`header "${n}" not present`);return}const o=this.headers[n][s],c=o.raw;if(o.parsed)return o.parsed;const t=Ea.parse(c,n.replace(/-/g,"_"));if(t===-1){this.headers[n].splice(s,1),Ws.debug(`error parsing "${n}" header field with value "${c}"`);return}else return o.parsed=t,t}s(n,s){return this.parseHeader(n,s)}setHeader(n,s){const o={raw:s};this.headers[me.headerize(n)]=[o]}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=mn.parse(this.body||""),this.sdp)}toString(){return this.data}}class Sa extends Tn{constructor(n){super(),this.ua=n,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(n,s,o,c,t,d){const p=[];let a=this.getHeader("To");if(n=n||null,s=s||null,!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(s&&typeof s!="string"&&!(s instanceof String))throw new TypeError(`Invalid reason_phrase: ${s}`);s=s||Ae.REASON_PHRASE[n]||"",o=me.cloneArray(o),this.ua.configuration.extra_headers&&(o=o.concat(this.ua.configuration.extra_headers));let T=`SIP/2.0 ${n} ${s}\r
17
- `;if(this.method===Ae.INVITE&&n>100&&n<=200){const S=this.getHeaders("record-route");for(const O of S)T+=`Record-Route: ${O}\r
18
- `}const m=this.getHeaders("via");for(const S of m)T+=`Via: ${S}\r
19
- `;!this.to_tag&&n>100?a+=`;tag=${me.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(a+=`;tag=${this.to_tag}`),T+=`To: ${a}\r
20
- `,T+=`From: ${this.getHeader("From")}\r
21
- `,T+=`Call-ID: ${this.call_id}\r
22
- `,T+=`CSeq: ${this.cseq} ${this.method}\r
23
- `;for(const S of o)T+=`${S.trim()}\r
24
- `;switch(this.method){case Ae.INVITE:{this.ua.configuration.session_timers&&p.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&p.push("gruu"),p.push("ice","replaces");break}case Ae.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),c&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===Ae.OPTIONS?(T+=`Allow: ${Ae.ALLOWED_METHODS}\r
25
- `,T+=`Accept: ${Ae.ACCEPTED_BODY_TYPES}\r
26
- `):n===405?T+=`Allow: ${Ae.ALLOWED_METHODS}\r
27
- `:n===415&&(T+=`Accept: ${Ae.ACCEPTED_BODY_TYPES}\r
28
- `),T+=`Supported: ${p}\r
29
- `,c){const S=me.str_utf8_length(c);T+=`Content-Type: application/sdp\r
30
- `,T+=`Content-Length: ${S}\r
16
+ `;return n}clone(){const n=new ns(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(s){n.headers[s]=this.headers[s].slice()},this),n.body=this.body,n.extraHeaders=me.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n}}class Vs extends ns{constructor(n,s,o,c,t){super(Ae.INVITE,n,s,o,c,t),this.transaction=null}cancel(n){this.transaction.cancel(n)}clone(){const n=new Vs(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(s){n.headers[s]=this.headers[s].slice()},this),n.body=this.body,n.extraHeaders=me.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 Cn{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,s){const o={raw:s};n=me.headerize(n),this.headers[n]?this.headers[n].push(o):this.headers[n]=[o]}getHeader(n){const s=this.headers[me.headerize(n)];if(s){if(s[0])return s[0].raw}else return}getHeaders(n){const s=this.headers[me.headerize(n)],o=[];if(!s)return[];for(const c of s)o.push(c.raw);return o}hasHeader(n){return!!this.headers[me.headerize(n)]}parseHeader(n,s=0){if(n=me.headerize(n),this.headers[n]){if(s>=this.headers[n].length){Ws.debug(`not so many "${n}" headers present`);return}}else{Ws.debug(`header "${n}" not present`);return}const o=this.headers[n][s],c=o.raw;if(o.parsed)return o.parsed;const t=Ca.parse(c,n.replace(/-/g,"_"));if(t===-1){this.headers[n].splice(s,1),Ws.debug(`error parsing "${n}" header field with value "${c}"`);return}else return o.parsed=t,t}s(n,s){return this.parseHeader(n,s)}setHeader(n,s){const o={raw:s};this.headers[me.headerize(n)]=[o]}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=En.parse(this.body||""),this.sdp)}toString(){return this.data}}class Aa extends Cn{constructor(n){super(),this.ua=n,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(n,s,o,c,t,d){const p=[];let a=this.getHeader("To");if(n=n||null,s=s||null,!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(s&&typeof s!="string"&&!(s instanceof String))throw new TypeError(`Invalid reason_phrase: ${s}`);s=s||Ae.REASON_PHRASE[n]||"",o=me.cloneArray(o),this.ua.configuration.extra_headers&&(o=o.concat(this.ua.configuration.extra_headers));let g=`SIP/2.0 ${n} ${s}\r
17
+ `;if(this.method===Ae.INVITE&&n>100&&n<=200){const S=this.getHeaders("record-route");for(const O of S)g+=`Record-Route: ${O}\r
18
+ `}const m=this.getHeaders("via");for(const S of m)g+=`Via: ${S}\r
19
+ `;!this.to_tag&&n>100?a+=`;tag=${me.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(a+=`;tag=${this.to_tag}`),g+=`To: ${a}\r
20
+ `,g+=`From: ${this.getHeader("From")}\r
21
+ `,g+=`Call-ID: ${this.call_id}\r
22
+ `,g+=`CSeq: ${this.cseq} ${this.method}\r
23
+ `;for(const S of o)g+=`${S.trim()}\r
24
+ `;switch(this.method){case Ae.INVITE:{this.ua.configuration.session_timers&&p.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&p.push("gruu"),p.push("ice","replaces");break}case Ae.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),c&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===Ae.OPTIONS?(g+=`Allow: ${Ae.ALLOWED_METHODS}\r
25
+ `,g+=`Accept: ${Ae.ACCEPTED_BODY_TYPES}\r
26
+ `):n===405?g+=`Allow: ${Ae.ALLOWED_METHODS}\r
27
+ `:n===415&&(g+=`Accept: ${Ae.ACCEPTED_BODY_TYPES}\r
28
+ `),g+=`Supported: ${p}\r
29
+ `,c){const S=me.str_utf8_length(c);g+=`Content-Type: application/sdp\r
30
+ `,g+=`Content-Length: ${S}\r
31
31
  \r
32
- `,T+=c}else T+=`Content-Length: 0\r
32
+ `,g+=c}else g+=`Content-Length: 0\r
33
33
  \r
34
- `;this.server_transaction.receiveResponse(n,T,t,d)}reply_sl(n=null,s=null){const o=this.getHeaders("via");if(!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(s&&typeof s!="string"&&!(s instanceof String))throw new TypeError(`Invalid reason_phrase: ${s}`);s=s||Ae.REASON_PHRASE[n]||"";let c=`SIP/2.0 ${n} ${s}\r
34
+ `;this.server_transaction.receiveResponse(n,g,t,d)}reply_sl(n=null,s=null){const o=this.getHeaders("via");if(!n||n<100||n>699)throw new TypeError(`Invalid status_code: ${n}`);if(s&&typeof s!="string"&&!(s instanceof String))throw new TypeError(`Invalid reason_phrase: ${s}`);s=s||Ae.REASON_PHRASE[n]||"";let c=`SIP/2.0 ${n} ${s}\r
35
35
  `;for(const d of o)c+=`Via: ${d}\r
36
36
  `;let t=this.getHeader("To");if(!this.to_tag&&n>100?t+=`;tag=${me.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(t+=`;tag=${this.to_tag}`),c+=`To: ${t}\r
37
37
  `,c+=`From: ${this.getHeader("From")}\r
@@ -40,31 +40,31 @@
40
40
  `,this.ua.configuration.extra_headers)for(const d of this.ua.configuration.extra_headers)c+=`${d.trim()}\r
41
41
  `;c+=`Content-Length: 0\r
42
42
  \r
43
- `,this.transport.send(c)}}class Ca extends Tn{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var ke={OutgoingRequest:ns,InitialOutgoingInviteRequest:Vs,IncomingRequest:Sa,IncomingResponse:Ca};const Aa=pe,je=Ce(),Me=new Aa("DigestAuthentication");var va=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:{Me.warn('get() | cannot get "%s" parameter',n);return}}}authenticate({method:n,ruri:s,body:o},c,t=null){if(this._algorithm=c.algorithm,this._realm=c.realm,this._nonce=c.nonce,this._opaque=c.opaque,this._stale=c.stale,this._algorithm){if(this._algorithm!=="MD5")return Me.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Me.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Me.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Me.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Me.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(c.qop)if(c.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(c.qop.indexOf("auth")>-1)this._qop="auth";else return Me.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=n,this._uri=s,this._cnonce=t||je.createRandomToken(12),this._nc+=1;const d=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-d.length)+d,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=je.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,a;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${a}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${je.calculateMD5(o||"")}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${a}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${a}`)),Me.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 Ye=500;var En={T1:Ye,T2:4e3,TIMER_B:64*Ye,TIMER_D:0*Ye,TIMER_F:64*Ye,TIMER_H:64*Ye,TIMER_I:0*Ye,TIMER_J:0*Ye,TIMER_K:0*5e3,TIMER_L:64*Ye,TIMER_M:64*Ye,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Dt=Fe.EventEmitter,Ut=pe,$t=oe,Sn=ke,qe=En,Cn=new Ut("NonInviteClientTransaction"),ls=new Ut("InviteClientTransaction"),Ra=new Ut("AckClientTransaction"),An=new Ut("NonInviteServerTransaction"),is=new Ut("InviteServerTransaction"),D={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 Ia extends Dt{constructor(n,s,o,c){super(),this.type=D.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=s,this.request=o,this.eventHandlers=c;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(D.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},qe.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){Cn.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){Cn.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(n){const s=n.status_code;if(s<200)switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}}else switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(n),this.K=setTimeout(()=>{this.timer_K()},qe.TIMER_K);break}case D.STATUS_COMPLETED:break}}}class ba extends Dt{constructor(n,s,o,c){super(),this.type=D.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=s,this.request=o,this.eventHandlers=c,o.transaction=this;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(D.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},qe.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==D.STATUS_ACCEPTED&&(ls.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){ls.debug(`Timer M expired for transaction ${this.id}`),this.state===D.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){ls.debug(`Timer B expired for transaction ${this.id}`),this.state===D.STATUS_CALLING&&(this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){ls.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(n){const s=new Sn.OutgoingRequest($t.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",n.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},qe.TIMER_D),this.transport.send(s)}cancel(n){if(this.state!==D.STATUS_PROCEEDING)return;const s=new Sn.OutgoingRequest($t.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",this.request.getHeader("to")),n&&s.setHeader("reason",n),this.transport.send(s)}receiveResponse(n){const s=n.status_code;if(s>=100&&s<=199)switch(this.state){case D.STATUS_CALLING:{this.stateChanged(D.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_PROCEEDING:{this.eventHandlers.onReceiveResponse(n);break}}else if(s>=200&&s<=299)switch(this.state){case D.STATUS_CALLING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},qe.TIMER_M),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_ACCEPTED:{this.eventHandlers.onReceiveResponse(n);break}}else if(s>=300&&s<=699)switch(this.state){case D.STATUS_CALLING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),this.sendACK(n),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_COMPLETED:{this.sendACK(n);break}}}}class wa extends Dt{constructor(n,s,o,c){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=s,this.request=o,this.eventHandlers=c;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return D}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Ra.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class ya extends Dt{constructor(n,s,o){super(),this.type=D.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=s,this.request=o,this.last_response="",o.server_transaction=this,this.state=D.STATUS_TRYING,n.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_J(){An.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,An.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(n,s,o,c){if(n===100)switch(this.state){case D.STATUS_TRYING:{this.stateChanged(D.STATUS_PROCEEDING),this.transport.send(s)||this.onTransportError();break}case D.STATUS_PROCEEDING:{this.last_response=s,this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}}else if(n>=200&&n<=699)switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),this.last_response=s,this.J=setTimeout(()=>{this.timer_J()},qe.TIMER_J),this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}case D.STATUS_COMPLETED:break}}}class Na extends Dt{constructor(n,s,o){super(),this.type=D.INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=s,this.request=o,this.last_response="",o.server_transaction=this,this.state=D.STATUS_PROCEEDING,n.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_H(){is.debug(`Timer H expired for transaction ${this.id}`),this.state===D.STATUS_COMPLETED&&is.debug("ACK not received, dialog will be terminated"),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){is.debug(`Timer L expired for transaction ${this.id}`),this.state===D.STATUS_ACCEPTED&&(this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,is.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(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(n,s,o,c){if(n>=100&&n<=199)switch(this.state){case D.STATUS_PROCEEDING:{this.transport.send(s)||this.onTransportError(),this.last_response=s;break}}if(n>100&&n<=199&&this.state===D.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},qe.PROVISIONAL_RESPONSE_INTERVAL));else if(n>=200&&n<=299)switch(this.state){case D.STATUS_PROCEEDING:this.stateChanged(D.STATUS_ACCEPTED),this.last_response=s,this.L=setTimeout(()=>{this.timer_L()},qe.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case D.STATUS_ACCEPTED:{this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}}else if(n>=300&&n<=699)switch(this.state){case D.STATUS_PROCEEDING:{this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(s)?(this.stateChanged(D.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},qe.TIMER_H),o&&o()):(this.onTransportError(),c&&c());break}}}}function Oa({_transactions:f},n){let s;switch(n.method){case $t.INVITE:{if(s=f.ist[n.via_branch],s){switch(s.state){case D.STATUS_PROCEEDING:{s.transport.send(s.last_response);break}case D.STATUS_ACCEPTED:break}return!0}break}case $t.ACK:{if(s=f.ist[n.via_branch],s){if(s.state===D.STATUS_ACCEPTED)return!1;if(s.state===D.STATUS_COMPLETED)return s.state=D.STATUS_CONFIRMED,s.I=setTimeout(()=>{s.timer_I()},qe.TIMER_I),!0}else return!1;break}case $t.CANCEL:return s=f.ist[n.via_branch],s?(n.reply_sl(200),s.state!==D.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:{if(s=f.nist[n.via_branch],s){switch(s.state){case D.STATUS_TRYING:break;case D.STATUS_PROCEEDING:case D.STATUS_COMPLETED:{s.transport.send(s.last_response);break}}return!0}break}}}var Pt={C:D,NonInviteClientTransaction:Ia,InviteClientTransaction:ba,AckClientTransaction:wa,NonInviteServerTransaction:ya,InviteServerTransaction:Na,checkTransaction:Oa};const xa=pe,vn=oe,Da=va,js=Pt,Ua=new xa("RequestSender"),Ys={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var At=class{constructor(n,s,o){this._ua=n,this._eventHandlers=o,this._method=s.method,this._request=s,this._auth=null,this._challenged=!1,this._staled=!1;for(const c in Ys)Object.prototype.hasOwnProperty.call(Ys,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=Ys[c]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==vn.BYE||this._method!==vn.ACK)&&this._eventHandlers.onTransportError()}send(){const n={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:s=>{this._receiveResponse(s)}};switch(this._method){case"INVITE":{this.clientTransaction=new js.InviteClientTransaction(this._ua,this._ua.transport,this._request,n);break}case"ACK":{this.clientTransaction=new js.AckClientTransaction(this._ua,this._ua.transport,this._request,n);break}default:this.clientTransaction=new js.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 s,o;const c=n.status_code;if((c===401||c===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(s=n.parseHeader("www-authenticate"),o="authorization"):(s=n.parseHeader("proxy-authenticate"),o="proxy-authorization"),!s){Ua.debug(`${n.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&s.stale===!0){if(this._auth||(this._auth=new Da({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,s)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),s.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(n)}else this._eventHandlers.onReceiveResponse(n)}};const $a=pe,vt=Ce(),it=oe,Rn=ke,In=At,Mt=new $a("Registrator"),as=10;var Pa=class{constructor(n,s){this._reg_id=1,this._ua=n,this._transport=s,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=vt.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)){const o=n[s];this._extraContactParams+=`;${s}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Mt.debug("Register request in progress...");return}const n=vt.cloneArray(this._extraHeaders);let s;this._expires?(s=`${this._contact};expires=${this._expires}${this._extraContactParams}`,n.push(`Expires: ${this._expires}`)):s=`${this._contact}${this._extraContactParams}`,n.push(`Contact: ${s}`);let o=vt.newTag();this._ua.configuration.register_from_tag_trail&&(typeof this._ua.configuration.register_from_tag_trail=="function"?o+=this._ua.configuration.register_from_tag_trail():o+=this._ua.configuration.register_from_tag_trail);const c=new Rn.OutgoingRequest(it.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1,from_tag:o},n),t=new In(this._ua,c,{onRequestTimeout:()=>{this._registrationFailure(null,it.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,it.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:d=>{if(d.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(d.status_code):break;case/^2[0-9]{2}$/.test(d.status_code):{if(this._registering=!1,!d.hasHeader("Contact")){Mt.debug("no Contact header in response to REGISTER, response ignored");break}const p=d.headers.Contact.reduce((S,O)=>S.concat(O.parsed),[]);let a=p.find(S=>this._sipInstance===S.getParam("+sip.instance")&&this._reg_id===parseInt(S.getParam("reg-id")));if(a||(a=p.find(S=>S.uri.user===this._ua.contact.uri.user)),!a){Mt.debug("no Contact header pointing to us, response ignored");break}let T=a.getParam("expires");!T&&d.hasHeader("expires")&&(T=d.getHeader("expires")),T||(T=this._expires),T=Number(T),T<as&&(T=as);const m=T>64?T*1e3/2+Math.floor((T/2-32)*1e3*Math.random()):T*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},m),a.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=a.getParam("temp-gruu").replace(/"/g,"")),a.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=a.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:d}));break}case/^423$/.test(d.status_code):{d.hasHeader("min-expires")?(this._expires=Number(d.getHeader("min-expires")),this._expires<as&&(this._expires=as),this._registering=!1,this.register()):(Mt.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(d,it.causes.SIP_FAILURE_CODE));break}default:{const p=vt.sipErrorCause(d.status_code);this._registrationFailure(d,p)}}}});this._registering=!0,t.send()}unregister(n={}){if(!this._registered){Mt.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const s=vt.cloneArray(this._extraHeaders);n.all?s.push(`Contact: *${this._extraContactParams}`):s.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),s.push("Expires: 0");const o=new Rn.OutgoingRequest(it.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s);new In(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,it.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,it.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 d=vt.sipErrorCause(t.status_code);this._unregistered(t,d)}}}}).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,s){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:s}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:s}))}_unregistered(n,s){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:s||null})}};const Ks=oe,os=Pt,Ma=At,zs={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var La=class{constructor(n,s,o){this._dialog=n,this._ua=n._ua,this._request=s,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(const c in zs)Object.prototype.hasOwnProperty.call(zs,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=zs[c]))}get request(){return this._request}send(){const n=new Ma(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:s=>{this._eventHandlers.onAuthenticated(s)},onReceiveResponse:s=>{this._receiveResponse(s)}});if(n.send(),(this._request.method===Ks.INVITE||this._request.method===Ks.UPDATE&&this._request.body)&&n.clientTransaction.state!==os.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const s=()=>{(n.clientTransaction.state===os.C.STATUS_ACCEPTED||n.clientTransaction.state===os.C.STATUS_COMPLETED||n.clientTransaction.state===os.C.STATUS_TERMINATED)&&(n.clientTransaction.removeListener("stateChanged",s),this._dialog.uac_pending_reply=!1)};n.clientTransaction.on("stateChanged",s)}}_receiveResponse(n){n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===Ks.INVITE&&n.status_code===491?this._reattempt?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 Ha=pe,bn=ke,Ge=oe,Lt=Pt,Fa=La,Xs=Ce(),Js=new Ha("Dialog"),et={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var Qs=class{static get C(){return et}constructor(n,s,o,c=et.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!s.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};s instanceof bn.IncomingResponse&&(c=s.status_code<200?et.STATUS_EARLY:et.STATUS_CONFIRMED);const t=s.parseHeader("contact");o==="UAS"?(this._id={call_id:s.call_id,local_tag:s.to_tag,remote_tag:s.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=c,this._remote_seqnum=s.cseq,this._local_uri=s.parseHeader("to").uri,this._remote_uri=s.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=s.getHeaders("record-route"),this._incoming_ack_seqnum=s.cseq,this._outgoing_ack_seqnum=null):o==="UAC"&&(this._id={call_id:s.call_id,local_tag:s.from_tag,remote_tag:s.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=c,this._local_seqnum=s.cseq,this._local_uri=s.parseHeader("from").uri,this._remote_uri=s.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=s.getHeaders("record-route").reverse(),this._incoming_ack_seqnum=null,this._outgoing_ack_seqnum=this._local_seqnum),this._ua.newDialog(this),Js.debug(`new ${o} dialog created with status ${this._state===et.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===et.STATUS_TERMINATED}update(n,s){this._state=et.STATUS_CONFIRMED,Js.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),s==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){Js.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=et.STATUS_TERMINATED}sendRequest(n,s={}){const o=Xs.cloneArray(s.extraHeaders),c=Xs.cloneObject(s.eventHandlers),t=s.body||null,d=this._createRequest(n,o,t),p=c.onAuthenticated||(()=>{});return c.onAuthenticated=T=>{this._local_seqnum+=1,d.method===Ge.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum),p(T)},new Fa(this,d,c).send(),d}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===Ge.ACK&&this._incoming_ack_seqnum!==null?this._incoming_ack_seqnum=null:n.method===Ge.INVITE&&(this._incoming_ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,s,o){s=Xs.cloneArray(s),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const c=n===Ge.CANCEL||n===Ge.ACK?this._outgoing_ack_seqnum:this._local_seqnum+=1;return n===Ge.INVITE&&(this._outgoing_ack_seqnum=c),new bn.OutgoingRequest(n,this._remote_target,this._ua,{cseq:c,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},s,o)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===Ge.ACK){if(this._incoming_ack_seqnum===null||n.cseq!==this._incoming_ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===Ge.INVITE||n.method===Ge.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const s=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${s}`]),!1}else{this._uas_pending_reply=!0;const s=()=>{(n.server_transaction.state===Lt.C.STATUS_ACCEPTED||n.server_transaction.state===Lt.C.STATUS_COMPLETED||n.server_transaction.state===Lt.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",s),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",s)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Lt.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===Ge.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Lt.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}},Zs={exports:{}};const ka=Fe.EventEmitter,qa=pe,Ga=oe,Ba=He,wn=Ce(),Wa=new qa("RTCSession:DTMF"),yn={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Zs.exports=class extends ka{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,s={}){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&&this._session.status!==this._session.C.STATUS_1XX_RECEIVED)throw new Ba.InvalidStateError(this._session.status);const o=wn.cloneArray(s.extraHeaders);if(this.eventHandlers=wn.cloneObject(s.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=s.duration,o.push("Content-Type: application/dtmf-relay");let c=`Signal=${this._tone}\r
44
- `;c+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(Ga.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:c})}init_incoming(n){const s=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,o=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=n,n.reply(200),n.body){const c=n.body.split(`
45
- `);c.length>=1&&s.test(c[0])&&(this._tone=c[0].replace(s,"$2")),c.length>=2&&o.test(c[1])&&(this._duration=parseInt(c[1].replace(o,"$2"),10))}this._duration||(this._duration=yn.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:n}):Wa.debug("invalid INFO DTMF received, discarded")}},Zs.exports.C=yn;var Va=Zs.exports;const ja=Fe.EventEmitter,Ya=oe,Ka=He,za=Ce();var Xa=class extends ja{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,s,o={}){if(this._direction="outgoing",n===void 0)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new Ka.InvalidStateError(this._session.status);this._contentType=n,this._body=s;const c=za.cloneArray(o.extraHeaders);c.push(`Content-Type: ${n}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(Ya.INFO,{extraHeaders:c,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:s})}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 Ja=pe,Nn=oe,Qa=new Ja("RTCSession:ReferNotifier"),er={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var Za=class{constructor(n,s,o){this._session=n,this._id=s,this._expires=o||er.expires,this._active=!0,this.notify(100)}notify(n,s){if(Qa.debug("notify()"),this._active===!1)return;s=s||Nn.REASON_PHRASE[n]||"";let o;n>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(Nn.NOTIFY,{extraHeaders:[`Event: ${er.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${er.body_type}`],body:`SIP/2.0 ${n} ${s}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const eo=Fe.EventEmitter,to=pe,Ht=oe,so=$e(),On=Ce(),at=new to("RTCSession:ReferSubscriber");var ro=class extends eo{constructor(n){super(),this._id=null,this._session=n}get id(){return this._id}sendRefer(n,s={}){at.debug("sendRefer()");const o=On.cloneArray(s.extraHeaders),c=On.cloneObject(s.eventHandlers);for(const a in c)Object.prototype.hasOwnProperty.call(c,a)&&this.on(a,c[a]);let t=null;s.replaces&&(t=s.replaces._request.call_id,t+=`;to-tag=${s.replaces._to_tag}`,t+=`;from-tag=${s.replaces._from_tag}`,t=encodeURIComponent(t));const d=`Refer-To: <${n}${t?`?Replaces=${t}`:""}>`;if(o.push(d),!o.some(a=>a.toLowerCase().startsWith("referred-by:"))){const a=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;o.push(a)}o.push(`Contact: ${this._session.contact}`);const p=this._session.sendRequest(Ht.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:a=>{this._requestSucceeded(a)},onErrorResponse:a=>{this._requestFailed(a,Ht.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Ht.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Ht.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Ht.causes.DIALOG_ERROR)},onAuthenticated:a=>{this._id=a.cseq,this.emit("authenticated")}}});this._id=p.cseq}receiveNotify(n){if(at.debug("receiveNotify()"),!n.body)return;const s=so.parse(n.body.trim().split(`\r
46
- `,1)[0],"Status_Line");if(s===-1){at.debug(`receiveNotify() | error parsing NOTIFY body: "${n.body}"`);return}switch(!0){case/^100$/.test(s.status_code):{this.emit("trying",{request:n,status_line:s});break}case/^1[0-9]{2}$/.test(s.status_code):{this.emit("progress",{request:n,status_line:s});break}case/^2[0-9]{2}$/.test(s.status_code):{this.emit("accepted",{request:n,status_line:s});break}default:{this.emit("failed",{request:n,status_line:s});break}}}_requestSucceeded(n){at.debug("REFER succeeded"),at.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:n})}_requestFailed(n,s){at.debug("REFER failed"),at.debug('emit "requestFailed"'),this.emit("requestFailed",{response:n||null,cause:s})}};const no=Fe.EventEmitter,xn=Pe,lo=pe,x=oe,ot=He,Dn=Pt,ie=Ce(),Ft=En,io=ke,us=Qs,ao=At,ye=Va,Un=Xa,oo=Za,uo=ro,$n=Ze(),A=new lo("RTCSession"),R={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},cs=["audio","video"];var Pn=class Yr extends no{static get C(){return R}constructor(n){A.debug("new"),super(),this._id=null,this._ua=n,this._status=R.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:x.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return R}get causes(){return x.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 R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:case R.STATUS_INVITE_RECEIVED:case R.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case R.STATUS_ANSWERED:case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case R.STATUS_CANCELED:case R.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,s={},o){A.debug("connect()");const c=n,t=ie.cloneObject(s.eventHandlers),d=ie.cloneArray(s.extraHeaders),p=ie.cloneObject(s.mediaConstraints,{audio:!0,video:!0}),a=s.mediaStream||null,T=ie.cloneObject(s.pcConfig,{iceServers:[]}),m=s.rtcConstraints||null,S=s.rtcOfferConstraints||null;if(this._rtcOfferConstraints=S,this._rtcAnswerConstraints=s.rtcAnswerConstraints||null,this._data=s.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==R.STATUS_NULL)throw new ot.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new ot.NotSupportedError("WebRTC not supported");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${c}`);this._sessionTimers.enabled&&ie.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=x.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=x.SESSION_EXPIRES);for(const B in t)Object.prototype.hasOwnProperty.call(t,B)&&this.on(B,t[B]);this._from_tag=ie.newTag();const O=s.anonymous||!1,H={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:O,outbound:!0}),O?(H.from_display_name="Anonymous",H.from_uri=new $n("sip","anonymous","anonymous.invalid"),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),d.push("Privacy: id")):s.fromUserName&&(H.from_uri=new $n("sip",s.fromUserName,this._ua.configuration.uri.host),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),s.fromDisplayName&&(H.from_display_name=s.fromDisplayName),d.push(`Contact: ${this._contact}`),d.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&d.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new io.InitialOutgoingInviteRequest(n,this._ua,H,d),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(T,m),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,o&&o(this),this._newRTCSession("local",this._request),this._sendInitialRequest(p,S,a)}init_incoming(n,s){A.debug("init_incoming()");let o;const c=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&c!=="application/sdp"){n.reply(415);return}if(this._status=R.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(o=n.getHeader("expires")*1e3),n.to_tag=ie.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=R.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,x.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===R.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,x.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,s&&s(this),this._newRTCSession("remote",n),this._status!==R.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){A.debug("answer()");const s=this._request,o=ie.cloneArray(n.extraHeaders),c=ie.cloneObject(n.mediaConstraints),t=n.mediaStream||null,d=ie.cloneObject(n.pcConfig,{iceServers:[]}),p=n.rtcConstraints||null,a=n.rtcAnswerConstraints||null,T=ie.cloneObject(n.rtcOfferConstraints);let m,S=!1,O=!1,H=!1,B=!1;if(this._rtcAnswerConstraints=a,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new ot.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==R.STATUS_WAITING_FOR_ANSWER)throw new ot.InvalidStateError(this._status);if(this._sessionTimers.enabled&&ie.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=x.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=x.SESSION_EXPIRES),this._status=R.STATUS_ANSWERED,!this._createDialog(s,"UAS")){s.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const k=s.parseSDP();Array.isArray(k.media)||(k.media=[k.media]);for(const U of k.media)U.type==="audio"&&(S=!0,(!U.direction||U.direction==="sendrecv")&&(H=!0)),U.type==="video"&&(O=!0,(!U.direction||U.direction==="sendrecv")&&(B=!0));if(t&&c.audio===!1){m=t.getAudioTracks();for(const U of m)t.removeTrack(U)}if(t&&c.video===!1){m=t.getVideoTracks();for(const U of m)t.removeTrack(U)}!t&&c.audio===void 0&&(c.audio=H),!t&&c.video===void 0&&(c.video=B),!t&&!S&&!T.offerToReceiveAudio&&(c.audio=!1),!t&&!O&&!T.offerToReceiveVideo&&(c.video=!1),this._createRTCConnection(d,p),Promise.resolve().then(()=>{if(t)return t;if(c.audio||c.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(c).catch(U=>{throw this._status===R.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),this._failed("local",null,x.causes.USER_DENIED_MEDIA_ACCESS),A.warn('emit "getusermediafailed" [error:%o]',U),this.emit("getusermediafailed",U),new Error("getUserMedia() failed"))})}).then(U=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=U,U&&U.getTracks().forEach(de=>{this._connection.addTrack(de,U)})}).then(()=>{if(this._late_sdp)return;const U={originator:"remote",type:"offer",sdp:s.body};A.debug('emit "sdp"'),this.emit("sdp",U);const de=new RTCSessionDescription({type:"offer",sdp:U.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(de)).catch(ne=>{throw s.reply(488),this._failed("system",null,x.causes.WEBRTC_ERROR),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',ne),this.emit("peerconnection:setremotedescriptionfailed",ne),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(s),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw s.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",a).catch(()=>{throw s.reply(500),new Error("_createLocalDescription() failed")})}).then(U=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(s,o),s.reply(200,null,o,U,()=>{this._status=R.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,U),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,x.causes.CONNECTION_ERROR)})}).catch(U=>{this._status!==R.STATUS_TERMINATED&&(A.warn(`answer() failed: ${U.message}`),this._failed("system",U.message,x.causes.INTERNAL_ERROR))})}terminate(n={}){A.debug("terminate()");const s=n.cause||x.causes.BYE,o=ie.cloneArray(n.extraHeaders),c=n.body;let t,d=n.status_code,p=n.reason_phrase;if(this._status===R.STATUS_TERMINATED)throw new ot.InvalidStateError(this._status);switch(this._status){case R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:{if(A.debug("canceling session"),d&&(d<200||d>=700))throw new TypeError(`Invalid status_code: ${d}`);d&&(p=p||x.REASON_PHRASE[d]||"",t=`SIP ;cause=${d} ;text="${p}"`),this._status===R.STATUS_NULL||this._status===R.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===R.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=R.STATUS_CANCELED,this._failed("local",null,x.causes.CANCELED);break}case R.STATUS_WAITING_FOR_ANSWER:case R.STATUS_ANSWERED:{if(A.debug("rejecting session"),d=d||480,d<300||d>=700)throw new TypeError(`Invalid status_code: ${d}`);this._request.reply(d,p,o,c),this._failed("local",null,x.causes.REJECTED);break}case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:{if(A.debug("terminating session"),p=n.reason_phrase||x.REASON_PHRASE[d]||"",d&&(d<200||d>=700))throw new TypeError(`Invalid status_code: ${d}`);if(d&&o.push(`Reason: SIP ;cause=${d}; text="${p}"`),this._status===R.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Dn.C.STATUS_TERMINATED){const a=this._dialog;this.receiveRequest=({method:T})=>{T===x.ACK&&(this.sendRequest(x.BYE,{extraHeaders:o,body:c}),a.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Dn.C.STATUS_TERMINATED&&(this.sendRequest(x.BYE,{extraHeaders:o,body:c}),a.terminate())}),this._ended("local",null,s),this._dialog=a,this._ua.newDialog(a)}else this.sendRequest(x.BYE,{extraHeaders:o,body:c}),this._ended("local",null,s)}}}sendDTMF(n,s={}){A.debug("sendDTMF() | tones: %s",n);let o=s.duration||null,c=s.interToneGap||null;const t=s.transportType||x.DTMF_TRANSPORT.INFO;if(n===void 0)throw new TypeError("Not enough arguments");if(this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new ot.InvalidStateError(this._status);if(t!==x.DTMF_TRANSPORT.INFO&&t!==x.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&&!ie.isDecimal(o))throw new TypeError(`Invalid tone duration: ${o}`);if(o?o<ye.C.MIN_DURATION?(A.debug(`"duration" value is lower than the minimum allowed, setting it to ${ye.C.MIN_DURATION} milliseconds`),o=ye.C.MIN_DURATION):o>ye.C.MAX_DURATION?(A.debug(`"duration" value is greater than the maximum allowed, setting it to ${ye.C.MAX_DURATION} milliseconds`),o=ye.C.MAX_DURATION):o=Math.abs(o):o=ye.C.DEFAULT_DURATION,s.duration=o,c&&!ie.isDecimal(c))throw new TypeError(`Invalid interToneGap: ${c}`);if(c?c<ye.C.MIN_INTER_TONE_GAP?(A.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${ye.C.MIN_INTER_TONE_GAP} milliseconds`),c=ye.C.MIN_INTER_TONE_GAP):c=Math.abs(c):c=ye.C.DEFAULT_INTER_TONE_GAP,t===x.DTMF_TRANSPORT.RFC2833){const p=this._getDTMFRTPSender();p&&(n=p.toneBuffer+n,p.insertDTMF(n,o,c));return}if(this._tones){this._tones+=n;return}this._tones=n,d.call(this);function d(){let p;if(this._status===R.STATUS_TERMINATED||!this._tones){this._tones=null;return}const a=this._tones[0];if(this._tones=this._tones.substring(1),a===",")p=2e3;else{const T=new ye(this);s.eventHandlers={onFailed:()=>{this._tones=null}},T.send(a,s),p=o+c}setTimeout(d.bind(this),p)}}sendInfo(n,s,o={}){if(A.debug("sendInfo()"),this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new ot.InvalidStateError(this._status);new Un(this).send(n,s,o)}mute(n={audio:!0,video:!1}){A.debug("mute()");let s=!1,o=!1;this._audioMuted===!1&&n.audio&&(s=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(s===!0||o===!0)&&this._onmute({audio:s,video:o})}unmute(n={audio:!0,video:!0}){A.debug("unmute()");let s=!1,o=!1;this._audioMuted===!0&&n.audio&&(s=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(s===!0||o===!0)&&this._onunmute({audio:s,video:o})}hold(n={},s){if(A.debug("hold()"),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!0||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}unhold(n={},s){if(A.debug("unhold()"),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!1||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},s){A.debug("renegotiate()");const o=n.rtcOfferConstraints||null;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;const c={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:c,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:c,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}),!0}refer(n,s){A.debug("refer()");const o=n;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const c=new uo(this);c.sendRefer(n,s);let t=c.id;return this._referSubscribers[t]=c,c.on("requestFailed",()=>{delete this._referSubscribers[t]}),c.on("accepted",()=>{delete this._referSubscribers[t]}),c.on("failed",()=>{delete this._referSubscribers[t]}),c.on("authenticated",()=>{delete this._referSubscribers[t],t=c.id,this._referSubscribers[t]=c}),c}sendRequest(n,s){if(A.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(n,s);{const o=Object.values(this._earlyDialogs);if(o.length>0)return o[0].sendRequest(n,s);A.warn("sendRequest() | no valid early dialog found");return}}receiveRequest(n){if(A.debug("receiveRequest()"),n.method===x.CANCEL)(this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED)&&(this._status=R.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,x.causes.CANCELED));else switch(n.method){case x.ACK:{if(this._status!==R.STATUS_WAITING_FOR_ACK)return;if(this._status=R.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:x.causes.MISSING_SDP,status_code:400});break}const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(c=>{this.terminate({cause:x.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)})}else this._is_confirmed||this._confirmed("remote",n);break}case x.BYE:{this._status===R.STATUS_CONFIRMED||this._status===R.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,x.causes.BYE)):this._status===R.STATUS_INVITE_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,x.causes.BYE)):n.reply(403,"Wrong Status");break}case x.INVITE:{this._status===R.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break}case x.INFO:{if(this._status===R.STATUS_1XX_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED||this._status===R.STATUS_WAITING_FOR_ACK||this._status===R.STATUS_CONFIRMED){const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;s&&s.match(/^application\/dtmf-relay/i)?new ye(this).init_incoming(n):s!==void 0?new Un(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break}case x.UPDATE:{this._status===R.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break}case x.REFER:{this._status===R.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break}case x.NOTIFY:{this._status===R.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break}default:n.reply(501)}}onTransportError(){A.warn("onTransportError()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:x.causes.CONNECTION_ERROR,cause:x.causes.CONNECTION_ERROR})}onRequestTimeout(){A.warn("onRequestTimeout()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:x.causes.REQUEST_TIMEOUT,cause:x.causes.REQUEST_TIMEOUT})}onDialogError(){A.warn("onDialogError()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:x.causes.DIALOG_ERROR,cause:x.causes.DIALOG_ERROR})}newDTMF(n){A.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){A.debug("newInfo()"),this.emit("newInfo",n)}isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(A.debug("isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(A.debug("isReadyToReOffer() | session not established yet"),!1):(A.debug("isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(A.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(A.debug("close() | closing local MediaStream"),ie.closeMediaStream(this._localMediaStream)),this._status!==R.STATUS_TERMINATED){if(this._status=R.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){A.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,s){let o=Ft.T1;function c(){this._status===R.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],s),o<Ft.T2&&(o=o*2,o>Ft.T2&&(o=Ft.T2)),this._timers.invite2xxTimer=setTimeout(c.bind(this),o))}this._timers.invite2xxTimer=setTimeout(c.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===R.STATUS_WAITING_FOR_ACK&&(A.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(x.BYE),this._ended("remote",null,x.causes.NO_ACK))},Ft.TIMER_H)}_createRTCConnection(n,s){this._connection=new RTCPeerConnection(n,s),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:x.causes.RTP_TIMEOUT,status_code:408,reason_phrase:x.causes.RTP_TIMEOUT})}),A.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,s){if(A.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?o.createOffer(s).catch(c=>(A.warn('emit "peerconnection:createofferfailed" [error:%o]',c),this.emit("peerconnection:createofferfailed",c),Promise.reject(c))):o.createAnswer(s).catch(c=>(A.warn('emit "peerconnection:createanswerfailed" [error:%o]',c),this.emit("peerconnection:createanswerfailed",c),Promise.reject(c)))).then(c=>o.setLocalDescription(c).catch(t=>(this._rtcReady=!0,A.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const c=s&&s.iceRestart;if(o.iceGatheringState==="complete"&&!c||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:n,sdp:o.localDescription.sdp};return A.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let d=!1,p,a;this._iceReady=!1;const T=()=>{if(d)return;o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",a),d=!0,this._rtcReady=!0,this._iceReady=!0;const m={originator:"local",type:n,sdp:o.localDescription.sdp};A.debug('emit "sdp"'),this.emit("sdp",m),t(m.sdp)};o.addEventListener("icecandidate",p=m=>{const S=m.candidate;S?this.emit("icecandidate",{candidate:S,ready:T}):T()}),o.addEventListener("icegatheringstatechange",a=()=>{o.iceGatheringState==="complete"&&T()})})})}_createDialog(n,s,o){const c=s==="UAS"?n.to_tag:n.from_tag,t=s==="UAS"?n.from_tag:n.to_tag,d=n.call_id+c+t;let p=this._earlyDialogs[d];if(o)return p?!0:(p=new us(this,n,s,us.C.STATUS_EARLY),p.error?(A.debug(p.error),this._failed("remote",n,x.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[d]=p,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,p)return p.update(n,s),this._dialog=p,delete this._earlyDialogs[d],!0;const a=new us(this,n,s);return a.error?(A.debug(a.error),this._failed("remote",n,x.causes.INTERNAL_ERROR),!1):(this._dialog=a,!0)}}_receiveReinvite(n){A.debug("receiveReinvite()");const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let c=!1;function t(p={}){c=!0;const a=p.status_code||403,T=p.reason_phrase||"",m=ie.cloneArray(p.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);n.reply(a,T,m)}if(this.emit("reinvite",o),c)return;if(this._late_sdp=!1,!n.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(p=>{d.call(this,p)}).catch(()=>{n.reply(500)});return}if(s!=="application/sdp"){A.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==R.STATUS_TERMINATED&&d.call(this,p)}).catch(p=>{A.warn(p)});function d(p){const a=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,a),this._late_sdp&&(p=this._mangleOffer(p)),n.reply(200,null,a,p,()=>{this._status=R.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(n){A.debug("receiveUpdate()");const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let c=!1;function t(p={}){c=!0;const a=p.status_code||403,T=p.reason_phrase||"",m=ie.cloneArray(p.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);n.reply(a,T,m)}if(this.emit("update",o),c)return;if(!n.body){d.call(this,null);return}if(s!=="application/sdp"){A.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==R.STATUS_TERMINATED&&d.call(this,p)}).catch(p=>{A.warn(p)});function d(p){const a=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,a),n.reply(200,null,a,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(n){A.debug("_processInDialogSdpOffer()");const s=n.parseSDP();let o=!1;for(const d of s.media){if(cs.indexOf(d.type)===-1)continue;const p=d.direction||s.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const c={originator:"remote",type:"offer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",c);const t=new RTCSessionDescription({type:"offer",sdp:c.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(d=>{throw n.reply(488),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),this.emit("peerconnection:setremotedescriptionfailed",d),d})}).then(()=>{if(this._status===R.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===R.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(d=>{throw n.reply(500),A.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',d),d})}).catch(d=>{A.warn("_processInDialogSdpOffer() failed [error: %o]",d)}),this._connectionPromiseQueue}_receiveRefer(n){if(A.debug("receiveRefer()"),!n.refer_to){A.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==x.SIP){A.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const s=new oo(this,n.cseq);A.debug('emit "refer"'),this.emit("refer",{request:n,accept:(t,d)=>{o.call(this,t,d)},reject:()=>{c.call(this)}});function o(t,d={}){if(t=typeof t=="function"?t:null,this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;const p=new Yr(this._ua);if(p.on("progress",({response:T})=>{s.notify(T.status_code,T.reason_phrase)}),p.on("accepted",({response:T})=>{s.notify(T.status_code,T.reason_phrase)}),p.on("_failed",({message:T,cause:m})=>{T?s.notify(T.status_code,T.reason_phrase):s.notify(487,m)}),n.refer_to.uri.hasHeader("replaces")){const T=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));d.extraHeaders=ie.cloneArray(d.extraHeaders),d.extraHeaders.push(`Replaces: ${T}`)}const a=n.refer_to.uri.clone();a.clearHeaders(),p.connect(a,d,t)}function c(){s.notify(603)}}_receiveNotify(n){switch(A.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let s,o;if(n.event.params&&n.event.params.id)s=n.event.params.id,o=this._referSubscribers[s];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!o){n.reply(481,"Subscription does not exist");return}o.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){A.debug("receiveReplaces()");function s(c){if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;const t=new Yr(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(n,c)}function o(){A.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:c=>{s.call(this,c)},reject:()=>{o.call(this)}})}_sendInitialRequest(n,s,o){const c=new ao(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t)}});Promise.resolve().then(()=>{if(o)return o;if(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(t=>{throw this._status===R.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,x.causes.USER_DENIED_MEDIA_ACCESS),A.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=t,t&&t.getTracks().forEach(d=>{this._connection.addTrack(d,t)}),this._connecting(this._request),this._createLocalDescription("offer",s).catch(d=>{throw this._failed("local",null,x.causes.WEBRTC_ERROR),d})}).then(t=>{if(this._is_canceled||this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=R.STATUS_INVITE_SENT,A.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),c.send()}).catch(t=>{this._status!==R.STATUS_TERMINATED&&A.warn(t)})}_getDTMFRTPSender(){const n=this._connection.getSenders().find(s=>s.track&&s.track.kind==="audio");if(!(n&&n.dtmf)){A.warn("sendDTMF() | no local audio track to send DTMF with");return}return n.dtmf}_receiveInviteResponse(n){if(A.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(x.ACK);return}else{const s=new us(this,n,"UAC");if(s.error!==void 0){A.debug(s.error);return}this.sendRequest(x.ACK),this.sendRequest(x.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!==R.STATUS_INVITE_SENT&&this._status!==R.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):{this._status=R.STATUS_1XX_RECEIVED;break}case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){A.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=R.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",n)).catch(c=>{A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=R.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,x.causes.MISSING_SDP),this._failed("remote",n,x.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(c=>this._connection.setLocalDescription(c)).catch(c=>{this._acceptAndTerminate(n,500,c.toString()),this._failed("local",n,x.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(x.ACK),this._confirmed("local",null)}).catch(c=>{this._acceptAndTerminate(n,488,"Not Acceptable Here"),this._failed("remote",n,x.causes.BAD_MEDIA_DESCRIPTION),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)})});break}default:{const s=ie.sipErrorCause(n.status_code);this._failed("remote",n,s)}}}_sendReinvite(n={}){A.debug("sendReinvite()");const s=ie.cloneArray(n.extraHeaders),o=ie.cloneObject(n.eventHandlers),c=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;s.push(`Contact: ${this._contact}`),s.push("Content-Type: application/sdp"),this._sessionTimers.running&&s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",c)).then(a=>{a=this._mangleOffer(a);const T={originator:"local",type:"offer",sdp:a};A.debug('emit "sdp"'),this.emit("sdp",T),this.sendRequest(x.INVITE,{extraHeaders:s,body:a,eventHandlers:{onSuccessResponse:m=>{d.call(this,m),t=!0},onErrorResponse:m=>{p.call(this,m)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function d(a){if(this._status===R.STATUS_TERMINATED||(this.sendRequest(x.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(a),a.body){if(!a.hasHeader("Content-Type")||a.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const T={originator:"remote",type:"answer",sdp:a.body};A.debug('emit "sdp"'),this.emit("sdp",T);const m=new RTCSessionDescription({type:"answer",sdp:T.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(m)).then(()=>{o.succeeded&&o.succeeded(a)}).catch(S=>{p.call(this),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',S),this.emit("peerconnection:setremotedescriptionfailed",S)})}function p(a){o.failed&&o.failed(a)}}_sendUpdate(n={}){A.debug("sendUpdate()");const s=ie.cloneArray(n.extraHeaders),o=ie.cloneObject(n.eventHandlers),c=n.rtcOfferConstraints||this._rtcOfferConstraints||null,t=n.sdpOffer||!1;let d=!1;s.push(`Contact: ${this._contact}`),this._sessionTimers.running&&s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(s.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",c)).then(T=>{T=this._mangleOffer(T);const m={originator:"local",type:"offer",sdp:T};A.debug('emit "sdp"'),this.emit("sdp",m),this.sendRequest(x.UPDATE,{extraHeaders:s,body:T,eventHandlers:{onSuccessResponse:S=>{p.call(this,S),d=!0},onErrorResponse:S=>{a.call(this,S)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{a.call(this)})):this.sendRequest(x.UPDATE,{extraHeaders:s,eventHandlers:{onSuccessResponse:T=>{p.call(this,T)},onErrorResponse:T=>{a.call(this,T)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(T){if(this._status!==R.STATUS_TERMINATED&&!d)if(this._handleSessionTimersInIncomingResponse(T),t){if(T.body){if(!T.hasHeader("Content-Type")||T.getHeader("Content-Type").toLowerCase()!=="application/sdp"){a.call(this);return}}else{a.call(this);return}const m={originator:"remote",type:"answer",sdp:T.body};A.debug('emit "sdp"'),this.emit("sdp",m);const S=new RTCSessionDescription({type:"answer",sdp:m.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(S)).then(()=>{o.succeeded&&o.succeeded(T)}).catch(O=>{a.call(this),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',O),this.emit("peerconnection:setremotedescriptionfailed",O)})}else o.succeeded&&o.succeeded(T)}function a(T){o.failed&&o.failed(T)}}_acceptAndTerminate(n,s,o){A.debug("acceptAndTerminate()");const c=[];s&&(o=o||x.REASON_PHRASE[s]||"",c.push(`Reason: SIP ;cause=${s}; text="${o}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(x.ACK),this.sendRequest(x.BYE,{extraHeaders:c})),this._status=R.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=xn.parse(n),this._localHold&&!this._remoteHold){A.debug("mangleOffer() | me on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction?s.direction==="sendrecv"?s.direction="sendonly":s.direction==="recvonly"&&(s.direction="inactive"):s.direction="sendonly")}else if(this._localHold&&this._remoteHold){A.debug("mangleOffer() | both on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction="inactive")}else if(this._remoteHold){A.debug("mangleOffer() | remote on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction?s.direction==="sendrecv"?s.direction="recvonly":s.direction==="recvonly"&&(s.direction="inactive"):s.direction="recvonly")}return xn.write(n)}_setLocalMediaStatus(){let n=!0,s=!0;(this._localHold||this._remoteHold)&&(n=!1,s=!1),this._audioMuted&&(n=!1),this._videoMuted&&(s=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!s)}_handleSessionTimersInIncomingRequest(n,s){if(!this._sessionTimers.enabled)return;let o;n.session_expires&&n.session_expires>=x.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,o=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let s;n.session_expires&&n.session_expires>=x.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,s=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,s="uac"),this._sessionTimers.refresher=s==="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!==R.STATUS_TERMINATED&&this.isReadyToReOffer()&&(A.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===x.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==R.STATUS_TERMINATED&&(A.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:x.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const s=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of s)o.track.enabled=!n}_toggleMuteVideo(n){const s=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of s)o.track.enabled=!n}_newRTCSession(n,s){A.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:n,session:this,request:s})}_connecting(n){A.debug("session connecting"),A.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,s){A.debug("session progress"),A.debug('emit "progress"'),this.emit("progress",{originator:n,response:s||null})}_accepted(n,s){A.debug("session accepted"),this._start_time=new Date,A.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:s||null})}_confirmed(n,s){A.debug("session confirmed"),this._is_confirmed=!0,A.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:s||null})}_ended(n,s,o){A.debug("session ended"),this._end_time=new Date,this._close(),A.debug('emit "ended"'),this.emit("ended",{originator:n,message:s||null,cause:o})}_failed(n,s,o){A.debug("session failed"),A.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:s||null,cause:o}),this._close(),A.debug('emit "failed"'),this.emit("failed",{originator:n,message:s||null,cause:o})}_onhold(n){A.debug("session onhold"),this._setLocalMediaStatus(),A.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){A.debug("session onunhold"),this._setLocalMediaStatus(),A.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:s}){A.debug("session onmute"),this._setLocalMediaStatus(),A.debug('emit "muted"'),this.emit("muted",{audio:n,video:s})}_onunmute({audio:n,video:s}){A.debug("session onunmute"),this._setLocalMediaStatus(),A.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:s})}};const co=Fe.EventEmitter,fo=He,ho=pe,tr=oe,Ke=Ce(),_o=$e(),po=ke,mo=At,go=Qs,Te=new ho("Subscriber"),Y={SUBSCRIBE_RESPONSE_TIMEOUT:0,SUBSCRIBE_TRANSPORT_ERROR:1,SUBSCRIBE_NON_OK_RESPONSE:2,SUBSCRIBE_WRONG_OK_RESPONSE:3,SUBSCRIBE_AUTHENTICATION_FAILED:4,UNSUBSCRIBE_TIMEOUT:5,FINAL_NOTIFY_RECEIVED:6,WRONG_NOTIFY_RECEIVED:7,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,STATE_INIT:3,STATE_WAITING_NOTIFY:4,DEFAULT_EXPIRES_SEC:900};var To=class extends co{static get C(){return Y}constructor(n,s,o,c,{expires:t,contentType:d,allowEvents:p,params:a,extraHeaders:T}){if(Te.debug("new"),super(),!s)throw new TypeError("Not enough arguments: Missing target");if(!o)throw new TypeError("Not enough arguments: Missing eventName");if(!c)throw new TypeError("Not enough arguments: Missing accept");const m=_o.parse(o,"Event");if(m===-1)throw new TypeError("Missing Event header field");this._ua=n,this._target=s,(!Ke.isDecimal(t)||t<=0)&&(t=Y.DEFAULT_EXPIRES_SEC),this._expires=t,this._content_type=d,this._params=Ke.cloneObject(a),this._params.from_uri||(this._params.from_uri=this._ua.configuration.uri),this._params.from_tag=Ke.newTag(),this._params.to_tag=null,this._params.call_id=Ke.createRandomToken(20),this._params.cseq===void 0&&(this._params.cseq=Math.floor(Math.random()*1e4+1)),this._state=Y.STATE_INIT,this._dialog=null,this._expires_timer=null,this._expires_timestamp=null,this._terminated=!1,this._event_name=m.event,this._event_id=m.params&&m.params.id;let S=this._event_name;if(this._event_id&&(S+=`;id=${this._event_id}`),this._headers=Ke.cloneArray(T),this._headers=this._headers.concat([`Event: ${S}`,`Expires: ${this._expires}`,`Accept: ${c}`]),!this._headers.find(O=>O.startsWith("Contact"))){const O=`Contact: ${this._ua._contact.toString()}`;this._headers.push(O)}p&&this._headers.push(`Allow-Events: ${p}`),this._queue=[],this._data={}}get C(){return Y}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(n){this._data=n}onRequestTimeout(){this._terminateDialog(Y.SUBSCRIBE_RESPONSE_TIMEOUT)}onTransportError(){this._terminateDialog(Y.SUBSCRIBE_TRANSPORT_ERROR)}receiveRequest(n){if(n.method!==tr.NOTIFY){Te.warn("received non-NOTIFY request"),n.reply(405);return}const s=n.parseHeader("Event");if(!s){Te.warn("missing Event header"),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const o=s.event,c=s.params&&s.params.id;if(o!==this._event_name||c!==this._event_id){Te.warn("Event header does not match the one in SUBSCRIBE request"),n.reply(489),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const t=n.parseHeader("subscription-state");if(!t){Te.warn("missing Subscription-State header"),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const d=this._parseSubscriptionState(t.state);if(d===void 0){Te.warn(`Invalid Subscription-State header value: ${t.state}`),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}n.reply(200);const p=this._state;if(p!==Y.STATE_TERMINATED&&d!==Y.STATE_TERMINATED&&(this._state=d,t.expires!==void 0)){const m=t.expires,S=new Date().getTime()+m*1e3;this._expires_timestamp-S>2e3&&(Te.debug("update sending re-SUBSCRIBE time"),this._scheduleSubscribe(m))}p!==Y.STATE_PENDING&&d===Y.STATE_PENDING?(Te.debug('emit "pending"'),this.emit("pending")):p!==Y.STATE_ACTIVE&&d===Y.STATE_ACTIVE&&(Te.debug('emit "active"'),this.emit("active"));const a=n.body,T=d===Y.STATE_TERMINATED;if(a){const m=n.getHeader("content-type");Te.debug('emit "notify"'),this.emit("notify",T,n,a,m)}if(T){const m=t.reason;let S;t.params&&t.params["retry-after"]!==void 0&&(S=parseInt(t.params["retry-after"])),this._terminateDialog(Y.FINAL_NOTIFY_RECEIVED,m,S)}}subscribe(n=null){Te.debug("subscribe()"),this._state===Y.STATE_INIT?this._sendInitialSubscribe(n,this._headers):this._sendSubsequentSubscribe(n,this._headers)}terminate(n=null){if(Te.debug("terminate()"),this._state===Y.STATE_INIT)throw new fo.InvalidStateError(this._state);if(this._terminated)return;this._terminated=!0;const s=this._headers.map(o=>o.startsWith("Expires")?"Expires: 0":o);this._sendSubsequentSubscribe(n,s)}_terminateDialog(n,s=void 0,o=void 0){this._state!==Y.STATE_TERMINATED&&(this._state=Y.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),Te.debug(`emit "terminated" code=${n}`),this.emit("terminated",n,s,o))}_sendInitialSubscribe(n,s){if(n){if(!this._content_type)throw new TypeError("content_type is undefined");s=Ke.cloneArray(s),s.push(`Content-Type: ${this._content_type}`)}this._state=Y.STATE_WAITING_NOTIFY;const o=new po.OutgoingRequest(tr.SUBSCRIBE,this._ua.normalizeTarget(this._target),this._ua,this._params,s,n);new mo(this._ua,o,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onReceiveResponse:t=>{this._receiveSubscribeResponse(t)}}).send()}_sendSubsequentSubscribe(n,s){if(this._state!==Y.STATE_TERMINATED){if(!this._dialog){Te.debug("enqueue subscribe"),this._queue.push({body:n,headers:Ke.cloneArray(s)});return}if(n){if(!this._content_type)throw new TypeError("content_type is undefined");s=Ke.cloneArray(s),s.push(`Content-Type: ${this._content_type}`)}this._dialog.sendRequest(tr.SUBSCRIBE,{body:n,extraHeaders:s,eventHandlers:{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onSuccessResponse:o=>{this._receiveSubscribeResponse(o)},onErrorResponse:o=>{this._receiveSubscribeResponse(o)},onDialogError:o=>{this._receiveSubscribeResponse(o)}}})}}_receiveSubscribeResponse(n){if(this._state!==Y.STATE_TERMINATED)if(n.status_code>=200&&n.status_code<300){if(this._dialog===null){const c=new go(this,n,"UAC");if(c.error){Te.warn(c.error),this._terminateDialog(Y.SUBSCRIBE_WRONG_OK_RESPONSE);return}this._dialog=c,Te.debug('emit "accepted"'),this.emit("accepted");for(const t of this._queue)Te.debug("dequeue subscribe"),this._sendSubsequentSubscribe(t.body,t.headers)}const s=n.getHeader("expires");let o=parseInt(s);(!Ke.isDecimal(o)||o<=0)&&(Te.warn(`response without Expires header, setting a default value of ${Y.DEFAULT_EXPIRES_SEC}`),o=Y.DEFAULT_EXPIRES_SEC),o>0&&this._scheduleSubscribe(o)}else n.status_code===401||n.status_code===407?this._terminateDialog(Y.SUBSCRIBE_AUTHENTICATION_FAILED):n.status_code>=300&&this._terminateDialog(Y.SUBSCRIBE_NON_OK_RESPONSE)}_scheduleSubscribe(n){const s=n>=140?n*1e3/2+Math.floor((n/2-70)*1e3*Math.random()):n*1e3-5e3;this._expires_timestamp=new Date().getTime()+n*1e3,Te.debug(`next SUBSCRIBE will be sent in ${Math.floor(s/1e3)} sec`),clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._expires_timer=null,this._sendSubsequentSubscribe(null,this._headers)},s)}_parseSubscriptionState(n){switch(n){case"pending":return Y.STATE_PENDING;case"active":return Y.STATE_ACTIVE;case"terminated":return Y.STATE_TERMINATED;case"init":return Y.STATE_INIT;case"notify_wait":return Y.STATE_WAITING_NOTIFY;default:return}}};const Eo=Fe.EventEmitter,sr=He,So=pe,rr=oe,fs=Ce(),Co=Qs,De=new So("Notifier"),se={NOTIFY_RESPONSE_TIMEOUT:0,NOTIFY_TRANSPORT_ERROR:1,NOTIFY_NON_OK_RESPONSE:2,NOTIFY_AUTHENTICATION_FAILED:3,FINAL_NOTIFY_SENT:4,UNSUBSCRIBE_RECEIVED:5,SUBSCRIPTION_EXPIRED:6,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,DEFAULT_EXPIRES_SEC:900};var Ao=class Kr extends Eo{static get C(){return se}static init_incoming(n,s){try{Kr.checkSubscribe(n)}catch(o){De.warn("Notifier.init_incoming: invalid request. Error: ",o.message),n.reply(405);return}s()}static checkSubscribe(n){if(!n)throw new TypeError("Not enough arguments. Missing subscribe request");if(n.method!==rr.SUBSCRIBE)throw new TypeError("Invalid method for Subscribe request");if(!n.hasHeader("contact"))throw new TypeError("Missing Contact header in subscribe request");if(!n.hasHeader("event"))throw new TypeError("Missing Event header in subscribe request");const s=n.getHeader("expires");if(s){const o=parseInt(s);if(!fs.isDecimal(o)||o<0)throw new TypeError("Invalid Expires header field in subscribe request")}}constructor(n,s,o,{extraHeaders:c,allowEvents:t,pending:d,defaultExpires:p}){if(De.debug("new"),super(),!o)throw new TypeError("Not enough arguments. Missing contentType");Kr.checkSubscribe(s);const a=s.getHeader("event");this._ua=n,this._initial_subscribe=s,this._expires_timestamp=null,this._expires_timer=null,this._defaultExpires=p||se.DEFAULT_EXPIRES_SEC,this._state=d?se.STATE_PENDING:se.STATE_ACTIVE,this._content_type=o,this._headers=fs.cloneArray(c),this._headers.push(`Event: ${a}`),this._contact=this._headers.find(T=>T.startsWith("Contact")),this._contact||(this._contact=`Contact: ${this._ua._contact.toString()}`,this._headers.push(this._contact)),t&&this._headers.push(`Allow-Events: ${t}`),this._target=s.from.uri.user,s.to_tag=fs.newTag(),this._data={}}get C(){return se}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(n){this._data=n}receiveRequest(n){if(n.method!==rr.SUBSCRIBE){n.reply(405);return}this._setExpires(n),this._dialog||(this._dialog=new Co(this,n,"UAS")),n.reply(200,null,[`Expires: ${this._expires}`,`${this._contact}`]);const s=n.body,o=n.getHeader("content-type"),c=this._expires===0;c||this._setExpiresTimer(),De.debug('emit "subscribe"'),this.emit("subscribe",c,n,s,o),c&&this._terminateDialog(se.UNSUBSCRIBE_RECEIVED)}start(){if(De.debug("start()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);this.receiveRequest(this._initial_subscribe)}setActiveState(){if(De.debug("setActiveState()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);this._state===se.STATE_PENDING&&(this._state=se.STATE_ACTIVE)}notify(n=null){if(De.debug("notify()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);const s=Math.floor((this._expires_timestamp-new Date().getTime())/1e3);s<=0?(this._expires_timer||De.error("expires timer is not set"),clearTimeout(this._expires_timer),this.terminate(n,"timeout")):this._sendNotify([`;expires=${s}`],n)}terminate(n=null,s=null,o=null){if(De.debug("terminate()"),this._state===se.STATE_TERMINATED)return;const c=[];s&&c.push(`;reason=${s}`),o!==null&&c.push(`;retry-after=${o}`),this._sendNotify(c,n,null,"terminated"),this._terminateDialog(s==="timeout"?se.SUBSCRIPTION_EXPIRED:se.FINAL_NOTIFY_SENT)}_terminateDialog(n){this._state!==se.STATE_TERMINATED&&(this._state=se.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),De.debug(`emit "terminated" code=${n}`),this.emit("terminated",n))}_setExpires(n){n.hasHeader("expires")?this._expires=parseInt(n.getHeader("expires")):(this._expires=this._defaultExpires,De.debug(`missing Expires header field, default value set: ${this._expires}`))}_sendNotify(n,s=null,o=null,c=null){if(this._state===se.STATE_TERMINATED){De.warn("final notify already sent");return}let t=`Subscription-State: ${c||this._parseState()}`;for(const p of n)t+=p;let d=fs.cloneArray(this._headers);d.push(t),o&&(d=d.concat(o)),s&&d.push(`Content-Type: ${this._content_type}`),this._dialog.sendRequest(rr.NOTIFY,{body:s,extraHeaders:d,eventHandlers:{onRequestTimeout:()=>{this._terminateDialog(se.NOTIFY_RESPONSE_TIMEOUT)},onTransportError:()=>{this._terminateDialog(se.NOTIFY_TRANSPORT_ERROR)},onErrorResponse:p=>{p.status_code===401||p.status_code===407?this._terminateDialog(se.NOTIFY_AUTHENTICATION_FAILED):this._terminateDialog(se.NOTIFY_NON_OK_RESPONSE)},onDialogError:()=>{this._terminateDialog(se.NOTIFY_NON_OK_RESPONSE)}}})}_setExpiresTimer(){this._expires_timestamp=new Date().getTime()+this._expires*1e3,clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._state!==se.STATE_TERMINATED&&(De.debug('emit "expired"'),this.emit("expired"),this.terminate(null,"timeout"))},this._expires*1e3)}_parseState(){switch(this._state){case se.STATE_PENDING:return"pending";case se.STATE_ACTIVE:return"active";case se.STATE_TERMINATED:return"terminated";default:throw new TypeError("wrong state value")}}};const vo=Fe.EventEmitter,Ro=pe,nr=oe,Io=ke,kt=Ce(),bo=At,Mn=He,wo=Ze(),hs=new Ro("Message");var yo=class extends vo{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,s,o={}){const c=n;if(n===void 0||s===void 0)throw new TypeError("Not enough arguments");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${c}`);const t=kt.cloneArray(o.extraHeaders),d=kt.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",a={};o.fromUserName&&(a.from_uri=new wo("sip",o.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(a.from_display_name=o.fromDisplayName);for(const m in d)Object.prototype.hasOwnProperty.call(d,m)&&this.on(m,d[m]);t.push(`Content-Type: ${p}`),this._request=new Io.OutgoingRequest(nr.MESSAGE,n,this._ua,a,t),s&&(this._request.body=s);const T=new bo(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:m=>{this._receiveResponse(m)}});this._newMessage("local",this._request),T.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 s=kt.cloneArray(n.extraHeaders),o=n.body;if(this._direction!=="incoming")throw new Mn.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,s,o)}reject(n={}){const s=n.status_code||480,o=n.reason_phrase,c=kt.cloneArray(n.extraHeaders),t=n.body;if(this._direction!=="incoming")throw new Mn.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._is_replied=!0,this._request.reply(s,o,c,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):{this._succeeded("remote",n);break}default:{const s=kt.sipErrorCause(n.status_code);this._failed("remote",n,s);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,nr.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,nr.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(n,s){n==="remote"?(this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from):n==="local"&&(this._direction="outgoing",this._local_identity=s.from,this._remote_identity=s.to),this._ua.newMessage(this,{originator:n,message:this,request:s})}_failed(n,s,o){hs.debug("MESSAGE failed"),this._close(),hs.debug('emit "failed"'),this.emit("failed",{originator:n,response:s||null,cause:o})}_succeeded(n,s){hs.debug("MESSAGE succeeded"),this._close(),hs.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:s})}};const No=Fe.EventEmitter,Oo=pe,lr=oe,xo=ke,qt=Ce(),Do=At,Ln=He,ds=new Oo("Options");var Uo=class extends No{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,s,o={}){const c=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: ${c}`);const t=qt.cloneArray(o.extraHeaders),d=qt.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const T in d)Object.prototype.hasOwnProperty.call(d,T)&&this.on(T,d[T]);t.push(`Content-Type: ${p}`),this._request=new xo.OutgoingRequest(lr.OPTIONS,n,this._ua,null,t),s&&(this._request.body=s);const a=new Do(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:T=>{this._receiveResponse(T)}});this._newOptions("local",this._request),a.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 s=qt.cloneArray(n.extraHeaders),o=n.body;if(this._direction!=="incoming")throw new Ln.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,s,o)}reject(n={}){const s=n.status_code||480,o=n.reason_phrase,c=qt.cloneArray(n.extraHeaders),t=n.body;if(this._direction!=="incoming")throw new Ln.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._is_replied=!0,this._request.reply(s,o,c,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):{this._succeeded("remote",n);break}default:{const s=qt.sipErrorCause(n.status_code);this._failed("remote",n,s);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,lr.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,lr.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(n,s){n==="remote"?(this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from):n==="local"&&(this._direction="outgoing",this._local_identity=s.from,this._remote_identity=s.to),this._ua.newOptions(this,{originator:n,message:this,request:s})}_failed(n,s,o){ds.debug("OPTIONS failed"),this._close(),ds.debug('emit "failed"'),this.emit("failed",{originator:n,response:s||null,cause:o})}_succeeded(n,s){ds.debug("OPTIONS succeeded"),this._close(),ds.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:s})}},ir={};const $o=pe,ar=Ce(),Po=$e(),Gt=new $o("Socket");ir.isSocket=f=>{if(Array.isArray(f))return!1;if(typeof f>"u")return Gt.warn("undefined JsSIP.Socket instance"),!1;try{if(!ar.isString(f.url))throw Gt.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ar.isString(f.via_transport))throw Gt.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Po.parse(f.sip_uri,"SIP_URI")===-1)throw Gt.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(!ar.isFunction(f[n]))throw Gt.warn(`missing or invalid JsSIP.Socket method: ${n}`),new Error(`Missing or invalid JsSIP.Socket method: ${n}`)})}catch{return!1}return!0};const Mo=pe,Lo=ir,Hn=oe,Re=new Mo("Transport"),Ue={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Hn.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Hn.CONNECTION_RECOVERY_MAX_INTERVAL}};var Ho=class{constructor(n,s=Ue.recovery_options){Re.debug("new()"),this.status=Ue.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=s,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){Re.warn(`cannot use TextDecoder: ${o}`)}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(o){if(!Lo.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:Ue.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(Re.debug("connect()"),this.isConnected()){Re.debug("Transport is already connected");return}else if(this.isConnecting()){Re.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ue.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(){Re.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ue.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(Re.debug("send()"),!this.isConnected())return Re.warn("unable to send message, transport is not connected"),!1;const s=n.toString();return Re.debug(`sending message:
43
+ `,this.transport.send(c)}}class va extends Cn{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var ke={OutgoingRequest:ns,InitialOutgoingInviteRequest:Vs,IncomingRequest:Aa,IncomingResponse:va};const Ra=pe,je=Ce(),Me=new Ra("DigestAuthentication");var Ia=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:{Me.warn('get() | cannot get "%s" parameter',n);return}}}authenticate({method:n,ruri:s,body:o},c,t=null){if(this._algorithm=c.algorithm,this._realm=c.realm,this._nonce=c.nonce,this._opaque=c.opaque,this._stale=c.stale,this._algorithm){if(this._algorithm!=="MD5")return Me.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Me.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Me.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Me.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Me.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(c.qop)if(c.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(c.qop.indexOf("auth")>-1)this._qop="auth";else return Me.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=n,this._uri=s,this._cnonce=t||je.createRandomToken(12),this._nc+=1;const d=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-d.length)+d,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=je.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,a;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${a}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${je.calculateMD5(o||"")}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${a}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,a=je.calculateMD5(p),Me.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=je.calculateMD5(`${this._ha1}:${this._nonce}:${a}`)),Me.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 Ye=500;var An={T1:Ye,T2:4e3,TIMER_B:64*Ye,TIMER_D:0*Ye,TIMER_F:64*Ye,TIMER_H:64*Ye,TIMER_I:0*Ye,TIMER_J:0*Ye,TIMER_K:0*5e3,TIMER_L:64*Ye,TIMER_M:64*Ye,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Dt=Fe.EventEmitter,Ut=pe,$t=oe,vn=ke,qe=An,Rn=new Ut("NonInviteClientTransaction"),ls=new Ut("InviteClientTransaction"),ba=new Ut("AckClientTransaction"),In=new Ut("NonInviteServerTransaction"),is=new Ut("InviteServerTransaction"),D={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 ya extends Dt{constructor(n,s,o,c){super(),this.type=D.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=s,this.request=o,this.eventHandlers=c;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(D.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},qe.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){Rn.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){Rn.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(n){const s=n.status_code;if(s<200)switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}}else switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(n),this.K=setTimeout(()=>{this.timer_K()},qe.TIMER_K);break}case D.STATUS_COMPLETED:break}}}class wa extends Dt{constructor(n,s,o,c){super(),this.type=D.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=s,this.request=o,this.eventHandlers=c,o.transaction=this;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(D.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},qe.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==D.STATUS_ACCEPTED&&(ls.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){ls.debug(`Timer M expired for transaction ${this.id}`),this.state===D.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){ls.debug(`Timer B expired for transaction ${this.id}`),this.state===D.STATUS_CALLING&&(this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){ls.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(n){const s=new vn.OutgoingRequest($t.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",n.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},qe.TIMER_D),this.transport.send(s)}cancel(n){if(this.state!==D.STATUS_PROCEEDING)return;const s=new vn.OutgoingRequest($t.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",this.request.getHeader("to")),n&&s.setHeader("reason",n),this.transport.send(s)}receiveResponse(n){const s=n.status_code;if(s>=100&&s<=199)switch(this.state){case D.STATUS_CALLING:{this.stateChanged(D.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_PROCEEDING:{this.eventHandlers.onReceiveResponse(n);break}}else if(s>=200&&s<=299)switch(this.state){case D.STATUS_CALLING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},qe.TIMER_M),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_ACCEPTED:{this.eventHandlers.onReceiveResponse(n);break}}else if(s>=300&&s<=699)switch(this.state){case D.STATUS_CALLING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),this.sendACK(n),this.eventHandlers.onReceiveResponse(n);break}case D.STATUS_COMPLETED:{this.sendACK(n);break}}}}class Na extends Dt{constructor(n,s,o,c){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=s,this.request=o,this.eventHandlers=c;let t=`SIP/2.0/${s.via_transport}`;t+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return D}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){ba.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class Oa extends Dt{constructor(n,s,o){super(),this.type=D.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=s,this.request=o,this.last_response="",o.server_transaction=this,this.state=D.STATUS_TRYING,n.newTransaction(this)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_J(){In.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,In.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(n,s,o,c){if(n===100)switch(this.state){case D.STATUS_TRYING:{this.stateChanged(D.STATUS_PROCEEDING),this.transport.send(s)||this.onTransportError();break}case D.STATUS_PROCEEDING:{this.last_response=s,this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}}else if(n>=200&&n<=699)switch(this.state){case D.STATUS_TRYING:case D.STATUS_PROCEEDING:{this.stateChanged(D.STATUS_COMPLETED),this.last_response=s,this.J=setTimeout(()=>{this.timer_J()},qe.TIMER_J),this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}case D.STATUS_COMPLETED:break}}}class xa extends Dt{constructor(n,s,o){super(),this.type=D.INVITE_SERVER,this.id=o.via_branch,this.ua=n,this.transport=s,this.request=o,this.last_response="",o.server_transaction=this,this.state=D.STATUS_PROCEEDING,n.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return D}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_H(){is.debug(`Timer H expired for transaction ${this.id}`),this.state===D.STATUS_COMPLETED&&is.debug("ACK not received, dialog will be terminated"),this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){is.debug(`Timer L expired for transaction ${this.id}`),this.state===D.STATUS_ACCEPTED&&(this.stateChanged(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,is.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(D.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(n,s,o,c){if(n>=100&&n<=199)switch(this.state){case D.STATUS_PROCEEDING:{this.transport.send(s)||this.onTransportError(),this.last_response=s;break}}if(n>100&&n<=199&&this.state===D.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},qe.PROVISIONAL_RESPONSE_INTERVAL));else if(n>=200&&n<=299)switch(this.state){case D.STATUS_PROCEEDING:this.stateChanged(D.STATUS_ACCEPTED),this.last_response=s,this.L=setTimeout(()=>{this.timer_L()},qe.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case D.STATUS_ACCEPTED:{this.transport.send(s)?o&&o():(this.onTransportError(),c&&c());break}}else if(n>=300&&n<=699)switch(this.state){case D.STATUS_PROCEEDING:{this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(s)?(this.stateChanged(D.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},qe.TIMER_H),o&&o()):(this.onTransportError(),c&&c());break}}}}function Da({_transactions:f},n){let s;switch(n.method){case $t.INVITE:{if(s=f.ist[n.via_branch],s){switch(s.state){case D.STATUS_PROCEEDING:{s.transport.send(s.last_response);break}case D.STATUS_ACCEPTED:break}return!0}break}case $t.ACK:{if(s=f.ist[n.via_branch],s){if(s.state===D.STATUS_ACCEPTED)return!1;if(s.state===D.STATUS_COMPLETED)return s.state=D.STATUS_CONFIRMED,s.I=setTimeout(()=>{s.timer_I()},qe.TIMER_I),!0}else return!1;break}case $t.CANCEL:return s=f.ist[n.via_branch],s?(n.reply_sl(200),s.state!==D.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:{if(s=f.nist[n.via_branch],s){switch(s.state){case D.STATUS_TRYING:break;case D.STATUS_PROCEEDING:case D.STATUS_COMPLETED:{s.transport.send(s.last_response);break}}return!0}break}}}var Pt={C:D,NonInviteClientTransaction:ya,InviteClientTransaction:wa,AckClientTransaction:Na,NonInviteServerTransaction:Oa,InviteServerTransaction:xa,checkTransaction:Da};const Ua=pe,bn=oe,$a=Ia,js=Pt,Pa=new Ua("RequestSender"),Ys={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var At=class{constructor(n,s,o){this._ua=n,this._eventHandlers=o,this._method=s.method,this._request=s,this._auth=null,this._challenged=!1,this._staled=!1;for(const c in Ys)Object.prototype.hasOwnProperty.call(Ys,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=Ys[c]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==bn.BYE||this._method!==bn.ACK)&&this._eventHandlers.onTransportError()}send(){const n={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:s=>{this._receiveResponse(s)}};switch(this._method){case"INVITE":{this.clientTransaction=new js.InviteClientTransaction(this._ua,this._ua.transport,this._request,n);break}case"ACK":{this.clientTransaction=new js.AckClientTransaction(this._ua,this._ua.transport,this._request,n);break}default:this.clientTransaction=new js.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 s,o;const c=n.status_code;if((c===401||c===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(s=n.parseHeader("www-authenticate"),o="authorization"):(s=n.parseHeader("proxy-authenticate"),o="proxy-authorization"),!s){Pa.debug(`${n.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&s.stale===!0){if(this._auth||(this._auth=new $a({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,s)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),s.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(n)}else this._eventHandlers.onReceiveResponse(n)}};const Ma=pe,vt=Ce(),it=oe,yn=ke,wn=At,Mt=new Ma("Registrator"),as=10;var La=class{constructor(n,s){this._reg_id=1,this._ua=n,this._transport=s,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=vt.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)){const o=n[s];this._extraContactParams+=`;${s}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Mt.debug("Register request in progress...");return}const n=vt.cloneArray(this._extraHeaders);let s;this._expires?(s=`${this._contact};expires=${this._expires}${this._extraContactParams}`,n.push(`Expires: ${this._expires}`)):s=`${this._contact}${this._extraContactParams}`,n.push(`Contact: ${s}`);let o=vt.newTag();this._ua.configuration.register_from_tag_trail&&(typeof this._ua.configuration.register_from_tag_trail=="function"?o+=this._ua.configuration.register_from_tag_trail():o+=this._ua.configuration.register_from_tag_trail);const c=new yn.OutgoingRequest(it.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1,from_tag:o},n),t=new wn(this._ua,c,{onRequestTimeout:()=>{this._registrationFailure(null,it.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,it.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:d=>{if(d.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(d.status_code):break;case/^2[0-9]{2}$/.test(d.status_code):{if(this._registering=!1,!d.hasHeader("Contact")){Mt.debug("no Contact header in response to REGISTER, response ignored");break}const p=d.headers.Contact.reduce((S,O)=>S.concat(O.parsed),[]);let a=p.find(S=>this._sipInstance===S.getParam("+sip.instance")&&this._reg_id===parseInt(S.getParam("reg-id")));if(a||(a=p.find(S=>S.uri.user===this._ua.contact.uri.user)),!a){Mt.debug("no Contact header pointing to us, response ignored");break}let g=a.getParam("expires");!g&&d.hasHeader("expires")&&(g=d.getHeader("expires")),g||(g=this._expires),g=Number(g),g<as&&(g=as);const m=g>64?g*1e3/2+Math.floor((g/2-32)*1e3*Math.random()):g*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},m),a.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=a.getParam("temp-gruu").replace(/"/g,"")),a.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=a.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:d}));break}case/^423$/.test(d.status_code):{d.hasHeader("min-expires")?(this._expires=Number(d.getHeader("min-expires")),this._expires<as&&(this._expires=as),this._registering=!1,this.register()):(Mt.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(d,it.causes.SIP_FAILURE_CODE));break}default:{const p=vt.sipErrorCause(d.status_code);this._registrationFailure(d,p)}}}});this._registering=!0,t.send()}unregister(n={}){if(!this._registered){Mt.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const s=vt.cloneArray(this._extraHeaders);n.all?s.push(`Contact: *${this._extraContactParams}`):s.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),s.push("Expires: 0");const o=new yn.OutgoingRequest(it.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s);new wn(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,it.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,it.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 d=vt.sipErrorCause(t.status_code);this._unregistered(t,d)}}}}).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,s){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:s}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:s}))}_unregistered(n,s){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:s||null})}};const Ks=oe,os=Pt,Ha=At,zs={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var Fa=class{constructor(n,s,o){this._dialog=n,this._ua=n._ua,this._request=s,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(const c in zs)Object.prototype.hasOwnProperty.call(zs,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=zs[c]))}get request(){return this._request}send(){const n=new Ha(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:s=>{this._eventHandlers.onAuthenticated(s)},onReceiveResponse:s=>{this._receiveResponse(s)}});if(n.send(),(this._request.method===Ks.INVITE||this._request.method===Ks.UPDATE&&this._request.body)&&n.clientTransaction.state!==os.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const s=()=>{(n.clientTransaction.state===os.C.STATUS_ACCEPTED||n.clientTransaction.state===os.C.STATUS_COMPLETED||n.clientTransaction.state===os.C.STATUS_TERMINATED)&&(n.clientTransaction.removeListener("stateChanged",s),this._dialog.uac_pending_reply=!1)};n.clientTransaction.on("stateChanged",s)}}_receiveResponse(n){n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===Ks.INVITE&&n.status_code===491?this._reattempt?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 ka=pe,Nn=ke,Ge=oe,Lt=Pt,qa=Fa,Xs=Ce(),Js=new ka("Dialog"),et={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var Qs=class{static get C(){return et}constructor(n,s,o,c=et.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!s.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};s instanceof Nn.IncomingResponse&&(c=s.status_code<200?et.STATUS_EARLY:et.STATUS_CONFIRMED);const t=s.parseHeader("contact");o==="UAS"?(this._id={call_id:s.call_id,local_tag:s.to_tag,remote_tag:s.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=c,this._remote_seqnum=s.cseq,this._local_uri=s.parseHeader("to").uri,this._remote_uri=s.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=s.getHeaders("record-route"),this._incoming_ack_seqnum=s.cseq,this._outgoing_ack_seqnum=null):o==="UAC"&&(this._id={call_id:s.call_id,local_tag:s.from_tag,remote_tag:s.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=c,this._local_seqnum=s.cseq,this._local_uri=s.parseHeader("from").uri,this._remote_uri=s.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=s.getHeaders("record-route").reverse(),this._incoming_ack_seqnum=null,this._outgoing_ack_seqnum=this._local_seqnum),this._ua.newDialog(this),Js.debug(`new ${o} dialog created with status ${this._state===et.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===et.STATUS_TERMINATED}update(n,s){this._state=et.STATUS_CONFIRMED,Js.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),s==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){Js.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=et.STATUS_TERMINATED}sendRequest(n,s={}){const o=Xs.cloneArray(s.extraHeaders),c=Xs.cloneObject(s.eventHandlers),t=s.body||null,d=this._createRequest(n,o,t),p=c.onAuthenticated||(()=>{});return c.onAuthenticated=g=>{this._local_seqnum+=1,d.method===Ge.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum),p(g)},new qa(this,d,c).send(),d}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===Ge.ACK&&this._incoming_ack_seqnum!==null?this._incoming_ack_seqnum=null:n.method===Ge.INVITE&&(this._incoming_ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,s,o){s=Xs.cloneArray(s),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const c=n===Ge.CANCEL||n===Ge.ACK?this._outgoing_ack_seqnum:this._local_seqnum+=1;return n===Ge.INVITE&&(this._outgoing_ack_seqnum=c),new Nn.OutgoingRequest(n,this._remote_target,this._ua,{cseq:c,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},s,o)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===Ge.ACK){if(this._incoming_ack_seqnum===null||n.cseq!==this._incoming_ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===Ge.INVITE||n.method===Ge.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const s=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${s}`]),!1}else{this._uas_pending_reply=!0;const s=()=>{(n.server_transaction.state===Lt.C.STATUS_ACCEPTED||n.server_transaction.state===Lt.C.STATUS_COMPLETED||n.server_transaction.state===Lt.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",s),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",s)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Lt.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===Ge.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Lt.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}},Zs={exports:{}};const Ga=Fe.EventEmitter,Ba=pe,Wa=oe,Va=He,On=Ce(),ja=new Ba("RTCSession:DTMF"),xn={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Zs.exports=class extends Ga{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,s={}){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&&this._session.status!==this._session.C.STATUS_1XX_RECEIVED)throw new Va.InvalidStateError(this._session.status);const o=On.cloneArray(s.extraHeaders);if(this.eventHandlers=On.cloneObject(s.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=s.duration,o.push("Content-Type: application/dtmf-relay");let c=`Signal=${this._tone}\r
44
+ `;c+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(Wa.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:c})}init_incoming(n){const s=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,o=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=n,n.reply(200),n.body){const c=n.body.split(`
45
+ `);c.length>=1&&s.test(c[0])&&(this._tone=c[0].replace(s,"$2")),c.length>=2&&o.test(c[1])&&(this._duration=parseInt(c[1].replace(o,"$2"),10))}this._duration||(this._duration=xn.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:n}):ja.debug("invalid INFO DTMF received, discarded")}},Zs.exports.C=xn;var Ya=Zs.exports;const Ka=Fe.EventEmitter,za=oe,Xa=He,Ja=Ce();var Qa=class extends Ka{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,s,o={}){if(this._direction="outgoing",n===void 0)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new Xa.InvalidStateError(this._session.status);this._contentType=n,this._body=s;const c=Ja.cloneArray(o.extraHeaders);c.push(`Content-Type: ${n}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(za.INFO,{extraHeaders:c,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:s})}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 Za=pe,Dn=oe,eo=new Za("RTCSession:ReferNotifier"),er={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var to=class{constructor(n,s,o){this._session=n,this._id=s,this._expires=o||er.expires,this._active=!0,this.notify(100)}notify(n,s){if(eo.debug("notify()"),this._active===!1)return;s=s||Dn.REASON_PHRASE[n]||"";let o;n>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(Dn.NOTIFY,{extraHeaders:[`Event: ${er.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${er.body_type}`],body:`SIP/2.0 ${n} ${s}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const so=Fe.EventEmitter,ro=pe,Ht=oe,no=$e(),Un=Ce(),at=new ro("RTCSession:ReferSubscriber");var lo=class extends so{constructor(n){super(),this._id=null,this._session=n}get id(){return this._id}sendRefer(n,s={}){at.debug("sendRefer()");const o=Un.cloneArray(s.extraHeaders),c=Un.cloneObject(s.eventHandlers);for(const a in c)Object.prototype.hasOwnProperty.call(c,a)&&this.on(a,c[a]);let t=null;s.replaces&&(t=s.replaces._request.call_id,t+=`;to-tag=${s.replaces._to_tag}`,t+=`;from-tag=${s.replaces._from_tag}`,t=encodeURIComponent(t));const d=`Refer-To: <${n}${t?`?Replaces=${t}`:""}>`;if(o.push(d),!o.some(a=>a.toLowerCase().startsWith("referred-by:"))){const a=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;o.push(a)}o.push(`Contact: ${this._session.contact}`);const p=this._session.sendRequest(Ht.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:a=>{this._requestSucceeded(a)},onErrorResponse:a=>{this._requestFailed(a,Ht.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Ht.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Ht.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Ht.causes.DIALOG_ERROR)},onAuthenticated:a=>{this._id=a.cseq,this.emit("authenticated")}}});this._id=p.cseq}receiveNotify(n){if(at.debug("receiveNotify()"),!n.body)return;const s=no.parse(n.body.trim().split(`\r
46
+ `,1)[0],"Status_Line");if(s===-1){at.debug(`receiveNotify() | error parsing NOTIFY body: "${n.body}"`);return}switch(!0){case/^100$/.test(s.status_code):{this.emit("trying",{request:n,status_line:s});break}case/^1[0-9]{2}$/.test(s.status_code):{this.emit("progress",{request:n,status_line:s});break}case/^2[0-9]{2}$/.test(s.status_code):{this.emit("accepted",{request:n,status_line:s});break}default:{this.emit("failed",{request:n,status_line:s});break}}}_requestSucceeded(n){at.debug("REFER succeeded"),at.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:n})}_requestFailed(n,s){at.debug("REFER failed"),at.debug('emit "requestFailed"'),this.emit("requestFailed",{response:n||null,cause:s})}};const io=Fe.EventEmitter,$n=Pe,ao=pe,x=oe,ot=He,Pn=Pt,ie=Ce(),Ft=An,oo=ke,us=Qs,uo=At,we=Ya,Mn=Qa,co=to,fo=lo,Ln=Ze(),A=new ao("RTCSession"),R={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},cs=["audio","video"];var Hn=class Xr extends io{static get C(){return R}constructor(n){A.debug("new"),super(),this._id=null,this._ua=n,this._status=R.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:x.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return R}get causes(){return x.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 R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:case R.STATUS_INVITE_RECEIVED:case R.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case R.STATUS_ANSWERED:case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case R.STATUS_CANCELED:case R.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,s={},o){A.debug("connect()");const c=n,t=ie.cloneObject(s.eventHandlers),d=ie.cloneArray(s.extraHeaders),p=ie.cloneObject(s.mediaConstraints,{audio:!0,video:!0}),a=s.mediaStream||null,g=ie.cloneObject(s.pcConfig,{iceServers:[]}),m=s.rtcConstraints||null,S=s.rtcOfferConstraints||null;if(this._rtcOfferConstraints=S,this._rtcAnswerConstraints=s.rtcAnswerConstraints||null,this._data=s.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==R.STATUS_NULL)throw new ot.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new ot.NotSupportedError("WebRTC not supported");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${c}`);this._sessionTimers.enabled&&ie.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=x.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=x.SESSION_EXPIRES);for(const B in t)Object.prototype.hasOwnProperty.call(t,B)&&this.on(B,t[B]);this._from_tag=ie.newTag();const O=s.anonymous||!1,H={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:O,outbound:!0}),O?(H.from_display_name="Anonymous",H.from_uri=new Ln("sip","anonymous","anonymous.invalid"),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),d.push("Privacy: id")):s.fromUserName&&(H.from_uri=new Ln("sip",s.fromUserName,this._ua.configuration.uri.host),d.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),s.fromDisplayName&&(H.from_display_name=s.fromDisplayName),d.push(`Contact: ${this._contact}`),d.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&d.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new oo.InitialOutgoingInviteRequest(n,this._ua,H,d),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(g,m),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,o&&o(this),this._newRTCSession("local",this._request),this._sendInitialRequest(p,S,a)}init_incoming(n,s){A.debug("init_incoming()");let o;const c=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&c!=="application/sdp"){n.reply(415);return}if(this._status=R.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(o=n.getHeader("expires")*1e3),n.to_tag=ie.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=R.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,x.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===R.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,x.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,s&&s(this),this._newRTCSession("remote",n),this._status!==R.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){A.debug("answer()");const s=this._request,o=ie.cloneArray(n.extraHeaders),c=ie.cloneObject(n.mediaConstraints),t=n.mediaStream||null,d=ie.cloneObject(n.pcConfig,{iceServers:[]}),p=n.rtcConstraints||null,a=n.rtcAnswerConstraints||null,g=ie.cloneObject(n.rtcOfferConstraints);let m,S=!1,O=!1,H=!1,B=!1;if(this._rtcAnswerConstraints=a,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new ot.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==R.STATUS_WAITING_FOR_ANSWER)throw new ot.InvalidStateError(this._status);if(this._sessionTimers.enabled&&ie.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=x.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=x.SESSION_EXPIRES),this._status=R.STATUS_ANSWERED,!this._createDialog(s,"UAS")){s.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const k=s.parseSDP();Array.isArray(k.media)||(k.media=[k.media]);for(const U of k.media)U.type==="audio"&&(S=!0,(!U.direction||U.direction==="sendrecv")&&(H=!0)),U.type==="video"&&(O=!0,(!U.direction||U.direction==="sendrecv")&&(B=!0));if(t&&c.audio===!1){m=t.getAudioTracks();for(const U of m)t.removeTrack(U)}if(t&&c.video===!1){m=t.getVideoTracks();for(const U of m)t.removeTrack(U)}!t&&c.audio===void 0&&(c.audio=H),!t&&c.video===void 0&&(c.video=B),!t&&!S&&!g.offerToReceiveAudio&&(c.audio=!1),!t&&!O&&!g.offerToReceiveVideo&&(c.video=!1),this._createRTCConnection(d,p),Promise.resolve().then(()=>{if(t)return t;if(c.audio||c.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(c).catch(U=>{throw this._status===R.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),this._failed("local",null,x.causes.USER_DENIED_MEDIA_ACCESS),A.warn('emit "getusermediafailed" [error:%o]',U),this.emit("getusermediafailed",U),new Error("getUserMedia() failed"))})}).then(U=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=U,U&&U.getTracks().forEach(de=>{this._connection.addTrack(de,U)})}).then(()=>{if(this._late_sdp)return;const U={originator:"remote",type:"offer",sdp:s.body};A.debug('emit "sdp"'),this.emit("sdp",U);const de=new RTCSessionDescription({type:"offer",sdp:U.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(de)).catch(ne=>{throw s.reply(488),this._failed("system",null,x.causes.WEBRTC_ERROR),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',ne),this.emit("peerconnection:setremotedescriptionfailed",ne),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(s),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw s.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",a).catch(()=>{throw s.reply(500),new Error("_createLocalDescription() failed")})}).then(U=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(s,o),s.reply(200,null,o,U,()=>{this._status=R.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,U),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,x.causes.CONNECTION_ERROR)})}).catch(U=>{this._status!==R.STATUS_TERMINATED&&(A.warn(`answer() failed: ${U.message}`),this._failed("system",U.message,x.causes.INTERNAL_ERROR))})}terminate(n={}){A.debug("terminate()");const s=n.cause||x.causes.BYE,o=ie.cloneArray(n.extraHeaders),c=n.body;let t,d=n.status_code,p=n.reason_phrase;if(this._status===R.STATUS_TERMINATED)throw new ot.InvalidStateError(this._status);switch(this._status){case R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:{if(A.debug("canceling session"),d&&(d<200||d>=700))throw new TypeError(`Invalid status_code: ${d}`);d&&(p=p||x.REASON_PHRASE[d]||"",t=`SIP ;cause=${d} ;text="${p}"`),this._status===R.STATUS_NULL||this._status===R.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===R.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=R.STATUS_CANCELED,this._failed("local",null,x.causes.CANCELED);break}case R.STATUS_WAITING_FOR_ANSWER:case R.STATUS_ANSWERED:{if(A.debug("rejecting session"),d=d||480,d<300||d>=700)throw new TypeError(`Invalid status_code: ${d}`);this._request.reply(d,p,o,c),this._failed("local",null,x.causes.REJECTED);break}case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:{if(A.debug("terminating session"),p=n.reason_phrase||x.REASON_PHRASE[d]||"",d&&(d<200||d>=700))throw new TypeError(`Invalid status_code: ${d}`);if(d&&o.push(`Reason: SIP ;cause=${d}; text="${p}"`),this._status===R.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Pn.C.STATUS_TERMINATED){const a=this._dialog;this.receiveRequest=({method:g})=>{g===x.ACK&&(this.sendRequest(x.BYE,{extraHeaders:o,body:c}),a.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Pn.C.STATUS_TERMINATED&&(this.sendRequest(x.BYE,{extraHeaders:o,body:c}),a.terminate())}),this._ended("local",null,s),this._dialog=a,this._ua.newDialog(a)}else this.sendRequest(x.BYE,{extraHeaders:o,body:c}),this._ended("local",null,s)}}}sendDTMF(n,s={}){A.debug("sendDTMF() | tones: %s",n);let o=s.duration||null,c=s.interToneGap||null;const t=s.transportType||x.DTMF_TRANSPORT.INFO;if(n===void 0)throw new TypeError("Not enough arguments");if(this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new ot.InvalidStateError(this._status);if(t!==x.DTMF_TRANSPORT.INFO&&t!==x.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&&!ie.isDecimal(o))throw new TypeError(`Invalid tone duration: ${o}`);if(o?o<we.C.MIN_DURATION?(A.debug(`"duration" value is lower than the minimum allowed, setting it to ${we.C.MIN_DURATION} milliseconds`),o=we.C.MIN_DURATION):o>we.C.MAX_DURATION?(A.debug(`"duration" value is greater than the maximum allowed, setting it to ${we.C.MAX_DURATION} milliseconds`),o=we.C.MAX_DURATION):o=Math.abs(o):o=we.C.DEFAULT_DURATION,s.duration=o,c&&!ie.isDecimal(c))throw new TypeError(`Invalid interToneGap: ${c}`);if(c?c<we.C.MIN_INTER_TONE_GAP?(A.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${we.C.MIN_INTER_TONE_GAP} milliseconds`),c=we.C.MIN_INTER_TONE_GAP):c=Math.abs(c):c=we.C.DEFAULT_INTER_TONE_GAP,t===x.DTMF_TRANSPORT.RFC2833){const p=this._getDTMFRTPSender();p&&(n=p.toneBuffer+n,p.insertDTMF(n,o,c));return}if(this._tones){this._tones+=n;return}this._tones=n,d.call(this);function d(){let p;if(this._status===R.STATUS_TERMINATED||!this._tones){this._tones=null;return}const a=this._tones[0];if(this._tones=this._tones.substring(1),a===",")p=2e3;else{const g=new we(this);s.eventHandlers={onFailed:()=>{this._tones=null}},g.send(a,s),p=o+c}setTimeout(d.bind(this),p)}}sendInfo(n,s,o={}){if(A.debug("sendInfo()"),this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new ot.InvalidStateError(this._status);new Mn(this).send(n,s,o)}mute(n={audio:!0,video:!1}){A.debug("mute()");let s=!1,o=!1;this._audioMuted===!1&&n.audio&&(s=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(s===!0||o===!0)&&this._onmute({audio:s,video:o})}unmute(n={audio:!0,video:!0}){A.debug("unmute()");let s=!1,o=!1;this._audioMuted===!0&&n.audio&&(s=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(s===!0||o===!0)&&this._onunmute({audio:s,video:o})}hold(n={},s){if(A.debug("hold()"),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!0||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}unhold(n={},s){if(A.debug("unhold()"),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!1||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},s){A.debug("renegotiate()");const o=n.rtcOfferConstraints||null;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;const c={succeeded:()=>{s&&s()},failed:()=>{this.terminate({cause:x.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:c,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:c,rtcOfferConstraints:o,extraHeaders:n.extraHeaders}),!0}refer(n,s){A.debug("refer()");const o=n;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const c=new fo(this);c.sendRefer(n,s);let t=c.id;return this._referSubscribers[t]=c,c.on("requestFailed",()=>{delete this._referSubscribers[t]}),c.on("accepted",()=>{delete this._referSubscribers[t]}),c.on("failed",()=>{delete this._referSubscribers[t]}),c.on("authenticated",()=>{delete this._referSubscribers[t],t=c.id,this._referSubscribers[t]=c}),c}sendRequest(n,s){if(A.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(n,s);{const o=Object.values(this._earlyDialogs);if(o.length>0)return o[0].sendRequest(n,s);A.warn("sendRequest() | no valid early dialog found");return}}receiveRequest(n){if(A.debug("receiveRequest()"),n.method===x.CANCEL)(this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED)&&(this._status=R.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,x.causes.CANCELED));else switch(n.method){case x.ACK:{if(this._status!==R.STATUS_WAITING_FOR_ACK)return;if(this._status=R.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:x.causes.MISSING_SDP,status_code:400});break}const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(c=>{this.terminate({cause:x.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)})}else this._is_confirmed||this._confirmed("remote",n);break}case x.BYE:{this._status===R.STATUS_CONFIRMED||this._status===R.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,x.causes.BYE)):this._status===R.STATUS_INVITE_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,x.causes.BYE)):n.reply(403,"Wrong Status");break}case x.INVITE:{this._status===R.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break}case x.INFO:{if(this._status===R.STATUS_1XX_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED||this._status===R.STATUS_WAITING_FOR_ACK||this._status===R.STATUS_CONFIRMED){const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;s&&s.match(/^application\/dtmf-relay/i)?new we(this).init_incoming(n):s!==void 0?new Mn(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break}case x.UPDATE:{this._status===R.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break}case x.REFER:{this._status===R.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break}case x.NOTIFY:{this._status===R.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break}default:n.reply(501)}}onTransportError(){A.warn("onTransportError()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:x.causes.CONNECTION_ERROR,cause:x.causes.CONNECTION_ERROR})}onRequestTimeout(){A.warn("onRequestTimeout()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:x.causes.REQUEST_TIMEOUT,cause:x.causes.REQUEST_TIMEOUT})}onDialogError(){A.warn("onDialogError()"),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:x.causes.DIALOG_ERROR,cause:x.causes.DIALOG_ERROR})}newDTMF(n){A.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){A.debug("newInfo()"),this.emit("newInfo",n)}isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(A.debug("isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(A.debug("isReadyToReOffer() | session not established yet"),!1):(A.debug("isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(A.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(A.debug("close() | closing local MediaStream"),ie.closeMediaStream(this._localMediaStream)),this._status!==R.STATUS_TERMINATED){if(this._status=R.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){A.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,s){let o=Ft.T1;function c(){this._status===R.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],s),o<Ft.T2&&(o=o*2,o>Ft.T2&&(o=Ft.T2)),this._timers.invite2xxTimer=setTimeout(c.bind(this),o))}this._timers.invite2xxTimer=setTimeout(c.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===R.STATUS_WAITING_FOR_ACK&&(A.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(x.BYE),this._ended("remote",null,x.causes.NO_ACK))},Ft.TIMER_H)}_createRTCConnection(n,s){this._connection=new RTCPeerConnection(n,s),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:x.causes.RTP_TIMEOUT,status_code:408,reason_phrase:x.causes.RTP_TIMEOUT})}),A.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,s){if(A.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?o.createOffer(s).catch(c=>(A.warn('emit "peerconnection:createofferfailed" [error:%o]',c),this.emit("peerconnection:createofferfailed",c),Promise.reject(c))):o.createAnswer(s).catch(c=>(A.warn('emit "peerconnection:createanswerfailed" [error:%o]',c),this.emit("peerconnection:createanswerfailed",c),Promise.reject(c)))).then(c=>o.setLocalDescription(c).catch(t=>(this._rtcReady=!0,A.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const c=s&&s.iceRestart;if(o.iceGatheringState==="complete"&&!c||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:n,sdp:o.localDescription.sdp};return A.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let d=!1,p,a;this._iceReady=!1;const g=()=>{if(d)return;o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",a),d=!0,this._rtcReady=!0,this._iceReady=!0;const m={originator:"local",type:n,sdp:o.localDescription.sdp};A.debug('emit "sdp"'),this.emit("sdp",m),t(m.sdp)};o.addEventListener("icecandidate",p=m=>{const S=m.candidate;S?this.emit("icecandidate",{candidate:S,ready:g}):g()}),o.addEventListener("icegatheringstatechange",a=()=>{o.iceGatheringState==="complete"&&g()})})})}_createDialog(n,s,o){const c=s==="UAS"?n.to_tag:n.from_tag,t=s==="UAS"?n.from_tag:n.to_tag,d=n.call_id+c+t;let p=this._earlyDialogs[d];if(o)return p?!0:(p=new us(this,n,s,us.C.STATUS_EARLY),p.error?(A.debug(p.error),this._failed("remote",n,x.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[d]=p,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,p)return p.update(n,s),this._dialog=p,delete this._earlyDialogs[d],!0;const a=new us(this,n,s);return a.error?(A.debug(a.error),this._failed("remote",n,x.causes.INTERNAL_ERROR),!1):(this._dialog=a,!0)}}_receiveReinvite(n){A.debug("receiveReinvite()");const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let c=!1;function t(p={}){c=!0;const a=p.status_code||403,g=p.reason_phrase||"",m=ie.cloneArray(p.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);n.reply(a,g,m)}if(this.emit("reinvite",o),c)return;if(this._late_sdp=!1,!n.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(p=>{d.call(this,p)}).catch(()=>{n.reply(500)});return}if(s!=="application/sdp"){A.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==R.STATUS_TERMINATED&&d.call(this,p)}).catch(p=>{A.warn(p)});function d(p){const a=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,a),this._late_sdp&&(p=this._mangleOffer(p)),n.reply(200,null,a,p,()=>{this._status=R.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(n){A.debug("receiveUpdate()");const s=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,o={request:n,callback:void 0,reject:t.bind(this)};let c=!1;function t(p={}){c=!0;const a=p.status_code||403,g=p.reason_phrase||"",m=ie.cloneArray(p.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);n.reply(a,g,m)}if(this.emit("update",o),c)return;if(!n.body){d.call(this,null);return}if(s!=="application/sdp"){A.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(p=>{this._status!==R.STATUS_TERMINATED&&d.call(this,p)}).catch(p=>{A.warn(p)});function d(p){const a=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,a),n.reply(200,null,a,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(n){A.debug("_processInDialogSdpOffer()");const s=n.parseSDP();let o=!1;for(const d of s.media){if(cs.indexOf(d.type)===-1)continue;const p=d.direction||s.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const c={originator:"remote",type:"offer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",c);const t=new RTCSessionDescription({type:"offer",sdp:c.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(d=>{throw n.reply(488),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),this.emit("peerconnection:setremotedescriptionfailed",d),d})}).then(()=>{if(this._status===R.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===R.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(d=>{throw n.reply(500),A.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',d),d})}).catch(d=>{A.warn("_processInDialogSdpOffer() failed [error: %o]",d)}),this._connectionPromiseQueue}_receiveRefer(n){if(A.debug("receiveRefer()"),!n.refer_to){A.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==x.SIP){A.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const s=new co(this,n.cseq);A.debug('emit "refer"'),this.emit("refer",{request:n,accept:(t,d)=>{o.call(this,t,d)},reject:()=>{c.call(this)}});function o(t,d={}){if(t=typeof t=="function"?t:null,this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;const p=new Xr(this._ua);if(p.on("progress",({response:g})=>{s.notify(g.status_code,g.reason_phrase)}),p.on("accepted",({response:g})=>{s.notify(g.status_code,g.reason_phrase)}),p.on("_failed",({message:g,cause:m})=>{g?s.notify(g.status_code,g.reason_phrase):s.notify(487,m)}),n.refer_to.uri.hasHeader("replaces")){const g=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));d.extraHeaders=ie.cloneArray(d.extraHeaders),d.extraHeaders.push(`Replaces: ${g}`)}const a=n.refer_to.uri.clone();a.clearHeaders(),p.connect(a,d,t)}function c(){s.notify(603)}}_receiveNotify(n){switch(A.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let s,o;if(n.event.params&&n.event.params.id)s=n.event.params.id,o=this._referSubscribers[s];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!o){n.reply(481,"Subscription does not exist");return}o.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){A.debug("receiveReplaces()");function s(c){if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;const t=new Xr(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(n,c)}function o(){A.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:c=>{s.call(this,c)},reject:()=>{o.call(this)}})}_sendInitialRequest(n,s,o){const c=new uo(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t)}});Promise.resolve().then(()=>{if(o)return o;if(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(t=>{throw this._status===R.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,x.causes.USER_DENIED_MEDIA_ACCESS),A.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===R.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=t,t&&t.getTracks().forEach(d=>{this._connection.addTrack(d,t)}),this._connecting(this._request),this._createLocalDescription("offer",s).catch(d=>{throw this._failed("local",null,x.causes.WEBRTC_ERROR),d})}).then(t=>{if(this._is_canceled||this._status===R.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=R.STATUS_INVITE_SENT,A.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),c.send()}).catch(t=>{this._status!==R.STATUS_TERMINATED&&A.warn(t)})}_getDTMFRTPSender(){const n=this._connection.getSenders().find(s=>s.track&&s.track.kind==="audio");if(!(n&&n.dtmf)){A.warn("sendDTMF() | no local audio track to send DTMF with");return}return n.dtmf}_receiveInviteResponse(n){if(A.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(x.ACK);return}else{const s=new us(this,n,"UAC");if(s.error!==void 0){A.debug(s.error);return}this.sendRequest(x.ACK),this.sendRequest(x.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!==R.STATUS_INVITE_SENT&&this._status!==R.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):{this._status=R.STATUS_1XX_RECEIVED;break}case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){A.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=R.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",n)).catch(c=>{A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=R.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,x.causes.MISSING_SDP),this._failed("remote",n,x.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const s={originator:"remote",type:"answer",sdp:n.body};A.debug('emit "sdp"'),this.emit("sdp",s);const o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(c=>this._connection.setLocalDescription(c)).catch(c=>{this._acceptAndTerminate(n,500,c.toString()),this._failed("local",n,x.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(x.ACK),this._confirmed("local",null)}).catch(c=>{this._acceptAndTerminate(n,488,"Not Acceptable Here"),this._failed("remote",n,x.causes.BAD_MEDIA_DESCRIPTION),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',c),this.emit("peerconnection:setremotedescriptionfailed",c)})});break}default:{const s=ie.sipErrorCause(n.status_code);this._failed("remote",n,s)}}}_sendReinvite(n={}){A.debug("sendReinvite()");const s=ie.cloneArray(n.extraHeaders),o=ie.cloneObject(n.eventHandlers),c=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;s.push(`Contact: ${this._contact}`),s.push("Content-Type: application/sdp"),this._sessionTimers.running&&s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",c)).then(a=>{a=this._mangleOffer(a);const g={originator:"local",type:"offer",sdp:a};A.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(x.INVITE,{extraHeaders:s,body:a,eventHandlers:{onSuccessResponse:m=>{d.call(this,m),t=!0},onErrorResponse:m=>{p.call(this,m)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function d(a){if(this._status===R.STATUS_TERMINATED||(this.sendRequest(x.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(a),a.body){if(!a.hasHeader("Content-Type")||a.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const g={originator:"remote",type:"answer",sdp:a.body};A.debug('emit "sdp"'),this.emit("sdp",g);const m=new RTCSessionDescription({type:"answer",sdp:g.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(m)).then(()=>{o.succeeded&&o.succeeded(a)}).catch(S=>{p.call(this),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',S),this.emit("peerconnection:setremotedescriptionfailed",S)})}function p(a){o.failed&&o.failed(a)}}_sendUpdate(n={}){A.debug("sendUpdate()");const s=ie.cloneArray(n.extraHeaders),o=ie.cloneObject(n.eventHandlers),c=n.rtcOfferConstraints||this._rtcOfferConstraints||null,t=n.sdpOffer||!1;let d=!1;s.push(`Contact: ${this._contact}`),this._sessionTimers.running&&s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(s.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",c)).then(g=>{g=this._mangleOffer(g);const m={originator:"local",type:"offer",sdp:g};A.debug('emit "sdp"'),this.emit("sdp",m),this.sendRequest(x.UPDATE,{extraHeaders:s,body:g,eventHandlers:{onSuccessResponse:S=>{p.call(this,S),d=!0},onErrorResponse:S=>{a.call(this,S)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{a.call(this)})):this.sendRequest(x.UPDATE,{extraHeaders:s,eventHandlers:{onSuccessResponse:g=>{p.call(this,g)},onErrorResponse:g=>{a.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(g){if(this._status!==R.STATUS_TERMINATED&&!d)if(this._handleSessionTimersInIncomingResponse(g),t){if(g.body){if(!g.hasHeader("Content-Type")||g.getHeader("Content-Type").toLowerCase()!=="application/sdp"){a.call(this);return}}else{a.call(this);return}const m={originator:"remote",type:"answer",sdp:g.body};A.debug('emit "sdp"'),this.emit("sdp",m);const S=new RTCSessionDescription({type:"answer",sdp:m.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(S)).then(()=>{o.succeeded&&o.succeeded(g)}).catch(O=>{a.call(this),A.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',O),this.emit("peerconnection:setremotedescriptionfailed",O)})}else o.succeeded&&o.succeeded(g)}function a(g){o.failed&&o.failed(g)}}_acceptAndTerminate(n,s,o){A.debug("acceptAndTerminate()");const c=[];s&&(o=o||x.REASON_PHRASE[s]||"",c.push(`Reason: SIP ;cause=${s}; text="${o}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(x.ACK),this.sendRequest(x.BYE,{extraHeaders:c})),this._status=R.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=$n.parse(n),this._localHold&&!this._remoteHold){A.debug("mangleOffer() | me on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction?s.direction==="sendrecv"?s.direction="sendonly":s.direction==="recvonly"&&(s.direction="inactive"):s.direction="sendonly")}else if(this._localHold&&this._remoteHold){A.debug("mangleOffer() | both on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction="inactive")}else if(this._remoteHold){A.debug("mangleOffer() | remote on hold, mangling offer");for(const s of n.media)cs.indexOf(s.type)!==-1&&(s.direction?s.direction==="sendrecv"?s.direction="recvonly":s.direction==="recvonly"&&(s.direction="inactive"):s.direction="recvonly")}return $n.write(n)}_setLocalMediaStatus(){let n=!0,s=!0;(this._localHold||this._remoteHold)&&(n=!1,s=!1),this._audioMuted&&(n=!1),this._videoMuted&&(s=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!s)}_handleSessionTimersInIncomingRequest(n,s){if(!this._sessionTimers.enabled)return;let o;n.session_expires&&n.session_expires>=x.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,o=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),s.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let s;n.session_expires&&n.session_expires>=x.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,s=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,s="uac"),this._sessionTimers.refresher=s==="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!==R.STATUS_TERMINATED&&this.isReadyToReOffer()&&(A.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===x.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==R.STATUS_TERMINATED&&(A.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:x.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const s=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of s)o.track.enabled=!n}_toggleMuteVideo(n){const s=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of s)o.track.enabled=!n}_newRTCSession(n,s){A.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:n,session:this,request:s})}_connecting(n){A.debug("session connecting"),A.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,s){A.debug("session progress"),A.debug('emit "progress"'),this.emit("progress",{originator:n,response:s||null})}_accepted(n,s){A.debug("session accepted"),this._start_time=new Date,A.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:s||null})}_confirmed(n,s){A.debug("session confirmed"),this._is_confirmed=!0,A.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:s||null})}_ended(n,s,o){A.debug("session ended"),this._end_time=new Date,this._close(),A.debug('emit "ended"'),this.emit("ended",{originator:n,message:s||null,cause:o})}_failed(n,s,o){A.debug("session failed"),A.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:s||null,cause:o}),this._close(),A.debug('emit "failed"'),this.emit("failed",{originator:n,message:s||null,cause:o})}_onhold(n){A.debug("session onhold"),this._setLocalMediaStatus(),A.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){A.debug("session onunhold"),this._setLocalMediaStatus(),A.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:s}){A.debug("session onmute"),this._setLocalMediaStatus(),A.debug('emit "muted"'),this.emit("muted",{audio:n,video:s})}_onunmute({audio:n,video:s}){A.debug("session onunmute"),this._setLocalMediaStatus(),A.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:s})}};const ho=Fe.EventEmitter,_o=He,po=pe,tr=oe,Ke=Ce(),mo=$e(),go=ke,To=At,Eo=Qs,Ee=new po("Subscriber"),Y={SUBSCRIBE_RESPONSE_TIMEOUT:0,SUBSCRIBE_TRANSPORT_ERROR:1,SUBSCRIBE_NON_OK_RESPONSE:2,SUBSCRIBE_WRONG_OK_RESPONSE:3,SUBSCRIBE_AUTHENTICATION_FAILED:4,UNSUBSCRIBE_TIMEOUT:5,FINAL_NOTIFY_RECEIVED:6,WRONG_NOTIFY_RECEIVED:7,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,STATE_INIT:3,STATE_WAITING_NOTIFY:4,DEFAULT_EXPIRES_SEC:900};var So=class extends ho{static get C(){return Y}constructor(n,s,o,c,{expires:t,contentType:d,allowEvents:p,params:a,extraHeaders:g}){if(Ee.debug("new"),super(),!s)throw new TypeError("Not enough arguments: Missing target");if(!o)throw new TypeError("Not enough arguments: Missing eventName");if(!c)throw new TypeError("Not enough arguments: Missing accept");const m=mo.parse(o,"Event");if(m===-1)throw new TypeError("Missing Event header field");this._ua=n,this._target=s,(!Ke.isDecimal(t)||t<=0)&&(t=Y.DEFAULT_EXPIRES_SEC),this._expires=t,this._content_type=d,this._params=Ke.cloneObject(a),this._params.from_uri||(this._params.from_uri=this._ua.configuration.uri),this._params.from_tag=Ke.newTag(),this._params.to_tag=null,this._params.call_id=Ke.createRandomToken(20),this._params.cseq===void 0&&(this._params.cseq=Math.floor(Math.random()*1e4+1)),this._state=Y.STATE_INIT,this._dialog=null,this._expires_timer=null,this._expires_timestamp=null,this._terminated=!1,this._event_name=m.event,this._event_id=m.params&&m.params.id;let S=this._event_name;if(this._event_id&&(S+=`;id=${this._event_id}`),this._headers=Ke.cloneArray(g),this._headers=this._headers.concat([`Event: ${S}`,`Expires: ${this._expires}`,`Accept: ${c}`]),!this._headers.find(O=>O.startsWith("Contact"))){const O=`Contact: ${this._ua._contact.toString()}`;this._headers.push(O)}p&&this._headers.push(`Allow-Events: ${p}`),this._queue=[],this._data={}}get C(){return Y}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(n){this._data=n}onRequestTimeout(){this._terminateDialog(Y.SUBSCRIBE_RESPONSE_TIMEOUT)}onTransportError(){this._terminateDialog(Y.SUBSCRIBE_TRANSPORT_ERROR)}receiveRequest(n){if(n.method!==tr.NOTIFY){Ee.warn("received non-NOTIFY request"),n.reply(405);return}const s=n.parseHeader("Event");if(!s){Ee.warn("missing Event header"),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const o=s.event,c=s.params&&s.params.id;if(o!==this._event_name||c!==this._event_id){Ee.warn("Event header does not match the one in SUBSCRIBE request"),n.reply(489),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const t=n.parseHeader("subscription-state");if(!t){Ee.warn("missing Subscription-State header"),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}const d=this._parseSubscriptionState(t.state);if(d===void 0){Ee.warn(`Invalid Subscription-State header value: ${t.state}`),n.reply(400),this._terminateDialog(Y.WRONG_NOTIFY_RECEIVED);return}n.reply(200);const p=this._state;if(p!==Y.STATE_TERMINATED&&d!==Y.STATE_TERMINATED&&(this._state=d,t.expires!==void 0)){const m=t.expires,S=new Date().getTime()+m*1e3;this._expires_timestamp-S>2e3&&(Ee.debug("update sending re-SUBSCRIBE time"),this._scheduleSubscribe(m))}p!==Y.STATE_PENDING&&d===Y.STATE_PENDING?(Ee.debug('emit "pending"'),this.emit("pending")):p!==Y.STATE_ACTIVE&&d===Y.STATE_ACTIVE&&(Ee.debug('emit "active"'),this.emit("active"));const a=n.body,g=d===Y.STATE_TERMINATED;if(a){const m=n.getHeader("content-type");Ee.debug('emit "notify"'),this.emit("notify",g,n,a,m)}if(g){const m=t.reason;let S;t.params&&t.params["retry-after"]!==void 0&&(S=parseInt(t.params["retry-after"])),this._terminateDialog(Y.FINAL_NOTIFY_RECEIVED,m,S)}}subscribe(n=null){Ee.debug("subscribe()"),this._state===Y.STATE_INIT?this._sendInitialSubscribe(n,this._headers):this._sendSubsequentSubscribe(n,this._headers)}terminate(n=null){if(Ee.debug("terminate()"),this._state===Y.STATE_INIT)throw new _o.InvalidStateError(this._state);if(this._terminated)return;this._terminated=!0;const s=this._headers.map(o=>o.startsWith("Expires")?"Expires: 0":o);this._sendSubsequentSubscribe(n,s)}_terminateDialog(n,s=void 0,o=void 0){this._state!==Y.STATE_TERMINATED&&(this._state=Y.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),Ee.debug(`emit "terminated" code=${n}`),this.emit("terminated",n,s,o))}_sendInitialSubscribe(n,s){if(n){if(!this._content_type)throw new TypeError("content_type is undefined");s=Ke.cloneArray(s),s.push(`Content-Type: ${this._content_type}`)}this._state=Y.STATE_WAITING_NOTIFY;const o=new go.OutgoingRequest(tr.SUBSCRIBE,this._ua.normalizeTarget(this._target),this._ua,this._params,s,n);new To(this._ua,o,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onReceiveResponse:t=>{this._receiveSubscribeResponse(t)}}).send()}_sendSubsequentSubscribe(n,s){if(this._state!==Y.STATE_TERMINATED){if(!this._dialog){Ee.debug("enqueue subscribe"),this._queue.push({body:n,headers:Ke.cloneArray(s)});return}if(n){if(!this._content_type)throw new TypeError("content_type is undefined");s=Ke.cloneArray(s),s.push(`Content-Type: ${this._content_type}`)}this._dialog.sendRequest(tr.SUBSCRIBE,{body:n,extraHeaders:s,eventHandlers:{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onSuccessResponse:o=>{this._receiveSubscribeResponse(o)},onErrorResponse:o=>{this._receiveSubscribeResponse(o)},onDialogError:o=>{this._receiveSubscribeResponse(o)}}})}}_receiveSubscribeResponse(n){if(this._state!==Y.STATE_TERMINATED)if(n.status_code>=200&&n.status_code<300){if(this._dialog===null){const c=new Eo(this,n,"UAC");if(c.error){Ee.warn(c.error),this._terminateDialog(Y.SUBSCRIBE_WRONG_OK_RESPONSE);return}this._dialog=c,Ee.debug('emit "accepted"'),this.emit("accepted");for(const t of this._queue)Ee.debug("dequeue subscribe"),this._sendSubsequentSubscribe(t.body,t.headers)}const s=n.getHeader("expires");let o=parseInt(s);(!Ke.isDecimal(o)||o<=0)&&(Ee.warn(`response without Expires header, setting a default value of ${Y.DEFAULT_EXPIRES_SEC}`),o=Y.DEFAULT_EXPIRES_SEC),o>0&&this._scheduleSubscribe(o)}else n.status_code===401||n.status_code===407?this._terminateDialog(Y.SUBSCRIBE_AUTHENTICATION_FAILED):n.status_code>=300&&this._terminateDialog(Y.SUBSCRIBE_NON_OK_RESPONSE)}_scheduleSubscribe(n){const s=n>=140?n*1e3/2+Math.floor((n/2-70)*1e3*Math.random()):n*1e3-5e3;this._expires_timestamp=new Date().getTime()+n*1e3,Ee.debug(`next SUBSCRIBE will be sent in ${Math.floor(s/1e3)} sec`),clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._expires_timer=null,this._sendSubsequentSubscribe(null,this._headers)},s)}_parseSubscriptionState(n){switch(n){case"pending":return Y.STATE_PENDING;case"active":return Y.STATE_ACTIVE;case"terminated":return Y.STATE_TERMINATED;case"init":return Y.STATE_INIT;case"notify_wait":return Y.STATE_WAITING_NOTIFY;default:return}}};const Co=Fe.EventEmitter,sr=He,Ao=pe,rr=oe,fs=Ce(),vo=Qs,De=new Ao("Notifier"),se={NOTIFY_RESPONSE_TIMEOUT:0,NOTIFY_TRANSPORT_ERROR:1,NOTIFY_NON_OK_RESPONSE:2,NOTIFY_AUTHENTICATION_FAILED:3,FINAL_NOTIFY_SENT:4,UNSUBSCRIBE_RECEIVED:5,SUBSCRIPTION_EXPIRED:6,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,DEFAULT_EXPIRES_SEC:900};var Ro=class Jr extends Co{static get C(){return se}static init_incoming(n,s){try{Jr.checkSubscribe(n)}catch(o){De.warn("Notifier.init_incoming: invalid request. Error: ",o.message),n.reply(405);return}s()}static checkSubscribe(n){if(!n)throw new TypeError("Not enough arguments. Missing subscribe request");if(n.method!==rr.SUBSCRIBE)throw new TypeError("Invalid method for Subscribe request");if(!n.hasHeader("contact"))throw new TypeError("Missing Contact header in subscribe request");if(!n.hasHeader("event"))throw new TypeError("Missing Event header in subscribe request");const s=n.getHeader("expires");if(s){const o=parseInt(s);if(!fs.isDecimal(o)||o<0)throw new TypeError("Invalid Expires header field in subscribe request")}}constructor(n,s,o,{extraHeaders:c,allowEvents:t,pending:d,defaultExpires:p}){if(De.debug("new"),super(),!o)throw new TypeError("Not enough arguments. Missing contentType");Jr.checkSubscribe(s);const a=s.getHeader("event");this._ua=n,this._initial_subscribe=s,this._expires_timestamp=null,this._expires_timer=null,this._defaultExpires=p||se.DEFAULT_EXPIRES_SEC,this._state=d?se.STATE_PENDING:se.STATE_ACTIVE,this._content_type=o,this._headers=fs.cloneArray(c),this._headers.push(`Event: ${a}`),this._contact=this._headers.find(g=>g.startsWith("Contact")),this._contact||(this._contact=`Contact: ${this._ua._contact.toString()}`,this._headers.push(this._contact)),t&&this._headers.push(`Allow-Events: ${t}`),this._target=s.from.uri.user,s.to_tag=fs.newTag(),this._data={}}get C(){return se}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(n){this._data=n}receiveRequest(n){if(n.method!==rr.SUBSCRIBE){n.reply(405);return}this._setExpires(n),this._dialog||(this._dialog=new vo(this,n,"UAS")),n.reply(200,null,[`Expires: ${this._expires}`,`${this._contact}`]);const s=n.body,o=n.getHeader("content-type"),c=this._expires===0;c||this._setExpiresTimer(),De.debug('emit "subscribe"'),this.emit("subscribe",c,n,s,o),c&&this._terminateDialog(se.UNSUBSCRIBE_RECEIVED)}start(){if(De.debug("start()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);this.receiveRequest(this._initial_subscribe)}setActiveState(){if(De.debug("setActiveState()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);this._state===se.STATE_PENDING&&(this._state=se.STATE_ACTIVE)}notify(n=null){if(De.debug("notify()"),this._state===se.STATE_TERMINATED)throw new sr.InvalidStateError(this._state);const s=Math.floor((this._expires_timestamp-new Date().getTime())/1e3);s<=0?(this._expires_timer||De.error("expires timer is not set"),clearTimeout(this._expires_timer),this.terminate(n,"timeout")):this._sendNotify([`;expires=${s}`],n)}terminate(n=null,s=null,o=null){if(De.debug("terminate()"),this._state===se.STATE_TERMINATED)return;const c=[];s&&c.push(`;reason=${s}`),o!==null&&c.push(`;retry-after=${o}`),this._sendNotify(c,n,null,"terminated"),this._terminateDialog(s==="timeout"?se.SUBSCRIPTION_EXPIRED:se.FINAL_NOTIFY_SENT)}_terminateDialog(n){this._state!==se.STATE_TERMINATED&&(this._state=se.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),De.debug(`emit "terminated" code=${n}`),this.emit("terminated",n))}_setExpires(n){n.hasHeader("expires")?this._expires=parseInt(n.getHeader("expires")):(this._expires=this._defaultExpires,De.debug(`missing Expires header field, default value set: ${this._expires}`))}_sendNotify(n,s=null,o=null,c=null){if(this._state===se.STATE_TERMINATED){De.warn("final notify already sent");return}let t=`Subscription-State: ${c||this._parseState()}`;for(const p of n)t+=p;let d=fs.cloneArray(this._headers);d.push(t),o&&(d=d.concat(o)),s&&d.push(`Content-Type: ${this._content_type}`),this._dialog.sendRequest(rr.NOTIFY,{body:s,extraHeaders:d,eventHandlers:{onRequestTimeout:()=>{this._terminateDialog(se.NOTIFY_RESPONSE_TIMEOUT)},onTransportError:()=>{this._terminateDialog(se.NOTIFY_TRANSPORT_ERROR)},onErrorResponse:p=>{p.status_code===401||p.status_code===407?this._terminateDialog(se.NOTIFY_AUTHENTICATION_FAILED):this._terminateDialog(se.NOTIFY_NON_OK_RESPONSE)},onDialogError:()=>{this._terminateDialog(se.NOTIFY_NON_OK_RESPONSE)}}})}_setExpiresTimer(){this._expires_timestamp=new Date().getTime()+this._expires*1e3,clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._state!==se.STATE_TERMINATED&&(De.debug('emit "expired"'),this.emit("expired"),this.terminate(null,"timeout"))},this._expires*1e3)}_parseState(){switch(this._state){case se.STATE_PENDING:return"pending";case se.STATE_ACTIVE:return"active";case se.STATE_TERMINATED:return"terminated";default:throw new TypeError("wrong state value")}}};const Io=Fe.EventEmitter,bo=pe,nr=oe,yo=ke,kt=Ce(),wo=At,Fn=He,No=Ze(),hs=new bo("Message");var Oo=class extends Io{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,s,o={}){const c=n;if(n===void 0||s===void 0)throw new TypeError("Not enough arguments");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${c}`);const t=kt.cloneArray(o.extraHeaders),d=kt.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",a={};o.fromUserName&&(a.from_uri=new No("sip",o.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(a.from_display_name=o.fromDisplayName);for(const m in d)Object.prototype.hasOwnProperty.call(d,m)&&this.on(m,d[m]);t.push(`Content-Type: ${p}`),this._request=new yo.OutgoingRequest(nr.MESSAGE,n,this._ua,a,t),s&&(this._request.body=s);const g=new wo(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:m=>{this._receiveResponse(m)}});this._newMessage("local",this._request),g.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 s=kt.cloneArray(n.extraHeaders),o=n.body;if(this._direction!=="incoming")throw new Fn.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,s,o)}reject(n={}){const s=n.status_code||480,o=n.reason_phrase,c=kt.cloneArray(n.extraHeaders),t=n.body;if(this._direction!=="incoming")throw new Fn.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._is_replied=!0,this._request.reply(s,o,c,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):{this._succeeded("remote",n);break}default:{const s=kt.sipErrorCause(n.status_code);this._failed("remote",n,s);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,nr.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,nr.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(n,s){n==="remote"?(this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from):n==="local"&&(this._direction="outgoing",this._local_identity=s.from,this._remote_identity=s.to),this._ua.newMessage(this,{originator:n,message:this,request:s})}_failed(n,s,o){hs.debug("MESSAGE failed"),this._close(),hs.debug('emit "failed"'),this.emit("failed",{originator:n,response:s||null,cause:o})}_succeeded(n,s){hs.debug("MESSAGE succeeded"),this._close(),hs.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:s})}};const xo=Fe.EventEmitter,Do=pe,lr=oe,Uo=ke,qt=Ce(),$o=At,kn=He,ds=new Do("Options");var Po=class extends xo{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,s,o={}){const c=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: ${c}`);const t=qt.cloneArray(o.extraHeaders),d=qt.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const g in d)Object.prototype.hasOwnProperty.call(d,g)&&this.on(g,d[g]);t.push(`Content-Type: ${p}`),this._request=new Uo.OutgoingRequest(lr.OPTIONS,n,this._ua,null,t),s&&(this._request.body=s);const a=new $o(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:g=>{this._receiveResponse(g)}});this._newOptions("local",this._request),a.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 s=qt.cloneArray(n.extraHeaders),o=n.body;if(this._direction!=="incoming")throw new kn.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,s,o)}reject(n={}){const s=n.status_code||480,o=n.reason_phrase,c=qt.cloneArray(n.extraHeaders),t=n.body;if(this._direction!=="incoming")throw new kn.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._is_replied=!0,this._request.reply(s,o,c,t)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):{this._succeeded("remote",n);break}default:{const s=qt.sipErrorCause(n.status_code);this._failed("remote",n,s);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,lr.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,lr.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(n,s){n==="remote"?(this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from):n==="local"&&(this._direction="outgoing",this._local_identity=s.from,this._remote_identity=s.to),this._ua.newOptions(this,{originator:n,message:this,request:s})}_failed(n,s,o){ds.debug("OPTIONS failed"),this._close(),ds.debug('emit "failed"'),this.emit("failed",{originator:n,response:s||null,cause:o})}_succeeded(n,s){ds.debug("OPTIONS succeeded"),this._close(),ds.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:s})}},ir={};const Mo=pe,ar=Ce(),Lo=$e(),Gt=new Mo("Socket");ir.isSocket=f=>{if(Array.isArray(f))return!1;if(typeof f>"u")return Gt.warn("undefined JsSIP.Socket instance"),!1;try{if(!ar.isString(f.url))throw Gt.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ar.isString(f.via_transport))throw Gt.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Lo.parse(f.sip_uri,"SIP_URI")===-1)throw Gt.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(!ar.isFunction(f[n]))throw Gt.warn(`missing or invalid JsSIP.Socket method: ${n}`),new Error(`Missing or invalid JsSIP.Socket method: ${n}`)})}catch{return!1}return!0};const Ho=pe,Fo=ir,qn=oe,Ie=new Ho("Transport"),Ue={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:qn.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:qn.CONNECTION_RECOVERY_MAX_INTERVAL}};var ko=class{constructor(n,s=Ue.recovery_options){Ie.debug("new()"),this.status=Ue.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=s,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){Ie.warn(`cannot use TextDecoder: ${o}`)}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(o){if(!Fo.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:Ue.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(Ie.debug("connect()"),this.isConnected()){Ie.debug("Transport is already connected");return}else if(this.isConnecting()){Ie.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ue.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(){Ie.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ue.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(Ie.debug("send()"),!this.isConnected())return Ie.warn("unable to send message, transport is not connected"),!1;const s=n.toString();return Ie.debug(`sending message:
47
47
 
48
48
  ${s}
49
- `),this.socket.send(s)}isConnected(){return this.status===Ue.STATUS_CONNECTED}isConnecting(){return this.status===Ue.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),Re.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${n} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},n*1e3)}_getSocket(){let n=[];if(this.sockets.forEach(o=>{o.status!==Ue.SOCKET_STATUS_ERROR&&(n.length===0?n.push(o):o.weight>n[0].weight?n=[o]:o.weight===n[0].weight&&n.push(o))}),n.length===0){this.sockets.forEach(o=>{o.status=Ue.SOCKET_STATUS_READY}),this._getSocket();return}const s=Math.floor(Math.random()*n.length);this.socket=n[s].socket}_onConnect(){this.recover_attempts=0,this.status=Ue.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(n,s,o){this.status=Ue.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:n,code:s,reason:o}),!this.close_requested&&(this.sockets.forEach(function(c){this.socket===c.socket&&(c.status=Ue.SOCKET_STATUS_ERROR)},this),this._reconnect(n))}_onData(n){if(n===`\r
49
+ `),this.socket.send(s)}isConnected(){return this.status===Ue.STATUS_CONNECTED}isConnecting(){return this.status===Ue.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),Ie.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${n} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},n*1e3)}_getSocket(){let n=[];if(this.sockets.forEach(o=>{o.status!==Ue.SOCKET_STATUS_ERROR&&(n.length===0?n.push(o):o.weight>n[0].weight?n=[o]:o.weight===n[0].weight&&n.push(o))}),n.length===0){this.sockets.forEach(o=>{o.status=Ue.SOCKET_STATUS_READY}),this._getSocket();return}const s=Math.floor(Math.random()*n.length);this.socket=n[s].socket}_onConnect(){this.recover_attempts=0,this.status=Ue.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(n,s,o){this.status=Ue.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:n,code:s,reason:o}),!this.close_requested&&(this.sockets.forEach(function(c){this.socket===c.socket&&(c.status=Ue.SOCKET_STATUS_ERROR)},this),this._reconnect(n))}_onData(n){if(n===`\r
50
50
  \r
51
- `){Re.debug("received message with double-CRLF Keep Alive request");try{this.socket.send(`\r
52
- `)}catch(s){Re.warn(`error sending Keep Alive response: ${s}`)}return}if(n===`\r
53
- `){Re.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(s){Re.debug(`received binary message failed to be converted into string: ${s}`);return}Re.debug(`received binary message:
51
+ `){Ie.debug("received message with double-CRLF Keep Alive request");try{this.socket.send(`\r
52
+ `)}catch(s){Ie.warn(`error sending Keep Alive response: ${s}`)}return}if(n===`\r
53
+ `){Ie.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(s){Ie.debug(`received binary message failed to be converted into string: ${s}`);return}Ie.debug(`received binary message:
54
54
 
55
55
  ${n}
56
- `)}else Re.debug(`received text message:
56
+ `)}else Ie.debug(`received text message:
57
57
 
58
58
  ${n}
59
- `);this.ondata({transport:this,message:n})}},Fn={};const Fo=pe,or=$e(),ur=ke,_s=new Fo("Parser");Fn.parseMessage=(f,n)=>{let s,o,c=f.indexOf(`\r
60
- `);if(c===-1){_s.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=f.substring(0,c);let d=or.parse(t,"Request_Response");if(d===-1){_s.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else d.status_code?(s=new ur.IncomingResponse,s.status_code=d.status_code,s.reason_phrase=d.reason_phrase):(s=new ur.IncomingRequest(n),s.method=d.method,s.ruri=d.uri);s.data=f;let p=c+2;for(;;){if(c=ko(f,p),c===-2){o=p+2;break}else if(c===-1){_s.warn("parseMessage() | malformed message");return}if(d=qo(s,f,p,c),d!==!0){_s.warn("parseMessage() |",d.error);return}p=c+2}if(s.hasHeader("content-length")){const a=s.getHeader("content-length");s.body=f.substr(o,a)}else s.body=f.substring(o);return s};function ko(f,n){let s=n,o=0,c=0;if(f.substring(s,s+2).match(/(^\r\n)/))return-2;for(;o===0;){if(c=f.indexOf(`\r
61
- `,s),c===-1)return c;!f.substring(c+2,c+4).match(/(^\r\n)/)&&f.charAt(c+2).match(/(^\s+)/)?s=c+2:o=c}return o}function qo(f,n,s,o){let c;const t=n.indexOf(":",s),d=n.substring(s,t).trim(),p=n.substring(t+1,o).trim();switch(d.toLowerCase()){case"via":case"v":{f.addHeader("via",p),f.getHeaders("via").length===1?(c=f.parseHeader("Via"),c&&(f.via=c,f.via_branch=c.branch)):c=0;break}case"from":case"f":{f.setHeader("from",p),c=f.parseHeader("from"),c&&(f.from=c,f.from_tag=c.getParam("tag"));break}case"to":case"t":{f.setHeader("to",p),c=f.parseHeader("to"),c&&(f.to=c,f.to_tag=c.getParam("tag"));break}case"record-route":{if(c=or.parse(p,"Record_Route"),c===-1)c=void 0;else for(const a of c)f.addHeader("record-route",p.substring(a.possition,a.offset)),f.headers["Record-Route"][f.getHeaders("record-route").length-1].parsed=a.parsed;break}case"call-id":case"i":{f.setHeader("call-id",p),c=f.parseHeader("call-id"),c&&(f.call_id=p);break}case"contact":case"m":{if(c=or.parse(p,"Contact"),c===-1)c=void 0;else for(const a of c)f.addHeader("contact",p.substring(a.possition,a.offset)),f.headers.Contact[f.getHeaders("contact").length-1].parsed=a.parsed;break}case"content-length":case"l":{f.setHeader("content-length",p),c=f.parseHeader("content-length");break}case"content-type":case"c":{f.setHeader("content-type",p),c=f.parseHeader("content-type");break}case"cseq":{f.setHeader("cseq",p),c=f.parseHeader("cseq"),c&&(f.cseq=c.value),f instanceof ur.IncomingResponse&&(f.method=c.method);break}case"max-forwards":{f.setHeader("max-forwards",p),c=f.parseHeader("max-forwards");break}case"www-authenticate":{f.setHeader("www-authenticate",p),c=f.parseHeader("www-authenticate");break}case"proxy-authenticate":{f.setHeader("proxy-authenticate",p),c=f.parseHeader("proxy-authenticate");break}case"session-expires":case"x":{f.setHeader("session-expires",p),c=f.parseHeader("session-expires"),c&&(f.session_expires=c.expires,f.session_expires_refresher=c.refresher);break}case"refer-to":case"r":{f.setHeader("refer-to",p),c=f.parseHeader("refer-to"),c&&(f.refer_to=c);break}case"replaces":{f.setHeader("replaces",p),c=f.parseHeader("replaces"),c&&(f.replaces=c);break}case"event":case"o":{f.setHeader("event",p),c=f.parseHeader("event"),c&&(f.event=c);break}default:f.addHeader(d,p),c=0}return c===void 0?{error:`error parsing header "${d}"`}:!0}const Go=pe,kn=oe,qn=ke,cr=Ce(),fr=new Go("sanityCheck"),Bo=[Zo],Wo=[Yo,Ko,zo,Xo],Vo=[Jo,Qo];let re,Be,Gn;var jo=(f,n,s)=>{re=f,Be=n,Gn=s;for(const o of Bo)if(o()===!1)return!1;if(re instanceof qn.IncomingRequest){for(const o of Wo)if(o()===!1)return!1}else if(re instanceof qn.IncomingResponse){for(const o of Vo)if(o()===!1)return!1}return!0};function Yo(){if(re.s("to").uri.scheme!=="sip")return Bt(416),!1}function Ko(){if(!re.to_tag&&re.call_id.substr(0,5)===Be.configuration.jssip_id)return Bt(482),!1}function zo(){const f=cr.str_utf8_length(re.body),n=re.getHeader("content-length");if(f<n)return Bt(400),!1}function Xo(){const f=re.from_tag,n=re.call_id,s=re.cseq;let o;if(!re.to_tag)if(re.method===kn.INVITE){if(Be._transactions.ist[re.via_branch])return!1;for(const c in Be._transactions.ist)if(Object.prototype.hasOwnProperty.call(Be._transactions.ist,c)&&(o=Be._transactions.ist[c],o.request.from_tag===f&&o.request.call_id===n&&o.request.cseq===s))return Bt(482),!1}else{if(Be._transactions.nist[re.via_branch])return!1;for(const c in Be._transactions.nist)if(Object.prototype.hasOwnProperty.call(Be._transactions.nist,c)&&(o=Be._transactions.nist[c],o.request.from_tag===f&&o.request.call_id===n&&o.request.cseq===s))return Bt(482),!1}}function Jo(){if(re.getHeaders("via").length>1)return fr.debug("more than one Via header field present in the response, dropping the response"),!1}function Qo(){const f=cr.str_utf8_length(re.body),n=re.getHeader("content-length");if(f<n)return fr.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function Zo(){const f=["from","to","call_id","cseq","via"];for(const n of f)if(!re.hasHeader(n))return fr.debug(`missing mandatory header field : ${n}, dropping the response`),!1}function Bt(f){const n=re.getHeaders("via");let s,o=`SIP/2.0 ${f} ${kn.REASON_PHRASE[f]}\r
59
+ `);this.ondata({transport:this,message:n})}},Gn={};const qo=pe,or=$e(),ur=ke,_s=new qo("Parser");Gn.parseMessage=(f,n)=>{let s,o,c=f.indexOf(`\r
60
+ `);if(c===-1){_s.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=f.substring(0,c);let d=or.parse(t,"Request_Response");if(d===-1){_s.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else d.status_code?(s=new ur.IncomingResponse,s.status_code=d.status_code,s.reason_phrase=d.reason_phrase):(s=new ur.IncomingRequest(n),s.method=d.method,s.ruri=d.uri);s.data=f;let p=c+2;for(;;){if(c=Go(f,p),c===-2){o=p+2;break}else if(c===-1){_s.warn("parseMessage() | malformed message");return}if(d=Bo(s,f,p,c),d!==!0){_s.warn("parseMessage() |",d.error);return}p=c+2}if(s.hasHeader("content-length")){const a=s.getHeader("content-length");s.body=f.substr(o,a)}else s.body=f.substring(o);return s};function Go(f,n){let s=n,o=0,c=0;if(f.substring(s,s+2).match(/(^\r\n)/))return-2;for(;o===0;){if(c=f.indexOf(`\r
61
+ `,s),c===-1)return c;!f.substring(c+2,c+4).match(/(^\r\n)/)&&f.charAt(c+2).match(/(^\s+)/)?s=c+2:o=c}return o}function Bo(f,n,s,o){let c;const t=n.indexOf(":",s),d=n.substring(s,t).trim(),p=n.substring(t+1,o).trim();switch(d.toLowerCase()){case"via":case"v":{f.addHeader("via",p),f.getHeaders("via").length===1?(c=f.parseHeader("Via"),c&&(f.via=c,f.via_branch=c.branch)):c=0;break}case"from":case"f":{f.setHeader("from",p),c=f.parseHeader("from"),c&&(f.from=c,f.from_tag=c.getParam("tag"));break}case"to":case"t":{f.setHeader("to",p),c=f.parseHeader("to"),c&&(f.to=c,f.to_tag=c.getParam("tag"));break}case"record-route":{if(c=or.parse(p,"Record_Route"),c===-1)c=void 0;else for(const a of c)f.addHeader("record-route",p.substring(a.possition,a.offset)),f.headers["Record-Route"][f.getHeaders("record-route").length-1].parsed=a.parsed;break}case"call-id":case"i":{f.setHeader("call-id",p),c=f.parseHeader("call-id"),c&&(f.call_id=p);break}case"contact":case"m":{if(c=or.parse(p,"Contact"),c===-1)c=void 0;else for(const a of c)f.addHeader("contact",p.substring(a.possition,a.offset)),f.headers.Contact[f.getHeaders("contact").length-1].parsed=a.parsed;break}case"content-length":case"l":{f.setHeader("content-length",p),c=f.parseHeader("content-length");break}case"content-type":case"c":{f.setHeader("content-type",p),c=f.parseHeader("content-type");break}case"cseq":{f.setHeader("cseq",p),c=f.parseHeader("cseq"),c&&(f.cseq=c.value),f instanceof ur.IncomingResponse&&(f.method=c.method);break}case"max-forwards":{f.setHeader("max-forwards",p),c=f.parseHeader("max-forwards");break}case"www-authenticate":{f.setHeader("www-authenticate",p),c=f.parseHeader("www-authenticate");break}case"proxy-authenticate":{f.setHeader("proxy-authenticate",p),c=f.parseHeader("proxy-authenticate");break}case"session-expires":case"x":{f.setHeader("session-expires",p),c=f.parseHeader("session-expires"),c&&(f.session_expires=c.expires,f.session_expires_refresher=c.refresher);break}case"refer-to":case"r":{f.setHeader("refer-to",p),c=f.parseHeader("refer-to"),c&&(f.refer_to=c);break}case"replaces":{f.setHeader("replaces",p),c=f.parseHeader("replaces"),c&&(f.replaces=c);break}case"event":case"o":{f.setHeader("event",p),c=f.parseHeader("event"),c&&(f.event=c);break}default:f.addHeader(d,p),c=0}return c===void 0?{error:`error parsing header "${d}"`}:!0}const Wo=pe,Bn=oe,Wn=ke,cr=Ce(),fr=new Wo("sanityCheck"),Vo=[tu],jo=[zo,Xo,Jo,Qo],Yo=[Zo,eu];let re,Be,Vn;var Ko=(f,n,s)=>{re=f,Be=n,Vn=s;for(const o of Vo)if(o()===!1)return!1;if(re instanceof Wn.IncomingRequest){for(const o of jo)if(o()===!1)return!1}else if(re instanceof Wn.IncomingResponse){for(const o of Yo)if(o()===!1)return!1}return!0};function zo(){if(re.s("to").uri.scheme!=="sip")return Bt(416),!1}function Xo(){if(!re.to_tag&&re.call_id.substr(0,5)===Be.configuration.jssip_id)return Bt(482),!1}function Jo(){const f=cr.str_utf8_length(re.body),n=re.getHeader("content-length");if(f<n)return Bt(400),!1}function Qo(){const f=re.from_tag,n=re.call_id,s=re.cseq;let o;if(!re.to_tag)if(re.method===Bn.INVITE){if(Be._transactions.ist[re.via_branch])return!1;for(const c in Be._transactions.ist)if(Object.prototype.hasOwnProperty.call(Be._transactions.ist,c)&&(o=Be._transactions.ist[c],o.request.from_tag===f&&o.request.call_id===n&&o.request.cseq===s))return Bt(482),!1}else{if(Be._transactions.nist[re.via_branch])return!1;for(const c in Be._transactions.nist)if(Object.prototype.hasOwnProperty.call(Be._transactions.nist,c)&&(o=Be._transactions.nist[c],o.request.from_tag===f&&o.request.call_id===n&&o.request.cseq===s))return Bt(482),!1}}function Zo(){if(re.getHeaders("via").length>1)return fr.debug("more than one Via header field present in the response, dropping the response"),!1}function eu(){const f=cr.str_utf8_length(re.body),n=re.getHeader("content-length");if(f<n)return fr.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function tu(){const f=["from","to","call_id","cseq","via"];for(const n of f)if(!re.hasHeader(n))return fr.debug(`missing mandatory header field : ${n}, dropping the response`),!1}function Bt(f){const n=re.getHeaders("via");let s,o=`SIP/2.0 ${f} ${Bn.REASON_PHRASE[f]}\r
62
62
  `;for(const c of n)o+=`Via: ${c}\r
63
63
  `;s=re.getHeader("To"),re.to_tag||(s+=`;tag=${cr.newTag()}`),o+=`To: ${s}\r
64
64
  `,o+=`From: ${re.getHeader("From")}\r
65
65
  `,o+=`Call-ID: ${re.call_id}\r
66
66
  `,o+=`CSeq: ${re.cseq} ${re.method}\r
67
67
  `,o+=`\r
68
- `,Gn.send(o)}var hr={};const Rt=Ce(),ut=oe,dr=$e(),Bn=Ze(),_r=ir,pr=He;hr.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:ut.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,register_from_tag_trail:"",registrar_server:null,sockets:null,connection_recovery_max_interval:ut.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:ut.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${Rt.createRandomToken(12)}.invalid`};const ps={mandatory:{sockets(f){const n=[];if(_r.isSocket(f))n.push({socket:f});else if(Array.isArray(f)&&f.length)for(const s of f)Object.prototype.hasOwnProperty.call(s,"socket")&&_r.isSocket(s.socket)?n.push(s):_r.isSocket(s)&&n.push({socket:s});else return;return n},uri(f){/^sip:/i.test(f)||(f=`${ut.SIP}:${f}`);const n=Bn.parse(f);if(n)return n.user?n:void 0}},optional:{authorization_user(f){if(dr.parse(`"${f}"`,"quoted_string")!==-1)return f},authorization_jwt(f){if(typeof f=="string")return f},user_agent(f){if(typeof f=="string")return f},connection_recovery_max_interval(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},connection_recovery_min_interval(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},contact_uri(f){if(typeof f=="string"){const n=dr.parse(f,"SIP_URI");if(n!==-1)return n}},display_name(f){return f},instance_id(f){if(/^uuid:/i.test(f)&&(f=f.substr(5)),dr.parse(f,"uuid")!==-1)return f},no_answer_timeout(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},session_timers(f){if(typeof f=="boolean")return f},session_timers_refresh_method(f){if(typeof f=="string"&&(f=f.toUpperCase(),f===ut.INVITE||f===ut.UPDATE))return f},session_timers_force_refresher(f){if(typeof f=="boolean")return f},password(f){return String(f)},realm(f){return String(f)},ha1(f){return String(f)},register(f){if(typeof f=="boolean")return f},register_expires(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>=0)return n}},register_from_tag_trail(f){return typeof f=="function"?f:String(f)},registrar_server(f){/^sip:/i.test(f)||(f=`${ut.SIP}:${f}`);const n=Bn.parse(f);if(n)return n.user?void 0:n},use_preloaded_route(f){if(typeof f=="boolean")return f},extra_headers(f){const n=[];if(Array.isArray(f)&&f.length)for(const s of f)typeof s=="string"&&n.push(s);else return;return n}}};hr.load=(f,n)=>{for(const s in ps.mandatory)if(n.hasOwnProperty(s)){const o=n[s],c=ps.mandatory[s](o);if(c!==void 0)f[s]=c;else throw new pr.ConfigurationError(s,o)}else throw new pr.ConfigurationError(s);for(const s in ps.optional)if(n.hasOwnProperty(s)){const o=n[s];if(Rt.isEmpty(o))continue;const c=ps.optional[s](o);if(c!==void 0)f[s]=c;else throw new pr.ConfigurationError(s,o)}};const eu=Fe.EventEmitter,tu=pe,Ee=oe,su=Pa,Wn=Pn,ru=To,Vn=Ao,jn=yo,Yn=Uo,mr=Pt,nu=Ho,ms=Ce(),lu=He,iu=Ze(),au=Fn,gr=ke,ou=jo,Tr=hr,Z=new tu("UA"),ve={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var uu=class extends eu{static get C(){return ve}constructor(n){if(!n)throw new TypeError("Not enough arguments");const s=["password","ha1","authorization_jwt"];Z.debug("new() [configuration:%o]",Object.entries(n).filter(([o])=>!s.includes(o))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Tr.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=ve.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(n)}catch(o){throw this._status=ve.STATUS_NOT_READY,this._error=ve.CONFIGURATION_ERROR,o}this._registrator=new su(this)}get C(){return ve}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){Z.debug("start()"),this._status===ve.STATUS_INIT?this._transport.connect():this._status===ve.STATUS_USER_CLOSED?(Z.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ve.STATUS_INIT,this._transport.connect()):this._status===ve.STATUS_READY?Z.debug("UA is in READY status, not restarted"):Z.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){Z.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(n){Z.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,s){Z.debug("call()");const o=new Wn(this);return o.connect(n,s),o}sendMessage(n,s,o){Z.debug("sendMessage()");const c=new jn(this);return c.send(n,s,o),c}subscribe(n,s,o,c){return Z.debug("subscribe()"),new ru(this,n,s,o,c)}notify(n,s,o){return Z.debug("notify()"),new Vn(this,n,s,o)}sendOptions(n,s,o){Z.debug("sendOptions()");const c=new Yn(this);return c.send(n,s,o),c}terminateSessions(n){Z.debug("terminateSessions()");for(const s in this._sessions)this._sessions[s].isEnded()||this._sessions[s].terminate(n)}stop(){if(Z.debug("stop()"),this._dynConfiguration={},this._status===ve.STATUS_USER_CLOSED){Z.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){Z.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=ve.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 ms.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:{Z.warn('get() | cannot get "%s" parameter in runtime',n);return}}}set(n,s){switch(n){case"authorization_user":{this._configuration.authorization_user=String(s);break}case"password":{this._configuration.password=String(s);break}case"realm":{this._configuration.realm=String(s);break}case"ha1":{this._configuration.ha1=String(s),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(s);break}case"display_name":{this._configuration.display_name=s;break}case"extra_headers":{this._configuration.extra_headers=s;break}default:return Z.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,s){this._applicants[n]=n,this.emit("newMessage",s)}newOptions(n,s){this._applicants[n]=n,this.emit("newOptions",s)}destroyMessage(n){delete this._applicants[n]}newRTCSession(n,s){this._sessions[n.id]=n,this.emit("newRTCSession",s)}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 s=n.method;if(n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){Z.debug("Request-URI does not point to us"),n.method!==Ee.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===Ee.SIPS){n.reply_sl(416);return}if(mr.checkTransaction(this,n))return;if(s===Ee.INVITE?new mr.InviteServerTransaction(this,this._transport,n):s!==Ee.ACK&&s!==Ee.CANCEL&&new mr.NonInviteServerTransaction(this,this._transport,n),s===Ee.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new Yn(this).init_incoming(n)}else if(s===Ee.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new jn(this).init_incoming(n)}else if(s===Ee.SUBSCRIBE){if(this.listeners("newSubscribe").length===0){n.reply(405);return}}else if(s===Ee.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let o,c;if(n.to_tag)o=this._findDialog(n.call_id,n.from_tag,n.to_tag),o?o.receiveRequest(n):s===Ee.NOTIFY?(c=this._findSession(n),c?c.receiveRequest(n):(Z.debug("received NOTIFY request for a non existent subscription"),n.reply(481,"Subscription does not exist"))):s!==Ee.ACK&&n.reply(481);else switch(s){case Ee.INVITE:{if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const t=n.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(c=o.owner,c.isEnded()?n.reply(603):c.receiveRequest(n)):n.reply(481)}else c=new Wn(this),c.init_incoming(n);else Z.warn("INVITE received but WebRTC is not supported"),n.reply(488);break}case Ee.BYE:{n.reply(481);break}case Ee.CANCEL:{c=this._findSession(n),c?c.receiveRequest(n):Z.debug("received CANCEL request for a non existent session");break}case Ee.ACK:break;case Ee.NOTIFY:{this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break}case Ee.SUBSCRIBE:{Vn.init_incoming(n,()=>{this.emit("newSubscribe",{event:n.event,request:n})});break}default:{n.reply(405);break}}}_findSession({call_id:n,from_tag:s,to_tag:o}){const c=n+s,t=this._sessions[c],d=n+o,p=this._sessions[d];return t||p||null}_findDialog(n,s,o){let c=n+s+o,t=this._dialogs[c];return t||(c=n+o+s,t=this._dialogs[c],t||null)}_loadConfig(n){Tr.load(this._configuration,n),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 s=this._configuration.uri.clone();s.user=null,this._configuration.hostport_params=s.toString().replace(/^sip:/i,"");try{this._transport=new nu(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=cu.bind(this),this._transport.onconnect=fu.bind(this),this._transport.ondisconnect=hu.bind(this),this._transport.ondata=du.bind(this)}catch(c){throw Z.warn(c),new lu.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 c=this._configuration.uri.clone();c.user=null,c.clearParams(),c.clearHeaders(),this._configuration.registrar_server=c}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new iu("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(c={}){const t=c.anonymous||null,d=c.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),d&&(t?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(const c in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,c)&&(o.indexOf(c)!==-1?Object.defineProperty(this._configuration,c,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,c,{writable:!1,configurable:!1}));Z.debug("configuration parameters after validation:");for(const c in this._configuration)if(Object.prototype.hasOwnProperty.call(Tr.settings,c))switch(c){case"uri":case"registrar_server":{Z.debug(`- ${c}: ${this._configuration[c]}`);break}case"password":case"ha1":case"authorization_jwt":{Z.debug(`- ${c}: NOT SHOWN`);break}default:Z.debug(`- ${c}: ${JSON.stringify(this._configuration[c])}`)}}};function cu(f){this.emit("connecting",f)}function fu(f){this._status!==ve.STATUS_USER_CLOSED&&(this._status=ve.STATUS_READY,this._error=null,this.emit("connected",f),this._dynConfiguration.register&&this._registrator.register())}function hu(f){const n=["nict","ict","nist","ist"];for(const s of n)for(const o in this._transactions[s])Object.prototype.hasOwnProperty.call(this._transactions[s],o)&&this._transactions[s][o].onTransportError();this.emit("disconnected",f),this._registrator.onTransportClosed(),this._status!==ve.STATUS_USER_CLOSED&&(this._status=ve.STATUS_NOT_READY,this._error=ve.NETWORK_ERROR)}function du(f){const n=f.transport;let s=f.message;if(s=au.parseMessage(s,this),!!s&&!(this._status===ve.STATUS_USER_CLOSED&&s instanceof gr.IncomingRequest)&&ou(s,this,n)){if(s instanceof gr.IncomingRequest)s.transport=n,this.receiveRequest(s);else if(s instanceof gr.IncomingResponse){let o;switch(s.method){case Ee.INVITE:{o=this._transactions.ict[s.via_branch],o&&o.receiveResponse(s);break}case Ee.ACK:break;default:{o=this._transactions.nict[s.via_branch],o&&o.receiveResponse(s);break}}}}}const _u=pe,pu=$e(),be=new _u("WebSocketInterface");var mu=class{constructor(n){be.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;const s=pu.parse(n,"absoluteURI");if(s===-1)throw be.warn(`invalid WebSocket URI: ${n}`),new TypeError(`Invalid argument: ${n}`);if(s.scheme!=="wss"&&s.scheme!=="ws")throw be.warn(`invalid WebSocket URI scheme: ${s.scheme}`),new TypeError(`Invalid argument: ${n}`);this._sip_uri=`sip:${s.host}${s.port?`:${s.port}`:""};transport=ws`,this._via_transport=s.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(be.debug("connect()"),this.isConnected()){be.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){be.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),be.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(){be.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 be.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(be.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(){be.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:n,code:s,reason:o}){be.debug(`WebSocket ${this._url} closed`),n===!1&&be.debug("WebSocket abrupt disconnection"),this.ondisconnect(!n,s,o)}_onMessage({data:n}){be.debug("received WebSocket message"),this.ondata(n)}_onError(n){be.warn(`WebSocket ${this._url} error: `,n)}};const Er=zr,gu=oe,Tu=He,Eu=Ce(),Su=uu,Cu=Ze(),Au=Ps(),vu=$e(),Ru=mu,Iu=qs("JsSIP"),bu=Pn;Iu("version %s",Er.version);var wu={C:gu,Exceptions:Tu,Utils:Eu,UA:Su,URI:Cu,NameAddrHeader:Au,WebSocketInterface:Ru,Grammar:vu,RTCSession:bu,debug:qs,get name(){return Er.title},get version(){return Er.version}};const Kn=Ji(wu);let L=null,he=null,It=null;const ct=f=>(f==null?void 0:f.replace(/^(https?|wss?):\/\//,"").replace(/\/+$/,""))||null,Se={setConfig(f){L=f},getConfig(){return L},pushSound(){try{It&&clearInterval(It);const f=()=>{try{(!he||he.state==="closed")&&(he=new(window.AudioContext||window.webkitAudioContext)),he.state==="suspended"&&he.resume();const n=he.createOscillator(),s=he.createOscillator(),o=he.createGain();n.type="sine",s.type="sine",n.frequency.setValueAtTime(400,he.currentTime),s.frequency.setValueAtTime(450,he.currentTime);const c=he.createOscillator(),t=he.createGain();c.frequency.value=25,t.gain.value=15,c.connect(t),t.connect(n.frequency),t.connect(s.frequency),n.connect(o),s.connect(o),o.connect(he.destination),o.gain.setValueAtTime(0,he.currentTime),o.gain.linearRampToValueAtTime(.08,he.currentTime+.05),o.gain.setValueAtTime(.08,he.currentTime+1.2),o.gain.linearRampToValueAtTime(0,he.currentTime+1.3),[c,n,s].forEach(d=>{d.start(),d.stop(he.currentTime+1.4)})}catch(n){console.warn("Failed to play synthesized tone:",n)}};f(),It=setInterval(f,3e3)}catch(f){console.warn("AudioContext initialization failed:",f)}},stopSound(){It&&(clearInterval(It),It=null),he&&(he.close().catch(()=>{}),he=null)},toHHMMSS(f){const n=parseInt(f,10),s=Math.floor(n/3600),o=Math.floor(n/60)%60,c=n%60;return[s,o,c].map(t=>t<10?"0"+t:t).filter((t,d)=>t!=="00"||d>0).join(":")},getContactName(f){var n;return f&&((n=L==null?void 0:L.contacts)==null?void 0:n[f])||null},getCpaasBaseUrl(){var n,s;const f=((L==null?void 0:L.cpaas_base_url)||(L==null?void 0:L.cpaasBaseUrl)||((n=L==null?void 0:L.env)==null?void 0:n.CPAAS_BASE_URL)||((s=L==null?void 0:L.pabxConfig)==null?void 0:s.cpaas_base_url)||"https://api-cpaas.omnix.co.id").replace(/\/+$/,"");return!/^https:\/\//.test(f)&&!/^http:\/\/(localhost|127\.0\.0\.1)(:|\/|$)/.test(f)?(console.error("cpaas_base_url must use https. CPaaS API calls are disabled."),null):f},getSipHost(){var f,n,s,o;return ct(L==null?void 0:L.pbx_url)||ct((f=L==null?void 0:L.pabxConfig)==null?void 0:f.pbx_url)||ct((n=L==null?void 0:L.auth)==null?void 0:n.pabx_host)||ct((s=L==null?void 0:L.auth)==null?void 0:s.pbxurl)||ct((o=L==null?void 0:L.auth)==null?void 0:o.host)},getWssHost(){var f;return ct(L==null?void 0:L.sip_url)||ct((f=L==null?void 0:L.pabxConfig)==null?void 0:f.sip_url)||this.getSipHost()},getFingerprint(){var f,n,s;return(L==null?void 0:L["X-CPAAS-Key-Fingerprint"])||(L==null?void 0:L.fingerprint)||(L==null?void 0:L.cpaasKeyFingerprint)||((f=L==null?void 0:L.env)==null?void 0:f.fingerprint)||((n=L==null?void 0:L.env)==null?void 0:n.X_CPAAS_Key_Fingerprint)||((s=L==null?void 0:L.pabxConfig)==null?void 0:s["X-CPAAS-Key-Fingerprint"])},getExtensionUsername(){var f,n;return((f=L==null?void 0:L.auth)==null?void 0:f.user_pbx)||((n=L==null?void 0:L.auth)==null?void 0:n.username)||null},async updateExtensionStatus(f,n="Ready",s="ready"){const o=this.getFingerprint(),c=this.getCpaasBaseUrl();if(!c)return!1;if(!o)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot update extension status."),!1;try{return(await fetch(`${c}/voice/extensions/status`,{method:"POST",headers:{"X-CPAAS-Key-Fingerprint":o,"Content-Type":"application/json"},body:JSON.stringify({extension:f,status:n,reason:s})})).ok}catch(t){return console.error("Failed to update extension status:",t),!1}},async fetchExtensionStatus(f){var o,c;const n=this.getFingerprint(),s=this.getCpaasBaseUrl();if(!s)return null;if(!n)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot fetch extension status."),null;try{const t=await fetch(`${s}/voice/portal/extension?extension=${encodeURIComponent(f)}`,{headers:{"X-CPAAS-Key-Fingerprint":n,"Content-Type":"application/json"}});return t.ok&&((c=(o=await t.json())==null?void 0:o.data)==null?void 0:c[0])||null}catch(t){return console.error("Failed to fetch extension status:",t),null}}},zn={audio:!0,video:!1},Xn={iceServers:[]};let we=null,ee=null,Sr=null,Ne=null,Cr=!1;const Jn={registerStatus:"CONNECTING",agentStatus:"NOT_READY",currentAux:null,callStatus:"Idle",callDuration:"00:00",isMuted:!1,isOnHold:!1,remote:null};let bt={...Jn};const yu=()=>({...bt}),Ie=(f,n,s)=>{s&&Object.assign(bt,s),ts.emitLocal(f,n)},Le=(f,n)=>Ie("register_status",f==="FAILED"?{status:f,reason:n}:f,f==="FAILED"?{registerStatus:f,agentStatus:"NOT_READY",currentAux:null}:{registerStatus:f}),Wt=(f,n=null)=>Ie("agent_status",f,{agentStatus:f,currentAux:f==="AUX"?n:null}),Vt=f=>Ie("call_status",f,{callStatus:f}),Qn=f=>{f.addEventListener("track",n=>{n.track.kind==="audio"&&(Ne||(Ne=document.createElement("audio"),Ne.id="voxnix-remote-audio",Ne.autoplay=!0,document.body.appendChild(Ne)),Ne.srcObject=n.streams[0]||new MediaStream([n.track]),Ne.play().catch(s=>console.error("Error playing media:",s)))})},Nu=f=>n=>{var d,p;if(n.originator!=="remote"||n.type!=="answer")return;const s=(((p=(d=f.connection)==null?void 0:d.localDescription)==null?void 0:p.sdp.match(/^m=/gm))||[]).length,o=(n.sdp.match(/^m=/gm)||[]).length;if(!s||o<=s)return;let c=0;const t=n.sdp.split(/\r?\n/).filter(a=>(a.startsWith("m=")&&c++,c<=s));n.sdp=t.join(`\r
68
+ `,Vn.send(o)}var hr={};const Rt=Ce(),ut=oe,dr=$e(),jn=Ze(),_r=ir,pr=He;hr.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:ut.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,register_from_tag_trail:"",registrar_server:null,sockets:null,connection_recovery_max_interval:ut.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:ut.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${Rt.createRandomToken(12)}.invalid`};const ps={mandatory:{sockets(f){const n=[];if(_r.isSocket(f))n.push({socket:f});else if(Array.isArray(f)&&f.length)for(const s of f)Object.prototype.hasOwnProperty.call(s,"socket")&&_r.isSocket(s.socket)?n.push(s):_r.isSocket(s)&&n.push({socket:s});else return;return n},uri(f){/^sip:/i.test(f)||(f=`${ut.SIP}:${f}`);const n=jn.parse(f);if(n)return n.user?n:void 0}},optional:{authorization_user(f){if(dr.parse(`"${f}"`,"quoted_string")!==-1)return f},authorization_jwt(f){if(typeof f=="string")return f},user_agent(f){if(typeof f=="string")return f},connection_recovery_max_interval(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},connection_recovery_min_interval(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},contact_uri(f){if(typeof f=="string"){const n=dr.parse(f,"SIP_URI");if(n!==-1)return n}},display_name(f){return f},instance_id(f){if(/^uuid:/i.test(f)&&(f=f.substr(5)),dr.parse(f,"uuid")!==-1)return f},no_answer_timeout(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>0)return n}},session_timers(f){if(typeof f=="boolean")return f},session_timers_refresh_method(f){if(typeof f=="string"&&(f=f.toUpperCase(),f===ut.INVITE||f===ut.UPDATE))return f},session_timers_force_refresher(f){if(typeof f=="boolean")return f},password(f){return String(f)},realm(f){return String(f)},ha1(f){return String(f)},register(f){if(typeof f=="boolean")return f},register_expires(f){if(Rt.isDecimal(f)){const n=Number(f);if(n>=0)return n}},register_from_tag_trail(f){return typeof f=="function"?f:String(f)},registrar_server(f){/^sip:/i.test(f)||(f=`${ut.SIP}:${f}`);const n=jn.parse(f);if(n)return n.user?void 0:n},use_preloaded_route(f){if(typeof f=="boolean")return f},extra_headers(f){const n=[];if(Array.isArray(f)&&f.length)for(const s of f)typeof s=="string"&&n.push(s);else return;return n}}};hr.load=(f,n)=>{for(const s in ps.mandatory)if(n.hasOwnProperty(s)){const o=n[s],c=ps.mandatory[s](o);if(c!==void 0)f[s]=c;else throw new pr.ConfigurationError(s,o)}else throw new pr.ConfigurationError(s);for(const s in ps.optional)if(n.hasOwnProperty(s)){const o=n[s];if(Rt.isEmpty(o))continue;const c=ps.optional[s](o);if(c!==void 0)f[s]=c;else throw new pr.ConfigurationError(s,o)}};const su=Fe.EventEmitter,ru=pe,Se=oe,nu=La,Yn=Hn,lu=So,Kn=Ro,zn=Oo,Xn=Po,mr=Pt,iu=ko,ms=Ce(),au=He,ou=Ze(),uu=Gn,gr=ke,cu=Ko,Tr=hr,ee=new ru("UA"),ve={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var fu=class extends su{static get C(){return ve}constructor(n){if(!n)throw new TypeError("Not enough arguments");const s=["password","ha1","authorization_jwt"];ee.debug("new() [configuration:%o]",Object.entries(n).filter(([o])=>!s.includes(o))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Tr.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=ve.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(n)}catch(o){throw this._status=ve.STATUS_NOT_READY,this._error=ve.CONFIGURATION_ERROR,o}this._registrator=new nu(this)}get C(){return ve}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){ee.debug("start()"),this._status===ve.STATUS_INIT?this._transport.connect():this._status===ve.STATUS_USER_CLOSED?(ee.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ve.STATUS_INIT,this._transport.connect()):this._status===ve.STATUS_READY?ee.debug("UA is in READY status, not restarted"):ee.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){ee.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(n){ee.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,s){ee.debug("call()");const o=new Yn(this);return o.connect(n,s),o}sendMessage(n,s,o){ee.debug("sendMessage()");const c=new zn(this);return c.send(n,s,o),c}subscribe(n,s,o,c){return ee.debug("subscribe()"),new lu(this,n,s,o,c)}notify(n,s,o){return ee.debug("notify()"),new Kn(this,n,s,o)}sendOptions(n,s,o){ee.debug("sendOptions()");const c=new Xn(this);return c.send(n,s,o),c}terminateSessions(n){ee.debug("terminateSessions()");for(const s in this._sessions)this._sessions[s].isEnded()||this._sessions[s].terminate(n)}stop(){if(ee.debug("stop()"),this._dynConfiguration={},this._status===ve.STATUS_USER_CLOSED){ee.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){ee.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=ve.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 ms.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:{ee.warn('get() | cannot get "%s" parameter in runtime',n);return}}}set(n,s){switch(n){case"authorization_user":{this._configuration.authorization_user=String(s);break}case"password":{this._configuration.password=String(s);break}case"realm":{this._configuration.realm=String(s);break}case"ha1":{this._configuration.ha1=String(s),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(s);break}case"display_name":{this._configuration.display_name=s;break}case"extra_headers":{this._configuration.extra_headers=s;break}default:return ee.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,s){this._applicants[n]=n,this.emit("newMessage",s)}newOptions(n,s){this._applicants[n]=n,this.emit("newOptions",s)}destroyMessage(n){delete this._applicants[n]}newRTCSession(n,s){this._sessions[n.id]=n,this.emit("newRTCSession",s)}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 s=n.method;if(n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){ee.debug("Request-URI does not point to us"),n.method!==Se.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===Se.SIPS){n.reply_sl(416);return}if(mr.checkTransaction(this,n))return;if(s===Se.INVITE?new mr.InviteServerTransaction(this,this._transport,n):s!==Se.ACK&&s!==Se.CANCEL&&new mr.NonInviteServerTransaction(this,this._transport,n),s===Se.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new Xn(this).init_incoming(n)}else if(s===Se.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new zn(this).init_incoming(n)}else if(s===Se.SUBSCRIBE){if(this.listeners("newSubscribe").length===0){n.reply(405);return}}else if(s===Se.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let o,c;if(n.to_tag)o=this._findDialog(n.call_id,n.from_tag,n.to_tag),o?o.receiveRequest(n):s===Se.NOTIFY?(c=this._findSession(n),c?c.receiveRequest(n):(ee.debug("received NOTIFY request for a non existent subscription"),n.reply(481,"Subscription does not exist"))):s!==Se.ACK&&n.reply(481);else switch(s){case Se.INVITE:{if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const t=n.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(c=o.owner,c.isEnded()?n.reply(603):c.receiveRequest(n)):n.reply(481)}else c=new Yn(this),c.init_incoming(n);else ee.warn("INVITE received but WebRTC is not supported"),n.reply(488);break}case Se.BYE:{n.reply(481);break}case Se.CANCEL:{c=this._findSession(n),c?c.receiveRequest(n):ee.debug("received CANCEL request for a non existent session");break}case Se.ACK:break;case Se.NOTIFY:{this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break}case Se.SUBSCRIBE:{Kn.init_incoming(n,()=>{this.emit("newSubscribe",{event:n.event,request:n})});break}default:{n.reply(405);break}}}_findSession({call_id:n,from_tag:s,to_tag:o}){const c=n+s,t=this._sessions[c],d=n+o,p=this._sessions[d];return t||p||null}_findDialog(n,s,o){let c=n+s+o,t=this._dialogs[c];return t||(c=n+o+s,t=this._dialogs[c],t||null)}_loadConfig(n){Tr.load(this._configuration,n),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 s=this._configuration.uri.clone();s.user=null,this._configuration.hostport_params=s.toString().replace(/^sip:/i,"");try{this._transport=new iu(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=hu.bind(this),this._transport.onconnect=du.bind(this),this._transport.ondisconnect=_u.bind(this),this._transport.ondata=pu.bind(this)}catch(c){throw ee.warn(c),new au.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 c=this._configuration.uri.clone();c.user=null,c.clearParams(),c.clearHeaders(),this._configuration.registrar_server=c}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new ou("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(c={}){const t=c.anonymous||null,d=c.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),d&&(t?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(const c in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,c)&&(o.indexOf(c)!==-1?Object.defineProperty(this._configuration,c,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,c,{writable:!1,configurable:!1}));ee.debug("configuration parameters after validation:");for(const c in this._configuration)if(Object.prototype.hasOwnProperty.call(Tr.settings,c))switch(c){case"uri":case"registrar_server":{ee.debug(`- ${c}: ${this._configuration[c]}`);break}case"password":case"ha1":case"authorization_jwt":{ee.debug(`- ${c}: NOT SHOWN`);break}default:ee.debug(`- ${c}: ${JSON.stringify(this._configuration[c])}`)}}};function hu(f){this.emit("connecting",f)}function du(f){this._status!==ve.STATUS_USER_CLOSED&&(this._status=ve.STATUS_READY,this._error=null,this.emit("connected",f),this._dynConfiguration.register&&this._registrator.register())}function _u(f){const n=["nict","ict","nist","ist"];for(const s of n)for(const o in this._transactions[s])Object.prototype.hasOwnProperty.call(this._transactions[s],o)&&this._transactions[s][o].onTransportError();this.emit("disconnected",f),this._registrator.onTransportClosed(),this._status!==ve.STATUS_USER_CLOSED&&(this._status=ve.STATUS_NOT_READY,this._error=ve.NETWORK_ERROR)}function pu(f){const n=f.transport;let s=f.message;if(s=uu.parseMessage(s,this),!!s&&!(this._status===ve.STATUS_USER_CLOSED&&s instanceof gr.IncomingRequest)&&cu(s,this,n)){if(s instanceof gr.IncomingRequest)s.transport=n,this.receiveRequest(s);else if(s instanceof gr.IncomingResponse){let o;switch(s.method){case Se.INVITE:{o=this._transactions.ict[s.via_branch],o&&o.receiveResponse(s);break}case Se.ACK:break;default:{o=this._transactions.nict[s.via_branch],o&&o.receiveResponse(s);break}}}}}const mu=pe,gu=$e(),ye=new mu("WebSocketInterface");var Tu=class{constructor(n){ye.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;const s=gu.parse(n,"absoluteURI");if(s===-1)throw ye.warn(`invalid WebSocket URI: ${n}`),new TypeError(`Invalid argument: ${n}`);if(s.scheme!=="wss"&&s.scheme!=="ws")throw ye.warn(`invalid WebSocket URI scheme: ${s.scheme}`),new TypeError(`Invalid argument: ${n}`);this._sip_uri=`sip:${s.host}${s.port?`:${s.port}`:""};transport=ws`,this._via_transport=s.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(ye.debug("connect()"),this.isConnected()){ye.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){ye.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),ye.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(){ye.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 ye.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(ye.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(){ye.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:n,code:s,reason:o}){ye.debug(`WebSocket ${this._url} closed`),n===!1&&ye.debug("WebSocket abrupt disconnection"),this.ondisconnect(!n,s,o)}_onMessage({data:n}){ye.debug("received WebSocket message"),this.ondata(n)}_onError(n){ye.warn(`WebSocket ${this._url} error: `,n)}};const Er=Qr,Eu=oe,Su=He,Cu=Ce(),Au=fu,vu=Ze(),Ru=Ps(),Iu=$e(),bu=Tu,yu=qs("JsSIP"),wu=Hn;yu("version %s",Er.version);var Nu={C:Eu,Exceptions:Su,Utils:Cu,UA:Au,URI:vu,NameAddrHeader:Ru,WebSocketInterface:bu,Grammar:Iu,RTCSession:wu,debug:qs,get name(){return Er.title},get version(){return Er.version}};const Jn=Zi(Nu);let L=null,he=null,It=null;const ct=f=>(f==null?void 0:f.replace(/^(https?|wss?):\/\//,"").replace(/\/+$/,""))||null,ge={setConfig(f){L=f},getConfig(){return L},pushSound(){try{It&&clearInterval(It);const f=()=>{try{(!he||he.state==="closed")&&(he=new(window.AudioContext||window.webkitAudioContext)),he.state==="suspended"&&he.resume();const n=he.createOscillator(),s=he.createOscillator(),o=he.createGain();n.type="sine",s.type="sine",n.frequency.setValueAtTime(400,he.currentTime),s.frequency.setValueAtTime(450,he.currentTime);const c=he.createOscillator(),t=he.createGain();c.frequency.value=25,t.gain.value=15,c.connect(t),t.connect(n.frequency),t.connect(s.frequency),n.connect(o),s.connect(o),o.connect(he.destination),o.gain.setValueAtTime(0,he.currentTime),o.gain.linearRampToValueAtTime(.08,he.currentTime+.05),o.gain.setValueAtTime(.08,he.currentTime+1.2),o.gain.linearRampToValueAtTime(0,he.currentTime+1.3),[c,n,s].forEach(d=>{d.start(),d.stop(he.currentTime+1.4)})}catch(n){console.warn("Failed to play synthesized tone:",n)}};f(),It=setInterval(f,3e3)}catch(f){console.warn("AudioContext initialization failed:",f)}},stopSound(){It&&(clearInterval(It),It=null),he&&(he.close().catch(()=>{}),he=null)},toHHMMSS(f){const n=parseInt(f,10),s=Math.floor(n/3600),o=Math.floor(n/60)%60,c=n%60;return[s,o,c].map(t=>t<10?"0"+t:t).filter((t,d)=>t!=="00"||d>0).join(":")},getContactName(f){var n;return f&&((n=L==null?void 0:L.contacts)==null?void 0:n[f])||null},getCpaasBaseUrl(){var n,s;const f=((L==null?void 0:L.cpaas_base_url)||(L==null?void 0:L.cpaasBaseUrl)||((n=L==null?void 0:L.env)==null?void 0:n.CPAAS_BASE_URL)||((s=L==null?void 0:L.pabxConfig)==null?void 0:s.cpaas_base_url)||"https://api-cpaas.omnix.co.id").replace(/\/+$/,"");return!/^https:\/\//.test(f)&&!/^http:\/\/(localhost|127\.0\.0\.1)(:|\/|$)/.test(f)?(console.error("cpaas_base_url must use https. CPaaS API calls are disabled."),null):f},getSipHost(){var f,n,s,o;return ct(L==null?void 0:L.pbx_url)||ct((f=L==null?void 0:L.pabxConfig)==null?void 0:f.pbx_url)||ct((n=L==null?void 0:L.auth)==null?void 0:n.pabx_host)||ct((s=L==null?void 0:L.auth)==null?void 0:s.pbxurl)||ct((o=L==null?void 0:L.auth)==null?void 0:o.host)},getWssHost(){var f;return ct(L==null?void 0:L.sip_url)||ct((f=L==null?void 0:L.pabxConfig)==null?void 0:f.sip_url)||this.getSipHost()},getFingerprint(){var f,n,s;return(L==null?void 0:L["X-CPAAS-Key-Fingerprint"])||(L==null?void 0:L.fingerprint)||(L==null?void 0:L.cpaasKeyFingerprint)||((f=L==null?void 0:L.env)==null?void 0:f.fingerprint)||((n=L==null?void 0:L.env)==null?void 0:n.X_CPAAS_Key_Fingerprint)||((s=L==null?void 0:L.pabxConfig)==null?void 0:s["X-CPAAS-Key-Fingerprint"])},getExtensionUsername(){var f,n;return((f=L==null?void 0:L.auth)==null?void 0:f.user_pbx)||((n=L==null?void 0:L.auth)==null?void 0:n.username)||null},async updateExtensionStatus(f,n="Ready",s="ready"){const o=this.getFingerprint(),c=this.getCpaasBaseUrl();if(!c)return!1;if(!o)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot update extension status."),!1;try{return(await fetch(`${c}/voice/extensions/status`,{method:"POST",headers:{"X-CPAAS-Key-Fingerprint":o,"Content-Type":"application/json"},body:JSON.stringify({extension:f,status:n,reason:s})})).ok}catch(t){return console.error("Failed to update extension status:",t),!1}},async fetchExtensionStatus(f){var o,c;const n=this.getFingerprint(),s=this.getCpaasBaseUrl();if(!s)return null;if(!n)return console.warn("X-CPAAS-Key-Fingerprint not found. Cannot fetch extension status."),null;try{const t=await fetch(`${s}/voice/portal/extension?extension=${encodeURIComponent(f)}`,{headers:{"X-CPAAS-Key-Fingerprint":n,"Content-Type":"application/json"}});return t.ok&&((c=(o=await t.json())==null?void 0:o.data)==null?void 0:c[0])||null}catch(t){return console.error("Failed to fetch extension status:",t),null}}},Sr={audio:!0,video:!1},Cr={iceServers:[]};let Re=null,Q=null,Ar=null,Ne=null,vr=!1,Rr=!1;const Qn={registerStatus:"CONNECTING",agentStatus:"NOT_READY",currentAux:null,callStatus:"Idle",callDuration:"00:00",isMuted:!1,isOnHold:!1,remote:null};let bt={...Qn};const Ou=()=>({...bt}),be=(f,n,s)=>{s&&Object.assign(bt,s),ts.emitLocal(f,n)},Le=(f,n)=>be("register_status",f==="FAILED"?{status:f,reason:n}:f,f==="FAILED"?{registerStatus:f,agentStatus:"NOT_READY",currentAux:null}:{registerStatus:f}),Wt=(f,n=null)=>be("agent_status",f,{agentStatus:f,currentAux:f==="AUX"?n:null}),Vt=f=>be("call_status",f,{callStatus:f}),Zn=f=>{f.addEventListener("track",n=>{n.track.kind==="audio"&&(Ne||(Ne=document.createElement("audio"),Ne.id="voxnix-remote-audio",Ne.autoplay=!0,document.body.appendChild(Ne)),Ne.srcObject=n.streams[0]||new MediaStream([n.track]),Ne.play().catch(s=>console.error("Error playing media:",s)))})},xu=f=>n=>{var d,p;if(n.originator!=="remote"||n.type!=="answer")return;const s=(((p=(d=f.connection)==null?void 0:d.localDescription)==null?void 0:p.sdp.match(/^m=/gm))||[]).length,o=(n.sdp.match(/^m=/gm)||[]).length;if(!s||o<=s)return;let c=0;const t=n.sdp.split(/\r?\n/).filter(a=>(a.startsWith("m=")&&c++,c<=s));n.sdp=t.join(`\r
69
69
  `).replace(/(\r\n)*$/,`\r
70
- `)},Ou=f=>{var s,o,c;const n=((o=(s=f.remote_identity)==null?void 0:s.uri)==null?void 0:o.user)||"Unknown";return{number:n,name:((c=f.remote_identity)==null?void 0:c.display_name)||Se.getContactName(n)||"",direction:f.direction}},Zn=f=>{ee=f;const n=Ou(f);Object.assign(bt,{remote:n,isMuted:!1,isOnHold:!1}),f.connection?Qn(f.connection):f.on("peerconnection",o=>Qn(o.peerconnection)),f.on("sdp",Nu(f)),f.on("confirmed",()=>{Se.stopSound(),Vt("InCall"),Ie("sync_call_answered",n);const o=Date.now();Sr=setInterval(()=>{const c=Se.toHHMMSS((Date.now()-o)/1e3);Ie("call_duration",c,{callDuration:c})},1e3)}),f.on("muted",()=>Ie("mute_status",!0,{isMuted:!0})),f.on("unmuted",()=>Ie("mute_status",!1,{isMuted:!1})),f.on("hold",o=>o.originator==="local"&&Ie("hold_status",!0,{isOnHold:!0})),f.on("unhold",o=>o.originator==="local"&&Ie("hold_status",!1,{isOnHold:!1}));const s=o=>c=>{Se.stopSound(),clearInterval(Sr),Ne&&(Ne.srcObject=null),ee=null,Ie("call_duration","00:00",{callDuration:"00:00",isMuted:!1,isOnHold:!1,remote:null}),Vt("Idle");const t={...n,cause:c.cause,originator:c.originator};o?Ie("sync_call_ended",t):n.direction==="incoming"?Ie("sync_call_unanswered",t):c.originator!=="local"&&Ie("call_failed",c.cause||"Call Failed")};f.on("ended",s(!0)),f.on("failed",s(!1))},xu=({session:f,originator:n})=>{var s;if(n==="local")return Zn(f);if(ee)return f.terminate({status_code:486,reason_phrase:"Busy Here"});Zn(f),((s=Se.getConfig())==null?void 0:s.ringtone)!==!1&&Se.pushSound(),Vt("Ringing"),Ie("incoming_call",bt.remote)},Du=f=>{if(f=String(f??"").trim(),!(!we||ee||!f)){if(!/^[0-9A-Za-z+*#._-]+$/.test(f))return Ie("call_failed","Invalid number");Vt("Calling...");try{we.call(`sip:${f}@${Se.getSipHost()}`,{mediaConstraints:zn,pcConfig:Xn})}catch(n){console.error("Dial failed:",n),Vt("Idle"),Ie("call_failed",n.message||"Call Failed")}}},Uu=()=>{Se.stopSound(),(ee==null?void 0:ee.direction)==="incoming"&&!ee.isEstablished()&&ee.answer({mediaConstraints:zn,pcConfig:Xn})},el=()=>{Se.stopSound(),ee&&!ee.isEnded()&&ee.terminate()},$u=el,Pu=(f=!0)=>{ee!=null&&ee.isEstablished()&&(f?ee.mute({audio:!0}):ee.unmute({audio:!0}))},Mu=(f=!0)=>{ee!=null&&ee.isEstablished()&&(f?ee.hold():ee.unhold())},Lu=f=>{if(ee!=null&&ee.isEstablished())try{ee.sendDTMF(String(f))}catch(n){console.error("DTMF failed:",n)}},Hu=3,tl=1e3,Fu=()=>new Promise(f=>{const n=we;if(!n)return f(!1);Cr=!0;const s=d=>{Cr=!1,clearTimeout(t),n.off("registered",o),n.off("registrationFailed",c),f(d)},o=()=>s(!0),c=d=>{console.error("SIP re-register rejected:",d==null?void 0:d.cause),s(!1)},t=setTimeout(()=>s(!0),tl);n.on("registered",o),n.on("registrationFailed",c),n.register()}),sl=async f=>{let n=await Se.fetchExtensionStatus(f);if(!n||Number(n.is_register)!==0)return{ext:n,registered:!0};if(!await Fu())return{ext:n,registered:!1};for(let s=0;s<Hu;s++)if(await new Promise(o=>setTimeout(o,tl)),n=await Se.fetchExtensionStatus(f),n&&Number(n.is_register)===1)return{ext:n,registered:!0};return console.warn("[ExtStatus] is_register still 0 after SIP re-register"),{ext:n,registered:!1}},Ar=async(f,n)=>{const s=Se.getExtensionUsername();if(!s)return!1;const{ext:o,registered:c}=await sl(s);return c?f==="Ready"&&(o==null?void 0:o.extension_status)==="Ready"?!0:Se.updateExtensionStatus(s,f,n):!1},ku=async()=>{const{ext:f,registered:n}=await sl(Se.getExtensionUsername());if(!n)return Le("FAILED","Extension not registered after SIP re-register");const s=f==null?void 0:f.extension_status;if(s==="Ready")return Le("REGISTERED"),Wt("READY");const o=typeof s=="string"&&s.toLowerCase().startsWith("aux");Le("SIP_CONNECTED"),Wt(o?"AUX":"NOT_READY",o?{code:s,label:s}:null)},rl=async()=>{const f=await Ar("Ready","ready");return f&&(Le("REGISTERED"),Wt("READY")),f},qu=async()=>{const f=await Ar("Logout","not_ready");return f&&(Le("SIP_CONNECTED"),Wt("NOT_READY")),f},Gu=async(f="AUX",n=f)=>{const s=await Ar("AUX",f);return s&&Wt("AUX",{code:f,label:n}),s},Bu=async()=>{var f;if(!Cr){if(((f=Se.getConfig())==null?void 0:f.autoReady)===!1)return ku();await rl()||Le("FAILED","Failed to hit extension ready API")}},nl=()=>Math.random().toString(36).slice(2,10),Wu=(f={})=>{var p;ll();const n=f.auth||((p=f.pabxConfig)==null?void 0:p.auth)||{};Se.setConfig({...f,auth:n});const s=n.user_pbx||n.username,o=n.pwd_pbx||n.secret,c=Se.getSipHost(),t=Se.getWssHost(),d=n.port||8089;if(!s||!o||!c)return Le("FAILED","Missing SIP credentials (username, password, host)");try{we=new Kn.UA({sockets:[new Kn.WebSocketInterface(`wss://${t}:${d}`)],uri:`sip:${s}@${c}`,authorization_user:s,password:o,register_expires:600,session_timers:!1,contact_uri:`sip:${nl()}@${nl()}.invalid;transport=tls`}),we.on("registered",Bu),we.on("unregistered",()=>Le("FAILED","SIP Unregistered")),we.on("registrationFailed",a=>Le("FAILED",`SIP registration failed: ${a.cause}`)),we.on("disconnected",()=>{bt.registerStatus!=="FAILED"&&Le("FAILED","WebSocket disconnected, retrying...")}),we.on("newRTCSession",xu),we.start()}catch(a){console.error("JsSIP init error:",a),we=null,Le("FAILED",a.message||"Failed to connect to SIP server")}},ll=()=>{Se.stopSound(),clearInterval(Sr),we&&(we.removeAllListeners(),we.stop(),we=null),ee=null,Ne==null||Ne.remove(),Ne=null,bt={...Jn}},Vu={register_status:"onRegisterStatus",agent_status:"onAgentStatus",call_status:"onCallStatus",call_failed:"onCallFailed",incoming_call:"onIncomingCall",sync_call_answered:"onCallAnswered",sync_call_ended:"onCallEnded",sync_call_unanswered:"onCallUnanswered"};function il(){ll(),ts.listeners={}}const ju={init(f={}){return il(),Object.entries(Vu).forEach(([n,s])=>ts.on(n,o=>{var c;n==="register_status"&&o==="SIP_CONNECTED"||(c=f[s])==null||c.call(f,o)})),Wu(f),{dial:Du,answer:Uu,reject:$u,hangup:el,mute:Pu,hold:Mu,sendDtmf:Lu,setReady:rl,setNotReady:qu,setAux:Gu,getState:yu,on:(n,s)=>ts.on(n,s),destroy:il}}};Tt.OmnixWidget=ju,Object.defineProperty(Tt,Symbol.toStringTag,{value:"Module"})});
70
+ `)},Du=f=>Object.fromEntries(Object.keys((f==null?void 0:f.headers)||{}).filter(n=>/^X-/i.test(n)).map(n=>[n,f.getHeader(n)])),Uu=(f,n)=>{var o,c,t;const s=((c=(o=f.remote_identity)==null?void 0:o.uri)==null?void 0:c.user)||"Unknown";return{number:s,name:((t=f.remote_identity)==null?void 0:t.display_name)||ge.getContactName(s)||"",direction:f.direction,headers:f.direction==="incoming"?Du(n):{}}},el=(f,n)=>{Q=f;const s=Uu(f,n);Object.assign(bt,{remote:s,isMuted:!1,isOnHold:!1}),f.connection?Zn(f.connection):f.on("peerconnection",c=>Zn(c.peerconnection)),f.on("sdp",xu(f)),f.on("confirmed",()=>{ge.stopSound(),Vt("InCall"),be("sync_call_answered",s);const c=Date.now();Ar=setInterval(()=>{const t=ge.toHHMMSS((Date.now()-c)/1e3);be("call_duration",t,{callDuration:t})},1e3)}),f.on("muted",()=>be("mute_status",!0,{isMuted:!0})),f.on("unmuted",()=>be("mute_status",!1,{isMuted:!1})),f.on("hold",c=>c.originator==="local"&&be("hold_status",!0,{isOnHold:!0})),f.on("unhold",c=>c.originator==="local"&&be("hold_status",!1,{isOnHold:!1}));const o=c=>t=>{ge.stopSound(),clearInterval(Ar),Ne&&(Ne.srcObject=null),Q=null,be("call_duration","00:00",{callDuration:"00:00",isMuted:!1,isOnHold:!1,remote:null}),Vt("Idle");const d={...s,cause:t.cause,originator:t.originator};c?be("sync_call_ended",d):s.direction==="incoming"?be("sync_call_unanswered",d):t.originator!=="local"&&be("call_failed",t.cause||"Call Failed")};f.on("ended",o(!0)),f.on("failed",o(!1))},$u=({session:f,originator:n,request:s})=>{var o;if(n==="local")return Rr?void 0:el(f);if(Q)return f.terminate({status_code:486,reason_phrase:"Busy Here"});el(f,s),((o=ge.getConfig())==null?void 0:o.ringtone)!==!1&&ge.pushSound(),Vt("Ringing"),be("incoming_call",bt.remote)},tl=/^[0-9A-Za-z+*#._-]+$/,Pu=f=>{if(f=String(f??"").trim(),!(!Re||Q||!f)){if(!tl.test(f))return be("call_failed","Invalid number");Vt("Calling...");try{Re.call(`sip:${f}@${ge.getSipHost()}`,{mediaConstraints:Sr,pcConfig:Cr})}catch(n){console.error("Dial failed:",n),Vt("Idle"),be("call_failed",n.message||"Call Failed")}}},Mu=()=>{ge.stopSound(),(Q==null?void 0:Q.direction)==="incoming"&&!Q.isEstablished()&&Q.answer({mediaConstraints:Sr,pcConfig:Cr})},sl=()=>{ge.stopSound(),Q&&!Q.isEnded()&&Q.terminate()},Lu=sl,Hu=(f=!0)=>{Q!=null&&Q.isEstablished()&&(f?Q.mute({audio:!0}):Q.unmute({audio:!0}))},Fu=(f=!0)=>{Q!=null&&Q.isEstablished()&&(f?Q.hold():Q.unhold())},ku=f=>{if(Q!=null&&Q.isEstablished())try{Q.sendDTMF(String(f))}catch(n){console.error("DTMF failed:",n)}},qu=(f,{attended:n=!1}={})=>new Promise(s=>{f=String(f??"").trim();const o=Q;if(!Re||!(o!=null&&o.isEstablished())||!tl.test(f))return s(!1);const c=`sip:${f}@${ge.getSipHost()}`;let t=null,d=!1;const p=g=>{d||(d=!0,t&&!t.isEnded()&&t.terminate(),g&&!o.isEnded()&&o.terminate(),!g&&!o.isEnded()&&n&&o.unhold(),s(g))},a=(g={})=>{let m=!1;if(!o.refer(c,{...g,eventHandlers:{requestSucceeded:()=>m=!0,requestFailed:()=>p(!1),accepted:()=>p(!0),failed:()=>p(!1)}}))return p(!1);o.once("ended",()=>p(m))};if(!n)return a();o.hold(),Rr=!0;try{t=Re.call(c,{mediaConstraints:Sr,pcConfig:Cr})}catch(g){return console.error("Transfer consult call failed:",g),p(!1)}finally{Rr=!1}t.on("confirmed",()=>a({replaces:t})),t.on("failed",()=>p(!1))}),Gu=3,rl=1e3,Bu=()=>new Promise(f=>{const n=Re;if(!n)return f(!1);vr=!0;const s=d=>{vr=!1,clearTimeout(t),n.off("registered",o),n.off("registrationFailed",c),f(d)},o=()=>s(!0),c=d=>{console.error("SIP re-register rejected:",d==null?void 0:d.cause),s(!1)},t=setTimeout(()=>s(!0),rl);n.on("registered",o),n.on("registrationFailed",c),n.register()}),nl=async f=>{let n=await ge.fetchExtensionStatus(f);if(!n||Number(n.is_register)!==0)return{ext:n,registered:!0};if(!await Bu())return{ext:n,registered:!1};for(let s=0;s<Gu;s++)if(await new Promise(o=>setTimeout(o,rl)),n=await ge.fetchExtensionStatus(f),n&&Number(n.is_register)===1)return{ext:n,registered:!0};return console.warn("[ExtStatus] is_register still 0 after SIP re-register"),{ext:n,registered:!1}},Ir=async(f,n)=>{const s=ge.getExtensionUsername();if(!s)return!1;const{ext:o,registered:c}=await nl(s);return c?f==="Ready"&&(o==null?void 0:o.extension_status)==="Ready"?!0:ge.updateExtensionStatus(s,f,n):!1},Wu=async()=>{const{ext:f,registered:n}=await nl(ge.getExtensionUsername());if(!n)return Le("FAILED","Extension not registered after SIP re-register");const s=f==null?void 0:f.extension_status;if(s==="Ready")return Le("REGISTERED"),Wt("READY");const o=typeof s=="string"&&s.toLowerCase().startsWith("aux");Le("SIP_CONNECTED"),Wt(o?"AUX":"NOT_READY",o?{code:s,label:s}:null)},ll=async()=>{const f=await Ir("Ready","ready");return f&&(Le("REGISTERED"),Wt("READY")),f},Vu=async()=>{const f=await Ir("Logout","not_ready");return f&&(Le("SIP_CONNECTED"),Wt("NOT_READY")),f},ju=async(f="AUX",n=f)=>{const s=await Ir("AUX",f);return s&&Wt("AUX",{code:f,label:n}),s},Yu=async()=>{var f;if(!vr){if(((f=ge.getConfig())==null?void 0:f.autoReady)===!1)return Wu();await ll()||Le("FAILED","Failed to hit extension ready API")}},il=()=>Math.random().toString(36).slice(2,10),Ku=(f={})=>{var p;al();const n=f.auth||((p=f.pabxConfig)==null?void 0:p.auth)||{};ge.setConfig({...f,auth:n});const s=n.user_pbx||n.username,o=n.pwd_pbx||n.secret,c=ge.getSipHost(),t=ge.getWssHost(),d=n.port||8089;if(!s||!o||!c)return Le("FAILED","Missing SIP credentials (username, password, host)");try{Re=new Jn.UA({sockets:[new Jn.WebSocketInterface(`wss://${t}:${d}`)],uri:`sip:${s}@${c}`,authorization_user:s,password:o,register_expires:600,session_timers:!1,contact_uri:`sip:${il()}@${il()}.invalid;transport=tls`}),Re.on("registered",Yu),Re.on("unregistered",()=>Le("FAILED","SIP Unregistered")),Re.on("registrationFailed",a=>Le("FAILED",`SIP registration failed: ${a.cause}`)),Re.on("disconnected",()=>{bt.registerStatus!=="FAILED"&&Le("FAILED","WebSocket disconnected, retrying...")}),Re.on("newRTCSession",$u),Re.start()}catch(a){console.error("JsSIP init error:",a),Re=null,Le("FAILED",a.message||"Failed to connect to SIP server")}},al=()=>{ge.stopSound(),clearInterval(Ar),Re&&(Re.removeAllListeners(),Re.stop(),Re=null),Q=null,Ne==null||Ne.remove(),Ne=null,bt={...Qn}},zu={register_status:"onRegisterStatus",agent_status:"onAgentStatus",call_status:"onCallStatus",call_failed:"onCallFailed",incoming_call:"onIncomingCall",sync_call_answered:"onCallAnswered",sync_call_ended:"onCallEnded",sync_call_unanswered:"onCallUnanswered"};function ol(){al(),ts.listeners={}}const Xu={init(f={}){return ol(),Object.entries(zu).forEach(([n,s])=>ts.on(n,o=>{var c;n==="register_status"&&o==="SIP_CONNECTED"||(c=f[s])==null||c.call(f,o)})),Ku(f),{dial:Pu,answer:Mu,reject:Lu,hangup:sl,mute:Hu,hold:Fu,sendDtmf:ku,transfer:qu,setReady:ll,setNotReady:Vu,setAux:ju,getState:Ou,on:(n,s)=>ts.on(n,s),destroy:ol}}};Tt.OmnixWidget=Xu,Object.defineProperty(Tt,Symbol.toStringTag,{value:"Module"})});