@tbisoftware/phone 1.0.8 → 1.0.10

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.
Files changed (3) hide show
  1. package/dist/index.cjs +31 -31
  2. package/dist/index.js +2817 -2781
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,52 +1,52 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),re=require("react");function Ts(...w){return w.filter(Boolean).join(" ")}function pt(w){const I=Math.floor(w/3600),i=Math.floor(w%3600/60),_=w%60;return I>0?`${I.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`:`${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`}const zl={calling:"Llamando",waitingResponse:"Esperando respuesta...",cancel:"Cancelar",hangUp:"Colgar",callEnded:"Llamada finalizada",duration:"Duración",inactive:"Inactivo",inCall:"En llamada",placeholder:"Número a llamar",callHistory:"Historial de llamadas",noCallsRegistered:"No hay llamadas registradas",callsRegistered:"llamada(s) registrada(s)",noCalls:"No hay llamadas",startingCall:"Iniciando llamada a",callInProgress:"Ya hay una llamada en curso"};function Kl(w){return w&&w.__esModule&&Object.prototype.hasOwnProperty.call(w,"default")?w.default:w}const Yl="JsSIP",Jl="3.11.1",Qn={title:Yl,version:Jl};var kt,dn;function ce(){if(dn)return kt;dn=1;const w=Qn;return kt={USER_AGENT:`${w.title} ${w.version}`,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",DTMF_TRANSPORT:{INFO:"INFO",RFC2833:"RFC2833"},REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60,CONNECTION_RECOVERY_MAX_INTERVAL:30,CONNECTION_RECOVERY_MIN_INTERVAL:2},kt}var qt,_n;function we(){if(_n)return qt;_n=1;class w extends Error{constructor(t,d){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=t,this.value=d,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class I extends Error{constructor(t){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=t,this.message=`Invalid status: ${t}`}}class i extends Error{constructor(t){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=t}}class _ extends Error{constructor(t){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=t}}return qt={ConfigurationError:w,InvalidStateError:I,NotSupportedError:i,NotReadyError:_},qt}var ae={},jt,pn;function Ss(){if(pn)return jt;pn=1;const w=ye(),I=Ce();return jt=class Zn{static parse(_){if(_=I.parse(_,"Name_Addr_Header"),_!==-1)return _}constructor(_,R,t){if(!_||!(_ instanceof w))throw new TypeError('missing or invalid "uri" parameter');this._uri=_,this._parameters={},this.display_name=R;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(_){this._display_name=_===0?"0":_}setParam(_,R){_&&(this._parameters[_.toLowerCase()]=typeof R>"u"||R===null?null:R.toString())}getParam(_){if(_)return this._parameters[_.toLowerCase()]}hasParam(_){if(_)return this._parameters.hasOwnProperty(_.toLowerCase())&&!0||!1}deleteParam(_){if(_=_.toLowerCase(),this._parameters.hasOwnProperty(_)){const R=this._parameters[_];return delete this._parameters[_],R}}clearParams(){this._parameters={}}clone(){return new Zn(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(_){return _.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let _=this._display_name?`"${this._quote(this._display_name)}" `:"";_+=`<${this._uri.toString()}>`;for(const R in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,R)&&(_+=`;${R}`,this._parameters[R]!==null&&(_+=`=${this._parameters[R]}`));return _}},jt}var Gt,mn;function Ce(){return mn||(mn=1,Gt=(function(){function w(i){return'"'+i.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 I={parse:function(i,_){var R={CRLF:g,DIGIT:c,ALPHA:A,HEXDIG:U,WSP:v,OCTET:N,DQUOTE:$,SP:C,HTAB:y,alphanum:F,reserved:H,unreserved:o,mark:f,escaped:T,LWS:p,SWS:S,HCOLON:D,TEXT_UTF8_TRIM:E,TEXT_UTF8char:b,UTF8_NONASCII:O,UTF8_CONT:M,LHEX:z,token:j,token_nodot:ie,separators:he,word:oe,STAR:Y,SLASH:de,EQUAL:Q,LPAREN:xe,RPAREN:Ne,RAQUOT:Ae,LAQUOT:Re,COMMA:ee,SEMI:X,COLON:Oe,LDQUOT:be,RDQUOT:ze,comment:K,ctext:V,quoted_string:J,quoted_string_clean:Z,qdtext:ne,quoted_pair:le,SIP_URI_noparams:te,SIP_URI:ve,uri_scheme:pe,uri_scheme_sips:Rs,uri_scheme_sip:bs,userinfo:Ke,user:ws,user_unreserved:mt,password:ys,hostport:Ye,host:Me,hostname:gt,domainlabel:Tt,toplabel:Is,IPv6reference:Ct,IPv6address:vt,h16:G,ls32:me,IPv4address:Le,dec_octet:Fe,port:xs,uri_parameters:Ns,uri_parameter:Et,transport_param:Os,user_param:Ds,method_param:Us,ttl_param:Ps,maddr_param:Ms,lr_param:Ls,other_param:Fs,pname:Hs,pvalue:$s,paramchar:He,param_unreserved:ks,headers:qs,header:Je,hname:js,hvalue:Gs,hnv_unreserved:$e,Request_Response:ul,Request_Line:Bs,Request_URI:Ws,absoluteURI:St,hier_part:Vs,net_path:zs,abs_path:Xe,opaque_part:Ks,uric:ke,uric_no_slash:Ys,path_segments:Js,segment:Qe,param:At,pchar:qe,scheme:Xs,authority:Qs,srvr:Zs,reg_name:er,query:tr,SIP_Version:Rt,INVITEm:sr,ACKm:rr,OPTIONSm:nr,BYEm:lr,CANCELm:ir,REGISTERm:ar,SUBSCRIBEm:or,NOTIFYm:ur,REFERm:cr,Method:Ze,Status_Line:fr,Status_Code:hr,extension_code:dr,Reason_Phrase:_r,Allow_Events:cl,Call_ID:fl,Contact:hl,contact_param:et,name_addr:De,display_name:tt,contact_params:bt,c_p_q:pr,c_p_expires:mr,delta_seconds:Ue,qvalue:gr,generic_param:ue,gen_value:Tr,Content_Disposition:dl,disp_type:Cr,disp_param:wt,handling_param:vr,Content_Encoding:_l,Content_Length:pl,Content_Type:ml,media_type:Er,m_type:Sr,discrete_type:Ar,composite_type:Rr,extension_token:st,x_token:br,m_subtype:wr,m_parameter:yt,m_value:yr,CSeq:gl,CSeq_value:Ir,Expires:Tl,Event:Cl,event_type:je,From:vl,from_param:It,tag_param:xt,Max_Forwards:El,Min_Expires:Sl,Name_Addr_Header:Al,Proxy_Authenticate:Rl,challenge:Nt,other_challenge:xr,auth_param:Ge,digest_cln:rt,realm:Nr,realm_value:Or,domain:Dr,URI:nt,nonce:Ur,nonce_value:Pr,opaque:Mr,stale:Lr,algorithm:Fr,qop_options:Hr,qop_value:lt,Proxy_Require:bl,Record_Route:wl,rec_route:it,Reason:yl,reason_param:Ot,reason_cause:$r,Require:Il,Route:xl,route_param:at,Subscription_State:Nl,substate_value:kr,subexp_params:Dt,event_reason_value:qr,Subject:Ol,Supported:Dl,To:Ul,to_param:Ut,Via:Pl,via_param:ot,via_params:Pt,via_ttl:jr,via_maddr:Gr,via_received:Br,via_branch:Wr,response_port:Vr,rport:zr,sent_protocol:Kr,protocol_name:Yr,transport:Jr,sent_by:Xr,via_host:Qr,via_port:Zr,ttl:Mt,WWW_Authenticate:Ml,Session_Expires:Ll,s_e_expires:en,s_e_params:Lt,s_e_refresher:tn,extension_header:Fl,header_value:sn,message_body:Hl,uuid_URI:$l,uuid:rn,hex4:Ee,hex8:nn,hex12:ln,Refer_To:kl,Replaces:ql,call_id:an,replaces_param:Ft,to_tag:on,from_tag:un,early_flag:cn};if(_!==void 0){if(R[_]===void 0)throw new Error("Invalid rule name: "+w(_)+".")}else _="CRLF";var t=0,d=0,h=[];function l(e){t<d||(t>d&&(d=t,h=[]),h.push(e))}function g(){var e;return i.substr(t,2)===`\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),re=require("react");function Cs(...b){return b.filter(Boolean).join(" ")}function pt(b){const y=Math.floor(b/3600),i=Math.floor(b%3600/60),_=b%60;return y>0?`${y.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`:`${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`}const Kl={calling:"Llamando",waitingResponse:"Esperando respuesta...",cancel:"Cancelar",hangUp:"Colgar",callEnded:"Llamada finalizada",duration:"Duración",inactive:"Inactivo",inCall:"En llamada",placeholder:"Número a llamar",callHistory:"Historial de llamadas",noCallsRegistered:"No hay llamadas registradas",callsRegistered:"llamada(s) registrada(s)",noCalls:"No hay llamadas",startingCall:"Iniciando llamada a",callInProgress:"Ya hay una llamada en curso"};function Yl(b){return b&&b.__esModule&&Object.prototype.hasOwnProperty.call(b,"default")?b.default:b}const Jl="JsSIP",Xl="3.11.1",Zn={title:Jl,version:Xl};var kt,_n;function oe(){if(_n)return kt;_n=1;const b=Zn;return kt={USER_AGENT:`${b.title} ${b.version}`,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",DTMF_TRANSPORT:{INFO:"INFO",RFC2833:"RFC2833"},REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60,CONNECTION_RECOVERY_MAX_INTERVAL:30,CONNECTION_RECOVERY_MIN_INTERVAL:2},kt}var qt,pn;function we(){if(pn)return qt;pn=1;class b extends Error{constructor(t,d){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=t,this.value=d,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class y extends Error{constructor(t){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=t,this.message=`Invalid status: ${t}`}}class i extends Error{constructor(t){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=t}}class _ extends Error{constructor(t){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=t}}return qt={ConfigurationError:b,InvalidStateError:y,NotSupportedError:i,NotReadyError:_},qt}var ie={},jt,mn;function As(){if(mn)return jt;mn=1;const b=ye(),y=Ce();return jt=class el{static parse(_){if(_=y.parse(_,"Name_Addr_Header"),_!==-1)return _}constructor(_,S,t){if(!_||!(_ instanceof b))throw new TypeError('missing or invalid "uri" parameter');this._uri=_,this._parameters={},this.display_name=S;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(_){this._display_name=_===0?"0":_}setParam(_,S){_&&(this._parameters[_.toLowerCase()]=typeof S>"u"||S===null?null:S.toString())}getParam(_){if(_)return this._parameters[_.toLowerCase()]}hasParam(_){if(_)return this._parameters.hasOwnProperty(_.toLowerCase())&&!0||!1}deleteParam(_){if(_=_.toLowerCase(),this._parameters.hasOwnProperty(_)){const S=this._parameters[_];return delete this._parameters[_],S}}clearParams(){this._parameters={}}clone(){return new el(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(_){return _.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let _=this._display_name?`"${this._quote(this._display_name)}" `:"";_+=`<${this._uri.toString()}>`;for(const S in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,S)&&(_+=`;${S}`,this._parameters[S]!==null&&(_+=`=${this._parameters[S]}`));return _}},jt}var Gt,gn;function Ce(){return gn||(gn=1,Gt=(function(){function b(i){return'"'+i.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 y={parse:function(i,_){var S={CRLF:m,DIGIT:c,ALPHA:R,HEXDIG:D,WSP:E,OCTET:N,DQUOTE:$,SP:C,HTAB:I,alphanum:F,reserved:H,unreserved:o,mark:f,escaped:T,LWS:p,SWS:A,HCOLON:O,TEXT_UTF8_TRIM:v,TEXT_UTF8char:w,UTF8_NONASCII:U,UTF8_CONT:M,LHEX:Y,token:B,token_nodot:ue,separators:de,word:he,STAR:X,SLASH:_e,EQUAL:Q,LPAREN:xe,RPAREN:Ne,RAQUOT:Ae,LAQUOT:Re,COMMA:ee,SEMI:J,COLON:Oe,LDQUOT:be,RDQUOT:ze,comment:z,ctext:V,quoted_string:K,quoted_string_clean:Z,qdtext:ne,quoted_pair:le,SIP_URI_noparams:te,SIP_URI:ve,uri_scheme:pe,uri_scheme_sips:bs,uri_scheme_sip:ws,userinfo:Ke,user:ys,user_unreserved:mt,password:Is,hostport:Ye,host:Le,hostname:gt,domainlabel:Tt,toplabel:xs,IPv6reference:Ct,IPv6address:vt,h16:j,ls32:me,IPv4address:Fe,dec_octet:He,port:Ns,uri_parameters:Os,uri_parameter:Et,transport_param:Ds,user_param:Us,method_param:Ps,ttl_param:Ms,maddr_param:Ls,lr_param:Fs,other_param:Hs,pname:$s,pvalue:ks,paramchar:$e,param_unreserved:qs,headers:js,header:Je,hname:Gs,hvalue:Bs,hnv_unreserved:ke,Request_Response:cl,Request_Line:Ws,Request_URI:Vs,absoluteURI:St,hier_part:zs,net_path:Ks,abs_path:Xe,opaque_part:Ys,uric:qe,uric_no_slash:Js,path_segments:Xs,segment:Qe,param:At,pchar:je,scheme:Qs,authority:Zs,srvr:er,reg_name:tr,query:sr,SIP_Version:Rt,INVITEm:rr,ACKm:nr,OPTIONSm:lr,BYEm:ir,CANCELm:ar,REGISTERm:or,SUBSCRIBEm:ur,NOTIFYm:cr,REFERm:fr,Method:Ze,Status_Line:hr,Status_Code:dr,extension_code:_r,Reason_Phrase:pr,Allow_Events:fl,Call_ID:hl,Contact:dl,contact_param:et,name_addr:De,display_name:tt,contact_params:bt,c_p_q:mr,c_p_expires:gr,delta_seconds:Ue,qvalue:Tr,generic_param:ae,gen_value:Cr,Content_Disposition:_l,disp_type:vr,disp_param:wt,handling_param:Er,Content_Encoding:pl,Content_Length:ml,Content_Type:gl,media_type:Sr,m_type:Ar,discrete_type:Rr,composite_type:br,extension_token:st,x_token:wr,m_subtype:yr,m_parameter:yt,m_value:Ir,CSeq:Tl,CSeq_value:xr,Expires:Cl,Event:vl,event_type:Ge,From:El,from_param:It,tag_param:xt,Max_Forwards:Sl,Min_Expires:Al,Name_Addr_Header:Rl,Proxy_Authenticate:bl,challenge:Nt,other_challenge:Nr,auth_param:Be,digest_cln:rt,realm:Or,realm_value:Dr,domain:Ur,URI:nt,nonce:Pr,nonce_value:Mr,opaque:Lr,stale:Fr,algorithm:Hr,qop_options:$r,qop_value:lt,Proxy_Require:wl,Record_Route:yl,rec_route:it,Reason:Il,reason_param:Ot,reason_cause:kr,Require:xl,Route:Nl,route_param:at,Subscription_State:Ol,substate_value:qr,subexp_params:Dt,event_reason_value:jr,Subject:Dl,Supported:Ul,To:Pl,to_param:Ut,Via:Ml,via_param:ot,via_params:Pt,via_ttl:Gr,via_maddr:Br,via_received:Wr,via_branch:Vr,response_port:zr,rport:Kr,sent_protocol:Yr,protocol_name:Jr,transport:Xr,sent_by:Qr,via_host:Zr,via_port:en,ttl:Mt,WWW_Authenticate:Ll,Session_Expires:Fl,s_e_expires:tn,s_e_params:Lt,s_e_refresher:sn,extension_header:Hl,header_value:rn,message_body:$l,uuid_URI:kl,uuid:nn,hex4:Ee,hex8:ln,hex12:an,Refer_To:ql,Replaces:jl,call_id:on,replaces_param:Ft,to_tag:un,from_tag:cn,early_flag:fn};if(_!==void 0){if(S[_]===void 0)throw new Error("Invalid rule name: "+b(_)+".")}else _="CRLF";var t=0,d=0,h=[];function n(e){t<d||(t>d&&(d=t,h=[]),h.push(e))}function m(){var e;return i.substr(t,2)===`\r
2
2
  `?(e=`\r
3
- `,t+=2):(e=null,l('"\\r\\n"')),e}function c(){var e;return/^[0-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[0-9]")),e}function A(){var e;return/^[a-zA-Z]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[a-zA-Z]")),e}function U(){var e;return/^[0-9a-fA-F]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[0-9a-fA-F]")),e}function v(){var e;return e=C(),e===null&&(e=y()),e}function N(){var e;return/^[\0-\xFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\0-\\xFF]")),e}function $(){var e;return/^["]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l('["]')),e}function C(){var e;return i.charCodeAt(t)===32?(e=" ",t++):(e=null,l('" "')),e}function y(){var e;return i.charCodeAt(t)===9?(e=" ",t++):(e=null,l('"\\t"')),e}function F(){var e;return/^[a-zA-Z0-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[a-zA-Z0-9]")),e}function H(){var e;return i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","'))))))))))),e}function o(){var e;return e=F(),e===null&&(e=f()),e}function f(){var e;return i.charCodeAt(t)===45?(e="-",t++):(e=null,l('"-"')),e===null&&(i.charCodeAt(t)===95?(e="_",t++):(e=null,l('"_"')),e===null&&(i.charCodeAt(t)===46?(e=".",t++):(e=null,l('"."')),e===null&&(i.charCodeAt(t)===33?(e="!",t++):(e=null,l('"!"')),e===null&&(i.charCodeAt(t)===126?(e="~",t++):(e=null,l('"~"')),e===null&&(i.charCodeAt(t)===42?(e="*",t++):(e=null,l('"*"')),e===null&&(i.charCodeAt(t)===39?(e="'",t++):(e=null,l(`"'"`)),e===null&&(i.charCodeAt(t)===40?(e="(",t++):(e=null,l('"("')),e===null&&(i.charCodeAt(t)===41?(e=")",t++):(e=null,l('")"')))))))))),e}function T(){var e,s,r,n,a;return n=t,a=t,i.charCodeAt(t)===37?(e="%",t++):(e=null,l('"%"')),e!==null?(s=U(),s!==null?(r=U(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){return m.join("")})(n,e)),e===null&&(t=n),e}function p(){var e,s,r,n,a,u;for(n=t,a=t,u=t,e=[],s=v();s!==null;)e.push(s),s=v();if(e!==null?(s=g(),s!==null?e=[e,s]:(e=null,t=u)):(e=null,t=u),e=e!==null?e:"",e!==null){if(r=v(),r!==null)for(s=[];r!==null;)s.push(r),r=v();else s=null;s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e!==null&&(e=(function(m){return" "})()),e===null&&(t=n),e}function S(){var e;return e=p(),e=e!==null?e:"",e}function D(){var e,s,r,n,a;for(n=t,a=t,e=[],s=C(),s===null&&(s=y());s!==null;)e.push(s),s=C(),s===null&&(s=y());return e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return":"})()),e===null&&(t=n),e}function E(){var e,s,r,n,a,u,m;if(a=t,u=t,s=b(),s!==null)for(e=[];s!==null;)e.push(s),s=b();else e=null;if(e!==null){for(s=[],m=t,r=[],n=p();n!==null;)r.push(n),n=p();for(r!==null?(n=b(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;){for(s.push(r),m=t,r=[],n=p();n!==null;)r.push(n),n=p();r!==null?(n=b(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m)}s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){return i.substring(t,P)})(a)),e===null&&(t=a),e}function b(){var e;return/^[!-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[!-~]")),e===null&&(e=O()),e}function O(){var e;return/^[\x80-\uFFFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\x80-\\uFFFF]")),e}function M(){var e;return/^[\x80-\xBF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\x80-\\xBF]")),e}function z(){var e;return e=c(),e===null&&(/^[a-f]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[a-f]"))),e}function j(){var e,s,r;if(r=t,s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"'))))))))))));else e=null;return e!==null&&(e=(function(n){return i.substring(t,n)})(r)),e===null&&(t=r),e}function ie(){var e,s,r;if(r=t,s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"'))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')))))))))));else e=null;return e!==null&&(e=(function(n){return i.substring(t,n)})(r)),e===null&&(t=r),e}function he(){var e;return i.charCodeAt(t)===40?(e="(",t++):(e=null,l('"("')),e===null&&(i.charCodeAt(t)===41?(e=")",t++):(e=null,l('")"')),e===null&&(i.charCodeAt(t)===60?(e="<",t++):(e=null,l('"<"')),e===null&&(i.charCodeAt(t)===62?(e=">",t++):(e=null,l('">"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===92?(e="\\",t++):(e=null,l('"\\\\"')),e===null&&(e=$(),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,l('"]"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===123?(e="{",t++):(e=null,l('"{"')),e===null&&(i.charCodeAt(t)===125?(e="}",t++):(e=null,l('"}"')),e===null&&(e=C(),e===null&&(e=y())))))))))))))))))),e}function oe(){var e,s,r;if(r=t,s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')),s===null&&(i.charCodeAt(t)===40?(s="(",t++):(s=null,l('"("')),s===null&&(i.charCodeAt(t)===41?(s=")",t++):(s=null,l('")"')),s===null&&(i.charCodeAt(t)===60?(s="<",t++):(s=null,l('"<"')),s===null&&(i.charCodeAt(t)===62?(s=">",t++):(s=null,l('">"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===92?(s="\\",t++):(s=null,l('"\\\\"')),s===null&&(s=$(),s===null&&(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s===null&&(i.charCodeAt(t)===91?(s="[",t++):(s=null,l('"["')),s===null&&(i.charCodeAt(t)===93?(s="]",t++):(s=null,l('"]"')),s===null&&(i.charCodeAt(t)===63?(s="?",t++):(s=null,l('"?"')),s===null&&(i.charCodeAt(t)===123?(s="{",t++):(s=null,l('"{"')),s===null&&(i.charCodeAt(t)===125?(s="}",t++):(s=null,l('"}"'))))))))))))))))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,l('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,l('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,l('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,l('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,l(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,l('"~"')),s===null&&(i.charCodeAt(t)===40?(s="(",t++):(s=null,l('"("')),s===null&&(i.charCodeAt(t)===41?(s=")",t++):(s=null,l('")"')),s===null&&(i.charCodeAt(t)===60?(s="<",t++):(s=null,l('"<"')),s===null&&(i.charCodeAt(t)===62?(s=">",t++):(s=null,l('">"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===92?(s="\\",t++):(s=null,l('"\\\\"')),s===null&&(s=$(),s===null&&(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s===null&&(i.charCodeAt(t)===91?(s="[",t++):(s=null,l('"["')),s===null&&(i.charCodeAt(t)===93?(s="]",t++):(s=null,l('"]"')),s===null&&(i.charCodeAt(t)===63?(s="?",t++):(s=null,l('"?"')),s===null&&(i.charCodeAt(t)===123?(s="{",t++):(s=null,l('"{"')),s===null&&(i.charCodeAt(t)===125?(s="}",t++):(s=null,l('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=(function(n){return i.substring(t,n)})(r)),e===null&&(t=r),e}function Y(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===42?(s="*",t++):(s=null,l('"*"')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"*"})()),e===null&&(t=n),e}function de(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"/"})()),e===null&&(t=n),e}function Q(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"="})()),e===null&&(t=n),e}function xe(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===40?(s="(",t++):(s=null,l('"("')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"("})()),e===null&&(t=n),e}function Ne(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===41?(s=")",t++):(s=null,l('")"')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return")"})()),e===null&&(t=n),e}function Ae(){var e,s,r,n;return r=t,n=t,i.charCodeAt(t)===62?(e=">",t++):(e=null,l('">"')),e!==null?(s=S(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return">"})()),e===null&&(t=r),e}function Re(){var e,s,r,n;return r=t,n=t,e=S(),e!==null?(i.charCodeAt(t)===60?(s="<",t++):(s=null,l('"<"')),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return"<"})()),e===null&&(t=r),e}function ee(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return","})()),e===null&&(t=n),e}function X(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return";"})()),e===null&&(t=n),e}function Oe(){var e,s,r,n,a;return n=t,a=t,e=S(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=S(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return":"})()),e===null&&(t=n),e}function be(){var e,s,r,n;return r=t,n=t,e=S(),e!==null?(s=$(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return'"'})()),e===null&&(t=r),e}function ze(){var e,s,r,n;return r=t,n=t,e=$(),e!==null?(s=S(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a){return'"'})()),e===null&&(t=r),e}function K(){var e,s,r,n;if(n=t,e=xe(),e!==null){for(s=[],r=V(),r===null&&(r=le(),r===null&&(r=K()));r!==null;)s.push(r),r=V(),r===null&&(r=le(),r===null&&(r=K()));s!==null?(r=Ne(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)}else e=null,t=n;return e}function V(){var e;return/^[!-']/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[!-']")),e===null&&(/^[*-[]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[*-[]")),e===null&&(/^[\]-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\]-~]")),e===null&&(e=O(),e===null&&(e=p())))),e}function J(){var e,s,r,n,a,u;if(a=t,u=t,e=S(),e!==null)if(s=$(),s!==null){for(r=[],n=ne(),n===null&&(n=le());n!==null;)r.push(n),n=ne(),n===null&&(n=le());r!==null?(n=$(),n!==null?e=[e,s,r,n]:(e=null,t=u)):(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(m){return i.substring(t,m)})(a)),e===null&&(t=a),e}function Z(){var e,s,r,n,a,u;if(a=t,u=t,e=S(),e!==null)if(s=$(),s!==null){for(r=[],n=ne(),n===null&&(n=le());n!==null;)r.push(n),n=ne(),n===null&&(n=le());r!==null?(n=$(),n!==null?e=[e,s,r,n]:(e=null,t=u)):(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(m){var P=i.substring(t,m).trim();return P.substring(1,P.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")})(a)),e===null&&(t=a),e}function ne(){var e;return e=p(),e===null&&(i.charCodeAt(t)===33?(e="!",t++):(e=null,l('"!"')),e===null&&(/^[#-[]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[#-[]")),e===null&&(/^[\]-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[\\]-~]")),e===null&&(e=O())))),e}function le(){var e,s,r;return r=t,i.charCodeAt(t)===92?(e="\\",t++):(e=null,l('"\\\\"')),e!==null?(/^[\0-\t]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[\\0-\\t]")),s===null&&(/^[\x0B-\f]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[\\x0B-\\f]")),s===null&&(/^[\x0E-]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[\\x0E-]")))),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function te(){var e,s,r,n,a,u;return a=t,u=t,e=pe(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=Ke(),r=r!==null?r:"",r!==null?(n=Ye(),n!==null?e=[e,s,r,n]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=(function(m){try{x.uri=new fn(x.scheme,x.user,x.host,x.port),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port}catch{x=-1}})()),e===null&&(t=a),e}function ve(){var e,s,r,n,a,u,m,P;return m=t,P=t,e=pe(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=Ke(),r=r!==null?r:"",r!==null?(n=Ye(),n!==null?(a=Ns(),a!==null?(u=qs(),u=u!==null?u:"",u!==null?e=[e,s,r,n,a,u]:(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P),e!==null&&(e=(function(k){try{x.uri=new fn(x.scheme,x.user,x.host,x.port,x.uri_params,x.uri_headers),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port,delete x.uri_params,_==="SIP_URI"&&(x=x.uri)}catch{x=-1}})()),e===null&&(t=m),e}function pe(){var e;return e=Rs(),e===null&&(e=bs()),e}function Rs(){var e,s;return s=t,i.substr(t,4).toLowerCase()==="sips"?(e=i.substr(t,4),t+=4):(e=null,l('"sips"')),e!==null&&(e=(function(r,n){x.scheme=n.toLowerCase()})(s,e)),e===null&&(t=s),e}function bs(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"sip"')),e!==null&&(e=(function(r,n){x.scheme=n.toLowerCase()})(s,e)),e===null&&(t=s),e}function Ke(){var e,s,r,n,a,u;return n=t,a=t,e=ws(),e!==null?(u=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=ys(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?(i.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){x.user=decodeURIComponent(i.substring(t-1,m))})(n)),e===null&&(t=n),e}function ws(){var e,s;if(s=o(),s===null&&(s=T(),s===null&&(s=mt())),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(s=mt()));else e=null;return e}function mt(){var e;return i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"'))))))))),e}function ys(){var e,s,r;for(r=t,e=[],s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","'))))))));s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","'))))))));return e!==null&&(e=(function(n){x.password=i.substring(t,n)})(r)),e===null&&(t=r),e}function Ye(){var e,s,r,n,a;return n=t,e=Me(),e!==null?(a=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=xs(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function Me(){var e,s;return s=t,e=gt(),e===null&&(e=Le(),e===null&&(e=Ct())),e!==null&&(e=(function(r){return x.host=i.substring(t,r).toLowerCase(),x.host})(s)),e===null&&(t=s),e}function gt(){var e,s,r,n,a,u;for(n=t,a=t,e=[],u=t,s=Tt(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u);s!==null;)e.push(s),u=t,s=Tt(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u);return e!==null?(s=Is(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){return x.host_type="domain",i.substring(t,m)})(n)),e===null&&(t=n),e}function Tt(){var e,s,r,n;if(n=t,e=F(),e!==null){for(s=[],r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));r!==null;)s.push(r),r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));s!==null?e=[e,s]:(e=null,t=n)}else e=null,t=n;return e}function Is(){var e,s,r,n;if(n=t,e=A(),e!==null){for(s=[],r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));r!==null;)s.push(r),r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"'))));s!==null?e=[e,s]:(e=null,t=n)}else e=null,t=n;return e}function Ct(){var e,s,r,n,a;return n=t,a=t,i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e!==null?(s=vt(),s!==null?(i.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return x.host_type="IPv6",i.substring(t,u)})(n)),e===null&&(t=n),e}function vt(){var e,s,r,n,a,u,m,P,k,W,se,Te,ut,$t,L,B;return $t=t,L=t,e=G(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?(i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=G(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=G(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?(k=G(),k!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,l('":"')),W!==null?(se=G(),se!==null?(i.charCodeAt(t)===58?(Te=":",t++):(Te=null,l('":"')),Te!==null?(ut=me(),ut!==null?e=[e,s,r,n,a,u,m,P,k,W,se,Te,ut]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=G(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,l('":"')),k!==null?(W=G(),W!==null?(i.charCodeAt(t)===58?(se=":",t++):(se=null,l('":"')),se!==null?(Te=me(),Te!==null?e=[e,s,r,n,a,u,m,P,k,W,se,Te]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=G(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,l('":"')),k!==null?(W=me(),W!==null?e=[e,s,r,n,a,u,m,P,k,W]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=me(),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=me(),u!==null?e=[e,s,r,n,a,u]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=me(),n!==null?e=[e,s,r,n]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=me(),s!==null?e=[e,s]:(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,l('"::"')),e!==null?(s=G(),s!==null?e=[e,s]:(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(i.substr(t,2)==="::"?(s="::",t+=2):(s=null,l('"::"')),s!==null?(r=G(),r!==null?(i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=G(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=G(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?(k=G(),k!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,l('":"')),W!==null?(se=me(),se!==null?e=[e,s,r,n,a,u,m,P,k,W,se]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?s=[s,r]:(s=null,t=B)):(s=null,t=B),s=s!==null?s:"",s!==null?(i.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(n=G(),n!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=G(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,l('":"')),k!==null?(W=me(),W!==null?e=[e,s,r,n,a,u,m,P,k,W]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?s=[s,r]:(s=null,t=B)):(s=null,t=B),s=s!==null?s:"",s!==null?(B=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?r=[r,n]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(i.substr(t,2)==="::"?(n="::",t+=2):(n=null,l('"::"')),n!==null?(a=G(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=G(),m!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,l('":"')),P!==null?(k=me(),k!==null?e=[e,s,r,n,a,u,m,P,k]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?s=[s,r]:(s=null,t=B)):(s=null,t=B),s=s!==null?s:"",s!==null?(B=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?r=[r,n]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=G(),a!==null?n=[n,a]:(n=null,t=B)):(n=null,t=B),n=n!==null?n:"",n!==null?(i.substr(t,2)==="::"?(a="::",t+=2):(a=null,l('"::"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=me(),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?s=[s,r]:(s=null,t=B)):(s=null,t=B),s=s!==null?s:"",s!==null?(B=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?r=[r,n]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=G(),a!==null?n=[n,a]:(n=null,t=B)):(n=null,t=B),n=n!==null?n:"",n!==null?(B=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=G(),u!==null?a=[a,u]:(a=null,t=B)):(a=null,t=B),a=a!==null?a:"",a!==null?(i.substr(t,2)==="::"?(u="::",t+=2):(u=null,l('"::"')),u!==null?(m=me(),m!==null?e=[e,s,r,n,a,u,m]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?s=[s,r]:(s=null,t=B)):(s=null,t=B),s=s!==null?s:"",s!==null?(B=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?r=[r,n]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=G(),a!==null?n=[n,a]:(n=null,t=B)):(n=null,t=B),n=n!==null?n:"",n!==null?(B=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=G(),u!==null?a=[a,u]:(a=null,t=B)):(a=null,t=B),a=a!==null?a:"",a!==null?(B=t,i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=G(),m!==null?u=[u,m]:(u=null,t=B)):(u=null,t=B),u=u!==null?u:"",u!==null?(i.substr(t,2)==="::"?(m="::",t+=2):(m=null,l('"::"')),m!==null?(P=G(),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?s=[s,r]:(s=null,t=B)):(s=null,t=B),s=s!==null?s:"",s!==null?(B=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r!==null?(n=G(),n!==null?r=[r,n]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(n=":",t++):(n=null,l('":"')),n!==null?(a=G(),a!==null?n=[n,a]:(n=null,t=B)):(n=null,t=B),n=n!==null?n:"",n!==null?(B=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,l('":"')),a!==null?(u=G(),u!==null?a=[a,u]:(a=null,t=B)):(a=null,t=B),a=a!==null?a:"",a!==null?(B=t,i.charCodeAt(t)===58?(u=":",t++):(u=null,l('":"')),u!==null?(m=G(),m!==null?u=[u,m]:(u=null,t=B)):(u=null,t=B),u=u!==null?u:"",u!==null?(B=t,i.charCodeAt(t)===58?(m=":",t++):(m=null,l('":"')),m!==null?(P=G(),P!==null?m=[m,P]:(m=null,t=B)):(m=null,t=B),m=m!==null?m:"",m!==null?(i.substr(t,2)==="::"?(P="::",t+=2):(P=null,l('"::"')),P!==null?e=[e,s,r,n,a,u,m,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L))))))))))))))),e!==null&&(e=(function(Vl){return x.host_type="IPv6",i.substring(t,Vl)})($t)),e===null&&(t=$t),e}function G(){var e,s,r,n,a;return a=t,e=U(),e!==null?(s=U(),s=s!==null?s:"",s!==null?(r=U(),r=r!==null?r:"",r!==null?(n=U(),n=n!==null?n:"",n!==null?e=[e,s,r,n]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function me(){var e,s,r,n;return n=t,e=G(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=G(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e===null&&(e=Le()),e}function Le(){var e,s,r,n,a,u,m,P,k;return P=t,k=t,e=Fe(),e!==null?(i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null?(r=Fe(),r!==null?(i.charCodeAt(t)===46?(n=".",t++):(n=null,l('"."')),n!==null?(a=Fe(),a!==null?(i.charCodeAt(t)===46?(u=".",t++):(u=null,l('"."')),u!==null?(m=Fe(),m!==null?e=[e,s,r,n,a,u,m]:(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k),e!==null&&(e=(function(W){return x.host_type="IPv4",i.substring(t,W)})(P)),e===null&&(t=P),e}function Fe(){var e,s,r,n;return n=t,i.substr(t,2)==="25"?(e="25",t+=2):(e=null,l('"25"')),e!==null?(/^[0-5]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[0-5]")),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e===null&&(n=t,i.charCodeAt(t)===50?(e="2",t++):(e=null,l('"2"')),e!==null?(/^[0-4]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,l("[0-4]")),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e===null&&(n=t,i.charCodeAt(t)===49?(e="1",t++):(e=null,l('"1"')),e!==null?(s=c(),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e===null&&(n=t,/^[1-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,l("[1-9]")),e!==null?(s=c(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e===null&&(e=c())))),e}function xs(){var e,s,r,n,a,u,m;return u=t,m=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,n,a]:(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function(P,k){return k=parseInt(k.join("")),x.port=k,k})(u,e)),e===null&&(t=u),e}function Ns(){var e,s,r,n;for(e=[],n=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s!==null?(r=Et(),r!==null?s=[s,r]:(s=null,t=n)):(s=null,t=n);s!==null;)e.push(s),n=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s!==null?(r=Et(),r!==null?s=[s,r]:(s=null,t=n)):(s=null,t=n);return e}function Et(){var e;return e=Os(),e===null&&(e=Ds(),e===null&&(e=Us(),e===null&&(e=Ps(),e===null&&(e=Ms(),e===null&&(e=Ls(),e===null&&(e=Fs())))))),e}function Os(){var e,s,r,n;return r=t,n=t,i.substr(t,10).toLowerCase()==="transport="?(e=i.substr(t,10),t+=10):(e=null,l('"transport="')),e!==null?(i.substr(t,3).toLowerCase()==="udp"?(s=i.substr(t,3),t+=3):(s=null,l('"udp"')),s===null&&(i.substr(t,3).toLowerCase()==="tcp"?(s=i.substr(t,3),t+=3):(s=null,l('"tcp"')),s===null&&(i.substr(t,4).toLowerCase()==="sctp"?(s=i.substr(t,4),t+=4):(s=null,l('"sctp"')),s===null&&(i.substr(t,3).toLowerCase()==="tls"?(s=i.substr(t,3),t+=3):(s=null,l('"tls"')),s===null&&(s=j())))),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.transport=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function Ds(){var e,s,r,n;return r=t,n=t,i.substr(t,5).toLowerCase()==="user="?(e=i.substr(t,5),t+=5):(e=null,l('"user="')),e!==null?(i.substr(t,5).toLowerCase()==="phone"?(s=i.substr(t,5),t+=5):(s=null,l('"phone"')),s===null&&(i.substr(t,2).toLowerCase()==="ip"?(s=i.substr(t,2),t+=2):(s=null,l('"ip"')),s===null&&(s=j())),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.user=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function Us(){var e,s,r,n;return r=t,n=t,i.substr(t,7).toLowerCase()==="method="?(e=i.substr(t,7),t+=7):(e=null,l('"method="')),e!==null?(s=Ze(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.method=u})(r,e[1])),e===null&&(t=r),e}function Ps(){var e,s,r,n;return r=t,n=t,i.substr(t,4).toLowerCase()==="ttl="?(e=i.substr(t,4),t+=4):(e=null,l('"ttl="')),e!==null?(s=Mt(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.params||(x.params={}),x.params.ttl=u})(r,e[1])),e===null&&(t=r),e}function Ms(){var e,s,r,n;return r=t,n=t,i.substr(t,6).toLowerCase()==="maddr="?(e=i.substr(t,6),t+=6):(e=null,l('"maddr="')),e!==null?(s=Me(),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.maddr=u})(r,e[1])),e===null&&(t=r),e}function Ls(){var e,s,r,n,a,u;return n=t,a=t,i.substr(t,2).toLowerCase()==="lr"?(e=i.substr(t,2),t+=2):(e=null,l('"lr"')),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=j(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){x.uri_params||(x.uri_params={}),x.uri_params.lr=void 0})()),e===null&&(t=n),e}function Fs(){var e,s,r,n,a,u;return n=t,a=t,e=Hs(),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=$s(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m,P,k){x.uri_params||(x.uri_params={}),typeof k>"u"?k=void 0:k=k[1],x.uri_params[P.toLowerCase()]=k})(n,e[0],e[1])),e===null&&(t=n),e}function Hs(){var e,s,r;if(r=t,s=He(),s!==null)for(e=[];s!==null;)e.push(s),s=He();else e=null;return e!==null&&(e=(function(n,a){return a.join("")})(r,e)),e===null&&(t=r),e}function $s(){var e,s,r;if(r=t,s=He(),s!==null)for(e=[];s!==null;)e.push(s),s=He();else e=null;return e!==null&&(e=(function(n,a){return a.join("")})(r,e)),e===null&&(t=r),e}function He(){var e;return e=ks(),e===null&&(e=o(),e===null&&(e=T())),e}function ks(){var e;return i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,l('"]"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')))))))),e}function qs(){var e,s,r,n,a,u,m;if(u=t,i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e!==null)if(s=Je(),s!==null){for(r=[],m=t,i.charCodeAt(t)===38?(n="&",t++):(n=null,l('"&"')),n!==null?(a=Je(),a!==null?n=[n,a]:(n=null,t=m)):(n=null,t=m);n!==null;)r.push(n),m=t,i.charCodeAt(t)===38?(n="&",t++):(n=null,l('"&"')),n!==null?(a=Je(),a!==null?n=[n,a]:(n=null,t=m)):(n=null,t=m);r!==null?e=[e,s,r]:(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e}function Je(){var e,s,r,n,a;return n=t,a=t,e=js(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s!==null?(r=Gs(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m,P){m=m.join("").toLowerCase(),P=P.join(""),x.uri_headers||(x.uri_headers={}),x.uri_headers[m]?x.uri_headers[m].push(P):x.uri_headers[m]=[P]})(n,e[0],e[2])),e===null&&(t=n),e}function js(){var e,s;if(s=$e(),s===null&&(s=o(),s===null&&(s=T())),s!==null)for(e=[];s!==null;)e.push(s),s=$e(),s===null&&(s=o(),s===null&&(s=T()));else e=null;return e}function Gs(){var e,s;for(e=[],s=$e(),s===null&&(s=o(),s===null&&(s=T()));s!==null;)e.push(s),s=$e(),s===null&&(s=o(),s===null&&(s=T()));return e}function $e(){var e;return i.charCodeAt(t)===91?(e="[",t++):(e=null,l('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,l('"]"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')))))))),e}function ul(){var e;return e=fr(),e===null&&(e=Bs()),e}function Bs(){var e,s,r,n,a,u;return u=t,e=Ze(),e!==null?(s=C(),s!==null?(r=Ws(),r!==null?(n=C(),n!==null?(a=Rt(),a!==null?e=[e,s,r,n,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Ws(){var e;return e=ve(),e===null&&(e=St()),e}function St(){var e,s,r,n;return n=t,e=Xs(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(r=Vs(),r===null&&(r=Ks()),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Vs(){var e,s,r,n,a;return n=t,e=zs(),e===null&&(e=Xe()),e!==null?(a=t,i.charCodeAt(t)===63?(s="?",t++):(s=null,l('"?"')),s!==null?(r=tr(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function zs(){var e,s,r,n;return n=t,i.substr(t,2)==="//"?(e="//",t+=2):(e=null,l('"//"')),e!==null?(s=Qs(),s!==null?(r=Xe(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Xe(){var e,s,r;return r=t,i.charCodeAt(t)===47?(e="/",t++):(e=null,l('"/"')),e!==null?(s=Js(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Ks(){var e,s,r,n;if(n=t,e=Ys(),e!==null){for(s=[],r=ke();r!==null;)s.push(r),r=ke();s!==null?e=[e,s]:(e=null,t=n)}else e=null,t=n;return e}function ke(){var e;return e=H(),e===null&&(e=o(),e===null&&(e=T())),e}function Ys(){var e;return e=o(),e===null&&(e=T(),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,l('";"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,l('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')))))))))))),e}function Js(){var e,s,r,n,a,u;if(a=t,e=Qe(),e!==null){for(s=[],u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r!==null?(n=Qe(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r!==null?(n=Qe(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Qe(){var e,s,r,n,a,u;for(a=t,e=[],s=qe();s!==null;)e.push(s),s=qe();if(e!==null){for(s=[],u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r!==null?(n=At(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r!==null?(n=At(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function At(){var e,s;for(e=[],s=qe();s!==null;)e.push(s),s=qe();return e}function qe(){var e;return e=o(),e===null&&(e=T(),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,l('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,l('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,l('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,l('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,l('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,l('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,l('","')))))))))),e}function Xs(){var e,s,r,n,a;if(n=t,a=t,e=A(),e!==null){for(s=[],r=A(),r===null&&(r=c(),r===null&&(i.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."'))))));r!==null;)s.push(r),r=A(),r===null&&(r=c(),r===null&&(i.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."'))))));s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e!==null&&(e=(function(u){x.scheme=i.substring(t,u)})(n)),e===null&&(t=n),e}function Qs(){var e;return e=Zs(),e===null&&(e=er()),e}function Zs(){var e,s,r,n;return r=t,n=t,e=Ke(),e!==null?(i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e=e!==null?e:"",e!==null?(s=Ye(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e=e!==null?e:"",e}function er(){var e,s;if(s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","')),s===null&&(i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"'))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,l('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,l('","')),s===null&&(i.charCodeAt(t)===59?(s=";",t++):(s=null,l('";"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s===null&&(i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,l('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,l('"+"')))))))))));else e=null;return e}function tr(){var e,s;for(e=[],s=ke();s!==null;)e.push(s),s=ke();return e}function Rt(){var e,s,r,n,a,u,m,P;if(m=t,P=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"SIP"')),e!==null)if(i.charCodeAt(t)===47?(s="/",t++):(s=null,l('"/"')),s!==null){if(n=c(),n!==null)for(r=[];n!==null;)r.push(n),n=c();else r=null;if(r!==null)if(i.charCodeAt(t)===46?(n=".",t++):(n=null,l('"."')),n!==null){if(u=c(),u!==null)for(a=[];u!==null;)a.push(u),u=c();else a=null;a!==null?e=[e,s,r,n,a]:(e=null,t=P)}else e=null,t=P;else e=null,t=P}else e=null,t=P;else e=null,t=P;return e!==null&&(e=(function(k){x.sip_version=i.substring(t,k)})(m)),e===null&&(t=m),e}function sr(){var e;return i.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,l('"INVITE"')),e}function rr(){var e;return i.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,l('"ACK"')),e}function nr(){var e;return i.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,l('"OPTIONS"')),e}function lr(){var e;return i.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,l('"BYE"')),e}function ir(){var e;return i.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,l('"CANCEL"')),e}function ar(){var e;return i.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,l('"REGISTER"')),e}function or(){var e;return i.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,l('"SUBSCRIBE"')),e}function ur(){var e;return i.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,l('"NOTIFY"')),e}function cr(){var e;return i.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,l('"REFER"')),e}function Ze(){var e,s;return s=t,e=sr(),e===null&&(e=rr(),e===null&&(e=nr(),e===null&&(e=lr(),e===null&&(e=ir(),e===null&&(e=ar(),e===null&&(e=or(),e===null&&(e=ur(),e===null&&(e=cr(),e===null&&(e=j()))))))))),e!==null&&(e=(function(r){return x.method=i.substring(t,r),x.method})(s)),e===null&&(t=s),e}function fr(){var e,s,r,n,a,u;return u=t,e=Rt(),e!==null?(s=C(),s!==null?(r=hr(),r!==null?(n=C(),n!==null?(a=_r(),a!==null?e=[e,s,r,n,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function hr(){var e,s;return s=t,e=dr(),e!==null&&(e=(function(r,n){x.status_code=parseInt(n.join(""))})(s,e)),e===null&&(t=s),e}function dr(){var e,s,r,n;return n=t,e=c(),e!==null?(s=c(),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function _r(){var e,s,r;for(r=t,e=[],s=H(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=O(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=y()))))));s!==null;)e.push(s),s=H(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=O(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=y()))))));return e!==null&&(e=(function(n){x.reason_phrase=i.substring(t,n)})(r)),e===null&&(t=r),e}function cl(){var e,s,r,n,a,u;if(a=t,e=je(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=je(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=je(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function fl(){var e,s,r,n,a,u;return n=t,a=t,e=oe(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?(r=oe(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){x=i.substring(t,m)})(n)),e===null&&(t=n),e}function hl(){var e,s,r,n,a,u,m;if(a=t,e=Y(),e===null)if(u=t,e=et(),e!==null){for(s=[],m=t,r=ee(),r!==null?(n=et(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=ee(),r!==null?(n=et(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k,W;for(W=x.multi_header.length,k=0;k<W;k++)if(x.multi_header[k].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function et(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=X(),r!==null?(n=bt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=X(),r!==null?(n=bt(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k;x.multi_header||(x.multi_header=[]);try{k=new Pe(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{k=null}x.multi_header.push({possition:t,offset:P,parsed:k})})(a)),e===null&&(t=a),e}function De(){var e,s,r,n,a;return a=t,e=tt(),e=e!==null?e:"",e!==null?(s=Re(),s!==null?(r=ve(),r!==null?(n=Ae(),n!==null?e=[e,s,r,n]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function tt(){var e,s,r,n,a,u,m;if(a=t,u=t,e=j(),e!==null){for(s=[],m=t,r=p(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=p(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e===null&&(e=Z()),e!==null&&(e=(function(P,k){typeof k=="string"?x.display_name=k:x.display_name=k[1].reduce(function(W,se){return W+se[0]+se[1]},k[0])})(a,e)),e===null&&(t=a),e}function bt(){var e;return e=pr(),e===null&&(e=mr(),e===null&&(e=ue())),e}function pr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,1).toLowerCase()==="q"?(e=i.substr(t,1),t++):(e=null,l('"q"')),e!==null?(s=Q(),s!==null?(r=gr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.params||(x.params={}),x.params.q=m})(n,e[2])),e===null&&(t=n),e}function mr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,7).toLowerCase()==="expires"?(e=i.substr(t,7),t+=7):(e=null,l('"expires"')),e!==null?(s=Q(),s!==null?(r=Ue(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.params||(x.params={}),x.params.expires=m})(n,e[2])),e===null&&(t=n),e}function Ue(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){return parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function gr(){var e,s,r,n,a,u,m,P;return u=t,m=t,i.charCodeAt(t)===48?(e="0",t++):(e=null,l('"0"')),e!==null?(P=t,i.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?s=[s,r,n,a]:(s=null,t=P)):(s=null,t=P)):(s=null,t=P)):(s=null,t=P),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function(k){return parseFloat(i.substring(t,k))})(u)),e===null&&(t=u),e}function ue(){var e,s,r,n,a,u;return n=t,a=t,e=j(),e!==null?(u=t,s=Q(),s!==null?(r=Tr(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m,P,k){x.params||(x.params={}),typeof k>"u"?k=void 0:k=k[1],x.params[P.toLowerCase()]=k})(n,e[0],e[1])),e===null&&(t=n),e}function Tr(){var e;return e=j(),e===null&&(e=Me(),e===null&&(e=J())),e}function dl(){var e,s,r,n,a,u;if(a=t,e=Cr(),e!==null){for(s=[],u=t,r=X(),r!==null?(n=wt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(n=wt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Cr(){var e;return i.substr(t,6).toLowerCase()==="render"?(e=i.substr(t,6),t+=6):(e=null,l('"render"')),e===null&&(i.substr(t,7).toLowerCase()==="session"?(e=i.substr(t,7),t+=7):(e=null,l('"session"')),e===null&&(i.substr(t,4).toLowerCase()==="icon"?(e=i.substr(t,4),t+=4):(e=null,l('"icon"')),e===null&&(i.substr(t,5).toLowerCase()==="alert"?(e=i.substr(t,5),t+=5):(e=null,l('"alert"')),e===null&&(e=j())))),e}function wt(){var e;return e=vr(),e===null&&(e=ue()),e}function vr(){var e,s,r,n;return n=t,i.substr(t,8).toLowerCase()==="handling"?(e=i.substr(t,8),t+=8):(e=null,l('"handling"')),e!==null?(s=Q(),s!==null?(i.substr(t,8).toLowerCase()==="optional"?(r=i.substr(t,8),t+=8):(r=null,l('"optional"')),r===null&&(i.substr(t,8).toLowerCase()==="required"?(r=i.substr(t,8),t+=8):(r=null,l('"required"')),r===null&&(r=j())),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function _l(){var e,s,r,n,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function pl(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){x=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function ml(){var e,s;return s=t,e=Er(),e!==null&&(e=(function(r){x=i.substring(t,r)})(s)),e===null&&(t=s),e}function Er(){var e,s,r,n,a,u,m,P;if(m=t,e=Sr(),e!==null)if(s=de(),s!==null)if(r=wr(),r!==null){for(n=[],P=t,a=X(),a!==null?(u=yt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=X(),a!==null?(u=yt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e}function Sr(){var e;return e=Ar(),e===null&&(e=Rr()),e}function Ar(){var e;return i.substr(t,4).toLowerCase()==="text"?(e=i.substr(t,4),t+=4):(e=null,l('"text"')),e===null&&(i.substr(t,5).toLowerCase()==="image"?(e=i.substr(t,5),t+=5):(e=null,l('"image"')),e===null&&(i.substr(t,5).toLowerCase()==="audio"?(e=i.substr(t,5),t+=5):(e=null,l('"audio"')),e===null&&(i.substr(t,5).toLowerCase()==="video"?(e=i.substr(t,5),t+=5):(e=null,l('"video"')),e===null&&(i.substr(t,11).toLowerCase()==="application"?(e=i.substr(t,11),t+=11):(e=null,l('"application"')),e===null&&(e=st()))))),e}function Rr(){var e;return i.substr(t,7).toLowerCase()==="message"?(e=i.substr(t,7),t+=7):(e=null,l('"message"')),e===null&&(i.substr(t,9).toLowerCase()==="multipart"?(e=i.substr(t,9),t+=9):(e=null,l('"multipart"')),e===null&&(e=st())),e}function st(){var e;return e=j(),e===null&&(e=br()),e}function br(){var e,s,r;return r=t,i.substr(t,2).toLowerCase()==="x-"?(e=i.substr(t,2),t+=2):(e=null,l('"x-"')),e!==null?(s=j(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function wr(){var e;return e=st(),e===null&&(e=j()),e}function yt(){var e,s,r,n;return n=t,e=j(),e!==null?(s=Q(),s!==null?(r=yr(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function yr(){var e;return e=j(),e===null&&(e=J()),e}function gl(){var e,s,r,n;return n=t,e=Ir(),e!==null?(s=p(),s!==null?(r=Ze(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Ir(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){x.value=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function Tl(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,n){x=n})(s,e)),e===null&&(t=s),e}function Cl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=je(),e!==null){for(s=[],m=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P,k){x.event=k.join("").toLowerCase()})(a,e[0])),e===null&&(t=a),e}function je(){var e,s,r,n,a,u;if(a=t,e=ie(),e!==null){for(s=[],u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?(n=ie(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r!==null?(n=ie(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function vl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=X(),r!==null?(n=It(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=X(),r!==null?(n=It(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k=x.tag;try{x=new Pe(x.uri,x.display_name,x.params),k&&x.setParam("tag",k)}catch{x=-1}})()),e===null&&(t=a),e}function It(){var e;return e=xt(),e===null&&(e=ue()),e}function xt(){var e,s,r,n,a;return n=t,a=t,i.substr(t,3).toLowerCase()==="tag"?(e=i.substr(t,3),t+=3):(e=null,l('"tag"')),e!==null?(s=Q(),s!==null?(r=j(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.tag=m})(n,e[2])),e===null&&(t=n),e}function El(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(n,a){x=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function Sl(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,n){x=n})(s,e)),e===null&&(t=s),e}function Al(){var e,s,r,n,a,u,m,P,k,W;for(P=t,k=t,e=[],s=tt();s!==null;)e.push(s),s=tt();if(e!==null)if(s=Re(),s!==null)if(r=ve(),r!==null)if(n=Ae(),n!==null){for(a=[],W=t,u=X(),u!==null?(m=ue(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,u=X(),u!==null?(m=ue(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);a!==null?e=[e,s,r,n,a]:(e=null,t=k)}else e=null,t=k;else e=null,t=k;else e=null,t=k;else e=null,t=k;return e!==null&&(e=(function(se){try{x=new Pe(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=P),e}function Rl(){var e;return e=Nt(),e}function Nt(){var e,s,r,n,a,u,m,P;if(m=t,i.substr(t,6).toLowerCase()==="digest"?(e=i.substr(t,6),t+=6):(e=null,l('"Digest"')),e!==null)if(s=p(),s!==null)if(r=rt(),r!==null){for(n=[],P=t,a=ee(),a!==null?(u=rt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=ee(),a!==null?(u=rt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e===null&&(e=xr()),e}function xr(){var e,s,r,n,a,u,m,P;if(m=t,e=j(),e!==null)if(s=p(),s!==null)if(r=Ge(),r!==null){for(n=[],P=t,a=ee(),a!==null?(u=Ge(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=ee(),a!==null?(u=Ge(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e}function Ge(){var e,s,r,n;return n=t,e=j(),e!==null?(s=Q(),s!==null?(r=j(),r===null&&(r=J()),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function rt(){var e;return e=Nr(),e===null&&(e=Dr(),e===null&&(e=Ur(),e===null&&(e=Mr(),e===null&&(e=Lr(),e===null&&(e=Fr(),e===null&&(e=Hr(),e===null&&(e=Ge()))))))),e}function Nr(){var e,s,r,n;return n=t,i.substr(t,5).toLowerCase()==="realm"?(e=i.substr(t,5),t+=5):(e=null,l('"realm"')),e!==null?(s=Q(),s!==null?(r=Or(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Or(){var e,s;return s=t,e=Z(),e!==null&&(e=(function(r,n){x.realm=n})(s,e)),e===null&&(t=s),e}function Dr(){var e,s,r,n,a,u,m,P,k;if(P=t,i.substr(t,6).toLowerCase()==="domain"?(e=i.substr(t,6),t+=6):(e=null,l('"domain"')),e!==null)if(s=Q(),s!==null)if(r=be(),r!==null)if(n=nt(),n!==null){if(a=[],k=t,m=C(),m!==null)for(u=[];m!==null;)u.push(m),m=C();else u=null;for(u!==null?(m=nt(),m!==null?u=[u,m]:(u=null,t=k)):(u=null,t=k);u!==null;){if(a.push(u),k=t,m=C(),m!==null)for(u=[];m!==null;)u.push(m),m=C();else u=null;u!==null?(m=nt(),m!==null?u=[u,m]:(u=null,t=k)):(u=null,t=k)}a!==null?(u=ze(),u!==null?e=[e,s,r,n,a,u]:(e=null,t=P)):(e=null,t=P)}else e=null,t=P;else e=null,t=P;else e=null,t=P;else e=null,t=P;return e}function nt(){var e;return e=St(),e===null&&(e=Xe()),e}function Ur(){var e,s,r,n;return n=t,i.substr(t,5).toLowerCase()==="nonce"?(e=i.substr(t,5),t+=5):(e=null,l('"nonce"')),e!==null?(s=Q(),s!==null?(r=Pr(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Pr(){var e,s;return s=t,e=Z(),e!==null&&(e=(function(r,n){x.nonce=n})(s,e)),e===null&&(t=s),e}function Mr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6).toLowerCase()==="opaque"?(e=i.substr(t,6),t+=6):(e=null,l('"opaque"')),e!==null?(s=Q(),s!==null?(r=Z(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.opaque=m})(n,e[2])),e===null&&(t=n),e}function Lr(){var e,s,r,n,a;return n=t,i.substr(t,5).toLowerCase()==="stale"?(e=i.substr(t,5),t+=5):(e=null,l('"stale"')),e!==null?(s=Q(),s!==null?(a=t,i.substr(t,4).toLowerCase()==="true"?(r=i.substr(t,4),t+=4):(r=null,l('"true"')),r!==null&&(r=(function(u){x.stale=!0})()),r===null&&(t=a),r===null&&(a=t,i.substr(t,5).toLowerCase()==="false"?(r=i.substr(t,5),t+=5):(r=null,l('"false"')),r!==null&&(r=(function(u){x.stale=!1})()),r===null&&(t=a)),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function Fr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,9).toLowerCase()==="algorithm"?(e=i.substr(t,9),t+=9):(e=null,l('"algorithm"')),e!==null?(s=Q(),s!==null?(i.substr(t,3).toLowerCase()==="md5"?(r=i.substr(t,3),t+=3):(r=null,l('"MD5"')),r===null&&(i.substr(t,8).toLowerCase()==="md5-sess"?(r=i.substr(t,8),t+=8):(r=null,l('"MD5-sess"')),r===null&&(r=j())),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.algorithm=m.toUpperCase()})(n,e[2])),e===null&&(t=n),e}function Hr(){var e,s,r,n,a,u,m,P,k,W;if(P=t,i.substr(t,3).toLowerCase()==="qop"?(e=i.substr(t,3),t+=3):(e=null,l('"qop"')),e!==null)if(s=Q(),s!==null)if(r=be(),r!==null){if(k=t,n=lt(),n!==null){for(a=[],W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,l('","')),u!==null?(m=lt(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,l('","')),u!==null?(m=lt(),m!==null?u=[u,m]:(u=null,t=W)):(u=null,t=W);a!==null?n=[n,a]:(n=null,t=k)}else n=null,t=k;n!==null?(a=ze(),a!==null?e=[e,s,r,n,a]:(e=null,t=P)):(e=null,t=P)}else e=null,t=P;else e=null,t=P;else e=null,t=P;return e}function lt(){var e,s;return s=t,i.substr(t,8).toLowerCase()==="auth-int"?(e=i.substr(t,8),t+=8):(e=null,l('"auth-int"')),e===null&&(i.substr(t,4).toLowerCase()==="auth"?(e=i.substr(t,4),t+=4):(e=null,l('"auth"')),e===null&&(e=j())),e!==null&&(e=(function(r,n){x.qop||(x.qop=[]),x.qop.push(n.toLowerCase())})(s,e)),e===null&&(t=s),e}function bl(){var e,s,r,n,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function wl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=it(),e!==null){for(s=[],m=t,r=ee(),r!==null?(n=it(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=ee(),r!==null?(n=it(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k,W;for(W=x.multi_header.length,k=0;k<W;k++)if(x.multi_header[k].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function it(){var e,s,r,n,a,u,m;if(a=t,u=t,e=De(),e!==null){for(s=[],m=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k;x.multi_header||(x.multi_header=[]);try{k=new Pe(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{k=null}x.multi_header.push({possition:t,offset:P,parsed:k})})(a)),e===null&&(t=a),e}function yl(){var e,s,r,n,a,u,m;if(a=t,u=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"SIP"')),e===null&&(e=j()),e!==null){for(s=[],m=t,r=X(),r!==null?(n=Ot(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=X(),r!==null?(n=Ot(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P,k){if(x.protocol=k.toLowerCase(),x.params||(x.params={}),x.params.text&&x.params.text[0]==='"'){var W=x.params.text;x.text=W.substring(1,W.length-1),delete x.params.text}})(a,e[0])),e===null&&(t=a),e}function Ot(){var e;return e=$r(),e===null&&(e=ue()),e}function $r(){var e,s,r,n,a,u;if(a=t,u=t,i.substr(t,5).toLowerCase()==="cause"?(e=i.substr(t,5),t+=5):(e=null,l('"cause"')),e!==null)if(s=Q(),s!==null){if(n=c(),n!==null)for(r=[];n!==null;)r.push(n),n=c();else r=null;r!==null?e=[e,s,r]:(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(m,P){x.cause=parseInt(P.join(""))})(a,e[2])),e===null&&(t=a),e}function Il(){var e,s,r,n,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function xl(){var e,s,r,n,a,u;if(a=t,e=at(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=at(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=at(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function at(){var e,s,r,n,a,u;if(a=t,e=De(),e!==null){for(s=[],u=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Nl(){var e,s,r,n,a,u;if(a=t,e=kr(),e!==null){for(s=[],u=t,r=X(),r!==null?(n=Dt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(n=Dt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function kr(){var e,s;return s=t,i.substr(t,6).toLowerCase()==="active"?(e=i.substr(t,6),t+=6):(e=null,l('"active"')),e===null&&(i.substr(t,7).toLowerCase()==="pending"?(e=i.substr(t,7),t+=7):(e=null,l('"pending"')),e===null&&(i.substr(t,10).toLowerCase()==="terminated"?(e=i.substr(t,10),t+=10):(e=null,l('"terminated"')),e===null&&(e=j()))),e!==null&&(e=(function(r){x.state=i.substring(t,r)})(s)),e===null&&(t=s),e}function Dt(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6).toLowerCase()==="reason"?(e=i.substr(t,6),t+=6):(e=null,l('"reason"')),e!==null?(s=Q(),s!==null?(r=qr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){typeof m<"u"&&(x.reason=m)})(n,e[2])),e===null&&(t=n),e===null&&(n=t,a=t,i.substr(t,7).toLowerCase()==="expires"?(e=i.substr(t,7),t+=7):(e=null,l('"expires"')),e!==null?(s=Q(),s!==null?(r=Ue(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){typeof m<"u"&&(x.expires=m)})(n,e[2])),e===null&&(t=n),e===null&&(n=t,a=t,i.substr(t,11).toLowerCase()==="retry_after"?(e=i.substr(t,11),t+=11):(e=null,l('"retry_after"')),e!==null?(s=Q(),s!==null?(r=Ue(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){typeof m<"u"&&(x.retry_after=m)})(n,e[2])),e===null&&(t=n),e===null&&(e=ue()))),e}function qr(){var e;return i.substr(t,11).toLowerCase()==="deactivated"?(e=i.substr(t,11),t+=11):(e=null,l('"deactivated"')),e===null&&(i.substr(t,9).toLowerCase()==="probation"?(e=i.substr(t,9),t+=9):(e=null,l('"probation"')),e===null&&(i.substr(t,8).toLowerCase()==="rejected"?(e=i.substr(t,8),t+=8):(e=null,l('"rejected"')),e===null&&(i.substr(t,7).toLowerCase()==="timeout"?(e=i.substr(t,7),t+=7):(e=null,l('"timeout"')),e===null&&(i.substr(t,6).toLowerCase()==="giveup"?(e=i.substr(t,6),t+=6):(e=null,l('"giveup"')),e===null&&(i.substr(t,10).toLowerCase()==="noresource"?(e=i.substr(t,10),t+=10):(e=null,l('"noresource"')),e===null&&(i.substr(t,9).toLowerCase()==="invariant"?(e=i.substr(t,9),t+=9):(e=null,l('"invariant"')),e===null&&(e=j()))))))),e}function Ol(){var e;return e=E(),e=e!==null?e:"",e}function Dl(){var e,s,r,n,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=j(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e=e!==null?e:"",e}function Ul(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=X(),r!==null?(n=Ut(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=X(),r!==null?(n=Ut(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k=x.tag;try{x=new Pe(x.uri,x.display_name,x.params),k&&x.setParam("tag",k)}catch{x=-1}})()),e===null&&(t=a),e}function Ut(){var e;return e=xt(),e===null&&(e=ue()),e}function Pl(){var e,s,r,n,a,u;if(a=t,e=ot(),e!==null){for(s=[],u=t,r=ee(),r!==null?(n=ot(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(n=ot(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function ot(){var e,s,r,n,a,u,m,P;if(m=t,e=Kr(),e!==null)if(s=p(),s!==null)if(r=Xr(),r!==null){for(n=[],P=t,a=X(),a!==null?(u=Pt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)n.push(a),P=t,a=X(),a!==null?(u=Pt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);n!==null?e=[e,s,r,n]:(e=null,t=m)}else e=null,t=m;else e=null,t=m;else e=null,t=m;return e}function Pt(){var e;return e=jr(),e===null&&(e=Gr(),e===null&&(e=Br(),e===null&&(e=Wr(),e===null&&(e=Vr(),e===null&&(e=ue()))))),e}function jr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,3).toLowerCase()==="ttl"?(e=i.substr(t,3),t+=3):(e=null,l('"ttl"')),e!==null?(s=Q(),s!==null?(r=Mt(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.ttl=m})(n,e[2])),e===null&&(t=n),e}function Gr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,5).toLowerCase()==="maddr"?(e=i.substr(t,5),t+=5):(e=null,l('"maddr"')),e!==null?(s=Q(),s!==null?(r=Me(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.maddr=m})(n,e[2])),e===null&&(t=n),e}function Br(){var e,s,r,n,a;return n=t,a=t,i.substr(t,8).toLowerCase()==="received"?(e=i.substr(t,8),t+=8):(e=null,l('"received"')),e!==null?(s=Q(),s!==null?(r=Le(),r===null&&(r=vt()),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.received=m})(n,e[2])),e===null&&(t=n),e}function Wr(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6).toLowerCase()==="branch"?(e=i.substr(t,6),t+=6):(e=null,l('"branch"')),e!==null?(s=Q(),s!==null?(r=j(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.branch=m})(n,e[2])),e===null&&(t=n),e}function Vr(){var e,s,r,n,a;return n=t,i.substr(t,5).toLowerCase()==="rport"?(e=i.substr(t,5),t+=5):(e=null,l('"rport"')),e!==null?(a=t,s=Q(),s!==null?(r=zr(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function zr(){var e,s,r,n,a,u,m;return u=t,m=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,n,a]:(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function(P,k){x.rport=parseInt(k.join(""))})(u,e)),e===null&&(t=u),e}function Kr(){var e,s,r,n,a,u;return u=t,e=Yr(),e!==null?(s=de(),s!==null?(r=j(),r!==null?(n=de(),n!==null?(a=Jr(),a!==null?e=[e,s,r,n,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Yr(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,l('"SIP"')),e===null&&(e=j()),e!==null&&(e=(function(r,n){x.protocol=n})(s,e)),e===null&&(t=s),e}function Jr(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="udp"?(e=i.substr(t,3),t+=3):(e=null,l('"UDP"')),e===null&&(i.substr(t,3).toLowerCase()==="tcp"?(e=i.substr(t,3),t+=3):(e=null,l('"TCP"')),e===null&&(i.substr(t,3).toLowerCase()==="tls"?(e=i.substr(t,3),t+=3):(e=null,l('"TLS"')),e===null&&(i.substr(t,4).toLowerCase()==="sctp"?(e=i.substr(t,4),t+=4):(e=null,l('"SCTP"')),e===null&&(e=j())))),e!==null&&(e=(function(r,n){x.transport=n})(s,e)),e===null&&(t=s),e}function Xr(){var e,s,r,n,a;return n=t,e=Qr(),e!==null?(a=t,s=Oe(),s!==null?(r=Zr(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=n)):(e=null,t=n),e}function Qr(){var e,s;return s=t,e=Le(),e===null&&(e=Ct(),e===null&&(e=gt())),e!==null&&(e=(function(r){x.host=i.substring(t,r)})(s)),e===null&&(t=s),e}function Zr(){var e,s,r,n,a,u,m;return u=t,m=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(n=c(),n=n!==null?n:"",n!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,n,a]:(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m)):(e=null,t=m),e!==null&&(e=(function(P,k){x.port=parseInt(k.join(""))})(u,e)),e===null&&(t=u),e}function Mt(){var e,s,r,n,a;return n=t,a=t,e=c(),e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){return parseInt(m.join(""))})(n,e)),e===null&&(t=n),e}function Ml(){var e;return e=Nt(),e}function Ll(){var e,s,r,n,a,u;if(a=t,e=en(),e!==null){for(s=[],u=t,r=X(),r!==null?(n=Lt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(n=Lt(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function en(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,n){x.expires=n})(s,e)),e===null&&(t=s),e}function Lt(){var e;return e=tn(),e===null&&(e=ue()),e}function tn(){var e,s,r,n,a;return n=t,a=t,i.substr(t,9).toLowerCase()==="refresher"?(e=i.substr(t,9),t+=9):(e=null,l('"refresher"')),e!==null?(s=Q(),s!==null?(i.substr(t,3).toLowerCase()==="uac"?(r=i.substr(t,3),t+=3):(r=null,l('"uac"')),r===null&&(i.substr(t,3).toLowerCase()==="uas"?(r=i.substr(t,3),t+=3):(r=null,l('"uas"'))),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.refresher=m.toLowerCase()})(n,e[2])),e===null&&(t=n),e}function Fl(){var e,s,r,n;return n=t,e=j(),e!==null?(s=D(),s!==null?(r=sn(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function sn(){var e,s;for(e=[],s=b(),s===null&&(s=M(),s===null&&(s=p()));s!==null;)e.push(s),s=b(),s===null&&(s=M(),s===null&&(s=p()));return e}function Hl(){var e,s;for(e=[],s=N();s!==null;)e.push(s),s=N();return e}function $l(){var e,s,r;return r=t,i.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,l('"uuid:"')),e!==null?(s=rn(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function rn(){var e,s,r,n,a,u,m,P,k,W,se;return W=t,se=t,e=nn(),e!==null?(i.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s!==null?(r=Ee(),r!==null?(i.charCodeAt(t)===45?(n="-",t++):(n=null,l('"-"')),n!==null?(a=Ee(),a!==null?(i.charCodeAt(t)===45?(u="-",t++):(u=null,l('"-"')),u!==null?(m=Ee(),m!==null?(i.charCodeAt(t)===45?(P="-",t++):(P=null,l('"-"')),P!==null?(k=ln(),k!==null?e=[e,s,r,n,a,u,m,P,k]:(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se),e!==null&&(e=(function(Te,ut){x=i.substring(t+5,Te)})(W,e[0])),e===null&&(t=W),e}function Ee(){var e,s,r,n,a;return a=t,e=U(),e!==null?(s=U(),s!==null?(r=U(),r!==null?(n=U(),n!==null?e=[e,s,r,n]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function nn(){var e,s,r;return r=t,e=Ee(),e!==null?(s=Ee(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function ln(){var e,s,r,n;return n=t,e=Ee(),e!==null?(s=Ee(),s!==null?(r=Ee(),r!==null?e=[e,s,r]:(e=null,t=n)):(e=null,t=n)):(e=null,t=n),e}function kl(){var e,s,r,n,a,u,m;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],m=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);r!==null;)s.push(r),m=t,r=X(),r!==null?(n=ue(),n!==null?r=[r,n]:(r=null,t=m)):(r=null,t=m);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){try{x=new Pe(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=a),e}function ql(){var e,s,r,n,a,u;if(a=t,e=an(),e!==null){for(s=[],u=t,r=X(),r!==null?(n=Ft(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(n=Ft(),n!==null?r=[r,n]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function an(){var e,s,r,n,a,u;return n=t,a=t,e=oe(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,l('"@"')),s!==null?(r=oe(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(m){x.call_id=i.substring(t,m)})(n)),e===null&&(t=n),e}function Ft(){var e;return e=on(),e===null&&(e=un(),e===null&&(e=cn(),e===null&&(e=ue()))),e}function on(){var e,s,r,n,a;return n=t,a=t,i.substr(t,6)==="to-tag"?(e="to-tag",t+=6):(e=null,l('"to-tag"')),e!==null?(s=Q(),s!==null?(r=j(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.to_tag=m})(n,e[2])),e===null&&(t=n),e}function un(){var e,s,r,n,a;return n=t,a=t,i.substr(t,8)==="from-tag"?(e="from-tag",t+=8):(e=null,l('"from-tag"')),e!==null?(s=Q(),s!==null?(r=j(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,m){x.from_tag=m})(n,e[2])),e===null&&(t=n),e}function cn(){var e,s;return s=t,i.substr(t,10)==="early-only"?(e="early-only",t+=10):(e=null,l('"early-only"')),e!==null&&(e=(function(r){x.early_only=!0})()),e===null&&(t=s),e}function jl(e){e.sort();for(var s=null,r=[],n=0;n<e.length;n++)e[n]!==s&&(r.push(e[n]),s=e[n]);return r}function Gl(){for(var e=1,s=1,r=!1,n=0;n<Math.max(t,d);n++){var a=i.charAt(n);a===`
4
- `?(r||e++,s=1,r=!1):a==="\r"||a==="\u2028"||a==="\u2029"?(e++,s=1,r=!0):(s++,r=!1)}return{line:e,column:s}}var fn=ye(),Pe=Ss(),x={},Bl=R[_]();if(Bl===null||t!==i.length){var Ht=Math.max(t,d),Wl=Ht<i.length?i.charAt(Ht):null,hn=Gl();return new this.SyntaxError(jl(h),Wl,Ht,hn.line,hn.column),-1}return x},toSource:function(){return this._source}};return I.SyntaxError=function(i,_,R,t,d){function h(l,g){var c,A;switch(l.length){case 0:c="end of input";break;case 1:c=l[0];break;default:c=l.slice(0,l.length-1).join(", ")+" or "+l[l.length-1]}return A=g?w(g):"end of input","Expected "+c+" but "+A+" found."}this.name="SyntaxError",this.expected=i,this.found=_,this.message=h(i,_),this.offset=R,this.line=t,this.column=d},I.SyntaxError.prototype=Error.prototype,I})()),Gt}var Bt,gn;function ye(){if(gn)return Bt;gn=1;const w=ce(),I=_e(),i=Ce();return Bt=class el{static parse(R){if(R=i.parse(R,"SIP_URI"),R!==-1)return R}constructor(R,t,d,h,l={},g={}){if(!d)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=R||w.SIP,this._user=t,this._host=d,this._port=h;for(const c in l)Object.prototype.hasOwnProperty.call(l,c)&&this.setParam(c,l[c]);for(const c in g)Object.prototype.hasOwnProperty.call(g,c)&&this.setHeader(c,g[c])}get scheme(){return this._scheme}set scheme(R){this._scheme=R.toLowerCase()}get user(){return this._user}set user(R){this._user=R}get host(){return this._host}set host(R){this._host=R.toLowerCase()}get port(){return this._port}set port(R){this._port=R===0?R:parseInt(R,10)||null}setParam(R,t){R&&(this._parameters[R.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(R){if(R)return this._parameters[R.toLowerCase()]}hasParam(R){if(R)return this._parameters.hasOwnProperty(R.toLowerCase())&&!0||!1}deleteParam(R){if(R=R.toLowerCase(),this._parameters.hasOwnProperty(R)){const t=this._parameters[R];return delete this._parameters[R],t}}clearParams(){this._parameters={}}setHeader(R,t){this._headers[I.headerize(R)]=Array.isArray(t)?t:[t]}getHeader(R){if(R)return this._headers[I.headerize(R)]}hasHeader(R){if(R)return this._headers.hasOwnProperty(I.headerize(R))&&!0||!1}deleteHeader(R){if(R=I.headerize(R),this._headers.hasOwnProperty(R)){const t=this._headers[R];return delete this._headers[R],t}}clearHeaders(){this._headers={}}clone(){return new el(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const R=[];let t=`${this._scheme}:`;this._user&&(t+=`${I.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 h of this._headers[d])R.push(`${d}=${h}`);return R.length>0&&(t+=`?${R.join("&")}`),t}toAor(R){let t=`${this._scheme}:`;return this._user&&(t+=`${I.escapeUser(this._user)}@`),t+=this._host,R&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},Bt}var Tn;function _e(){if(Tn)return ae;Tn=1;const w=ce(),I=ye(),i=Ce();ae.str_utf8_length=d=>unescape(encodeURIComponent(d)).length;const _=ae.isFunction=d=>d!==void 0?Object.prototype.toString.call(d)==="[object Function]":!1;ae.isString=d=>d!==void 0?Object.prototype.toString.call(d)==="[object String]":!1,ae.isDecimal=d=>!isNaN(d)&&parseFloat(d)===parseInt(d,10),ae.isEmpty=d=>d===null||d===""||d===void 0||Array.isArray(d)&&d.length===0||typeof d=="number"&&isNaN(d),ae.hasMethods=function(d,...h){for(const l of h)if(_(d[l]))return!1;return!0};const R=ae.createRandomToken=(d,h=32)=>{let l,g,c="";for(l=0;l<d;l++)g=Math.random()*h|0,c+=g.toString(h);return c};ae.newTag=()=>R(10),ae.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,h=>{const l=Math.random()*16|0;return(h==="x"?l:l&3|8).toString(16)}),ae.hostType=d=>{if(d){if(d=i.parse(d,"host"),d!==-1)return d.host_type}else return};const t=ae.escapeUser=d=>encodeURIComponent(decodeURIComponent(d)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return ae.normalizeTarget=(d,h)=>{if(d){if(d instanceof I)return d;if(typeof d=="string"){const l=d.split("@");let g,c;switch(l.length){case 1:if(!h)return;g=d,c=h;break;case 2:g=l[0],c=l[1];break;default:g=l.slice(0,l.length-1).join("@"),c=l[l.length-1]}g=g.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(g)&&(g=g.replace(/[-.()]/g,"")),d=`${w.SIP}:${t(g)}@${c}`;let A;return(A=I.parse(d))?A:void 0}else return}else return},ae.headerize=d=>{const h={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},l=d.toLowerCase().replace(/_/g,"-").split("-");let g="";const c=l.length;let A;for(A=0;A<c;A++)A!==0&&(g+="-"),g+=l[A].charAt(0).toUpperCase()+l[A].substring(1);return h[g]&&(g=h[g]),g},ae.sipErrorCause=d=>{for(const h in w.SIP_ERROR_CAUSES)if(w.SIP_ERROR_CAUSES[h].indexOf(d)!==-1)return w.causes[h];return w.causes.SIP_FAILURE_CODE},ae.getRandomTestNetIP=()=>{function d(h,l){return Math.floor(Math.random()*(l-h+1)+h)}return`192.0.2.${d(1,254)}`},ae.calculateMD5=d=>{function h(K,V){return K<<V|K>>>32-V}function l(K,V){const J=K&2147483648,Z=V&2147483648,ne=K&1073741824,le=V&1073741824,te=(K&1073741823)+(V&1073741823);return ne&le?te^2147483648^J^Z:ne|le?te&1073741824?te^3221225472^J^Z:te^1073741824^J^Z:te^J^Z}function g(K,V,J){return K&V|~K&J}function c(K,V,J){return K&J|V&~J}function A(K,V,J){return K^V^J}function U(K,V,J){return V^(K|~J)}function v(K,V,J,Z,ne,le,te){return K=l(K,l(l(g(V,J,Z),ne),te)),l(h(K,le),V)}function N(K,V,J,Z,ne,le,te){return K=l(K,l(l(c(V,J,Z),ne),te)),l(h(K,le),V)}function $(K,V,J,Z,ne,le,te){return K=l(K,l(l(A(V,J,Z),ne),te)),l(h(K,le),V)}function C(K,V,J,Z,ne,le,te){return K=l(K,l(l(U(V,J,Z),ne),te)),l(h(K,le),V)}function y(K){let V;const J=K.length,Z=J+8,le=((Z-Z%64)/64+1)*16,te=new Array(le-1);let ve=0,pe=0;for(;pe<J;)V=(pe-pe%4)/4,ve=pe%4*8,te[V]=te[V]|K.charCodeAt(pe)<<ve,pe++;return V=(pe-pe%4)/4,ve=pe%4*8,te[V]=te[V]|128<<ve,te[le-2]=J<<3,te[le-1]=J>>>29,te}function F(K){let V="",J="",Z,ne;for(ne=0;ne<=3;ne++)Z=K>>>ne*8&255,J=`0${Z.toString(16)}`,V=V+J.substr(J.length-2,2);return V}function H(K){let V="";for(let J=0;J<K.length;J++){const Z=K.charCodeAt(J);Z<128?V+=String.fromCharCode(Z):Z>127&&Z<2048?(V+=String.fromCharCode(Z>>6|192),V+=String.fromCharCode(Z&63|128)):(V+=String.fromCharCode(Z>>12|224),V+=String.fromCharCode(Z>>6&63|128),V+=String.fromCharCode(Z&63|128))}return V}let o=[],f,T,p,S,D,E,b,O,M;const z=7,j=12,ie=17,he=22,oe=5,Y=9,de=14,Q=20,xe=4,Ne=11,Ae=16,Re=23,ee=6,X=10,Oe=15,be=21;for(d=H(d),o=y(d),E=1732584193,b=4023233417,O=2562383102,M=271733878,f=0;f<o.length;f+=16)T=E,p=b,S=O,D=M,E=v(E,b,O,M,o[f+0],z,3614090360),M=v(M,E,b,O,o[f+1],j,3905402710),O=v(O,M,E,b,o[f+2],ie,606105819),b=v(b,O,M,E,o[f+3],he,3250441966),E=v(E,b,O,M,o[f+4],z,4118548399),M=v(M,E,b,O,o[f+5],j,1200080426),O=v(O,M,E,b,o[f+6],ie,2821735955),b=v(b,O,M,E,o[f+7],he,4249261313),E=v(E,b,O,M,o[f+8],z,1770035416),M=v(M,E,b,O,o[f+9],j,2336552879),O=v(O,M,E,b,o[f+10],ie,4294925233),b=v(b,O,M,E,o[f+11],he,2304563134),E=v(E,b,O,M,o[f+12],z,1804603682),M=v(M,E,b,O,o[f+13],j,4254626195),O=v(O,M,E,b,o[f+14],ie,2792965006),b=v(b,O,M,E,o[f+15],he,1236535329),E=N(E,b,O,M,o[f+1],oe,4129170786),M=N(M,E,b,O,o[f+6],Y,3225465664),O=N(O,M,E,b,o[f+11],de,643717713),b=N(b,O,M,E,o[f+0],Q,3921069994),E=N(E,b,O,M,o[f+5],oe,3593408605),M=N(M,E,b,O,o[f+10],Y,38016083),O=N(O,M,E,b,o[f+15],de,3634488961),b=N(b,O,M,E,o[f+4],Q,3889429448),E=N(E,b,O,M,o[f+9],oe,568446438),M=N(M,E,b,O,o[f+14],Y,3275163606),O=N(O,M,E,b,o[f+3],de,4107603335),b=N(b,O,M,E,o[f+8],Q,1163531501),E=N(E,b,O,M,o[f+13],oe,2850285829),M=N(M,E,b,O,o[f+2],Y,4243563512),O=N(O,M,E,b,o[f+7],de,1735328473),b=N(b,O,M,E,o[f+12],Q,2368359562),E=$(E,b,O,M,o[f+5],xe,4294588738),M=$(M,E,b,O,o[f+8],Ne,2272392833),O=$(O,M,E,b,o[f+11],Ae,1839030562),b=$(b,O,M,E,o[f+14],Re,4259657740),E=$(E,b,O,M,o[f+1],xe,2763975236),M=$(M,E,b,O,o[f+4],Ne,1272893353),O=$(O,M,E,b,o[f+7],Ae,4139469664),b=$(b,O,M,E,o[f+10],Re,3200236656),E=$(E,b,O,M,o[f+13],xe,681279174),M=$(M,E,b,O,o[f+0],Ne,3936430074),O=$(O,M,E,b,o[f+3],Ae,3572445317),b=$(b,O,M,E,o[f+6],Re,76029189),E=$(E,b,O,M,o[f+9],xe,3654602809),M=$(M,E,b,O,o[f+12],Ne,3873151461),O=$(O,M,E,b,o[f+15],Ae,530742520),b=$(b,O,M,E,o[f+2],Re,3299628645),E=C(E,b,O,M,o[f+0],ee,4096336452),M=C(M,E,b,O,o[f+7],X,1126891415),O=C(O,M,E,b,o[f+14],Oe,2878612391),b=C(b,O,M,E,o[f+5],be,4237533241),E=C(E,b,O,M,o[f+12],ee,1700485571),M=C(M,E,b,O,o[f+3],X,2399980690),O=C(O,M,E,b,o[f+10],Oe,4293915773),b=C(b,O,M,E,o[f+1],be,2240044497),E=C(E,b,O,M,o[f+8],ee,1873313359),M=C(M,E,b,O,o[f+15],X,4264355552),O=C(O,M,E,b,o[f+6],Oe,2734768916),b=C(b,O,M,E,o[f+13],be,1309151649),E=C(E,b,O,M,o[f+4],ee,4149444226),M=C(M,E,b,O,o[f+11],X,3174756917),O=C(O,M,E,b,o[f+2],Oe,718787259),b=C(b,O,M,E,o[f+9],be,3951481745),E=l(E,T),b=l(b,p),O=l(O,S),M=l(M,D);return(F(E)+F(b)+F(O)+F(M)).toLowerCase()},ae.closeMediaStream=d=>{if(d)try{let h;if(d.getTracks){h=d.getTracks();for(const l of h)l.stop()}else{h=d.getAudioTracks();for(const l of h)l.stop();h=d.getVideoTracks();for(const l of h)l.stop()}}catch{(typeof d.stop=="function"||typeof d.stop=="object")&&d.stop()}},ae.cloneArray=d=>d&&d.slice()||[],ae.cloneObject=(d,h={})=>d&&Object.assign({},d)||h,ae}var ct={exports:{}},Cn;function Ie(){if(Cn)return ct.exports;Cn=1;var w=typeof Reflect=="object"?Reflect:null,I=w&&typeof w.apply=="function"?w.apply:function(f,T,p){return Function.prototype.apply.call(f,T,p)},i;w&&typeof w.ownKeys=="function"?i=w.ownKeys:Object.getOwnPropertySymbols?i=function(f){return Object.getOwnPropertyNames(f).concat(Object.getOwnPropertySymbols(f))}:i=function(f){return Object.getOwnPropertyNames(f)};function _(o){console&&console.warn&&console.warn(o)}var R=Number.isNaN||function(f){return f!==f};function t(){t.init.call(this)}ct.exports=t,ct.exports.once=y,t.EventEmitter=t,t.prototype._events=void 0,t.prototype._eventsCount=0,t.prototype._maxListeners=void 0;var d=10;function h(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(t,"defaultMaxListeners",{enumerable:!0,get:function(){return d},set:function(o){if(typeof o!="number"||o<0||R(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");d=o}}),t.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},t.prototype.setMaxListeners=function(f){if(typeof f!="number"||f<0||R(f))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+f+".");return this._maxListeners=f,this};function l(o){return o._maxListeners===void 0?t.defaultMaxListeners:o._maxListeners}t.prototype.getMaxListeners=function(){return l(this)},t.prototype.emit=function(f){for(var T=[],p=1;p<arguments.length;p++)T.push(arguments[p]);var S=f==="error",D=this._events;if(D!==void 0)S=S&&D.error===void 0;else if(!S)return!1;if(S){var E;if(T.length>0&&(E=T[0]),E instanceof Error)throw E;var b=new Error("Unhandled error."+(E?" ("+E.message+")":""));throw b.context=E,b}var O=D[f];if(O===void 0)return!1;if(typeof O=="function")I(O,this,T);else for(var M=O.length,z=N(O,M),p=0;p<M;++p)I(z[p],this,T);return!0};function g(o,f,T,p){var S,D,E;if(h(T),D=o._events,D===void 0?(D=o._events=Object.create(null),o._eventsCount=0):(D.newListener!==void 0&&(o.emit("newListener",f,T.listener?T.listener:T),D=o._events),E=D[f]),E===void 0)E=D[f]=T,++o._eventsCount;else if(typeof E=="function"?E=D[f]=p?[T,E]:[E,T]:p?E.unshift(T):E.push(T),S=l(o),S>0&&E.length>S&&!E.warned){E.warned=!0;var b=new Error("Possible EventEmitter memory leak detected. "+E.length+" "+String(f)+" listeners added. Use emitter.setMaxListeners() to increase limit");b.name="MaxListenersExceededWarning",b.emitter=o,b.type=f,b.count=E.length,_(b)}return o}t.prototype.addListener=function(f,T){return g(this,f,T,!1)},t.prototype.on=t.prototype.addListener,t.prototype.prependListener=function(f,T){return g(this,f,T,!0)};function c(){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 A(o,f,T){var p={fired:!1,wrapFn:void 0,target:o,type:f,listener:T},S=c.bind(p);return S.listener=T,p.wrapFn=S,S}t.prototype.once=function(f,T){return h(T),this.on(f,A(this,f,T)),this},t.prototype.prependOnceListener=function(f,T){return h(T),this.prependListener(f,A(this,f,T)),this},t.prototype.removeListener=function(f,T){var p,S,D,E,b;if(h(T),S=this._events,S===void 0)return this;if(p=S[f],p===void 0)return this;if(p===T||p.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete S[f],S.removeListener&&this.emit("removeListener",f,p.listener||T));else if(typeof p!="function"){for(D=-1,E=p.length-1;E>=0;E--)if(p[E]===T||p[E].listener===T){b=p[E].listener,D=E;break}if(D<0)return this;D===0?p.shift():$(p,D),p.length===1&&(S[f]=p[0]),S.removeListener!==void 0&&this.emit("removeListener",f,b||T)}return this},t.prototype.off=t.prototype.removeListener,t.prototype.removeAllListeners=function(f){var T,p,S;if(p=this._events,p===void 0)return this;if(p.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):p[f]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete p[f]),this;if(arguments.length===0){var D=Object.keys(p),E;for(S=0;S<D.length;++S)E=D[S],E!=="removeListener"&&this.removeAllListeners(E);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=p[f],typeof T=="function")this.removeListener(f,T);else if(T!==void 0)for(S=T.length-1;S>=0;S--)this.removeListener(f,T[S]);return this};function U(o,f,T){var p=o._events;if(p===void 0)return[];var S=p[f];return S===void 0?[]:typeof S=="function"?T?[S.listener||S]:[S]:T?C(S):N(S,S.length)}t.prototype.listeners=function(f){return U(this,f,!0)},t.prototype.rawListeners=function(f){return U(this,f,!1)},t.listenerCount=function(o,f){return typeof o.listenerCount=="function"?o.listenerCount(f):v.call(o,f)},t.prototype.listenerCount=v;function v(o){var f=this._events;if(f!==void 0){var T=f[o];if(typeof T=="function")return 1;if(T!==void 0)return T.length}return 0}t.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function N(o,f){for(var T=new Array(f),p=0;p<f;++p)T[p]=o[p];return T}function $(o,f){for(;f+1<o.length;f++)o[f]=o[f+1];o.pop()}function C(o){for(var f=new Array(o.length),T=0;T<f.length;++T)f[T]=o[T].listener||o[T];return f}function y(o,f){return new Promise(function(T,p){function S(E){o.removeListener(f,D),p(E)}function D(){typeof o.removeListener=="function"&&o.removeListener("error",S),T([].slice.call(arguments))}H(o,f,D,{once:!0}),f!=="error"&&F(o,S,{once:!0})})}function F(o,f,T){typeof o.on=="function"&&H(o,"error",f,T)}function H(o,f,T,p){if(typeof o.on=="function")p.once?o.once(f,T):o.on(f,T);else if(typeof o.addEventListener=="function")o.addEventListener(f,function S(D){p.once&&o.removeEventListener(f,S),T(D)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}return ct.exports}var ft={exports:{}},Wt,vn;function Xl(){if(vn)return Wt;vn=1;var w=1e3,I=w*60,i=I*60,_=i*24,R=_*7,t=_*365.25;Wt=function(c,A){A=A||{};var U=typeof c;if(U==="string"&&c.length>0)return d(c);if(U==="number"&&isFinite(c))return A.long?l(c):h(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function d(c){if(c=String(c),!(c.length>100)){var A=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(A){var U=parseFloat(A[1]),v=(A[2]||"ms").toLowerCase();switch(v){case"years":case"year":case"yrs":case"yr":case"y":return U*t;case"weeks":case"week":case"w":return U*R;case"days":case"day":case"d":return U*_;case"hours":case"hour":case"hrs":case"hr":case"h":return U*i;case"minutes":case"minute":case"mins":case"min":case"m":return U*I;case"seconds":case"second":case"secs":case"sec":case"s":return U*w;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return U;default:return}}}}function h(c){var A=Math.abs(c);return A>=_?Math.round(c/_)+"d":A>=i?Math.round(c/i)+"h":A>=I?Math.round(c/I)+"m":A>=w?Math.round(c/w)+"s":c+"ms"}function l(c){var A=Math.abs(c);return A>=_?g(c,A,_,"day"):A>=i?g(c,A,i,"hour"):A>=I?g(c,A,I,"minute"):A>=w?g(c,A,w,"second"):c+" ms"}function g(c,A,U,v){var N=A>=U*1.5;return Math.round(c/U)+" "+v+(N?"s":"")}return Wt}var Vt,En;function Ql(){if(En)return Vt;En=1;function w(I){_.debug=_,_.default=_,_.coerce=g,_.disable=h,_.enable=t,_.enabled=l,_.humanize=Xl(),_.destroy=c,Object.keys(I).forEach(A=>{_[A]=I[A]}),_.names=[],_.skips=[],_.formatters={};function i(A){let U=0;for(let v=0;v<A.length;v++)U=(U<<5)-U+A.charCodeAt(v),U|=0;return _.colors[Math.abs(U)%_.colors.length]}_.selectColor=i;function _(A){let U,v=null,N,$;function C(...y){if(!C.enabled)return;const F=C,H=Number(new Date),o=H-(U||H);F.diff=o,F.prev=U,F.curr=H,U=H,y[0]=_.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let f=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(p,S)=>{if(p==="%%")return"%";f++;const D=_.formatters[S];if(typeof D=="function"){const E=y[f];p=D.call(F,E),y.splice(f,1),f--}return p}),_.formatArgs.call(F,y),(F.log||_.log).apply(F,y)}return C.namespace=A,C.useColors=_.useColors(),C.color=_.selectColor(A),C.extend=R,C.destroy=_.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(N!==_.namespaces&&(N=_.namespaces,$=_.enabled(A)),$),set:y=>{v=y}}),typeof _.init=="function"&&_.init(C),C}function R(A,U){const v=_(this.namespace+(typeof U>"u"?":":U)+A);return v.log=this.log,v}function t(A){_.save(A),_.namespaces=A,_.names=[],_.skips=[];const U=(typeof A=="string"?A:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const v of U)v[0]==="-"?_.skips.push(v.slice(1)):_.names.push(v)}function d(A,U){let v=0,N=0,$=-1,C=0;for(;v<A.length;)if(N<U.length&&(U[N]===A[v]||U[N]==="*"))U[N]==="*"?($=N,C=v,N++):(v++,N++);else if($!==-1)N=$+1,C++,v=C;else return!1;for(;N<U.length&&U[N]==="*";)N++;return N===U.length}function h(){const A=[..._.names,..._.skips.map(U=>"-"+U)].join(",");return _.enable(""),A}function l(A){for(const U of _.skips)if(d(A,U))return!1;for(const U of _.names)if(d(A,U))return!0;return!1}function g(A){return A instanceof Error?A.stack||A.message:A}function c(){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 _.enable(_.load()),_}return Vt=w,Vt}var Sn;function Cs(){return Sn||(Sn=1,(function(w,I){I.formatArgs=_,I.save=R,I.load=t,I.useColors=i,I.storage=d(),I.destroy=(()=>{let l=!1;return()=>{l||(l=!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`."))}})(),I.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 i(){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 l;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&&(l=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(l[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function _(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+w.exports.humanize(this.diff),!this.useColors)return;const g="color: "+this.color;l.splice(1,0,g,"color: inherit");let c=0,A=0;l[0].replace(/%[a-zA-Z%]/g,U=>{U!=="%%"&&(c++,U==="%c"&&(A=c))}),l.splice(A,0,g)}I.log=console.debug||console.log||(()=>{});function R(l){try{l?I.storage.setItem("debug",l):I.storage.removeItem("debug")}catch{}}function t(){let l;try{l=I.storage.getItem("debug")||I.storage.getItem("DEBUG")}catch{}return!l&&typeof process<"u"&&"env"in process&&(l=process.env.DEBUG),l}function d(){try{return localStorage}catch{}}w.exports=Ql()(I);const{formatters:h}=w.exports;h.j=function(l){try{return JSON.stringify(l)}catch(g){return"[UnexpectedJSONParseError]: "+g.message}}})(ft,ft.exports)),ft.exports}var zt,An;function fe(){if(An)return zt;An=1;const w=Cs(),I="JsSIP";return zt=class{constructor(_){_?(this._debug=w.default(`${I}:${_}`),this._warn=w.default(`${I}:WARN:${_}`),this._error=w.default(`${I}:ERROR:${_}`)):(this._debug=w.default(I),this._warn=w.default(`${I}:WARN`),this._error=w.default(`${I}: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}},zt}var ge={},Kt={},Yt={exports:{}},Rn;function As(){if(Rn)return Yt.exports;Rn=1;var w=Yt.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(I){return I.encoding?"rtpmap:%d %s/%s/%s":I.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(I){return I.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(I){return I.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(I){return"extmap:%d"+(I.direction?"/%s":"%v")+(I["encrypt-uri"]?" %s":"%v")+" %s"+(I.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(I){return I.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(I){var i="candidate:%s %d %s %d %s %d typ %s";return i+=I.raddr!=null?" raddr %s rport %d":"%v%v",i+=I.tcptype!=null?" tcptype %s":"%v",I.generation!=null&&(i+=" generation %d"),i+=I["network-id"]!=null?" network-id %d":"%v",i+=I["network-cost"]!=null?" network-cost %d":"%v",i}},{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(I){var i="ssrc:%d";return I.attribute!=null&&(i+=" %s",I.value!=null&&(i+=":%s")),i}},{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(I){return I.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(I){return I.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(I){return"imageattr:%s %s %s"+(I.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(I){return"simulcast:%s %s"+(I.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(I){return"ts-refclk:%s"+(I.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(I){var i="mediaclk:";return i+=I.id!=null?"id=%s %s":"%v%s",i+=I.mediaClockValue!=null?"=%s":"",i+=I.rateNumerator!=null?" rate=%s":"",i+=I.rateDenominator!=null?"/%s":"",i}},{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"]}]};return Object.keys(w).forEach(function(I){var i=w[I];i.forEach(function(_){_.reg||(_.reg=/(.*)/),_.format||(_.format="%s")})}),Yt.exports}var bn;function Zl(){return bn||(bn=1,(function(w){var I=function(h){return String(Number(h))===h?Number(h):h},i=function(h,l,g,c){if(c&&!g)l[c]=I(h[1]);else for(var A=0;A<g.length;A+=1)h[A+1]!=null&&(l[g[A]]=I(h[A+1]))},_=function(h,l,g){var c=h.name&&h.names;h.push&&!l[h.push]?l[h.push]=[]:c&&!l[h.name]&&(l[h.name]={});var A=h.push?{}:c?l[h.name]:l;i(g.match(h.reg),A,h.names,h.name),h.push&&l[h.push].push(A)},R=As(),t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);w.parse=function(h){var l={},g=[],c=l;return h.split(/(\r\n|\r|\n)/).filter(t).forEach(function(A){var U=A[0],v=A.slice(2);U==="m"&&(g.push({rtp:[],fmtp:[]}),c=g[g.length-1]);for(var N=0;N<(R[U]||[]).length;N+=1){var $=R[U][N];if($.reg.test(v))return _($,c,v)}}),l.media=g,l};var d=function(h,l){var g=l.split(/=(.+)/,2);return g.length===2?h[g[0]]=I(g[1]):g.length===1&&l.length>1&&(h[g[0]]=void 0),h};w.parseParams=function(h){return h.split(/;\s?/).reduce(d,{})},w.parseFmtpConfig=w.parseParams,w.parsePayloads=function(h){return h.toString().split(" ").map(Number)},w.parseRemoteCandidates=function(h){for(var l=[],g=h.split(" ").map(I),c=0;c<g.length;c+=3)l.push({component:g[c],ip:g[c+1],port:g[c+2]});return l},w.parseImageAttributes=function(h){return h.split(" ").map(function(l){return l.substring(1,l.length-1).split(",").reduce(d,{})})},w.parseSimulcastStreamList=function(h){return h.split(";").map(function(l){return l.split(",").map(function(g){var c,A=!1;return g[0]!=="~"?c=I(g):(c=I(g.substring(1,g.length)),A=!0),{scid:c,paused:A}})})}})(Kt)),Kt}var Jt,wn;function ei(){if(wn)return Jt;wn=1;var w=As(),I=/%[sdv%]/g,i=function(d){var h=1,l=arguments,g=l.length;return d.replace(I,function(c){if(h>=g)return c;var A=l[h];switch(h+=1,c){case"%%":return"%";case"%s":return String(A);case"%d":return Number(A);case"%v":return""}})},_=function(d,h,l){var g=h.format instanceof Function?h.format(h.push?l:l[h.name]):h.format,c=[d+"="+g];if(h.names)for(var A=0;A<h.names.length;A+=1){var U=h.names[A];h.name?c.push(l[h.name][U]):c.push(l[h.names[A]])}else c.push(l[h.name]);return i.apply(null,c)},R=["v","o","s","i","u","e","p","c","b","t","r","z","a"],t=["i","c","b","a"];return Jt=function(d,h){h=h||{},d.version==null&&(d.version=0),d.name==null&&(d.name=" "),d.media.forEach(function(A){A.payloads==null&&(A.payloads="")});var l=h.outerOrder||R,g=h.innerOrder||t,c=[];return l.forEach(function(A){w[A].forEach(function(U){U.name in d&&d[U.name]!=null?c.push(_(A,U,d)):U.push in d&&d[U.push]!=null&&d[U.push].forEach(function(v){c.push(_(A,U,v))})})}),d.media.forEach(function(A){c.push(_("m",w.m[0],A)),g.forEach(function(U){w[U].forEach(function(v){v.name in A&&A[v.name]!=null?c.push(_(U,v,A)):v.push in A&&A[v.push]!=null&&A[v.push].forEach(function(N){c.push(_(U,v,N))})})})}),c.join(`\r
3
+ `,t+=2):(e=null,n('"\\r\\n"')),e}function c(){var e;return/^[0-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[0-9]")),e}function R(){var e;return/^[a-zA-Z]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[a-zA-Z]")),e}function D(){var e;return/^[0-9a-fA-F]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[0-9a-fA-F]")),e}function E(){var e;return e=C(),e===null&&(e=I()),e}function N(){var e;return/^[\0-\xFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[\\0-\\xFF]")),e}function $(){var e;return/^["]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n('["]')),e}function C(){var e;return i.charCodeAt(t)===32?(e=" ",t++):(e=null,n('" "')),e}function I(){var e;return i.charCodeAt(t)===9?(e=" ",t++):(e=null,n('"\\t"')),e}function F(){var e;return/^[a-zA-Z0-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[a-zA-Z0-9]")),e}function H(){var e;return i.charCodeAt(t)===59?(e=";",t++):(e=null,n('";"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,n('"/"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,n('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,n('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,n('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,n('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,n('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,n('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,n('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,n('","'))))))))))),e}function o(){var e;return e=F(),e===null&&(e=f()),e}function f(){var e;return i.charCodeAt(t)===45?(e="-",t++):(e=null,n('"-"')),e===null&&(i.charCodeAt(t)===95?(e="_",t++):(e=null,n('"_"')),e===null&&(i.charCodeAt(t)===46?(e=".",t++):(e=null,n('"."')),e===null&&(i.charCodeAt(t)===33?(e="!",t++):(e=null,n('"!"')),e===null&&(i.charCodeAt(t)===126?(e="~",t++):(e=null,n('"~"')),e===null&&(i.charCodeAt(t)===42?(e="*",t++):(e=null,n('"*"')),e===null&&(i.charCodeAt(t)===39?(e="'",t++):(e=null,n(`"'"`)),e===null&&(i.charCodeAt(t)===40?(e="(",t++):(e=null,n('"("')),e===null&&(i.charCodeAt(t)===41?(e=")",t++):(e=null,n('")"')))))))))),e}function T(){var e,s,r,l,a;return l=t,a=t,i.charCodeAt(t)===37?(e="%",t++):(e=null,n('"%"')),e!==null?(s=D(),s!==null?(r=D(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){return g.join("")})(l,e)),e===null&&(t=l),e}function p(){var e,s,r,l,a,u;for(l=t,a=t,u=t,e=[],s=E();s!==null;)e.push(s),s=E();if(e!==null?(s=m(),s!==null?e=[e,s]:(e=null,t=u)):(e=null,t=u),e=e!==null?e:"",e!==null){if(r=E(),r!==null)for(s=[];r!==null;)s.push(r),r=E();else s=null;s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e!==null&&(e=(function(g){return" "})()),e===null&&(t=l),e}function A(){var e;return e=p(),e=e!==null?e:"",e}function O(){var e,s,r,l,a;for(l=t,a=t,e=[],s=C(),s===null&&(s=I());s!==null;)e.push(s),s=C(),s===null&&(s=I());return e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return":"})()),e===null&&(t=l),e}function v(){var e,s,r,l,a,u,g;if(a=t,u=t,s=w(),s!==null)for(e=[];s!==null;)e.push(s),s=w();else e=null;if(e!==null){for(s=[],g=t,r=[],l=p();l!==null;)r.push(l),l=p();for(r!==null?(l=w(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;){for(s.push(r),g=t,r=[],l=p();l!==null;)r.push(l),l=p();r!==null?(l=w(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g)}s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){return i.substring(t,P)})(a)),e===null&&(t=a),e}function w(){var e;return/^[!-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[!-~]")),e===null&&(e=U()),e}function U(){var e;return/^[\x80-\uFFFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[\\x80-\\uFFFF]")),e}function M(){var e;return/^[\x80-\xBF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[\\x80-\\xBF]")),e}function Y(){var e;return e=c(),e===null&&(/^[a-f]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[a-f]"))),e}function B(){var e,s,r;if(r=t,s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,n('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,n('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,n('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,n('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,n('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,n('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,n(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,n('"~"')))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,n('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,n('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,n('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,n('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,n('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,n('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,n(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,n('"~"'))))))))))));else e=null;return e!==null&&(e=(function(l){return i.substring(t,l)})(r)),e===null&&(t=r),e}function ue(){var e,s,r;if(r=t,s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,n('"-"')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,n('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,n('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,n('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,n('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,n(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,n('"~"'))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,n('"-"')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,n('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,n('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,n('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,n('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,n(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,n('"~"')))))))))));else e=null;return e!==null&&(e=(function(l){return i.substring(t,l)})(r)),e===null&&(t=r),e}function de(){var e;return i.charCodeAt(t)===40?(e="(",t++):(e=null,n('"("')),e===null&&(i.charCodeAt(t)===41?(e=")",t++):(e=null,n('")"')),e===null&&(i.charCodeAt(t)===60?(e="<",t++):(e=null,n('"<"')),e===null&&(i.charCodeAt(t)===62?(e=">",t++):(e=null,n('">"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,n('"@"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,n('","')),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,n('";"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,n('":"')),e===null&&(i.charCodeAt(t)===92?(e="\\",t++):(e=null,n('"\\\\"')),e===null&&(e=$(),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,n('"/"')),e===null&&(i.charCodeAt(t)===91?(e="[",t++):(e=null,n('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,n('"]"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,n('"?"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,n('"="')),e===null&&(i.charCodeAt(t)===123?(e="{",t++):(e=null,n('"{"')),e===null&&(i.charCodeAt(t)===125?(e="}",t++):(e=null,n('"}"')),e===null&&(e=C(),e===null&&(e=I())))))))))))))))))),e}function he(){var e,s,r;if(r=t,s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,n('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,n('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,n('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,n('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,n('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,n('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,n(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,n('"~"')),s===null&&(i.charCodeAt(t)===40?(s="(",t++):(s=null,n('"("')),s===null&&(i.charCodeAt(t)===41?(s=")",t++):(s=null,n('")"')),s===null&&(i.charCodeAt(t)===60?(s="<",t++):(s=null,n('"<"')),s===null&&(i.charCodeAt(t)===62?(s=">",t++):(s=null,n('">"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s===null&&(i.charCodeAt(t)===92?(s="\\",t++):(s=null,n('"\\\\"')),s===null&&(s=$(),s===null&&(i.charCodeAt(t)===47?(s="/",t++):(s=null,n('"/"')),s===null&&(i.charCodeAt(t)===91?(s="[",t++):(s=null,n('"["')),s===null&&(i.charCodeAt(t)===93?(s="]",t++):(s=null,n('"]"')),s===null&&(i.charCodeAt(t)===63?(s="?",t++):(s=null,n('"?"')),s===null&&(i.charCodeAt(t)===123?(s="{",t++):(s=null,n('"{"')),s===null&&(i.charCodeAt(t)===125?(s="}",t++):(s=null,n('"}"'))))))))))))))))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=F(),s===null&&(i.charCodeAt(t)===45?(s="-",t++):(s=null,n('"-"')),s===null&&(i.charCodeAt(t)===46?(s=".",t++):(s=null,n('"."')),s===null&&(i.charCodeAt(t)===33?(s="!",t++):(s=null,n('"!"')),s===null&&(i.charCodeAt(t)===37?(s="%",t++):(s=null,n('"%"')),s===null&&(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s===null&&(i.charCodeAt(t)===95?(s="_",t++):(s=null,n('"_"')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===96?(s="`",t++):(s=null,n('"`"')),s===null&&(i.charCodeAt(t)===39?(s="'",t++):(s=null,n(`"'"`)),s===null&&(i.charCodeAt(t)===126?(s="~",t++):(s=null,n('"~"')),s===null&&(i.charCodeAt(t)===40?(s="(",t++):(s=null,n('"("')),s===null&&(i.charCodeAt(t)===41?(s=")",t++):(s=null,n('")"')),s===null&&(i.charCodeAt(t)===60?(s="<",t++):(s=null,n('"<"')),s===null&&(i.charCodeAt(t)===62?(s=">",t++):(s=null,n('">"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s===null&&(i.charCodeAt(t)===92?(s="\\",t++):(s=null,n('"\\\\"')),s===null&&(s=$(),s===null&&(i.charCodeAt(t)===47?(s="/",t++):(s=null,n('"/"')),s===null&&(i.charCodeAt(t)===91?(s="[",t++):(s=null,n('"["')),s===null&&(i.charCodeAt(t)===93?(s="]",t++):(s=null,n('"]"')),s===null&&(i.charCodeAt(t)===63?(s="?",t++):(s=null,n('"?"')),s===null&&(i.charCodeAt(t)===123?(s="{",t++):(s=null,n('"{"')),s===null&&(i.charCodeAt(t)===125?(s="}",t++):(s=null,n('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=(function(l){return i.substring(t,l)})(r)),e===null&&(t=r),e}function X(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"*"})()),e===null&&(t=l),e}function _e(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===47?(s="/",t++):(s=null,n('"/"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"/"})()),e===null&&(t=l),e}function Q(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"="})()),e===null&&(t=l),e}function xe(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===40?(s="(",t++):(s=null,n('"("')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return"("})()),e===null&&(t=l),e}function Ne(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===41?(s=")",t++):(s=null,n('")"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return")"})()),e===null&&(t=l),e}function Ae(){var e,s,r,l;return r=t,l=t,i.charCodeAt(t)===62?(e=">",t++):(e=null,n('">"')),e!==null?(s=A(),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a){return">"})()),e===null&&(t=r),e}function Re(){var e,s,r,l;return r=t,l=t,e=A(),e!==null?(i.charCodeAt(t)===60?(s="<",t++):(s=null,n('"<"')),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a){return"<"})()),e===null&&(t=r),e}function ee(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===44?(s=",",t++):(s=null,n('","')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return","})()),e===null&&(t=l),e}function J(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===59?(s=";",t++):(s=null,n('";"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return";"})()),e===null&&(t=l),e}function Oe(){var e,s,r,l,a;return l=t,a=t,e=A(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=A(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return":"})()),e===null&&(t=l),e}function be(){var e,s,r,l;return r=t,l=t,e=A(),e!==null?(s=$(),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a){return'"'})()),e===null&&(t=r),e}function ze(){var e,s,r,l;return r=t,l=t,e=$(),e!==null?(s=A(),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a){return'"'})()),e===null&&(t=r),e}function z(){var e,s,r,l;if(l=t,e=xe(),e!==null){for(s=[],r=V(),r===null&&(r=le(),r===null&&(r=z()));r!==null;)s.push(r),r=V(),r===null&&(r=le(),r===null&&(r=z()));s!==null?(r=Ne(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)}else e=null,t=l;return e}function V(){var e;return/^[!-']/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[!-']")),e===null&&(/^[*-[]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[*-[]")),e===null&&(/^[\]-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[\\]-~]")),e===null&&(e=U(),e===null&&(e=p())))),e}function K(){var e,s,r,l,a,u;if(a=t,u=t,e=A(),e!==null)if(s=$(),s!==null){for(r=[],l=ne(),l===null&&(l=le());l!==null;)r.push(l),l=ne(),l===null&&(l=le());r!==null?(l=$(),l!==null?e=[e,s,r,l]:(e=null,t=u)):(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(g){return i.substring(t,g)})(a)),e===null&&(t=a),e}function Z(){var e,s,r,l,a,u;if(a=t,u=t,e=A(),e!==null)if(s=$(),s!==null){for(r=[],l=ne(),l===null&&(l=le());l!==null;)r.push(l),l=ne(),l===null&&(l=le());r!==null?(l=$(),l!==null?e=[e,s,r,l]:(e=null,t=u)):(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(g){var P=i.substring(t,g).trim();return P.substring(1,P.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")})(a)),e===null&&(t=a),e}function ne(){var e;return e=p(),e===null&&(i.charCodeAt(t)===33?(e="!",t++):(e=null,n('"!"')),e===null&&(/^[#-[]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[#-[]")),e===null&&(/^[\]-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[\\]-~]")),e===null&&(e=U())))),e}function le(){var e,s,r;return r=t,i.charCodeAt(t)===92?(e="\\",t++):(e=null,n('"\\\\"')),e!==null?(/^[\0-\t]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,n("[\\0-\\t]")),s===null&&(/^[\x0B-\f]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,n("[\\x0B-\\f]")),s===null&&(/^[\x0E-]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,n("[\\x0E-]")))),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function te(){var e,s,r,l,a,u;return a=t,u=t,e=pe(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Ke(),r=r!==null?r:"",r!==null?(l=Ye(),l!==null?e=[e,s,r,l]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e!==null&&(e=(function(g){try{x.uri=new hn(x.scheme,x.user,x.host,x.port),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port}catch{x=-1}})()),e===null&&(t=a),e}function ve(){var e,s,r,l,a,u,g,P;return g=t,P=t,e=pe(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Ke(),r=r!==null?r:"",r!==null?(l=Ye(),l!==null?(a=Os(),a!==null?(u=js(),u=u!==null?u:"",u!==null?e=[e,s,r,l,a,u]:(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P)):(e=null,t=P),e!==null&&(e=(function(k){try{x.uri=new hn(x.scheme,x.user,x.host,x.port,x.uri_params,x.uri_headers),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port,delete x.uri_params,_==="SIP_URI"&&(x=x.uri)}catch{x=-1}})()),e===null&&(t=g),e}function pe(){var e;return e=bs(),e===null&&(e=ws()),e}function bs(){var e,s;return s=t,i.substr(t,4).toLowerCase()==="sips"?(e=i.substr(t,4),t+=4):(e=null,n('"sips"')),e!==null&&(e=(function(r,l){x.scheme=l.toLowerCase()})(s,e)),e===null&&(t=s),e}function ws(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,n('"sip"')),e!==null&&(e=(function(r,l){x.scheme=l.toLowerCase()})(s,e)),e===null&&(t=s),e}function Ke(){var e,s,r,l,a,u;return l=t,a=t,e=ys(),e!==null?(u=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Is(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?(i.charCodeAt(t)===64?(r="@",t++):(r=null,n('"@"')),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(g){x.user=decodeURIComponent(i.substring(t-1,g))})(l)),e===null&&(t=l),e}function ys(){var e,s;if(s=o(),s===null&&(s=T(),s===null&&(s=mt())),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(s=mt()));else e=null;return e}function mt(){var e;return i.charCodeAt(t)===38?(e="&",t++):(e=null,n('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,n('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,n('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,n('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,n('","')),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,n('";"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,n('"?"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,n('"/"'))))))))),e}function Is(){var e,s,r;for(r=t,e=[],s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,n('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,n('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,n('","'))))))));s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,n('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,n('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,n('","'))))))));return e!==null&&(e=(function(l){x.password=i.substring(t,l)})(r)),e===null&&(t=r),e}function Ye(){var e,s,r,l,a;return l=t,e=Le(),e!==null?(a=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Ns(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e}function Le(){var e,s;return s=t,e=gt(),e===null&&(e=Fe(),e===null&&(e=Ct())),e!==null&&(e=(function(r){return x.host=i.substring(t,r).toLowerCase(),x.host})(s)),e===null&&(t=s),e}function gt(){var e,s,r,l,a,u;for(l=t,a=t,e=[],u=t,s=Tt(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."')),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u);s!==null;)e.push(s),u=t,s=Tt(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."')),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u);return e!==null?(s=xs(),s!==null?(i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."')),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(g){return x.host_type="domain",i.substring(t,g)})(l)),e===null&&(t=l),e}function Tt(){var e,s,r,l;if(l=t,e=F(),e!==null){for(s=[],r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,n('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,n('"_"'))));r!==null;)s.push(r),r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,n('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,n('"_"'))));s!==null?e=[e,s]:(e=null,t=l)}else e=null,t=l;return e}function xs(){var e,s,r,l;if(l=t,e=R(),e!==null){for(s=[],r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,n('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,n('"_"'))));r!==null;)s.push(r),r=F(),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,n('"-"')),r===null&&(i.charCodeAt(t)===95?(r="_",t++):(r=null,n('"_"'))));s!==null?e=[e,s]:(e=null,t=l)}else e=null,t=l;return e}function Ct(){var e,s,r,l,a;return l=t,a=t,i.charCodeAt(t)===91?(e="[",t++):(e=null,n('"["')),e!==null?(s=vt(),s!==null?(i.charCodeAt(t)===93?(r="]",t++):(r=null,n('"]"')),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u){return x.host_type="IPv6",i.substring(t,u)})(l)),e===null&&(t=l),e}function vt(){var e,s,r,l,a,u,g,P,k,W,se,Te,ut,$t,L,G;return $t=t,L=t,e=j(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?(i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=j(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(g=j(),g!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,n('":"')),P!==null?(k=j(),k!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,n('":"')),W!==null?(se=j(),se!==null?(i.charCodeAt(t)===58?(Te=":",t++):(Te=null,n('":"')),Te!==null?(ut=me(),ut!==null?e=[e,s,r,l,a,u,g,P,k,W,se,Te,ut]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(g=":",t++):(g=null,n('":"')),g!==null?(P=j(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,n('":"')),k!==null?(W=j(),W!==null?(i.charCodeAt(t)===58?(se=":",t++):(se=null,n('":"')),se!==null?(Te=me(),Te!==null?e=[e,s,r,l,a,u,g,P,k,W,se,Te]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(g=":",t++):(g=null,n('":"')),g!==null?(P=j(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,n('":"')),k!==null?(W=me(),W!==null?e=[e,s,r,l,a,u,g,P,k,W]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(g=":",t++):(g=null,n('":"')),g!==null?(P=me(),P!==null?e=[e,s,r,l,a,u,g,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=me(),u!==null?e=[e,s,r,l,a,u]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=j(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=me(),l!==null?e=[e,s,r,l]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=me(),s!==null?e=[e,s]:(e=null,t=L)):(e=null,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=j(),s!==null?e=[e,s]:(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(i.substr(t,2)==="::"?(s="::",t+=2):(s=null,n('"::"')),s!==null?(r=j(),r!==null?(i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=j(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(g=j(),g!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,n('":"')),P!==null?(k=j(),k!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,n('":"')),W!==null?(se=me(),se!==null?e=[e,s,r,l,a,u,g,P,k,W,se]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(i.substr(t,2)==="::"?(r="::",t+=2):(r=null,n('"::"')),r!==null?(l=j(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(g=":",t++):(g=null,n('":"')),g!==null?(P=j(),P!==null?(i.charCodeAt(t)===58?(k=":",t++):(k=null,n('":"')),k!==null?(W=me(),W!==null?e=[e,s,r,l,a,u,g,P,k,W]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(i.substr(t,2)==="::"?(l="::",t+=2):(l=null,n('"::"')),l!==null?(a=j(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(g=j(),g!==null?(i.charCodeAt(t)===58?(P=":",t++):(P=null,n('":"')),P!==null?(k=me(),k!==null?e=[e,s,r,l,a,u,g,P,k]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=j(),a!==null?l=[l,a]:(l=null,t=G)):(l=null,t=G),l=l!==null?l:"",l!==null?(i.substr(t,2)==="::"?(a="::",t+=2):(a=null,n('"::"')),a!==null?(u=j(),u!==null?(i.charCodeAt(t)===58?(g=":",t++):(g=null,n('":"')),g!==null?(P=me(),P!==null?e=[e,s,r,l,a,u,g,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=j(),a!==null?l=[l,a]:(l=null,t=G)):(l=null,t=G),l=l!==null?l:"",l!==null?(G=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=j(),u!==null?a=[a,u]:(a=null,t=G)):(a=null,t=G),a=a!==null?a:"",a!==null?(i.substr(t,2)==="::"?(u="::",t+=2):(u=null,n('"::"')),u!==null?(g=me(),g!==null?e=[e,s,r,l,a,u,g]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=j(),a!==null?l=[l,a]:(l=null,t=G)):(l=null,t=G),l=l!==null?l:"",l!==null?(G=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=j(),u!==null?a=[a,u]:(a=null,t=G)):(a=null,t=G),a=a!==null?a:"",a!==null?(G=t,i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(g=j(),g!==null?u=[u,g]:(u=null,t=G)):(u=null,t=G),u=u!==null?u:"",u!==null?(i.substr(t,2)==="::"?(g="::",t+=2):(g=null,n('"::"')),g!==null?(P=j(),P!==null?e=[e,s,r,l,a,u,g,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L),e===null&&(L=t,e=j(),e!==null?(G=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?s=[s,r]:(s=null,t=G)):(s=null,t=G),s=s!==null?s:"",s!==null?(G=t,i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=G)):(r=null,t=G),r=r!==null?r:"",r!==null?(G=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=j(),a!==null?l=[l,a]:(l=null,t=G)):(l=null,t=G),l=l!==null?l:"",l!==null?(G=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=j(),u!==null?a=[a,u]:(a=null,t=G)):(a=null,t=G),a=a!==null?a:"",a!==null?(G=t,i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(g=j(),g!==null?u=[u,g]:(u=null,t=G)):(u=null,t=G),u=u!==null?u:"",u!==null?(G=t,i.charCodeAt(t)===58?(g=":",t++):(g=null,n('":"')),g!==null?(P=j(),P!==null?g=[g,P]:(g=null,t=G)):(g=null,t=G),g=g!==null?g:"",g!==null?(i.substr(t,2)==="::"?(P="::",t+=2):(P=null,n('"::"')),P!==null?e=[e,s,r,l,a,u,g,P]:(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L)):(e=null,t=L))))))))))))))),e!==null&&(e=(function(zl){return x.host_type="IPv6",i.substring(t,zl)})($t)),e===null&&(t=$t),e}function j(){var e,s,r,l,a;return a=t,e=D(),e!==null?(s=D(),s=s!==null?s:"",s!==null?(r=D(),r=r!==null?r:"",r!==null?(l=D(),l=l!==null?l:"",l!==null?e=[e,s,r,l]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function me(){var e,s,r,l;return l=t,e=j(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=j(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e===null&&(e=Fe()),e}function Fe(){var e,s,r,l,a,u,g,P,k;return P=t,k=t,e=He(),e!==null?(i.charCodeAt(t)===46?(s=".",t++):(s=null,n('"."')),s!==null?(r=He(),r!==null?(i.charCodeAt(t)===46?(l=".",t++):(l=null,n('"."')),l!==null?(a=He(),a!==null?(i.charCodeAt(t)===46?(u=".",t++):(u=null,n('"."')),u!==null?(g=He(),g!==null?e=[e,s,r,l,a,u,g]:(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k)):(e=null,t=k),e!==null&&(e=(function(W){return x.host_type="IPv4",i.substring(t,W)})(P)),e===null&&(t=P),e}function He(){var e,s,r,l;return l=t,i.substr(t,2)==="25"?(e="25",t+=2):(e=null,n('"25"')),e!==null?(/^[0-5]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,n("[0-5]")),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e===null&&(l=t,i.charCodeAt(t)===50?(e="2",t++):(e=null,n('"2"')),e!==null?(/^[0-4]/.test(i.charAt(t))?(s=i.charAt(t),t++):(s=null,n("[0-4]")),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e===null&&(l=t,i.charCodeAt(t)===49?(e="1",t++):(e=null,n('"1"')),e!==null?(s=c(),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e===null&&(l=t,/^[1-9]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[1-9]")),e!==null?(s=c(),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e===null&&(e=c())))),e}function Ns(){var e,s,r,l,a,u,g;return u=t,g=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(l=c(),l=l!==null?l:"",l!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,l,a]:(e=null,t=g)):(e=null,t=g)):(e=null,t=g)):(e=null,t=g)):(e=null,t=g),e!==null&&(e=(function(P,k){return k=parseInt(k.join("")),x.port=k,k})(u,e)),e===null&&(t=u),e}function Os(){var e,s,r,l;for(e=[],l=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,n('";"')),s!==null?(r=Et(),r!==null?s=[s,r]:(s=null,t=l)):(s=null,t=l);s!==null;)e.push(s),l=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,n('";"')),s!==null?(r=Et(),r!==null?s=[s,r]:(s=null,t=l)):(s=null,t=l);return e}function Et(){var e;return e=Ds(),e===null&&(e=Us(),e===null&&(e=Ps(),e===null&&(e=Ms(),e===null&&(e=Ls(),e===null&&(e=Fs(),e===null&&(e=Hs())))))),e}function Ds(){var e,s,r,l;return r=t,l=t,i.substr(t,10).toLowerCase()==="transport="?(e=i.substr(t,10),t+=10):(e=null,n('"transport="')),e!==null?(i.substr(t,3).toLowerCase()==="udp"?(s=i.substr(t,3),t+=3):(s=null,n('"udp"')),s===null&&(i.substr(t,3).toLowerCase()==="tcp"?(s=i.substr(t,3),t+=3):(s=null,n('"tcp"')),s===null&&(i.substr(t,4).toLowerCase()==="sctp"?(s=i.substr(t,4),t+=4):(s=null,n('"sctp"')),s===null&&(i.substr(t,3).toLowerCase()==="tls"?(s=i.substr(t,3),t+=3):(s=null,n('"tls"')),s===null&&(s=B())))),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.transport=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function Us(){var e,s,r,l;return r=t,l=t,i.substr(t,5).toLowerCase()==="user="?(e=i.substr(t,5),t+=5):(e=null,n('"user="')),e!==null?(i.substr(t,5).toLowerCase()==="phone"?(s=i.substr(t,5),t+=5):(s=null,n('"phone"')),s===null&&(i.substr(t,2).toLowerCase()==="ip"?(s=i.substr(t,2),t+=2):(s=null,n('"ip"')),s===null&&(s=B())),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.user=u.toLowerCase()})(r,e[1])),e===null&&(t=r),e}function Ps(){var e,s,r,l;return r=t,l=t,i.substr(t,7).toLowerCase()==="method="?(e=i.substr(t,7),t+=7):(e=null,n('"method="')),e!==null?(s=Ze(),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.method=u})(r,e[1])),e===null&&(t=r),e}function Ms(){var e,s,r,l;return r=t,l=t,i.substr(t,4).toLowerCase()==="ttl="?(e=i.substr(t,4),t+=4):(e=null,n('"ttl="')),e!==null?(s=Mt(),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a,u){x.params||(x.params={}),x.params.ttl=u})(r,e[1])),e===null&&(t=r),e}function Ls(){var e,s,r,l;return r=t,l=t,i.substr(t,6).toLowerCase()==="maddr="?(e=i.substr(t,6),t+=6):(e=null,n('"maddr="')),e!==null?(s=Le(),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e!==null&&(e=(function(a,u){x.uri_params||(x.uri_params={}),x.uri_params.maddr=u})(r,e[1])),e===null&&(t=r),e}function Fs(){var e,s,r,l,a,u;return l=t,a=t,i.substr(t,2).toLowerCase()==="lr"?(e=i.substr(t,2),t+=2):(e=null,n('"lr"')),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s!==null?(r=B(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(g){x.uri_params||(x.uri_params={}),x.uri_params.lr=void 0})()),e===null&&(t=l),e}function Hs(){var e,s,r,l,a,u;return l=t,a=t,e=$s(),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s!==null?(r=ks(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(g,P,k){x.uri_params||(x.uri_params={}),typeof k>"u"?k=void 0:k=k[1],x.uri_params[P.toLowerCase()]=k})(l,e[0],e[1])),e===null&&(t=l),e}function $s(){var e,s,r;if(r=t,s=$e(),s!==null)for(e=[];s!==null;)e.push(s),s=$e();else e=null;return e!==null&&(e=(function(l,a){return a.join("")})(r,e)),e===null&&(t=r),e}function ks(){var e,s,r;if(r=t,s=$e(),s!==null)for(e=[];s!==null;)e.push(s),s=$e();else e=null;return e!==null&&(e=(function(l,a){return a.join("")})(r,e)),e===null&&(t=r),e}function $e(){var e;return e=qs(),e===null&&(e=o(),e===null&&(e=T())),e}function qs(){var e;return i.charCodeAt(t)===91?(e="[",t++):(e=null,n('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,n('"]"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,n('"/"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,n('":"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,n('"&"')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,n('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,n('"$"')))))))),e}function js(){var e,s,r,l,a,u,g;if(u=t,i.charCodeAt(t)===63?(e="?",t++):(e=null,n('"?"')),e!==null)if(s=Je(),s!==null){for(r=[],g=t,i.charCodeAt(t)===38?(l="&",t++):(l=null,n('"&"')),l!==null?(a=Je(),a!==null?l=[l,a]:(l=null,t=g)):(l=null,t=g);l!==null;)r.push(l),g=t,i.charCodeAt(t)===38?(l="&",t++):(l=null,n('"&"')),l!==null?(a=Je(),a!==null?l=[l,a]:(l=null,t=g)):(l=null,t=g);r!==null?e=[e,s,r]:(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e}function Je(){var e,s,r,l,a;return l=t,a=t,e=Gs(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s!==null?(r=Bs(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g,P){g=g.join("").toLowerCase(),P=P.join(""),x.uri_headers||(x.uri_headers={}),x.uri_headers[g]?x.uri_headers[g].push(P):x.uri_headers[g]=[P]})(l,e[0],e[2])),e===null&&(t=l),e}function Gs(){var e,s;if(s=ke(),s===null&&(s=o(),s===null&&(s=T())),s!==null)for(e=[];s!==null;)e.push(s),s=ke(),s===null&&(s=o(),s===null&&(s=T()));else e=null;return e}function Bs(){var e,s;for(e=[],s=ke(),s===null&&(s=o(),s===null&&(s=T()));s!==null;)e.push(s),s=ke(),s===null&&(s=o(),s===null&&(s=T()));return e}function ke(){var e;return i.charCodeAt(t)===91?(e="[",t++):(e=null,n('"["')),e===null&&(i.charCodeAt(t)===93?(e="]",t++):(e=null,n('"]"')),e===null&&(i.charCodeAt(t)===47?(e="/",t++):(e=null,n('"/"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,n('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,n('":"')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,n('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,n('"$"')))))))),e}function cl(){var e;return e=hr(),e===null&&(e=Ws()),e}function Ws(){var e,s,r,l,a,u;return u=t,e=Ze(),e!==null?(s=C(),s!==null?(r=Vs(),r!==null?(l=C(),l!==null?(a=Rt(),a!==null?e=[e,s,r,l,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Vs(){var e;return e=ve(),e===null&&(e=St()),e}function St(){var e,s,r,l;return l=t,e=Qs(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=zs(),r===null&&(r=Ys()),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function zs(){var e,s,r,l,a;return l=t,e=Ks(),e===null&&(e=Xe()),e!==null?(a=t,i.charCodeAt(t)===63?(s="?",t++):(s=null,n('"?"')),s!==null?(r=sr(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e}function Ks(){var e,s,r,l;return l=t,i.substr(t,2)==="//"?(e="//",t+=2):(e=null,n('"//"')),e!==null?(s=Zs(),s!==null?(r=Xe(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Xe(){var e,s,r;return r=t,i.charCodeAt(t)===47?(e="/",t++):(e=null,n('"/"')),e!==null?(s=Xs(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Ys(){var e,s,r,l;if(l=t,e=Js(),e!==null){for(s=[],r=qe();r!==null;)s.push(r),r=qe();s!==null?e=[e,s]:(e=null,t=l)}else e=null,t=l;return e}function qe(){var e;return e=H(),e===null&&(e=o(),e===null&&(e=T())),e}function Js(){var e;return e=o(),e===null&&(e=T(),e===null&&(i.charCodeAt(t)===59?(e=";",t++):(e=null,n('";"')),e===null&&(i.charCodeAt(t)===63?(e="?",t++):(e=null,n('"?"')),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,n('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,n('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,n('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,n('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,n('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,n('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,n('","')))))))))))),e}function Xs(){var e,s,r,l,a,u;if(a=t,e=Qe(),e!==null){for(s=[],u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,n('"/"')),r!==null?(l=Qe(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,n('"/"')),r!==null?(l=Qe(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Qe(){var e,s,r,l,a,u;for(a=t,e=[],s=je();s!==null;)e.push(s),s=je();if(e!==null){for(s=[],u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,n('";"')),r!==null?(l=At(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,n('";"')),r!==null?(l=At(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function At(){var e,s;for(e=[],s=je();s!==null;)e.push(s),s=je();return e}function je(){var e;return e=o(),e===null&&(e=T(),e===null&&(i.charCodeAt(t)===58?(e=":",t++):(e=null,n('":"')),e===null&&(i.charCodeAt(t)===64?(e="@",t++):(e=null,n('"@"')),e===null&&(i.charCodeAt(t)===38?(e="&",t++):(e=null,n('"&"')),e===null&&(i.charCodeAt(t)===61?(e="=",t++):(e=null,n('"="')),e===null&&(i.charCodeAt(t)===43?(e="+",t++):(e=null,n('"+"')),e===null&&(i.charCodeAt(t)===36?(e="$",t++):(e=null,n('"$"')),e===null&&(i.charCodeAt(t)===44?(e=",",t++):(e=null,n('","')))))))))),e}function Qs(){var e,s,r,l,a;if(l=t,a=t,e=R(),e!==null){for(s=[],r=R(),r===null&&(r=c(),r===null&&(i.charCodeAt(t)===43?(r="+",t++):(r=null,n('"+"')),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,n('"-"')),r===null&&(i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."'))))));r!==null;)s.push(r),r=R(),r===null&&(r=c(),r===null&&(i.charCodeAt(t)===43?(r="+",t++):(r=null,n('"+"')),r===null&&(i.charCodeAt(t)===45?(r="-",t++):(r=null,n('"-"')),r===null&&(i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."'))))));s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e!==null&&(e=(function(u){x.scheme=i.substring(t,u)})(l)),e===null&&(t=l),e}function Zs(){var e;return e=er(),e===null&&(e=tr()),e}function er(){var e,s,r,l;return r=t,l=t,e=Ke(),e!==null?(i.charCodeAt(t)===64?(s="@",t++):(s=null,n('"@"')),s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e=e!==null?e:"",e!==null?(s=Ye(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e=e!==null?e:"",e}function tr(){var e,s;if(s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,n('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,n('","')),s===null&&(i.charCodeAt(t)===59?(s=";",t++):(s=null,n('";"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s===null&&(i.charCodeAt(t)===64?(s="@",t++):(s=null,n('"@"')),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,n('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"'))))))))))),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=T(),s===null&&(i.charCodeAt(t)===36?(s="$",t++):(s=null,n('"$"')),s===null&&(i.charCodeAt(t)===44?(s=",",t++):(s=null,n('","')),s===null&&(i.charCodeAt(t)===59?(s=";",t++):(s=null,n('";"')),s===null&&(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s===null&&(i.charCodeAt(t)===64?(s="@",t++):(s=null,n('"@"')),s===null&&(i.charCodeAt(t)===38?(s="&",t++):(s=null,n('"&"')),s===null&&(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s===null&&(i.charCodeAt(t)===43?(s="+",t++):(s=null,n('"+"')))))))))));else e=null;return e}function sr(){var e,s;for(e=[],s=qe();s!==null;)e.push(s),s=qe();return e}function Rt(){var e,s,r,l,a,u,g,P;if(g=t,P=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,n('"SIP"')),e!==null)if(i.charCodeAt(t)===47?(s="/",t++):(s=null,n('"/"')),s!==null){if(l=c(),l!==null)for(r=[];l!==null;)r.push(l),l=c();else r=null;if(r!==null)if(i.charCodeAt(t)===46?(l=".",t++):(l=null,n('"."')),l!==null){if(u=c(),u!==null)for(a=[];u!==null;)a.push(u),u=c();else a=null;a!==null?e=[e,s,r,l,a]:(e=null,t=P)}else e=null,t=P;else e=null,t=P}else e=null,t=P;else e=null,t=P;return e!==null&&(e=(function(k){x.sip_version=i.substring(t,k)})(g)),e===null&&(t=g),e}function rr(){var e;return i.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,n('"INVITE"')),e}function nr(){var e;return i.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,n('"ACK"')),e}function lr(){var e;return i.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,n('"OPTIONS"')),e}function ir(){var e;return i.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,n('"BYE"')),e}function ar(){var e;return i.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,n('"CANCEL"')),e}function or(){var e;return i.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,n('"REGISTER"')),e}function ur(){var e;return i.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,n('"SUBSCRIBE"')),e}function cr(){var e;return i.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,n('"NOTIFY"')),e}function fr(){var e;return i.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,n('"REFER"')),e}function Ze(){var e,s;return s=t,e=rr(),e===null&&(e=nr(),e===null&&(e=lr(),e===null&&(e=ir(),e===null&&(e=ar(),e===null&&(e=or(),e===null&&(e=ur(),e===null&&(e=cr(),e===null&&(e=fr(),e===null&&(e=B()))))))))),e!==null&&(e=(function(r){return x.method=i.substring(t,r),x.method})(s)),e===null&&(t=s),e}function hr(){var e,s,r,l,a,u;return u=t,e=Rt(),e!==null?(s=C(),s!==null?(r=dr(),r!==null?(l=C(),l!==null?(a=pr(),a!==null?e=[e,s,r,l,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function dr(){var e,s;return s=t,e=_r(),e!==null&&(e=(function(r,l){x.status_code=parseInt(l.join(""))})(s,e)),e===null&&(t=s),e}function _r(){var e,s,r,l;return l=t,e=c(),e!==null?(s=c(),s!==null?(r=c(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function pr(){var e,s,r;for(r=t,e=[],s=H(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=U(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=I()))))));s!==null;)e.push(s),s=H(),s===null&&(s=o(),s===null&&(s=T(),s===null&&(s=U(),s===null&&(s=M(),s===null&&(s=C(),s===null&&(s=I()))))));return e!==null&&(e=(function(l){x.reason_phrase=i.substring(t,l)})(r)),e===null&&(t=r),e}function fl(){var e,s,r,l,a,u;if(a=t,e=Ge(),e!==null){for(s=[],u=t,r=ee(),r!==null?(l=Ge(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(l=Ge(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function hl(){var e,s,r,l,a,u;return l=t,a=t,e=he(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,n('"@"')),s!==null?(r=he(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(g){x=i.substring(t,g)})(l)),e===null&&(t=l),e}function dl(){var e,s,r,l,a,u,g;if(a=t,e=X(),e===null)if(u=t,e=et(),e!==null){for(s=[],g=t,r=ee(),r!==null?(l=et(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=ee(),r!==null?(l=et(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k,W;for(W=x.multi_header.length,k=0;k<W;k++)if(x.multi_header[k].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function et(){var e,s,r,l,a,u,g;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],g=t,r=J(),r!==null?(l=bt(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=J(),r!==null?(l=bt(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k;x.multi_header||(x.multi_header=[]);try{k=new Pe(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{k=null}x.multi_header.push({possition:t,offset:P,parsed:k})})(a)),e===null&&(t=a),e}function De(){var e,s,r,l,a;return a=t,e=tt(),e=e!==null?e:"",e!==null?(s=Re(),s!==null?(r=ve(),r!==null?(l=Ae(),l!==null?e=[e,s,r,l]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function tt(){var e,s,r,l,a,u,g;if(a=t,u=t,e=B(),e!==null){for(s=[],g=t,r=p(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=p(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e===null&&(e=Z()),e!==null&&(e=(function(P,k){typeof k=="string"?x.display_name=k:x.display_name=k[1].reduce(function(W,se){return W+se[0]+se[1]},k[0])})(a,e)),e===null&&(t=a),e}function bt(){var e;return e=mr(),e===null&&(e=gr(),e===null&&(e=ae())),e}function mr(){var e,s,r,l,a;return l=t,a=t,i.substr(t,1).toLowerCase()==="q"?(e=i.substr(t,1),t++):(e=null,n('"q"')),e!==null?(s=Q(),s!==null?(r=Tr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.params||(x.params={}),x.params.q=g})(l,e[2])),e===null&&(t=l),e}function gr(){var e,s,r,l,a;return l=t,a=t,i.substr(t,7).toLowerCase()==="expires"?(e=i.substr(t,7),t+=7):(e=null,n('"expires"')),e!==null?(s=Q(),s!==null?(r=Ue(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.params||(x.params={}),x.params.expires=g})(l,e[2])),e===null&&(t=l),e}function Ue(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(l,a){return parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function Tr(){var e,s,r,l,a,u,g,P;return u=t,g=t,i.charCodeAt(t)===48?(e="0",t++):(e=null,n('"0"')),e!==null?(P=t,i.charCodeAt(t)===46?(s=".",t++):(s=null,n('"."')),s!==null?(r=c(),r=r!==null?r:"",r!==null?(l=c(),l=l!==null?l:"",l!==null?(a=c(),a=a!==null?a:"",a!==null?s=[s,r,l,a]:(s=null,t=P)):(s=null,t=P)):(s=null,t=P)):(s=null,t=P),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=g)):(e=null,t=g),e!==null&&(e=(function(k){return parseFloat(i.substring(t,k))})(u)),e===null&&(t=u),e}function ae(){var e,s,r,l,a,u;return l=t,a=t,e=B(),e!==null?(u=t,s=Q(),s!==null?(r=Cr(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(g,P,k){x.params||(x.params={}),typeof k>"u"?k=void 0:k=k[1],x.params[P.toLowerCase()]=k})(l,e[0],e[1])),e===null&&(t=l),e}function Cr(){var e;return e=B(),e===null&&(e=Le(),e===null&&(e=K())),e}function _l(){var e,s,r,l,a,u;if(a=t,e=vr(),e!==null){for(s=[],u=t,r=J(),r!==null?(l=wt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=J(),r!==null?(l=wt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function vr(){var e;return i.substr(t,6).toLowerCase()==="render"?(e=i.substr(t,6),t+=6):(e=null,n('"render"')),e===null&&(i.substr(t,7).toLowerCase()==="session"?(e=i.substr(t,7),t+=7):(e=null,n('"session"')),e===null&&(i.substr(t,4).toLowerCase()==="icon"?(e=i.substr(t,4),t+=4):(e=null,n('"icon"')),e===null&&(i.substr(t,5).toLowerCase()==="alert"?(e=i.substr(t,5),t+=5):(e=null,n('"alert"')),e===null&&(e=B())))),e}function wt(){var e;return e=Er(),e===null&&(e=ae()),e}function Er(){var e,s,r,l;return l=t,i.substr(t,8).toLowerCase()==="handling"?(e=i.substr(t,8),t+=8):(e=null,n('"handling"')),e!==null?(s=Q(),s!==null?(i.substr(t,8).toLowerCase()==="optional"?(r=i.substr(t,8),t+=8):(r=null,n('"optional"')),r===null&&(i.substr(t,8).toLowerCase()==="required"?(r=i.substr(t,8),t+=8):(r=null,n('"required"')),r===null&&(r=B())),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function pl(){var e,s,r,l,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function ml(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(l,a){x=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function gl(){var e,s;return s=t,e=Sr(),e!==null&&(e=(function(r){x=i.substring(t,r)})(s)),e===null&&(t=s),e}function Sr(){var e,s,r,l,a,u,g,P;if(g=t,e=Ar(),e!==null)if(s=_e(),s!==null)if(r=yr(),r!==null){for(l=[],P=t,a=J(),a!==null?(u=yt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)l.push(a),P=t,a=J(),a!==null?(u=yt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);l!==null?e=[e,s,r,l]:(e=null,t=g)}else e=null,t=g;else e=null,t=g;else e=null,t=g;return e}function Ar(){var e;return e=Rr(),e===null&&(e=br()),e}function Rr(){var e;return i.substr(t,4).toLowerCase()==="text"?(e=i.substr(t,4),t+=4):(e=null,n('"text"')),e===null&&(i.substr(t,5).toLowerCase()==="image"?(e=i.substr(t,5),t+=5):(e=null,n('"image"')),e===null&&(i.substr(t,5).toLowerCase()==="audio"?(e=i.substr(t,5),t+=5):(e=null,n('"audio"')),e===null&&(i.substr(t,5).toLowerCase()==="video"?(e=i.substr(t,5),t+=5):(e=null,n('"video"')),e===null&&(i.substr(t,11).toLowerCase()==="application"?(e=i.substr(t,11),t+=11):(e=null,n('"application"')),e===null&&(e=st()))))),e}function br(){var e;return i.substr(t,7).toLowerCase()==="message"?(e=i.substr(t,7),t+=7):(e=null,n('"message"')),e===null&&(i.substr(t,9).toLowerCase()==="multipart"?(e=i.substr(t,9),t+=9):(e=null,n('"multipart"')),e===null&&(e=st())),e}function st(){var e;return e=B(),e===null&&(e=wr()),e}function wr(){var e,s,r;return r=t,i.substr(t,2).toLowerCase()==="x-"?(e=i.substr(t,2),t+=2):(e=null,n('"x-"')),e!==null?(s=B(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function yr(){var e;return e=st(),e===null&&(e=B()),e}function yt(){var e,s,r,l;return l=t,e=B(),e!==null?(s=Q(),s!==null?(r=Ir(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Ir(){var e;return e=B(),e===null&&(e=K()),e}function Tl(){var e,s,r,l;return l=t,e=xr(),e!==null?(s=p(),s!==null?(r=Ze(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function xr(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(l,a){x.value=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function Cl(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,l){x=l})(s,e)),e===null&&(t=s),e}function vl(){var e,s,r,l,a,u,g;if(a=t,u=t,e=Ge(),e!==null){for(s=[],g=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P,k){x.event=k.join("").toLowerCase()})(a,e[0])),e===null&&(t=a),e}function Ge(){var e,s,r,l,a,u;if(a=t,e=ue(),e!==null){for(s=[],u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."')),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."')),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function El(){var e,s,r,l,a,u,g;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],g=t,r=J(),r!==null?(l=It(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=J(),r!==null?(l=It(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k=x.tag;try{x=new Pe(x.uri,x.display_name,x.params),k&&x.setParam("tag",k)}catch{x=-1}})()),e===null&&(t=a),e}function It(){var e;return e=xt(),e===null&&(e=ae()),e}function xt(){var e,s,r,l,a;return l=t,a=t,i.substr(t,3).toLowerCase()==="tag"?(e=i.substr(t,3),t+=3):(e=null,n('"tag"')),e!==null?(s=Q(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.tag=g})(l,e[2])),e===null&&(t=l),e}function Sl(){var e,s,r;if(r=t,s=c(),s!==null)for(e=[];s!==null;)e.push(s),s=c();else e=null;return e!==null&&(e=(function(l,a){x=parseInt(a.join(""))})(r,e)),e===null&&(t=r),e}function Al(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,l){x=l})(s,e)),e===null&&(t=s),e}function Rl(){var e,s,r,l,a,u,g,P,k,W;for(P=t,k=t,e=[],s=tt();s!==null;)e.push(s),s=tt();if(e!==null)if(s=Re(),s!==null)if(r=ve(),r!==null)if(l=Ae(),l!==null){for(a=[],W=t,u=J(),u!==null?(g=ae(),g!==null?u=[u,g]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,u=J(),u!==null?(g=ae(),g!==null?u=[u,g]:(u=null,t=W)):(u=null,t=W);a!==null?e=[e,s,r,l,a]:(e=null,t=k)}else e=null,t=k;else e=null,t=k;else e=null,t=k;else e=null,t=k;return e!==null&&(e=(function(se){try{x=new Pe(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=P),e}function bl(){var e;return e=Nt(),e}function Nt(){var e,s,r,l,a,u,g,P;if(g=t,i.substr(t,6).toLowerCase()==="digest"?(e=i.substr(t,6),t+=6):(e=null,n('"Digest"')),e!==null)if(s=p(),s!==null)if(r=rt(),r!==null){for(l=[],P=t,a=ee(),a!==null?(u=rt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)l.push(a),P=t,a=ee(),a!==null?(u=rt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);l!==null?e=[e,s,r,l]:(e=null,t=g)}else e=null,t=g;else e=null,t=g;else e=null,t=g;return e===null&&(e=Nr()),e}function Nr(){var e,s,r,l,a,u,g,P;if(g=t,e=B(),e!==null)if(s=p(),s!==null)if(r=Be(),r!==null){for(l=[],P=t,a=ee(),a!==null?(u=Be(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)l.push(a),P=t,a=ee(),a!==null?(u=Be(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);l!==null?e=[e,s,r,l]:(e=null,t=g)}else e=null,t=g;else e=null,t=g;else e=null,t=g;return e}function Be(){var e,s,r,l;return l=t,e=B(),e!==null?(s=Q(),s!==null?(r=B(),r===null&&(r=K()),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function rt(){var e;return e=Or(),e===null&&(e=Ur(),e===null&&(e=Pr(),e===null&&(e=Lr(),e===null&&(e=Fr(),e===null&&(e=Hr(),e===null&&(e=$r(),e===null&&(e=Be()))))))),e}function Or(){var e,s,r,l;return l=t,i.substr(t,5).toLowerCase()==="realm"?(e=i.substr(t,5),t+=5):(e=null,n('"realm"')),e!==null?(s=Q(),s!==null?(r=Dr(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Dr(){var e,s;return s=t,e=Z(),e!==null&&(e=(function(r,l){x.realm=l})(s,e)),e===null&&(t=s),e}function Ur(){var e,s,r,l,a,u,g,P,k;if(P=t,i.substr(t,6).toLowerCase()==="domain"?(e=i.substr(t,6),t+=6):(e=null,n('"domain"')),e!==null)if(s=Q(),s!==null)if(r=be(),r!==null)if(l=nt(),l!==null){if(a=[],k=t,g=C(),g!==null)for(u=[];g!==null;)u.push(g),g=C();else u=null;for(u!==null?(g=nt(),g!==null?u=[u,g]:(u=null,t=k)):(u=null,t=k);u!==null;){if(a.push(u),k=t,g=C(),g!==null)for(u=[];g!==null;)u.push(g),g=C();else u=null;u!==null?(g=nt(),g!==null?u=[u,g]:(u=null,t=k)):(u=null,t=k)}a!==null?(u=ze(),u!==null?e=[e,s,r,l,a,u]:(e=null,t=P)):(e=null,t=P)}else e=null,t=P;else e=null,t=P;else e=null,t=P;else e=null,t=P;return e}function nt(){var e;return e=St(),e===null&&(e=Xe()),e}function Pr(){var e,s,r,l;return l=t,i.substr(t,5).toLowerCase()==="nonce"?(e=i.substr(t,5),t+=5):(e=null,n('"nonce"')),e!==null?(s=Q(),s!==null?(r=Mr(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Mr(){var e,s;return s=t,e=Z(),e!==null&&(e=(function(r,l){x.nonce=l})(s,e)),e===null&&(t=s),e}function Lr(){var e,s,r,l,a;return l=t,a=t,i.substr(t,6).toLowerCase()==="opaque"?(e=i.substr(t,6),t+=6):(e=null,n('"opaque"')),e!==null?(s=Q(),s!==null?(r=Z(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.opaque=g})(l,e[2])),e===null&&(t=l),e}function Fr(){var e,s,r,l,a;return l=t,i.substr(t,5).toLowerCase()==="stale"?(e=i.substr(t,5),t+=5):(e=null,n('"stale"')),e!==null?(s=Q(),s!==null?(a=t,i.substr(t,4).toLowerCase()==="true"?(r=i.substr(t,4),t+=4):(r=null,n('"true"')),r!==null&&(r=(function(u){x.stale=!0})()),r===null&&(t=a),r===null&&(a=t,i.substr(t,5).toLowerCase()==="false"?(r=i.substr(t,5),t+=5):(r=null,n('"false"')),r!==null&&(r=(function(u){x.stale=!1})()),r===null&&(t=a)),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Hr(){var e,s,r,l,a;return l=t,a=t,i.substr(t,9).toLowerCase()==="algorithm"?(e=i.substr(t,9),t+=9):(e=null,n('"algorithm"')),e!==null?(s=Q(),s!==null?(i.substr(t,3).toLowerCase()==="md5"?(r=i.substr(t,3),t+=3):(r=null,n('"MD5"')),r===null&&(i.substr(t,8).toLowerCase()==="md5-sess"?(r=i.substr(t,8),t+=8):(r=null,n('"MD5-sess"')),r===null&&(r=B())),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.algorithm=g.toUpperCase()})(l,e[2])),e===null&&(t=l),e}function $r(){var e,s,r,l,a,u,g,P,k,W;if(P=t,i.substr(t,3).toLowerCase()==="qop"?(e=i.substr(t,3),t+=3):(e=null,n('"qop"')),e!==null)if(s=Q(),s!==null)if(r=be(),r!==null){if(k=t,l=lt(),l!==null){for(a=[],W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,n('","')),u!==null?(g=lt(),g!==null?u=[u,g]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,n('","')),u!==null?(g=lt(),g!==null?u=[u,g]:(u=null,t=W)):(u=null,t=W);a!==null?l=[l,a]:(l=null,t=k)}else l=null,t=k;l!==null?(a=ze(),a!==null?e=[e,s,r,l,a]:(e=null,t=P)):(e=null,t=P)}else e=null,t=P;else e=null,t=P;else e=null,t=P;return e}function lt(){var e,s;return s=t,i.substr(t,8).toLowerCase()==="auth-int"?(e=i.substr(t,8),t+=8):(e=null,n('"auth-int"')),e===null&&(i.substr(t,4).toLowerCase()==="auth"?(e=i.substr(t,4),t+=4):(e=null,n('"auth"')),e===null&&(e=B())),e!==null&&(e=(function(r,l){x.qop||(x.qop=[]),x.qop.push(l.toLowerCase())})(s,e)),e===null&&(t=s),e}function wl(){var e,s,r,l,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function yl(){var e,s,r,l,a,u,g;if(a=t,u=t,e=it(),e!==null){for(s=[],g=t,r=ee(),r!==null?(l=it(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=ee(),r!==null?(l=it(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k,W;for(W=x.multi_header.length,k=0;k<W;k++)if(x.multi_header[k].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function it(){var e,s,r,l,a,u,g;if(a=t,u=t,e=De(),e!==null){for(s=[],g=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k;x.multi_header||(x.multi_header=[]);try{k=new Pe(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{k=null}x.multi_header.push({possition:t,offset:P,parsed:k})})(a)),e===null&&(t=a),e}function Il(){var e,s,r,l,a,u,g;if(a=t,u=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,n('"SIP"')),e===null&&(e=B()),e!==null){for(s=[],g=t,r=J(),r!==null?(l=Ot(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=J(),r!==null?(l=Ot(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P,k){if(x.protocol=k.toLowerCase(),x.params||(x.params={}),x.params.text&&x.params.text[0]==='"'){var W=x.params.text;x.text=W.substring(1,W.length-1),delete x.params.text}})(a,e[0])),e===null&&(t=a),e}function Ot(){var e;return e=kr(),e===null&&(e=ae()),e}function kr(){var e,s,r,l,a,u;if(a=t,u=t,i.substr(t,5).toLowerCase()==="cause"?(e=i.substr(t,5),t+=5):(e=null,n('"cause"')),e!==null)if(s=Q(),s!==null){if(l=c(),l!==null)for(r=[];l!==null;)r.push(l),l=c();else r=null;r!==null?e=[e,s,r]:(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e!==null&&(e=(function(g,P){x.cause=parseInt(P.join(""))})(a,e[2])),e===null&&(t=a),e}function xl(){var e,s,r,l,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Nl(){var e,s,r,l,a,u;if(a=t,e=at(),e!==null){for(s=[],u=t,r=ee(),r!==null?(l=at(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(l=at(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function at(){var e,s,r,l,a,u;if(a=t,e=De(),e!==null){for(s=[],u=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function Ol(){var e,s,r,l,a,u;if(a=t,e=qr(),e!==null){for(s=[],u=t,r=J(),r!==null?(l=Dt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=J(),r!==null?(l=Dt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function qr(){var e,s;return s=t,i.substr(t,6).toLowerCase()==="active"?(e=i.substr(t,6),t+=6):(e=null,n('"active"')),e===null&&(i.substr(t,7).toLowerCase()==="pending"?(e=i.substr(t,7),t+=7):(e=null,n('"pending"')),e===null&&(i.substr(t,10).toLowerCase()==="terminated"?(e=i.substr(t,10),t+=10):(e=null,n('"terminated"')),e===null&&(e=B()))),e!==null&&(e=(function(r){x.state=i.substring(t,r)})(s)),e===null&&(t=s),e}function Dt(){var e,s,r,l,a;return l=t,a=t,i.substr(t,6).toLowerCase()==="reason"?(e=i.substr(t,6),t+=6):(e=null,n('"reason"')),e!==null?(s=Q(),s!==null?(r=jr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){typeof g<"u"&&(x.reason=g)})(l,e[2])),e===null&&(t=l),e===null&&(l=t,a=t,i.substr(t,7).toLowerCase()==="expires"?(e=i.substr(t,7),t+=7):(e=null,n('"expires"')),e!==null?(s=Q(),s!==null?(r=Ue(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){typeof g<"u"&&(x.expires=g)})(l,e[2])),e===null&&(t=l),e===null&&(l=t,a=t,i.substr(t,11).toLowerCase()==="retry_after"?(e=i.substr(t,11),t+=11):(e=null,n('"retry_after"')),e!==null?(s=Q(),s!==null?(r=Ue(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){typeof g<"u"&&(x.retry_after=g)})(l,e[2])),e===null&&(t=l),e===null&&(e=ae()))),e}function jr(){var e;return i.substr(t,11).toLowerCase()==="deactivated"?(e=i.substr(t,11),t+=11):(e=null,n('"deactivated"')),e===null&&(i.substr(t,9).toLowerCase()==="probation"?(e=i.substr(t,9),t+=9):(e=null,n('"probation"')),e===null&&(i.substr(t,8).toLowerCase()==="rejected"?(e=i.substr(t,8),t+=8):(e=null,n('"rejected"')),e===null&&(i.substr(t,7).toLowerCase()==="timeout"?(e=i.substr(t,7),t+=7):(e=null,n('"timeout"')),e===null&&(i.substr(t,6).toLowerCase()==="giveup"?(e=i.substr(t,6),t+=6):(e=null,n('"giveup"')),e===null&&(i.substr(t,10).toLowerCase()==="noresource"?(e=i.substr(t,10),t+=10):(e=null,n('"noresource"')),e===null&&(i.substr(t,9).toLowerCase()==="invariant"?(e=i.substr(t,9),t+=9):(e=null,n('"invariant"')),e===null&&(e=B()))))))),e}function Dl(){var e;return e=v(),e=e!==null?e:"",e}function Ul(){var e,s,r,l,a,u;if(a=t,e=B(),e!==null){for(s=[],u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(l=B(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e=e!==null?e:"",e}function Pl(){var e,s,r,l,a,u,g;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],g=t,r=J(),r!==null?(l=Ut(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=J(),r!==null?(l=Ut(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){var k=x.tag;try{x=new Pe(x.uri,x.display_name,x.params),k&&x.setParam("tag",k)}catch{x=-1}})()),e===null&&(t=a),e}function Ut(){var e;return e=xt(),e===null&&(e=ae()),e}function Ml(){var e,s,r,l,a,u;if(a=t,e=ot(),e!==null){for(s=[],u=t,r=ee(),r!==null?(l=ot(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=ee(),r!==null?(l=ot(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function ot(){var e,s,r,l,a,u,g,P;if(g=t,e=Yr(),e!==null)if(s=p(),s!==null)if(r=Qr(),r!==null){for(l=[],P=t,a=J(),a!==null?(u=Pt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);a!==null;)l.push(a),P=t,a=J(),a!==null?(u=Pt(),u!==null?a=[a,u]:(a=null,t=P)):(a=null,t=P);l!==null?e=[e,s,r,l]:(e=null,t=g)}else e=null,t=g;else e=null,t=g;else e=null,t=g;return e}function Pt(){var e;return e=Gr(),e===null&&(e=Br(),e===null&&(e=Wr(),e===null&&(e=Vr(),e===null&&(e=zr(),e===null&&(e=ae()))))),e}function Gr(){var e,s,r,l,a;return l=t,a=t,i.substr(t,3).toLowerCase()==="ttl"?(e=i.substr(t,3),t+=3):(e=null,n('"ttl"')),e!==null?(s=Q(),s!==null?(r=Mt(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.ttl=g})(l,e[2])),e===null&&(t=l),e}function Br(){var e,s,r,l,a;return l=t,a=t,i.substr(t,5).toLowerCase()==="maddr"?(e=i.substr(t,5),t+=5):(e=null,n('"maddr"')),e!==null?(s=Q(),s!==null?(r=Le(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.maddr=g})(l,e[2])),e===null&&(t=l),e}function Wr(){var e,s,r,l,a;return l=t,a=t,i.substr(t,8).toLowerCase()==="received"?(e=i.substr(t,8),t+=8):(e=null,n('"received"')),e!==null?(s=Q(),s!==null?(r=Fe(),r===null&&(r=vt()),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.received=g})(l,e[2])),e===null&&(t=l),e}function Vr(){var e,s,r,l,a;return l=t,a=t,i.substr(t,6).toLowerCase()==="branch"?(e=i.substr(t,6),t+=6):(e=null,n('"branch"')),e!==null?(s=Q(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.branch=g})(l,e[2])),e===null&&(t=l),e}function zr(){var e,s,r,l,a;return l=t,i.substr(t,5).toLowerCase()==="rport"?(e=i.substr(t,5),t+=5):(e=null,n('"rport"')),e!==null?(a=t,s=Q(),s!==null?(r=Kr(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e}function Kr(){var e,s,r,l,a,u,g;return u=t,g=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(l=c(),l=l!==null?l:"",l!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,l,a]:(e=null,t=g)):(e=null,t=g)):(e=null,t=g)):(e=null,t=g)):(e=null,t=g),e!==null&&(e=(function(P,k){x.rport=parseInt(k.join(""))})(u,e)),e===null&&(t=u),e}function Yr(){var e,s,r,l,a,u;return u=t,e=Jr(),e!==null?(s=_e(),s!==null?(r=B(),r!==null?(l=_e(),l!==null?(a=Xr(),a!==null?e=[e,s,r,l,a]:(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u)):(e=null,t=u),e}function Jr(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="sip"?(e=i.substr(t,3),t+=3):(e=null,n('"SIP"')),e===null&&(e=B()),e!==null&&(e=(function(r,l){x.protocol=l})(s,e)),e===null&&(t=s),e}function Xr(){var e,s;return s=t,i.substr(t,3).toLowerCase()==="udp"?(e=i.substr(t,3),t+=3):(e=null,n('"UDP"')),e===null&&(i.substr(t,3).toLowerCase()==="tcp"?(e=i.substr(t,3),t+=3):(e=null,n('"TCP"')),e===null&&(i.substr(t,3).toLowerCase()==="tls"?(e=i.substr(t,3),t+=3):(e=null,n('"TLS"')),e===null&&(i.substr(t,4).toLowerCase()==="sctp"?(e=i.substr(t,4),t+=4):(e=null,n('"SCTP"')),e===null&&(e=B())))),e!==null&&(e=(function(r,l){x.transport=l})(s,e)),e===null&&(t=s),e}function Qr(){var e,s,r,l,a;return l=t,e=Zr(),e!==null?(a=t,s=Oe(),s!==null?(r=en(),r!==null?s=[s,r]:(s=null,t=a)):(s=null,t=a),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=l)):(e=null,t=l),e}function Zr(){var e,s;return s=t,e=Fe(),e===null&&(e=Ct(),e===null&&(e=gt())),e!==null&&(e=(function(r){x.host=i.substring(t,r)})(s)),e===null&&(t=s),e}function en(){var e,s,r,l,a,u,g;return u=t,g=t,e=c(),e=e!==null?e:"",e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?(l=c(),l=l!==null?l:"",l!==null?(a=c(),a=a!==null?a:"",a!==null?e=[e,s,r,l,a]:(e=null,t=g)):(e=null,t=g)):(e=null,t=g)):(e=null,t=g)):(e=null,t=g),e!==null&&(e=(function(P,k){x.port=parseInt(k.join(""))})(u,e)),e===null&&(t=u),e}function Mt(){var e,s,r,l,a;return l=t,a=t,e=c(),e!==null?(s=c(),s=s!==null?s:"",s!==null?(r=c(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){return parseInt(g.join(""))})(l,e)),e===null&&(t=l),e}function Ll(){var e;return e=Nt(),e}function Fl(){var e,s,r,l,a,u;if(a=t,e=tn(),e!==null){for(s=[],u=t,r=J(),r!==null?(l=Lt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=J(),r!==null?(l=Lt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function tn(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,l){x.expires=l})(s,e)),e===null&&(t=s),e}function Lt(){var e;return e=sn(),e===null&&(e=ae()),e}function sn(){var e,s,r,l,a;return l=t,a=t,i.substr(t,9).toLowerCase()==="refresher"?(e=i.substr(t,9),t+=9):(e=null,n('"refresher"')),e!==null?(s=Q(),s!==null?(i.substr(t,3).toLowerCase()==="uac"?(r=i.substr(t,3),t+=3):(r=null,n('"uac"')),r===null&&(i.substr(t,3).toLowerCase()==="uas"?(r=i.substr(t,3),t+=3):(r=null,n('"uas"'))),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.refresher=g.toLowerCase()})(l,e[2])),e===null&&(t=l),e}function Hl(){var e,s,r,l;return l=t,e=B(),e!==null?(s=O(),s!==null?(r=rn(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function rn(){var e,s;for(e=[],s=w(),s===null&&(s=M(),s===null&&(s=p()));s!==null;)e.push(s),s=w(),s===null&&(s=M(),s===null&&(s=p()));return e}function $l(){var e,s;for(e=[],s=N();s!==null;)e.push(s),s=N();return e}function kl(){var e,s,r;return r=t,i.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,n('"uuid:"')),e!==null?(s=nn(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function nn(){var e,s,r,l,a,u,g,P,k,W,se;return W=t,se=t,e=ln(),e!==null?(i.charCodeAt(t)===45?(s="-",t++):(s=null,n('"-"')),s!==null?(r=Ee(),r!==null?(i.charCodeAt(t)===45?(l="-",t++):(l=null,n('"-"')),l!==null?(a=Ee(),a!==null?(i.charCodeAt(t)===45?(u="-",t++):(u=null,n('"-"')),u!==null?(g=Ee(),g!==null?(i.charCodeAt(t)===45?(P="-",t++):(P=null,n('"-"')),P!==null?(k=an(),k!==null?e=[e,s,r,l,a,u,g,P,k]:(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se)):(e=null,t=se),e!==null&&(e=(function(Te,ut){x=i.substring(t+5,Te)})(W,e[0])),e===null&&(t=W),e}function Ee(){var e,s,r,l,a;return a=t,e=D(),e!==null?(s=D(),s!==null?(r=D(),r!==null?(l=D(),l!==null?e=[e,s,r,l]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e}function ln(){var e,s,r;return r=t,e=Ee(),e!==null?(s=Ee(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function an(){var e,s,r,l;return l=t,e=Ee(),e!==null?(s=Ee(),s!==null?(r=Ee(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function ql(){var e,s,r,l,a,u,g;if(a=t,u=t,e=te(),e===null&&(e=De()),e!==null){for(s=[],g=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);r!==null;)s.push(r),g=t,r=J(),r!==null?(l=ae(),l!==null?r=[r,l]:(r=null,t=g)):(r=null,t=g);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(P){try{x=new Pe(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=a),e}function jl(){var e,s,r,l,a,u;if(a=t,e=on(),e!==null){for(s=[],u=t,r=J(),r!==null?(l=Ft(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=J(),r!==null?(l=Ft(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);s!==null?e=[e,s]:(e=null,t=a)}else e=null,t=a;return e}function on(){var e,s,r,l,a,u;return l=t,a=t,e=he(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,n('"@"')),s!==null?(r=he(),r!==null?s=[s,r]:(s=null,t=u)):(s=null,t=u),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(g){x.call_id=i.substring(t,g)})(l)),e===null&&(t=l),e}function Ft(){var e;return e=un(),e===null&&(e=cn(),e===null&&(e=fn(),e===null&&(e=ae()))),e}function un(){var e,s,r,l,a;return l=t,a=t,i.substr(t,6)==="to-tag"?(e="to-tag",t+=6):(e=null,n('"to-tag"')),e!==null?(s=Q(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.to_tag=g})(l,e[2])),e===null&&(t=l),e}function cn(){var e,s,r,l,a;return l=t,a=t,i.substr(t,8)==="from-tag"?(e="from-tag",t+=8):(e=null,n('"from-tag"')),e!==null?(s=Q(),s!==null?(r=B(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,g){x.from_tag=g})(l,e[2])),e===null&&(t=l),e}function fn(){var e,s;return s=t,i.substr(t,10)==="early-only"?(e="early-only",t+=10):(e=null,n('"early-only"')),e!==null&&(e=(function(r){x.early_only=!0})()),e===null&&(t=s),e}function Gl(e){e.sort();for(var s=null,r=[],l=0;l<e.length;l++)e[l]!==s&&(r.push(e[l]),s=e[l]);return r}function Bl(){for(var e=1,s=1,r=!1,l=0;l<Math.max(t,d);l++){var a=i.charAt(l);a===`
4
+ `?(r||e++,s=1,r=!1):a==="\r"||a==="\u2028"||a==="\u2029"?(e++,s=1,r=!0):(s++,r=!1)}return{line:e,column:s}}var hn=ye(),Pe=As(),x={},Wl=S[_]();if(Wl===null||t!==i.length){var Ht=Math.max(t,d),Vl=Ht<i.length?i.charAt(Ht):null,dn=Bl();return new this.SyntaxError(Gl(h),Vl,Ht,dn.line,dn.column),-1}return x},toSource:function(){return this._source}};return y.SyntaxError=function(i,_,S,t,d){function h(n,m){var c,R;switch(n.length){case 0:c="end of input";break;case 1:c=n[0];break;default:c=n.slice(0,n.length-1).join(", ")+" or "+n[n.length-1]}return R=m?b(m):"end of input","Expected "+c+" but "+R+" found."}this.name="SyntaxError",this.expected=i,this.found=_,this.message=h(i,_),this.offset=S,this.line=t,this.column=d},y.SyntaxError.prototype=Error.prototype,y})()),Gt}var Bt,Tn;function ye(){if(Tn)return Bt;Tn=1;const b=oe(),y=fe(),i=Ce();return Bt=class tl{static parse(S){if(S=i.parse(S,"SIP_URI"),S!==-1)return S}constructor(S,t,d,h,n={},m={}){if(!d)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=S||b.SIP,this._user=t,this._host=d,this._port=h;for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&this.setParam(c,n[c]);for(const c in m)Object.prototype.hasOwnProperty.call(m,c)&&this.setHeader(c,m[c])}get scheme(){return this._scheme}set scheme(S){this._scheme=S.toLowerCase()}get user(){return this._user}set user(S){this._user=S}get host(){return this._host}set host(S){this._host=S.toLowerCase()}get port(){return this._port}set port(S){this._port=S===0?S:parseInt(S,10)||null}setParam(S,t){S&&(this._parameters[S.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(S){if(S)return this._parameters[S.toLowerCase()]}hasParam(S){if(S)return this._parameters.hasOwnProperty(S.toLowerCase())&&!0||!1}deleteParam(S){if(S=S.toLowerCase(),this._parameters.hasOwnProperty(S)){const t=this._parameters[S];return delete this._parameters[S],t}}clearParams(){this._parameters={}}setHeader(S,t){this._headers[y.headerize(S)]=Array.isArray(t)?t:[t]}getHeader(S){if(S)return this._headers[y.headerize(S)]}hasHeader(S){if(S)return this._headers.hasOwnProperty(y.headerize(S))&&!0||!1}deleteHeader(S){if(S=y.headerize(S),this._headers.hasOwnProperty(S)){const t=this._headers[S];return delete this._headers[S],t}}clearHeaders(){this._headers={}}clone(){return new tl(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const S=[];let t=`${this._scheme}:`;this._user&&(t+=`${y.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 h of this._headers[d])S.push(`${d}=${h}`);return S.length>0&&(t+=`?${S.join("&")}`),t}toAor(S){let t=`${this._scheme}:`;return this._user&&(t+=`${y.escapeUser(this._user)}@`),t+=this._host,S&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},Bt}var Cn;function fe(){if(Cn)return ie;Cn=1;const b=oe(),y=ye(),i=Ce();ie.str_utf8_length=d=>unescape(encodeURIComponent(d)).length;const _=ie.isFunction=d=>d!==void 0?Object.prototype.toString.call(d)==="[object Function]":!1;ie.isString=d=>d!==void 0?Object.prototype.toString.call(d)==="[object String]":!1,ie.isDecimal=d=>!isNaN(d)&&parseFloat(d)===parseInt(d,10),ie.isEmpty=d=>d===null||d===""||d===void 0||Array.isArray(d)&&d.length===0||typeof d=="number"&&isNaN(d),ie.hasMethods=function(d,...h){for(const n of h)if(_(d[n]))return!1;return!0};const S=ie.createRandomToken=(d,h=32)=>{let n,m,c="";for(n=0;n<d;n++)m=Math.random()*h|0,c+=m.toString(h);return c};ie.newTag=()=>S(10),ie.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,h=>{const n=Math.random()*16|0;return(h==="x"?n:n&3|8).toString(16)}),ie.hostType=d=>{if(d){if(d=i.parse(d,"host"),d!==-1)return d.host_type}else return};const t=ie.escapeUser=d=>encodeURIComponent(decodeURIComponent(d)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return ie.normalizeTarget=(d,h)=>{if(d){if(d instanceof y)return d;if(typeof d=="string"){const n=d.split("@");let m,c;switch(n.length){case 1:if(!h)return;m=d,c=h;break;case 2:m=n[0],c=n[1];break;default:m=n.slice(0,n.length-1).join("@"),c=n[n.length-1]}m=m.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(m)&&(m=m.replace(/[-.()]/g,"")),d=`${b.SIP}:${t(m)}@${c}`;let R;return(R=y.parse(d))?R:void 0}else return}else return},ie.headerize=d=>{const h={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},n=d.toLowerCase().replace(/_/g,"-").split("-");let m="";const c=n.length;let R;for(R=0;R<c;R++)R!==0&&(m+="-"),m+=n[R].charAt(0).toUpperCase()+n[R].substring(1);return h[m]&&(m=h[m]),m},ie.sipErrorCause=d=>{for(const h in b.SIP_ERROR_CAUSES)if(b.SIP_ERROR_CAUSES[h].indexOf(d)!==-1)return b.causes[h];return b.causes.SIP_FAILURE_CODE},ie.getRandomTestNetIP=()=>{function d(h,n){return Math.floor(Math.random()*(n-h+1)+h)}return`192.0.2.${d(1,254)}`},ie.calculateMD5=d=>{function h(z,V){return z<<V|z>>>32-V}function n(z,V){const K=z&2147483648,Z=V&2147483648,ne=z&1073741824,le=V&1073741824,te=(z&1073741823)+(V&1073741823);return ne&le?te^2147483648^K^Z:ne|le?te&1073741824?te^3221225472^K^Z:te^1073741824^K^Z:te^K^Z}function m(z,V,K){return z&V|~z&K}function c(z,V,K){return z&K|V&~K}function R(z,V,K){return z^V^K}function D(z,V,K){return V^(z|~K)}function E(z,V,K,Z,ne,le,te){return z=n(z,n(n(m(V,K,Z),ne),te)),n(h(z,le),V)}function N(z,V,K,Z,ne,le,te){return z=n(z,n(n(c(V,K,Z),ne),te)),n(h(z,le),V)}function $(z,V,K,Z,ne,le,te){return z=n(z,n(n(R(V,K,Z),ne),te)),n(h(z,le),V)}function C(z,V,K,Z,ne,le,te){return z=n(z,n(n(D(V,K,Z),ne),te)),n(h(z,le),V)}function I(z){let V;const K=z.length,Z=K+8,le=((Z-Z%64)/64+1)*16,te=new Array(le-1);let ve=0,pe=0;for(;pe<K;)V=(pe-pe%4)/4,ve=pe%4*8,te[V]=te[V]|z.charCodeAt(pe)<<ve,pe++;return V=(pe-pe%4)/4,ve=pe%4*8,te[V]=te[V]|128<<ve,te[le-2]=K<<3,te[le-1]=K>>>29,te}function F(z){let V="",K="",Z,ne;for(ne=0;ne<=3;ne++)Z=z>>>ne*8&255,K=`0${Z.toString(16)}`,V=V+K.substr(K.length-2,2);return V}function H(z){let V="";for(let K=0;K<z.length;K++){const Z=z.charCodeAt(K);Z<128?V+=String.fromCharCode(Z):Z>127&&Z<2048?(V+=String.fromCharCode(Z>>6|192),V+=String.fromCharCode(Z&63|128)):(V+=String.fromCharCode(Z>>12|224),V+=String.fromCharCode(Z>>6&63|128),V+=String.fromCharCode(Z&63|128))}return V}let o=[],f,T,p,A,O,v,w,U,M;const Y=7,B=12,ue=17,de=22,he=5,X=9,_e=14,Q=20,xe=4,Ne=11,Ae=16,Re=23,ee=6,J=10,Oe=15,be=21;for(d=H(d),o=I(d),v=1732584193,w=4023233417,U=2562383102,M=271733878,f=0;f<o.length;f+=16)T=v,p=w,A=U,O=M,v=E(v,w,U,M,o[f+0],Y,3614090360),M=E(M,v,w,U,o[f+1],B,3905402710),U=E(U,M,v,w,o[f+2],ue,606105819),w=E(w,U,M,v,o[f+3],de,3250441966),v=E(v,w,U,M,o[f+4],Y,4118548399),M=E(M,v,w,U,o[f+5],B,1200080426),U=E(U,M,v,w,o[f+6],ue,2821735955),w=E(w,U,M,v,o[f+7],de,4249261313),v=E(v,w,U,M,o[f+8],Y,1770035416),M=E(M,v,w,U,o[f+9],B,2336552879),U=E(U,M,v,w,o[f+10],ue,4294925233),w=E(w,U,M,v,o[f+11],de,2304563134),v=E(v,w,U,M,o[f+12],Y,1804603682),M=E(M,v,w,U,o[f+13],B,4254626195),U=E(U,M,v,w,o[f+14],ue,2792965006),w=E(w,U,M,v,o[f+15],de,1236535329),v=N(v,w,U,M,o[f+1],he,4129170786),M=N(M,v,w,U,o[f+6],X,3225465664),U=N(U,M,v,w,o[f+11],_e,643717713),w=N(w,U,M,v,o[f+0],Q,3921069994),v=N(v,w,U,M,o[f+5],he,3593408605),M=N(M,v,w,U,o[f+10],X,38016083),U=N(U,M,v,w,o[f+15],_e,3634488961),w=N(w,U,M,v,o[f+4],Q,3889429448),v=N(v,w,U,M,o[f+9],he,568446438),M=N(M,v,w,U,o[f+14],X,3275163606),U=N(U,M,v,w,o[f+3],_e,4107603335),w=N(w,U,M,v,o[f+8],Q,1163531501),v=N(v,w,U,M,o[f+13],he,2850285829),M=N(M,v,w,U,o[f+2],X,4243563512),U=N(U,M,v,w,o[f+7],_e,1735328473),w=N(w,U,M,v,o[f+12],Q,2368359562),v=$(v,w,U,M,o[f+5],xe,4294588738),M=$(M,v,w,U,o[f+8],Ne,2272392833),U=$(U,M,v,w,o[f+11],Ae,1839030562),w=$(w,U,M,v,o[f+14],Re,4259657740),v=$(v,w,U,M,o[f+1],xe,2763975236),M=$(M,v,w,U,o[f+4],Ne,1272893353),U=$(U,M,v,w,o[f+7],Ae,4139469664),w=$(w,U,M,v,o[f+10],Re,3200236656),v=$(v,w,U,M,o[f+13],xe,681279174),M=$(M,v,w,U,o[f+0],Ne,3936430074),U=$(U,M,v,w,o[f+3],Ae,3572445317),w=$(w,U,M,v,o[f+6],Re,76029189),v=$(v,w,U,M,o[f+9],xe,3654602809),M=$(M,v,w,U,o[f+12],Ne,3873151461),U=$(U,M,v,w,o[f+15],Ae,530742520),w=$(w,U,M,v,o[f+2],Re,3299628645),v=C(v,w,U,M,o[f+0],ee,4096336452),M=C(M,v,w,U,o[f+7],J,1126891415),U=C(U,M,v,w,o[f+14],Oe,2878612391),w=C(w,U,M,v,o[f+5],be,4237533241),v=C(v,w,U,M,o[f+12],ee,1700485571),M=C(M,v,w,U,o[f+3],J,2399980690),U=C(U,M,v,w,o[f+10],Oe,4293915773),w=C(w,U,M,v,o[f+1],be,2240044497),v=C(v,w,U,M,o[f+8],ee,1873313359),M=C(M,v,w,U,o[f+15],J,4264355552),U=C(U,M,v,w,o[f+6],Oe,2734768916),w=C(w,U,M,v,o[f+13],be,1309151649),v=C(v,w,U,M,o[f+4],ee,4149444226),M=C(M,v,w,U,o[f+11],J,3174756917),U=C(U,M,v,w,o[f+2],Oe,718787259),w=C(w,U,M,v,o[f+9],be,3951481745),v=n(v,T),w=n(w,p),U=n(U,A),M=n(M,O);return(F(v)+F(w)+F(U)+F(M)).toLowerCase()},ie.closeMediaStream=d=>{if(d)try{let h;if(d.getTracks){h=d.getTracks();for(const n of h)n.stop()}else{h=d.getAudioTracks();for(const n of h)n.stop();h=d.getVideoTracks();for(const n of h)n.stop()}}catch{(typeof d.stop=="function"||typeof d.stop=="object")&&d.stop()}},ie.cloneArray=d=>d&&d.slice()||[],ie.cloneObject=(d,h={})=>d&&Object.assign({},d)||h,ie}var ct={exports:{}},vn;function Ie(){if(vn)return ct.exports;vn=1;var b=typeof Reflect=="object"?Reflect:null,y=b&&typeof b.apply=="function"?b.apply:function(f,T,p){return Function.prototype.apply.call(f,T,p)},i;b&&typeof b.ownKeys=="function"?i=b.ownKeys:Object.getOwnPropertySymbols?i=function(f){return Object.getOwnPropertyNames(f).concat(Object.getOwnPropertySymbols(f))}:i=function(f){return Object.getOwnPropertyNames(f)};function _(o){console&&console.warn&&console.warn(o)}var S=Number.isNaN||function(f){return f!==f};function t(){t.init.call(this)}ct.exports=t,ct.exports.once=I,t.EventEmitter=t,t.prototype._events=void 0,t.prototype._eventsCount=0,t.prototype._maxListeners=void 0;var d=10;function h(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(t,"defaultMaxListeners",{enumerable:!0,get:function(){return d},set:function(o){if(typeof o!="number"||o<0||S(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");d=o}}),t.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},t.prototype.setMaxListeners=function(f){if(typeof f!="number"||f<0||S(f))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+f+".");return this._maxListeners=f,this};function n(o){return o._maxListeners===void 0?t.defaultMaxListeners:o._maxListeners}t.prototype.getMaxListeners=function(){return n(this)},t.prototype.emit=function(f){for(var T=[],p=1;p<arguments.length;p++)T.push(arguments[p]);var A=f==="error",O=this._events;if(O!==void 0)A=A&&O.error===void 0;else if(!A)return!1;if(A){var v;if(T.length>0&&(v=T[0]),v instanceof Error)throw v;var w=new Error("Unhandled error."+(v?" ("+v.message+")":""));throw w.context=v,w}var U=O[f];if(U===void 0)return!1;if(typeof U=="function")y(U,this,T);else for(var M=U.length,Y=N(U,M),p=0;p<M;++p)y(Y[p],this,T);return!0};function m(o,f,T,p){var A,O,v;if(h(T),O=o._events,O===void 0?(O=o._events=Object.create(null),o._eventsCount=0):(O.newListener!==void 0&&(o.emit("newListener",f,T.listener?T.listener:T),O=o._events),v=O[f]),v===void 0)v=O[f]=T,++o._eventsCount;else if(typeof v=="function"?v=O[f]=p?[T,v]:[v,T]:p?v.unshift(T):v.push(T),A=n(o),A>0&&v.length>A&&!v.warned){v.warned=!0;var w=new Error("Possible EventEmitter memory leak detected. "+v.length+" "+String(f)+" listeners added. Use emitter.setMaxListeners() to increase limit");w.name="MaxListenersExceededWarning",w.emitter=o,w.type=f,w.count=v.length,_(w)}return o}t.prototype.addListener=function(f,T){return m(this,f,T,!1)},t.prototype.on=t.prototype.addListener,t.prototype.prependListener=function(f,T){return m(this,f,T,!0)};function c(){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 R(o,f,T){var p={fired:!1,wrapFn:void 0,target:o,type:f,listener:T},A=c.bind(p);return A.listener=T,p.wrapFn=A,A}t.prototype.once=function(f,T){return h(T),this.on(f,R(this,f,T)),this},t.prototype.prependOnceListener=function(f,T){return h(T),this.prependListener(f,R(this,f,T)),this},t.prototype.removeListener=function(f,T){var p,A,O,v,w;if(h(T),A=this._events,A===void 0)return this;if(p=A[f],p===void 0)return this;if(p===T||p.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete A[f],A.removeListener&&this.emit("removeListener",f,p.listener||T));else if(typeof p!="function"){for(O=-1,v=p.length-1;v>=0;v--)if(p[v]===T||p[v].listener===T){w=p[v].listener,O=v;break}if(O<0)return this;O===0?p.shift():$(p,O),p.length===1&&(A[f]=p[0]),A.removeListener!==void 0&&this.emit("removeListener",f,w||T)}return this},t.prototype.off=t.prototype.removeListener,t.prototype.removeAllListeners=function(f){var T,p,A;if(p=this._events,p===void 0)return this;if(p.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):p[f]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete p[f]),this;if(arguments.length===0){var O=Object.keys(p),v;for(A=0;A<O.length;++A)v=O[A],v!=="removeListener"&&this.removeAllListeners(v);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=p[f],typeof T=="function")this.removeListener(f,T);else if(T!==void 0)for(A=T.length-1;A>=0;A--)this.removeListener(f,T[A]);return this};function D(o,f,T){var p=o._events;if(p===void 0)return[];var A=p[f];return A===void 0?[]:typeof A=="function"?T?[A.listener||A]:[A]:T?C(A):N(A,A.length)}t.prototype.listeners=function(f){return D(this,f,!0)},t.prototype.rawListeners=function(f){return D(this,f,!1)},t.listenerCount=function(o,f){return typeof o.listenerCount=="function"?o.listenerCount(f):E.call(o,f)},t.prototype.listenerCount=E;function E(o){var f=this._events;if(f!==void 0){var T=f[o];if(typeof T=="function")return 1;if(T!==void 0)return T.length}return 0}t.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function N(o,f){for(var T=new Array(f),p=0;p<f;++p)T[p]=o[p];return T}function $(o,f){for(;f+1<o.length;f++)o[f]=o[f+1];o.pop()}function C(o){for(var f=new Array(o.length),T=0;T<f.length;++T)f[T]=o[T].listener||o[T];return f}function I(o,f){return new Promise(function(T,p){function A(v){o.removeListener(f,O),p(v)}function O(){typeof o.removeListener=="function"&&o.removeListener("error",A),T([].slice.call(arguments))}H(o,f,O,{once:!0}),f!=="error"&&F(o,A,{once:!0})})}function F(o,f,T){typeof o.on=="function"&&H(o,"error",f,T)}function H(o,f,T,p){if(typeof o.on=="function")p.once?o.once(f,T):o.on(f,T);else if(typeof o.addEventListener=="function")o.addEventListener(f,function A(O){p.once&&o.removeEventListener(f,A),T(O)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}return ct.exports}var ft={exports:{}},Wt,En;function Ql(){if(En)return Wt;En=1;var b=1e3,y=b*60,i=y*60,_=i*24,S=_*7,t=_*365.25;Wt=function(c,R){R=R||{};var D=typeof c;if(D==="string"&&c.length>0)return d(c);if(D==="number"&&isFinite(c))return R.long?n(c):h(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))};function d(c){if(c=String(c),!(c.length>100)){var R=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(R){var D=parseFloat(R[1]),E=(R[2]||"ms").toLowerCase();switch(E){case"years":case"year":case"yrs":case"yr":case"y":return D*t;case"weeks":case"week":case"w":return D*S;case"days":case"day":case"d":return D*_;case"hours":case"hour":case"hrs":case"hr":case"h":return D*i;case"minutes":case"minute":case"mins":case"min":case"m":return D*y;case"seconds":case"second":case"secs":case"sec":case"s":return D*b;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function h(c){var R=Math.abs(c);return R>=_?Math.round(c/_)+"d":R>=i?Math.round(c/i)+"h":R>=y?Math.round(c/y)+"m":R>=b?Math.round(c/b)+"s":c+"ms"}function n(c){var R=Math.abs(c);return R>=_?m(c,R,_,"day"):R>=i?m(c,R,i,"hour"):R>=y?m(c,R,y,"minute"):R>=b?m(c,R,b,"second"):c+" ms"}function m(c,R,D,E){var N=R>=D*1.5;return Math.round(c/D)+" "+E+(N?"s":"")}return Wt}var Vt,Sn;function Zl(){if(Sn)return Vt;Sn=1;function b(y){_.debug=_,_.default=_,_.coerce=m,_.disable=h,_.enable=t,_.enabled=n,_.humanize=Ql(),_.destroy=c,Object.keys(y).forEach(R=>{_[R]=y[R]}),_.names=[],_.skips=[],_.formatters={};function i(R){let D=0;for(let E=0;E<R.length;E++)D=(D<<5)-D+R.charCodeAt(E),D|=0;return _.colors[Math.abs(D)%_.colors.length]}_.selectColor=i;function _(R){let D,E=null,N,$;function C(...I){if(!C.enabled)return;const F=C,H=Number(new Date),o=H-(D||H);F.diff=o,F.prev=D,F.curr=H,D=H,I[0]=_.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let f=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(p,A)=>{if(p==="%%")return"%";f++;const O=_.formatters[A];if(typeof O=="function"){const v=I[f];p=O.call(F,v),I.splice(f,1),f--}return p}),_.formatArgs.call(F,I),(F.log||_.log).apply(F,I)}return C.namespace=R,C.useColors=_.useColors(),C.color=_.selectColor(R),C.extend=S,C.destroy=_.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(N!==_.namespaces&&(N=_.namespaces,$=_.enabled(R)),$),set:I=>{E=I}}),typeof _.init=="function"&&_.init(C),C}function S(R,D){const E=_(this.namespace+(typeof D>"u"?":":D)+R);return E.log=this.log,E}function t(R){_.save(R),_.namespaces=R,_.names=[],_.skips=[];const D=(typeof R=="string"?R:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const E of D)E[0]==="-"?_.skips.push(E.slice(1)):_.names.push(E)}function d(R,D){let E=0,N=0,$=-1,C=0;for(;E<R.length;)if(N<D.length&&(D[N]===R[E]||D[N]==="*"))D[N]==="*"?($=N,C=E,N++):(E++,N++);else if($!==-1)N=$+1,C++,E=C;else return!1;for(;N<D.length&&D[N]==="*";)N++;return N===D.length}function h(){const R=[..._.names,..._.skips.map(D=>"-"+D)].join(",");return _.enable(""),R}function n(R){for(const D of _.skips)if(d(R,D))return!1;for(const D of _.names)if(d(R,D))return!0;return!1}function m(R){return R instanceof Error?R.stack||R.message:R}function c(){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 _.enable(_.load()),_}return Vt=b,Vt}var An;function vs(){return An||(An=1,(function(b,y){y.formatArgs=_,y.save=S,y.load=t,y.useColors=i,y.storage=d(),y.destroy=(()=>{let n=!1;return()=>{n||(n=!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`."))}})(),y.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 i(){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 n;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&&(n=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(n[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function _(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+b.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;n.splice(1,0,m,"color: inherit");let c=0,R=0;n[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(c++,D==="%c"&&(R=c))}),n.splice(R,0,m)}y.log=console.debug||console.log||(()=>{});function S(n){try{n?y.storage.setItem("debug",n):y.storage.removeItem("debug")}catch{}}function t(){let n;try{n=y.storage.getItem("debug")||y.storage.getItem("DEBUG")}catch{}return!n&&typeof process<"u"&&"env"in process&&(n=process.env.DEBUG),n}function d(){try{return localStorage}catch{}}b.exports=Zl()(y);const{formatters:h}=b.exports;h.j=function(n){try{return JSON.stringify(n)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}})(ft,ft.exports)),ft.exports}var zt,Rn;function ce(){if(Rn)return zt;Rn=1;const b=vs(),y="JsSIP";return zt=class{constructor(_){_?(this._debug=b.default(`${y}:${_}`),this._warn=b.default(`${y}:WARN:${_}`),this._error=b.default(`${y}:ERROR:${_}`)):(this._debug=b.default(y),this._warn=b.default(`${y}:WARN`),this._error=b.default(`${y}: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}},zt}var ge={},Kt={},Yt={exports:{}},bn;function Rs(){if(bn)return Yt.exports;bn=1;var b=Yt.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(y){return y.encoding?"rtpmap:%d %s/%s/%s":y.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(y){return y.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(y){return y.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(y){return"extmap:%d"+(y.direction?"/%s":"%v")+(y["encrypt-uri"]?" %s":"%v")+" %s"+(y.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(y){return y.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(y){var i="candidate:%s %d %s %d %s %d typ %s";return i+=y.raddr!=null?" raddr %s rport %d":"%v%v",i+=y.tcptype!=null?" tcptype %s":"%v",y.generation!=null&&(i+=" generation %d"),i+=y["network-id"]!=null?" network-id %d":"%v",i+=y["network-cost"]!=null?" network-cost %d":"%v",i}},{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(y){var i="ssrc:%d";return y.attribute!=null&&(i+=" %s",y.value!=null&&(i+=":%s")),i}},{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(y){return y.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(y){return y.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(y){return"imageattr:%s %s %s"+(y.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(y){return"simulcast:%s %s"+(y.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(y){return"ts-refclk:%s"+(y.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(y){var i="mediaclk:";return i+=y.id!=null?"id=%s %s":"%v%s",i+=y.mediaClockValue!=null?"=%s":"",i+=y.rateNumerator!=null?" rate=%s":"",i+=y.rateDenominator!=null?"/%s":"",i}},{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"]}]};return Object.keys(b).forEach(function(y){var i=b[y];i.forEach(function(_){_.reg||(_.reg=/(.*)/),_.format||(_.format="%s")})}),Yt.exports}var wn;function ei(){return wn||(wn=1,(function(b){var y=function(h){return String(Number(h))===h?Number(h):h},i=function(h,n,m,c){if(c&&!m)n[c]=y(h[1]);else for(var R=0;R<m.length;R+=1)h[R+1]!=null&&(n[m[R]]=y(h[R+1]))},_=function(h,n,m){var c=h.name&&h.names;h.push&&!n[h.push]?n[h.push]=[]:c&&!n[h.name]&&(n[h.name]={});var R=h.push?{}:c?n[h.name]:n;i(m.match(h.reg),R,h.names,h.name),h.push&&n[h.push].push(R)},S=Rs(),t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);b.parse=function(h){var n={},m=[],c=n;return h.split(/(\r\n|\r|\n)/).filter(t).forEach(function(R){var D=R[0],E=R.slice(2);D==="m"&&(m.push({rtp:[],fmtp:[]}),c=m[m.length-1]);for(var N=0;N<(S[D]||[]).length;N+=1){var $=S[D][N];if($.reg.test(E))return _($,c,E)}}),n.media=m,n};var d=function(h,n){var m=n.split(/=(.+)/,2);return m.length===2?h[m[0]]=y(m[1]):m.length===1&&n.length>1&&(h[m[0]]=void 0),h};b.parseParams=function(h){return h.split(/;\s?/).reduce(d,{})},b.parseFmtpConfig=b.parseParams,b.parsePayloads=function(h){return h.toString().split(" ").map(Number)},b.parseRemoteCandidates=function(h){for(var n=[],m=h.split(" ").map(y),c=0;c<m.length;c+=3)n.push({component:m[c],ip:m[c+1],port:m[c+2]});return n},b.parseImageAttributes=function(h){return h.split(" ").map(function(n){return n.substring(1,n.length-1).split(",").reduce(d,{})})},b.parseSimulcastStreamList=function(h){return h.split(";").map(function(n){return n.split(",").map(function(m){var c,R=!1;return m[0]!=="~"?c=y(m):(c=y(m.substring(1,m.length)),R=!0),{scid:c,paused:R}})})}})(Kt)),Kt}var Jt,yn;function ti(){if(yn)return Jt;yn=1;var b=Rs(),y=/%[sdv%]/g,i=function(d){var h=1,n=arguments,m=n.length;return d.replace(y,function(c){if(h>=m)return c;var R=n[h];switch(h+=1,c){case"%%":return"%";case"%s":return String(R);case"%d":return Number(R);case"%v":return""}})},_=function(d,h,n){var m=h.format instanceof Function?h.format(h.push?n:n[h.name]):h.format,c=[d+"="+m];if(h.names)for(var R=0;R<h.names.length;R+=1){var D=h.names[R];h.name?c.push(n[h.name][D]):c.push(n[h.names[R]])}else c.push(n[h.name]);return i.apply(null,c)},S=["v","o","s","i","u","e","p","c","b","t","r","z","a"],t=["i","c","b","a"];return Jt=function(d,h){h=h||{},d.version==null&&(d.version=0),d.name==null&&(d.name=" "),d.media.forEach(function(R){R.payloads==null&&(R.payloads="")});var n=h.outerOrder||S,m=h.innerOrder||t,c=[];return n.forEach(function(R){b[R].forEach(function(D){D.name in d&&d[D.name]!=null?c.push(_(R,D,d)):D.push in d&&d[D.push]!=null&&d[D.push].forEach(function(E){c.push(_(R,D,E))})})}),d.media.forEach(function(R){c.push(_("m",b.m[0],R)),m.forEach(function(D){b[D].forEach(function(E){E.name in R&&R[E.name]!=null?c.push(_(D,E,R)):E.push in R&&R[E.push]!=null&&R[E.push].forEach(function(N){c.push(_(D,E,N))})})})}),c.join(`\r
5
5
  `)+`\r
6
- `},Jt}var yn;function tl(){if(yn)return ge;yn=1;var w=Zl(),I=ei(),i=As();return ge.grammar=i,ge.write=I,ge.parse=w.parse,ge.parseParams=w.parseParams,ge.parseFmtpConfig=w.parseFmtpConfig,ge.parsePayloads=w.parsePayloads,ge.parseRemoteCandidates=w.parseRemoteCandidates,ge.parseImageAttributes=w.parseImageAttributes,ge.parseSimulcastStreamList=w.parseSimulcastStreamList,ge}var Xt,In;function Se(){if(In)return Xt;In=1;const w=tl(),I=fe(),i=ce(),_=_e(),R=Ss(),t=Ce(),d=new I("SIPMessage");class h{constructor(v,N,$,C,y,F){if(!v||!N||!$)return null;C=C||{},this.ua=$,this.headers={},this.method=v,this.ruri=N,this.body=F,this.extraHeaders=_.cloneArray(y),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),C.route_set?this.setHeader("route",C.route_set):$.configuration.use_preloaded_route&&this.setHeader("route",`<${$.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",i.MAX_FORWARDS);const H=C.to_uri||N,o=C.to_tag?{tag:C.to_tag}:null,f=typeof C.to_display_name<"u"?C.to_display_name:null;this.to=new R(H,f,o),this.setHeader("to",this.to.toString());const T=C.from_uri||$.configuration.uri,p={tag:C.from_tag||_.newTag()};let S;typeof C.from_display_name<"u"?S=C.from_display_name:$.configuration.display_name?S=$.configuration.display_name:S=null,this.from=new R(T,S,p),this.setHeader("from",this.from.toString());const D=C.call_id||$.configuration.jssip_id+_.createRandomToken(15);this.call_id=D,this.setHeader("call-id",D);const E=C.cseq||Math.floor(Math.random()*1e4);this.cseq=E,this.setHeader("cseq",`${E} ${v}`)}setHeader(v,N){const $=new RegExp(`^\\s*${v}\\s*:`,"i");for(let C=0;C<this.extraHeaders.length;C++)$.test(this.extraHeaders[C])&&this.extraHeaders.splice(C,1);this.headers[_.headerize(v)]=Array.isArray(N)?N:[N]}getHeader(v){const N=this.headers[_.headerize(v)];if(N){if(N[0])return N[0]}else{const $=new RegExp(`^\\s*${v}\\s*:`,"i");for(const C of this.extraHeaders)if($.test(C))return C.substring(C.indexOf(":")+1).trim()}}getHeaders(v){const N=this.headers[_.headerize(v)],$=[];if(N){for(const C of N)$.push(C);return $}else{const C=new RegExp(`^\\s*${v}\\s*:`,"i");for(const y of this.extraHeaders)C.test(y)&&$.push(y.substring(y.indexOf(":")+1).trim());return $}}hasHeader(v){if(this.headers[_.headerize(v)])return!0;{const N=new RegExp(`^\\s*${v}\\s*:`,"i");for(const $ of this.extraHeaders)if(N.test($))return!0}return!1}parseSDP(v){return!v&&this.sdp?this.sdp:(this.sdp=w.parse(this.body||""),this.sdp)}toString(){let v=`${this.method} ${this.ruri} SIP/2.0\r
7
- `;for(const C in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,C))for(const y of this.headers[C])v+=`${C}: ${y}\r
8
- `;for(const C of this.extraHeaders)v+=`${C.trim()}\r
9
- `;const N=[];switch(this.method){case i.REGISTER:N.push("path","gruu");break;case i.INVITE:this.ua.configuration.session_timers&&N.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&N.push("gruu"),N.push("ice","replaces");break;case i.UPDATE:this.ua.configuration.session_timers&&N.push("timer"),N.push("ice");break}N.push("outbound");const $=this.ua.configuration.user_agent||i.USER_AGENT;if(v+=`Allow: ${i.ALLOWED_METHODS}\r
10
- `,v+=`Supported: ${N}\r
11
- `,v+=`User-Agent: ${$}\r
12
- `,this.body){const C=_.str_utf8_length(this.body);v+=`Content-Length: ${C}\r
6
+ `},Jt}var In;function sl(){if(In)return ge;In=1;var b=ei(),y=ti(),i=Rs();return ge.grammar=i,ge.write=y,ge.parse=b.parse,ge.parseParams=b.parseParams,ge.parseFmtpConfig=b.parseFmtpConfig,ge.parsePayloads=b.parsePayloads,ge.parseRemoteCandidates=b.parseRemoteCandidates,ge.parseImageAttributes=b.parseImageAttributes,ge.parseSimulcastStreamList=b.parseSimulcastStreamList,ge}var Xt,xn;function Se(){if(xn)return Xt;xn=1;const b=sl(),y=ce(),i=oe(),_=fe(),S=As(),t=Ce(),d=new y("SIPMessage");class h{constructor(E,N,$,C,I,F){if(!E||!N||!$)return null;C=C||{},this.ua=$,this.headers={},this.method=E,this.ruri=N,this.body=F,this.extraHeaders=_.cloneArray(I),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),C.route_set?this.setHeader("route",C.route_set):$.configuration.use_preloaded_route&&this.setHeader("route",`<${$.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",i.MAX_FORWARDS);const H=C.to_uri||N,o=C.to_tag?{tag:C.to_tag}:null,f=typeof C.to_display_name<"u"?C.to_display_name:null;this.to=new S(H,f,o),this.setHeader("to",this.to.toString());const T=C.from_uri||$.configuration.uri,p={tag:C.from_tag||_.newTag()};let A;typeof C.from_display_name<"u"?A=C.from_display_name:$.configuration.display_name?A=$.configuration.display_name:A=null,this.from=new S(T,A,p),this.setHeader("from",this.from.toString());const O=C.call_id||$.configuration.jssip_id+_.createRandomToken(15);this.call_id=O,this.setHeader("call-id",O);const v=C.cseq||Math.floor(Math.random()*1e4);this.cseq=v,this.setHeader("cseq",`${v} ${E}`)}setHeader(E,N){const $=new RegExp(`^\\s*${E}\\s*:`,"i");for(let C=0;C<this.extraHeaders.length;C++)$.test(this.extraHeaders[C])&&this.extraHeaders.splice(C,1);this.headers[_.headerize(E)]=Array.isArray(N)?N:[N]}getHeader(E){const N=this.headers[_.headerize(E)];if(N){if(N[0])return N[0]}else{const $=new RegExp(`^\\s*${E}\\s*:`,"i");for(const C of this.extraHeaders)if($.test(C))return C.substring(C.indexOf(":")+1).trim()}}getHeaders(E){const N=this.headers[_.headerize(E)],$=[];if(N){for(const C of N)$.push(C);return $}else{const C=new RegExp(`^\\s*${E}\\s*:`,"i");for(const I of this.extraHeaders)C.test(I)&&$.push(I.substring(I.indexOf(":")+1).trim());return $}}hasHeader(E){if(this.headers[_.headerize(E)])return!0;{const N=new RegExp(`^\\s*${E}\\s*:`,"i");for(const $ of this.extraHeaders)if(N.test($))return!0}return!1}parseSDP(E){return!E&&this.sdp?this.sdp:(this.sdp=b.parse(this.body||""),this.sdp)}toString(){let E=`${this.method} ${this.ruri} SIP/2.0\r
7
+ `;for(const C in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,C))for(const I of this.headers[C])E+=`${C}: ${I}\r
8
+ `;for(const C of this.extraHeaders)E+=`${C.trim()}\r
9
+ `;const N=[];switch(this.method){case i.REGISTER:N.push("path","gruu");break;case i.INVITE:this.ua.configuration.session_timers&&N.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&N.push("gruu"),N.push("ice","replaces");break;case i.UPDATE:this.ua.configuration.session_timers&&N.push("timer"),N.push("ice");break}N.push("outbound");const $=this.ua.configuration.user_agent||i.USER_AGENT;if(E+=`Allow: ${i.ALLOWED_METHODS}\r
10
+ `,E+=`Supported: ${N}\r
11
+ `,E+=`User-Agent: ${$}\r
12
+ `,this.body){const C=_.str_utf8_length(this.body);E+=`Content-Length: ${C}\r
13
13
  \r
14
- `,v+=this.body}else v+=`Content-Length: 0\r
14
+ `,E+=this.body}else E+=`Content-Length: 0\r
15
15
  \r
16
- `;return v}clone(){const v=new h(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){v.headers[N]=this.headers[N].slice()},this),v.body=this.body,v.extraHeaders=_.cloneArray(this.extraHeaders),v.to=this.to,v.from=this.from,v.call_id=this.call_id,v.cseq=this.cseq,v}}class l extends h{constructor(v,N,$,C,y){super(i.INVITE,v,N,$,C,y),this.transaction=null}cancel(v){this.transaction.cancel(v)}clone(){const v=new l(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){v.headers[N]=this.headers[N].slice()},this),v.body=this.body,v.extraHeaders=_.cloneArray(this.extraHeaders),v.to=this.to,v.from=this.from,v.call_id=this.call_id,v.cseq=this.cseq,v.transaction=this.transaction,v}}class g{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(v,N){const $={raw:N};v=_.headerize(v),this.headers[v]?this.headers[v].push($):this.headers[v]=[$]}getHeader(v){const N=this.headers[_.headerize(v)];if(N){if(N[0])return N[0].raw}else return}getHeaders(v){const N=this.headers[_.headerize(v)],$=[];if(!N)return[];for(const C of N)$.push(C.raw);return $}hasHeader(v){return!!this.headers[_.headerize(v)]}parseHeader(v,N=0){if(v=_.headerize(v),this.headers[v]){if(N>=this.headers[v].length){d.debug(`not so many "${v}" headers present`);return}}else{d.debug(`header "${v}" not present`);return}const $=this.headers[v][N],C=$.raw;if($.parsed)return $.parsed;const y=t.parse(C,v.replace(/-/g,"_"));if(y===-1){this.headers[v].splice(N,1),d.debug(`error parsing "${v}" header field with value "${C}"`);return}else return $.parsed=y,y}s(v,N){return this.parseHeader(v,N)}setHeader(v,N){const $={raw:N};this.headers[_.headerize(v)]=[$]}parseSDP(v){return!v&&this.sdp?this.sdp:(this.sdp=w.parse(this.body||""),this.sdp)}toString(){return this.data}}class c extends g{constructor(v){super(),this.ua=v,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(v,N,$,C,y,F){const H=[];let o=this.getHeader("To");if(v=v||null,N=N||null,!v||v<100||v>699)throw new TypeError(`Invalid status_code: ${v}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[v]||"",$=_.cloneArray($),this.ua.configuration.extra_headers&&($=$.concat(this.ua.configuration.extra_headers));let f=`SIP/2.0 ${v} ${N}\r
17
- `;if(this.method===i.INVITE&&v>100&&v<=200){const p=this.getHeaders("record-route");for(const S of p)f+=`Record-Route: ${S}\r
16
+ `;return E}clone(){const E=new h(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){E.headers[N]=this.headers[N].slice()},this),E.body=this.body,E.extraHeaders=_.cloneArray(this.extraHeaders),E.to=this.to,E.from=this.from,E.call_id=this.call_id,E.cseq=this.cseq,E}}class n extends h{constructor(E,N,$,C,I){super(i.INVITE,E,N,$,C,I),this.transaction=null}cancel(E){this.transaction.cancel(E)}clone(){const E=new n(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(N){E.headers[N]=this.headers[N].slice()},this),E.body=this.body,E.extraHeaders=_.cloneArray(this.extraHeaders),E.to=this.to,E.from=this.from,E.call_id=this.call_id,E.cseq=this.cseq,E.transaction=this.transaction,E}}class m{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(E,N){const $={raw:N};E=_.headerize(E),this.headers[E]?this.headers[E].push($):this.headers[E]=[$]}getHeader(E){const N=this.headers[_.headerize(E)];if(N){if(N[0])return N[0].raw}else return}getHeaders(E){const N=this.headers[_.headerize(E)],$=[];if(!N)return[];for(const C of N)$.push(C.raw);return $}hasHeader(E){return!!this.headers[_.headerize(E)]}parseHeader(E,N=0){if(E=_.headerize(E),this.headers[E]){if(N>=this.headers[E].length){d.debug(`not so many "${E}" headers present`);return}}else{d.debug(`header "${E}" not present`);return}const $=this.headers[E][N],C=$.raw;if($.parsed)return $.parsed;const I=t.parse(C,E.replace(/-/g,"_"));if(I===-1){this.headers[E].splice(N,1),d.debug(`error parsing "${E}" header field with value "${C}"`);return}else return $.parsed=I,I}s(E,N){return this.parseHeader(E,N)}setHeader(E,N){const $={raw:N};this.headers[_.headerize(E)]=[$]}parseSDP(E){return!E&&this.sdp?this.sdp:(this.sdp=b.parse(this.body||""),this.sdp)}toString(){return this.data}}class c extends m{constructor(E){super(),this.ua=E,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(E,N,$,C,I,F){const H=[];let o=this.getHeader("To");if(E=E||null,N=N||null,!E||E<100||E>699)throw new TypeError(`Invalid status_code: ${E}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[E]||"",$=_.cloneArray($),this.ua.configuration.extra_headers&&($=$.concat(this.ua.configuration.extra_headers));let f=`SIP/2.0 ${E} ${N}\r
17
+ `;if(this.method===i.INVITE&&E>100&&E<=200){const p=this.getHeaders("record-route");for(const A of p)f+=`Record-Route: ${A}\r
18
18
  `}const T=this.getHeaders("via");for(const p of T)f+=`Via: ${p}\r
19
- `;!this.to_tag&&v>100?o+=`;tag=${_.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(o+=`;tag=${this.to_tag}`),f+=`To: ${o}\r
19
+ `;!this.to_tag&&E>100?o+=`;tag=${_.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(o+=`;tag=${this.to_tag}`),f+=`To: ${o}\r
20
20
  `,f+=`From: ${this.getHeader("From")}\r
21
21
  `,f+=`Call-ID: ${this.call_id}\r
22
22
  `,f+=`CSeq: ${this.cseq} ${this.method}\r
23
23
  `;for(const p of $)f+=`${p.trim()}\r
24
24
  `;switch(this.method){case i.INVITE:this.ua.configuration.session_timers&&H.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&H.push("gruu"),H.push("ice","replaces");break;case i.UPDATE:this.ua.configuration.session_timers&&H.push("timer"),C&&H.push("ice"),H.push("replaces")}if(H.push("outbound"),this.method===i.OPTIONS?(f+=`Allow: ${i.ALLOWED_METHODS}\r
25
25
  `,f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
26
- `):v===405?f+=`Allow: ${i.ALLOWED_METHODS}\r
27
- `:v===415&&(f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
26
+ `):E===405?f+=`Allow: ${i.ALLOWED_METHODS}\r
27
+ `:E===415&&(f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
28
28
  `),f+=`Supported: ${H}\r
29
29
  `,C){const p=_.str_utf8_length(C);f+=`Content-Type: application/sdp\r
30
30
  `,f+=`Content-Length: ${p}\r
31
31
  \r
32
32
  `,f+=C}else f+=`Content-Length: 0\r
33
33
  \r
34
- `;this.server_transaction.receiveResponse(v,f,y,F)}reply_sl(v=null,N=null){const $=this.getHeaders("via");if(!v||v<100||v>699)throw new TypeError(`Invalid status_code: ${v}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[v]||"";let C=`SIP/2.0 ${v} ${N}\r
34
+ `;this.server_transaction.receiveResponse(E,f,I,F)}reply_sl(E=null,N=null){const $=this.getHeaders("via");if(!E||E<100||E>699)throw new TypeError(`Invalid status_code: ${E}`);if(N&&typeof N!="string"&&!(N instanceof String))throw new TypeError(`Invalid reason_phrase: ${N}`);N=N||i.REASON_PHRASE[E]||"";let C=`SIP/2.0 ${E} ${N}\r
35
35
  `;for(const F of $)C+=`Via: ${F}\r
36
- `;let y=this.getHeader("To");if(!this.to_tag&&v>100?y+=`;tag=${_.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(y+=`;tag=${this.to_tag}`),C+=`To: ${y}\r
36
+ `;let I=this.getHeader("To");if(!this.to_tag&&E>100?I+=`;tag=${_.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(I+=`;tag=${this.to_tag}`),C+=`To: ${I}\r
37
37
  `,C+=`From: ${this.getHeader("From")}\r
38
38
  `,C+=`Call-ID: ${this.call_id}\r
39
39
  `,C+=`CSeq: ${this.cseq} ${this.method}\r
40
40
  `,this.ua.configuration.extra_headers)for(const F of this.ua.configuration.extra_headers)C+=`${F.trim()}\r
41
41
  `;C+=`Content-Length: 0\r
42
42
  \r
43
- `,this.transport.send(C)}}class A extends g{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}return Xt={OutgoingRequest:h,InitialOutgoingInviteRequest:l,IncomingRequest:c,IncomingResponse:A},Xt}var Qt,xn;function ti(){if(xn)return Qt;xn=1;const w=fe(),I=_e(),i=new w("DigestAuthentication");return Qt=class{constructor(R){this._credentials=R,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(R){switch(R){case"realm":return this._realm;case"ha1":return this._ha1;default:i.warn('get() | cannot get "%s" parameter',R);return}}authenticate({method:R,ruri:t,body:d},h,l=null){if(this._algorithm=h.algorithm,this._realm=h.realm,this._nonce=h.nonce,this._opaque=h.opaque,this._stale=h.stale,this._algorithm){if(this._algorithm!=="MD5")return i.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return i.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return i.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return i.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return i.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(h.qop)if(h.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(h.qop.indexOf("auth")>-1)this._qop="auth";else return i.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=R,this._uri=t,this._cnonce=l||I.createRandomToken(12),this._nc+=1;const g=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-g.length)+g,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=I.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let c,A;return this._qop==="auth"?(c=`${this._method}:${this._uri}`,A=I.calculateMD5(c),i.debug('authenticate() | using qop=auth [a2:"%s"]',c),this._response=I.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${A}`)):this._qop==="auth-int"?(c=`${this._method}:${this._uri}:${I.calculateMD5(d||"")}`,A=I.calculateMD5(c),i.debug('authenticate() | using qop=auth-int [a2:"%s"]',c),this._response=I.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${A}`)):this._qop===null&&(c=`${this._method}:${this._uri}`,A=I.calculateMD5(c),i.debug('authenticate() | using qop=null [a2:"%s"]',c),this._response=I.calculateMD5(`${this._ha1}:${this._nonce}:${A}`)),i.debug("authenticate() | response generated"),!0}toString(){const R=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return R.push(`algorithm=${this._algorithm}`),R.push(`username="${this._credentials.username}"`),R.push(`realm="${this._realm}"`),R.push(`nonce="${this._nonce}"`),R.push(`uri="${this._uri}"`),R.push(`response="${this._response}"`),this._opaque&&R.push(`opaque="${this._opaque}"`),this._qop&&(R.push(`qop=${this._qop}`),R.push(`cnonce="${this._cnonce}"`),R.push(`nc=${this._ncHex}`)),`Digest ${R.join(", ")}`}},Qt}var Zt,Nn;function sl(){if(Nn)return Zt;Nn=1;const w=500,I=4e3,i=5e3;return Zt={T1:w,T2:I,T4:i,TIMER_B:64*w,TIMER_D:0*w,TIMER_F:64*w,TIMER_H:64*w,TIMER_I:0*w,TIMER_J:0*w,TIMER_K:0*i,TIMER_L:64*w,TIMER_M:64*w,PROVISIONAL_RESPONSE_INTERVAL:6e4},Zt}var es,On;function We(){if(On)return es;On=1;const w=Ie().EventEmitter,I=fe(),i=ce(),_=Se(),R=sl(),t=new I("NonInviteClientTransaction"),d=new I("InviteClientTransaction"),h=new I("AckClientTransaction"),l=new I("NonInviteServerTransaction"),g=new I("InviteServerTransaction"),c={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 A extends w{constructor(F,H,o,f){super(),this.type=c.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=F,this.transport=H,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},R.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){t.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){t.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(F){const H=F.status_code;if(H<200)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(F);break}else switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),clearTimeout(this.F),H===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(F),this.K=setTimeout(()=>{this.timer_K()},R.TIMER_K);break;case c.STATUS_COMPLETED:break}}}class U extends w{constructor(F,H,o,f){super(),this.type=c.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=F,this.transport=H,this.request=o,this.eventHandlers=f,o.transaction=this;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},R.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==c.STATUS_ACCEPTED&&(d.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){d.debug(`Timer M expired for transaction ${this.id}`),this.state===c.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){d.debug(`Timer B expired for transaction ${this.id}`),this.state===c.STATUS_CALLING&&(this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){d.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(F){const H=new _.OutgoingRequest(i.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});H.setHeader("from",this.request.getHeader("from")),H.setHeader("via",this.request.getHeader("via")),H.setHeader("to",F.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},R.TIMER_D),this.transport.send(H)}cancel(F){if(this.state!==c.STATUS_PROCEEDING)return;const H=new _.OutgoingRequest(i.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});H.setHeader("from",this.request.getHeader("from")),H.setHeader("via",this.request.getHeader("via")),H.setHeader("to",this.request.getHeader("to")),F&&H.setHeader("reason",F),this.transport.send(H)}receiveResponse(F){const H=F.status_code;if(H>=100&&H<=199)switch(this.state){case c.STATUS_CALLING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(F);break}else if(H>=200&&H<=299)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},R.TIMER_M),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(F);break}else if(H>=300&&H<=699)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.sendACK(F),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_COMPLETED:this.sendACK(F);break}}}class v extends w{constructor(F,H,o,f){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=H,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T)}get C(){return c}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){h.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class N extends w{constructor(F,H,o){super(),this.type=c.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=F,this.transport=H,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_TRYING,F.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}timer_J(){l.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,l.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(F,H,o,f){if(F===100)switch(this.state){case c.STATUS_TRYING:this.stateChanged(c.STATUS_PROCEEDING),this.transport.send(H)||this.onTransportError();break;case c.STATUS_PROCEEDING:this.last_response=H,this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break}else if(F>=200&&F<=699)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.last_response=H,this.J=setTimeout(()=>{this.timer_J()},R.TIMER_J),this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break;case c.STATUS_COMPLETED:break}}}class $ extends w{constructor(F,H,o){super(),this.type=c.INVITE_SERVER,this.id=o.via_branch,this.ua=F,this.transport=H,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_PROCEEDING,F.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}timer_H(){g.debug(`Timer H expired for transaction ${this.id}`),this.state===c.STATUS_COMPLETED&&g.debug("ACK not received, dialog will be terminated"),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){g.debug(`Timer L expired for transaction ${this.id}`),this.state===c.STATUS_ACCEPTED&&(this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,g.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(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(F,H,o,f){if(F>=100&&F<=199&&this.state===c.STATUS_PROCEEDING&&(this.transport.send(H)||this.onTransportError(),this.last_response=H),F>100&&F<=199&&this.state===c.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},R.PROVISIONAL_RESPONSE_INTERVAL));else if(F>=200&&F<=299)switch(this.state){case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.last_response=H,this.L=setTimeout(()=>{this.timer_L()},R.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case c.STATUS_ACCEPTED:this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break}else F>=300&&F<=699&&this.state===c.STATUS_PROCEEDING&&(this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(H)?(this.stateChanged(c.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},R.TIMER_H),o&&o()):(this.onTransportError(),f&&f()))}}function C({_transactions:y},F){let H;switch(F.method){case i.INVITE:if(H=y.ist[F.via_branch],H){switch(H.state){case c.STATUS_PROCEEDING:H.transport.send(H.last_response);break;case c.STATUS_ACCEPTED:break}return!0}break;case i.ACK:if(H=y.ist[F.via_branch],H){if(H.state===c.STATUS_ACCEPTED)return!1;if(H.state===c.STATUS_COMPLETED)return H.state=c.STATUS_CONFIRMED,H.I=setTimeout(()=>{H.timer_I()},R.TIMER_I),!0}else return!1;break;case i.CANCEL:return H=y.ist[F.via_branch],H?(F.reply_sl(200),H.state!==c.STATUS_PROCEEDING):(F.reply_sl(481),!0);default:if(H=y.nist[F.via_branch],H){switch(H.state){case c.STATUS_TRYING:break;case c.STATUS_PROCEEDING:case c.STATUS_COMPLETED:H.transport.send(H.last_response);break}return!0}break}}return es={C:c,NonInviteClientTransaction:A,InviteClientTransaction:U,AckClientTransaction:v,NonInviteServerTransaction:N,InviteServerTransaction:$,checkTransaction:C},es}var ts,Dn;function Ve(){if(Dn)return ts;Dn=1;const w=fe(),I=ce(),i=ti(),_=We(),R=new w("RequestSender"),t={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};return ts=class{constructor(h,l,g){this._ua=h,this._eventHandlers=g,this._method=l.method,this._request=l,this._auth=null,this._challenged=!1,this._staled=!1;for(const c in t)Object.prototype.hasOwnProperty.call(t,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=t[c]));h.status===h.C.STATUS_USER_CLOSED&&(this._method!==I.BYE||this._method!==I.ACK)&&this._eventHandlers.onTransportError()}send(){const h={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:l=>{this._receiveResponse(l)}};switch(this._method){case"INVITE":this.clientTransaction=new _.InviteClientTransaction(this._ua,this._ua.transport,this._request,h);break;case"ACK":this.clientTransaction=new _.AckClientTransaction(this._ua,this._ua.transport,this._request,h);break;default:this.clientTransaction=new _.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,h)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(h){let l,g;const c=h.status_code;if((c===401||c===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(h.status_code===401?(l=h.parseHeader("www-authenticate"),g="authorization"):(l=h.parseHeader("proxy-authenticate"),g="proxy-authorization"),!l){R.debug(`${h.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(h);return}if(!this._challenged||!this._staled&&l.stale===!0){if(this._auth||(this._auth=new i({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,l)){this._eventHandlers.onReceiveResponse(h);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),l.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(g,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(h)}else this._eventHandlers.onReceiveResponse(h)}},ts}var ss,Un;function si(){if(Un)return ss;Un=1;const w=fe(),I=_e(),i=ce(),_=Se(),R=Ve(),t=new w("Registrator"),d=10;return ss=class{constructor(l,g){this._reg_id=1,this._ua=l,this._transport=g,this._registrar=l.configuration.registrar_server,this._expires=l.configuration.register_expires,this._call_id=I.createRandomToken(22),this._cseq=0,this._to_uri=l.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(l){Array.isArray(l)||(l=[]),this._extraHeaders=l.slice()}setExtraContactParams(l){l instanceof Object||(l={}),this._extraContactParams="";for(const g in l)if(Object.prototype.hasOwnProperty.call(l,g)){const c=l[g];this._extraContactParams+=`;${g}`,c&&(this._extraContactParams+=`=${c}`)}}register(){if(this._registering){t.debug("Register request in progress...");return}const l=this._extraHeaders.slice();let g;this._expires?(g=`${this._contact};expires=${this._expires}${this._extraContactParams}`,l.push(`Expires: ${this._expires}`)):g=`${this._contact}${this._extraContactParams}`,l.push(`Contact: ${g}`);let c=I.newTag();this._ua.configuration.register_from_tag_trail&&(typeof this._ua.configuration.register_from_tag_trail=="function"?c+=this._ua.configuration.register_from_tag_trail():c+=this._ua.configuration.register_from_tag_trail);const A=new _.OutgoingRequest(i.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1,from_tag:c},l),U=new R(this._ua,A,{onRequestTimeout:()=>{this._registrationFailure(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:v=>{if(v.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(v.status_code):break;case/^2[0-9]{2}$/.test(v.status_code):{if(this._registering=!1,!v.hasHeader("Contact")){t.debug("no Contact header in response to REGISTER, response ignored");break}const N=v.headers.Contact.reduce((F,H)=>F.concat(H.parsed),[]);let $=N.find(F=>this._sipInstance===F.getParam("+sip.instance")&&this._reg_id===parseInt(F.getParam("reg-id")));if($||($=N.find(F=>F.uri.user===this._ua.contact.uri.user)),!$){t.debug("no Contact header pointing to us, response ignored");break}let C=$.getParam("expires");!C&&v.hasHeader("expires")&&(C=v.getHeader("expires")),C||(C=this._expires),C=Number(C),C<d&&(C=d);const y=C>64?C*1e3/2+Math.floor((C/2-32)*1e3*Math.random()):C*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},y),$.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=$.getParam("temp-gruu").replace(/"/g,"")),$.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=$.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:v}));break}case/^423$/.test(v.status_code):{v.hasHeader("min-expires")?(this._expires=Number(v.getHeader("min-expires")),this._expires<d&&(this._expires=d),this._registering=!1,this.register()):(t.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(v,i.causes.SIP_FAILURE_CODE));break}default:{const N=I.sipErrorCause(v.status_code);this._registrationFailure(v,N)}}}});this._registering=!0,U.send()}unregister(l={}){if(!this._registered){t.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const g=this._extraHeaders.slice();l.all?g.push(`Contact: *${this._extraContactParams}`):g.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),g.push("Expires: 0");const c=new _.OutgoingRequest(i.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},g);new R(this._ua,c,{onRequestTimeout:()=>{this._unregistered(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:U=>{switch(!0){case/^1[0-9]{2}$/.test(U.status_code):break;case/^2[0-9]{2}$/.test(U.status_code):this._unregistered(U);break;default:{const v=I.sipErrorCause(U.status_code);this._unregistered(U,v)}}}}).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(l,g){this._registering=!1,this._ua.registrationFailed({response:l||null,cause:g}),this._registered&&(this._registered=!1,this._ua.unregistered({response:l||null,cause:g}))}_unregistered(l,g){this._registering=!1,this._registered=!1,this._ua.unregistered({response:l||null,cause:g||null})}},ss}var rs,Pn;function ri(){if(Pn)return rs;Pn=1;const w=ce(),I=We(),i=Ve(),_={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};return rs=class{constructor(t,d,h){this._dialog=t,this._ua=t._ua,this._request=d,this._eventHandlers=h,this._reattempt=!1,this._reattemptTimer=null;for(const l in _)Object.prototype.hasOwnProperty.call(_,l)&&(this._eventHandlers[l]||(this._eventHandlers[l]=_[l]))}get request(){return this._request}send(){const t=new i(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:d=>{this._eventHandlers.onAuthenticated(d)},onReceiveResponse:d=>{this._receiveResponse(d)}});if(t.send(),(this._request.method===w.INVITE||this._request.method===w.UPDATE&&this._request.body)&&t.clientTransaction.state!==I.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const d=()=>{(t.clientTransaction.state===I.C.STATUS_ACCEPTED||t.clientTransaction.state===I.C.STATUS_COMPLETED||t.clientTransaction.state===I.C.STATUS_TERMINATED)&&(t.clientTransaction.removeListener("stateChanged",d),this._dialog.uac_pending_reply=!1)};t.clientTransaction.on("stateChanged",d)}}_receiveResponse(t){t.status_code===408||t.status_code===481?this._eventHandlers.onDialogError(t):t.method===w.INVITE&&t.status_code===491?this._reattempt?this._eventHandlers.onErrorResponse(t):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):t.status_code>=200&&t.status_code<300?this._eventHandlers.onSuccessResponse(t):t.status_code>=300&&this._eventHandlers.onErrorResponse(t)}},rs}var ns,Mn;function ni(){if(Mn)return ns;Mn=1;const w=fe(),I=Se(),i=ce(),_=We(),R=ri(),t=_e(),d=new w("Dialog"),h={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};return ns=class{static get C(){return h}constructor(g,c,A,U=h.STATUS_CONFIRMED){if(this._owner=g,this._ua=g._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!c.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};c instanceof I.IncomingResponse&&(U=c.status_code<200?h.STATUS_EARLY:h.STATUS_CONFIRMED);const v=c.parseHeader("contact");A==="UAS"?(this._id={call_id:c.call_id,local_tag:c.to_tag,remote_tag:c.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=U,this._remote_seqnum=c.cseq,this._local_uri=c.parseHeader("to").uri,this._remote_uri=c.parseHeader("from").uri,this._remote_target=v.uri,this._route_set=c.getHeaders("record-route"),this.incoming_ack_seqnum=c.cseq,this.outgoing_ack_seqnum=null):A==="UAC"&&(this._id={call_id:c.call_id,local_tag:c.from_tag,remote_tag:c.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=U,this._local_seqnum=c.cseq,this._local_uri=c.parseHeader("from").uri,this._remote_uri=c.parseHeader("to").uri,this._remote_target=v.uri,this._route_set=c.getHeaders("record-route").reverse(),this.incoming_ack_seqnum=null,this.outgoing_ack_seqnum=this._local_seqnum),this._ua.newDialog(this),d.debug(`new ${A} dialog created with status ${this._state===h.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(g){this._local_seqnum=g}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(g){this._uac_pending_reply=g}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===h.STATUS_TERMINATED}update(g,c){this._state=h.STATUS_CONFIRMED,d.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),c==="UAC"&&(this._route_set=g.getHeaders("record-route").reverse())}terminate(){d.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=h.STATUS_TERMINATED}sendRequest(g,c={}){const A=t.cloneArray(c.extraHeaders),U=t.cloneObject(c.eventHandlers),v=c.body||null,N=this._createRequest(g,A,v);return U.onAuthenticated=()=>{this._local_seqnum+=1,N.method===i.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum)},new R(this,N,U).send(),N}receiveRequest(g){this._checkInDialogRequest(g)&&(g.method===i.ACK&&this.incoming_ack_seqnum!==null?this.incoming_ack_seqnum=null:g.method===i.INVITE&&(this.incoming_ack_seqnum=g.cseq),this._owner.receiveRequest(g))}_createRequest(g,c,A){c=t.cloneArray(c),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const U=g===i.CANCEL||g===i.ACK?this.outgoing_ack_seqnum:this._local_seqnum+=1;return g===i.INVITE&&(this.outgoing_ack_seqnum=U),new I.OutgoingRequest(g,this._remote_target,this._ua,{cseq:U,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},c,A)}_checkInDialogRequest(g){if(!this._remote_seqnum)this._remote_seqnum=g.cseq;else if(g.cseq<this._remote_seqnum)if(g.method===i.ACK){if(this.incoming_ack_seqnum===null||g.cseq!==this.incoming_ack_seqnum)return!1}else return g.reply(500),!1;else g.cseq>this._remote_seqnum&&(this._remote_seqnum=g.cseq);if(g.method===i.INVITE||g.method===i.UPDATE&&g.body){if(this._uac_pending_reply===!0)g.reply(491);else if(this._uas_pending_reply===!0){const c=(Math.random()*10|0)+1;return g.reply(500,null,[`Retry-After:${c}`]),!1}else{this._uas_pending_reply=!0;const c=()=>{(g.server_transaction.state===_.C.STATUS_ACCEPTED||g.server_transaction.state===_.C.STATUS_COMPLETED||g.server_transaction.state===_.C.STATUS_TERMINATED)&&(g.server_transaction.removeListener("stateChanged",c),this._uas_pending_reply=!1)};g.server_transaction.on("stateChanged",c)}g.hasHeader("contact")&&g.server_transaction.on("stateChanged",()=>{g.server_transaction.state===_.C.STATUS_ACCEPTED&&(this._remote_target=g.parseHeader("contact").uri)})}else g.method===i.NOTIFY&&g.hasHeader("contact")&&g.server_transaction.on("stateChanged",()=>{g.server_transaction.state===_.C.STATUS_COMPLETED&&(this._remote_target=g.parseHeader("contact").uri)});return!0}},ns}var ht={exports:{}},Ln;function li(){if(Ln)return ht.exports;Ln=1;const w=Ie().EventEmitter,I=fe(),i=ce(),_=we(),R=_e(),t=new I("RTCSession:DTMF"),d={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};return ht.exports=class extends w{constructor(l){super(),this._session=l,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(l,g={}){if(l===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 _.InvalidStateError(this._session.status);const c=R.cloneArray(g.extraHeaders);if(this.eventHandlers=R.cloneObject(g.eventHandlers),typeof l=="string")l=l.toUpperCase();else if(typeof l=="number")l=l.toString();else throw new TypeError(`Invalid tone: ${l}`);if(l.match(/^[0-9A-DR#*]$/))this._tone=l;else throw new TypeError(`Invalid tone: ${l}`);this._duration=g.duration,c.push("Content-Type: application/dtmf-relay");let A=`Signal=${this._tone}\r
44
- `;A+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(i.INFO,{extraHeaders:c,eventHandlers:{onSuccessResponse:U=>{this.emit("succeeded",{originator:"remote",response:U})},onErrorResponse:U=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:U})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:A})}init_incoming(l){const g=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,c=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=l,l.reply(200),l.body){const A=l.body.split(`
45
- `);A.length>=1&&g.test(A[0])&&(this._tone=A[0].replace(g,"$2")),A.length>=2&&c.test(A[1])&&(this._duration=parseInt(A[1].replace(c,"$2"),10))}this._duration||(this._duration=d.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:l}):t.debug("invalid INFO DTMF received, discarded")}},ht.exports.C=d,ht.exports}var ls,Fn;function ii(){if(Fn)return ls;Fn=1;const w=Ie().EventEmitter,I=ce(),i=we(),_=_e();return ls=class extends w{constructor(t){super(),this._session=t,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(t,d,h={}){if(this._direction="outgoing",t===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 i.InvalidStateError(this._session.status);this._contentType=t,this._body=d;const l=_.cloneArray(h.extraHeaders);l.push(`Content-Type: ${t}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(I.INFO,{extraHeaders:l,eventHandlers:{onSuccessResponse:g=>{this.emit("succeeded",{originator:"remote",response:g})},onErrorResponse:g=>{this.emit("failed",{originator:"remote",response:g})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:d})}init_incoming(t){this._direction="incoming",this.request=t,t.reply(200),this._contentType=t.hasHeader("Content-Type")?t.getHeader("Content-Type").toLowerCase():void 0,this._body=t.body,this._session.newInfo({originator:"remote",info:this,request:t})}},ls}var is,Hn;function ai(){if(Hn)return is;Hn=1;const w=fe(),I=ce(),i=new w("RTCSession:ReferNotifier"),_={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};return is=class{constructor(t,d,h){this._session=t,this._id=d,this._expires=h||_.expires,this._active=!0,this.notify(100)}notify(t,d){if(i.debug("notify()"),this._active===!1)return;d=d||I.REASON_PHRASE[t]||"";let h;t>=200?h="terminated;reason=noresource":h=`active;expires=${this._expires}`,this._session.sendRequest(I.NOTIFY,{extraHeaders:[`Event: ${_.event_type};id=${this._id}`,`Subscription-State: ${h}`,`Content-Type: ${_.body_type}`],body:`SIP/2.0 ${t} ${d}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}},is}var as,$n;function oi(){if($n)return as;$n=1;const w=Ie().EventEmitter,I=fe(),i=ce(),_=Ce(),R=_e(),t=new I("RTCSession:ReferSubscriber");return as=class extends w{constructor(h){super(),this._id=null,this._session=h}get id(){return this._id}sendRefer(h,l={}){t.debug("sendRefer()");const g=R.cloneArray(l.extraHeaders),c=R.cloneObject(l.eventHandlers);for(const N in c)Object.prototype.hasOwnProperty.call(c,N)&&this.on(N,c[N]);let A=null;l.replaces&&(A=l.replaces._request.call_id,A+=`;to-tag=${l.replaces._to_tag}`,A+=`;from-tag=${l.replaces._from_tag}`,A=encodeURIComponent(A));const U=`Refer-To: <${h}${A?`?Replaces=${A}`:""}>`;if(g.push(U),!g.some(N=>N.toLowerCase().startsWith("referred-by:"))){const N=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;g.push(N)}g.push(`Contact: ${this._session.contact}`);const v=this._session.sendRequest(i.REFER,{extraHeaders:g,eventHandlers:{onSuccessResponse:N=>{this._requestSucceeded(N)},onErrorResponse:N=>{this._requestFailed(N,i.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,i.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,i.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,i.causes.DIALOG_ERROR)}}});this._id=v.cseq}receiveNotify(h){if(t.debug("receiveNotify()"),!h.body)return;const l=_.parse(h.body.trim().split(`\r
46
- `,1)[0],"Status_Line");if(l===-1){t.debug(`receiveNotify() | error parsing NOTIFY body: "${h.body}"`);return}switch(!0){case/^100$/.test(l.status_code):this.emit("trying",{request:h,status_line:l});break;case/^1[0-9]{2}$/.test(l.status_code):this.emit("progress",{request:h,status_line:l});break;case/^2[0-9]{2}$/.test(l.status_code):this.emit("accepted",{request:h,status_line:l});break;default:this.emit("failed",{request:h,status_line:l});break}}_requestSucceeded(h){t.debug("REFER succeeded"),t.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:h})}_requestFailed(h,l){t.debug("REFER failed"),t.debug('emit "requestFailed"'),this.emit("requestFailed",{response:h||null,cause:l})}},as}var os,kn;function rl(){if(kn)return os;kn=1;const w=Ie().EventEmitter,I=tl(),i=fe(),_=ce(),R=we(),t=We(),d=_e(),h=sl(),l=Se(),g=ni(),c=Ve(),A=li(),U=ii(),v=ai(),N=oi(),$=ye(),C=new i("RTCSession"),y={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},F=["audio","video"];return os=class vs extends w{static get C(){return y}constructor(o){C.debug("new"),super(),this._id=null,this._ua=o,this._status=y.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:_.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return y}get causes(){return _.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(o){this._data=o}get status(){return this._status}isInProgress(){switch(this._status){case y.STATUS_NULL:case y.STATUS_INVITE_SENT:case y.STATUS_1XX_RECEIVED:case y.STATUS_INVITE_RECEIVED:case y.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case y.STATUS_ANSWERED:case y.STATUS_WAITING_FOR_ACK:case y.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case y.STATUS_CANCELED:case y.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(o,f={},T){C.debug("connect()");const p=o,S=d.cloneObject(f.eventHandlers),D=d.cloneArray(f.extraHeaders),E=d.cloneObject(f.mediaConstraints,{audio:!0,video:!0}),b=f.mediaStream||null,O=d.cloneObject(f.pcConfig,{iceServers:[]}),M=f.rtcConstraints||null,z=f.rtcOfferConstraints||null;if(this._rtcOfferConstraints=z,this._rtcAnswerConstraints=f.rtcAnswerConstraints||null,this._data=f.data||this._data,o===void 0)throw new TypeError("Not enough arguments");if(this._status!==y.STATUS_NULL)throw new R.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new R.NotSupportedError("WebRTC not supported");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${p}`);this._sessionTimers.enabled&&d.isDecimal(f.sessionTimersExpires)&&(f.sessionTimersExpires>=_.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=f.sessionTimersExpires:this._sessionTimers.defaultExpires=_.SESSION_EXPIRES);for(const he in S)Object.prototype.hasOwnProperty.call(S,he)&&this.on(he,S[he]);this._from_tag=d.newTag();const j=f.anonymous||!1,ie={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:j,outbound:!0}),j?(ie.from_display_name="Anonymous",ie.from_uri=new $("sip","anonymous","anonymous.invalid"),D.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),D.push("Privacy: id")):f.fromUserName&&(ie.from_uri=new $("sip",f.fromUserName,this._ua.configuration.uri.host),D.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),f.fromDisplayName&&(ie.from_display_name=f.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 l.InitialOutgoingInviteRequest(o,this._ua,ie,D),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(O,M),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,T&&T(this),this._newRTCSession("local",this._request),this._sendInitialRequest(E,z,b)}init_incoming(o,f){C.debug("init_incoming()");let T;const p=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;if(o.body&&p!=="application/sdp"){o.reply(415);return}if(this._status=y.STATUS_INVITE_RECEIVED,this._from_tag=o.from_tag,this._id=o.call_id+this._from_tag,this._request=o,this._contact=this._ua.contact.toString(),o.hasHeader("expires")&&(T=o.getHeader("expires")*1e3),o.to_tag=d.newTag(),!this._createDialog(o,"UAS",!0)){o.reply(500,"Missing Contact header field");return}o.body?this._late_sdp=!1:this._late_sdp=!0,this._status=y.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{o.reply(408),this._failed("local",null,_.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),T&&(this._timers.expiresTimer=setTimeout(()=>{this._status===y.STATUS_WAITING_FOR_ANSWER&&(o.reply(487),this._failed("system",null,_.causes.EXPIRES))},T)),this._direction="incoming",this._local_identity=o.to,this._remote_identity=o.from,f&&f(this),this._newRTCSession("remote",o),this._status!==y.STATUS_TERMINATED&&(o.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(o={}){C.debug("answer()");const f=this._request,T=d.cloneArray(o.extraHeaders),p=d.cloneObject(o.mediaConstraints),S=o.mediaStream||null,D=d.cloneObject(o.pcConfig,{iceServers:[]}),E=o.rtcConstraints||null,b=o.rtcAnswerConstraints||null,O=d.cloneObject(o.rtcOfferConstraints);let M,z=!1,j=!1,ie=!1,he=!1;if(this._rtcAnswerConstraints=b,this._rtcOfferConstraints=o.rtcOfferConstraints||null,this._data=o.data||this._data,this._direction!=="incoming")throw new R.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==y.STATUS_WAITING_FOR_ANSWER)throw new R.InvalidStateError(this._status);if(this._sessionTimers.enabled&&d.isDecimal(o.sessionTimersExpires)&&(o.sessionTimersExpires>=_.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=o.sessionTimersExpires:this._sessionTimers.defaultExpires=_.SESSION_EXPIRES),this._status=y.STATUS_ANSWERED,!this._createDialog(f,"UAS")){f.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),T.unshift(`Contact: ${this._contact}`);const oe=f.parseSDP();Array.isArray(oe.media)||(oe.media=[oe.media]);for(const Y of oe.media)Y.type==="audio"&&(z=!0,(!Y.direction||Y.direction==="sendrecv")&&(ie=!0)),Y.type==="video"&&(j=!0,(!Y.direction||Y.direction==="sendrecv")&&(he=!0));if(S&&p.audio===!1){M=S.getAudioTracks();for(const Y of M)S.removeTrack(Y)}if(S&&p.video===!1){M=S.getVideoTracks();for(const Y of M)S.removeTrack(Y)}!S&&p.audio===void 0&&(p.audio=ie),!S&&p.video===void 0&&(p.video=he),!S&&!z&&!O.offerToReceiveAudio&&(p.audio=!1),!S&&!j&&!O.offerToReceiveVideo&&(p.video=!1),this._createRTCConnection(D,E),Promise.resolve().then(()=>{if(S)return S;if(p.audio||p.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(p).catch(Y=>{throw this._status===y.STATUS_TERMINATED?new Error("terminated"):(f.reply(480),this._failed("local",null,_.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',Y),this.emit("getusermediafailed",Y),new Error("getUserMedia() failed"))})}).then(Y=>{if(this._status===y.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=Y,Y&&Y.getTracks().forEach(de=>{this._connection.addTrack(de,Y)})}).then(()=>{if(this._late_sdp)return;const Y={originator:"remote",type:"offer",sdp:f.body};C.debug('emit "sdp"'),this.emit("sdp",Y);const de=new RTCSessionDescription({type:"offer",sdp:Y.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(de)).catch(Q=>{throw f.reply(488),this._failed("system",null,_.causes.WEBRTC_ERROR),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',Q),this.emit("peerconnection:setremotedescriptionfailed",Q),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===y.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(f),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",b).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")})}).then(Y=>{if(this._status===y.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(f,T),f.reply(200,null,T,Y,()=>{this._status=y.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(f,Y),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,_.causes.CONNECTION_ERROR)})}).catch(Y=>{this._status!==y.STATUS_TERMINATED&&(C.warn(`answer() failed: ${Y.message}`),this._failed("system",Y.message,_.causes.INTERNAL_ERROR))})}terminate(o={}){C.debug("terminate()");const f=o.cause||_.causes.BYE,T=d.cloneArray(o.extraHeaders),p=o.body;let S,D=o.status_code,E=o.reason_phrase;if(this._status===y.STATUS_TERMINATED)throw new R.InvalidStateError(this._status);switch(this._status){case y.STATUS_NULL:case y.STATUS_INVITE_SENT:case y.STATUS_1XX_RECEIVED:if(C.debug("canceling session"),D&&(D<200||D>=700))throw new TypeError(`Invalid status_code: ${D}`);D&&(E=E||_.REASON_PHRASE[D]||"",S=`SIP ;cause=${D} ;text="${E}"`),this._status===y.STATUS_NULL||this._status===y.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=S):this._status===y.STATUS_1XX_RECEIVED&&this._request.cancel(S),this._status=y.STATUS_CANCELED,this._failed("local",null,_.causes.CANCELED);break;case y.STATUS_WAITING_FOR_ANSWER:case y.STATUS_ANSWERED:if(C.debug("rejecting session"),D=D||480,D<300||D>=700)throw new TypeError(`Invalid status_code: ${D}`);this._request.reply(D,E,T,p),this._failed("local",null,_.causes.REJECTED);break;case y.STATUS_WAITING_FOR_ACK:case y.STATUS_CONFIRMED:if(C.debug("terminating session"),E=o.reason_phrase||_.REASON_PHRASE[D]||"",D&&(D<200||D>=700))throw new TypeError(`Invalid status_code: ${D}`);if(D&&T.push(`Reason: SIP ;cause=${D}; text="${E}"`),this._status===y.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==t.C.STATUS_TERMINATED){const b=this._dialog;this.receiveRequest=({method:O})=>{O===_.ACK&&(this.sendRequest(_.BYE,{extraHeaders:T,body:p}),b.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===t.C.STATUS_TERMINATED&&(this.sendRequest(_.BYE,{extraHeaders:T,body:p}),b.terminate())}),this._ended("local",null,f),this._dialog=b,this._ua.newDialog(b)}else this.sendRequest(_.BYE,{extraHeaders:T,body:p}),this._ended("local",null,f)}}sendDTMF(o,f={}){C.debug("sendDTMF() | tones: %s",o);let T=f.duration||null,p=f.interToneGap||null;const S=f.transportType||_.DTMF_TRANSPORT.INFO;if(o===void 0)throw new TypeError("Not enough arguments");if(this._status!==y.STATUS_CONFIRMED&&this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_1XX_RECEIVED)throw new R.InvalidStateError(this._status);if(S!==_.DTMF_TRANSPORT.INFO&&S!==_.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${S}`);if(typeof o=="number"&&(o=o.toString()),!o||typeof o!="string"||!o.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${o}`);if(T&&!d.isDecimal(T))throw new TypeError(`Invalid tone duration: ${T}`);if(T?T<A.C.MIN_DURATION?(C.debug(`"duration" value is lower than the minimum allowed, setting it to ${A.C.MIN_DURATION} milliseconds`),T=A.C.MIN_DURATION):T>A.C.MAX_DURATION?(C.debug(`"duration" value is greater than the maximum allowed, setting it to ${A.C.MAX_DURATION} milliseconds`),T=A.C.MAX_DURATION):T=Math.abs(T):T=A.C.DEFAULT_DURATION,f.duration=T,p&&!d.isDecimal(p))throw new TypeError(`Invalid interToneGap: ${p}`);if(p?p<A.C.MIN_INTER_TONE_GAP?(C.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${A.C.MIN_INTER_TONE_GAP} milliseconds`),p=A.C.MIN_INTER_TONE_GAP):p=Math.abs(p):p=A.C.DEFAULT_INTER_TONE_GAP,S===_.DTMF_TRANSPORT.RFC2833){const E=this._getDTMFRTPSender();E&&(o=E.toneBuffer+o,E.insertDTMF(o,T,p));return}if(this._tones){this._tones+=o;return}this._tones=o,D.call(this);function D(){let E;if(this._status===y.STATUS_TERMINATED||!this._tones){this._tones=null;return}const b=this._tones[0];if(this._tones=this._tones.substring(1),b===",")E=2e3;else{const O=new A(this);f.eventHandlers={onFailed:()=>{this._tones=null}},O.send(b,f),E=T+p}setTimeout(D.bind(this),E)}}sendInfo(o,f,T={}){if(C.debug("sendInfo()"),this._status!==y.STATUS_CONFIRMED&&this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_1XX_RECEIVED)throw new R.InvalidStateError(this._status);new U(this).send(o,f,T)}mute(o={audio:!0,video:!1}){C.debug("mute()");let f=!1,T=!1;this._audioMuted===!1&&o.audio&&(f=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&o.video&&(T=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(f===!0||T===!0)&&this._onmute({audio:f,video:T})}unmute(o={audio:!0,video:!0}){C.debug("unmute()");let f=!1,T=!1;this._audioMuted===!0&&o.audio&&(f=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&o.video&&(T=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(f===!0||T===!0)&&this._onunmute({audio:f,video:T})}hold(o={},f){if(C.debug("hold()"),this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_CONFIRMED||this._localHold===!0||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:T,extraHeaders:o.extraHeaders}),!0}unhold(o={},f){if(C.debug("unhold()"),this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_CONFIRMED||this._localHold===!1||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:T,extraHeaders:o.extraHeaders}),!0}renegotiate(o={},f){C.debug("renegotiate()");const T=o.rtcOfferConstraints||null;if(this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;const p={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:p,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}),!0}refer(o,f){C.debug("refer()");const T=o;if(this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_CONFIRMED)return!1;if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${T}`);const p=new N(this);p.sendRefer(o,f);const S=p.id;return this._referSubscribers[S]=p,p.on("requestFailed",()=>{delete this._referSubscribers[S]}),p.on("accepted",()=>{delete this._referSubscribers[S]}),p.on("failed",()=>{delete this._referSubscribers[S]}),p}sendRequest(o,f){if(C.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(o,f);{const T=Object.values(this._earlyDialogs);if(T.length>0)return T[0].sendRequest(o,f);C.warn("sendRequest() | no valid early dialog found");return}}receiveRequest(o){if(C.debug("receiveRequest()"),o.method===_.CANCEL)(this._status===y.STATUS_WAITING_FOR_ANSWER||this._status===y.STATUS_ANSWERED)&&(this._status=y.STATUS_CANCELED,this._request.reply(487),this._failed("remote",o,_.causes.CANCELED));else switch(o.method){case _.ACK:if(this._status!==y.STATUS_WAITING_FOR_ACK)return;if(this._status=y.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!o.body){this.terminate({cause:_.causes.MISSING_SDP,status_code:400});break}const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>{this._is_confirmed||this._confirmed("remote",o)}).catch(p=>{this.terminate({cause:_.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)})}else this._is_confirmed||this._confirmed("remote",o);break;case _.BYE:this._status===y.STATUS_CONFIRMED||this._status===y.STATUS_WAITING_FOR_ACK?(o.reply(200),this._ended("remote",o,_.causes.BYE)):this._status===y.STATUS_INVITE_RECEIVED||this._status===y.STATUS_WAITING_FOR_ANSWER?(o.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",o,_.causes.BYE)):o.reply(403,"Wrong Status");break;case _.INVITE:this._status===y.STATUS_CONFIRMED?o.hasHeader("replaces")?this._receiveReplaces(o):this._receiveReinvite(o):o.reply(403,"Wrong Status");break;case _.INFO:if(this._status===y.STATUS_1XX_RECEIVED||this._status===y.STATUS_WAITING_FOR_ANSWER||this._status===y.STATUS_ANSWERED||this._status===y.STATUS_WAITING_FOR_ACK||this._status===y.STATUS_CONFIRMED){const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;f&&f.match(/^application\/dtmf-relay/i)?new A(this).init_incoming(o):f!==void 0?new U(this).init_incoming(o):o.reply(415)}else o.reply(403,"Wrong Status");break;case _.UPDATE:this._status===y.STATUS_CONFIRMED?this._receiveUpdate(o):o.reply(403,"Wrong Status");break;case _.REFER:this._status===y.STATUS_CONFIRMED?this._receiveRefer(o):o.reply(403,"Wrong Status");break;case _.NOTIFY:this._status===y.STATUS_CONFIRMED?this._receiveNotify(o):o.reply(403,"Wrong Status");break;default:o.reply(501)}}onTransportError(){C.warn("onTransportError()"),this._status!==y.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_.causes.CONNECTION_ERROR,cause:_.causes.CONNECTION_ERROR})}onRequestTimeout(){C.warn("onRequestTimeout()"),this._status!==y.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:_.causes.REQUEST_TIMEOUT,cause:_.causes.REQUEST_TIMEOUT})}onDialogError(){C.warn("onDialogError()"),this._status!==y.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_.causes.DIALOG_ERROR,cause:_.causes.DIALOG_ERROR})}newDTMF(o){C.debug("newDTMF()"),this.emit("newDTMF",o)}newInfo(o){C.debug("newInfo()"),this.emit("newInfo",o)}isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(C.debug("isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(C.debug("isReadyToReOffer() | session not established yet"),!1):(C.debug("isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(C.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(C.debug("close() | closing local MediaStream"),d.closeMediaStream(this._localMediaStream)),this._status!==y.STATUS_TERMINATED){if(this._status=y.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(o){C.warn("close() | error closing the RTCPeerConnection: %o",o)}for(const o in this._timers)Object.prototype.hasOwnProperty.call(this._timers,o)&&clearTimeout(this._timers[o]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const o in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,o)&&(this._earlyDialogs[o].terminate(),delete this._earlyDialogs[o]);for(const o in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,o)&&delete this._referSubscribers[o];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(o,f){let T=h.T1;function p(){this._status===y.STATUS_WAITING_FOR_ACK&&(o.reply(200,null,[`Contact: ${this._contact}`],f),T<h.T2&&(T=T*2,T>h.T2&&(T=h.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),T))}this._timers.invite2xxTimer=setTimeout(p.bind(this),T)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===y.STATUS_WAITING_FOR_ACK&&(C.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(_.BYE),this._ended("remote",null,_.causes.NO_ACK))},h.TIMER_H)}_createRTCConnection(o,f){this._connection=new RTCPeerConnection(o,f),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:_.causes.RTP_TIMEOUT,status_code:408,reason_phrase:_.causes.RTP_TIMEOUT})}),C.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(o,f){if(C.debug("createLocalDescription()"),o!=="offer"&&o!=="answer")throw new Error(`createLocalDescription() | invalid type "${o}"`);const T=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>o==="offer"?T.createOffer(f).catch(p=>(C.warn('emit "peerconnection:createofferfailed" [error:%o]',p),this.emit("peerconnection:createofferfailed",p),Promise.reject(p))):T.createAnswer(f).catch(p=>(C.warn('emit "peerconnection:createanswerfailed" [error:%o]',p),this.emit("peerconnection:createanswerfailed",p),Promise.reject(p)))).then(p=>T.setLocalDescription(p).catch(S=>(this._rtcReady=!0,C.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',S),this.emit("peerconnection:setlocaldescriptionfailed",S),Promise.reject(S)))).then(()=>{const p=f&&f.iceRestart;if(T.iceGatheringState==="complete"&&!p||T.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const S={originator:"local",type:o,sdp:T.localDescription.sdp};return C.debug('emit "sdp"'),this.emit("sdp",S),Promise.resolve(S.sdp)}return new Promise(S=>{let D=!1,E,b;this._iceReady=!1;const O=()=>{if(D)return;T.removeEventListener("icecandidate",E),T.removeEventListener("icegatheringstatechange",b),D=!0,this._rtcReady=!0,this._iceReady=!0;const M={originator:"local",type:o,sdp:T.localDescription.sdp};C.debug('emit "sdp"'),this.emit("sdp",M),S(M.sdp)};T.addEventListener("icecandidate",E=M=>{const z=M.candidate;z?this.emit("icecandidate",{candidate:z,ready:O}):O()}),T.addEventListener("icegatheringstatechange",b=()=>{T.iceGatheringState==="complete"&&O()})})})}_createDialog(o,f,T){const p=f==="UAS"?o.to_tag:o.from_tag,S=f==="UAS"?o.from_tag:o.to_tag,D=o.call_id+p+S;let E=this._earlyDialogs[D];if(T)return E?!0:(E=new g(this,o,f,g.C.STATUS_EARLY),E.error?(C.debug(E.error),this._failed("remote",o,_.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[D]=E,!0));{if(this._from_tag=o.from_tag,this._to_tag=o.to_tag,E)return E.update(o,f),this._dialog=E,delete this._earlyDialogs[D],!0;const b=new g(this,o,f);return b.error?(C.debug(b.error),this._failed("remote",o,_.causes.INTERNAL_ERROR),!1):(this._dialog=b,!0)}}_receiveReinvite(o){C.debug("receiveReinvite()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,T={request:o,callback:void 0,reject:S.bind(this)};let p=!1;function S(E={}){p=!0;const b=E.status_code||403,O=E.reason_phrase||"",M=d.cloneArray(E.extraHeaders);if(this._status!==y.STATUS_CONFIRMED)return!1;if(b<300||b>=700)throw new TypeError(`Invalid status_code: ${b}`);o.reply(b,O,M)}if(this.emit("reinvite",T),p)return;if(this._late_sdp=!1,!o.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(E=>{D.call(this,E)}).catch(()=>{o.reply(500)});return}if(f!=="application/sdp"){C.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(E=>{this._status!==y.STATUS_TERMINATED&&D.call(this,E)}).catch(E=>{C.warn(E)});function D(E){const b=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,b),this._late_sdp&&(E=this._mangleOffer(E)),o.reply(200,null,b,E,()=>{this._status=y.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(o,E),this._setACKTimer()}),typeof T.callback=="function"&&T.callback()}}_receiveUpdate(o){C.debug("receiveUpdate()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,T={request:o,callback:void 0,reject:S.bind(this)};let p=!1;function S(E={}){p=!0;const b=E.status_code||403,O=E.reason_phrase||"",M=d.cloneArray(E.extraHeaders);if(this._status!==y.STATUS_CONFIRMED)return!1;if(b<300||b>=700)throw new TypeError(`Invalid status_code: ${b}`);o.reply(b,O,M)}if(this.emit("update",T),p)return;if(!o.body){D.call(this,null);return}if(f!=="application/sdp"){C.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(E=>{this._status!==y.STATUS_TERMINATED&&D.call(this,E)}).catch(E=>{C.warn(E)});function D(E){const b=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,b),o.reply(200,null,b,E),typeof T.callback=="function"&&T.callback()}}_processInDialogSdpOffer(o){C.debug("_processInDialogSdpOffer()");const f=o.parseSDP();let T=!1;for(const D of f.media){if(F.indexOf(D.type)===-1)continue;const E=D.direction||f.direction||"sendrecv";if(E==="sendonly"||E==="inactive")T=!0;else{T=!1;break}}const p={originator:"remote",type:"offer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",p);const S=new RTCSessionDescription({type:"offer",sdp:p.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===y.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(S).catch(D=>{throw o.reply(488),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',D),this.emit("peerconnection:setremotedescriptionfailed",D),D})}).then(()=>{if(this._status===y.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&T===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&T===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===y.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(D=>{throw o.reply(500),C.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',D),D})}).catch(D=>{C.warn("_processInDialogSdpOffer() failed [error: %o]",D)}),this._connectionPromiseQueue}_receiveRefer(o){if(C.debug("receiveRefer()"),!o.refer_to){C.debug("no Refer-To header field present in REFER"),o.reply(400);return}if(o.refer_to.uri.scheme!==_.SIP){C.debug("Refer-To header field points to a non-SIP URI scheme"),o.reply(416);return}o.reply(202);const f=new v(this,o.cseq);C.debug('emit "refer"'),this.emit("refer",{request:o,accept:(S,D)=>{T.call(this,S,D)},reject:()=>{p.call(this)}});function T(S,D={}){if(S=typeof S=="function"?S:null,this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_CONFIRMED)return!1;const E=new vs(this._ua);if(E.on("progress",({response:b})=>{f.notify(b.status_code,b.reason_phrase)}),E.on("accepted",({response:b})=>{f.notify(b.status_code,b.reason_phrase)}),E.on("_failed",({message:b,cause:O})=>{b?f.notify(b.status_code,b.reason_phrase):f.notify(487,O)}),o.refer_to.uri.hasHeader("replaces")){const b=decodeURIComponent(o.refer_to.uri.getHeader("replaces"));D.extraHeaders=d.cloneArray(D.extraHeaders),D.extraHeaders.push(`Replaces: ${b}`)}E.connect(o.refer_to.uri.toAor(),D,S)}function p(){f.notify(603)}}_receiveNotify(o){switch(C.debug("receiveNotify()"),o.event||o.reply(400),o.event.event){case"refer":{let f,T;if(o.event.params&&o.event.params.id)f=o.event.params.id,T=this._referSubscribers[f];else if(Object.keys(this._referSubscribers).length===1)T=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{o.reply(400,"Missing event id parameter");return}if(!T){o.reply(481,"Subscription does not exist");return}T.receiveNotify(o),o.reply(200);break}default:o.reply(489)}}_receiveReplaces(o){C.debug("receiveReplaces()");function f(p){if(this._status!==y.STATUS_WAITING_FOR_ACK&&this._status!==y.STATUS_CONFIRMED)return!1;const S=new vs(this._ua);S.on("confirmed",()=>{this.terminate()}),S.init_incoming(o,p)}function T(){C.debug("Replaced INVITE rejected by the user"),o.reply(486)}this.emit("replaces",{request:o,accept:p=>{f.call(this,p)},reject:()=>{T.call(this)}})}_sendInitialRequest(o,f,T){const p=new c(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:S=>{this._request=S},onReceiveResponse:S=>{this._receiveInviteResponse(S)}});Promise.resolve().then(()=>{if(T)return T;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(S=>{throw this._status===y.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,_.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',S),this.emit("getusermediafailed",S),S)})}).then(S=>{if(this._status===y.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=S,S&&S.getTracks().forEach(D=>{this._connection.addTrack(D,S)}),this._connecting(this._request),this._createLocalDescription("offer",f).catch(D=>{throw this._failed("local",null,_.causes.WEBRTC_ERROR),D})}).then(S=>{if(this._is_canceled||this._status===y.STATUS_TERMINATED)throw new Error("terminated");this._request.body=S,this._status=y.STATUS_INVITE_SENT,C.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),p.send()}).catch(S=>{this._status!==y.STATUS_TERMINATED&&C.warn(S)})}_getDTMFRTPSender(){const o=this._connection.getSenders().find(f=>f.track&&f.track.kind==="audio");if(!(o&&o.dtmf)){C.warn("sendDTMF() | no local audio track to send DTMF with");return}return o.dtmf}_receiveInviteResponse(o){if(C.debug("receiveInviteResponse()"),this._dialog&&o.status_code>=200&&o.status_code<=299)if(this._dialog.id.call_id===o.call_id&&this._dialog.id.local_tag===o.from_tag&&this._dialog.id.remote_tag===o.to_tag){this.sendRequest(_.ACK);return}else{const f=new g(this,o,"UAC");if(f.error!==void 0){C.debug(f.error);return}this.sendRequest(_.ACK),this.sendRequest(_.BYE);return}if(this._is_canceled){o.status_code>=100&&o.status_code<200?this._request.cancel(this._cancel_reason):o.status_code>=200&&o.status_code<299&&this._acceptAndTerminate(o);return}if(!(this._status!==y.STATUS_INVITE_SENT&&this._status!==y.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(o.status_code):this._status=y.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(o.status_code):{if(!o.to_tag){C.debug("1xx response received without to tag");break}if(o.hasHeader("contact")&&!this._createDialog(o,"UAC",!0))break;if(this._status=y.STATUS_1XX_RECEIVED,!o.body){this._progress("remote",o);break}const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>this._progress("remote",o)).catch(p=>{C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)});break}case/^2[0-9]{2}$/.test(o.status_code):{if(this._status=y.STATUS_CONFIRMED,!o.body){this._acceptAndTerminate(o,400,_.causes.MISSING_SDP),this._failed("remote",o,_.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(o,"UAC"))break;const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(p=>this._connection.setLocalDescription(p)).catch(p=>{this._acceptAndTerminate(o,500,p.toString()),this._failed("local",o,_.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(T).then(()=>{this._handleSessionTimersInIncomingResponse(o),this._accepted("remote",o),this.sendRequest(_.ACK),this._confirmed("local",null)}).catch(p=>{this._acceptAndTerminate(o,488,"Not Acceptable Here"),this._failed("remote",o,_.causes.BAD_MEDIA_DESCRIPTION),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)})});break}default:{const f=d.sipErrorCause(o.status_code);this._failed("remote",o,f)}}}_sendReinvite(o={}){C.debug("sendReinvite()");const f=d.cloneArray(o.extraHeaders),T=d.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null;let S=!1;f.push(`Contact: ${this._contact}`),f.push("Content-Type: application/sdp"),this._sessionTimers.running&&f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",p)).then(b=>{b=this._mangleOffer(b);const O={originator:"local",type:"offer",sdp:b};C.debug('emit "sdp"'),this.emit("sdp",O),this.sendRequest(_.INVITE,{extraHeaders:f,body:b,eventHandlers:{onSuccessResponse:M=>{D.call(this,M),S=!0},onErrorResponse:M=>{E.call(this,M)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{E()});function D(b){if(this._status===y.STATUS_TERMINATED||(this.sendRequest(_.ACK),S))return;if(this._handleSessionTimersInIncomingResponse(b),b.body){if(!b.hasHeader("Content-Type")||b.getHeader("Content-Type").toLowerCase()!=="application/sdp"){E.call(this);return}}else{E.call(this);return}const O={originator:"remote",type:"answer",sdp:b.body};C.debug('emit "sdp"'),this.emit("sdp",O);const M=new RTCSessionDescription({type:"answer",sdp:O.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(M)).then(()=>{T.succeeded&&T.succeeded(b)}).catch(z=>{E.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',z),this.emit("peerconnection:setremotedescriptionfailed",z)})}function E(b){T.failed&&T.failed(b)}}_sendUpdate(o={}){C.debug("sendUpdate()");const f=d.cloneArray(o.extraHeaders),T=d.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null,S=o.sdpOffer||!1;let D=!1;f.push(`Contact: ${this._contact}`),this._sessionTimers.running&&f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),S?(f.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",p)).then(O=>{O=this._mangleOffer(O);const M={originator:"local",type:"offer",sdp:O};C.debug('emit "sdp"'),this.emit("sdp",M),this.sendRequest(_.UPDATE,{extraHeaders:f,body:O,eventHandlers:{onSuccessResponse:z=>{E.call(this,z),D=!0},onErrorResponse:z=>{b.call(this,z)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{b.call(this)})):this.sendRequest(_.UPDATE,{extraHeaders:f,eventHandlers:{onSuccessResponse:O=>{E.call(this,O)},onErrorResponse:O=>{b.call(this,O)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function E(O){if(this._status!==y.STATUS_TERMINATED&&!D)if(this._handleSessionTimersInIncomingResponse(O),S){if(O.body){if(!O.hasHeader("Content-Type")||O.getHeader("Content-Type").toLowerCase()!=="application/sdp"){b.call(this);return}}else{b.call(this);return}const M={originator:"remote",type:"answer",sdp:O.body};C.debug('emit "sdp"'),this.emit("sdp",M);const z=new RTCSessionDescription({type:"answer",sdp:M.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(z)).then(()=>{T.succeeded&&T.succeeded(O)}).catch(j=>{b.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',j),this.emit("peerconnection:setremotedescriptionfailed",j)})}else T.succeeded&&T.succeeded(O)}function b(O){T.failed&&T.failed(O)}}_acceptAndTerminate(o,f,T){C.debug("acceptAndTerminate()");const p=[];f&&(T=T||_.REASON_PHRASE[f]||"",p.push(`Reason: SIP ;cause=${f}; text="${T}"`)),(this._dialog||this._createDialog(o,"UAC"))&&(this.sendRequest(_.ACK),this.sendRequest(_.BYE,{extraHeaders:p})),this._status=y.STATUS_TERMINATED}_mangleOffer(o){if(!this._localHold&&!this._remoteHold)return o;if(o=I.parse(o),this._localHold&&!this._remoteHold){C.debug("mangleOffer() | me on hold, mangling offer");for(const f of o.media)F.indexOf(f.type)!==-1&&(f.direction?f.direction==="sendrecv"?f.direction="sendonly":f.direction==="recvonly"&&(f.direction="inactive"):f.direction="sendonly")}else if(this._localHold&&this._remoteHold){C.debug("mangleOffer() | both on hold, mangling offer");for(const f of o.media)F.indexOf(f.type)!==-1&&(f.direction="inactive")}else if(this._remoteHold){C.debug("mangleOffer() | remote on hold, mangling offer");for(const f of o.media)F.indexOf(f.type)!==-1&&(f.direction?f.direction==="sendrecv"?f.direction="recvonly":f.direction==="recvonly"&&(f.direction="inactive"):f.direction="recvonly")}return I.write(o)}_setLocalMediaStatus(){let o=!0,f=!0;(this._localHold||this._remoteHold)&&(o=!1,f=!1),this._audioMuted&&(o=!1),this._videoMuted&&(f=!1),this._toggleMuteAudio(!o),this._toggleMuteVideo(!f)}_handleSessionTimersInIncomingRequest(o,f){if(!this._sessionTimers.enabled)return;let T;o.session_expires&&o.session_expires>=_.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,T=o.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,T="uas"),f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${T}`),this._sessionTimers.refresher=T==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(o){if(!this._sessionTimers.enabled)return;let f;o.session_expires&&o.session_expires>=_.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,f=o.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,f="uac"),this._sessionTimers.refresher=f==="uac",this._runSessionTimer()}_runSessionTimer(){const o=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==y.STATUS_TERMINATED&&this.isReadyToReOffer()&&(C.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===_.UPDATE?this._sendUpdate():this._sendReinvite())},o*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==y.STATUS_TERMINATED&&(C.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:_.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},o*1100)}_toggleMuteAudio(o){const f=this._connection.getSenders().filter(T=>T.track&&T.track.kind==="audio");for(const T of f)T.track.enabled=!o}_toggleMuteVideo(o){const f=this._connection.getSenders().filter(T=>T.track&&T.track.kind==="video");for(const T of f)T.track.enabled=!o}_newRTCSession(o,f){C.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:o,session:this,request:f})}_connecting(o){C.debug("session connecting"),C.debug('emit "connecting"'),this.emit("connecting",{request:o})}_progress(o,f){C.debug("session progress"),C.debug('emit "progress"'),this.emit("progress",{originator:o,response:f||null})}_accepted(o,f){C.debug("session accepted"),this._start_time=new Date,C.debug('emit "accepted"'),this.emit("accepted",{originator:o,response:f||null})}_confirmed(o,f){C.debug("session confirmed"),this._is_confirmed=!0,C.debug('emit "confirmed"'),this.emit("confirmed",{originator:o,ack:f||null})}_ended(o,f,T){C.debug("session ended"),this._end_time=new Date,this._close(),C.debug('emit "ended"'),this.emit("ended",{originator:o,message:f||null,cause:T})}_failed(o,f,T){C.debug("session failed"),C.debug('emit "_failed"'),this.emit("_failed",{originator:o,message:f||null,cause:T}),this._close(),C.debug('emit "failed"'),this.emit("failed",{originator:o,message:f||null,cause:T})}_onhold(o){C.debug("session onhold"),this._setLocalMediaStatus(),C.debug('emit "hold"'),this.emit("hold",{originator:o})}_onunhold(o){C.debug("session onunhold"),this._setLocalMediaStatus(),C.debug('emit "unhold"'),this.emit("unhold",{originator:o})}_onmute({audio:o,video:f}){C.debug("session onmute"),this._setLocalMediaStatus(),C.debug('emit "muted"'),this.emit("muted",{audio:o,video:f})}_onunmute({audio:o,video:f}){C.debug("session onunmute"),this._setLocalMediaStatus(),C.debug('emit "unmuted"'),this.emit("unmuted",{audio:o,video:f})}},os}var us,qn;function ui(){if(qn)return us;qn=1;const w=Ie().EventEmitter,I=fe(),i=ce(),_=Se(),R=_e(),t=Ve(),d=we(),h=ye(),l=new I("Message");return us=class extends w{constructor(c){super(),this._ua=c,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(c,A,U={}){const v=c;if(c===void 0||A===void 0)throw new TypeError("Not enough arguments");if(c=this._ua.normalizeTarget(c),!c)throw new TypeError(`Invalid target: ${v}`);const N=R.cloneArray(U.extraHeaders),$=R.cloneObject(U.eventHandlers),C=U.contentType||"text/plain",y={};U.fromUserName&&(y.from_uri=new h("sip",U.fromUserName,this._ua.configuration.uri.host),N.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),U.fromDisplayName&&(y.from_display_name=U.fromDisplayName);for(const H in $)Object.prototype.hasOwnProperty.call($,H)&&this.on(H,$[H]);N.push(`Content-Type: ${C}`),this._request=new _.OutgoingRequest(i.MESSAGE,c,this._ua,y,N),A&&(this._request.body=A);const F=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:H=>{this._receiveResponse(H)}});this._newMessage("local",this._request),F.send()}init_incoming(c){this._request=c,this._newMessage("remote",c),this._is_replied||(this._is_replied=!0,c.reply(200)),this._close()}accept(c={}){const A=R.cloneArray(c.extraHeaders),U=c.body;if(this._direction!=="incoming")throw new d.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,A,U)}reject(c={}){const A=c.status_code||480,U=c.reason_phrase,v=R.cloneArray(c.extraHeaders),N=c.body;if(this._direction!=="incoming")throw new d.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(A<300||A>=700)throw new TypeError(`Invalid status_code: ${A}`);this._is_replied=!0,this._request.reply(A,U,v,N)}_receiveResponse(c){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(c.status_code):break;case/^2[0-9]{2}$/.test(c.status_code):this._succeeded("remote",c);break;default:{const A=R.sipErrorCause(c.status_code);this._failed("remote",c,A);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,i.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,i.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(c,A){c==="remote"?(this._direction="incoming",this._local_identity=A.to,this._remote_identity=A.from):c==="local"&&(this._direction="outgoing",this._local_identity=A.from,this._remote_identity=A.to),this._ua.newMessage(this,{originator:c,message:this,request:A})}_failed(c,A,U){l.debug("MESSAGE failed"),this._close(),l.debug('emit "failed"'),this.emit("failed",{originator:c,response:A||null,cause:U})}_succeeded(c,A){l.debug("MESSAGE succeeded"),this._close(),l.debug('emit "succeeded"'),this.emit("succeeded",{originator:c,response:A})}},us}var cs,jn;function ci(){if(jn)return cs;jn=1;const w=Ie().EventEmitter,I=fe(),i=ce(),_=Se(),R=_e(),t=Ve(),d=we(),h=new I("Options");return cs=class extends w{constructor(g){super(),this._ua=g,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(g,c,A={}){const U=g;if(g===void 0)throw new TypeError("A target is required for OPTIONS");if(g=this._ua.normalizeTarget(g),!g)throw new TypeError(`Invalid target: ${U}`);const v=R.cloneArray(A.extraHeaders),N=R.cloneObject(A.eventHandlers),$=A.contentType||"application/sdp";for(const y in N)Object.prototype.hasOwnProperty.call(N,y)&&this.on(y,N[y]);v.push(`Content-Type: ${$}`),this._request=new _.OutgoingRequest(i.OPTIONS,g,this._ua,null,v),c&&(this._request.body=c);const C=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:y=>{this._receiveResponse(y)}});this._newOptions("local",this._request),C.send()}init_incoming(g){this._request=g,this._newOptions("remote",g),this._is_replied||(this._is_replied=!0,g.reply(200)),this._close()}accept(g={}){const c=R.cloneArray(g.extraHeaders),A=g.body;if(this._direction!=="incoming")throw new d.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,c,A)}reject(g={}){const c=g.status_code||480,A=g.reason_phrase,U=R.cloneArray(g.extraHeaders),v=g.body;if(this._direction!=="incoming")throw new d.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(c<300||c>=700)throw new TypeError(`Invalid status_code: ${c}`);this._is_replied=!0,this._request.reply(c,A,U,v)}_receiveResponse(g){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(g.status_code):break;case/^2[0-9]{2}$/.test(g.status_code):this._succeeded("remote",g);break;default:{const c=R.sipErrorCause(g.status_code);this._failed("remote",g,c);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,i.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,i.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(g,c){g==="remote"?(this._direction="incoming",this._local_identity=c.to,this._remote_identity=c.from):g==="local"&&(this._direction="outgoing",this._local_identity=c.from,this._remote_identity=c.to),this._ua.newOptions(this,{originator:g,message:this,request:c})}_failed(g,c,A){h.debug("OPTIONS failed"),this._close(),h.debug('emit "failed"'),this.emit("failed",{originator:g,response:c||null,cause:A})}_succeeded(g,c){h.debug("OPTIONS succeeded"),this._close(),h.debug('emit "succeeded"'),this.emit("succeeded",{originator:g,response:c})}},cs}var fs={},Gn;function nl(){if(Gn)return fs;Gn=1;const w=fe(),I=_e(),i=Ce(),_=new w("Socket");return fs.isSocket=R=>{if(Array.isArray(R))return!1;if(typeof R>"u")return _.warn("undefined JsSIP.Socket instance"),!1;try{if(!I.isString(R.url))throw _.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!I.isString(R.via_transport))throw _.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(i.parse(R.sip_uri,"SIP_URI")===-1)throw _.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(t=>{if(!I.isFunction(R[t]))throw _.warn(`missing or invalid JsSIP.Socket method: ${t}`),new Error(`Missing or invalid JsSIP.Socket method: ${t}`)})}catch{return!1}return!0},fs}var hs,Bn;function fi(){if(Bn)return hs;Bn=1;const w=fe(),I=nl(),i=ce(),_=new w("Transport"),R={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:i.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:i.CONNECTION_RECOVERY_MAX_INTERVAL}};return hs=class{constructor(d,h=R.recovery_options){_.debug("new()"),this.status=R.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=h,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(l){_.warn(`cannot use TextDecoder: ${l}`)}if(typeof d>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");d instanceof Array||(d=[d]),d.forEach(function(l){if(!I.isSocket(l.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(l.weight&&!Number(l.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:l.socket,weight:l.weight||0,status:R.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(_.debug("connect()"),this.isConnected()){_.debug("Transport is already connected");return}else if(this.isConnecting()){_.debug("Transport is connecting");return}this.close_requested=!1,this.status=R.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(){_.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=R.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(d){if(_.debug("send()"),!this.isConnected())return _.warn("unable to send message, transport is not connected"),!1;const h=d.toString();return _.debug(`sending message:
43
+ `,this.transport.send(C)}}class R extends m{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}return Xt={OutgoingRequest:h,InitialOutgoingInviteRequest:n,IncomingRequest:c,IncomingResponse:R},Xt}var Qt,Nn;function si(){if(Nn)return Qt;Nn=1;const b=ce(),y=fe(),i=new b("DigestAuthentication");return Qt=class{constructor(S){this._credentials=S,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(S){switch(S){case"realm":return this._realm;case"ha1":return this._ha1;default:i.warn('get() | cannot get "%s" parameter',S);return}}authenticate({method:S,ruri:t,body:d},h,n=null){if(this._algorithm=h.algorithm,this._realm=h.realm,this._nonce=h.nonce,this._opaque=h.opaque,this._stale=h.stale,this._algorithm){if(this._algorithm!=="MD5")return i.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return i.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return i.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return i.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return i.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(h.qop)if(h.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(h.qop.indexOf("auth")>-1)this._qop="auth";else return i.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=S,this._uri=t,this._cnonce=n||y.createRandomToken(12),this._nc+=1;const m=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-m.length)+m,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=y.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let c,R;return this._qop==="auth"?(c=`${this._method}:${this._uri}`,R=y.calculateMD5(c),i.debug('authenticate() | using qop=auth [a2:"%s"]',c),this._response=y.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${R}`)):this._qop==="auth-int"?(c=`${this._method}:${this._uri}:${y.calculateMD5(d||"")}`,R=y.calculateMD5(c),i.debug('authenticate() | using qop=auth-int [a2:"%s"]',c),this._response=y.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${R}`)):this._qop===null&&(c=`${this._method}:${this._uri}`,R=y.calculateMD5(c),i.debug('authenticate() | using qop=null [a2:"%s"]',c),this._response=y.calculateMD5(`${this._ha1}:${this._nonce}:${R}`)),i.debug("authenticate() | response generated"),!0}toString(){const S=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return S.push(`algorithm=${this._algorithm}`),S.push(`username="${this._credentials.username}"`),S.push(`realm="${this._realm}"`),S.push(`nonce="${this._nonce}"`),S.push(`uri="${this._uri}"`),S.push(`response="${this._response}"`),this._opaque&&S.push(`opaque="${this._opaque}"`),this._qop&&(S.push(`qop=${this._qop}`),S.push(`cnonce="${this._cnonce}"`),S.push(`nc=${this._ncHex}`)),`Digest ${S.join(", ")}`}},Qt}var Zt,On;function rl(){if(On)return Zt;On=1;const b=500,y=4e3,i=5e3;return Zt={T1:b,T2:y,T4:i,TIMER_B:64*b,TIMER_D:0*b,TIMER_F:64*b,TIMER_H:64*b,TIMER_I:0*b,TIMER_J:0*b,TIMER_K:0*i,TIMER_L:64*b,TIMER_M:64*b,PROVISIONAL_RESPONSE_INTERVAL:6e4},Zt}var es,Dn;function We(){if(Dn)return es;Dn=1;const b=Ie().EventEmitter,y=ce(),i=oe(),_=Se(),S=rl(),t=new y("NonInviteClientTransaction"),d=new y("InviteClientTransaction"),h=new y("AckClientTransaction"),n=new y("NonInviteServerTransaction"),m=new y("InviteServerTransaction"),c={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 R extends b{constructor(F,H,o,f){super(),this.type=c.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=F,this.transport=H,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},S.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){t.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){t.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(F){const H=F.status_code;if(H<200)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(F);break}else switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),clearTimeout(this.F),H===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(F),this.K=setTimeout(()=>{this.timer_K()},S.TIMER_K);break;case c.STATUS_COMPLETED:break}}}class D extends b{constructor(F,H,o,f){super(),this.type=c.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=F,this.transport=H,this.request=o,this.eventHandlers=f,o.transaction=this;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T),this.ua.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}send(){this.stateChanged(c.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},S.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==c.STATUS_ACCEPTED&&(d.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){d.debug(`Timer M expired for transaction ${this.id}`),this.state===c.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){d.debug(`Timer B expired for transaction ${this.id}`),this.state===c.STATUS_CALLING&&(this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){d.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(F){const H=new _.OutgoingRequest(i.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});H.setHeader("from",this.request.getHeader("from")),H.setHeader("via",this.request.getHeader("via")),H.setHeader("to",F.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},S.TIMER_D),this.transport.send(H)}cancel(F){if(this.state!==c.STATUS_PROCEEDING)return;const H=new _.OutgoingRequest(i.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});H.setHeader("from",this.request.getHeader("from")),H.setHeader("via",this.request.getHeader("via")),H.setHeader("to",this.request.getHeader("to")),F&&H.setHeader("reason",F),this.transport.send(H)}receiveResponse(F){const H=F.status_code;if(H>=100&&H<=199)switch(this.state){case c.STATUS_CALLING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(F);break}else if(H>=200&&H<=299)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},S.TIMER_M),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(F);break}else if(H>=300&&H<=699)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.sendACK(F),this.eventHandlers.onReceiveResponse(F);break;case c.STATUS_COMPLETED:this.sendACK(F);break}}}class E extends b{constructor(F,H,o,f){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=H,this.request=o,this.eventHandlers=f;let T=`SIP/2.0/${H.via_transport}`;T+=` ${F.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",T)}get C(){return c}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){h.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class N extends b{constructor(F,H,o){super(),this.type=c.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=F,this.transport=H,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_TRYING,F.newTransaction(this)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}timer_J(){n.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,n.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(F,H,o,f){if(F===100)switch(this.state){case c.STATUS_TRYING:this.stateChanged(c.STATUS_PROCEEDING),this.transport.send(H)||this.onTransportError();break;case c.STATUS_PROCEEDING:this.last_response=H,this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break}else if(F>=200&&F<=699)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.last_response=H,this.J=setTimeout(()=>{this.timer_J()},S.TIMER_J),this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break;case c.STATUS_COMPLETED:break}}}class $ extends b{constructor(F,H,o){super(),this.type=c.INVITE_SERVER,this.id=o.via_branch,this.ua=F,this.transport=H,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_PROCEEDING,F.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return c}stateChanged(F){this.state=F,this.emit("stateChanged")}timer_H(){m.debug(`Timer H expired for transaction ${this.id}`),this.state===c.STATUS_COMPLETED&&m.debug("ACK not received, dialog will be terminated"),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){m.debug(`Timer L expired for transaction ${this.id}`),this.state===c.STATUS_ACCEPTED&&(this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,m.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(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(F,H,o,f){if(F>=100&&F<=199&&this.state===c.STATUS_PROCEEDING&&(this.transport.send(H)||this.onTransportError(),this.last_response=H),F>100&&F<=199&&this.state===c.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},S.PROVISIONAL_RESPONSE_INTERVAL));else if(F>=200&&F<=299)switch(this.state){case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.last_response=H,this.L=setTimeout(()=>{this.timer_L()},S.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case c.STATUS_ACCEPTED:this.transport.send(H)?o&&o():(this.onTransportError(),f&&f());break}else F>=300&&F<=699&&this.state===c.STATUS_PROCEEDING&&(this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(H)?(this.stateChanged(c.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},S.TIMER_H),o&&o()):(this.onTransportError(),f&&f()))}}function C({_transactions:I},F){let H;switch(F.method){case i.INVITE:if(H=I.ist[F.via_branch],H){switch(H.state){case c.STATUS_PROCEEDING:H.transport.send(H.last_response);break;case c.STATUS_ACCEPTED:break}return!0}break;case i.ACK:if(H=I.ist[F.via_branch],H){if(H.state===c.STATUS_ACCEPTED)return!1;if(H.state===c.STATUS_COMPLETED)return H.state=c.STATUS_CONFIRMED,H.I=setTimeout(()=>{H.timer_I()},S.TIMER_I),!0}else return!1;break;case i.CANCEL:return H=I.ist[F.via_branch],H?(F.reply_sl(200),H.state!==c.STATUS_PROCEEDING):(F.reply_sl(481),!0);default:if(H=I.nist[F.via_branch],H){switch(H.state){case c.STATUS_TRYING:break;case c.STATUS_PROCEEDING:case c.STATUS_COMPLETED:H.transport.send(H.last_response);break}return!0}break}}return es={C:c,NonInviteClientTransaction:R,InviteClientTransaction:D,AckClientTransaction:E,NonInviteServerTransaction:N,InviteServerTransaction:$,checkTransaction:C},es}var ts,Un;function Ve(){if(Un)return ts;Un=1;const b=ce(),y=oe(),i=si(),_=We(),S=new b("RequestSender"),t={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};return ts=class{constructor(h,n,m){this._ua=h,this._eventHandlers=m,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1;for(const c in t)Object.prototype.hasOwnProperty.call(t,c)&&(this._eventHandlers[c]||(this._eventHandlers[c]=t[c]));h.status===h.C.STATUS_USER_CLOSED&&(this._method!==y.BYE||this._method!==y.ACK)&&this._eventHandlers.onTransportError()}send(){const h={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:n=>{this._receiveResponse(n)}};switch(this._method){case"INVITE":this.clientTransaction=new _.InviteClientTransaction(this._ua,this._ua.transport,this._request,h);break;case"ACK":this.clientTransaction=new _.AckClientTransaction(this._ua,this._ua.transport,this._request,h);break;default:this.clientTransaction=new _.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,h)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(h){let n,m;const c=h.status_code;if((c===401||c===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(h.status_code===401?(n=h.parseHeader("www-authenticate"),m="authorization"):(n=h.parseHeader("proxy-authenticate"),m="proxy-authorization"),!n){S.debug(`${h.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(h);return}if(!this._challenged||!this._staled&&n.stale===!0){if(this._auth||(this._auth=new i({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,n)){this._eventHandlers.onReceiveResponse(h);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),n.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(m,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(h)}else this._eventHandlers.onReceiveResponse(h)}},ts}var ss,Pn;function ri(){if(Pn)return ss;Pn=1;const b=ce(),y=fe(),i=oe(),_=Se(),S=Ve(),t=new b("Registrator"),d=10;return ss=class{constructor(n,m){this._reg_id=1,this._ua=n,this._transport=m,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=y.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 m in n)if(Object.prototype.hasOwnProperty.call(n,m)){const c=n[m];this._extraContactParams+=`;${m}`,c&&(this._extraContactParams+=`=${c}`)}}register(){if(this._registering){t.debug("Register request in progress...");return}const n=this._extraHeaders.slice();let m;this._expires?(m=`${this._contact};expires=${this._expires}${this._extraContactParams}`,n.push(`Expires: ${this._expires}`)):m=`${this._contact}${this._extraContactParams}`,n.push(`Contact: ${m}`);let c=y.newTag();this._ua.configuration.register_from_tag_trail&&(typeof this._ua.configuration.register_from_tag_trail=="function"?c+=this._ua.configuration.register_from_tag_trail():c+=this._ua.configuration.register_from_tag_trail);const R=new _.OutgoingRequest(i.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1,from_tag:c},n),D=new S(this._ua,R,{onRequestTimeout:()=>{this._registrationFailure(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:E=>{if(E.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(E.status_code):break;case/^2[0-9]{2}$/.test(E.status_code):{if(this._registering=!1,!E.hasHeader("Contact")){t.debug("no Contact header in response to REGISTER, response ignored");break}const N=E.headers.Contact.reduce((F,H)=>F.concat(H.parsed),[]);let $=N.find(F=>this._sipInstance===F.getParam("+sip.instance")&&this._reg_id===parseInt(F.getParam("reg-id")));if($||($=N.find(F=>F.uri.user===this._ua.contact.uri.user)),!$){t.debug("no Contact header pointing to us, response ignored");break}let C=$.getParam("expires");!C&&E.hasHeader("expires")&&(C=E.getHeader("expires")),C||(C=this._expires),C=Number(C),C<d&&(C=d);const I=C>64?C*1e3/2+Math.floor((C/2-32)*1e3*Math.random()):C*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},I),$.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=$.getParam("temp-gruu").replace(/"/g,"")),$.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=$.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:E}));break}case/^423$/.test(E.status_code):{E.hasHeader("min-expires")?(this._expires=Number(E.getHeader("min-expires")),this._expires<d&&(this._expires=d),this._registering=!1,this.register()):(t.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(E,i.causes.SIP_FAILURE_CODE));break}default:{const N=y.sipErrorCause(E.status_code);this._registrationFailure(E,N)}}}});this._registering=!0,D.send()}unregister(n={}){if(!this._registered){t.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const m=this._extraHeaders.slice();n.all?m.push(`Contact: *${this._extraContactParams}`):m.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),m.push("Expires: 0");const c=new _.OutgoingRequest(i.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},m);new S(this._ua,c,{onRequestTimeout:()=>{this._unregistered(null,i.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,i.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:D=>{switch(!0){case/^1[0-9]{2}$/.test(D.status_code):break;case/^2[0-9]{2}$/.test(D.status_code):this._unregistered(D);break;default:{const E=y.sipErrorCause(D.status_code);this._unregistered(D,E)}}}}).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,m){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:m}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:m}))}_unregistered(n,m){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:m||null})}},ss}var rs,Mn;function ni(){if(Mn)return rs;Mn=1;const b=oe(),y=We(),i=Ve(),_={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};return rs=class{constructor(t,d,h){this._dialog=t,this._ua=t._ua,this._request=d,this._eventHandlers=h,this._reattempt=!1,this._reattemptTimer=null;for(const n in _)Object.prototype.hasOwnProperty.call(_,n)&&(this._eventHandlers[n]||(this._eventHandlers[n]=_[n]))}get request(){return this._request}send(){const t=new i(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:d=>{this._eventHandlers.onAuthenticated(d)},onReceiveResponse:d=>{this._receiveResponse(d)}});if(t.send(),(this._request.method===b.INVITE||this._request.method===b.UPDATE&&this._request.body)&&t.clientTransaction.state!==y.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const d=()=>{(t.clientTransaction.state===y.C.STATUS_ACCEPTED||t.clientTransaction.state===y.C.STATUS_COMPLETED||t.clientTransaction.state===y.C.STATUS_TERMINATED)&&(t.clientTransaction.removeListener("stateChanged",d),this._dialog.uac_pending_reply=!1)};t.clientTransaction.on("stateChanged",d)}}_receiveResponse(t){t.status_code===408||t.status_code===481?this._eventHandlers.onDialogError(t):t.method===b.INVITE&&t.status_code===491?this._reattempt?this._eventHandlers.onErrorResponse(t):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):t.status_code>=200&&t.status_code<300?this._eventHandlers.onSuccessResponse(t):t.status_code>=300&&this._eventHandlers.onErrorResponse(t)}},rs}var ns,Ln;function li(){if(Ln)return ns;Ln=1;const b=ce(),y=Se(),i=oe(),_=We(),S=ni(),t=fe(),d=new b("Dialog"),h={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};return ns=class{static get C(){return h}constructor(m,c,R,D=h.STATUS_CONFIRMED){if(this._owner=m,this._ua=m._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!c.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};c instanceof y.IncomingResponse&&(D=c.status_code<200?h.STATUS_EARLY:h.STATUS_CONFIRMED);const E=c.parseHeader("contact");R==="UAS"?(this._id={call_id:c.call_id,local_tag:c.to_tag,remote_tag:c.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=D,this._remote_seqnum=c.cseq,this._local_uri=c.parseHeader("to").uri,this._remote_uri=c.parseHeader("from").uri,this._remote_target=E.uri,this._route_set=c.getHeaders("record-route"),this.incoming_ack_seqnum=c.cseq,this.outgoing_ack_seqnum=null):R==="UAC"&&(this._id={call_id:c.call_id,local_tag:c.from_tag,remote_tag:c.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=D,this._local_seqnum=c.cseq,this._local_uri=c.parseHeader("from").uri,this._remote_uri=c.parseHeader("to").uri,this._remote_target=E.uri,this._route_set=c.getHeaders("record-route").reverse(),this.incoming_ack_seqnum=null,this.outgoing_ack_seqnum=this._local_seqnum),this._ua.newDialog(this),d.debug(`new ${R} dialog created with status ${this._state===h.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(m){this._local_seqnum=m}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(m){this._uac_pending_reply=m}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===h.STATUS_TERMINATED}update(m,c){this._state=h.STATUS_CONFIRMED,d.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),c==="UAC"&&(this._route_set=m.getHeaders("record-route").reverse())}terminate(){d.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=h.STATUS_TERMINATED}sendRequest(m,c={}){const R=t.cloneArray(c.extraHeaders),D=t.cloneObject(c.eventHandlers),E=c.body||null,N=this._createRequest(m,R,E);return D.onAuthenticated=()=>{this._local_seqnum+=1,N.method===i.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum)},new S(this,N,D).send(),N}receiveRequest(m){this._checkInDialogRequest(m)&&(m.method===i.ACK&&this.incoming_ack_seqnum!==null?this.incoming_ack_seqnum=null:m.method===i.INVITE&&(this.incoming_ack_seqnum=m.cseq),this._owner.receiveRequest(m))}_createRequest(m,c,R){c=t.cloneArray(c),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const D=m===i.CANCEL||m===i.ACK?this.outgoing_ack_seqnum:this._local_seqnum+=1;return m===i.INVITE&&(this.outgoing_ack_seqnum=D),new y.OutgoingRequest(m,this._remote_target,this._ua,{cseq:D,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},c,R)}_checkInDialogRequest(m){if(!this._remote_seqnum)this._remote_seqnum=m.cseq;else if(m.cseq<this._remote_seqnum)if(m.method===i.ACK){if(this.incoming_ack_seqnum===null||m.cseq!==this.incoming_ack_seqnum)return!1}else return m.reply(500),!1;else m.cseq>this._remote_seqnum&&(this._remote_seqnum=m.cseq);if(m.method===i.INVITE||m.method===i.UPDATE&&m.body){if(this._uac_pending_reply===!0)m.reply(491);else if(this._uas_pending_reply===!0){const c=(Math.random()*10|0)+1;return m.reply(500,null,[`Retry-After:${c}`]),!1}else{this._uas_pending_reply=!0;const c=()=>{(m.server_transaction.state===_.C.STATUS_ACCEPTED||m.server_transaction.state===_.C.STATUS_COMPLETED||m.server_transaction.state===_.C.STATUS_TERMINATED)&&(m.server_transaction.removeListener("stateChanged",c),this._uas_pending_reply=!1)};m.server_transaction.on("stateChanged",c)}m.hasHeader("contact")&&m.server_transaction.on("stateChanged",()=>{m.server_transaction.state===_.C.STATUS_ACCEPTED&&(this._remote_target=m.parseHeader("contact").uri)})}else m.method===i.NOTIFY&&m.hasHeader("contact")&&m.server_transaction.on("stateChanged",()=>{m.server_transaction.state===_.C.STATUS_COMPLETED&&(this._remote_target=m.parseHeader("contact").uri)});return!0}},ns}var ht={exports:{}},Fn;function ii(){if(Fn)return ht.exports;Fn=1;const b=Ie().EventEmitter,y=ce(),i=oe(),_=we(),S=fe(),t=new y("RTCSession:DTMF"),d={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};return ht.exports=class extends b{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,m={}){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 _.InvalidStateError(this._session.status);const c=S.cloneArray(m.extraHeaders);if(this.eventHandlers=S.cloneObject(m.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=m.duration,c.push("Content-Type: application/dtmf-relay");let R=`Signal=${this._tone}\r
44
+ `;R+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(i.INFO,{extraHeaders:c,eventHandlers:{onSuccessResponse:D=>{this.emit("succeeded",{originator:"remote",response:D})},onErrorResponse:D=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:D})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:R})}init_incoming(n){const m=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,c=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=n,n.reply(200),n.body){const R=n.body.split(`
45
+ `);R.length>=1&&m.test(R[0])&&(this._tone=R[0].replace(m,"$2")),R.length>=2&&c.test(R[1])&&(this._duration=parseInt(R[1].replace(c,"$2"),10))}this._duration||(this._duration=d.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:n}):t.debug("invalid INFO DTMF received, discarded")}},ht.exports.C=d,ht.exports}var ls,Hn;function ai(){if(Hn)return ls;Hn=1;const b=Ie().EventEmitter,y=oe(),i=we(),_=fe();return ls=class extends b{constructor(t){super(),this._session=t,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(t,d,h={}){if(this._direction="outgoing",t===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 i.InvalidStateError(this._session.status);this._contentType=t,this._body=d;const n=_.cloneArray(h.extraHeaders);n.push(`Content-Type: ${t}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(y.INFO,{extraHeaders:n,eventHandlers:{onSuccessResponse:m=>{this.emit("succeeded",{originator:"remote",response:m})},onErrorResponse:m=>{this.emit("failed",{originator:"remote",response:m})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:d})}init_incoming(t){this._direction="incoming",this.request=t,t.reply(200),this._contentType=t.hasHeader("Content-Type")?t.getHeader("Content-Type").toLowerCase():void 0,this._body=t.body,this._session.newInfo({originator:"remote",info:this,request:t})}},ls}var is,$n;function oi(){if($n)return is;$n=1;const b=ce(),y=oe(),i=new b("RTCSession:ReferNotifier"),_={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};return is=class{constructor(t,d,h){this._session=t,this._id=d,this._expires=h||_.expires,this._active=!0,this.notify(100)}notify(t,d){if(i.debug("notify()"),this._active===!1)return;d=d||y.REASON_PHRASE[t]||"";let h;t>=200?h="terminated;reason=noresource":h=`active;expires=${this._expires}`,this._session.sendRequest(y.NOTIFY,{extraHeaders:[`Event: ${_.event_type};id=${this._id}`,`Subscription-State: ${h}`,`Content-Type: ${_.body_type}`],body:`SIP/2.0 ${t} ${d}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}},is}var as,kn;function ui(){if(kn)return as;kn=1;const b=Ie().EventEmitter,y=ce(),i=oe(),_=Ce(),S=fe(),t=new y("RTCSession:ReferSubscriber");return as=class extends b{constructor(h){super(),this._id=null,this._session=h}get id(){return this._id}sendRefer(h,n={}){t.debug("sendRefer()");const m=S.cloneArray(n.extraHeaders),c=S.cloneObject(n.eventHandlers);for(const N in c)Object.prototype.hasOwnProperty.call(c,N)&&this.on(N,c[N]);let R=null;n.replaces&&(R=n.replaces._request.call_id,R+=`;to-tag=${n.replaces._to_tag}`,R+=`;from-tag=${n.replaces._from_tag}`,R=encodeURIComponent(R));const D=`Refer-To: <${h}${R?`?Replaces=${R}`:""}>`;if(m.push(D),!m.some(N=>N.toLowerCase().startsWith("referred-by:"))){const N=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;m.push(N)}m.push(`Contact: ${this._session.contact}`);const E=this._session.sendRequest(i.REFER,{extraHeaders:m,eventHandlers:{onSuccessResponse:N=>{this._requestSucceeded(N)},onErrorResponse:N=>{this._requestFailed(N,i.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,i.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,i.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,i.causes.DIALOG_ERROR)}}});this._id=E.cseq}receiveNotify(h){if(t.debug("receiveNotify()"),!h.body)return;const n=_.parse(h.body.trim().split(`\r
46
+ `,1)[0],"Status_Line");if(n===-1){t.debug(`receiveNotify() | error parsing NOTIFY body: "${h.body}"`);return}switch(!0){case/^100$/.test(n.status_code):this.emit("trying",{request:h,status_line:n});break;case/^1[0-9]{2}$/.test(n.status_code):this.emit("progress",{request:h,status_line:n});break;case/^2[0-9]{2}$/.test(n.status_code):this.emit("accepted",{request:h,status_line:n});break;default:this.emit("failed",{request:h,status_line:n});break}}_requestSucceeded(h){t.debug("REFER succeeded"),t.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:h})}_requestFailed(h,n){t.debug("REFER failed"),t.debug('emit "requestFailed"'),this.emit("requestFailed",{response:h||null,cause:n})}},as}var os,qn;function nl(){if(qn)return os;qn=1;const b=Ie().EventEmitter,y=sl(),i=ce(),_=oe(),S=we(),t=We(),d=fe(),h=rl(),n=Se(),m=li(),c=Ve(),R=ii(),D=ai(),E=oi(),N=ui(),$=ye(),C=new i("RTCSession"),I={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},F=["audio","video"];return os=class Es extends b{static get C(){return I}constructor(o){C.debug("new"),super(),this._id=null,this._ua=o,this._status=I.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:_.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return I}get causes(){return _.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(o){this._data=o}get status(){return this._status}isInProgress(){switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:case I.STATUS_INVITE_RECEIVED:case I.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case I.STATUS_ANSWERED:case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case I.STATUS_CANCELED:case I.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(o,f={},T){C.debug("connect()");const p=o,A=d.cloneObject(f.eventHandlers),O=d.cloneArray(f.extraHeaders),v=d.cloneObject(f.mediaConstraints,{audio:!0,video:!0}),w=f.mediaStream||null,U=d.cloneObject(f.pcConfig,{iceServers:[]}),M=f.rtcConstraints||null,Y=f.rtcOfferConstraints||null;if(this._rtcOfferConstraints=Y,this._rtcAnswerConstraints=f.rtcAnswerConstraints||null,this._data=f.data||this._data,o===void 0)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_NULL)throw new S.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new S.NotSupportedError("WebRTC not supported");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${p}`);this._sessionTimers.enabled&&d.isDecimal(f.sessionTimersExpires)&&(f.sessionTimersExpires>=_.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=f.sessionTimersExpires:this._sessionTimers.defaultExpires=_.SESSION_EXPIRES);for(const de in A)Object.prototype.hasOwnProperty.call(A,de)&&this.on(de,A[de]);this._from_tag=d.newTag();const B=f.anonymous||!1,ue={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:B,outbound:!0}),B?(ue.from_display_name="Anonymous",ue.from_uri=new $("sip","anonymous","anonymous.invalid"),O.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),O.push("Privacy: id")):f.fromUserName&&(ue.from_uri=new $("sip",f.fromUserName,this._ua.configuration.uri.host),O.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),f.fromDisplayName&&(ue.from_display_name=f.fromDisplayName),O.push(`Contact: ${this._contact}`),O.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&O.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new n.InitialOutgoingInviteRequest(o,this._ua,ue,O),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(U,M),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,T&&T(this),this._newRTCSession("local",this._request),this._sendInitialRequest(v,Y,w)}init_incoming(o,f){C.debug("init_incoming()");let T;const p=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;if(o.body&&p!=="application/sdp"){o.reply(415);return}if(this._status=I.STATUS_INVITE_RECEIVED,this._from_tag=o.from_tag,this._id=o.call_id+this._from_tag,this._request=o,this._contact=this._ua.contact.toString(),o.hasHeader("expires")&&(T=o.getHeader("expires")*1e3),o.to_tag=d.newTag(),!this._createDialog(o,"UAS",!0)){o.reply(500,"Missing Contact header field");return}o.body?this._late_sdp=!1:this._late_sdp=!0,this._status=I.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{o.reply(408),this._failed("local",null,_.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),T&&(this._timers.expiresTimer=setTimeout(()=>{this._status===I.STATUS_WAITING_FOR_ANSWER&&(o.reply(487),this._failed("system",null,_.causes.EXPIRES))},T)),this._direction="incoming",this._local_identity=o.to,this._remote_identity=o.from,f&&f(this),this._newRTCSession("remote",o),this._status!==I.STATUS_TERMINATED&&(o.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(o={}){C.debug("answer()");const f=this._request,T=d.cloneArray(o.extraHeaders),p=d.cloneObject(o.mediaConstraints),A=o.mediaStream||null,O=d.cloneObject(o.pcConfig,{iceServers:[]}),v=o.rtcConstraints||null,w=o.rtcAnswerConstraints||null,U=d.cloneObject(o.rtcOfferConstraints);let M,Y=!1,B=!1,ue=!1,de=!1;if(this._rtcAnswerConstraints=w,this._rtcOfferConstraints=o.rtcOfferConstraints||null,this._data=o.data||this._data,this._direction!=="incoming")throw new S.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==I.STATUS_WAITING_FOR_ANSWER)throw new S.InvalidStateError(this._status);if(this._sessionTimers.enabled&&d.isDecimal(o.sessionTimersExpires)&&(o.sessionTimersExpires>=_.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=o.sessionTimersExpires:this._sessionTimers.defaultExpires=_.SESSION_EXPIRES),this._status=I.STATUS_ANSWERED,!this._createDialog(f,"UAS")){f.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),T.unshift(`Contact: ${this._contact}`);const he=f.parseSDP();Array.isArray(he.media)||(he.media=[he.media]);for(const X of he.media)X.type==="audio"&&(Y=!0,(!X.direction||X.direction==="sendrecv")&&(ue=!0)),X.type==="video"&&(B=!0,(!X.direction||X.direction==="sendrecv")&&(de=!0));if(A&&p.audio===!1){M=A.getAudioTracks();for(const X of M)A.removeTrack(X)}if(A&&p.video===!1){M=A.getVideoTracks();for(const X of M)A.removeTrack(X)}!A&&p.audio===void 0&&(p.audio=ue),!A&&p.video===void 0&&(p.video=de),!A&&!Y&&!U.offerToReceiveAudio&&(p.audio=!1),!A&&!B&&!U.offerToReceiveVideo&&(p.video=!1),this._createRTCConnection(O,v),Promise.resolve().then(()=>{if(A)return A;if(p.audio||p.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(p).catch(X=>{throw this._status===I.STATUS_TERMINATED?new Error("terminated"):(f.reply(480),this._failed("local",null,_.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',X),this.emit("getusermediafailed",X),new Error("getUserMedia() failed"))})}).then(X=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=X,X&&X.getTracks().forEach(_e=>{this._connection.addTrack(_e,X)})}).then(()=>{if(this._late_sdp)return;const X={originator:"remote",type:"offer",sdp:f.body};C.debug('emit "sdp"'),this.emit("sdp",X);const _e=new RTCSessionDescription({type:"offer",sdp:X.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(_e)).catch(Q=>{throw f.reply(488),this._failed("system",null,_.causes.WEBRTC_ERROR),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',Q),this.emit("peerconnection:setremotedescriptionfailed",Q),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(f),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",w).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")})}).then(X=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(f,T),f.reply(200,null,T,X,()=>{this._status=I.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(f,X),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,_.causes.CONNECTION_ERROR)})}).catch(X=>{this._status!==I.STATUS_TERMINATED&&(C.warn(`answer() failed: ${X.message}`),this._failed("system",X.message,_.causes.INTERNAL_ERROR))})}terminate(o={}){C.debug("terminate()");const f=o.cause||_.causes.BYE,T=d.cloneArray(o.extraHeaders),p=o.body;let A,O=o.status_code,v=o.reason_phrase;if(this._status===I.STATUS_TERMINATED)throw new S.InvalidStateError(this._status);switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:if(C.debug("canceling session"),O&&(O<200||O>=700))throw new TypeError(`Invalid status_code: ${O}`);O&&(v=v||_.REASON_PHRASE[O]||"",A=`SIP ;cause=${O} ;text="${v}"`),this._status===I.STATUS_NULL||this._status===I.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=A):this._status===I.STATUS_1XX_RECEIVED&&this._request.cancel(A),this._status=I.STATUS_CANCELED,this._failed("local",null,_.causes.CANCELED);break;case I.STATUS_WAITING_FOR_ANSWER:case I.STATUS_ANSWERED:if(C.debug("rejecting session"),O=O||480,O<300||O>=700)throw new TypeError(`Invalid status_code: ${O}`);this._request.reply(O,v,T,p),this._failed("local",null,_.causes.REJECTED);break;case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:if(C.debug("terminating session"),v=o.reason_phrase||_.REASON_PHRASE[O]||"",O&&(O<200||O>=700))throw new TypeError(`Invalid status_code: ${O}`);if(O&&T.push(`Reason: SIP ;cause=${O}; text="${v}"`),this._status===I.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==t.C.STATUS_TERMINATED){const w=this._dialog;this.receiveRequest=({method:U})=>{U===_.ACK&&(this.sendRequest(_.BYE,{extraHeaders:T,body:p}),w.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===t.C.STATUS_TERMINATED&&(this.sendRequest(_.BYE,{extraHeaders:T,body:p}),w.terminate())}),this._ended("local",null,f),this._dialog=w,this._ua.newDialog(w)}else this.sendRequest(_.BYE,{extraHeaders:T,body:p}),this._ended("local",null,f)}}sendDTMF(o,f={}){C.debug("sendDTMF() | tones: %s",o);let T=f.duration||null,p=f.interToneGap||null;const A=f.transportType||_.DTMF_TRANSPORT.INFO;if(o===void 0)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new S.InvalidStateError(this._status);if(A!==_.DTMF_TRANSPORT.INFO&&A!==_.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${A}`);if(typeof o=="number"&&(o=o.toString()),!o||typeof o!="string"||!o.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${o}`);if(T&&!d.isDecimal(T))throw new TypeError(`Invalid tone duration: ${T}`);if(T?T<R.C.MIN_DURATION?(C.debug(`"duration" value is lower than the minimum allowed, setting it to ${R.C.MIN_DURATION} milliseconds`),T=R.C.MIN_DURATION):T>R.C.MAX_DURATION?(C.debug(`"duration" value is greater than the maximum allowed, setting it to ${R.C.MAX_DURATION} milliseconds`),T=R.C.MAX_DURATION):T=Math.abs(T):T=R.C.DEFAULT_DURATION,f.duration=T,p&&!d.isDecimal(p))throw new TypeError(`Invalid interToneGap: ${p}`);if(p?p<R.C.MIN_INTER_TONE_GAP?(C.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${R.C.MIN_INTER_TONE_GAP} milliseconds`),p=R.C.MIN_INTER_TONE_GAP):p=Math.abs(p):p=R.C.DEFAULT_INTER_TONE_GAP,A===_.DTMF_TRANSPORT.RFC2833){const v=this._getDTMFRTPSender();v&&(o=v.toneBuffer+o,v.insertDTMF(o,T,p));return}if(this._tones){this._tones+=o;return}this._tones=o,O.call(this);function O(){let v;if(this._status===I.STATUS_TERMINATED||!this._tones){this._tones=null;return}const w=this._tones[0];if(this._tones=this._tones.substring(1),w===",")v=2e3;else{const U=new R(this);f.eventHandlers={onFailed:()=>{this._tones=null}},U.send(w,f),v=T+p}setTimeout(O.bind(this),v)}}sendInfo(o,f,T={}){if(C.debug("sendInfo()"),this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new S.InvalidStateError(this._status);new D(this).send(o,f,T)}mute(o={audio:!0,video:!1}){C.debug("mute()");let f=!1,T=!1;this._audioMuted===!1&&o.audio&&(f=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&o.video&&(T=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(f===!0||T===!0)&&this._onmute({audio:f,video:T})}unmute(o={audio:!0,video:!0}){C.debug("unmute()");let f=!1,T=!1;this._audioMuted===!0&&o.audio&&(f=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&o.video&&(T=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(f===!0||T===!0)&&this._onunmute({audio:f,video:T})}hold(o={},f){if(C.debug("hold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED||this._localHold===!0||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:T,extraHeaders:o.extraHeaders}),!0}unhold(o={},f){if(C.debug("unhold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED||this._localHold===!1||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const T={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:T,extraHeaders:o.extraHeaders}),!0}renegotiate(o={},f){C.debug("renegotiate()");const T=o.rtcOfferConstraints||null;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;const p={succeeded:()=>{f&&f()},failed:()=>{this.terminate({cause:_.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),o.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:p,rtcOfferConstraints:T,extraHeaders:o.extraHeaders}),!0}refer(o,f){C.debug("refer()");const T=o;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(o=this._ua.normalizeTarget(o),!o)throw new TypeError(`Invalid target: ${T}`);const p=new N(this);p.sendRefer(o,f);const A=p.id;return this._referSubscribers[A]=p,p.on("requestFailed",()=>{delete this._referSubscribers[A]}),p.on("accepted",()=>{delete this._referSubscribers[A]}),p.on("failed",()=>{delete this._referSubscribers[A]}),p}sendRequest(o,f){if(C.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(o,f);{const T=Object.values(this._earlyDialogs);if(T.length>0)return T[0].sendRequest(o,f);C.warn("sendRequest() | no valid early dialog found");return}}receiveRequest(o){if(C.debug("receiveRequest()"),o.method===_.CANCEL)(this._status===I.STATUS_WAITING_FOR_ANSWER||this._status===I.STATUS_ANSWERED)&&(this._status=I.STATUS_CANCELED,this._request.reply(487),this._failed("remote",o,_.causes.CANCELED));else switch(o.method){case _.ACK:if(this._status!==I.STATUS_WAITING_FOR_ACK)return;if(this._status=I.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!o.body){this.terminate({cause:_.causes.MISSING_SDP,status_code:400});break}const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>{this._is_confirmed||this._confirmed("remote",o)}).catch(p=>{this.terminate({cause:_.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)})}else this._is_confirmed||this._confirmed("remote",o);break;case _.BYE:this._status===I.STATUS_CONFIRMED||this._status===I.STATUS_WAITING_FOR_ACK?(o.reply(200),this._ended("remote",o,_.causes.BYE)):this._status===I.STATUS_INVITE_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER?(o.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",o,_.causes.BYE)):o.reply(403,"Wrong Status");break;case _.INVITE:this._status===I.STATUS_CONFIRMED?o.hasHeader("replaces")?this._receiveReplaces(o):this._receiveReinvite(o):o.reply(403,"Wrong Status");break;case _.INFO:if(this._status===I.STATUS_1XX_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER||this._status===I.STATUS_ANSWERED||this._status===I.STATUS_WAITING_FOR_ACK||this._status===I.STATUS_CONFIRMED){const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;f&&f.match(/^application\/dtmf-relay/i)?new R(this).init_incoming(o):f!==void 0?new D(this).init_incoming(o):o.reply(415)}else o.reply(403,"Wrong Status");break;case _.UPDATE:this._status===I.STATUS_CONFIRMED?this._receiveUpdate(o):o.reply(403,"Wrong Status");break;case _.REFER:this._status===I.STATUS_CONFIRMED?this._receiveRefer(o):o.reply(403,"Wrong Status");break;case _.NOTIFY:this._status===I.STATUS_CONFIRMED?this._receiveNotify(o):o.reply(403,"Wrong Status");break;default:o.reply(501)}}onTransportError(){C.warn("onTransportError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_.causes.CONNECTION_ERROR,cause:_.causes.CONNECTION_ERROR})}onRequestTimeout(){C.warn("onRequestTimeout()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:_.causes.REQUEST_TIMEOUT,cause:_.causes.REQUEST_TIMEOUT})}onDialogError(){C.warn("onDialogError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_.causes.DIALOG_ERROR,cause:_.causes.DIALOG_ERROR})}newDTMF(o){C.debug("newDTMF()"),this.emit("newDTMF",o)}newInfo(o){C.debug("newInfo()"),this.emit("newInfo",o)}isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(C.debug("isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(C.debug("isReadyToReOffer() | session not established yet"),!1):(C.debug("isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(C.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(C.debug("close() | closing local MediaStream"),d.closeMediaStream(this._localMediaStream)),this._status!==I.STATUS_TERMINATED){if(this._status=I.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(o){C.warn("close() | error closing the RTCPeerConnection: %o",o)}for(const o in this._timers)Object.prototype.hasOwnProperty.call(this._timers,o)&&clearTimeout(this._timers[o]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const o in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,o)&&(this._earlyDialogs[o].terminate(),delete this._earlyDialogs[o]);for(const o in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,o)&&delete this._referSubscribers[o];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(o,f){let T=h.T1;function p(){this._status===I.STATUS_WAITING_FOR_ACK&&(o.reply(200,null,[`Contact: ${this._contact}`],f),T<h.T2&&(T=T*2,T>h.T2&&(T=h.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),T))}this._timers.invite2xxTimer=setTimeout(p.bind(this),T)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===I.STATUS_WAITING_FOR_ACK&&(C.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(_.BYE),this._ended("remote",null,_.causes.NO_ACK))},h.TIMER_H)}_createRTCConnection(o,f){this._connection=new RTCPeerConnection(o,f),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:_.causes.RTP_TIMEOUT,status_code:408,reason_phrase:_.causes.RTP_TIMEOUT})}),C.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(o,f){if(C.debug("createLocalDescription()"),o!=="offer"&&o!=="answer")throw new Error(`createLocalDescription() | invalid type "${o}"`);const T=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>o==="offer"?T.createOffer(f).catch(p=>(C.warn('emit "peerconnection:createofferfailed" [error:%o]',p),this.emit("peerconnection:createofferfailed",p),Promise.reject(p))):T.createAnswer(f).catch(p=>(C.warn('emit "peerconnection:createanswerfailed" [error:%o]',p),this.emit("peerconnection:createanswerfailed",p),Promise.reject(p)))).then(p=>T.setLocalDescription(p).catch(A=>(this._rtcReady=!0,C.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',A),this.emit("peerconnection:setlocaldescriptionfailed",A),Promise.reject(A)))).then(()=>{const p=f&&f.iceRestart;if(T.iceGatheringState==="complete"&&!p||T.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const A={originator:"local",type:o,sdp:T.localDescription.sdp};return C.debug('emit "sdp"'),this.emit("sdp",A),Promise.resolve(A.sdp)}return new Promise(A=>{let O=!1,v,w;this._iceReady=!1;const U=()=>{if(O)return;T.removeEventListener("icecandidate",v),T.removeEventListener("icegatheringstatechange",w),O=!0,this._rtcReady=!0,this._iceReady=!0;const M={originator:"local",type:o,sdp:T.localDescription.sdp};C.debug('emit "sdp"'),this.emit("sdp",M),A(M.sdp)};T.addEventListener("icecandidate",v=M=>{const Y=M.candidate;Y?this.emit("icecandidate",{candidate:Y,ready:U}):U()}),T.addEventListener("icegatheringstatechange",w=()=>{T.iceGatheringState==="complete"&&U()})})})}_createDialog(o,f,T){const p=f==="UAS"?o.to_tag:o.from_tag,A=f==="UAS"?o.from_tag:o.to_tag,O=o.call_id+p+A;let v=this._earlyDialogs[O];if(T)return v?!0:(v=new m(this,o,f,m.C.STATUS_EARLY),v.error?(C.debug(v.error),this._failed("remote",o,_.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[O]=v,!0));{if(this._from_tag=o.from_tag,this._to_tag=o.to_tag,v)return v.update(o,f),this._dialog=v,delete this._earlyDialogs[O],!0;const w=new m(this,o,f);return w.error?(C.debug(w.error),this._failed("remote",o,_.causes.INTERNAL_ERROR),!1):(this._dialog=w,!0)}}_receiveReinvite(o){C.debug("receiveReinvite()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,T={request:o,callback:void 0,reject:A.bind(this)};let p=!1;function A(v={}){p=!0;const w=v.status_code||403,U=v.reason_phrase||"",M=d.cloneArray(v.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(w<300||w>=700)throw new TypeError(`Invalid status_code: ${w}`);o.reply(w,U,M)}if(this.emit("reinvite",T),p)return;if(this._late_sdp=!1,!o.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(v=>{O.call(this,v)}).catch(()=>{o.reply(500)});return}if(f!=="application/sdp"){C.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(v=>{this._status!==I.STATUS_TERMINATED&&O.call(this,v)}).catch(v=>{C.warn(v)});function O(v){const w=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,w),this._late_sdp&&(v=this._mangleOffer(v)),o.reply(200,null,w,v,()=>{this._status=I.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(o,v),this._setACKTimer()}),typeof T.callback=="function"&&T.callback()}}_receiveUpdate(o){C.debug("receiveUpdate()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,T={request:o,callback:void 0,reject:A.bind(this)};let p=!1;function A(v={}){p=!0;const w=v.status_code||403,U=v.reason_phrase||"",M=d.cloneArray(v.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(w<300||w>=700)throw new TypeError(`Invalid status_code: ${w}`);o.reply(w,U,M)}if(this.emit("update",T),p)return;if(!o.body){O.call(this,null);return}if(f!=="application/sdp"){C.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(v=>{this._status!==I.STATUS_TERMINATED&&O.call(this,v)}).catch(v=>{C.warn(v)});function O(v){const w=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,w),o.reply(200,null,w,v),typeof T.callback=="function"&&T.callback()}}_processInDialogSdpOffer(o){C.debug("_processInDialogSdpOffer()");const f=o.parseSDP();let T=!1;for(const O of f.media){if(F.indexOf(O.type)===-1)continue;const v=O.direction||f.direction||"sendrecv";if(v==="sendonly"||v==="inactive")T=!0;else{T=!1;break}}const p={originator:"remote",type:"offer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",p);const A=new RTCSessionDescription({type:"offer",sdp:p.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(A).catch(O=>{throw o.reply(488),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',O),this.emit("peerconnection:setremotedescriptionfailed",O),O})}).then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&T===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&T===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(O=>{throw o.reply(500),C.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',O),O})}).catch(O=>{C.warn("_processInDialogSdpOffer() failed [error: %o]",O)}),this._connectionPromiseQueue}_receiveRefer(o){if(C.debug("receiveRefer()"),!o.refer_to){C.debug("no Refer-To header field present in REFER"),o.reply(400);return}if(o.refer_to.uri.scheme!==_.SIP){C.debug("Refer-To header field points to a non-SIP URI scheme"),o.reply(416);return}o.reply(202);const f=new E(this,o.cseq);C.debug('emit "refer"'),this.emit("refer",{request:o,accept:(A,O)=>{T.call(this,A,O)},reject:()=>{p.call(this)}});function T(A,O={}){if(A=typeof A=="function"?A:null,this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;const v=new Es(this._ua);if(v.on("progress",({response:w})=>{f.notify(w.status_code,w.reason_phrase)}),v.on("accepted",({response:w})=>{f.notify(w.status_code,w.reason_phrase)}),v.on("_failed",({message:w,cause:U})=>{w?f.notify(w.status_code,w.reason_phrase):f.notify(487,U)}),o.refer_to.uri.hasHeader("replaces")){const w=decodeURIComponent(o.refer_to.uri.getHeader("replaces"));O.extraHeaders=d.cloneArray(O.extraHeaders),O.extraHeaders.push(`Replaces: ${w}`)}v.connect(o.refer_to.uri.toAor(),O,A)}function p(){f.notify(603)}}_receiveNotify(o){switch(C.debug("receiveNotify()"),o.event||o.reply(400),o.event.event){case"refer":{let f,T;if(o.event.params&&o.event.params.id)f=o.event.params.id,T=this._referSubscribers[f];else if(Object.keys(this._referSubscribers).length===1)T=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{o.reply(400,"Missing event id parameter");return}if(!T){o.reply(481,"Subscription does not exist");return}T.receiveNotify(o),o.reply(200);break}default:o.reply(489)}}_receiveReplaces(o){C.debug("receiveReplaces()");function f(p){if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;const A=new Es(this._ua);A.on("confirmed",()=>{this.terminate()}),A.init_incoming(o,p)}function T(){C.debug("Replaced INVITE rejected by the user"),o.reply(486)}this.emit("replaces",{request:o,accept:p=>{f.call(this,p)},reject:()=>{T.call(this)}})}_sendInitialRequest(o,f,T){const p=new c(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:A=>{this._request=A},onReceiveResponse:A=>{this._receiveInviteResponse(A)}});Promise.resolve().then(()=>{if(T)return T;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(A=>{throw this._status===I.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,_.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',A),this.emit("getusermediafailed",A),A)})}).then(A=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=A,A&&A.getTracks().forEach(O=>{this._connection.addTrack(O,A)}),this._connecting(this._request),this._createLocalDescription("offer",f).catch(O=>{throw this._failed("local",null,_.causes.WEBRTC_ERROR),O})}).then(A=>{if(this._is_canceled||this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._request.body=A,this._status=I.STATUS_INVITE_SENT,C.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),p.send()}).catch(A=>{this._status!==I.STATUS_TERMINATED&&C.warn(A)})}_getDTMFRTPSender(){const o=this._connection.getSenders().find(f=>f.track&&f.track.kind==="audio");if(!(o&&o.dtmf)){C.warn("sendDTMF() | no local audio track to send DTMF with");return}return o.dtmf}_receiveInviteResponse(o){if(C.debug("receiveInviteResponse()"),this._dialog&&o.status_code>=200&&o.status_code<=299)if(this._dialog.id.call_id===o.call_id&&this._dialog.id.local_tag===o.from_tag&&this._dialog.id.remote_tag===o.to_tag){this.sendRequest(_.ACK);return}else{const f=new m(this,o,"UAC");if(f.error!==void 0){C.debug(f.error);return}this.sendRequest(_.ACK),this.sendRequest(_.BYE);return}if(this._is_canceled){o.status_code>=100&&o.status_code<200?this._request.cancel(this._cancel_reason):o.status_code>=200&&o.status_code<299&&this._acceptAndTerminate(o);return}if(!(this._status!==I.STATUS_INVITE_SENT&&this._status!==I.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(o.status_code):this._status=I.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(o.status_code):{if(!o.to_tag){C.debug("1xx response received without to tag");break}if(o.hasHeader("contact")&&!this._createDialog(o,"UAC",!0))break;if(this._status=I.STATUS_1XX_RECEIVED,!o.body){this._progress("remote",o);break}const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(T)).then(()=>this._progress("remote",o)).catch(p=>{C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)});break}case/^2[0-9]{2}$/.test(o.status_code):{if(this._status=I.STATUS_CONFIRMED,!o.body){this._acceptAndTerminate(o,400,_.causes.MISSING_SDP),this._failed("remote",o,_.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(o,"UAC"))break;const f={originator:"remote",type:"answer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",f);const T=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(p=>this._connection.setLocalDescription(p)).catch(p=>{this._acceptAndTerminate(o,500,p.toString()),this._failed("local",o,_.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(T).then(()=>{this._handleSessionTimersInIncomingResponse(o),this._accepted("remote",o),this.sendRequest(_.ACK),this._confirmed("local",null)}).catch(p=>{this._acceptAndTerminate(o,488,"Not Acceptable Here"),this._failed("remote",o,_.causes.BAD_MEDIA_DESCRIPTION),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',p),this.emit("peerconnection:setremotedescriptionfailed",p)})});break}default:{const f=d.sipErrorCause(o.status_code);this._failed("remote",o,f)}}}_sendReinvite(o={}){C.debug("sendReinvite()");const f=d.cloneArray(o.extraHeaders),T=d.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null;let A=!1;f.push(`Contact: ${this._contact}`),f.push("Content-Type: application/sdp"),this._sessionTimers.running&&f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",p)).then(w=>{w=this._mangleOffer(w);const U={originator:"local",type:"offer",sdp:w};C.debug('emit "sdp"'),this.emit("sdp",U),this.sendRequest(_.INVITE,{extraHeaders:f,body:w,eventHandlers:{onSuccessResponse:M=>{O.call(this,M),A=!0},onErrorResponse:M=>{v.call(this,M)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function O(w){if(this._status===I.STATUS_TERMINATED||(this.sendRequest(_.ACK),A))return;if(this._handleSessionTimersInIncomingResponse(w),w.body){if(!w.hasHeader("Content-Type")||w.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const U={originator:"remote",type:"answer",sdp:w.body};C.debug('emit "sdp"'),this.emit("sdp",U);const M=new RTCSessionDescription({type:"answer",sdp:U.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(M)).then(()=>{T.succeeded&&T.succeeded(w)}).catch(Y=>{v.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',Y),this.emit("peerconnection:setremotedescriptionfailed",Y)})}function v(w){T.failed&&T.failed(w)}}_sendUpdate(o={}){C.debug("sendUpdate()");const f=d.cloneArray(o.extraHeaders),T=d.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null,A=o.sdpOffer||!1;let O=!1;f.push(`Contact: ${this._contact}`),this._sessionTimers.running&&f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),A?(f.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",p)).then(U=>{U=this._mangleOffer(U);const M={originator:"local",type:"offer",sdp:U};C.debug('emit "sdp"'),this.emit("sdp",M),this.sendRequest(_.UPDATE,{extraHeaders:f,body:U,eventHandlers:{onSuccessResponse:Y=>{v.call(this,Y),O=!0},onErrorResponse:Y=>{w.call(this,Y)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{w.call(this)})):this.sendRequest(_.UPDATE,{extraHeaders:f,eventHandlers:{onSuccessResponse:U=>{v.call(this,U)},onErrorResponse:U=>{w.call(this,U)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(U){if(this._status!==I.STATUS_TERMINATED&&!O)if(this._handleSessionTimersInIncomingResponse(U),A){if(U.body){if(!U.hasHeader("Content-Type")||U.getHeader("Content-Type").toLowerCase()!=="application/sdp"){w.call(this);return}}else{w.call(this);return}const M={originator:"remote",type:"answer",sdp:U.body};C.debug('emit "sdp"'),this.emit("sdp",M);const Y=new RTCSessionDescription({type:"answer",sdp:M.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(Y)).then(()=>{T.succeeded&&T.succeeded(U)}).catch(B=>{w.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',B),this.emit("peerconnection:setremotedescriptionfailed",B)})}else T.succeeded&&T.succeeded(U)}function w(U){T.failed&&T.failed(U)}}_acceptAndTerminate(o,f,T){C.debug("acceptAndTerminate()");const p=[];f&&(T=T||_.REASON_PHRASE[f]||"",p.push(`Reason: SIP ;cause=${f}; text="${T}"`)),(this._dialog||this._createDialog(o,"UAC"))&&(this.sendRequest(_.ACK),this.sendRequest(_.BYE,{extraHeaders:p})),this._status=I.STATUS_TERMINATED}_mangleOffer(o){if(!this._localHold&&!this._remoteHold)return o;if(o=y.parse(o),this._localHold&&!this._remoteHold){C.debug("mangleOffer() | me on hold, mangling offer");for(const f of o.media)F.indexOf(f.type)!==-1&&(f.direction?f.direction==="sendrecv"?f.direction="sendonly":f.direction==="recvonly"&&(f.direction="inactive"):f.direction="sendonly")}else if(this._localHold&&this._remoteHold){C.debug("mangleOffer() | both on hold, mangling offer");for(const f of o.media)F.indexOf(f.type)!==-1&&(f.direction="inactive")}else if(this._remoteHold){C.debug("mangleOffer() | remote on hold, mangling offer");for(const f of o.media)F.indexOf(f.type)!==-1&&(f.direction?f.direction==="sendrecv"?f.direction="recvonly":f.direction==="recvonly"&&(f.direction="inactive"):f.direction="recvonly")}return y.write(o)}_setLocalMediaStatus(){let o=!0,f=!0;(this._localHold||this._remoteHold)&&(o=!1,f=!1),this._audioMuted&&(o=!1),this._videoMuted&&(f=!1),this._toggleMuteAudio(!o),this._toggleMuteVideo(!f)}_handleSessionTimersInIncomingRequest(o,f){if(!this._sessionTimers.enabled)return;let T;o.session_expires&&o.session_expires>=_.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,T=o.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,T="uas"),f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${T}`),this._sessionTimers.refresher=T==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(o){if(!this._sessionTimers.enabled)return;let f;o.session_expires&&o.session_expires>=_.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,f=o.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,f="uac"),this._sessionTimers.refresher=f==="uac",this._runSessionTimer()}_runSessionTimer(){const o=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==I.STATUS_TERMINATED&&this.isReadyToReOffer()&&(C.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===_.UPDATE?this._sendUpdate():this._sendReinvite())},o*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==I.STATUS_TERMINATED&&(C.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:_.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},o*1100)}_toggleMuteAudio(o){const f=this._connection.getSenders().filter(T=>T.track&&T.track.kind==="audio");for(const T of f)T.track.enabled=!o}_toggleMuteVideo(o){const f=this._connection.getSenders().filter(T=>T.track&&T.track.kind==="video");for(const T of f)T.track.enabled=!o}_newRTCSession(o,f){C.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:o,session:this,request:f})}_connecting(o){C.debug("session connecting"),C.debug('emit "connecting"'),this.emit("connecting",{request:o})}_progress(o,f){C.debug("session progress"),C.debug('emit "progress"'),this.emit("progress",{originator:o,response:f||null})}_accepted(o,f){C.debug("session accepted"),this._start_time=new Date,C.debug('emit "accepted"'),this.emit("accepted",{originator:o,response:f||null})}_confirmed(o,f){C.debug("session confirmed"),this._is_confirmed=!0,C.debug('emit "confirmed"'),this.emit("confirmed",{originator:o,ack:f||null})}_ended(o,f,T){C.debug("session ended"),this._end_time=new Date,this._close(),C.debug('emit "ended"'),this.emit("ended",{originator:o,message:f||null,cause:T})}_failed(o,f,T){C.debug("session failed"),C.debug('emit "_failed"'),this.emit("_failed",{originator:o,message:f||null,cause:T}),this._close(),C.debug('emit "failed"'),this.emit("failed",{originator:o,message:f||null,cause:T})}_onhold(o){C.debug("session onhold"),this._setLocalMediaStatus(),C.debug('emit "hold"'),this.emit("hold",{originator:o})}_onunhold(o){C.debug("session onunhold"),this._setLocalMediaStatus(),C.debug('emit "unhold"'),this.emit("unhold",{originator:o})}_onmute({audio:o,video:f}){C.debug("session onmute"),this._setLocalMediaStatus(),C.debug('emit "muted"'),this.emit("muted",{audio:o,video:f})}_onunmute({audio:o,video:f}){C.debug("session onunmute"),this._setLocalMediaStatus(),C.debug('emit "unmuted"'),this.emit("unmuted",{audio:o,video:f})}},os}var us,jn;function ci(){if(jn)return us;jn=1;const b=Ie().EventEmitter,y=ce(),i=oe(),_=Se(),S=fe(),t=Ve(),d=we(),h=ye(),n=new y("Message");return us=class extends b{constructor(c){super(),this._ua=c,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(c,R,D={}){const E=c;if(c===void 0||R===void 0)throw new TypeError("Not enough arguments");if(c=this._ua.normalizeTarget(c),!c)throw new TypeError(`Invalid target: ${E}`);const N=S.cloneArray(D.extraHeaders),$=S.cloneObject(D.eventHandlers),C=D.contentType||"text/plain",I={};D.fromUserName&&(I.from_uri=new h("sip",D.fromUserName,this._ua.configuration.uri.host),N.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),D.fromDisplayName&&(I.from_display_name=D.fromDisplayName);for(const H in $)Object.prototype.hasOwnProperty.call($,H)&&this.on(H,$[H]);N.push(`Content-Type: ${C}`),this._request=new _.OutgoingRequest(i.MESSAGE,c,this._ua,I,N),R&&(this._request.body=R);const F=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:H=>{this._receiveResponse(H)}});this._newMessage("local",this._request),F.send()}init_incoming(c){this._request=c,this._newMessage("remote",c),this._is_replied||(this._is_replied=!0,c.reply(200)),this._close()}accept(c={}){const R=S.cloneArray(c.extraHeaders),D=c.body;if(this._direction!=="incoming")throw new d.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,R,D)}reject(c={}){const R=c.status_code||480,D=c.reason_phrase,E=S.cloneArray(c.extraHeaders),N=c.body;if(this._direction!=="incoming")throw new d.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(R<300||R>=700)throw new TypeError(`Invalid status_code: ${R}`);this._is_replied=!0,this._request.reply(R,D,E,N)}_receiveResponse(c){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(c.status_code):break;case/^2[0-9]{2}$/.test(c.status_code):this._succeeded("remote",c);break;default:{const R=S.sipErrorCause(c.status_code);this._failed("remote",c,R);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,i.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,i.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(c,R){c==="remote"?(this._direction="incoming",this._local_identity=R.to,this._remote_identity=R.from):c==="local"&&(this._direction="outgoing",this._local_identity=R.from,this._remote_identity=R.to),this._ua.newMessage(this,{originator:c,message:this,request:R})}_failed(c,R,D){n.debug("MESSAGE failed"),this._close(),n.debug('emit "failed"'),this.emit("failed",{originator:c,response:R||null,cause:D})}_succeeded(c,R){n.debug("MESSAGE succeeded"),this._close(),n.debug('emit "succeeded"'),this.emit("succeeded",{originator:c,response:R})}},us}var cs,Gn;function fi(){if(Gn)return cs;Gn=1;const b=Ie().EventEmitter,y=ce(),i=oe(),_=Se(),S=fe(),t=Ve(),d=we(),h=new y("Options");return cs=class extends b{constructor(m){super(),this._ua=m,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(m,c,R={}){const D=m;if(m===void 0)throw new TypeError("A target is required for OPTIONS");if(m=this._ua.normalizeTarget(m),!m)throw new TypeError(`Invalid target: ${D}`);const E=S.cloneArray(R.extraHeaders),N=S.cloneObject(R.eventHandlers),$=R.contentType||"application/sdp";for(const I in N)Object.prototype.hasOwnProperty.call(N,I)&&this.on(I,N[I]);E.push(`Content-Type: ${$}`),this._request=new _.OutgoingRequest(i.OPTIONS,m,this._ua,null,E),c&&(this._request.body=c);const C=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:I=>{this._receiveResponse(I)}});this._newOptions("local",this._request),C.send()}init_incoming(m){this._request=m,this._newOptions("remote",m),this._is_replied||(this._is_replied=!0,m.reply(200)),this._close()}accept(m={}){const c=S.cloneArray(m.extraHeaders),R=m.body;if(this._direction!=="incoming")throw new d.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,c,R)}reject(m={}){const c=m.status_code||480,R=m.reason_phrase,D=S.cloneArray(m.extraHeaders),E=m.body;if(this._direction!=="incoming")throw new d.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(c<300||c>=700)throw new TypeError(`Invalid status_code: ${c}`);this._is_replied=!0,this._request.reply(c,R,D,E)}_receiveResponse(m){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(m.status_code):break;case/^2[0-9]{2}$/.test(m.status_code):this._succeeded("remote",m);break;default:{const c=S.sipErrorCause(m.status_code);this._failed("remote",m,c);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,i.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,i.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(m,c){m==="remote"?(this._direction="incoming",this._local_identity=c.to,this._remote_identity=c.from):m==="local"&&(this._direction="outgoing",this._local_identity=c.from,this._remote_identity=c.to),this._ua.newOptions(this,{originator:m,message:this,request:c})}_failed(m,c,R){h.debug("OPTIONS failed"),this._close(),h.debug('emit "failed"'),this.emit("failed",{originator:m,response:c||null,cause:R})}_succeeded(m,c){h.debug("OPTIONS succeeded"),this._close(),h.debug('emit "succeeded"'),this.emit("succeeded",{originator:m,response:c})}},cs}var fs={},Bn;function ll(){if(Bn)return fs;Bn=1;const b=ce(),y=fe(),i=Ce(),_=new b("Socket");return fs.isSocket=S=>{if(Array.isArray(S))return!1;if(typeof S>"u")return _.warn("undefined JsSIP.Socket instance"),!1;try{if(!y.isString(S.url))throw _.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!y.isString(S.via_transport))throw _.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(i.parse(S.sip_uri,"SIP_URI")===-1)throw _.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(t=>{if(!y.isFunction(S[t]))throw _.warn(`missing or invalid JsSIP.Socket method: ${t}`),new Error(`Missing or invalid JsSIP.Socket method: ${t}`)})}catch{return!1}return!0},fs}var hs,Wn;function hi(){if(Wn)return hs;Wn=1;const b=ce(),y=ll(),i=oe(),_=new b("Transport"),S={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:i.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:i.CONNECTION_RECOVERY_MAX_INTERVAL}};return hs=class{constructor(d,h=S.recovery_options){_.debug("new()"),this.status=S.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=h,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(n){_.warn(`cannot use TextDecoder: ${n}`)}if(typeof d>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");d instanceof Array||(d=[d]),d.forEach(function(n){if(!y.isSocket(n.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(n.weight&&!Number(n.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:n.socket,weight:n.weight||0,status:S.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(_.debug("connect()"),this.isConnected()){_.debug("Transport is already connected");return}else if(this.isConnecting()){_.debug("Transport is connecting");return}this.close_requested=!1,this.status=S.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(){_.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=S.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(d){if(_.debug("send()"),!this.isConnected())return _.warn("unable to send message, transport is not connected"),!1;const h=d.toString();return _.debug(`sending message:
47
47
 
48
48
  ${h}
49
- `),this.socket.send(h)}isConnected(){return this.status===R.STATUS_CONNECTED}isConnecting(){return this.status===R.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let d=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);d<this.recovery_options.min_interval?d=this.recovery_options.min_interval:d>this.recovery_options.max_interval&&(d=this.recovery_options.max_interval),_.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${d} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},d*1e3)}_getSocket(){let d=[];if(this.sockets.forEach(l=>{l.status!==R.SOCKET_STATUS_ERROR&&(d.length===0?d.push(l):l.weight>d[0].weight?d=[l]:l.weight===d[0].weight&&d.push(l))}),d.length===0){this.sockets.forEach(l=>{l.status=R.SOCKET_STATUS_READY}),this._getSocket();return}const h=Math.floor(Math.random()*d.length);this.socket=d[h].socket}_onConnect(){this.recover_attempts=0,this.status=R.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(d,h,l){this.status=R.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:d,code:h,reason:l}),!this.close_requested&&(this.sockets.forEach(function(g){this.socket===g.socket&&(g.status=R.SOCKET_STATUS_ERROR)},this),this._reconnect(d))}_onData(d){if(d===`\r
49
+ `),this.socket.send(h)}isConnected(){return this.status===S.STATUS_CONNECTED}isConnecting(){return this.status===S.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let d=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);d<this.recovery_options.min_interval?d=this.recovery_options.min_interval:d>this.recovery_options.max_interval&&(d=this.recovery_options.max_interval),_.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${d} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},d*1e3)}_getSocket(){let d=[];if(this.sockets.forEach(n=>{n.status!==S.SOCKET_STATUS_ERROR&&(d.length===0?d.push(n):n.weight>d[0].weight?d=[n]:n.weight===d[0].weight&&d.push(n))}),d.length===0){this.sockets.forEach(n=>{n.status=S.SOCKET_STATUS_READY}),this._getSocket();return}const h=Math.floor(Math.random()*d.length);this.socket=d[h].socket}_onConnect(){this.recover_attempts=0,this.status=S.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(d,h,n){this.status=S.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:d,code:h,reason:n}),!this.close_requested&&(this.sockets.forEach(function(m){this.socket===m.socket&&(m.status=S.SOCKET_STATUS_ERROR)},this),this._reconnect(d))}_onData(d){if(d===`\r
50
50
  \r
51
51
  `){_.debug("received message with double-CRLF Keep Alive request");try{this.socket.send(`\r
52
52
  `)}catch(h){_.warn(`error sending Keep Alive response: ${h}`)}return}if(d===`\r
@@ -56,13 +56,13 @@ ${d}
56
56
  `)}else _.debug(`received text message:
57
57
 
58
58
  ${d}
59
- `);this.ondata({transport:this,message:d})}},hs}var ds={},Wn;function hi(){if(Wn)return ds;Wn=1;const w=fe(),I=Ce(),i=Se(),_=new w("Parser");ds.parseMessage=(d,h)=>{let l,g,c=d.indexOf(`\r
60
- `);if(c===-1){_.warn("parseMessage() | no CRLF found, not a SIP message");return}const A=d.substring(0,c);let U=I.parse(A,"Request_Response");if(U===-1){_.warn(`parseMessage() | error parsing first line of SIP message: "${A}"`);return}else U.status_code?(l=new i.IncomingResponse,l.status_code=U.status_code,l.reason_phrase=U.reason_phrase):(l=new i.IncomingRequest(h),l.method=U.method,l.ruri=U.uri);l.data=d;let v=c+2;for(;;){if(c=R(d,v),c===-2){g=v+2;break}else if(c===-1){_.warn("parseMessage() | malformed message");return}if(U=t(l,d,v,c),U!==!0){_.warn("parseMessage() |",U.error);return}v=c+2}if(l.hasHeader("content-length")){const N=l.getHeader("content-length");l.body=d.substr(g,N)}else l.body=d.substring(g);return l};function R(d,h){let l=h,g=0,c=0;if(d.substring(l,l+2).match(/(^\r\n)/))return-2;for(;g===0;){if(c=d.indexOf(`\r
61
- `,l),c===-1)return c;!d.substring(c+2,c+4).match(/(^\r\n)/)&&d.charAt(c+2).match(/(^\s+)/)?l=c+2:g=c}return g}function t(d,h,l,g){let c;const A=h.indexOf(":",l),U=h.substring(l,A).trim(),v=h.substring(A+1,g).trim();switch(U.toLowerCase()){case"via":case"v":d.addHeader("via",v),d.getHeaders("via").length===1?(c=d.parseHeader("Via"),c&&(d.via=c,d.via_branch=c.branch)):c=0;break;case"from":case"f":d.setHeader("from",v),c=d.parseHeader("from"),c&&(d.from=c,d.from_tag=c.getParam("tag"));break;case"to":case"t":d.setHeader("to",v),c=d.parseHeader("to"),c&&(d.to=c,d.to_tag=c.getParam("tag"));break;case"record-route":if(c=I.parse(v,"Record_Route"),c===-1)c=void 0;else for(const N of c)d.addHeader("record-route",v.substring(N.possition,N.offset)),d.headers["Record-Route"][d.getHeaders("record-route").length-1].parsed=N.parsed;break;case"call-id":case"i":d.setHeader("call-id",v),c=d.parseHeader("call-id"),c&&(d.call_id=v);break;case"contact":case"m":if(c=I.parse(v,"Contact"),c===-1)c=void 0;else for(const N of c)d.addHeader("contact",v.substring(N.possition,N.offset)),d.headers.Contact[d.getHeaders("contact").length-1].parsed=N.parsed;break;case"content-length":case"l":d.setHeader("content-length",v),c=d.parseHeader("content-length");break;case"content-type":case"c":d.setHeader("content-type",v),c=d.parseHeader("content-type");break;case"cseq":d.setHeader("cseq",v),c=d.parseHeader("cseq"),c&&(d.cseq=c.value),d instanceof i.IncomingResponse&&(d.method=c.method);break;case"max-forwards":d.setHeader("max-forwards",v),c=d.parseHeader("max-forwards");break;case"www-authenticate":d.setHeader("www-authenticate",v),c=d.parseHeader("www-authenticate");break;case"proxy-authenticate":d.setHeader("proxy-authenticate",v),c=d.parseHeader("proxy-authenticate");break;case"session-expires":case"x":d.setHeader("session-expires",v),c=d.parseHeader("session-expires"),c&&(d.session_expires=c.expires,d.session_expires_refresher=c.refresher);break;case"refer-to":case"r":d.setHeader("refer-to",v),c=d.parseHeader("refer-to"),c&&(d.refer_to=c);break;case"replaces":d.setHeader("replaces",v),c=d.parseHeader("replaces"),c&&(d.replaces=c);break;case"event":case"o":d.setHeader("event",v),c=d.parseHeader("event"),c&&(d.event=c);break;default:d.addHeader(U,v),c=0}return c===void 0?{error:`error parsing header "${U}"`}:!0}return ds}var _s,Vn;function di(){if(Vn)return _s;Vn=1;const w=fe(),I=ce(),i=Se(),_=_e(),R=new w("sanityCheck"),t=[y],d=[A,U,v,N],h=[$,C];let l,g,c;_s=(H,o,f)=>{l=H,g=o,c=f;for(const T of t)if(T()===!1)return!1;if(l instanceof i.IncomingRequest){for(const T of d)if(T()===!1)return!1}else if(l instanceof i.IncomingResponse){for(const T of h)if(T()===!1)return!1}return!0};function A(){if(l.s("to").uri.scheme!=="sip")return F(416),!1}function U(){if(!l.to_tag&&l.call_id.substr(0,5)===g.configuration.jssip_id)return F(482),!1}function v(){const H=_.str_utf8_length(l.body),o=l.getHeader("content-length");if(H<o)return F(400),!1}function N(){const H=l.from_tag,o=l.call_id,f=l.cseq;let T;if(!l.to_tag)if(l.method===I.INVITE){if(g._transactions.ist[l.via_branch])return!1;for(const p in g._transactions.ist)if(Object.prototype.hasOwnProperty.call(g._transactions.ist,p)&&(T=g._transactions.ist[p],T.request.from_tag===H&&T.request.call_id===o&&T.request.cseq===f))return F(482),!1}else{if(g._transactions.nist[l.via_branch])return!1;for(const p in g._transactions.nist)if(Object.prototype.hasOwnProperty.call(g._transactions.nist,p)&&(T=g._transactions.nist[p],T.request.from_tag===H&&T.request.call_id===o&&T.request.cseq===f))return F(482),!1}}function $(){if(l.getHeaders("via").length>1)return R.debug("more than one Via header field present in the response, dropping the response"),!1}function C(){const H=_.str_utf8_length(l.body),o=l.getHeader("content-length");if(H<o)return R.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function y(){const H=["from","to","call_id","cseq","via"];for(const o of H)if(!l.hasHeader(o))return R.debug(`missing mandatory header field : ${o}, dropping the response`),!1}function F(H){const o=l.getHeaders("via");let f,T=`SIP/2.0 ${H} ${I.REASON_PHRASE[H]}\r
59
+ `);this.ondata({transport:this,message:d})}},hs}var ds={},Vn;function di(){if(Vn)return ds;Vn=1;const b=ce(),y=Ce(),i=Se(),_=new b("Parser");ds.parseMessage=(d,h)=>{let n,m,c=d.indexOf(`\r
60
+ `);if(c===-1){_.warn("parseMessage() | no CRLF found, not a SIP message");return}const R=d.substring(0,c);let D=y.parse(R,"Request_Response");if(D===-1){_.warn(`parseMessage() | error parsing first line of SIP message: "${R}"`);return}else D.status_code?(n=new i.IncomingResponse,n.status_code=D.status_code,n.reason_phrase=D.reason_phrase):(n=new i.IncomingRequest(h),n.method=D.method,n.ruri=D.uri);n.data=d;let E=c+2;for(;;){if(c=S(d,E),c===-2){m=E+2;break}else if(c===-1){_.warn("parseMessage() | malformed message");return}if(D=t(n,d,E,c),D!==!0){_.warn("parseMessage() |",D.error);return}E=c+2}if(n.hasHeader("content-length")){const N=n.getHeader("content-length");n.body=d.substr(m,N)}else n.body=d.substring(m);return n};function S(d,h){let n=h,m=0,c=0;if(d.substring(n,n+2).match(/(^\r\n)/))return-2;for(;m===0;){if(c=d.indexOf(`\r
61
+ `,n),c===-1)return c;!d.substring(c+2,c+4).match(/(^\r\n)/)&&d.charAt(c+2).match(/(^\s+)/)?n=c+2:m=c}return m}function t(d,h,n,m){let c;const R=h.indexOf(":",n),D=h.substring(n,R).trim(),E=h.substring(R+1,m).trim();switch(D.toLowerCase()){case"via":case"v":d.addHeader("via",E),d.getHeaders("via").length===1?(c=d.parseHeader("Via"),c&&(d.via=c,d.via_branch=c.branch)):c=0;break;case"from":case"f":d.setHeader("from",E),c=d.parseHeader("from"),c&&(d.from=c,d.from_tag=c.getParam("tag"));break;case"to":case"t":d.setHeader("to",E),c=d.parseHeader("to"),c&&(d.to=c,d.to_tag=c.getParam("tag"));break;case"record-route":if(c=y.parse(E,"Record_Route"),c===-1)c=void 0;else for(const N of c)d.addHeader("record-route",E.substring(N.possition,N.offset)),d.headers["Record-Route"][d.getHeaders("record-route").length-1].parsed=N.parsed;break;case"call-id":case"i":d.setHeader("call-id",E),c=d.parseHeader("call-id"),c&&(d.call_id=E);break;case"contact":case"m":if(c=y.parse(E,"Contact"),c===-1)c=void 0;else for(const N of c)d.addHeader("contact",E.substring(N.possition,N.offset)),d.headers.Contact[d.getHeaders("contact").length-1].parsed=N.parsed;break;case"content-length":case"l":d.setHeader("content-length",E),c=d.parseHeader("content-length");break;case"content-type":case"c":d.setHeader("content-type",E),c=d.parseHeader("content-type");break;case"cseq":d.setHeader("cseq",E),c=d.parseHeader("cseq"),c&&(d.cseq=c.value),d instanceof i.IncomingResponse&&(d.method=c.method);break;case"max-forwards":d.setHeader("max-forwards",E),c=d.parseHeader("max-forwards");break;case"www-authenticate":d.setHeader("www-authenticate",E),c=d.parseHeader("www-authenticate");break;case"proxy-authenticate":d.setHeader("proxy-authenticate",E),c=d.parseHeader("proxy-authenticate");break;case"session-expires":case"x":d.setHeader("session-expires",E),c=d.parseHeader("session-expires"),c&&(d.session_expires=c.expires,d.session_expires_refresher=c.refresher);break;case"refer-to":case"r":d.setHeader("refer-to",E),c=d.parseHeader("refer-to"),c&&(d.refer_to=c);break;case"replaces":d.setHeader("replaces",E),c=d.parseHeader("replaces"),c&&(d.replaces=c);break;case"event":case"o":d.setHeader("event",E),c=d.parseHeader("event"),c&&(d.event=c);break;default:d.addHeader(D,E),c=0}return c===void 0?{error:`error parsing header "${D}"`}:!0}return ds}var _s,zn;function _i(){if(zn)return _s;zn=1;const b=ce(),y=oe(),i=Se(),_=fe(),S=new b("sanityCheck"),t=[I],d=[R,D,E,N],h=[$,C];let n,m,c;_s=(H,o,f)=>{n=H,m=o,c=f;for(const T of t)if(T()===!1)return!1;if(n instanceof i.IncomingRequest){for(const T of d)if(T()===!1)return!1}else if(n instanceof i.IncomingResponse){for(const T of h)if(T()===!1)return!1}return!0};function R(){if(n.s("to").uri.scheme!=="sip")return F(416),!1}function D(){if(!n.to_tag&&n.call_id.substr(0,5)===m.configuration.jssip_id)return F(482),!1}function E(){const H=_.str_utf8_length(n.body),o=n.getHeader("content-length");if(H<o)return F(400),!1}function N(){const H=n.from_tag,o=n.call_id,f=n.cseq;let T;if(!n.to_tag)if(n.method===y.INVITE){if(m._transactions.ist[n.via_branch])return!1;for(const p in m._transactions.ist)if(Object.prototype.hasOwnProperty.call(m._transactions.ist,p)&&(T=m._transactions.ist[p],T.request.from_tag===H&&T.request.call_id===o&&T.request.cseq===f))return F(482),!1}else{if(m._transactions.nist[n.via_branch])return!1;for(const p in m._transactions.nist)if(Object.prototype.hasOwnProperty.call(m._transactions.nist,p)&&(T=m._transactions.nist[p],T.request.from_tag===H&&T.request.call_id===o&&T.request.cseq===f))return F(482),!1}}function $(){if(n.getHeaders("via").length>1)return S.debug("more than one Via header field present in the response, dropping the response"),!1}function C(){const H=_.str_utf8_length(n.body),o=n.getHeader("content-length");if(H<o)return S.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function I(){const H=["from","to","call_id","cseq","via"];for(const o of H)if(!n.hasHeader(o))return S.debug(`missing mandatory header field : ${o}, dropping the response`),!1}function F(H){const o=n.getHeaders("via");let f,T=`SIP/2.0 ${H} ${y.REASON_PHRASE[H]}\r
62
62
  `;for(const p of o)T+=`Via: ${p}\r
63
- `;f=l.getHeader("To"),l.to_tag||(f+=`;tag=${_.newTag()}`),T+=`To: ${f}\r
64
- `,T+=`From: ${l.getHeader("From")}\r
65
- `,T+=`Call-ID: ${l.call_id}\r
66
- `,T+=`CSeq: ${l.cseq} ${l.method}\r
63
+ `;f=n.getHeader("To"),n.to_tag||(f+=`;tag=${_.newTag()}`),T+=`To: ${f}\r
64
+ `,T+=`From: ${n.getHeader("From")}\r
65
+ `,T+=`Call-ID: ${n.call_id}\r
66
+ `,T+=`CSeq: ${n.cseq} ${n.method}\r
67
67
  `,T+=`\r
68
- `,c.send(T)}return _s}var dt={},zn;function _i(){if(zn)return dt;zn=1;const w=_e(),I=ce(),i=Ce(),_=ye(),R=nl(),t=we();dt.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:I.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:I.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:I.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${w.createRandomToken(12)}.invalid`};const d={mandatory:{sockets(h){const l=[];if(R.isSocket(h))l.push({socket:h});else if(Array.isArray(h)&&h.length)for(const g of h)Object.prototype.hasOwnProperty.call(g,"socket")&&R.isSocket(g.socket)?l.push(g):R.isSocket(g)&&l.push({socket:g});else return;return l},uri(h){/^sip:/i.test(h)||(h=`${I.SIP}:${h}`);const l=_.parse(h);if(l)return l.user?l:void 0}},optional:{authorization_user(h){if(i.parse(`"${h}"`,"quoted_string")!==-1)return h},authorization_jwt(h){if(typeof h=="string")return h},user_agent(h){if(typeof h=="string")return h},connection_recovery_max_interval(h){if(w.isDecimal(h)){const l=Number(h);if(l>0)return l}},connection_recovery_min_interval(h){if(w.isDecimal(h)){const l=Number(h);if(l>0)return l}},contact_uri(h){if(typeof h=="string"){const l=i.parse(h,"SIP_URI");if(l!==-1)return l}},display_name(h){return h},instance_id(h){if(/^uuid:/i.test(h)&&(h=h.substr(5)),i.parse(h,"uuid")!==-1)return h},no_answer_timeout(h){if(w.isDecimal(h)){const l=Number(h);if(l>0)return l}},session_timers(h){if(typeof h=="boolean")return h},session_timers_refresh_method(h){if(typeof h=="string"&&(h=h.toUpperCase(),h===I.INVITE||h===I.UPDATE))return h},session_timers_force_refresher(h){if(typeof h=="boolean")return h},password(h){return String(h)},realm(h){return String(h)},ha1(h){return String(h)},register(h){if(typeof h=="boolean")return h},register_expires(h){if(w.isDecimal(h)){const l=Number(h);if(l>=0)return l}},register_from_tag_trail(h){return typeof h=="function"?h:String(h)},registrar_server(h){/^sip:/i.test(h)||(h=`${I.SIP}:${h}`);const l=_.parse(h);if(l)return l.user?void 0:l},use_preloaded_route(h){if(typeof h=="boolean")return h},extra_headers(h){const l=[];if(Array.isArray(h)&&h.length)for(const g of h)typeof g=="string"&&l.push(g);else return;return l}}};return dt.load=(h,l)=>{for(const g in d.mandatory)if(l.hasOwnProperty(g)){const c=l[g],A=d.mandatory[g](c);if(A!==void 0)h[g]=A;else throw new t.ConfigurationError(g,c)}else throw new t.ConfigurationError(g);for(const g in d.optional)if(l.hasOwnProperty(g)){const c=l[g];if(w.isEmpty(c))continue;const A=d.optional[g](c);if(A!==void 0)h[g]=A;else throw new t.ConfigurationError(g,c)}},dt}var ps,Kn;function pi(){if(Kn)return ps;Kn=1;const w=Ie().EventEmitter,I=fe(),i=ce(),_=si(),R=rl(),t=ui(),d=ci(),h=We(),l=fi(),g=_e(),c=we(),A=ye(),U=hi(),v=Se(),N=di(),$=_i(),C=new I("UA"),y={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};ps=class extends w{static get C(){return y}constructor(p){if(!p)throw new TypeError("Not enough arguments");const S=["password","ha1","authorization_jwt"];C.debug("new() [configuration:%o]",Object.entries(p).filter(([D])=>!S.includes(D))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},$.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=y.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(p)}catch(D){throw this._status=y.STATUS_NOT_READY,this._error=y.CONFIGURATION_ERROR,D}this._registrator=new _(this)}get C(){return y}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){C.debug("start()"),this._status===y.STATUS_INIT?this._transport.connect():this._status===y.STATUS_USER_CLOSED?(C.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=y.STATUS_INIT,this._transport.connect()):this._status===y.STATUS_READY?C.debug("UA is in READY status, not restarted"):C.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){C.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(p){C.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(p)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(p,S){C.debug("call()");const D=new R(this);return D.connect(p,S),D}sendMessage(p,S,D){C.debug("sendMessage()");const E=new t(this);return E.send(p,S,D),E}sendOptions(p,S,D){C.debug("sendOptions()");const E=new d(this);return E.send(p,S,D),E}terminateSessions(p){C.debug("terminateSessions()");for(const S in this._sessions)this._sessions[S].isEnded()||this._sessions[S].terminate(p)}stop(){if(C.debug("stop()"),this._dynConfiguration={},this._status===y.STATUS_USER_CLOSED){C.debug("UA already closed");return}this._registrator.close();const p=Object.keys(this._sessions).length;for(const D in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,D)){C.debug(`closing session ${D}`);try{this._sessions[D].terminate()}catch{}}for(const D in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,D))try{this._applicants[D].close()}catch{}this._status=y.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&&p===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(p){return g.normalizeTarget(p,this._configuration.hostport_params)}get(p){switch(p){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:C.warn('get() | cannot get "%s" parameter in runtime',p);return}}set(p,S){switch(p){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 C.warn('set() | cannot set "%s" parameter in runtime',p),!1}return!0}newTransaction(p){this._transactions[p.type][p.id]=p,this.emit("newTransaction",{transaction:p})}destroyTransaction(p){delete this._transactions[p.type][p.id],this.emit("transactionDestroyed",{transaction:p})}newDialog(p){this._dialogs[p.id]=p}destroyDialog(p){delete this._dialogs[p.id]}newMessage(p,S){this._applicants[p]=p,this.emit("newMessage",S)}newOptions(p,S){this._applicants[p]=p,this.emit("newOptions",S)}destroyMessage(p){delete this._applicants[p]}newRTCSession(p,S){this._sessions[p.id]=p,this.emit("newRTCSession",S)}destroyRTCSession(p){delete this._sessions[p.id]}registered(p){this.emit("registered",p)}unregistered(p){this.emit("unregistered",p)}registrationFailed(p){this.emit("registrationFailed",p)}receiveRequest(p){const S=p.method;if(p.ruri.user!==this._configuration.uri.user&&p.ruri.user!==this._contact.uri.user){C.debug("Request-URI does not point to us"),p.method!==i.ACK&&p.reply_sl(404);return}if(p.ruri.scheme===i.SIPS){p.reply_sl(416);return}if(h.checkTransaction(this,p))return;if(S===i.INVITE?new h.InviteServerTransaction(this,this._transport,p):S!==i.ACK&&S!==i.CANCEL&&new h.NonInviteServerTransaction(this,this._transport,p),S===i.OPTIONS){if(this.listeners("newOptions").length===0){p.reply(200);return}new d(this).init_incoming(p)}else if(S===i.MESSAGE){if(this.listeners("newMessage").length===0){p.reply(405);return}new t(this).init_incoming(p)}else if(S===i.INVITE&&!p.to_tag&&this.listeners("newRTCSession").length===0){p.reply(405);return}let D,E;if(p.to_tag)D=this._findDialog(p.call_id,p.from_tag,p.to_tag),D?D.receiveRequest(p):S===i.NOTIFY?(E=this._findSession(p),E?E.receiveRequest(p):(C.debug("received NOTIFY request for a non existent subscription"),p.reply(481,"Subscription does not exist"))):S!==i.ACK&&p.reply(481);else switch(S){case i.INVITE:if(window.RTCPeerConnection)if(p.hasHeader("replaces")){const b=p.replaces;D=this._findDialog(b.call_id,b.from_tag,b.to_tag),D?(E=D.owner,E.isEnded()?p.reply(603):E.receiveRequest(p)):p.reply(481)}else E=new R(this),E.init_incoming(p);else C.warn("INVITE received but WebRTC is not supported"),p.reply(488);break;case i.BYE:p.reply(481);break;case i.CANCEL:E=this._findSession(p),E?E.receiveRequest(p):C.debug("received CANCEL request for a non existent session");break;case i.ACK:break;case i.NOTIFY:this.emit("sipEvent",{event:p.event,request:p}),p.reply(200);break;default:p.reply(405);break}}_findSession({call_id:p,from_tag:S,to_tag:D}){const E=p+S,b=this._sessions[E],O=p+D,M=this._sessions[O];return b||M||null}_findDialog(p,S,D){let E=p+S+D,b=this._dialogs[E];return b||(E=p+D+S,b=this._dialogs[E],b||null)}_loadConfig(p){try{$.load(this._configuration,p)}catch(E){throw E}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=g.newUUID()),this._configuration.jssip_id=g.createRandomToken(5);const S=this._configuration.uri.clone();S.user=null,this._configuration.hostport_params=S.toString().replace(/^sip:/i,"");try{this._transport=new l(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=F.bind(this),this._transport.onconnect=H.bind(this),this._transport.ondisconnect=o.bind(this),this._transport.ondata=f.bind(this)}catch(E){throw C.warn(E),new c.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 E=this._configuration.uri.clone();E.user=null,E.clearParams(),E.clearHeaders(),this._configuration.registrar_server=E}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new A("sip",g.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(E={}){const b=E.anonymous||null,O=E.outbound||null;let M="<";return b?M+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":M+=this.pub_gruu||this.uri.toString(),O&&(b?!this.temp_gruu:!this.pub_gruu)&&(M+=";ob"),M+=">",M}};const D=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(const E in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,E)&&(D.indexOf(E)!==-1?Object.defineProperty(this._configuration,E,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,E,{writable:!1,configurable:!1}));C.debug("configuration parameters after validation:");for(const E in this._configuration)if(Object.prototype.hasOwnProperty.call($.settings,E))switch(E){case"uri":case"registrar_server":C.debug(`- ${E}: ${this._configuration[E]}`);break;case"password":case"ha1":case"authorization_jwt":C.debug(`- ${E}: NOT SHOWN`);break;default:C.debug(`- ${E}: ${JSON.stringify(this._configuration[E])}`)}}};function F(T){this.emit("connecting",T)}function H(T){this._status!==y.STATUS_USER_CLOSED&&(this._status=y.STATUS_READY,this._error=null,this.emit("connected",T),this._dynConfiguration.register&&this._registrator.register())}function o(T){const p=["nict","ict","nist","ist"];for(const S of p)for(const D in this._transactions[S])Object.prototype.hasOwnProperty.call(this._transactions[S],D)&&this._transactions[S][D].onTransportError();this.emit("disconnected",T),this._registrator.onTransportClosed(),this._status!==y.STATUS_USER_CLOSED&&(this._status=y.STATUS_NOT_READY,this._error=y.NETWORK_ERROR)}function f(T){const p=T.transport;let S=T.message;if(S=U.parseMessage(S,this),!!S&&!(this._status===y.STATUS_USER_CLOSED&&S instanceof v.IncomingRequest)&&N(S,this,p)){if(S instanceof v.IncomingRequest)S.transport=p,this.receiveRequest(S);else if(S instanceof v.IncomingResponse){let D;switch(S.method){case i.INVITE:D=this._transactions.ict[S.via_branch],D&&D.receiveResponse(S);break;case i.ACK:break;default:D=this._transactions.nict[S.via_branch],D&&D.receiveResponse(S);break}}}}return ps}var ms,Yn;function mi(){if(Yn)return ms;Yn=1;const w=fe(),I=Ce(),i=new w("WebSocketInterface");return ms=class{constructor(R){i.debug('new() [url:"%s"]',R),this._url=R,this._sip_uri=null,this._via_transport=null,this._ws=null;const t=I.parse(R,"absoluteURI");if(t===-1)throw i.warn(`invalid WebSocket URI: ${R}`),new TypeError(`Invalid argument: ${R}`);if(t.scheme!=="wss"&&t.scheme!=="ws")throw i.warn(`invalid WebSocket URI scheme: ${t.scheme}`),new TypeError(`Invalid argument: ${R}`);this._sip_uri=`sip:${t.host}${t.port?`:${t.port}`:""};transport=ws`,this._via_transport=t.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(R){this._via_transport=R.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(i.debug("connect()"),this.isConnected()){i.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){i.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),i.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(R){this._onError(R)}}disconnect(){i.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(R){return i.debug("send()"),this.isConnected()?(this._ws.send(R),!0):(i.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(){i.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:R,code:t,reason:d}){i.debug(`WebSocket ${this._url} closed`),R===!1&&i.debug("WebSocket abrupt disconnection"),this.ondisconnect(!R,t,d)}_onMessage({data:R}){i.debug("received WebSocket message"),this.ondata(R)}_onError(R){i.warn(`WebSocket ${this._url} error: `,R)}},ms}var gs,Jn;function gi(){if(Jn)return gs;Jn=1;const w=Qn,I=ce(),i=we(),_=_e(),R=pi(),t=ye(),d=Ss(),h=Ce(),l=mi(),g=Cs()("JsSIP"),c=rl();return g("version %s",w.version),gs={C:I,Exceptions:i,Utils:_,UA:R,URI:t,NameAddrHeader:d,WebSocketInterface:l,Grammar:h,RTCSession:c,debug:Cs(),get name(){return w.title},get version(){return w.version}},gs}var Ti=gi();const Xn=Kl(Ti),ll=re.createContext(null),Be=new Map;function Ci(w){return`${w.websocketUrl}|${w.sipUri}|${w.authorizationUser}`}function il({config:w,children:I,onCallStart:i,onCallEnd:_,onStatusChange:R}){const[t,d]=re.useState(""),[h,l]=re.useState("disconnected"),[g,c]=re.useState(null),[A,U]=re.useState(0),[v,N]=re.useState([]),[$,C]=re.useState(!1),[y,F]=re.useState("disconnected"),H=re.useRef(null),o=re.useRef(null),f=re.useRef(null),T=re.useRef("");re.useEffect(()=>{f.current=g},[g]),re.useEffect(()=>{const b=Ci(w);T.current=b;let O=Be.get(b);if(O)O.refCount++,H.current=O.ua,O.ua.isRegistered()?(C(!0),F("connected")):O.ua.isConnected()&&F("connected");else{F("connecting");try{const z={sockets:[new Xn.WebSocketInterface(w.websocketUrl)],uri:w.sipUri,password:w.password,registrar_server:w.registrarServer,display_name:w.displayName,authorization_user:w.authorizationUser,connection_recovery_min_interval:2,connection_recovery_max_interval:30},j=new Xn.UA(z),ie=document.createElement("audio");ie.autoplay=!0,O={ua:j,refCount:1,audio:ie},Be.set(b,O),H.current=j,j.on("connecting",()=>{F("connecting")}),j.on("connected",()=>{F("connected")}),j.on("disconnected",()=>{F("disconnected"),C(!1)}),j.on("registered",()=>{C(!0),F("connected")}),j.on("unregistered",()=>{C(!1)}),j.on("registrationFailed",he=>{console.error("Registration failed:",he?.cause),C(!1),F("failed")}),j.on("newRTCSession",he=>{const oe=he.session;oe.direction==="outgoing"&&(o.current=oe,oe.on("peerconnection",()=>{oe.connection.addEventListener("track",Y=>{if(Y.streams&&Y.streams[0]){const de=Be.get(b);de?.audio&&(de.audio.srcObject=Y.streams[0],de.audio.play().catch(console.error))}})}))}),j.start()}catch(M){console.error("Failed to create JsSIP UA:",M),F("failed");return}}return()=>{const M=T.current,z=Be.get(M);if(z&&(z.refCount--,z.refCount<=0)){z.audio&&(z.audio.srcObject=null);try{z.ua.stop()}catch{}Be.delete(M)}H.current=null}},[w.websocketUrl,w.sipUri,w.password,w.registrarServer,w.displayName,w.authorizationUser]),re.useEffect(()=>{R?.(h)},[h,R]),re.useEffect(()=>{const b=localStorage.getItem("tbi-phone-call-history");if(b)try{N(JSON.parse(b))}catch(O){console.error("Error loading call history",O)}},[]),re.useEffect(()=>{v.length>0&&localStorage.setItem("tbi-phone-call-history",JSON.stringify(v))},[v]),re.useEffect(()=>{if(h==="confirmed"&&g){const b=setInterval(()=>{U(Math.floor((Date.now()-g)/1e3))},1e3);return()=>clearInterval(b)}else U(0)},[h,g]),re.useEffect(()=>{const b=O=>{const M=O.detail.number;h==="disconnected"&&D(M)};return window.addEventListener("StartCallEvent",b),()=>{window.removeEventListener("StartCallEvent",b)}},[h]);const p=re.useCallback((b,O,M)=>{const z={id:Date.now().toString(),number:b,timestamp:Date.now(),duration:O,status:M};N(j=>[z,...j].slice(0,50))},[]),S=re.useCallback(()=>{o.current&&(o.current.terminate(),o.current=null)},[]),D=re.useCallback(b=>{if(!b.trim()||!H.current)return;if(!$){console.warn("Phone is not ready yet. Please wait for registration.");return}d(b),i?.(b);const M={eventHandlers:{progress:()=>{l("progress")},failed:z=>{console.error("Call failed:",z?.cause),l("failed"),p(b,0,"failed"),_?.(b,0,"failed"),o.current=null,setTimeout(()=>l("disconnected"),3e3)},ended:()=>{l("ended");const z=f.current,j=z?Math.floor((Date.now()-z)/1e3):0;p(b,j,"completed"),_?.(b,j,"completed"),o.current=null,setTimeout(()=>{l("disconnected"),c(null)},2e3)},confirmed:()=>{l("confirmed"),c(Date.now())}},mediaConstraints:{audio:!0,video:!1}};l("progress");try{const z=H.current.call(b,M);o.current=z}catch(z){console.error("Failed to start call:",z),l("failed"),p(b,0,"failed"),setTimeout(()=>l("disconnected"),3e3)}},[p,i,_,$]),E={status:h,callNumber:t,setCallNumber:d,callHistory:v,currentCallDuration:A,startCall:D,endCall:S,isReady:$,connectionStatus:y};return q.jsx(ll.Provider,{value:E,children:I})}function al(){const w=re.useContext(ll);if(!w)throw new Error("usePhone must be used within a PhoneProvider");return w}const Es=({className:w})=>q.jsx("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"})}),vi=({className:w})=>q.jsx("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M15.05 5A7 7 0 0 1 19 8.95M15.05 1A11 11 0 0 1 23 8.94m-1 7.98v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),Ei=({className:w})=>q.jsx("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.12-.74-.03-1.02.24l-2.2 2.2c-2.83-1.45-5.15-3.76-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM19 12h2c0-4.97-4.03-9-9-9v2c3.87 0 7 3.13 7 7zm-4 0h2c0-2.76-2.24-5-5-5v2c1.66 0 3 1.34 3 3z"})}),_t=({className:w})=>q.jsx("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08a.956.956 0 0 1-.29-.7c0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28a11.27 11.27 0 0 0-2.67-1.85.996.996 0 0 1-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"})}),ol=({className:w})=>q.jsx("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M6.5 5.5 12 11l7-7-1-1-6 6-4.5-4.5H11V3H5v6h1.5V5.5zm17.21 11.17C20.66 13.78 16.54 12 12 12 7.46 12 3.34 13.78.29 16.67c-.18.18-.29.43-.29.71s.11.53.29.71l2.48 2.48c.18.18.43.29.71.29.27 0 .52-.11.7-.28.79-.74 1.69-1.36 2.66-1.85.33-.16.56-.5.56-.9v-3.1c1.45-.48 3-.73 4.6-.73 1.6 0 3.15.25 4.6.72v3.1c0 .39.23.74.56.9.98.49 1.87 1.12 2.67 1.85.18.18.43.28.7.28.28 0 .53-.11.71-.29l2.48-2.48c.18-.18.29-.43.29-.71s-.12-.52-.3-.7z"})}),Si=({className:w})=>q.jsxs("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:[q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"}),q.jsx("path",{d:"M16 3l-5 5-2-2-1.5 1.5L11 11l6.5-6.5z"})]}),Ai=({className:w})=>q.jsxs("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:[q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"}),q.jsx("path",{d:"M19 6.41L17.59 5 15 7.59 12.41 5 11 6.41 13.59 9 11 11.59 12.41 13 15 10.41 17.59 13 19 11.59 16.41 9z"})]}),Ri=({className:w})=>q.jsx("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M13 3a9 9 0 0 0-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0 0 13 21a9 9 0 0 0 0-18zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"})}),bi=({className:w})=>q.jsx("svg",{className:w,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})});function wi({className:w,labels:I}){const{status:i,callNumber:_,setCallNumber:R,callHistory:t,currentCallDuration:d,startCall:h,endCall:l,isReady:g,connectionStatus:c}=al(),[A,U]=re.useState(!1),v={...zl,...I},$=(()=>{switch(i){case"progress":return{text:`${v.calling}...`,color:"text-yellow-500",Icon:vi};case"confirmed":return{text:`${v.inCall} - ${pt(d)}`,color:"text-green-500",Icon:Ei};case"failed":return{text:v.callEnded,color:"text-red-500",Icon:ol};case"ended":return{text:v.callEnded,color:"text-gray-500",Icon:_t};default:return{text:v.inactive,color:"text-gray-300",Icon:Es}}})();return q.jsxs("div",{className:Ts("tbi-phone w-full max-w-md mx-auto bg-white rounded-2xl shadow-lg border border-gray-200 p-2",w),children:[i==="disconnected"&&q.jsxs("div",{className:"flex gap-2 items-center",children:[q.jsx("button",{onClick:()=>U(!0),className:"h-8 w-8 flex items-center justify-center rounded-xl border border-gray-200 hover:bg-gray-50 transition-colors",type:"button",children:q.jsx(Ri,{className:"w-4 h-4"})}),q.jsx("input",{type:"text",value:_,onChange:C=>R(C.target.value),onKeyDown:C=>{C.key==="Enter"&&h(_)},placeholder:v.placeholder,className:"flex-1 h-8 px-3 rounded-xl border border-gray-200 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent"}),q.jsx("button",{onClick:()=>h(_),disabled:_.length<9||!g,className:"h-8 w-8 flex items-center justify-center rounded-xl bg-green-500 hover:bg-green-600 disabled:bg-gray-300 disabled:cursor-not-allowed text-white transition-colors",type:"button",title:g?"Call":"Connecting...",children:c==="connecting"?q.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):q.jsx(Es,{className:"w-4 h-4"})})]}),i==="progress"&&q.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[q.jsxs("div",{className:"relative",children:[q.jsx($.Icon,{className:"w-12 h-12 text-yellow-500 animate-pulse"}),q.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-yellow-500/30 animate-ping"})]}),q.jsxs("div",{className:"text-center",children:[q.jsxs("p",{className:"text-base font-semibold",children:[v.calling," ",_]}),q.jsx("p",{className:"text-sm text-gray-500",children:v.waitingResponse})]}),q.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-6 py-2 rounded-full bg-red-500 hover:bg-red-600 text-white text-sm font-medium transition-colors",type:"button",children:[q.jsx(_t,{className:"w-4 h-4"}),v.cancel]})]}),i==="confirmed"&&q.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[q.jsxs("div",{className:"relative",children:[q.jsx($.Icon,{className:"w-12 h-12 text-green-500"}),q.jsx("div",{className:"absolute inset-0 rounded-full bg-green-500/20 animate-pulse"})]}),q.jsxs("div",{className:"text-center space-y-1",children:[q.jsx("p",{className:"text-xl font-bold",children:_}),q.jsx("p",{className:"text-2xl font-mono text-green-600 tabular-nums",children:pt(d)})]}),q.jsxs("button",{onClick:l,className:"flex items-center gap-2 px-6 py-2 rounded-full bg-red-500 hover:bg-red-600 text-white text-sm font-medium transition-colors",type:"button",children:[q.jsx(_t,{className:"w-4 h-4"}),v.hangUp]})]}),(i==="failed"||i==="ended")&&q.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[q.jsx($.Icon,{className:Ts("w-12 h-12",i==="failed"?"text-red-500":"text-gray-500")}),q.jsx("div",{className:"text-center",children:q.jsx("p",{className:"text-base font-semibold",children:$.text})})]}),A&&q.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[q.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:()=>U(!1)}),q.jsx("div",{className:"fixed right-0 top-0 h-full w-full max-w-md bg-white shadow-xl",children:q.jsxs("div",{className:"flex flex-col h-full",children:[q.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[q.jsxs("div",{children:[q.jsx("h2",{className:"text-lg font-semibold",children:v.callHistory}),q.jsx("p",{className:"text-sm text-gray-500",children:t.length===0?v.noCallsRegistered:`${t.length} ${v.callsRegistered}`})]}),q.jsx("button",{onClick:()=>U(!1),className:"h-8 w-8 flex items-center justify-center rounded-lg hover:bg-gray-100 transition-colors",type:"button",children:q.jsx(bi,{className:"w-5 h-5"})})]}),q.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:t.length===0?q.jsxs("div",{className:"text-center py-12 text-gray-500",children:[q.jsx(_t,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),q.jsx("p",{children:v.noCalls})]}):q.jsx("div",{className:"space-y-2",children:t.map((C,y)=>q.jsx(yi,{entry:C,index:y,onCall:()=>{R(C.number),U(!1),h(C.number)}},C.id))})})]})})]})]})}function yi({entry:w,index:I,onCall:i}){const _=()=>{switch(w.status){case"completed":return q.jsx(Si,{className:"w-4 h-4 text-green-600"});case"failed":return q.jsx(Ai,{className:"w-4 h-4 text-red-600"});case"missed":return q.jsx(ol,{className:"w-4 h-4 text-yellow-600"})}},R=()=>{switch(w.status){case"completed":return"bg-green-100";case"failed":return"bg-red-100";case"missed":return"bg-yellow-100"}};return q.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 transition-colors duration-200",style:{animationDelay:`${I*30}ms`},children:[q.jsx("div",{className:Ts("w-9 h-9 rounded-full flex items-center justify-center shrink-0",R()),children:_()}),q.jsxs("div",{className:"flex-1 min-w-0",children:[q.jsx("p",{className:"font-medium text-sm truncate",children:w.number}),q.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[q.jsx("span",{children:new Date(w.timestamp).toLocaleString("es-ES",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}),w.duration>0&&q.jsxs(q.Fragment,{children:[q.jsx("span",{children:"•"}),q.jsx("span",{className:"font-mono tabular-nums",children:pt(w.duration)})]})]})]}),q.jsx("button",{onClick:i,className:"h-8 w-8 flex items-center justify-center shrink-0 rounded-lg hover:bg-gray-100 transition-colors",type:"button",children:q.jsx(Es,{className:"w-4 h-4"})})]})}function Ii({config:w,className:I,onCallStart:i,onCallEnd:_,onStatusChange:R,labels:t}){return q.jsx(il,{config:w,onCallStart:i,onCallEnd:_,onStatusChange:R,children:q.jsx(wi,{className:I,labels:t})})}exports.Phone=Ii;exports.PhoneProvider=il;exports.formatDuration=pt;exports.usePhone=al;
68
+ `,c.send(T)}return _s}var dt={},Kn;function pi(){if(Kn)return dt;Kn=1;const b=fe(),y=oe(),i=Ce(),_=ye(),S=ll(),t=we();dt.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:y.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:y.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:y.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${b.createRandomToken(12)}.invalid`};const d={mandatory:{sockets(h){const n=[];if(S.isSocket(h))n.push({socket:h});else if(Array.isArray(h)&&h.length)for(const m of h)Object.prototype.hasOwnProperty.call(m,"socket")&&S.isSocket(m.socket)?n.push(m):S.isSocket(m)&&n.push({socket:m});else return;return n},uri(h){/^sip:/i.test(h)||(h=`${y.SIP}:${h}`);const n=_.parse(h);if(n)return n.user?n:void 0}},optional:{authorization_user(h){if(i.parse(`"${h}"`,"quoted_string")!==-1)return h},authorization_jwt(h){if(typeof h=="string")return h},user_agent(h){if(typeof h=="string")return h},connection_recovery_max_interval(h){if(b.isDecimal(h)){const n=Number(h);if(n>0)return n}},connection_recovery_min_interval(h){if(b.isDecimal(h)){const n=Number(h);if(n>0)return n}},contact_uri(h){if(typeof h=="string"){const n=i.parse(h,"SIP_URI");if(n!==-1)return n}},display_name(h){return h},instance_id(h){if(/^uuid:/i.test(h)&&(h=h.substr(5)),i.parse(h,"uuid")!==-1)return h},no_answer_timeout(h){if(b.isDecimal(h)){const n=Number(h);if(n>0)return n}},session_timers(h){if(typeof h=="boolean")return h},session_timers_refresh_method(h){if(typeof h=="string"&&(h=h.toUpperCase(),h===y.INVITE||h===y.UPDATE))return h},session_timers_force_refresher(h){if(typeof h=="boolean")return h},password(h){return String(h)},realm(h){return String(h)},ha1(h){return String(h)},register(h){if(typeof h=="boolean")return h},register_expires(h){if(b.isDecimal(h)){const n=Number(h);if(n>=0)return n}},register_from_tag_trail(h){return typeof h=="function"?h:String(h)},registrar_server(h){/^sip:/i.test(h)||(h=`${y.SIP}:${h}`);const n=_.parse(h);if(n)return n.user?void 0:n},use_preloaded_route(h){if(typeof h=="boolean")return h},extra_headers(h){const n=[];if(Array.isArray(h)&&h.length)for(const m of h)typeof m=="string"&&n.push(m);else return;return n}}};return dt.load=(h,n)=>{for(const m in d.mandatory)if(n.hasOwnProperty(m)){const c=n[m],R=d.mandatory[m](c);if(R!==void 0)h[m]=R;else throw new t.ConfigurationError(m,c)}else throw new t.ConfigurationError(m);for(const m in d.optional)if(n.hasOwnProperty(m)){const c=n[m];if(b.isEmpty(c))continue;const R=d.optional[m](c);if(R!==void 0)h[m]=R;else throw new t.ConfigurationError(m,c)}},dt}var ps,Yn;function mi(){if(Yn)return ps;Yn=1;const b=Ie().EventEmitter,y=ce(),i=oe(),_=ri(),S=nl(),t=ci(),d=fi(),h=We(),n=hi(),m=fe(),c=we(),R=ye(),D=di(),E=Se(),N=_i(),$=pi(),C=new y("UA"),I={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};ps=class extends b{static get C(){return I}constructor(p){if(!p)throw new TypeError("Not enough arguments");const A=["password","ha1","authorization_jwt"];C.debug("new() [configuration:%o]",Object.entries(p).filter(([O])=>!A.includes(O))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},$.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=I.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(p)}catch(O){throw this._status=I.STATUS_NOT_READY,this._error=I.CONFIGURATION_ERROR,O}this._registrator=new _(this)}get C(){return I}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){C.debug("start()"),this._status===I.STATUS_INIT?this._transport.connect():this._status===I.STATUS_USER_CLOSED?(C.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=I.STATUS_INIT,this._transport.connect()):this._status===I.STATUS_READY?C.debug("UA is in READY status, not restarted"):C.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){C.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(p){C.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(p)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(p,A){C.debug("call()");const O=new S(this);return O.connect(p,A),O}sendMessage(p,A,O){C.debug("sendMessage()");const v=new t(this);return v.send(p,A,O),v}sendOptions(p,A,O){C.debug("sendOptions()");const v=new d(this);return v.send(p,A,O),v}terminateSessions(p){C.debug("terminateSessions()");for(const A in this._sessions)this._sessions[A].isEnded()||this._sessions[A].terminate(p)}stop(){if(C.debug("stop()"),this._dynConfiguration={},this._status===I.STATUS_USER_CLOSED){C.debug("UA already closed");return}this._registrator.close();const p=Object.keys(this._sessions).length;for(const O in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,O)){C.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=I.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&&p===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(p){return m.normalizeTarget(p,this._configuration.hostport_params)}get(p){switch(p){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:C.warn('get() | cannot get "%s" parameter in runtime',p);return}}set(p,A){switch(p){case"authorization_user":{this._configuration.authorization_user=String(A);break}case"password":{this._configuration.password=String(A);break}case"realm":{this._configuration.realm=String(A);break}case"ha1":{this._configuration.ha1=String(A),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(A);break}case"display_name":{this._configuration.display_name=A;break}case"extra_headers":{this._configuration.extra_headers=A;break}default:return C.warn('set() | cannot set "%s" parameter in runtime',p),!1}return!0}newTransaction(p){this._transactions[p.type][p.id]=p,this.emit("newTransaction",{transaction:p})}destroyTransaction(p){delete this._transactions[p.type][p.id],this.emit("transactionDestroyed",{transaction:p})}newDialog(p){this._dialogs[p.id]=p}destroyDialog(p){delete this._dialogs[p.id]}newMessage(p,A){this._applicants[p]=p,this.emit("newMessage",A)}newOptions(p,A){this._applicants[p]=p,this.emit("newOptions",A)}destroyMessage(p){delete this._applicants[p]}newRTCSession(p,A){this._sessions[p.id]=p,this.emit("newRTCSession",A)}destroyRTCSession(p){delete this._sessions[p.id]}registered(p){this.emit("registered",p)}unregistered(p){this.emit("unregistered",p)}registrationFailed(p){this.emit("registrationFailed",p)}receiveRequest(p){const A=p.method;if(p.ruri.user!==this._configuration.uri.user&&p.ruri.user!==this._contact.uri.user){C.debug("Request-URI does not point to us"),p.method!==i.ACK&&p.reply_sl(404);return}if(p.ruri.scheme===i.SIPS){p.reply_sl(416);return}if(h.checkTransaction(this,p))return;if(A===i.INVITE?new h.InviteServerTransaction(this,this._transport,p):A!==i.ACK&&A!==i.CANCEL&&new h.NonInviteServerTransaction(this,this._transport,p),A===i.OPTIONS){if(this.listeners("newOptions").length===0){p.reply(200);return}new d(this).init_incoming(p)}else if(A===i.MESSAGE){if(this.listeners("newMessage").length===0){p.reply(405);return}new t(this).init_incoming(p)}else if(A===i.INVITE&&!p.to_tag&&this.listeners("newRTCSession").length===0){p.reply(405);return}let O,v;if(p.to_tag)O=this._findDialog(p.call_id,p.from_tag,p.to_tag),O?O.receiveRequest(p):A===i.NOTIFY?(v=this._findSession(p),v?v.receiveRequest(p):(C.debug("received NOTIFY request for a non existent subscription"),p.reply(481,"Subscription does not exist"))):A!==i.ACK&&p.reply(481);else switch(A){case i.INVITE:if(window.RTCPeerConnection)if(p.hasHeader("replaces")){const w=p.replaces;O=this._findDialog(w.call_id,w.from_tag,w.to_tag),O?(v=O.owner,v.isEnded()?p.reply(603):v.receiveRequest(p)):p.reply(481)}else v=new S(this),v.init_incoming(p);else C.warn("INVITE received but WebRTC is not supported"),p.reply(488);break;case i.BYE:p.reply(481);break;case i.CANCEL:v=this._findSession(p),v?v.receiveRequest(p):C.debug("received CANCEL request for a non existent session");break;case i.ACK:break;case i.NOTIFY:this.emit("sipEvent",{event:p.event,request:p}),p.reply(200);break;default:p.reply(405);break}}_findSession({call_id:p,from_tag:A,to_tag:O}){const v=p+A,w=this._sessions[v],U=p+O,M=this._sessions[U];return w||M||null}_findDialog(p,A,O){let v=p+A+O,w=this._dialogs[v];return w||(v=p+O+A,w=this._dialogs[v],w||null)}_loadConfig(p){try{$.load(this._configuration,p)}catch(v){throw v}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=m.newUUID()),this._configuration.jssip_id=m.createRandomToken(5);const A=this._configuration.uri.clone();A.user=null,this._configuration.hostport_params=A.toString().replace(/^sip:/i,"");try{this._transport=new n(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=F.bind(this),this._transport.onconnect=H.bind(this),this._transport.ondisconnect=o.bind(this),this._transport.ondata=f.bind(this)}catch(v){throw C.warn(v),new c.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 v=this._configuration.uri.clone();v.user=null,v.clearParams(),v.clearHeaders(),this._configuration.registrar_server=v}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new R("sip",m.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(v={}){const w=v.anonymous||null,U=v.outbound||null;let M="<";return w?M+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":M+=this.pub_gruu||this.uri.toString(),U&&(w?!this.temp_gruu:!this.pub_gruu)&&(M+=";ob"),M+=">",M}};const O=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(const v in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,v)&&(O.indexOf(v)!==-1?Object.defineProperty(this._configuration,v,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,v,{writable:!1,configurable:!1}));C.debug("configuration parameters after validation:");for(const v in this._configuration)if(Object.prototype.hasOwnProperty.call($.settings,v))switch(v){case"uri":case"registrar_server":C.debug(`- ${v}: ${this._configuration[v]}`);break;case"password":case"ha1":case"authorization_jwt":C.debug(`- ${v}: NOT SHOWN`);break;default:C.debug(`- ${v}: ${JSON.stringify(this._configuration[v])}`)}}};function F(T){this.emit("connecting",T)}function H(T){this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_READY,this._error=null,this.emit("connected",T),this._dynConfiguration.register&&this._registrator.register())}function o(T){const p=["nict","ict","nist","ist"];for(const A of p)for(const O in this._transactions[A])Object.prototype.hasOwnProperty.call(this._transactions[A],O)&&this._transactions[A][O].onTransportError();this.emit("disconnected",T),this._registrator.onTransportClosed(),this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_NOT_READY,this._error=I.NETWORK_ERROR)}function f(T){const p=T.transport;let A=T.message;if(A=D.parseMessage(A,this),!!A&&!(this._status===I.STATUS_USER_CLOSED&&A instanceof E.IncomingRequest)&&N(A,this,p)){if(A instanceof E.IncomingRequest)A.transport=p,this.receiveRequest(A);else if(A instanceof E.IncomingResponse){let O;switch(A.method){case i.INVITE:O=this._transactions.ict[A.via_branch],O&&O.receiveResponse(A);break;case i.ACK:break;default:O=this._transactions.nict[A.via_branch],O&&O.receiveResponse(A);break}}}}return ps}var ms,Jn;function gi(){if(Jn)return ms;Jn=1;const b=ce(),y=Ce(),i=new b("WebSocketInterface");return ms=class{constructor(S){i.debug('new() [url:"%s"]',S),this._url=S,this._sip_uri=null,this._via_transport=null,this._ws=null;const t=y.parse(S,"absoluteURI");if(t===-1)throw i.warn(`invalid WebSocket URI: ${S}`),new TypeError(`Invalid argument: ${S}`);if(t.scheme!=="wss"&&t.scheme!=="ws")throw i.warn(`invalid WebSocket URI scheme: ${t.scheme}`),new TypeError(`Invalid argument: ${S}`);this._sip_uri=`sip:${t.host}${t.port?`:${t.port}`:""};transport=ws`,this._via_transport=t.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(S){this._via_transport=S.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(i.debug("connect()"),this.isConnected()){i.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){i.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),i.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(S){this._onError(S)}}disconnect(){i.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(S){return i.debug("send()"),this.isConnected()?(this._ws.send(S),!0):(i.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(){i.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:S,code:t,reason:d}){i.debug(`WebSocket ${this._url} closed`),S===!1&&i.debug("WebSocket abrupt disconnection"),this.ondisconnect(!S,t,d)}_onMessage({data:S}){i.debug("received WebSocket message"),this.ondata(S)}_onError(S){i.warn(`WebSocket ${this._url} error: `,S)}},ms}var gs,Xn;function Ti(){if(Xn)return gs;Xn=1;const b=Zn,y=oe(),i=we(),_=fe(),S=mi(),t=ye(),d=As(),h=Ce(),n=gi(),m=vs()("JsSIP"),c=nl();return m("version %s",b.version),gs={C:y,Exceptions:i,Utils:_,UA:S,URI:t,NameAddrHeader:d,WebSocketInterface:n,Grammar:h,RTCSession:c,debug:vs(),get name(){return b.title},get version(){return b.version}},gs}var Ci=Ti();const Qn=Yl(Ci);let Me=null,Ts=null;function vi(b){return`${b.websocketUrl}|${b.sipUri}|${b.authorizationUser}`}function Ei(b){const y=vi(b);if(Me&&Ts===y)return Me;if(Me&&Ts!==y){try{Me.ua.stop()}catch{}Me=null}Ts=y;const _={sockets:[new Qn.WebSocketInterface(b.websocketUrl)],uri:b.sipUri,password:b.password,registrar_server:b.registrarServer,display_name:b.displayName,authorization_user:b.authorizationUser,connection_recovery_min_interval:2,connection_recovery_max_interval:30},S=new Qn.UA(_),t=document.createElement("audio");t.autoplay=!0;const d={ua:S,audio:t,isStarted:!1,listeners:new Set};return S.on("connecting",()=>{d.listeners.forEach(h=>h.onConnecting?.())}),S.on("connected",()=>{d.listeners.forEach(h=>h.onConnected?.())}),S.on("disconnected",()=>{d.listeners.forEach(h=>h.onDisconnected?.())}),S.on("registered",()=>{d.listeners.forEach(h=>h.onRegistered?.())}),S.on("unregistered",()=>{d.listeners.forEach(h=>h.onUnregistered?.())}),S.on("registrationFailed",h=>{d.listeners.forEach(n=>n.onRegistrationFailed?.(h?.cause))}),S.on("newRTCSession",h=>{const n=h.session;n.direction==="outgoing"&&(d.listeners.forEach(m=>m.onNewSession?.(n)),n.connection&&(n.connection.addEventListener("addstream",m=>{var c=document.createElement("audio");m.streams!==void 0&&m.streams.length!==0&&(c.srcObject=m.streams[0],c.play())}),n.connection.addEventListener("track",m=>{var c=document.createElement("audio");c.srcObject=m.streams[0],c.play()})))}),Me=d,d}function Si(b){b.isStarted||(b.ua.start(),b.isStarted=!0)}function Ai(b,y){b.listeners.add(y)}function Ri(b,y){b.listeners.delete(y)}function bi(b){return{isReady:b.ua.isRegistered(),isConnected:b.ua.isConnected()}}const il=re.createContext(null);function al({config:b,children:y,onCallStart:i,onCallEnd:_,onStatusChange:S}){const[t,d]=re.useState(""),[h,n]=re.useState("disconnected"),[m,c]=re.useState(null),[R,D]=re.useState(0),[E,N]=re.useState([]),[$,C]=re.useState(!1),[I,F]=re.useState("connecting"),H=re.useRef(null),o=re.useRef(null),f=re.useRef(null);re.useEffect(()=>{o.current=m},[m]),re.useEffect(()=>{const v=Ei(b);f.current=v;const w=bi(v);w.isReady?(C(!0),F("connected")):w.isConnected&&F("connected");const U={onConnecting:()=>F("connecting"),onConnected:()=>F("connected"),onDisconnected:()=>{F("disconnected"),C(!1)},onRegistered:()=>{C(!0),F("connected")},onUnregistered:()=>C(!1),onRegistrationFailed:M=>{console.error("Registration failed:",M),C(!1),F("failed")},onNewSession:M=>{H.current=M}};return Ai(v,U),Si(v),()=>{Ri(v,U)}},[b.websocketUrl,b.sipUri,b.password,b.registrarServer,b.displayName,b.authorizationUser]),re.useEffect(()=>{S?.(h)},[h,S]),re.useEffect(()=>{const v=localStorage.getItem("tbi-phone-call-history");if(v)try{N(JSON.parse(v))}catch(w){console.error("Error loading call history",w)}},[]),re.useEffect(()=>{E.length>0&&localStorage.setItem("tbi-phone-call-history",JSON.stringify(E))},[E]),re.useEffect(()=>{if(h==="confirmed"&&m){const v=setInterval(()=>{D(Math.floor((Date.now()-m)/1e3))},1e3);return()=>clearInterval(v)}else D(0)},[h,m]),re.useEffect(()=>{const v=w=>{const U=w.detail.number;h==="disconnected"&&A(U)};return window.addEventListener("StartCallEvent",v),()=>{window.removeEventListener("StartCallEvent",v)}},[h]);const T=re.useCallback((v,w,U)=>{const M={id:Date.now().toString(),number:v,timestamp:Date.now(),duration:w,status:U};N(Y=>[M,...Y].slice(0,50))},[]),p=re.useCallback(()=>{H.current&&(H.current.terminate(),H.current=null)},[]),A=re.useCallback(v=>{const w=f.current;if(!v.trim()||!w)return;if(!$){console.warn("Phone is not ready yet. Please wait for registration.");return}d(v),i?.(v);const M={eventHandlers:{progress:()=>{n("progress")},failed:Y=>{console.error("Call failed:",Y?.cause),n("failed"),T(v,0,"failed"),_?.(v,0,"failed"),H.current=null,setTimeout(()=>n("disconnected"),3e3)},ended:()=>{n("ended");const Y=o.current,B=Y?Math.floor((Date.now()-Y)/1e3):0;T(v,B,"completed"),_?.(v,B,"completed"),H.current=null,setTimeout(()=>{n("disconnected"),c(null)},2e3)},confirmed:()=>{n("confirmed"),c(Date.now())}},mediaConstraints:{audio:!0,video:!1}};n("progress");try{const Y=w.ua.call(v,M);H.current=Y}catch(Y){console.error("Failed to start call:",Y),n("failed"),T(v,0,"failed"),setTimeout(()=>n("disconnected"),3e3)}},[T,i,_,$]),O={status:h,callNumber:t,setCallNumber:d,callHistory:E,currentCallDuration:R,startCall:A,endCall:p,isReady:$,connectionStatus:I};return q.jsx(il.Provider,{value:O,children:y})}function ol(){const b=re.useContext(il);if(!b)throw new Error("usePhone must be used within a PhoneProvider");return b}const Ss=({className:b})=>q.jsx("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"})}),wi=({className:b})=>q.jsx("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M15.05 5A7 7 0 0 1 19 8.95M15.05 1A11 11 0 0 1 23 8.94m-1 7.98v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),yi=({className:b})=>q.jsx("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.12-.74-.03-1.02.24l-2.2 2.2c-2.83-1.45-5.15-3.76-6.59-6.59l2.2-2.21c.28-.26.36-.65.25-1C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM19 12h2c0-4.97-4.03-9-9-9v2c3.87 0 7 3.13 7 7zm-4 0h2c0-2.76-2.24-5-5-5v2c1.66 0 3 1.34 3 3z"})}),_t=({className:b})=>q.jsx("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08a.956.956 0 0 1-.29-.7c0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28a11.27 11.27 0 0 0-2.67-1.85.996.996 0 0 1-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z"})}),ul=({className:b})=>q.jsx("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M6.5 5.5 12 11l7-7-1-1-6 6-4.5-4.5H11V3H5v6h1.5V5.5zm17.21 11.17C20.66 13.78 16.54 12 12 12 7.46 12 3.34 13.78.29 16.67c-.18.18-.29.43-.29.71s.11.53.29.71l2.48 2.48c.18.18.43.29.71.29.27 0 .52-.11.7-.28.79-.74 1.69-1.36 2.66-1.85.33-.16.56-.5.56-.9v-3.1c1.45-.48 3-.73 4.6-.73 1.6 0 3.15.25 4.6.72v3.1c0 .39.23.74.56.9.98.49 1.87 1.12 2.67 1.85.18.18.43.28.7.28.28 0 .53-.11.71-.29l2.48-2.48c.18-.18.29-.43.29-.71s-.12-.52-.3-.7z"})}),Ii=({className:b})=>q.jsxs("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:[q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"}),q.jsx("path",{d:"M16 3l-5 5-2-2-1.5 1.5L11 11l6.5-6.5z"})]}),xi=({className:b})=>q.jsxs("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:[q.jsx("path",{d:"M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"}),q.jsx("path",{d:"M19 6.41L17.59 5 15 7.59 12.41 5 11 6.41 13.59 9 11 11.59 12.41 13 15 10.41 17.59 13 19 11.59 16.41 9z"})]}),Ni=({className:b})=>q.jsx("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M13 3a9 9 0 0 0-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0 0 13 21a9 9 0 0 0 0-18zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"})}),Oi=({className:b})=>q.jsx("svg",{className:b,viewBox:"0 0 24 24",fill:"currentColor",children:q.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})});function Di({className:b,labels:y}){const{status:i,callNumber:_,setCallNumber:S,callHistory:t,currentCallDuration:d,startCall:h,endCall:n,isReady:m,connectionStatus:c}=ol(),[R,D]=re.useState(!1),E={...Kl,...y},$=(()=>{switch(i){case"progress":return{text:`${E.calling}...`,color:"text-yellow-500",Icon:wi};case"confirmed":return{text:`${E.inCall} - ${pt(d)}`,color:"text-green-500",Icon:yi};case"failed":return{text:E.callEnded,color:"text-red-500",Icon:ul};case"ended":return{text:E.callEnded,color:"text-gray-500",Icon:_t};default:return{text:E.inactive,color:"text-gray-300",Icon:Ss}}})();return q.jsxs("div",{className:Cs("tbi-phone w-full max-w-md mx-auto bg-white rounded-2xl shadow-lg border border-gray-200 p-2",b),children:[i==="disconnected"&&q.jsxs("div",{className:"flex gap-2 items-center",children:[q.jsx("button",{onClick:()=>D(!0),className:"h-8 w-8 flex items-center justify-center rounded-xl border border-gray-200 hover:bg-gray-50 transition-colors",type:"button",children:q.jsx(Ni,{className:"w-4 h-4"})}),q.jsx("input",{type:"text",value:_,onChange:C=>S(C.target.value),onKeyDown:C=>{C.key==="Enter"&&h(_)},placeholder:E.placeholder,className:"flex-1 h-8 px-3 rounded-xl border border-gray-200 text-sm focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent"}),q.jsx("button",{onClick:()=>h(_),disabled:_.length<9||!m,className:"h-8 w-8 flex items-center justify-center rounded-xl bg-green-500 hover:bg-green-600 disabled:bg-gray-300 disabled:cursor-not-allowed text-white transition-colors",type:"button",title:m?"Call":"Connecting...",children:c==="connecting"?q.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):q.jsx(Ss,{className:"w-4 h-4"})})]}),i==="progress"&&q.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[q.jsxs("div",{className:"relative",children:[q.jsx($.Icon,{className:"w-12 h-12 text-yellow-500 animate-pulse"}),q.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-yellow-500/30 animate-ping"})]}),q.jsxs("div",{className:"text-center",children:[q.jsxs("p",{className:"text-base font-semibold",children:[E.calling," ",_]}),q.jsx("p",{className:"text-sm text-gray-500",children:E.waitingResponse})]}),q.jsxs("button",{onClick:n,className:"flex items-center gap-2 px-6 py-2 rounded-full bg-red-500 hover:bg-red-600 text-white text-sm font-medium transition-colors",type:"button",children:[q.jsx(_t,{className:"w-4 h-4"}),E.cancel]})]}),i==="confirmed"&&q.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[q.jsxs("div",{className:"relative",children:[q.jsx($.Icon,{className:"w-12 h-12 text-green-500"}),q.jsx("div",{className:"absolute inset-0 rounded-full bg-green-500/20 animate-pulse"})]}),q.jsxs("div",{className:"text-center space-y-1",children:[q.jsx("p",{className:"text-xl font-bold",children:_}),q.jsx("p",{className:"text-2xl font-mono text-green-600 tabular-nums",children:pt(d)})]}),q.jsxs("button",{onClick:n,className:"flex items-center gap-2 px-6 py-2 rounded-full bg-red-500 hover:bg-red-600 text-white text-sm font-medium transition-colors",type:"button",children:[q.jsx(_t,{className:"w-4 h-4"}),E.hangUp]})]}),(i==="failed"||i==="ended")&&q.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[q.jsx($.Icon,{className:Cs("w-12 h-12",i==="failed"?"text-red-500":"text-gray-500")}),q.jsx("div",{className:"text-center",children:q.jsx("p",{className:"text-base font-semibold",children:$.text})})]}),R&&q.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[q.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:()=>D(!1)}),q.jsx("div",{className:"fixed right-0 top-0 h-full w-full max-w-md bg-white shadow-xl",children:q.jsxs("div",{className:"flex flex-col h-full",children:[q.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[q.jsxs("div",{children:[q.jsx("h2",{className:"text-lg font-semibold",children:E.callHistory}),q.jsx("p",{className:"text-sm text-gray-500",children:t.length===0?E.noCallsRegistered:`${t.length} ${E.callsRegistered}`})]}),q.jsx("button",{onClick:()=>D(!1),className:"h-8 w-8 flex items-center justify-center rounded-lg hover:bg-gray-100 transition-colors",type:"button",children:q.jsx(Oi,{className:"w-5 h-5"})})]}),q.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:t.length===0?q.jsxs("div",{className:"text-center py-12 text-gray-500",children:[q.jsx(_t,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),q.jsx("p",{children:E.noCalls})]}):q.jsx("div",{className:"space-y-2",children:t.map((C,I)=>q.jsx(Ui,{entry:C,index:I,onCall:()=>{S(C.number),D(!1),h(C.number)}},C.id))})})]})})]})]})}function Ui({entry:b,index:y,onCall:i}){const _=()=>{switch(b.status){case"completed":return q.jsx(Ii,{className:"w-4 h-4 text-green-600"});case"failed":return q.jsx(xi,{className:"w-4 h-4 text-red-600"});case"missed":return q.jsx(ul,{className:"w-4 h-4 text-yellow-600"})}},S=()=>{switch(b.status){case"completed":return"bg-green-100";case"failed":return"bg-red-100";case"missed":return"bg-yellow-100"}};return q.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 transition-colors duration-200",style:{animationDelay:`${y*30}ms`},children:[q.jsx("div",{className:Cs("w-9 h-9 rounded-full flex items-center justify-center shrink-0",S()),children:_()}),q.jsxs("div",{className:"flex-1 min-w-0",children:[q.jsx("p",{className:"font-medium text-sm truncate",children:b.number}),q.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[q.jsx("span",{children:new Date(b.timestamp).toLocaleString("es-ES",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}),b.duration>0&&q.jsxs(q.Fragment,{children:[q.jsx("span",{children:"•"}),q.jsx("span",{className:"font-mono tabular-nums",children:pt(b.duration)})]})]})]}),q.jsx("button",{onClick:i,className:"h-8 w-8 flex items-center justify-center shrink-0 rounded-lg hover:bg-gray-100 transition-colors",type:"button",children:q.jsx(Ss,{className:"w-4 h-4"})})]})}function Pi({config:b,className:y,onCallStart:i,onCallEnd:_,onStatusChange:S,labels:t}){return q.jsx(al,{config:b,onCallStart:i,onCallEnd:_,onStatusChange:S,children:q.jsx(Di,{className:y,labels:t})})}exports.Phone=Pi;exports.PhoneProvider=al;exports.formatDuration=pt;exports.usePhone=ol;