@tbisoftware/phone 1.0.11 → 1.0.12

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 (4) hide show
  1. package/README.md +309 -7
  2. package/dist/index.cjs +29 -29
  3. package/dist/index.js +2305 -2112
  4. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,49 +1,49 @@
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
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),K=require("react");function mt(...R){return R.filter(Boolean).join(" ")}function gt(R){const b=Math.floor(R/3600),i=Math.floor(R%3600/60),_=R%60;return b>0?`${b.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`:`${i.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`}const Jl={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 Xl(R){return R&&R.__esModule&&Object.prototype.hasOwnProperty.call(R,"default")?R.default:R}const Ql="JsSIP",Zl="3.11.1",tl={title:Ql,version:Zl};var Gt,gn;function ce(){if(gn)return Gt;gn=1;const R=tl;return Gt={USER_AGENT:`${R.title} ${R.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},Gt}var Bt,Tn;function be(){if(Tn)return Bt;Tn=1;class R 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 b 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 Bt={ConfigurationError:R,InvalidStateError:b,NotSupportedError:i,NotReadyError:_},Bt}var oe={},Wt,Cn;function bs(){if(Cn)return Wt;Cn=1;const R=ye(),b=Ce();return Wt=class sl{static parse(_){if(_=b.parse(_,"Name_Addr_Header"),_!==-1)return _}constructor(_,S,t){if(!_||!(_ instanceof R))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 sl(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 _}},Wt}var Vt,vn;function Ce(){return vn||(vn=1,Vt=(function(){function R(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 b={parse:function(i,_){var S={CRLF:m,DIGIT:c,ALPHA:A,HEXDIG:D,WSP:E,OCTET:N,DQUOTE:k,SP:C,HTAB:I,alphanum:H,reserved:F,unreserved:o,mark:f,escaped:g,LWS:p,SWS:w,HCOLON:U,TEXT_UTF8_TRIM:v,TEXT_UTF8char:y,UTF8_NONASCII:P,UTF8_CONT:O,LHEX:V,token:j,token_nodot:le,separators:ne,word:fe,STAR:Q,SLASH:_e,EQUAL:Z,LPAREN:xe,RPAREN:Ne,RAQUOT:Ae,LAQUOT:Re,COMMA:te,SEMI:X,COLON:Oe,LDQUOT:we,RDQUOT:Ke,comment:Y,ctext:z,quoted_string:J,quoted_string_clean:ee,qdtext:ie,quoted_pair:ae,SIP_URI_noparams:se,SIP_URI:ve,uri_scheme:pe,uri_scheme_sips:Is,uri_scheme_sip:xs,userinfo:Ye,user:Ns,user_unreserved:Ct,password:Os,hostport:Je,host:He,hostname:vt,domainlabel:Et,toplabel:Ds,IPv6reference:St,IPv6address:At,h16:G,ls32:me,IPv4address:Fe,dec_octet:ke,port:Us,uri_parameters:Ps,uri_parameter:Rt,transport_param:Ms,user_param:Ls,method_param:Hs,ttl_param:Fs,maddr_param:ks,lr_param:$s,other_param:qs,pname:js,pvalue:Gs,paramchar:$e,param_unreserved:Bs,headers:Ws,header:Xe,hname:Vs,hvalue:zs,hnv_unreserved:qe,Request_Response:hl,Request_Line:Ks,Request_URI:Ys,absoluteURI:wt,hier_part:Js,net_path:Xs,abs_path:Qe,opaque_part:Qs,uric:je,uric_no_slash:Zs,path_segments:er,segment:Ze,param:bt,pchar:Ge,scheme:tr,authority:sr,srvr:rr,reg_name:nr,query:lr,SIP_Version:yt,INVITEm:ir,ACKm:ar,OPTIONSm:or,BYEm:ur,CANCELm:cr,REGISTERm:fr,SUBSCRIBEm:hr,NOTIFYm:dr,REFERm:_r,Method:et,Status_Line:pr,Status_Code:mr,extension_code:gr,Reason_Phrase:Tr,Allow_Events:dl,Call_ID:_l,Contact:pl,contact_param:tt,name_addr:De,display_name:st,contact_params:It,c_p_q:Cr,c_p_expires:vr,delta_seconds:Ue,qvalue:Er,generic_param:ue,gen_value:Sr,Content_Disposition:ml,disp_type:Ar,disp_param:xt,handling_param:Rr,Content_Encoding:gl,Content_Length:Tl,Content_Type:Cl,media_type:wr,m_type:br,discrete_type:yr,composite_type:Ir,extension_token:rt,x_token:xr,m_subtype:Nr,m_parameter:Nt,m_value:Or,CSeq:vl,CSeq_value:Dr,Expires:El,Event:Sl,event_type:Be,From:Al,from_param:Ot,tag_param:Dt,Max_Forwards:Rl,Min_Expires:wl,Name_Addr_Header:bl,Proxy_Authenticate:yl,challenge:Ut,other_challenge:Ur,auth_param:We,digest_cln:nt,realm:Pr,realm_value:Mr,domain:Lr,URI:lt,nonce:Hr,nonce_value:Fr,opaque:kr,stale:$r,algorithm:qr,qop_options:jr,qop_value:it,Proxy_Require:Il,Record_Route:xl,rec_route:at,Reason:Nl,reason_param:Pt,reason_cause:Gr,Require:Ol,Route:Dl,route_param:ot,Subscription_State:Ul,substate_value:Br,subexp_params:Mt,event_reason_value:Wr,Subject:Pl,Supported:Ml,To:Ll,to_param:Lt,Via:Hl,via_param:ut,via_params:Ht,via_ttl:Vr,via_maddr:zr,via_received:Kr,via_branch:Yr,response_port:Jr,rport:Xr,sent_protocol:Qr,protocol_name:Zr,transport:en,sent_by:tn,via_host:sn,via_port:rn,ttl:Ft,WWW_Authenticate:Fl,Session_Expires:kl,s_e_expires:nn,s_e_params:kt,s_e_refresher:ln,extension_header:$l,header_value:an,message_body:ql,uuid_URI:jl,uuid:on,hex4:Ee,hex8:un,hex12:cn,Refer_To:Gl,Replaces:Bl,call_id:fn,replaces_param:$t,to_tag:hn,from_tag:dn,early_flag:_n};if(_!==void 0){if(S[_]===void 0)throw new Error("Invalid rule name: "+R(_)+".")}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,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
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 A(){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 k(){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 H(){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 F(){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=H(),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 g(){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,T){return T.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(T){return" "})()),e===null&&(t=l),e}function w(){var e;return e=p(),e=e!==null?e:"",e}function U(){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=w(),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,T;if(a=t,u=t,s=y(),s!==null)for(e=[];s!==null;)e.push(s),s=y();else e=null;if(e!==null){for(s=[],T=t,r=[],l=p();l!==null;)r.push(l),l=p();for(r!==null?(l=y(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;){for(s.push(r),T=t,r=[],l=p();l!==null;)r.push(l),l=p();r!==null?(l=y(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T)}s!==null?e=[e,s]:(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 y(){var e;return/^[!-~]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[!-~]")),e===null&&(e=P()),e}function P(){var e;return/^[\x80-\uFFFF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[\\x80-\\uFFFF]")),e}function O(){var e;return/^[\x80-\xBF]/.test(i.charAt(t))?(e=i.charAt(t),t++):(e=null,n("[\\x80-\\xBF]")),e}function V(){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 j(){var e,s,r;if(r=t,s=H(),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=H(),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 le(){var e,s,r;if(r=t,s=H(),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=H(),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 ne(){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=k(),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 fe(){var e,s,r;if(r=t,s=H(),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=k(),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=H(),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=k(),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 Q(){var e,s,r,l,a;return l=t,a=t,e=w(),e!==null?(i.charCodeAt(t)===42?(s="*",t++):(s=null,n('"*"')),s!==null?(r=w(),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=w(),e!==null?(i.charCodeAt(t)===47?(s="/",t++):(s=null,n('"/"')),s!==null?(r=w(),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 Z(){var e,s,r,l,a;return l=t,a=t,e=w(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s!==null?(r=w(),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=w(),e!==null?(i.charCodeAt(t)===40?(s="(",t++):(s=null,n('"("')),s!==null?(r=w(),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=w(),e!==null?(i.charCodeAt(t)===41?(s=")",t++):(s=null,n('")"')),s!==null?(r=w(),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=w(),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=w(),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 te(){var e,s,r,l,a;return l=t,a=t,e=w(),e!==null?(i.charCodeAt(t)===44?(s=",",t++):(s=null,n('","')),s!==null?(r=w(),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 X(){var e,s,r,l,a;return l=t,a=t,e=w(),e!==null?(i.charCodeAt(t)===59?(s=";",t++):(s=null,n('";"')),s!==null?(r=w(),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=w(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=w(),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 we(){var e,s,r,l;return r=t,l=t,e=w(),e!==null?(s=k(),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 Ke(){var e,s,r,l;return r=t,l=t,e=k(),e!==null?(s=w(),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 Y(){var e,s,r,l;if(l=t,e=xe(),e!==null){for(s=[],r=z(),r===null&&(r=ae(),r===null&&(r=Y()));r!==null;)s.push(r),r=z(),r===null&&(r=ae(),r===null&&(r=Y()));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 z(){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=P(),e===null&&(e=p())))),e}function J(){var e,s,r,l,a,u;if(a=t,u=t,e=w(),e!==null)if(s=k(),s!==null){for(r=[],l=ie(),l===null&&(l=ae());l!==null;)r.push(l),l=ie(),l===null&&(l=ae());r!==null?(l=k(),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(T){return i.substring(t,T)})(a)),e===null&&(t=a),e}function ee(){var e,s,r,l,a,u;if(a=t,u=t,e=w(),e!==null)if(s=k(),s!==null){for(r=[],l=ie(),l===null&&(l=ae());l!==null;)r.push(l),l=ie(),l===null&&(l=ae());r!==null?(l=k(),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(T){var M=i.substring(t,T).trim();return M.substring(1,M.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")})(a)),e===null&&(t=a),e}function ie(){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=P())))),e}function ae(){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 se(){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=Ye(),r=r!==null?r:"",r!==null?(l=Je(),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(T){try{x.uri=new pn(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,T,M;return T=t,M=t,e=pe(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Ye(),r=r!==null?r:"",r!==null?(l=Je(),l!==null?(a=Ps(),a!==null?(u=Ws(),u=u!==null?u:"",u!==null?e=[e,s,r,l,a,u]:(e=null,t=M)):(e=null,t=M)):(e=null,t=M)):(e=null,t=M)):(e=null,t=M)):(e=null,t=M),e!==null&&(e=(function($){try{x.uri=new pn(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=T),e}function pe(){var e;return e=Is(),e===null&&(e=xs()),e}function Is(){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 xs(){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 Ye(){var e,s,r,l,a,u;return l=t,a=t,e=Ns(),e!==null?(u=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Os(),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(T){x.user=decodeURIComponent(i.substring(t-1,T))})(l)),e===null&&(t=l),e}function Ns(){var e,s;if(s=o(),s===null&&(s=g(),s===null&&(s=Ct())),s!==null)for(e=[];s!==null;)e.push(s),s=o(),s===null&&(s=g(),s===null&&(s=Ct()));else e=null;return e}function Ct(){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 Os(){var e,s,r;for(r=t,e=[],s=o(),s===null&&(s=g(),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=g(),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 Je(){var e,s,r,l,a;return l=t,e=He(),e!==null?(a=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Us(),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 He(){var e,s;return s=t,e=vt(),e===null&&(e=Fe(),e===null&&(e=St())),e!==null&&(e=(function(r){return x.host=i.substring(t,r).toLowerCase(),x.host})(s)),e===null&&(t=s),e}function vt(){var e,s,r,l,a,u;for(l=t,a=t,e=[],u=t,s=Et(),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=Et(),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=Ds(),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(T){return x.host_type="domain",i.substring(t,T)})(l)),e===null&&(t=l),e}function Et(){var e,s,r,l;if(l=t,e=H(),e!==null){for(s=[],r=H(),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=H(),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 Ds(){var e,s,r,l;if(l=t,e=A(),e!==null){for(s=[],r=H(),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=H(),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 St(){var e,s,r,l,a;return l=t,a=t,i.charCodeAt(t)===91?(e="[",t++):(e=null,n('"["')),e!==null?(s=At(),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 At(){var e,s,r,l,a,u,T,M,$,W,re,Te,ct,jt,L,B;return jt=t,L=t,e=G(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=G(),r!==null?(i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=G(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(T=G(),T!==null?(i.charCodeAt(t)===58?(M=":",t++):(M=null,n('":"')),M!==null?($=G(),$!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,n('":"')),W!==null?(re=G(),re!==null?(i.charCodeAt(t)===58?(Te=":",t++):(Te=null,n('":"')),Te!==null?(ct=me(),ct!==null?e=[e,s,r,l,a,u,T,M,$,W,re,Te,ct]:(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=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=G(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(T=":",t++):(T=null,n('":"')),T!==null?(M=G(),M!==null?(i.charCodeAt(t)===58?($=":",t++):($=null,n('":"')),$!==null?(W=G(),W!==null?(i.charCodeAt(t)===58?(re=":",t++):(re=null,n('":"')),re!==null?(Te=me(),Te!==null?e=[e,s,r,l,a,u,T,M,$,W,re,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=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=G(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(T=":",t++):(T=null,n('":"')),T!==null?(M=G(),M!==null?(i.charCodeAt(t)===58?($=":",t++):($=null,n('":"')),$!==null?(W=me(),W!==null?e=[e,s,r,l,a,u,T,M,$,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=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=G(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(T=":",t++):(T=null,n('":"')),T!==null?(M=me(),M!==null?e=[e,s,r,l,a,u,T,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,t=L),e===null&&(L=t,i.substr(t,2)==="::"?(e="::",t+=2):(e=null,n('"::"')),e!==null?(s=G(),s!==null?(i.charCodeAt(t)===58?(r=":",t++):(r=null,n('":"')),r!==null?(l=G(),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=G(),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=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,n('"::"')),s!==null?(r=G(),r!==null?(i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=G(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(T=G(),T!==null?(i.charCodeAt(t)===58?(M=":",t++):(M=null,n('":"')),M!==null?($=G(),$!==null?(i.charCodeAt(t)===58?(W=":",t++):(W=null,n('":"')),W!==null?(re=me(),re!==null?e=[e,s,r,l,a,u,T,M,$,W,re]:(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,n('":"')),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,n('"::"')),r!==null?(l=G(),l!==null?(i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(T=":",t++):(T=null,n('":"')),T!==null?(M=G(),M!==null?(i.charCodeAt(t)===58?($=":",t++):($=null,n('":"')),$!==null?(W=me(),W!==null?e=[e,s,r,l,a,u,T,M,$,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,n('":"')),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,n('":"')),r!==null?(l=G(),l!==null?r=[r,l]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(i.substr(t,2)==="::"?(l="::",t+=2):(l=null,n('"::"')),l!==null?(a=G(),a!==null?(i.charCodeAt(t)===58?(u=":",t++):(u=null,n('":"')),u!==null?(T=G(),T!==null?(i.charCodeAt(t)===58?(M=":",t++):(M=null,n('":"')),M!==null?($=me(),$!==null?e=[e,s,r,l,a,u,T,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,t=L)):(e=null,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),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,n('":"')),r!==null?(l=G(),l!==null?r=[r,l]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=G(),a!==null?l=[l,a]:(l=null,t=B)):(l=null,t=B),l=l!==null?l:"",l!==null?(i.substr(t,2)==="::"?(a="::",t+=2):(a=null,n('"::"')),a!==null?(u=G(),u!==null?(i.charCodeAt(t)===58?(T=":",t++):(T=null,n('":"')),T!==null?(M=me(),M!==null?e=[e,s,r,l,a,u,T,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,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),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,n('":"')),r!==null?(l=G(),l!==null?r=[r,l]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=G(),a!==null?l=[l,a]:(l=null,t=B)):(l=null,t=B),l=l!==null?l:"",l!==null?(B=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),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,n('"::"')),u!==null?(T=me(),T!==null?e=[e,s,r,l,a,u,T]:(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,n('":"')),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,n('":"')),r!==null?(l=G(),l!==null?r=[r,l]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=G(),a!==null?l=[l,a]:(l=null,t=B)):(l=null,t=B),l=l!==null?l:"",l!==null?(B=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),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,n('":"')),u!==null?(T=G(),T!==null?u=[u,T]:(u=null,t=B)):(u=null,t=B),u=u!==null?u:"",u!==null?(i.substr(t,2)==="::"?(T="::",t+=2):(T=null,n('"::"')),T!==null?(M=G(),M!==null?e=[e,s,r,l,a,u,T,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,t=L),e===null&&(L=t,e=G(),e!==null?(B=t,i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),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,n('":"')),r!==null?(l=G(),l!==null?r=[r,l]:(r=null,t=B)):(r=null,t=B),r=r!==null?r:"",r!==null?(B=t,i.charCodeAt(t)===58?(l=":",t++):(l=null,n('":"')),l!==null?(a=G(),a!==null?l=[l,a]:(l=null,t=B)):(l=null,t=B),l=l!==null?l:"",l!==null?(B=t,i.charCodeAt(t)===58?(a=":",t++):(a=null,n('":"')),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,n('":"')),u!==null?(T=G(),T!==null?u=[u,T]:(u=null,t=B)):(u=null,t=B),u=u!==null?u:"",u!==null?(B=t,i.charCodeAt(t)===58?(T=":",t++):(T=null,n('":"')),T!==null?(M=G(),M!==null?T=[T,M]:(T=null,t=B)):(T=null,t=B),T=T!==null?T:"",T!==null?(i.substr(t,2)==="::"?(M="::",t+=2):(M=null,n('"::"')),M!==null?e=[e,s,r,l,a,u,T,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,t=L))))))))))))))),e!==null&&(e=(function(Yl){return x.host_type="IPv6",i.substring(t,Yl)})(jt)),e===null&&(t=jt),e}function G(){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=G(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=G(),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,T,M,$;return M=t,$=t,e=ke(),e!==null?(i.charCodeAt(t)===46?(s=".",t++):(s=null,n('"."')),s!==null?(r=ke(),r!==null?(i.charCodeAt(t)===46?(l=".",t++):(l=null,n('"."')),l!==null?(a=ke(),a!==null?(i.charCodeAt(t)===46?(u=".",t++):(u=null,n('"."')),u!==null?(T=ke(),T!==null?e=[e,s,r,l,a,u,T]:(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$)):(e=null,t=$),e!==null&&(e=(function(W){return x.host_type="IPv4",i.substring(t,W)})(M)),e===null&&(t=M),e}function ke(){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 Us(){var e,s,r,l,a,u,T;return u=t,T=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=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T),e!==null&&(e=(function(M,$){return $=parseInt($.join("")),x.port=$,$})(u,e)),e===null&&(t=u),e}function Ps(){var e,s,r,l;for(e=[],l=t,i.charCodeAt(t)===59?(s=";",t++):(s=null,n('";"')),s!==null?(r=Rt(),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=Rt(),r!==null?s=[s,r]:(s=null,t=l)):(s=null,t=l);return e}function Rt(){var e;return e=Ms(),e===null&&(e=Ls(),e===null&&(e=Hs(),e===null&&(e=Fs(),e===null&&(e=ks(),e===null&&(e=$s(),e===null&&(e=qs())))))),e}function Ms(){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=j())))),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 Ls(){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=j())),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 Hs(){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=et(),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 Fs(){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=Ft(),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 ks(){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=He(),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 $s(){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=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(T){x.uri_params||(x.uri_params={}),x.uri_params.lr=void 0})()),e===null&&(t=l),e}function qs(){var e,s,r,l,a,u;return l=t,a=t,e=js(),e!==null?(u=t,i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s!==null?(r=Gs(),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(T,M,$){x.uri_params||(x.uri_params={}),typeof $>"u"?$=void 0:$=$[1],x.uri_params[M.toLowerCase()]=$})(l,e[0],e[1])),e===null&&(t=l),e}function js(){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 Gs(){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=Bs(),e===null&&(e=o(),e===null&&(e=g())),e}function Bs(){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 Ws(){var e,s,r,l,a,u,T;if(u=t,i.charCodeAt(t)===63?(e="?",t++):(e=null,n('"?"')),e!==null)if(s=Xe(),s!==null){for(r=[],T=t,i.charCodeAt(t)===38?(l="&",t++):(l=null,n('"&"')),l!==null?(a=Xe(),a!==null?l=[l,a]:(l=null,t=T)):(l=null,t=T);l!==null;)r.push(l),T=t,i.charCodeAt(t)===38?(l="&",t++):(l=null,n('"&"')),l!==null?(a=Xe(),a!==null?l=[l,a]:(l=null,t=T)):(l=null,t=T);r!==null?e=[e,s,r]:(e=null,t=u)}else e=null,t=u;else e=null,t=u;return e}function Xe(){var e,s,r,l,a;return l=t,a=t,e=Vs(),e!==null?(i.charCodeAt(t)===61?(s="=",t++):(s=null,n('"="')),s!==null?(r=zs(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T,M){T=T.join("").toLowerCase(),M=M.join(""),x.uri_headers||(x.uri_headers={}),x.uri_headers[T]?x.uri_headers[T].push(M):x.uri_headers[T]=[M]})(l,e[0],e[2])),e===null&&(t=l),e}function Vs(){var e,s;if(s=qe(),s===null&&(s=o(),s===null&&(s=g())),s!==null)for(e=[];s!==null;)e.push(s),s=qe(),s===null&&(s=o(),s===null&&(s=g()));else e=null;return e}function zs(){var e,s;for(e=[],s=qe(),s===null&&(s=o(),s===null&&(s=g()));s!==null;)e.push(s),s=qe(),s===null&&(s=o(),s===null&&(s=g()));return e}function qe(){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 hl(){var e;return e=pr(),e===null&&(e=Ks()),e}function Ks(){var e,s,r,l,a,u;return u=t,e=et(),e!==null?(s=C(),s!==null?(r=Ys(),r!==null?(l=C(),l!==null?(a=yt(),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 Ys(){var e;return e=ve(),e===null&&(e=wt()),e}function wt(){var e,s,r,l;return l=t,e=tr(),e!==null?(i.charCodeAt(t)===58?(s=":",t++):(s=null,n('":"')),s!==null?(r=Js(),r===null&&(r=Qs()),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Js(){var e,s,r,l,a;return l=t,e=Xs(),e===null&&(e=Qe()),e!==null?(a=t,i.charCodeAt(t)===63?(s="?",t++):(s=null,n('"?"')),s!==null?(r=lr(),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 Xs(){var e,s,r,l;return l=t,i.substr(t,2)==="//"?(e="//",t+=2):(e=null,n('"//"')),e!==null?(s=sr(),s!==null?(r=Qe(),r=r!==null?r:"",r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Qe(){var e,s,r;return r=t,i.charCodeAt(t)===47?(e="/",t++):(e=null,n('"/"')),e!==null?(s=er(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Qs(){var e,s,r,l;if(l=t,e=Zs(),e!==null){for(s=[],r=je();r!==null;)s.push(r),r=je();s!==null?e=[e,s]:(e=null,t=l)}else e=null,t=l;return e}function je(){var e;return e=F(),e===null&&(e=o(),e===null&&(e=g())),e}function Zs(){var e;return e=o(),e===null&&(e=g(),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 er(){var e,s,r,l,a,u;if(a=t,e=Ze(),e!==null){for(s=[],u=t,i.charCodeAt(t)===47?(r="/",t++):(r=null,n('"/"')),r!==null?(l=Ze(),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=Ze(),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 Ze(){var e,s,r,l,a,u;for(a=t,e=[],s=Ge();s!==null;)e.push(s),s=Ge();if(e!==null){for(s=[],u=t,i.charCodeAt(t)===59?(r=";",t++):(r=null,n('";"')),r!==null?(l=bt(),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=bt(),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 bt(){var e,s;for(e=[],s=Ge();s!==null;)e.push(s),s=Ge();return e}function Ge(){var e;return e=o(),e===null&&(e=g(),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 tr(){var e,s,r,l,a;if(l=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,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=A(),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 sr(){var e;return e=rr(),e===null&&(e=nr()),e}function rr(){var e,s,r,l;return r=t,l=t,e=Ye(),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=Je(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e=e!==null?e:"",e}function nr(){var e,s;if(s=o(),s===null&&(s=g(),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=g(),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 lr(){var e,s;for(e=[],s=je();s!==null;)e.push(s),s=je();return e}function yt(){var e,s,r,l,a,u,T,M;if(T=t,M=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=M)}else e=null,t=M;else e=null,t=M}else e=null,t=M;else e=null,t=M;return e!==null&&(e=(function($){x.sip_version=i.substring(t,$)})(T)),e===null&&(t=T),e}function ir(){var e;return i.substr(t,6)==="INVITE"?(e="INVITE",t+=6):(e=null,n('"INVITE"')),e}function ar(){var e;return i.substr(t,3)==="ACK"?(e="ACK",t+=3):(e=null,n('"ACK"')),e}function or(){var e;return i.substr(t,7)==="OPTIONS"?(e="OPTIONS",t+=7):(e=null,n('"OPTIONS"')),e}function ur(){var e;return i.substr(t,3)==="BYE"?(e="BYE",t+=3):(e=null,n('"BYE"')),e}function cr(){var e;return i.substr(t,6)==="CANCEL"?(e="CANCEL",t+=6):(e=null,n('"CANCEL"')),e}function fr(){var e;return i.substr(t,8)==="REGISTER"?(e="REGISTER",t+=8):(e=null,n('"REGISTER"')),e}function hr(){var e;return i.substr(t,9)==="SUBSCRIBE"?(e="SUBSCRIBE",t+=9):(e=null,n('"SUBSCRIBE"')),e}function dr(){var e;return i.substr(t,6)==="NOTIFY"?(e="NOTIFY",t+=6):(e=null,n('"NOTIFY"')),e}function _r(){var e;return i.substr(t,5)==="REFER"?(e="REFER",t+=5):(e=null,n('"REFER"')),e}function et(){var e,s;return s=t,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=hr(),e===null&&(e=dr(),e===null&&(e=_r(),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 pr(){var e,s,r,l,a,u;return u=t,e=yt(),e!==null?(s=C(),s!==null?(r=mr(),r!==null?(l=C(),l!==null?(a=Tr(),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 mr(){var e,s;return s=t,e=gr(),e!==null&&(e=(function(r,l){x.status_code=parseInt(l.join(""))})(s,e)),e===null&&(t=s),e}function gr(){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 Tr(){var e,s,r;for(r=t,e=[],s=F(),s===null&&(s=o(),s===null&&(s=g(),s===null&&(s=P(),s===null&&(s=O(),s===null&&(s=C(),s===null&&(s=I()))))));s!==null;)e.push(s),s=F(),s===null&&(s=o(),s===null&&(s=g(),s===null&&(s=P(),s===null&&(s=O(),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 dl(){var e,s,r,l,a,u;if(a=t,e=Be(),e!==null){for(s=[],u=t,r=te(),r!==null?(l=Be(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=te(),r!==null?(l=Be(),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 _l(){var e,s,r,l,a,u;return l=t,a=t,e=fe(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,n('"@"')),s!==null?(r=fe(),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(T){x=i.substring(t,T)})(l)),e===null&&(t=l),e}function pl(){var e,s,r,l,a,u,T;if(a=t,e=Q(),e===null)if(u=t,e=tt(),e!==null){for(s=[],T=t,r=te(),r!==null?(l=tt(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=te(),r!==null?(l=tt(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M){var $,W;for(W=x.multi_header.length,$=0;$<W;$++)if(x.multi_header[$].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function tt(){var e,s,r,l,a,u,T;if(a=t,u=t,e=se(),e===null&&(e=De()),e!==null){for(s=[],T=t,r=X(),r!==null?(l=It(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=X(),r!==null?(l=It(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M){var $;x.multi_header||(x.multi_header=[]);try{$=new Me(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{$=null}x.multi_header.push({possition:t,offset:M,parsed:$})})(a)),e===null&&(t=a),e}function De(){var e,s,r,l,a;return a=t,e=st(),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 st(){var e,s,r,l,a,u,T;if(a=t,u=t,e=j(),e!==null){for(s=[],T=t,r=p(),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=p(),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e===null&&(e=ee()),e!==null&&(e=(function(M,$){typeof $=="string"?x.display_name=$:x.display_name=$[1].reduce(function(W,re){return W+re[0]+re[1]},$[0])})(a,e)),e===null&&(t=a),e}function It(){var e;return e=Cr(),e===null&&(e=vr(),e===null&&(e=ue())),e}function Cr(){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=Z(),s!==null?(r=Er(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T){x.params||(x.params={}),x.params.q=T})(l,e[2])),e===null&&(t=l),e}function vr(){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=Z(),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,T){x.params||(x.params={}),x.params.expires=T})(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 Er(){var e,s,r,l,a,u,T,M;return u=t,T=t,i.charCodeAt(t)===48?(e="0",t++):(e=null,n('"0"')),e!==null?(M=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=M)):(s=null,t=M)):(s=null,t=M)):(s=null,t=M),s=s!==null?s:"",s!==null?e=[e,s]:(e=null,t=T)):(e=null,t=T),e!==null&&(e=(function($){return parseFloat(i.substring(t,$))})(u)),e===null&&(t=u),e}function ue(){var e,s,r,l,a,u;return l=t,a=t,e=j(),e!==null?(u=t,s=Z(),s!==null?(r=Sr(),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(T,M,$){x.params||(x.params={}),typeof $>"u"?$=void 0:$=$[1],x.params[M.toLowerCase()]=$})(l,e[0],e[1])),e===null&&(t=l),e}function Sr(){var e;return e=j(),e===null&&(e=He(),e===null&&(e=J())),e}function ml(){var e,s,r,l,a,u;if(a=t,e=Ar(),e!==null){for(s=[],u=t,r=X(),r!==null?(l=xt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(l=xt(),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 Ar(){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=j())))),e}function xt(){var e;return e=Rr(),e===null&&(e=ue()),e}function Rr(){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=Z(),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=j())),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function gl(){var e,s,r,l,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=te(),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=te(),r!==null?(l=j(),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 Tl(){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 Cl(){var e,s;return s=t,e=wr(),e!==null&&(e=(function(r){x=i.substring(t,r)})(s)),e===null&&(t=s),e}function wr(){var e,s,r,l,a,u,T,M;if(T=t,e=br(),e!==null)if(s=_e(),s!==null)if(r=Nr(),r!==null){for(l=[],M=t,a=X(),a!==null?(u=Nt(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);a!==null;)l.push(a),M=t,a=X(),a!==null?(u=Nt(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);l!==null?e=[e,s,r,l]:(e=null,t=T)}else e=null,t=T;else e=null,t=T;else e=null,t=T;return e}function br(){var e;return e=yr(),e===null&&(e=Ir()),e}function yr(){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=rt()))))),e}function Ir(){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=rt())),e}function rt(){var e;return e=j(),e===null&&(e=xr()),e}function xr(){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=j(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function Nr(){var e;return e=rt(),e===null&&(e=j()),e}function Nt(){var e,s,r,l;return l=t,e=j(),e!==null?(s=Z(),s!==null?(r=Or(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Or(){var e;return e=j(),e===null&&(e=J()),e}function vl(){var e,s,r,l;return l=t,e=Dr(),e!==null?(s=p(),s!==null?(r=et(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Dr(){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 El(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,l){x=l})(s,e)),e===null&&(t=s),e}function Sl(){var e,s,r,l,a,u,T;if(a=t,u=t,e=Be(),e!==null){for(s=[],T=t,r=X(),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=X(),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M,$){x.event=$.join("").toLowerCase()})(a,e[0])),e===null&&(t=a),e}function Be(){var e,s,r,l,a,u;if(a=t,e=le(),e!==null){for(s=[],u=t,i.charCodeAt(t)===46?(r=".",t++):(r=null,n('"."')),r!==null?(l=le(),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=le(),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 Al(){var e,s,r,l,a,u,T;if(a=t,u=t,e=se(),e===null&&(e=De()),e!==null){for(s=[],T=t,r=X(),r!==null?(l=Ot(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=X(),r!==null?(l=Ot(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M){var $=x.tag;try{x=new Me(x.uri,x.display_name,x.params),$&&x.setParam("tag",$)}catch{x=-1}})()),e===null&&(t=a),e}function Ot(){var e;return e=Dt(),e===null&&(e=ue()),e}function Dt(){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=Z(),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,T){x.tag=T})(l,e[2])),e===null&&(t=l),e}function Rl(){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 wl(){var e,s;return s=t,e=Ue(),e!==null&&(e=(function(r,l){x=l})(s,e)),e===null&&(t=s),e}function bl(){var e,s,r,l,a,u,T,M,$,W;for(M=t,$=t,e=[],s=st();s!==null;)e.push(s),s=st();if(e!==null)if(s=Re(),s!==null)if(r=ve(),r!==null)if(l=Ae(),l!==null){for(a=[],W=t,u=X(),u!==null?(T=ue(),T!==null?u=[u,T]:(u=null,t=W)):(u=null,t=W);u!==null;)a.push(u),W=t,u=X(),u!==null?(T=ue(),T!==null?u=[u,T]:(u=null,t=W)):(u=null,t=W);a!==null?e=[e,s,r,l,a]:(e=null,t=$)}else e=null,t=$;else e=null,t=$;else e=null,t=$;else e=null,t=$;return e!==null&&(e=(function(re){try{x=new Me(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=M),e}function yl(){var e;return e=Ut(),e}function Ut(){var e,s,r,l,a,u,T,M;if(T=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=nt(),r!==null){for(l=[],M=t,a=te(),a!==null?(u=nt(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);a!==null;)l.push(a),M=t,a=te(),a!==null?(u=nt(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);l!==null?e=[e,s,r,l]:(e=null,t=T)}else e=null,t=T;else e=null,t=T;else e=null,t=T;return e===null&&(e=Ur()),e}function Ur(){var e,s,r,l,a,u,T,M;if(T=t,e=j(),e!==null)if(s=p(),s!==null)if(r=We(),r!==null){for(l=[],M=t,a=te(),a!==null?(u=We(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);a!==null;)l.push(a),M=t,a=te(),a!==null?(u=We(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);l!==null?e=[e,s,r,l]:(e=null,t=T)}else e=null,t=T;else e=null,t=T;else e=null,t=T;return e}function We(){var e,s,r,l;return l=t,e=j(),e!==null?(s=Z(),s!==null?(r=j(),r===null&&(r=J()),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function nt(){var e;return e=Pr(),e===null&&(e=Lr(),e===null&&(e=Hr(),e===null&&(e=kr(),e===null&&(e=$r(),e===null&&(e=qr(),e===null&&(e=jr(),e===null&&(e=We()))))))),e}function Pr(){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=Z(),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=ee(),e!==null&&(e=(function(r,l){x.realm=l})(s,e)),e===null&&(t=s),e}function Lr(){var e,s,r,l,a,u,T,M,$;if(M=t,i.substr(t,6).toLowerCase()==="domain"?(e=i.substr(t,6),t+=6):(e=null,n('"domain"')),e!==null)if(s=Z(),s!==null)if(r=we(),r!==null)if(l=lt(),l!==null){if(a=[],$=t,T=C(),T!==null)for(u=[];T!==null;)u.push(T),T=C();else u=null;for(u!==null?(T=lt(),T!==null?u=[u,T]:(u=null,t=$)):(u=null,t=$);u!==null;){if(a.push(u),$=t,T=C(),T!==null)for(u=[];T!==null;)u.push(T),T=C();else u=null;u!==null?(T=lt(),T!==null?u=[u,T]:(u=null,t=$)):(u=null,t=$)}a!==null?(u=Ke(),u!==null?e=[e,s,r,l,a,u]:(e=null,t=M)):(e=null,t=M)}else e=null,t=M;else e=null,t=M;else e=null,t=M;else e=null,t=M;return e}function lt(){var e;return e=wt(),e===null&&(e=Qe()),e}function Hr(){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=Z(),s!==null?(r=Fr(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function Fr(){var e,s;return s=t,e=ee(),e!==null&&(e=(function(r,l){x.nonce=l})(s,e)),e===null&&(t=s),e}function kr(){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=Z(),s!==null?(r=ee(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T){x.opaque=T})(l,e[2])),e===null&&(t=l),e}function $r(){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=Z(),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 qr(){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=Z(),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=j())),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T){x.algorithm=T.toUpperCase()})(l,e[2])),e===null&&(t=l),e}function jr(){var e,s,r,l,a,u,T,M,$,W;if(M=t,i.substr(t,3).toLowerCase()==="qop"?(e=i.substr(t,3),t+=3):(e=null,n('"qop"')),e!==null)if(s=Z(),s!==null)if(r=we(),r!==null){if($=t,l=it(),l!==null){for(a=[],W=t,i.charCodeAt(t)===44?(u=",",t++):(u=null,n('","')),u!==null?(T=it(),T!==null?u=[u,T]:(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?(T=it(),T!==null?u=[u,T]:(u=null,t=W)):(u=null,t=W);a!==null?l=[l,a]:(l=null,t=$)}else l=null,t=$;l!==null?(a=Ke(),a!==null?e=[e,s,r,l,a]:(e=null,t=M)):(e=null,t=M)}else e=null,t=M;else e=null,t=M;else e=null,t=M;return e}function it(){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=j())),e!==null&&(e=(function(r,l){x.qop||(x.qop=[]),x.qop.push(l.toLowerCase())})(s,e)),e===null&&(t=s),e}function Il(){var e,s,r,l,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=te(),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=te(),r!==null?(l=j(),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 xl(){var e,s,r,l,a,u,T;if(a=t,u=t,e=at(),e!==null){for(s=[],T=t,r=te(),r!==null?(l=at(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=te(),r!==null?(l=at(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M){var $,W;for(W=x.multi_header.length,$=0;$<W;$++)if(x.multi_header[$].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1})()),e===null&&(t=a),e}function at(){var e,s,r,l,a,u,T;if(a=t,u=t,e=De(),e!==null){for(s=[],T=t,r=X(),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=X(),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M){var $;x.multi_header||(x.multi_header=[]);try{$=new Me(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{$=null}x.multi_header.push({possition:t,offset:M,parsed:$})})(a)),e===null&&(t=a),e}function Nl(){var e,s,r,l,a,u,T;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=j()),e!==null){for(s=[],T=t,r=X(),r!==null?(l=Pt(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=X(),r!==null?(l=Pt(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M,$){if(x.protocol=$.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 Pt(){var e;return e=Gr(),e===null&&(e=ue()),e}function Gr(){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=Z(),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(T,M){x.cause=parseInt(M.join(""))})(a,e[2])),e===null&&(t=a),e}function Ol(){var e,s,r,l,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=te(),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=te(),r!==null?(l=j(),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 Dl(){var e,s,r,l,a,u;if(a=t,e=ot(),e!==null){for(s=[],u=t,r=te(),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=te(),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;if(a=t,e=De(),e!==null){for(s=[],u=t,r=X(),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),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 Ul(){var e,s,r,l,a,u;if(a=t,e=Br(),e!==null){for(s=[],u=t,r=X(),r!==null?(l=Mt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(l=Mt(),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 Br(){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=j()))),e!==null&&(e=(function(r){x.state=i.substring(t,r)})(s)),e===null&&(t=s),e}function Mt(){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=Z(),s!==null?(r=Wr(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T){typeof T<"u"&&(x.reason=T)})(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=Z(),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,T){typeof T<"u"&&(x.expires=T)})(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=Z(),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,T){typeof T<"u"&&(x.retry_after=T)})(l,e[2])),e===null&&(t=l),e===null&&(e=ue()))),e}function Wr(){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=j()))))))),e}function Pl(){var e;return e=v(),e=e!==null?e:"",e}function Ml(){var e,s,r,l,a,u;if(a=t,e=j(),e!==null){for(s=[],u=t,r=te(),r!==null?(l=j(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=te(),r!==null?(l=j(),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 Ll(){var e,s,r,l,a,u,T;if(a=t,u=t,e=se(),e===null&&(e=De()),e!==null){for(s=[],T=t,r=X(),r!==null?(l=Lt(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=X(),r!==null?(l=Lt(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M){var $=x.tag;try{x=new Me(x.uri,x.display_name,x.params),$&&x.setParam("tag",$)}catch{x=-1}})()),e===null&&(t=a),e}function Lt(){var e;return e=Dt(),e===null&&(e=ue()),e}function Hl(){var e,s,r,l,a,u;if(a=t,e=ut(),e!==null){for(s=[],u=t,r=te(),r!==null?(l=ut(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=te(),r!==null?(l=ut(),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 ut(){var e,s,r,l,a,u,T,M;if(T=t,e=Qr(),e!==null)if(s=p(),s!==null)if(r=tn(),r!==null){for(l=[],M=t,a=X(),a!==null?(u=Ht(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);a!==null;)l.push(a),M=t,a=X(),a!==null?(u=Ht(),u!==null?a=[a,u]:(a=null,t=M)):(a=null,t=M);l!==null?e=[e,s,r,l]:(e=null,t=T)}else e=null,t=T;else e=null,t=T;else e=null,t=T;return e}function Ht(){var e;return e=Vr(),e===null&&(e=zr(),e===null&&(e=Kr(),e===null&&(e=Yr(),e===null&&(e=Jr(),e===null&&(e=ue()))))),e}function Vr(){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=Z(),s!==null?(r=Ft(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T){x.ttl=T})(l,e[2])),e===null&&(t=l),e}function zr(){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=Z(),s!==null?(r=He(),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T){x.maddr=T})(l,e[2])),e===null&&(t=l),e}function Kr(){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=Z(),s!==null?(r=Fe(),r===null&&(r=At()),r!==null?e=[e,s,r]:(e=null,t=a)):(e=null,t=a)):(e=null,t=a),e!==null&&(e=(function(u,T){x.received=T})(l,e[2])),e===null&&(t=l),e}function Yr(){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=Z(),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,T){x.branch=T})(l,e[2])),e===null&&(t=l),e}function Jr(){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=Z(),s!==null?(r=Xr(),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 Xr(){var e,s,r,l,a,u,T;return u=t,T=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=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T),e!==null&&(e=(function(M,$){x.rport=parseInt($.join(""))})(u,e)),e===null&&(t=u),e}function Qr(){var e,s,r,l,a,u;return u=t,e=Zr(),e!==null?(s=_e(),s!==null?(r=j(),r!==null?(l=_e(),l!==null?(a=en(),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 Zr(){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=j()),e!==null&&(e=(function(r,l){x.protocol=l})(s,e)),e===null&&(t=s),e}function en(){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=j())))),e!==null&&(e=(function(r,l){x.transport=l})(s,e)),e===null&&(t=s),e}function tn(){var e,s,r,l,a;return l=t,e=sn(),e!==null?(a=t,s=Oe(),s!==null?(r=rn(),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 sn(){var e,s;return s=t,e=Fe(),e===null&&(e=St(),e===null&&(e=vt())),e!==null&&(e=(function(r){x.host=i.substring(t,r)})(s)),e===null&&(t=s),e}function rn(){var e,s,r,l,a,u,T;return u=t,T=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=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T),e!==null&&(e=(function(M,$){x.port=parseInt($.join(""))})(u,e)),e===null&&(t=u),e}function Ft(){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,T){return parseInt(T.join(""))})(l,e)),e===null&&(t=l),e}function Fl(){var e;return e=Ut(),e}function kl(){var e,s,r,l,a,u;if(a=t,e=nn(),e!==null){for(s=[],u=t,r=X(),r!==null?(l=kt(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(l=kt(),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 nn(){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 kt(){var e;return e=ln(),e===null&&(e=ue()),e}function ln(){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=Z(),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,T){x.refresher=T.toLowerCase()})(l,e[2])),e===null&&(t=l),e}function $l(){var e,s,r,l;return l=t,e=j(),e!==null?(s=U(),s!==null?(r=an(),r!==null?e=[e,s,r]:(e=null,t=l)):(e=null,t=l)):(e=null,t=l),e}function an(){var e,s;for(e=[],s=y(),s===null&&(s=O(),s===null&&(s=p()));s!==null;)e.push(s),s=y(),s===null&&(s=O(),s===null&&(s=p()));return e}function ql(){var e,s;for(e=[],s=N();s!==null;)e.push(s),s=N();return e}function jl(){var e,s,r;return r=t,i.substr(t,5)==="uuid:"?(e="uuid:",t+=5):(e=null,n('"uuid:"')),e!==null?(s=on(),s!==null?e=[e,s]:(e=null,t=r)):(e=null,t=r),e}function on(){var e,s,r,l,a,u,T,M,$,W,re;return W=t,re=t,e=un(),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?(T=Ee(),T!==null?(i.charCodeAt(t)===45?(M="-",t++):(M=null,n('"-"')),M!==null?($=cn(),$!==null?e=[e,s,r,l,a,u,T,M,$]:(e=null,t=re)):(e=null,t=re)):(e=null,t=re)):(e=null,t=re)):(e=null,t=re)):(e=null,t=re)):(e=null,t=re)):(e=null,t=re)):(e=null,t=re),e!==null&&(e=(function(Te,ct){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 un(){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 cn(){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 Gl(){var e,s,r,l,a,u,T;if(a=t,u=t,e=se(),e===null&&(e=De()),e!==null){for(s=[],T=t,r=X(),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);r!==null;)s.push(r),T=t,r=X(),r!==null?(l=ue(),l!==null?r=[r,l]:(r=null,t=T)):(r=null,t=T);s!==null?e=[e,s]:(e=null,t=u)}else e=null,t=u;return e!==null&&(e=(function(M){try{x=new Me(x.uri,x.display_name,x.params)}catch{x=-1}})()),e===null&&(t=a),e}function Bl(){var e,s,r,l,a,u;if(a=t,e=fn(),e!==null){for(s=[],u=t,r=X(),r!==null?(l=$t(),l!==null?r=[r,l]:(r=null,t=u)):(r=null,t=u);r!==null;)s.push(r),u=t,r=X(),r!==null?(l=$t(),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 fn(){var e,s,r,l,a,u;return l=t,a=t,e=fe(),e!==null?(u=t,i.charCodeAt(t)===64?(s="@",t++):(s=null,n('"@"')),s!==null?(r=fe(),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(T){x.call_id=i.substring(t,T)})(l)),e===null&&(t=l),e}function $t(){var e;return e=hn(),e===null&&(e=dn(),e===null&&(e=_n(),e===null&&(e=ue()))),e}function hn(){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=Z(),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,T){x.to_tag=T})(l,e[2])),e===null&&(t=l),e}function dn(){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=Z(),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,T){x.from_tag=T})(l,e[2])),e===null&&(t=l),e}function _n(){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 Wl(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 Vl(){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 pn=ye(),Me=bs(),x={},zl=S[_]();if(zl===null||t!==i.length){var qt=Math.max(t,d),Kl=qt<i.length?i.charAt(qt):null,mn=Vl();return new this.SyntaxError(Wl(h),Kl,qt,mn.line,mn.column),-1}return x},toSource:function(){return this._source}};return b.SyntaxError=function(i,_,S,t,d){function h(n,m){var c,A;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 A=m?R(m):"end of input","Expected "+c+" but "+A+" found."}this.name="SyntaxError",this.expected=i,this.found=_,this.message=h(i,_),this.offset=S,this.line=t,this.column=d},b.SyntaxError.prototype=Error.prototype,b})()),Vt}var zt,En;function ye(){if(En)return zt;En=1;const R=ce(),b=de(),i=Ce();return zt=class rl{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||R.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[b.headerize(S)]=Array.isArray(t)?t:[t]}getHeader(S){if(S)return this._headers[b.headerize(S)]}hasHeader(S){if(S)return this._headers.hasOwnProperty(b.headerize(S))&&!0||!1}deleteHeader(S){if(S=b.headerize(S),this._headers.hasOwnProperty(S)){const t=this._headers[S];return delete this._headers[S],t}}clearHeaders(){this._headers={}}clone(){return new rl(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+=`${b.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+=`${b.escapeUser(this._user)}@`),t+=this._host,S&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},zt}var Sn;function de(){if(Sn)return oe;Sn=1;const R=ce(),b=ye(),i=Ce();oe.str_utf8_length=d=>unescape(encodeURIComponent(d)).length;const _=oe.isFunction=d=>d!==void 0?Object.prototype.toString.call(d)==="[object Function]":!1;oe.isString=d=>d!==void 0?Object.prototype.toString.call(d)==="[object String]":!1,oe.isDecimal=d=>!isNaN(d)&&parseFloat(d)===parseInt(d,10),oe.isEmpty=d=>d===null||d===""||d===void 0||Array.isArray(d)&&d.length===0||typeof d=="number"&&isNaN(d),oe.hasMethods=function(d,...h){for(const n of h)if(_(d[n]))return!1;return!0};const S=oe.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};oe.newTag=()=>S(10),oe.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)}),oe.hostType=d=>{if(d){if(d=i.parse(d,"host"),d!==-1)return d.host_type}else return};const t=oe.escapeUser=d=>encodeURIComponent(decodeURIComponent(d)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return oe.normalizeTarget=(d,h)=>{if(d){if(d instanceof b)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=`${R.SIP}:${t(m)}@${c}`;let A;return(A=b.parse(d))?A:void 0}else return}else return},oe.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 A;for(A=0;A<c;A++)A!==0&&(m+="-"),m+=n[A].charAt(0).toUpperCase()+n[A].substring(1);return h[m]&&(m=h[m]),m},oe.sipErrorCause=d=>{for(const h in R.SIP_ERROR_CAUSES)if(R.SIP_ERROR_CAUSES[h].indexOf(d)!==-1)return R.causes[h];return R.causes.SIP_FAILURE_CODE},oe.getRandomTestNetIP=()=>{function d(h,n){return Math.floor(Math.random()*(n-h+1)+h)}return`192.0.2.${d(1,254)}`},oe.calculateMD5=d=>{function h(Y,z){return Y<<z|Y>>>32-z}function n(Y,z){const J=Y&2147483648,ee=z&2147483648,ie=Y&1073741824,ae=z&1073741824,se=(Y&1073741823)+(z&1073741823);return ie&ae?se^2147483648^J^ee:ie|ae?se&1073741824?se^3221225472^J^ee:se^1073741824^J^ee:se^J^ee}function m(Y,z,J){return Y&z|~Y&J}function c(Y,z,J){return Y&J|z&~J}function A(Y,z,J){return Y^z^J}function D(Y,z,J){return z^(Y|~J)}function E(Y,z,J,ee,ie,ae,se){return Y=n(Y,n(n(m(z,J,ee),ie),se)),n(h(Y,ae),z)}function N(Y,z,J,ee,ie,ae,se){return Y=n(Y,n(n(c(z,J,ee),ie),se)),n(h(Y,ae),z)}function k(Y,z,J,ee,ie,ae,se){return Y=n(Y,n(n(A(z,J,ee),ie),se)),n(h(Y,ae),z)}function C(Y,z,J,ee,ie,ae,se){return Y=n(Y,n(n(D(z,J,ee),ie),se)),n(h(Y,ae),z)}function I(Y){let z;const J=Y.length,ee=J+8,ae=((ee-ee%64)/64+1)*16,se=new Array(ae-1);let ve=0,pe=0;for(;pe<J;)z=(pe-pe%4)/4,ve=pe%4*8,se[z]=se[z]|Y.charCodeAt(pe)<<ve,pe++;return z=(pe-pe%4)/4,ve=pe%4*8,se[z]=se[z]|128<<ve,se[ae-2]=J<<3,se[ae-1]=J>>>29,se}function H(Y){let z="",J="",ee,ie;for(ie=0;ie<=3;ie++)ee=Y>>>ie*8&255,J=`0${ee.toString(16)}`,z=z+J.substr(J.length-2,2);return z}function F(Y){let z="";for(let J=0;J<Y.length;J++){const ee=Y.charCodeAt(J);ee<128?z+=String.fromCharCode(ee):ee>127&&ee<2048?(z+=String.fromCharCode(ee>>6|192),z+=String.fromCharCode(ee&63|128)):(z+=String.fromCharCode(ee>>12|224),z+=String.fromCharCode(ee>>6&63|128),z+=String.fromCharCode(ee&63|128))}return z}let o=[],f,g,p,w,U,v,y,P,O;const V=7,j=12,le=17,ne=22,fe=5,Q=9,_e=14,Z=20,xe=4,Ne=11,Ae=16,Re=23,te=6,X=10,Oe=15,we=21;for(d=F(d),o=I(d),v=1732584193,y=4023233417,P=2562383102,O=271733878,f=0;f<o.length;f+=16)g=v,p=y,w=P,U=O,v=E(v,y,P,O,o[f+0],V,3614090360),O=E(O,v,y,P,o[f+1],j,3905402710),P=E(P,O,v,y,o[f+2],le,606105819),y=E(y,P,O,v,o[f+3],ne,3250441966),v=E(v,y,P,O,o[f+4],V,4118548399),O=E(O,v,y,P,o[f+5],j,1200080426),P=E(P,O,v,y,o[f+6],le,2821735955),y=E(y,P,O,v,o[f+7],ne,4249261313),v=E(v,y,P,O,o[f+8],V,1770035416),O=E(O,v,y,P,o[f+9],j,2336552879),P=E(P,O,v,y,o[f+10],le,4294925233),y=E(y,P,O,v,o[f+11],ne,2304563134),v=E(v,y,P,O,o[f+12],V,1804603682),O=E(O,v,y,P,o[f+13],j,4254626195),P=E(P,O,v,y,o[f+14],le,2792965006),y=E(y,P,O,v,o[f+15],ne,1236535329),v=N(v,y,P,O,o[f+1],fe,4129170786),O=N(O,v,y,P,o[f+6],Q,3225465664),P=N(P,O,v,y,o[f+11],_e,643717713),y=N(y,P,O,v,o[f+0],Z,3921069994),v=N(v,y,P,O,o[f+5],fe,3593408605),O=N(O,v,y,P,o[f+10],Q,38016083),P=N(P,O,v,y,o[f+15],_e,3634488961),y=N(y,P,O,v,o[f+4],Z,3889429448),v=N(v,y,P,O,o[f+9],fe,568446438),O=N(O,v,y,P,o[f+14],Q,3275163606),P=N(P,O,v,y,o[f+3],_e,4107603335),y=N(y,P,O,v,o[f+8],Z,1163531501),v=N(v,y,P,O,o[f+13],fe,2850285829),O=N(O,v,y,P,o[f+2],Q,4243563512),P=N(P,O,v,y,o[f+7],_e,1735328473),y=N(y,P,O,v,o[f+12],Z,2368359562),v=k(v,y,P,O,o[f+5],xe,4294588738),O=k(O,v,y,P,o[f+8],Ne,2272392833),P=k(P,O,v,y,o[f+11],Ae,1839030562),y=k(y,P,O,v,o[f+14],Re,4259657740),v=k(v,y,P,O,o[f+1],xe,2763975236),O=k(O,v,y,P,o[f+4],Ne,1272893353),P=k(P,O,v,y,o[f+7],Ae,4139469664),y=k(y,P,O,v,o[f+10],Re,3200236656),v=k(v,y,P,O,o[f+13],xe,681279174),O=k(O,v,y,P,o[f+0],Ne,3936430074),P=k(P,O,v,y,o[f+3],Ae,3572445317),y=k(y,P,O,v,o[f+6],Re,76029189),v=k(v,y,P,O,o[f+9],xe,3654602809),O=k(O,v,y,P,o[f+12],Ne,3873151461),P=k(P,O,v,y,o[f+15],Ae,530742520),y=k(y,P,O,v,o[f+2],Re,3299628645),v=C(v,y,P,O,o[f+0],te,4096336452),O=C(O,v,y,P,o[f+7],X,1126891415),P=C(P,O,v,y,o[f+14],Oe,2878612391),y=C(y,P,O,v,o[f+5],we,4237533241),v=C(v,y,P,O,o[f+12],te,1700485571),O=C(O,v,y,P,o[f+3],X,2399980690),P=C(P,O,v,y,o[f+10],Oe,4293915773),y=C(y,P,O,v,o[f+1],we,2240044497),v=C(v,y,P,O,o[f+8],te,1873313359),O=C(O,v,y,P,o[f+15],X,4264355552),P=C(P,O,v,y,o[f+6],Oe,2734768916),y=C(y,P,O,v,o[f+13],we,1309151649),v=C(v,y,P,O,o[f+4],te,4149444226),O=C(O,v,y,P,o[f+11],X,3174756917),P=C(P,O,v,y,o[f+2],Oe,718787259),y=C(y,P,O,v,o[f+9],we,3951481745),v=n(v,g),y=n(y,p),P=n(P,w),O=n(O,U);return(H(v)+H(y)+H(P)+H(O)).toLowerCase()},oe.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()}},oe.cloneArray=d=>d&&d.slice()||[],oe.cloneObject=(d,h={})=>d&&Object.assign({},d)||h,oe}var ft={exports:{}},An;function Ie(){if(An)return ft.exports;An=1;var R=typeof Reflect=="object"?Reflect:null,b=R&&typeof R.apply=="function"?R.apply:function(f,g,p){return Function.prototype.apply.call(f,g,p)},i;R&&typeof R.ownKeys=="function"?i=R.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)}ft.exports=t,ft.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 g=[],p=1;p<arguments.length;p++)g.push(arguments[p]);var w=f==="error",U=this._events;if(U!==void 0)w=w&&U.error===void 0;else if(!w)return!1;if(w){var v;if(g.length>0&&(v=g[0]),v instanceof Error)throw v;var y=new Error("Unhandled error."+(v?" ("+v.message+")":""));throw y.context=v,y}var P=U[f];if(P===void 0)return!1;if(typeof P=="function")b(P,this,g);else for(var O=P.length,V=N(P,O),p=0;p<O;++p)b(V[p],this,g);return!0};function m(o,f,g,p){var w,U,v;if(h(g),U=o._events,U===void 0?(U=o._events=Object.create(null),o._eventsCount=0):(U.newListener!==void 0&&(o.emit("newListener",f,g.listener?g.listener:g),U=o._events),v=U[f]),v===void 0)v=U[f]=g,++o._eventsCount;else if(typeof v=="function"?v=U[f]=p?[g,v]:[v,g]:p?v.unshift(g):v.push(g),w=n(o),w>0&&v.length>w&&!v.warned){v.warned=!0;var y=new Error("Possible EventEmitter memory leak detected. "+v.length+" "+String(f)+" listeners added. Use emitter.setMaxListeners() to increase limit");y.name="MaxListenersExceededWarning",y.emitter=o,y.type=f,y.count=v.length,_(y)}return o}t.prototype.addListener=function(f,g){return m(this,f,g,!1)},t.prototype.on=t.prototype.addListener,t.prototype.prependListener=function(f,g){return m(this,f,g,!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,g){var p={fired:!1,wrapFn:void 0,target:o,type:f,listener:g},w=c.bind(p);return w.listener=g,p.wrapFn=w,w}t.prototype.once=function(f,g){return h(g),this.on(f,A(this,f,g)),this},t.prototype.prependOnceListener=function(f,g){return h(g),this.prependListener(f,A(this,f,g)),this},t.prototype.removeListener=function(f,g){var p,w,U,v,y;if(h(g),w=this._events,w===void 0)return this;if(p=w[f],p===void 0)return this;if(p===g||p.listener===g)--this._eventsCount===0?this._events=Object.create(null):(delete w[f],w.removeListener&&this.emit("removeListener",f,p.listener||g));else if(typeof p!="function"){for(U=-1,v=p.length-1;v>=0;v--)if(p[v]===g||p[v].listener===g){y=p[v].listener,U=v;break}if(U<0)return this;U===0?p.shift():k(p,U),p.length===1&&(w[f]=p[0]),w.removeListener!==void 0&&this.emit("removeListener",f,y||g)}return this},t.prototype.off=t.prototype.removeListener,t.prototype.removeAllListeners=function(f){var g,p,w;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 U=Object.keys(p),v;for(w=0;w<U.length;++w)v=U[w],v!=="removeListener"&&this.removeAllListeners(v);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(g=p[f],typeof g=="function")this.removeListener(f,g);else if(g!==void 0)for(w=g.length-1;w>=0;w--)this.removeListener(f,g[w]);return this};function D(o,f,g){var p=o._events;if(p===void 0)return[];var w=p[f];return w===void 0?[]:typeof w=="function"?g?[w.listener||w]:[w]:g?C(w):N(w,w.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 g=f[o];if(typeof g=="function")return 1;if(g!==void 0)return g.length}return 0}t.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function N(o,f){for(var g=new Array(f),p=0;p<f;++p)g[p]=o[p];return g}function k(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),g=0;g<f.length;++g)f[g]=o[g].listener||o[g];return f}function I(o,f){return new Promise(function(g,p){function w(v){o.removeListener(f,U),p(v)}function U(){typeof o.removeListener=="function"&&o.removeListener("error",w),g([].slice.call(arguments))}F(o,f,U,{once:!0}),f!=="error"&&H(o,w,{once:!0})})}function H(o,f,g){typeof o.on=="function"&&F(o,"error",f,g)}function F(o,f,g,p){if(typeof o.on=="function")p.once?o.once(f,g):o.on(f,g);else if(typeof o.addEventListener=="function")o.addEventListener(f,function w(U){p.once&&o.removeEventListener(f,w),g(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}return ft.exports}var ht={exports:{}},Kt,Rn;function ei(){if(Rn)return Kt;Rn=1;var R=1e3,b=R*60,i=b*60,_=i*24,S=_*7,t=_*365.25;Kt=function(c,A){A=A||{};var D=typeof c;if(D==="string"&&c.length>0)return d(c);if(D==="number"&&isFinite(c))return A.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 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 D=parseFloat(A[1]),E=(A[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*b;case"seconds":case"second":case"secs":case"sec":case"s":return D*R;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function h(c){var A=Math.abs(c);return A>=_?Math.round(c/_)+"d":A>=i?Math.round(c/i)+"h":A>=b?Math.round(c/b)+"m":A>=R?Math.round(c/R)+"s":c+"ms"}function n(c){var A=Math.abs(c);return A>=_?m(c,A,_,"day"):A>=i?m(c,A,i,"hour"):A>=b?m(c,A,b,"minute"):A>=R?m(c,A,R,"second"):c+" ms"}function m(c,A,D,E){var N=A>=D*1.5;return Math.round(c/D)+" "+E+(N?"s":"")}return Kt}var Yt,wn;function ti(){if(wn)return Yt;wn=1;function R(b){_.debug=_,_.default=_,_.coerce=m,_.disable=h,_.enable=t,_.enabled=n,_.humanize=ei(),_.destroy=c,Object.keys(b).forEach(A=>{_[A]=b[A]}),_.names=[],_.skips=[],_.formatters={};function i(A){let D=0;for(let E=0;E<A.length;E++)D=(D<<5)-D+A.charCodeAt(E),D|=0;return _.colors[Math.abs(D)%_.colors.length]}_.selectColor=i;function _(A){let D,E=null,N,k;function C(...I){if(!C.enabled)return;const H=C,F=Number(new Date),o=F-(D||F);H.diff=o,H.prev=D,H.curr=F,D=F,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,w)=>{if(p==="%%")return"%";f++;const U=_.formatters[w];if(typeof U=="function"){const v=I[f];p=U.call(H,v),I.splice(f,1),f--}return p}),_.formatArgs.call(H,I),(H.log||_.log).apply(H,I)}return C.namespace=A,C.useColors=_.useColors(),C.color=_.selectColor(A),C.extend=S,C.destroy=_.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(N!==_.namespaces&&(N=_.namespaces,k=_.enabled(A)),k),set:I=>{E=I}}),typeof _.init=="function"&&_.init(C),C}function S(A,D){const E=_(this.namespace+(typeof D>"u"?":":D)+A);return E.log=this.log,E}function t(A){_.save(A),_.namespaces=A,_.names=[],_.skips=[];const D=(typeof A=="string"?A:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const E of D)E[0]==="-"?_.skips.push(E.slice(1)):_.names.push(E)}function d(A,D){let E=0,N=0,k=-1,C=0;for(;E<A.length;)if(N<D.length&&(D[N]===A[E]||D[N]==="*"))D[N]==="*"?(k=N,C=E,N++):(E++,N++);else if(k!==-1)N=k+1,C++,E=C;else return!1;for(;N<D.length&&D[N]==="*";)N++;return N===D.length}function h(){const A=[..._.names,..._.skips.map(D=>"-"+D)].join(",");return _.enable(""),A}function n(A){for(const D of _.skips)if(d(A,D))return!1;for(const D of _.names)if(d(A,D))return!0;return!1}function m(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 Yt=R,Yt}var bn;function As(){return bn||(bn=1,(function(R,b){b.formatArgs=_,b.save=S,b.load=t,b.useColors=i,b.storage=d(),b.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`."))}})(),b.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 ":" ")+"+"+R.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;n.splice(1,0,m,"color: inherit");let c=0,A=0;n[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(c++,D==="%c"&&(A=c))}),n.splice(A,0,m)}b.log=console.debug||console.log||(()=>{});function S(n){try{n?b.storage.setItem("debug",n):b.storage.removeItem("debug")}catch{}}function t(){let n;try{n=b.storage.getItem("debug")||b.storage.getItem("DEBUG")}catch{}return!n&&typeof process<"u"&&"env"in process&&(n=process.env.DEBUG),n}function d(){try{return localStorage}catch{}}R.exports=ti()(b);const{formatters:h}=R.exports;h.j=function(n){try{return JSON.stringify(n)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}})(ht,ht.exports)),ht.exports}var Jt,yn;function he(){if(yn)return Jt;yn=1;const R=As(),b="JsSIP";return Jt=class{constructor(_){_?(this._debug=R.default(`${b}:${_}`),this._warn=R.default(`${b}:WARN:${_}`),this._error=R.default(`${b}:ERROR:${_}`)):(this._debug=R.default(b),this._warn=R.default(`${b}:WARN`),this._error=R.default(`${b}: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}},Jt}var ge={},Xt={},Qt={exports:{}},In;function ys(){if(In)return Qt.exports;In=1;var R=Qt.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(b){return b.encoding?"rtpmap:%d %s/%s/%s":b.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(b){return b.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(b){return b.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(b){return"extmap:%d"+(b.direction?"/%s":"%v")+(b["encrypt-uri"]?" %s":"%v")+" %s"+(b.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(b){return b.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(b){var i="candidate:%s %d %s %d %s %d typ %s";return i+=b.raddr!=null?" raddr %s rport %d":"%v%v",i+=b.tcptype!=null?" tcptype %s":"%v",b.generation!=null&&(i+=" generation %d"),i+=b["network-id"]!=null?" network-id %d":"%v",i+=b["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(b){var i="ssrc:%d";return b.attribute!=null&&(i+=" %s",b.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(b){return b.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(b){return b.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(b){return"imageattr:%s %s %s"+(b.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(b){return"simulcast:%s %s"+(b.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(b){return"ts-refclk:%s"+(b.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(b){var i="mediaclk:";return i+=b.id!=null?"id=%s %s":"%v%s",i+=b.mediaClockValue!=null?"=%s":"",i+=b.rateNumerator!=null?" rate=%s":"",i+=b.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(R).forEach(function(b){var i=R[b];i.forEach(function(_){_.reg||(_.reg=/(.*)/),_.format||(_.format="%s")})}),Qt.exports}var xn;function si(){return xn||(xn=1,(function(R){var b=function(h){return String(Number(h))===h?Number(h):h},i=function(h,n,m,c){if(c&&!m)n[c]=b(h[1]);else for(var A=0;A<m.length;A+=1)h[A+1]!=null&&(n[m[A]]=b(h[A+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 A=h.push?{}:c?n[h.name]:n;i(m.match(h.reg),A,h.names,h.name),h.push&&n[h.push].push(A)},S=ys(),t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);R.parse=function(h){var n={},m=[],c=n;return h.split(/(\r\n|\r|\n)/).filter(t).forEach(function(A){var D=A[0],E=A.slice(2);D==="m"&&(m.push({rtp:[],fmtp:[]}),c=m[m.length-1]);for(var N=0;N<(S[D]||[]).length;N+=1){var k=S[D][N];if(k.reg.test(E))return _(k,c,E)}}),n.media=m,n};var d=function(h,n){var m=n.split(/=(.+)/,2);return m.length===2?h[m[0]]=b(m[1]):m.length===1&&n.length>1&&(h[m[0]]=void 0),h};R.parseParams=function(h){return h.split(/;\s?/).reduce(d,{})},R.parseFmtpConfig=R.parseParams,R.parsePayloads=function(h){return h.toString().split(" ").map(Number)},R.parseRemoteCandidates=function(h){for(var n=[],m=h.split(" ").map(b),c=0;c<m.length;c+=3)n.push({component:m[c],ip:m[c+1],port:m[c+2]});return n},R.parseImageAttributes=function(h){return h.split(" ").map(function(n){return n.substring(1,n.length-1).split(",").reduce(d,{})})},R.parseSimulcastStreamList=function(h){return h.split(";").map(function(n){return n.split(",").map(function(m){var c,A=!1;return m[0]!=="~"?c=b(m):(c=b(m.substring(1,m.length)),A=!0),{scid:c,paused:A}})})}})(Xt)),Xt}var Zt,Nn;function ri(){if(Nn)return Zt;Nn=1;var R=ys(),b=/%[sdv%]/g,i=function(d){var h=1,n=arguments,m=n.length;return d.replace(b,function(c){if(h>=m)return c;var A=n[h];switch(h+=1,c){case"%%":return"%";case"%s":return String(A);case"%d":return Number(A);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 A=0;A<h.names.length;A+=1){var D=h.names[A];h.name?c.push(n[h.name][D]):c.push(n[h.names[A]])}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 Zt=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 n=h.outerOrder||S,m=h.innerOrder||t,c=[];return n.forEach(function(A){R[A].forEach(function(D){D.name in d&&d[D.name]!=null?c.push(_(A,D,d)):D.push in d&&d[D.push]!=null&&d[D.push].forEach(function(E){c.push(_(A,D,E))})})}),d.media.forEach(function(A){c.push(_("m",R.m[0],A)),m.forEach(function(D){R[D].forEach(function(E){E.name in A&&A[E.name]!=null?c.push(_(D,E,A)):E.push in A&&A[E.push]!=null&&A[E.push].forEach(function(N){c.push(_(D,E,N))})})})}),c.join(`\r
5
5
  `)+`\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
6
+ `},Zt}var On;function nl(){if(On)return ge;On=1;var R=si(),b=ri(),i=ys();return ge.grammar=i,ge.write=b,ge.parse=R.parse,ge.parseParams=R.parseParams,ge.parseFmtpConfig=R.parseFmtpConfig,ge.parsePayloads=R.parsePayloads,ge.parseRemoteCandidates=R.parseRemoteCandidates,ge.parseImageAttributes=R.parseImageAttributes,ge.parseSimulcastStreamList=R.parseSimulcastStreamList,ge}var es,Dn;function Se(){if(Dn)return es;Dn=1;const R=nl(),b=he(),i=ce(),_=de(),S=bs(),t=Ce(),d=new b("SIPMessage");class h{constructor(E,N,k,C,I,H){if(!E||!N||!k)return null;C=C||{},this.ua=k,this.headers={},this.method=E,this.ruri=N,this.body=H,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):k.configuration.use_preloaded_route&&this.setHeader("route",`<${k.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",i.MAX_FORWARDS);const F=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(F,f,o),this.setHeader("to",this.to.toString());const g=C.from_uri||k.configuration.uri,p={tag:C.from_tag||_.newTag()};let w;typeof C.from_display_name<"u"?w=C.from_display_name:k.configuration.display_name?w=k.configuration.display_name:w=null,this.from=new S(g,w,p),this.setHeader("from",this.from.toString());const U=C.call_id||k.configuration.jssip_id+_.createRandomToken(15);this.call_id=U,this.setHeader("call-id",U);const v=C.cseq||Math.floor(Math.random()*1e4);this.cseq=v,this.setHeader("cseq",`${v} ${E}`)}setHeader(E,N){const k=new RegExp(`^\\s*${E}\\s*:`,"i");for(let C=0;C<this.extraHeaders.length;C++)k.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 k=new RegExp(`^\\s*${E}\\s*:`,"i");for(const C of this.extraHeaders)if(k.test(C))return C.substring(C.indexOf(":")+1).trim()}}getHeaders(E){const N=this.headers[_.headerize(E)],k=[];if(N){for(const C of N)k.push(C);return k}else{const C=new RegExp(`^\\s*${E}\\s*:`,"i");for(const I of this.extraHeaders)C.test(I)&&k.push(I.substring(I.indexOf(":")+1).trim());return k}}hasHeader(E){if(this.headers[_.headerize(E)])return!0;{const N=new RegExp(`^\\s*${E}\\s*:`,"i");for(const k of this.extraHeaders)if(N.test(k))return!0}return!1}parseSDP(E){return!E&&this.sdp?this.sdp:(this.sdp=R.parse(this.body||""),this.sdp)}toString(){let E=`${this.method} ${this.ruri} SIP/2.0\r
7
7
  `;for(const C in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,C))for(const I of this.headers[C])E+=`${C}: ${I}\r
8
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
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 k=this.ua.configuration.user_agent||i.USER_AGENT;if(E+=`Allow: ${i.ALLOWED_METHODS}\r
10
10
  `,E+=`Supported: ${N}\r
11
- `,E+=`User-Agent: ${$}\r
11
+ `,E+=`User-Agent: ${k}\r
12
12
  `,this.body){const C=_.str_utf8_length(this.body);E+=`Content-Length: ${C}\r
13
13
  \r
14
14
  `,E+=this.body}else E+=`Content-Length: 0\r
15
15
  \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
- `}const T=this.getHeaders("via");for(const p of T)f+=`Via: ${p}\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,k,C,I){super(i.INVITE,E,N,k,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 k={raw:N};E=_.headerize(E),this.headers[E]?this.headers[E].push(k):this.headers[E]=[k]}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)],k=[];if(!N)return[];for(const C of N)k.push(C.raw);return k}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 k=this.headers[E][N],C=k.raw;if(k.parsed)return k.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 k.parsed=I,I}s(E,N){return this.parseHeader(E,N)}setHeader(E,N){const k={raw:N};this.headers[_.headerize(E)]=[k]}parseSDP(E){return!E&&this.sdp?this.sdp:(this.sdp=R.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,k,C,I,H){const F=[];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]||"",k=_.cloneArray(k),this.ua.configuration.extra_headers&&(k=k.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 w of p)f+=`Record-Route: ${w}\r
18
+ `}const g=this.getHeaders("via");for(const p of g)f+=`Via: ${p}\r
19
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
- `;for(const p of $)f+=`${p.trim()}\r
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
23
+ `;for(const p of k)f+=`${p.trim()}\r
24
+ `;switch(this.method){case i.INVITE:this.ua.configuration.session_timers&&F.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&F.push("gruu"),F.push("ice","replaces");break;case i.UPDATE:this.ua.configuration.session_timers&&F.push("timer"),C&&F.push("ice"),F.push("replaces")}if(F.push("outbound"),this.method===i.OPTIONS?(f+=`Allow: ${i.ALLOWED_METHODS}\r
25
25
  `,f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
26
26
  `):E===405?f+=`Allow: ${i.ALLOWED_METHODS}\r
27
27
  `:E===415&&(f+=`Accept: ${i.ACCEPTED_BODY_TYPES}\r
28
- `),f+=`Supported: ${H}\r
28
+ `),f+=`Supported: ${F}\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(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
- `;for(const F of $)C+=`Via: ${F}\r
34
+ `;this.server_transaction.receiveResponse(E,f,I,H)}reply_sl(E=null,N=null){const k=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
+ `;for(const H of k)C+=`Via: ${H}\r
36
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
- `,this.ua.configuration.extra_headers)for(const F of this.ua.configuration.extra_headers)C+=`${F.trim()}\r
40
+ `,this.ua.configuration.extra_headers)for(const H of this.ua.configuration.extra_headers)C+=`${H.trim()}\r
41
41
  `;C+=`Content-Length: 0\r
42
42
  \r
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:
43
+ `,this.transport.send(C)}}class A extends m{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}return es={OutgoingRequest:h,InitialOutgoingInviteRequest:n,IncomingRequest:c,IncomingResponse:A},es}var ts,Un;function ni(){if(Un)return ts;Un=1;const R=he(),b=de(),i=new R("DigestAuthentication");return ts=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||b.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=b.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=b.calculateMD5(c),i.debug('authenticate() | using qop=auth [a2:"%s"]',c),this._response=b.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${A}`)):this._qop==="auth-int"?(c=`${this._method}:${this._uri}:${b.calculateMD5(d||"")}`,A=b.calculateMD5(c),i.debug('authenticate() | using qop=auth-int [a2:"%s"]',c),this._response=b.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${A}`)):this._qop===null&&(c=`${this._method}:${this._uri}`,A=b.calculateMD5(c),i.debug('authenticate() | using qop=null [a2:"%s"]',c),this._response=b.calculateMD5(`${this._ha1}:${this._nonce}:${A}`)),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(", ")}`}},ts}var ss,Pn;function ll(){if(Pn)return ss;Pn=1;const R=500,b=4e3,i=5e3;return ss={T1:R,T2:b,T4:i,TIMER_B:64*R,TIMER_D:0*R,TIMER_F:64*R,TIMER_H:64*R,TIMER_I:0*R,TIMER_J:0*R,TIMER_K:0*i,TIMER_L:64*R,TIMER_M:64*R,PROVISIONAL_RESPONSE_INTERVAL:6e4},ss}var rs,Mn;function Ve(){if(Mn)return rs;Mn=1;const R=Ie().EventEmitter,b=he(),i=ce(),_=Se(),S=ll(),t=new b("NonInviteClientTransaction"),d=new b("InviteClientTransaction"),h=new b("AckClientTransaction"),n=new b("NonInviteServerTransaction"),m=new b("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 R{constructor(H,F,o,f){super(),this.type=c.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=H,this.transport=F,this.request=o,this.eventHandlers=f;let g=`SIP/2.0/${F.via_transport}`;g+=` ${H.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",g),this.ua.newTransaction(this)}get C(){return c}stateChanged(H){this.state=H,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(H){const F=H.status_code;if(F<200)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(H);break}else switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),clearTimeout(this.F),F===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(H),this.K=setTimeout(()=>{this.timer_K()},S.TIMER_K);break;case c.STATUS_COMPLETED:break}}}class D extends R{constructor(H,F,o,f){super(),this.type=c.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=H,this.transport=F,this.request=o,this.eventHandlers=f,o.transaction=this;let g=`SIP/2.0/${F.via_transport}`;g+=` ${H.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",g),this.ua.newTransaction(this)}get C(){return c}stateChanged(H){this.state=H,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(H){const F=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});F.setHeader("from",this.request.getHeader("from")),F.setHeader("via",this.request.getHeader("via")),F.setHeader("to",H.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},S.TIMER_D),this.transport.send(F)}cancel(H){if(this.state!==c.STATUS_PROCEEDING)return;const F=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});F.setHeader("from",this.request.getHeader("from")),F.setHeader("via",this.request.getHeader("via")),F.setHeader("to",this.request.getHeader("to")),H&&F.setHeader("reason",H),this.transport.send(F)}receiveResponse(H){const F=H.status_code;if(F>=100&&F<=199)switch(this.state){case c.STATUS_CALLING:this.stateChanged(c.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(H);break;case c.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(H);break}else if(F>=200&&F<=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(H);break;case c.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(H);break}else if(F>=300&&F<=699)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.sendACK(H),this.eventHandlers.onReceiveResponse(H);break;case c.STATUS_COMPLETED:this.sendACK(H);break}}}class E extends R{constructor(H,F,o,f){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=F,this.request=o,this.eventHandlers=f;let g=`SIP/2.0/${F.via_transport}`;g+=` ${H.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",g)}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 R{constructor(H,F,o){super(),this.type=c.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=H,this.transport=F,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_TRYING,H.newTransaction(this)}get C(){return c}stateChanged(H){this.state=H,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(H,F,o,f){if(H===100)switch(this.state){case c.STATUS_TRYING:this.stateChanged(c.STATUS_PROCEEDING),this.transport.send(F)||this.onTransportError();break;case c.STATUS_PROCEEDING:this.last_response=F,this.transport.send(F)?o&&o():(this.onTransportError(),f&&f());break}else if(H>=200&&H<=699)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.last_response=F,this.J=setTimeout(()=>{this.timer_J()},S.TIMER_J),this.transport.send(F)?o&&o():(this.onTransportError(),f&&f());break;case c.STATUS_COMPLETED:break}}}class k extends R{constructor(H,F,o){super(),this.type=c.INVITE_SERVER,this.id=o.via_branch,this.ua=H,this.transport=F,this.request=o,this.last_response="",o.server_transaction=this,this.state=c.STATUS_PROCEEDING,H.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return c}stateChanged(H){this.state=H,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(H,F,o,f){if(H>=100&&H<=199&&this.state===c.STATUS_PROCEEDING&&(this.transport.send(F)||this.onTransportError(),this.last_response=F),H>100&&H<=199&&this.state===c.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},S.PROVISIONAL_RESPONSE_INTERVAL));else if(H>=200&&H<=299)switch(this.state){case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.last_response=F,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(F)?o&&o():(this.onTransportError(),f&&f());break}else H>=300&&H<=699&&this.state===c.STATUS_PROCEEDING&&(this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(F)?(this.stateChanged(c.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},S.TIMER_H),o&&o()):(this.onTransportError(),f&&f()))}}function C({_transactions:I},H){let F;switch(H.method){case i.INVITE:if(F=I.ist[H.via_branch],F){switch(F.state){case c.STATUS_PROCEEDING:F.transport.send(F.last_response);break;case c.STATUS_ACCEPTED:break}return!0}break;case i.ACK:if(F=I.ist[H.via_branch],F){if(F.state===c.STATUS_ACCEPTED)return!1;if(F.state===c.STATUS_COMPLETED)return F.state=c.STATUS_CONFIRMED,F.I=setTimeout(()=>{F.timer_I()},S.TIMER_I),!0}else return!1;break;case i.CANCEL:return F=I.ist[H.via_branch],F?(H.reply_sl(200),F.state!==c.STATUS_PROCEEDING):(H.reply_sl(481),!0);default:if(F=I.nist[H.via_branch],F){switch(F.state){case c.STATUS_TRYING:break;case c.STATUS_PROCEEDING:case c.STATUS_COMPLETED:F.transport.send(F.last_response);break}return!0}break}}return rs={C:c,NonInviteClientTransaction:A,InviteClientTransaction:D,AckClientTransaction:E,NonInviteServerTransaction:N,InviteServerTransaction:k,checkTransaction:C},rs}var ns,Ln;function ze(){if(Ln)return ns;Ln=1;const R=he(),b=ce(),i=ni(),_=Ve(),S=new R("RequestSender"),t={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};return ns=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!==b.BYE||this._method!==b.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)}},ns}var ls,Hn;function li(){if(Hn)return ls;Hn=1;const R=he(),b=de(),i=ce(),_=Se(),S=ze(),t=new R("Registrator"),d=10;return ls=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=b.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=b.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},n),D=new S(this._ua,A,{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((H,F)=>H.concat(F.parsed),[]);let k=N.find(H=>this._sipInstance===H.getParam("+sip.instance")&&this._reg_id===parseInt(H.getParam("reg-id")));if(k||(k=N.find(H=>H.uri.user===this._ua.contact.uri.user)),!k){t.debug("no Contact header pointing to us, response ignored");break}let C=k.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),k.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=k.getParam("temp-gruu").replace(/"/g,"")),k.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=k.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=b.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=b.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})}},ls}var is,Fn;function ii(){if(Fn)return is;Fn=1;const R=ce(),b=Ve(),i=ze(),_={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};return is=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===R.INVITE||this._request.method===R.UPDATE&&this._request.body)&&t.clientTransaction.state!==b.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const d=()=>{(t.clientTransaction.state===b.C.STATUS_ACCEPTED||t.clientTransaction.state===b.C.STATUS_COMPLETED||t.clientTransaction.state===b.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===R.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)}},is}var as,kn;function ai(){if(kn)return as;kn=1;const R=he(),b=Se(),i=ce(),_=Ve(),S=ii(),t=de(),d=new R("Dialog"),h={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};return as=class{static get C(){return h}constructor(m,c,A,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 b.IncomingResponse&&(D=c.status_code<200?h.STATUS_EARLY:h.STATUS_CONFIRMED);const E=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=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):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=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 ${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(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 A=t.cloneArray(c.extraHeaders),D=t.cloneObject(c.eventHandlers),E=c.body||null,N=this._createRequest(m,A,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,A){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 b.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,A)}_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}},as}var dt={exports:{}},$n;function oi(){if($n)return dt.exports;$n=1;const R=Ie().EventEmitter,b=he(),i=ce(),_=be(),S=de(),t=new b("RTCSession:DTMF"),d={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};return dt.exports=class extends R{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 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: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:A})}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 A=n.body.split(`
45
+ `);A.length>=1&&m.test(A[0])&&(this._tone=A[0].replace(m,"$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:n}):t.debug("invalid INFO DTMF received, discarded")}},dt.exports.C=d,dt.exports}var os,qn;function ui(){if(qn)return os;qn=1;const R=Ie().EventEmitter,b=ce(),i=be(),_=de();return os=class extends R{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(b.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})}},os}var us,jn;function ci(){if(jn)return us;jn=1;const R=he(),b=ce(),i=new R("RTCSession:ReferNotifier"),_={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};return us=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||b.REASON_PHRASE[t]||"";let h;t>=200?h="terminated;reason=noresource":h=`active;expires=${this._expires}`,this._session.sendRequest(b.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}}})}},us}var cs,Gn;function fi(){if(Gn)return cs;Gn=1;const R=Ie().EventEmitter,b=he(),i=ce(),_=Ce(),S=de(),t=new b("RTCSession:ReferSubscriber");return cs=class extends R{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 A=null;n.replaces&&(A=n.replaces._request.call_id,A+=`;to-tag=${n.replaces._to_tag}`,A+=`;from-tag=${n.replaces._from_tag}`,A=encodeURIComponent(A));const D=`Refer-To: <${h}${A?`?Replaces=${A}`:""}>`;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})}},cs}var fs,Bn;function il(){if(Bn)return fs;Bn=1;const R=Ie().EventEmitter,b=nl(),i=he(),_=ce(),S=be(),t=Ve(),d=de(),h=ll(),n=Se(),m=ai(),c=ze(),A=oi(),D=ui(),E=ci(),N=fi(),k=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},H=["audio","video"];return fs=class Rs extends R{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={},g){C.debug("connect()");const p=o,w=d.cloneObject(f.eventHandlers),U=d.cloneArray(f.extraHeaders),v=d.cloneObject(f.mediaConstraints,{audio:!0,video:!0}),y=f.mediaStream||null,P=d.cloneObject(f.pcConfig,{iceServers:[]}),O=f.rtcConstraints||null,V=f.rtcOfferConstraints||null;if(this._rtcOfferConstraints=V,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 ne in w)Object.prototype.hasOwnProperty.call(w,ne)&&this.on(ne,w[ne]);this._from_tag=d.newTag();const j=f.anonymous||!1,le={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:j,outbound:!0}),j?(le.from_display_name="Anonymous",le.from_uri=new k("sip","anonymous","anonymous.invalid"),U.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),U.push("Privacy: id")):f.fromUserName&&(le.from_uri=new k("sip",f.fromUserName,this._ua.configuration.uri.host),U.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),f.fromDisplayName&&(le.from_display_name=f.fromDisplayName),U.push(`Contact: ${this._contact}`),U.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&U.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new n.InitialOutgoingInviteRequest(o,this._ua,le,U),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(P,O),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,g&&g(this),this._newRTCSession("local",this._request),this._sendInitialRequest(v,V,y)}init_incoming(o,f){C.debug("init_incoming()");let g;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")&&(g=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),g&&(this._timers.expiresTimer=setTimeout(()=>{this._status===I.STATUS_WAITING_FOR_ANSWER&&(o.reply(487),this._failed("system",null,_.causes.EXPIRES))},g)),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,g=d.cloneArray(o.extraHeaders),p=d.cloneObject(o.mediaConstraints),w=o.mediaStream||null,U=d.cloneObject(o.pcConfig,{iceServers:[]}),v=o.rtcConstraints||null,y=o.rtcAnswerConstraints||null,P=d.cloneObject(o.rtcOfferConstraints);let O,V=!1,j=!1,le=!1,ne=!1;if(this._rtcAnswerConstraints=y,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),g.unshift(`Contact: ${this._contact}`);const fe=f.parseSDP();Array.isArray(fe.media)||(fe.media=[fe.media]);for(const Q of fe.media)Q.type==="audio"&&(V=!0,(!Q.direction||Q.direction==="sendrecv")&&(le=!0)),Q.type==="video"&&(j=!0,(!Q.direction||Q.direction==="sendrecv")&&(ne=!0));if(w&&p.audio===!1){O=w.getAudioTracks();for(const Q of O)w.removeTrack(Q)}if(w&&p.video===!1){O=w.getVideoTracks();for(const Q of O)w.removeTrack(Q)}!w&&p.audio===void 0&&(p.audio=le),!w&&p.video===void 0&&(p.video=ne),!w&&!V&&!P.offerToReceiveAudio&&(p.audio=!1),!w&&!j&&!P.offerToReceiveVideo&&(p.video=!1),this._createRTCConnection(U,v),Promise.resolve().then(()=>{if(w)return w;if(p.audio||p.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(p).catch(Q=>{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]',Q),this.emit("getusermediafailed",Q),new Error("getUserMedia() failed"))})}).then(Q=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=Q,Q&&Q.getTracks().forEach(_e=>{this._connection.addTrack(_e,Q)})}).then(()=>{if(this._late_sdp)return;const Q={originator:"remote",type:"offer",sdp:f.body};C.debug('emit "sdp"'),this.emit("sdp",Q);const _e=new RTCSessionDescription({type:"offer",sdp:Q.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(_e)).catch(Z=>{throw f.reply(488),this._failed("system",null,_.causes.WEBRTC_ERROR),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',Z),this.emit("peerconnection:setremotedescriptionfailed",Z),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",y).catch(()=>{throw f.reply(500),new Error("_createLocalDescription() failed")})}).then(Q=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(f,g),f.reply(200,null,g,Q,()=>{this._status=I.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(f,Q),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,_.causes.CONNECTION_ERROR)})}).catch(Q=>{this._status!==I.STATUS_TERMINATED&&(C.warn(`answer() failed: ${Q.message}`),this._failed("system",Q.message,_.causes.INTERNAL_ERROR))})}terminate(o={}){C.debug("terminate()");const f=o.cause||_.causes.BYE,g=d.cloneArray(o.extraHeaders),p=o.body;let w,U=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"),U&&(U<200||U>=700))throw new TypeError(`Invalid status_code: ${U}`);U&&(v=v||_.REASON_PHRASE[U]||"",w=`SIP ;cause=${U} ;text="${v}"`),this._status===I.STATUS_NULL||this._status===I.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=w):this._status===I.STATUS_1XX_RECEIVED&&this._request.cancel(w),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"),U=U||480,U<300||U>=700)throw new TypeError(`Invalid status_code: ${U}`);this._request.reply(U,v,g,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[U]||"",U&&(U<200||U>=700))throw new TypeError(`Invalid status_code: ${U}`);if(U&&g.push(`Reason: SIP ;cause=${U}; text="${v}"`),this._status===I.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==t.C.STATUS_TERMINATED){const y=this._dialog;this.receiveRequest=({method:P})=>{P===_.ACK&&(this.sendRequest(_.BYE,{extraHeaders:g,body:p}),y.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===t.C.STATUS_TERMINATED&&(this.sendRequest(_.BYE,{extraHeaders:g,body:p}),y.terminate())}),this._ended("local",null,f),this._dialog=y,this._ua.newDialog(y)}else this.sendRequest(_.BYE,{extraHeaders:g,body:p}),this._ended("local",null,f)}}sendDTMF(o,f={}){C.debug("sendDTMF() | tones: %s",o);let g=f.duration||null,p=f.interToneGap||null;const w=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(w!==_.DTMF_TRANSPORT.INFO&&w!==_.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${w}`);if(typeof o=="number"&&(o=o.toString()),!o||typeof o!="string"||!o.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${o}`);if(g&&!d.isDecimal(g))throw new TypeError(`Invalid tone duration: ${g}`);if(g?g<A.C.MIN_DURATION?(C.debug(`"duration" value is lower than the minimum allowed, setting it to ${A.C.MIN_DURATION} milliseconds`),g=A.C.MIN_DURATION):g>A.C.MAX_DURATION?(C.debug(`"duration" value is greater than the maximum allowed, setting it to ${A.C.MAX_DURATION} milliseconds`),g=A.C.MAX_DURATION):g=Math.abs(g):g=A.C.DEFAULT_DURATION,f.duration=g,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,w===_.DTMF_TRANSPORT.RFC2833){const v=this._getDTMFRTPSender();v&&(o=v.toneBuffer+o,v.insertDTMF(o,g,p));return}if(this._tones){this._tones+=o;return}this._tones=o,U.call(this);function U(){let v;if(this._status===I.STATUS_TERMINATED||!this._tones){this._tones=null;return}const y=this._tones[0];if(this._tones=this._tones.substring(1),y===",")v=2e3;else{const P=new A(this);f.eventHandlers={onFailed:()=>{this._tones=null}},P.send(y,f),v=g+p}setTimeout(U.bind(this),v)}}sendInfo(o,f,g={}){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,g)}mute(o={audio:!0,video:!1}){C.debug("mute()");let f=!1,g=!1;this._audioMuted===!1&&o.audio&&(f=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&o.video&&(g=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(f===!0||g===!0)&&this._onmute({audio:f,video:g})}unmute(o={audio:!0,video:!0}){C.debug("unmute()");let f=!1,g=!1;this._audioMuted===!0&&o.audio&&(f=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&o.video&&(g=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(f===!0||g===!0)&&this._onunmute({audio:f,video:g})}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 g={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:g,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:g,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 g={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:g,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:g,extraHeaders:o.extraHeaders}),!0}renegotiate(o={},f){C.debug("renegotiate()");const g=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:g,extraHeaders:o.extraHeaders}):this._sendReinvite({eventHandlers:p,rtcOfferConstraints:g,extraHeaders:o.extraHeaders}),!0}refer(o,f){C.debug("refer()");const g=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: ${g}`);const p=new N(this);p.sendRefer(o,f);const w=p.id;return this._referSubscribers[w]=p,p.on("requestFailed",()=>{delete this._referSubscribers[w]}),p.on("accepted",()=>{delete this._referSubscribers[w]}),p.on("failed",()=>{delete this._referSubscribers[w]}),p}sendRequest(o,f){if(C.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(o,f);{const g=Object.values(this._earlyDialogs);if(g.length>0)return g[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 g=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(g)).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 A(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 g=h.T1;function p(){this._status===I.STATUS_WAITING_FOR_ACK&&(o.reply(200,null,[`Contact: ${this._contact}`],f),g<h.T2&&(g=g*2,g>h.T2&&(g=h.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),g))}this._timers.invite2xxTimer=setTimeout(p.bind(this),g)}_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 g=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>o==="offer"?g.createOffer(f).catch(p=>(C.warn('emit "peerconnection:createofferfailed" [error:%o]',p),this.emit("peerconnection:createofferfailed",p),Promise.reject(p))):g.createAnswer(f).catch(p=>(C.warn('emit "peerconnection:createanswerfailed" [error:%o]',p),this.emit("peerconnection:createanswerfailed",p),Promise.reject(p)))).then(p=>g.setLocalDescription(p).catch(w=>(this._rtcReady=!0,C.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',w),this.emit("peerconnection:setlocaldescriptionfailed",w),Promise.reject(w)))).then(()=>{const p=f&&f.iceRestart;if(g.iceGatheringState==="complete"&&!p||g.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const w={originator:"local",type:o,sdp:g.localDescription.sdp};return C.debug('emit "sdp"'),this.emit("sdp",w),Promise.resolve(w.sdp)}return new Promise(w=>{let U=!1,v,y;this._iceReady=!1;const P=()=>{if(U)return;g.removeEventListener("icecandidate",v),g.removeEventListener("icegatheringstatechange",y),U=!0,this._rtcReady=!0,this._iceReady=!0;const O={originator:"local",type:o,sdp:g.localDescription.sdp};C.debug('emit "sdp"'),this.emit("sdp",O),w(O.sdp)};g.addEventListener("icecandidate",v=O=>{const V=O.candidate;V?this.emit("icecandidate",{candidate:V,ready:P}):P()}),g.addEventListener("icegatheringstatechange",y=()=>{g.iceGatheringState==="complete"&&P()})})})}_createDialog(o,f,g){const p=f==="UAS"?o.to_tag:o.from_tag,w=f==="UAS"?o.from_tag:o.to_tag,U=o.call_id+p+w;let v=this._earlyDialogs[U];if(g)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[U]=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[U],!0;const y=new m(this,o,f);return y.error?(C.debug(y.error),this._failed("remote",o,_.causes.INTERNAL_ERROR),!1):(this._dialog=y,!0)}}_receiveReinvite(o){C.debug("receiveReinvite()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,g={request:o,callback:void 0,reject:w.bind(this)};let p=!1;function w(v={}){p=!0;const y=v.status_code||403,P=v.reason_phrase||"",O=d.cloneArray(v.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(y<300||y>=700)throw new TypeError(`Invalid status_code: ${y}`);o.reply(y,P,O)}if(this.emit("reinvite",g),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=>{U.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&&U.call(this,v)}).catch(v=>{C.warn(v)});function U(v){const y=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,y),this._late_sdp&&(v=this._mangleOffer(v)),o.reply(200,null,y,v,()=>{this._status=I.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(o,v),this._setACKTimer()}),typeof g.callback=="function"&&g.callback()}}_receiveUpdate(o){C.debug("receiveUpdate()");const f=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,g={request:o,callback:void 0,reject:w.bind(this)};let p=!1;function w(v={}){p=!0;const y=v.status_code||403,P=v.reason_phrase||"",O=d.cloneArray(v.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(y<300||y>=700)throw new TypeError(`Invalid status_code: ${y}`);o.reply(y,P,O)}if(this.emit("update",g),p)return;if(!o.body){U.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&&U.call(this,v)}).catch(v=>{C.warn(v)});function U(v){const y=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(o,y),o.reply(200,null,y,v),typeof g.callback=="function"&&g.callback()}}_processInDialogSdpOffer(o){C.debug("_processInDialogSdpOffer()");const f=o.parseSDP();let g=!1;for(const U of f.media){if(H.indexOf(U.type)===-1)continue;const v=U.direction||f.direction||"sendrecv";if(v==="sendonly"||v==="inactive")g=!0;else{g=!1;break}}const p={originator:"remote",type:"offer",sdp:o.body};C.debug('emit "sdp"'),this.emit("sdp",p);const w=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(w).catch(U=>{throw o.reply(488),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),this.emit("peerconnection:setremotedescriptionfailed",U),U})}).then(()=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&g===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&g===!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(U=>{throw o.reply(500),C.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',U),U})}).catch(U=>{C.warn("_processInDialogSdpOffer() failed [error: %o]",U)}),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:(w,U)=>{g.call(this,w,U)},reject:()=>{p.call(this)}});function g(w,U={}){if(w=typeof w=="function"?w:null,this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;const v=new Rs(this._ua);if(v.on("progress",({response:y})=>{f.notify(y.status_code,y.reason_phrase)}),v.on("accepted",({response:y})=>{f.notify(y.status_code,y.reason_phrase)}),v.on("_failed",({message:y,cause:P})=>{y?f.notify(y.status_code,y.reason_phrase):f.notify(487,P)}),o.refer_to.uri.hasHeader("replaces")){const y=decodeURIComponent(o.refer_to.uri.getHeader("replaces"));U.extraHeaders=d.cloneArray(U.extraHeaders),U.extraHeaders.push(`Replaces: ${y}`)}v.connect(o.refer_to.uri.toAor(),U,w)}function p(){f.notify(603)}}_receiveNotify(o){switch(C.debug("receiveNotify()"),o.event||o.reply(400),o.event.event){case"refer":{let f,g;if(o.event.params&&o.event.params.id)f=o.event.params.id,g=this._referSubscribers[f];else if(Object.keys(this._referSubscribers).length===1)g=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{o.reply(400,"Missing event id parameter");return}if(!g){o.reply(481,"Subscription does not exist");return}g.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 w=new Rs(this._ua);w.on("confirmed",()=>{this.terminate()}),w.init_incoming(o,p)}function g(){C.debug("Replaced INVITE rejected by the user"),o.reply(486)}this.emit("replaces",{request:o,accept:p=>{f.call(this,p)},reject:()=>{g.call(this)}})}_sendInitialRequest(o,f,g){const p=new c(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:w=>{this._request=w},onReceiveResponse:w=>{this._receiveInviteResponse(w)}});Promise.resolve().then(()=>{if(g)return g;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(w=>{throw this._status===I.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,_.causes.USER_DENIED_MEDIA_ACCESS),C.warn('emit "getusermediafailed" [error:%o]',w),this.emit("getusermediafailed",w),w)})}).then(w=>{if(this._status===I.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=w,w&&w.getTracks().forEach(U=>{this._connection.addTrack(U,w)}),this._connecting(this._request),this._createLocalDescription("offer",f).catch(U=>{throw this._failed("local",null,_.causes.WEBRTC_ERROR),U})}).then(w=>{if(this._is_canceled||this._status===I.STATUS_TERMINATED)throw new Error("terminated");this._request.body=w,this._status=I.STATUS_INVITE_SENT,C.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),p.send()}).catch(w=>{this._status!==I.STATUS_TERMINATED&&C.warn(w)})}_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 g=new RTCSessionDescription({type:"answer",sdp:f.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(g)).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 g=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(g).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),g=d.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null;let w=!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(y=>{y=this._mangleOffer(y);const P={originator:"local",type:"offer",sdp:y};C.debug('emit "sdp"'),this.emit("sdp",P),this.sendRequest(_.INVITE,{extraHeaders:f,body:y,eventHandlers:{onSuccessResponse:O=>{U.call(this,O),w=!0},onErrorResponse:O=>{v.call(this,O)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function U(y){if(this._status===I.STATUS_TERMINATED||(this.sendRequest(_.ACK),w))return;if(this._handleSessionTimersInIncomingResponse(y),y.body){if(!y.hasHeader("Content-Type")||y.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const P={originator:"remote",type:"answer",sdp:y.body};C.debug('emit "sdp"'),this.emit("sdp",P);const O=new RTCSessionDescription({type:"answer",sdp:P.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(O)).then(()=>{g.succeeded&&g.succeeded(y)}).catch(V=>{v.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',V),this.emit("peerconnection:setremotedescriptionfailed",V)})}function v(y){g.failed&&g.failed(y)}}_sendUpdate(o={}){C.debug("sendUpdate()");const f=d.cloneArray(o.extraHeaders),g=d.cloneObject(o.eventHandlers),p=o.rtcOfferConstraints||this._rtcOfferConstraints||null,w=o.sdpOffer||!1;let U=!1;f.push(`Contact: ${this._contact}`),this._sessionTimers.running&&f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),w?(f.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",p)).then(P=>{P=this._mangleOffer(P);const O={originator:"local",type:"offer",sdp:P};C.debug('emit "sdp"'),this.emit("sdp",O),this.sendRequest(_.UPDATE,{extraHeaders:f,body:P,eventHandlers:{onSuccessResponse:V=>{v.call(this,V),U=!0},onErrorResponse:V=>{y.call(this,V)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{y.call(this)})):this.sendRequest(_.UPDATE,{extraHeaders:f,eventHandlers:{onSuccessResponse:P=>{v.call(this,P)},onErrorResponse:P=>{y.call(this,P)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(P){if(this._status!==I.STATUS_TERMINATED&&!U)if(this._handleSessionTimersInIncomingResponse(P),w){if(P.body){if(!P.hasHeader("Content-Type")||P.getHeader("Content-Type").toLowerCase()!=="application/sdp"){y.call(this);return}}else{y.call(this);return}const O={originator:"remote",type:"answer",sdp:P.body};C.debug('emit "sdp"'),this.emit("sdp",O);const V=new RTCSessionDescription({type:"answer",sdp:O.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(V)).then(()=>{g.succeeded&&g.succeeded(P)}).catch(j=>{y.call(this),C.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',j),this.emit("peerconnection:setremotedescriptionfailed",j)})}else g.succeeded&&g.succeeded(P)}function y(P){g.failed&&g.failed(P)}}_acceptAndTerminate(o,f,g){C.debug("acceptAndTerminate()");const p=[];f&&(g=g||_.REASON_PHRASE[f]||"",p.push(`Reason: SIP ;cause=${f}; text="${g}"`)),(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=b.parse(o),this._localHold&&!this._remoteHold){C.debug("mangleOffer() | me on hold, mangling offer");for(const f of o.media)H.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)H.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)H.indexOf(f.type)!==-1&&(f.direction?f.direction==="sendrecv"?f.direction="recvonly":f.direction==="recvonly"&&(f.direction="inactive"):f.direction="recvonly")}return b.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 g;o.session_expires&&o.session_expires>=_.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,g=o.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,g="uas"),f.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${g}`),this._sessionTimers.refresher=g==="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(g=>g.track&&g.track.kind==="audio");for(const g of f)g.track.enabled=!o}_toggleMuteVideo(o){const f=this._connection.getSenders().filter(g=>g.track&&g.track.kind==="video");for(const g of f)g.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,g){C.debug("session ended"),this._end_time=new Date,this._close(),C.debug('emit "ended"'),this.emit("ended",{originator:o,message:f||null,cause:g})}_failed(o,f,g){C.debug("session failed"),C.debug('emit "_failed"'),this.emit("_failed",{originator:o,message:f||null,cause:g}),this._close(),C.debug('emit "failed"'),this.emit("failed",{originator:o,message:f||null,cause:g})}_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})}},fs}var hs,Wn;function hi(){if(Wn)return hs;Wn=1;const R=Ie().EventEmitter,b=he(),i=ce(),_=Se(),S=de(),t=ze(),d=be(),h=ye(),n=new b("Message");return hs=class extends R{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,D={}){const E=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: ${E}`);const N=S.cloneArray(D.extraHeaders),k=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 F in k)Object.prototype.hasOwnProperty.call(k,F)&&this.on(F,k[F]);N.push(`Content-Type: ${C}`),this._request=new _.OutgoingRequest(i.MESSAGE,c,this._ua,I,N),A&&(this._request.body=A);const H=new t(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:F=>{this._receiveResponse(F)}});this._newMessage("local",this._request),H.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=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,A,D)}reject(c={}){const A=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(A<300||A>=700)throw new TypeError(`Invalid status_code: ${A}`);this._is_replied=!0,this._request.reply(A,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 A=S.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,D){n.debug("MESSAGE failed"),this._close(),n.debug('emit "failed"'),this.emit("failed",{originator:c,response:A||null,cause:D})}_succeeded(c,A){n.debug("MESSAGE succeeded"),this._close(),n.debug('emit "succeeded"'),this.emit("succeeded",{originator:c,response:A})}},hs}var ds,Vn;function di(){if(Vn)return ds;Vn=1;const R=Ie().EventEmitter,b=he(),i=ce(),_=Se(),S=de(),t=ze(),d=be(),h=new b("Options");return ds=class extends R{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,A={}){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(A.extraHeaders),N=S.cloneObject(A.eventHandlers),k=A.contentType||"application/sdp";for(const I in N)Object.prototype.hasOwnProperty.call(N,I)&&this.on(I,N[I]);E.push(`Content-Type: ${k}`),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),A=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,A)}reject(m={}){const c=m.status_code||480,A=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,A,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,A){h.debug("OPTIONS failed"),this._close(),h.debug('emit "failed"'),this.emit("failed",{originator:m,response:c||null,cause:A})}_succeeded(m,c){h.debug("OPTIONS succeeded"),this._close(),h.debug('emit "succeeded"'),this.emit("succeeded",{originator:m,response:c})}},ds}var _s={},zn;function al(){if(zn)return _s;zn=1;const R=he(),b=de(),i=Ce(),_=new R("Socket");return _s.isSocket=S=>{if(Array.isArray(S))return!1;if(typeof S>"u")return _.warn("undefined JsSIP.Socket instance"),!1;try{if(!b.isString(S.url))throw _.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!b.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(!b.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},_s}var ps,Kn;function _i(){if(Kn)return ps;Kn=1;const R=he(),b=al(),i=ce(),_=new R("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 ps=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(!b.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
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
@@ -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={},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
- `;for(const p of o)T+=`Via: ${p}\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
- `,T+=`\r
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 w-full 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;
59
+ `);this.ondata({transport:this,message:d})}},ps}var ms={},Yn;function pi(){if(Yn)return ms;Yn=1;const R=he(),b=Ce(),i=Se(),_=new R("Parser");ms.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 A=d.substring(0,c);let D=b.parse(A,"Request_Response");if(D===-1){_.warn(`parseMessage() | error parsing first line of SIP message: "${A}"`);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 A=h.indexOf(":",n),D=h.substring(n,A).trim(),E=h.substring(A+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=b.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=b.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 ms}var gs,Jn;function mi(){if(Jn)return gs;Jn=1;const R=he(),b=ce(),i=Se(),_=de(),S=new R("sanityCheck"),t=[I],d=[A,D,E,N],h=[k,C];let n,m,c;gs=(F,o,f)=>{n=F,m=o,c=f;for(const g of t)if(g()===!1)return!1;if(n instanceof i.IncomingRequest){for(const g of d)if(g()===!1)return!1}else if(n instanceof i.IncomingResponse){for(const g of h)if(g()===!1)return!1}return!0};function A(){if(n.s("to").uri.scheme!=="sip")return H(416),!1}function D(){if(!n.to_tag&&n.call_id.substr(0,5)===m.configuration.jssip_id)return H(482),!1}function E(){const F=_.str_utf8_length(n.body),o=n.getHeader("content-length");if(F<o)return H(400),!1}function N(){const F=n.from_tag,o=n.call_id,f=n.cseq;let g;if(!n.to_tag)if(n.method===b.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)&&(g=m._transactions.ist[p],g.request.from_tag===F&&g.request.call_id===o&&g.request.cseq===f))return H(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)&&(g=m._transactions.nist[p],g.request.from_tag===F&&g.request.call_id===o&&g.request.cseq===f))return H(482),!1}}function k(){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 F=_.str_utf8_length(n.body),o=n.getHeader("content-length");if(F<o)return S.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function I(){const F=["from","to","call_id","cseq","via"];for(const o of F)if(!n.hasHeader(o))return S.debug(`missing mandatory header field : ${o}, dropping the response`),!1}function H(F){const o=n.getHeaders("via");let f,g=`SIP/2.0 ${F} ${b.REASON_PHRASE[F]}\r
62
+ `;for(const p of o)g+=`Via: ${p}\r
63
+ `;f=n.getHeader("To"),n.to_tag||(f+=`;tag=${_.newTag()}`),g+=`To: ${f}\r
64
+ `,g+=`From: ${n.getHeader("From")}\r
65
+ `,g+=`Call-ID: ${n.call_id}\r
66
+ `,g+=`CSeq: ${n.cseq} ${n.method}\r
67
+ `,g+=`\r
68
+ `,c.send(g)}return gs}var _t={},Xn;function gi(){if(Xn)return _t;Xn=1;const R=de(),b=ce(),i=Ce(),_=ye(),S=al(),t=be();_t.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:b.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:b.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:b.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${R.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=`${b.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(R.isDecimal(h)){const n=Number(h);if(n>0)return n}},connection_recovery_min_interval(h){if(R.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(R.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===b.INVITE||h===b.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(R.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=`${b.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 _t.load=(h,n)=>{for(const m in d.mandatory)if(n.hasOwnProperty(m)){const c=n[m],A=d.mandatory[m](c);if(A!==void 0)h[m]=A;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(R.isEmpty(c))continue;const A=d.optional[m](c);if(A!==void 0)h[m]=A;else throw new t.ConfigurationError(m,c)}},_t}var Ts,Qn;function Ti(){if(Qn)return Ts;Qn=1;const R=Ie().EventEmitter,b=he(),i=ce(),_=li(),S=il(),t=hi(),d=di(),h=Ve(),n=_i(),m=de(),c=be(),A=ye(),D=pi(),E=Se(),N=mi(),k=gi(),C=new b("UA"),I={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};Ts=class extends R{static get C(){return I}constructor(p){if(!p)throw new TypeError("Not enough arguments");const w=["password","ha1","authorization_jwt"];C.debug("new() [configuration:%o]",Object.entries(p).filter(([U])=>!w.includes(U))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},k.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(U){throw this._status=I.STATUS_NOT_READY,this._error=I.CONFIGURATION_ERROR,U}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,w){C.debug("call()");const U=new S(this);return U.connect(p,w),U}sendMessage(p,w,U){C.debug("sendMessage()");const v=new t(this);return v.send(p,w,U),v}sendOptions(p,w,U){C.debug("sendOptions()");const v=new d(this);return v.send(p,w,U),v}terminateSessions(p){C.debug("terminateSessions()");for(const w in this._sessions)this._sessions[w].isEnded()||this._sessions[w].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 U in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,U)){C.debug(`closing session ${U}`);try{this._sessions[U].terminate()}catch{}}for(const U in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,U))try{this._applicants[U].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,w){switch(p){case"authorization_user":{this._configuration.authorization_user=String(w);break}case"password":{this._configuration.password=String(w);break}case"realm":{this._configuration.realm=String(w);break}case"ha1":{this._configuration.ha1=String(w),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(w);break}case"display_name":{this._configuration.display_name=w;break}case"extra_headers":{this._configuration.extra_headers=w;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,w){this._applicants[p]=p,this.emit("newMessage",w)}newOptions(p,w){this._applicants[p]=p,this.emit("newOptions",w)}destroyMessage(p){delete this._applicants[p]}newRTCSession(p,w){this._sessions[p.id]=p,this.emit("newRTCSession",w)}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 w=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(w===i.INVITE?new h.InviteServerTransaction(this,this._transport,p):w!==i.ACK&&w!==i.CANCEL&&new h.NonInviteServerTransaction(this,this._transport,p),w===i.OPTIONS){if(this.listeners("newOptions").length===0){p.reply(200);return}new d(this).init_incoming(p)}else if(w===i.MESSAGE){if(this.listeners("newMessage").length===0){p.reply(405);return}new t(this).init_incoming(p)}else if(w===i.INVITE&&!p.to_tag&&this.listeners("newRTCSession").length===0){p.reply(405);return}let U,v;if(p.to_tag)U=this._findDialog(p.call_id,p.from_tag,p.to_tag),U?U.receiveRequest(p):w===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"))):w!==i.ACK&&p.reply(481);else switch(w){case i.INVITE:if(window.RTCPeerConnection)if(p.hasHeader("replaces")){const y=p.replaces;U=this._findDialog(y.call_id,y.from_tag,y.to_tag),U?(v=U.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:w,to_tag:U}){const v=p+w,y=this._sessions[v],P=p+U,O=this._sessions[P];return y||O||null}_findDialog(p,w,U){let v=p+w+U,y=this._dialogs[v];return y||(v=p+U+w,y=this._dialogs[v],y||null)}_loadConfig(p){try{k.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 w=this._configuration.uri.clone();w.user=null,this._configuration.hostport_params=w.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=H.bind(this),this._transport.onconnect=F.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 A("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 y=v.anonymous||null,P=v.outbound||null;let O="<";return y?O+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":O+=this.pub_gruu||this.uri.toString(),P&&(y?!this.temp_gruu:!this.pub_gruu)&&(O+=";ob"),O+=">",O}};const U=["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)&&(U.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(k.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 H(g){this.emit("connecting",g)}function F(g){this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_READY,this._error=null,this.emit("connected",g),this._dynConfiguration.register&&this._registrator.register())}function o(g){const p=["nict","ict","nist","ist"];for(const w of p)for(const U in this._transactions[w])Object.prototype.hasOwnProperty.call(this._transactions[w],U)&&this._transactions[w][U].onTransportError();this.emit("disconnected",g),this._registrator.onTransportClosed(),this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_NOT_READY,this._error=I.NETWORK_ERROR)}function f(g){const p=g.transport;let w=g.message;if(w=D.parseMessage(w,this),!!w&&!(this._status===I.STATUS_USER_CLOSED&&w instanceof E.IncomingRequest)&&N(w,this,p)){if(w instanceof E.IncomingRequest)w.transport=p,this.receiveRequest(w);else if(w instanceof E.IncomingResponse){let U;switch(w.method){case i.INVITE:U=this._transactions.ict[w.via_branch],U&&U.receiveResponse(w);break;case i.ACK:break;default:U=this._transactions.nict[w.via_branch],U&&U.receiveResponse(w);break}}}}return Ts}var Cs,Zn;function Ci(){if(Zn)return Cs;Zn=1;const R=he(),b=Ce(),i=new R("WebSocketInterface");return Cs=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=b.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)}},Cs}var vs,el;function vi(){if(el)return vs;el=1;const R=tl,b=ce(),i=be(),_=de(),S=Ti(),t=ye(),d=bs(),h=Ce(),n=Ci(),m=As()("JsSIP"),c=il();return m("version %s",R.version),vs={C:b,Exceptions:i,Utils:_,UA:S,URI:t,NameAddrHeader:d,WebSocketInterface:n,Grammar:h,RTCSession:c,debug:As(),get name(){return R.title},get version(){return R.version}},vs}var Ei=vi();const Tt=Xl(Ei);let Le=null,Es=null;function Si(R){return`${R.websocketUrl}|${R.sipUri}|${R.authorizationUser}`}function Ai(R){const b=Si(R);if(Le&&Es===b)return Le;if(Le&&Es!==b){try{Le.ua.stop()}catch{}Le=null}Es=b;const _={sockets:[new Tt.WebSocketInterface(R.websocketUrl)],uri:R.sipUri,password:R.password,registrar_server:R.registrarServer,display_name:R.displayName,authorization_user:R.authorizationUser,connection_recovery_min_interval:2,connection_recovery_max_interval:30},S=new Tt.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()})))}),Le=d,d}function Ri(R){R.isStarted||(R.ua.start(),R.isStarted=!0)}function wi(R,b){R.listeners.add(b)}function bi(R,b){R.listeners.delete(b)}function yi(R){return{isReady:R.ua.isRegistered(),isConnected:R.ua.isConnected()}}const ol=K.createContext(null);function ul({config:R,children:b,onCallStart:i,onCallEnd:_,onStatusChange:S}){const[t,d]=K.useState(""),[h,n]=K.useState("disconnected"),[m,c]=K.useState(null),[A,D]=K.useState(0),[E,N]=K.useState([]),[k,C]=K.useState(!1),[I,H]=K.useState("connecting"),F=K.useRef(null),o=K.useRef(null),f=K.useRef(null);K.useEffect(()=>{o.current=m},[m]),K.useEffect(()=>{const v=Ai(R);f.current=v;const y=yi(v);y.isReady?(C(!0),H("connected")):y.isConnected&&H("connected");const P={onConnecting:()=>H("connecting"),onConnected:()=>H("connected"),onDisconnected:()=>{H("disconnected"),C(!1)},onRegistered:()=>{C(!0),H("connected")},onUnregistered:()=>C(!1),onRegistrationFailed:O=>{console.error("Registration failed:",O),C(!1),H("failed")},onNewSession:O=>{F.current=O}};return wi(v,P),Ri(v),()=>{bi(v,P)}},[R.websocketUrl,R.sipUri,R.password,R.registrarServer,R.displayName,R.authorizationUser]),K.useEffect(()=>{S?.(h)},[h,S]),K.useEffect(()=>{const v=localStorage.getItem("tbi-phone-call-history");if(v)try{N(JSON.parse(v))}catch(y){console.error("Error loading call history",y)}},[]),K.useEffect(()=>{E.length>0&&localStorage.setItem("tbi-phone-call-history",JSON.stringify(E))},[E]),K.useEffect(()=>{if(h==="confirmed"&&m){const v=setInterval(()=>{D(Math.floor((Date.now()-m)/1e3))},1e3);return()=>clearInterval(v)}else D(0)},[h,m]),K.useEffect(()=>{const v=y=>{const P=y.detail.number;h==="disconnected"&&w(P)};return window.addEventListener("StartCallEvent",v),()=>{window.removeEventListener("StartCallEvent",v)}},[h]);const g=K.useCallback((v,y,P)=>{const O={id:Date.now().toString(),number:v,timestamp:Date.now(),duration:y,status:P};N(V=>[O,...V].slice(0,50))},[]),p=K.useCallback(()=>{F.current&&(F.current.terminate(),F.current=null)},[]),w=K.useCallback(v=>{const y=f.current;if(!v.trim()||!y)return;if(!k){console.warn("Phone is not ready yet. Please wait for registration.");return}d(v),i?.(v);const O={eventHandlers:{progress:()=>{n("progress")},failed:V=>{console.error("Call failed:",V?.cause),n("failed"),g(v,0,"failed"),_?.(v,0,"failed"),F.current=null,setTimeout(()=>n("disconnected"),3e3)},ended:()=>{n("ended");const V=o.current,j=V?Math.floor((Date.now()-V)/1e3):0;g(v,j,"completed"),_?.(v,j,"completed"),F.current=null,setTimeout(()=>{n("disconnected"),c(null)},2e3)},confirmed:()=>{n("confirmed"),c(Date.now())}},mediaConstraints:{audio:!0,video:!1}};n("progress");try{const V=y.ua.call(v,O);F.current=V}catch(V){console.error("Failed to start call:",V),n("failed"),g(v,0,"failed"),setTimeout(()=>n("disconnected"),3e3)}},[g,i,_,k]),U={status:h,callNumber:t,setCallNumber:d,callHistory:E,currentCallDuration:A,startCall:w,endCall:p,isReady:k,connectionStatus:I};return q.jsx(ol.Provider,{value:U,children:b})}function cl(){const R=K.useContext(ol);if(!R)throw new Error("usePhone must be used within a PhoneProvider");return R}const ws=({className:R})=>q.jsx("svg",{className:R,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"})}),Ii=({className:R})=>q.jsx("svg",{className:R,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"})}),xi=({className:R})=>q.jsx("svg",{className:R,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"})}),pt=({className:R})=>q.jsx("svg",{className:R,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"})}),fl=({className:R})=>q.jsx("svg",{className:R,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"})}),Ni=({className:R})=>q.jsxs("svg",{className:R,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"})]}),Oi=({className:R})=>q.jsxs("svg",{className:R,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"})]}),Di=({className:R})=>q.jsx("svg",{className:R,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"})}),Ui=({className:R})=>q.jsx("svg",{className:R,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 Pi({className:R,labels:b}){const{status:i,callNumber:_,setCallNumber:S,callHistory:t,currentCallDuration:d,startCall:h,endCall:n,isReady:m,connectionStatus:c}=cl(),[A,D]=K.useState(!1),E={...Jl,...b},k=(()=>{switch(i){case"progress":return{text:`${E.calling}...`,color:"text-yellow-500",Icon:Ii};case"confirmed":return{text:`${E.inCall} - ${gt(d)}`,color:"text-green-500",Icon:xi};case"failed":return{text:E.callEnded,color:"text-red-500",Icon:fl};case"ended":return{text:E.callEnded,color:"text-gray-500",Icon:pt};default:return{text:E.inactive,color:"text-gray-300",Icon:ws}}})();return q.jsxs("div",{className:mt("tbi-phone w-full max-w-md mx-auto bg-white rounded-2xl shadow-lg border border-gray-200 p-2",R),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(Di,{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 w-full 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(ws,{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(k.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(pt,{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(k.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:gt(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(pt,{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(k.Icon,{className:mt("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:k.text})})]}),A&&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",style:{backgroundColor:"white"},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(Ui,{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(pt,{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(Mi,{entry:C,index:I,onCall:()=>{S(C.number),D(!1),h(C.number)}},C.id))})})]})})]})]})}function Mi({entry:R,index:b,onCall:i}){const _=()=>{switch(R.status){case"completed":return q.jsx(Ni,{className:"w-4 h-4 text-green-600"});case"failed":return q.jsx(Oi,{className:"w-4 h-4 text-red-600"});case"missed":return q.jsx(fl,{className:"w-4 h-4 text-yellow-600"})}},S=()=>{switch(R.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:`${b*30}ms`},children:[q.jsx("div",{className:mt("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:R.number}),q.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[q.jsx("span",{children:new Date(R.timestamp).toLocaleString("es-ES",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}),R.duration>0&&q.jsxs(q.Fragment,{children:[q.jsx("span",{children:"•"}),q.jsx("span",{className:"font-mono tabular-nums",children:gt(R.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(ws,{className:"w-4 h-4"})})]})}function Li({config:R,className:b,onCallStart:i,onCallEnd:_,onStatusChange:S,labels:t}){return q.jsx(ul,{config:R,onCallStart:i,onCallEnd:_,onStatusChange:S,children:q.jsx(Pi,{className:b,labels:t})})}let Pe=null,Ss=null;function Hi(R){return`${R.websocketUrl}|${R.sipUri}|${R.authorizationUser}`}function Fi(R){const i={sockets:[new Tt.WebSocketInterface(R.websocketUrl)],uri:R.sipUri,password:R.password,registrar_server:R.registrarServer,display_name:R.displayName,authorization_user:R.authorizationUser,connection_recovery_min_interval:2,connection_recovery_max_interval:30},_=new Tt.UA(i),S=document.createElement("audio");S.autoplay=!0;const t={ua:_,audio:S,isStarted:!1,listeners:new Set};return _.on("connecting",()=>{t.listeners.forEach(d=>d.onConnecting?.())}),_.on("connected",()=>{t.listeners.forEach(d=>d.onConnected?.())}),_.on("disconnected",()=>{t.listeners.forEach(d=>d.onDisconnected?.())}),_.on("registered",()=>{t.listeners.forEach(d=>d.onRegistered?.())}),_.on("unregistered",()=>{t.listeners.forEach(d=>d.onUnregistered?.())}),_.on("registrationFailed",d=>{t.listeners.forEach(h=>h.onRegistrationFailed?.(d?.cause))}),_.on("newRTCSession",d=>{const h=d.session;h.direction==="outgoing"&&(t.listeners.forEach(n=>n.onNewSession?.(h)),h.connection&&(h.connection.addEventListener("addstream",n=>{if(!n.streams?.length)return;const m=document.createElement("audio");m.srcObject=n.streams[0],m.play()}),h.connection.addEventListener("track",n=>{const m=document.createElement("audio");m.srcObject=n.streams[0],m.play()})))}),t}function ki(R){const b=Hi(R);if(Pe&&Ss===b)return Pe;if(Pe&&Ss!==b){try{Pe.ua.stop()}catch{}Pe=null}return Ss=b,Pe=Fi(R),Pe}function $i(R,b={}){const{onCallStart:i,onCallEnd:_,onStatusChange:S,onConnectionChange:t,persistHistory:d=!0,historyKey:h="tbi-phone-call-history"}=b,[n,m]=K.useState(""),[c,A]=K.useState("disconnected"),[D,E]=K.useState(null),[N,k]=K.useState(0),[C,I]=K.useState([]),[H,F]=K.useState(!1),[o,f]=K.useState("connecting"),g=K.useRef(null),p=K.useRef(null),w=K.useRef(null);K.useEffect(()=>{p.current=D},[D]),K.useEffect(()=>{const O=ki(R);w.current=O,O.ua.isRegistered()?(F(!0),f("connected")):O.ua.isConnected()&&f("connected");const V={onConnecting:()=>{f("connecting"),t?.("connecting")},onConnected:()=>{f("connected"),t?.("connected")},onDisconnected:()=>{f("disconnected"),F(!1),t?.("disconnected")},onRegistered:()=>{F(!0),f("connected"),t?.("connected")},onUnregistered:()=>F(!1),onRegistrationFailed:j=>{console.error("Registration failed:",j),F(!1),f("failed"),t?.("failed")},onNewSession:j=>{g.current=j}};return O.listeners.add(V),O.isStarted||(O.ua.start(),O.isStarted=!0),()=>{O.listeners.delete(V)}},[R.websocketUrl,R.sipUri,R.password,R.registrarServer,R.displayName,R.authorizationUser,t]),K.useEffect(()=>{S?.(c)},[c,S]),K.useEffect(()=>{if(!d)return;const O=localStorage.getItem(h);if(O)try{I(JSON.parse(O))}catch(V){console.error("Error loading call history",V)}},[d,h]),K.useEffect(()=>{d&&C.length>0&&localStorage.setItem(h,JSON.stringify(C))},[C,d,h]),K.useEffect(()=>{if(c==="confirmed"&&D){const O=setInterval(()=>{k(Math.floor((Date.now()-D)/1e3))},1e3);return()=>clearInterval(O)}else k(0)},[c,D]),K.useEffect(()=>{const O=V=>{const j=V.detail.number;c==="disconnected"&&P(j)};return window.addEventListener("StartCallEvent",O),()=>{window.removeEventListener("StartCallEvent",O)}},[c]);const U=K.useCallback((O,V,j)=>{const le={id:Date.now().toString(),number:O,timestamp:Date.now(),duration:V,status:j};I(ne=>[le,...ne].slice(0,50))},[]),v=K.useCallback(()=>{I([]),d&&localStorage.removeItem(h)},[d,h]),y=K.useCallback(()=>{g.current&&(g.current.terminate(),g.current=null)},[]),P=K.useCallback(O=>{const V=w.current;if(!O.trim()||!V)return;if(!H){console.warn("Phone is not ready yet. Please wait for registration.");return}m(O),i?.(O);const le={eventHandlers:{progress:()=>{A("progress")},failed:ne=>{console.error("Call failed:",ne?.cause),A("failed"),U(O,0,"failed"),_?.(O,0,"failed"),g.current=null,setTimeout(()=>A("disconnected"),3e3)},ended:()=>{A("ended");const ne=p.current,fe=ne?Math.floor((Date.now()-ne)/1e3):0;U(O,fe,"completed"),_?.(O,fe,"completed"),g.current=null,setTimeout(()=>{A("disconnected"),E(null)},2e3)},confirmed:()=>{A("confirmed"),E(Date.now())}},mediaConstraints:{audio:!0,video:!1}};A("progress");try{const ne=V.ua.call(O,le);g.current=ne}catch(ne){console.error("Failed to start call:",ne),A("failed"),U(O,0,"failed"),setTimeout(()=>A("disconnected"),3e3)}},[U,i,_,H]);return{status:c,callNumber:n,setCallNumber:m,callHistory:C,clearCallHistory:v,currentCallDuration:N,startCall:P,endCall:y,isReady:H,connectionStatus:o,ua:w.current?.ua??null}}exports.Phone=Li;exports.PhoneProvider=ul;exports.cn=mt;exports.formatDuration=gt;exports.usePhone=cl;exports.usePhoneManager=$i;