@16x/webphone-sdk 3.1.18 → 3.1.19
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.
- package/CHANGELOG.md +267 -40
- package/LICENSE +1 -1
- package/README.md +214 -161
- package/dist/{Diagnostics-DhX9Uc67.cjs → Diagnostics-CgDSPlQx.cjs} +1 -1
- package/dist/{Diagnostics-qnipur6s.js → Diagnostics-DJdBDGad.js} +1 -1
- package/dist/{JsSipAdapter-l97xq1ao.cjs → JsSipAdapter-CgBtmR16.cjs} +1 -1
- package/dist/{JsSipAdapter-B8ueIoBA.js → JsSipAdapter-CiqM4KOq.js} +1 -1
- package/dist/SharedWorkerProtocol-4VARy5ma.cjs +1 -0
- package/dist/SharedWorkerProtocol-DvLUl0JZ.js +93 -0
- package/dist/core/CCBarCall.d.ts +1 -1
- package/dist/createJsSipFactory-9CPsweDR.js +9665 -0
- package/dist/createJsSipFactory-Dr8HbLl-.cjs +75 -0
- package/dist/crypto/legacySipTicket.d.ts +40 -0
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.js +1 -1
- package/dist/errors/CCBarError.d.ts +2 -0
- package/dist/i18n/index.d.ts +22 -0
- package/dist/i18n/messages/en-US.d.ts +2 -0
- package/dist/i18n/messages/es-ES.d.ts +2 -0
- package/dist/i18n/messages/id-ID.d.ts +2 -0
- package/dist/i18n/messages/index.d.ts +7 -0
- package/dist/i18n/messages/zh-CN.d.ts +2 -0
- package/dist/i18n/types.d.ts +5 -0
- package/dist/i18n-BbEy6K9z.cjs +1 -0
- package/dist/i18n-D-DdHtGz.js +150 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -8
- package/dist/index.umd.js +69 -16
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +10 -276
- package/dist/legacy/legacySessionProvider.d.ts +20 -9
- package/dist/legacySessionProvider-CKJyrade.cjs +1 -0
- package/dist/{CCBarClient-5z2ZCceq.js → legacySessionProvider-DBrRBB3S.js} +778 -501
- package/dist/shared/SharedWorkerFactory.d.ts +2 -0
- package/dist/shared/SharedWorkerProtocol.d.ts +2 -0
- package/dist/shared-worker.cjs +1 -1
- package/dist/shared-worker.js +65 -64
- package/dist/styles.css +7 -7
- package/dist/ui/i18n/es-ES.d.ts +2 -0
- package/dist/ui/i18n/id-ID.d.ts +2 -0
- package/dist/ui/i18n/index.d.ts +2 -0
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.js +278 -170
- package/dist/version.d.ts +1 -1
- package/package.json +114 -109
- package/dist/CCBarClient-UAJK9WcJ.cjs +0 -1
- package/dist/SharedWorkerProtocol-C-4KpECM.cjs +0 -1
- package/dist/SharedWorkerProtocol-CffZrUXg.js +0 -119
- package/dist/createJsSipFactory-B1ORbJiP.cjs +0 -22
- package/dist/createJsSipFactory-CoWZN-BC.js +0 -7410
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,o)=>(o=n==null?{}:e(i(n)),l(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e),f=c({bugs:()=>C,contributors:()=>v,default:()=>D,dependencies:()=>w,description:()=>h,devDependencies:()=>T,homepage:()=>_,keywords:()=>x,license:()=>`MIT`,main:()=>b,name:()=>p,repository:()=>S,scripts:()=>E,title:()=>m,types:()=>y,version:()=>g}),p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=o((()=>{p=`jssip`,m=`JsSIP`,h=`the Javascript SIP library`,g=`3.10.1`,_=`https://jssip.net`,v=[`José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)`,`Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)`],y=`lib/JsSIP.d.ts`,b=`lib-es5/JsSIP.js`,x=[`sip`,`websocket`,`webrtc`,`node`,`browser`,`library`],S={type:`git`,url:`https://github.com/versatica/JsSIP.git`},C={url:`https://github.com/versatica/JsSIP/issues`},w={"@types/events":`^3.0.0`,"@types/debug":`^4.1.7`,debug:`^4.3.1`,events:`^3.3.0`,"sdp-transform":`^2.14.1`},T={"@babel/core":`^7.19.6`,"@babel/preset-env":`^7.19.4`,"ansi-colors":`^3.2.4`,browserify:`^16.5.1`,eslint:`^5.16.0`,"fancy-log":`^1.3.3`,gulp:`^4.0.2`,"gulp-babel":`^8.0.0`,"gulp-eslint":`^5.0.0`,"gulp-expect-file":`^1.0.2`,"gulp-header":`^2.0.9`,"gulp-nodeunit-runner":`^0.2.2`,"gulp-plumber":`^1.2.1`,"gulp-rename":`^1.4.0`,"gulp-uglify-es":`^1.0.4`,pegjs:`^0.7.0`,"vinyl-buffer":`^1.0.1`,"vinyl-source-stream":`^2.0.0`},E={lint:`node npm-scripts.js lint`,test:`node npm-scripts.js test`,prepublish:`node npm-scripts.js prepublish`,release:`node npm-scripts.js release`},D={name:p,title:m,description:h,version:g,homepage:_,contributors:v,types:y,main:b,keywords:x,license:`MIT`,repository:S,bugs:C,dependencies:w,devDependencies:T,scripts:E}})),k=s(((e,t)=>{var n=(O(),d(f).default);t.exports={USER_AGENT:`${n.title} ${n.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}})),A=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}function a(e){var t=u();return function(){var n=p(e),r;if(t){var i=p(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return o(this,r)}}function o(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:s(e)}function s(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function c(e){var t=typeof Map==`function`?new Map:void 0;return c=function(e){if(e===null||!d(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return l(e,arguments,p(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)},c(e)}function l(e,t,n){return l=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&f(i,n.prototype),i},l.apply(null,arguments)}function u(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function d(e){return Function.toString.call(e).indexOf(`[native code]`)!==-1}function f(e,t){return f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},f(e,t)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}t.exports={ConfigurationError:function(e){i(n,e);var t=a(n);function n(e,i){var a;return r(this,n),a=t.call(this),a.code=1,a.name=`CONFIGURATION_ERROR`,a.parameter=e,a.value=i,a.message=a.value?`Invalid value ${JSON.stringify(a.value)} for parameter "${a.parameter}"`:`Missing parameter: ${a.parameter}`,a}return n}(c(Error)),InvalidStateError:function(e){i(n,e);var t=a(n);function n(e){var i;return r(this,n),i=t.call(this),i.code=2,i.name=`INVALID_STATE_ERROR`,i.status=e,i.message=`Invalid status: ${e}`,i}return n}(c(Error)),NotSupportedError:function(e){i(n,e);var t=a(n);function n(e){var i;return r(this,n),i=t.call(this),i.code=3,i.name=`NOT_SUPPORTED_ERROR`,i.message=e,i}return n}(c(Error)),NotReadyError:function(e){i(n,e);var t=a(n);function n(e){var i;return r(this,n),i=t.call(this),i.code=4,i.name=`NOT_READY_ERROR`,i.message=e,i}return n}(c(Error))}})),j=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=N(),o=M();t.exports=function(){i(e,null,[{key:`parse`,value:function(e){if(e=o.parse(e,`Name_Addr_Header`),e!==-1)return e}}]);function e(t,r,i){if(n(this,e),!t||!(t instanceof a))throw TypeError(`missing or invalid "uri" parameter`);for(var o in this._uri=t,this._parameters={},this.display_name=r,i)Object.prototype.hasOwnProperty.call(i,o)&&this.setParam(o,i[o])}return i(e,[{key:`setParam`,value:function(e,t){e&&(this._parameters[e.toLowerCase()]=t==null?null:t.toString())}},{key:`getParam`,value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:`hasParam`,value:function(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}},{key:`deleteParam`,value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:`clearParams`,value:function(){this._parameters={}}},{key:`clone`,value:function(){return new e(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:`_quote`,value:function(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}},{key:`toString`,value:function(){var e=this._display_name?`"${this._quote(this._display_name)}" `:``;for(var t in e+=`<${this._uri.toString()}>`,this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=`;${t}`,this._parameters[t]!==null&&(e+=`=${this._parameters[t]}`));return e}},{key:`uri`,get:function(){return this._uri}},{key:`display_name`,get:function(){return this._display_name},set:function(e){this._display_name=e===0?`0`:e}}]),e}()})),M=s(((e,t)=>{t.exports=function(){function e(e){return`"`+e.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 t={parse:function(t,n){var r={CRLF:l,DIGIT:u,ALPHA:d,HEXDIG:f,WSP:p,OCTET:m,DQUOTE:h,SP:g,HTAB:_,alphanum:v,reserved:y,unreserved:b,mark:x,escaped:S,LWS:C,SWS:w,HCOLON:T,TEXT_UTF8_TRIM:E,TEXT_UTF8char:D,UTF8_NONASCII:O,UTF8_CONT:k,LHEX:A,token:M,token_nodot:P,separators:F,word:I,STAR:L,SLASH:R,EQUAL:z,LPAREN:B,RPAREN:ee,RAQUOT:te,LAQUOT:ne,COMMA:V,SEMI:H,COLON:re,LDQUOT:U,RDQUOT:W,comment:ie,ctext:ae,quoted_string:oe,quoted_string_clean:G,qdtext:se,quoted_pair:K,SIP_URI_noparams:ce,SIP_URI:le,uri_scheme:ue,uri_scheme_sips:de,uri_scheme_sip:fe,userinfo:pe,user:me,user_unreserved:he,password:ge,hostport:_e,host:ve,hostname:ye,domainlabel:be,toplabel:xe,IPv6reference:Se,IPv6address:Ce,h16:q,ls32:J,IPv4address:we,dec_octet:Te,port:Ee,uri_parameters:De,uri_parameter:Oe,transport_param:ke,user_param:Ae,method_param:je,ttl_param:Me,maddr_param:Ne,lr_param:Pe,other_param:Fe,pname:Ie,pvalue:Le,paramchar:Re,param_unreserved:ze,headers:Be,header:Ve,hname:He,hvalue:Ue,hnv_unreserved:We,Request_Response:Ge,Request_Line:Ke,Request_URI:qe,absoluteURI:Je,hier_part:Ye,net_path:Xe,abs_path:Ze,opaque_part:Qe,uric:$e,uric_no_slash:et,path_segments:tt,segment:nt,param:rt,pchar:it,scheme:at,authority:ot,srvr:st,reg_name:ct,query:lt,SIP_Version:ut,INVITEm:dt,ACKm:ft,OPTIONSm:pt,BYEm:mt,CANCELm:ht,REGISTERm:gt,SUBSCRIBEm:_t,NOTIFYm:vt,REFERm:yt,Method:bt,Status_Line:xt,Status_Code:St,extension_code:Ct,Reason_Phrase:wt,Allow_Events:Tt,Call_ID:Et,Contact:Dt,contact_param:Ot,name_addr:Y,display_name:kt,contact_params:At,c_p_q:jt,c_p_expires:Mt,delta_seconds:X,qvalue:Nt,generic_param:Z,gen_value:Pt,Content_Disposition:Ft,disp_type:It,disp_param:Lt,handling_param:Rt,Content_Encoding:zt,Content_Length:Bt,Content_Type:Vt,media_type:Ht,m_type:Ut,discrete_type:Wt,composite_type:Gt,extension_token:Kt,x_token:qt,m_subtype:Jt,m_parameter:Yt,m_value:Xt,CSeq:Zt,CSeq_value:Qt,Expires:$t,Event:en,event_type:tn,From:nn,from_param:rn,tag_param:an,Max_Forwards:on,Min_Expires:sn,Name_Addr_Header:cn,Proxy_Authenticate:ln,challenge:un,other_challenge:dn,auth_param:fn,digest_cln:pn,realm:mn,realm_value:hn,domain:gn,URI:_n,nonce:vn,nonce_value:yn,opaque:bn,stale:xn,algorithm:Sn,qop_options:Cn,qop_value:wn,Proxy_Require:Tn,Record_Route:En,rec_route:Dn,Reason:On,reason_param:kn,reason_cause:An,Require:jn,Route:Mn,route_param:Nn,Subscription_State:Pn,substate_value:Fn,subexp_params:In,event_reason_value:Ln,Subject:Rn,Supported:zn,To:Bn,to_param:Vn,Via:Hn,via_param:Un,via_params:Wn,via_ttl:Gn,via_maddr:Kn,via_received:qn,via_branch:Jn,response_port:Yn,rport:Xn,sent_protocol:Zn,protocol_name:Qn,transport:$n,sent_by:er,via_host:tr,via_port:nr,ttl:rr,WWW_Authenticate:ir,Session_Expires:ar,s_e_expires:or,s_e_params:sr,s_e_refresher:cr,extension_header:lr,header_value:ur,message_body:dr,uuid_URI:fr,uuid:pr,hex4:Q,hex8:mr,hex12:hr,Refer_To:gr,Replaces:_r,call_id:vr,replaces_param:yr,to_tag:br,from_tag:xr,early_flag:Sr};if(n!==void 0){if(r[n]===void 0)throw Error(`Invalid rule name: `+e(n)+`.`)}else n=`CRLF`;var i=0,a=0,o=0,s=[];function c(e){i<o||(i>o&&(o=i,s=[]),s.push(e))}function l(){var e;return t.substr(i,2)===`\r
|
|
2
|
+
`?(e=`\r
|
|
3
|
+
`,i+=2):(e=null,a===0&&c(`"\\r\\n"`)),e}function u(){var e;return/^[0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[0-9]`)),e}function d(){var e;return/^[a-zA-Z]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[a-zA-Z]`)),e}function f(){var e;return/^[0-9a-fA-F]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[0-9a-fA-F]`)),e}function p(){var e=g();return e===null&&(e=_()),e}function m(){var e;return/^[\0-\xFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[\\0-\\xFF]`)),e}function h(){var e;return/^["]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`["]`)),e}function g(){var e;return t.charCodeAt(i)===32?(e=` `,i++):(e=null,a===0&&c(`" "`)),e}function _(){var e;return t.charCodeAt(i)===9?(e=` `,i++):(e=null,a===0&&c(`"\\t"`)),e}function v(){var e;return/^[a-zA-Z0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[a-zA-Z0-9]`)),e}function y(){var e;return t.charCodeAt(i)===59?(e=`;`,i++):(e=null,a===0&&c(`";"`)),e===null&&(t.charCodeAt(i)===47?(e=`/`,i++):(e=null,a===0&&c(`"/"`)),e===null&&(t.charCodeAt(i)===63?(e=`?`,i++):(e=null,a===0&&c(`"?"`)),e===null&&(t.charCodeAt(i)===58?(e=`:`,i++):(e=null,a===0&&c(`":"`)),e===null&&(t.charCodeAt(i)===64?(e=`@`,i++):(e=null,a===0&&c(`"@"`)),e===null&&(t.charCodeAt(i)===38?(e=`&`,i++):(e=null,a===0&&c(`"&"`)),e===null&&(t.charCodeAt(i)===61?(e=`=`,i++):(e=null,a===0&&c(`"="`)),e===null&&(t.charCodeAt(i)===43?(e=`+`,i++):(e=null,a===0&&c(`"+"`)),e===null&&(t.charCodeAt(i)===36?(e=`$`,i++):(e=null,a===0&&c(`"$"`)),e===null&&(t.charCodeAt(i)===44?(e=`,`,i++):(e=null,a===0&&c(`","`))))))))))),e}function b(){var e=v();return e===null&&(e=x()),e}function x(){var e;return t.charCodeAt(i)===45?(e=`-`,i++):(e=null,a===0&&c(`"-"`)),e===null&&(t.charCodeAt(i)===95?(e=`_`,i++):(e=null,a===0&&c(`"_"`)),e===null&&(t.charCodeAt(i)===46?(e=`.`,i++):(e=null,a===0&&c(`"."`)),e===null&&(t.charCodeAt(i)===33?(e=`!`,i++):(e=null,a===0&&c(`"!"`)),e===null&&(t.charCodeAt(i)===126?(e=`~`,i++):(e=null,a===0&&c(`"~"`)),e===null&&(t.charCodeAt(i)===42?(e=`*`,i++):(e=null,a===0&&c(`"*"`)),e===null&&(t.charCodeAt(i)===39?(e=`'`,i++):(e=null,a===0&&c(`"'"`)),e===null&&(t.charCodeAt(i)===40?(e=`(`,i++):(e=null,a===0&&c(`"("`)),e===null&&(t.charCodeAt(i)===41?(e=`)`,i++):(e=null,a===0&&c(`")"`)))))))))),e}function S(){var e,n,r,o=i,s=i;return t.charCodeAt(i)===37?(e=`%`,i++):(e=null,a===0&&c(`"%"`)),e===null?(e=null,i=s):(n=f(),n===null?(e=null,i=s):(r=f(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){return t.join(``)}(o,e)),e===null&&(i=o),e}function C(){var e,t,n,r=i,a=i,o=i;for(e=[],t=p();t!==null;)e.push(t),t=p();if(e===null?(e=null,i=o):(t=l(),t===null?(e=null,i=o):e=[e,t]),e=e===null?``:e,e!==null){if(n=p(),n!==null)for(t=[];n!==null;)t.push(n),n=p();else t=null;t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e!==null&&(e=function(e){return` `}(r)),e===null&&(i=r),e}function w(){var e=C();return e=e===null?``:e,e}function T(){var e,n,r,o=i,s=i;for(e=[],n=g(),n===null&&(n=_());n!==null;)e.push(n),n=g(),n===null&&(n=_());return e===null?(e=null,i=s):(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`:`}(o)),e===null&&(i=o),e}function E(){var e,n,r,a,o=i,s=i,c;if(n=D(),n!==null)for(e=[];n!==null;)e.push(n),n=D();else e=null;if(e!==null){for(n=[],c=i,r=[],a=C();a!==null;)r.push(a),a=C();for(r===null?(r=null,i=c):(a=D(),a===null?(r=null,i=c):r=[r,a]);r!==null;){for(n.push(r),c=i,r=[],a=C();a!==null;)r.push(a),a=C();r===null?(r=null,i=c):(a=D(),a===null?(r=null,i=c):r=[r,a])}n===null?(e=null,i=s):e=[e,n]}else e=null,i=s;return e!==null&&(e=function(e){return t.substring(i,e)}(o)),e===null&&(i=o),e}function D(){var e;return/^[!-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[!-~]`)),e===null&&(e=O()),e}function O(){var e;return/^[\x80-\uFFFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[\\x80-\\uFFFF]`)),e}function k(){var e;return/^[\x80-\xBF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[\\x80-\\xBF]`)),e}function A(){var e=u();return e===null&&(/^[a-f]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[a-f]`))),e}function M(){var e,n,r=i;if(n=v(),n===null&&(t.charCodeAt(i)===45?(n=`-`,i++):(n=null,a===0&&c(`"-"`)),n===null&&(t.charCodeAt(i)===46?(n=`.`,i++):(n=null,a===0&&c(`"."`)),n===null&&(t.charCodeAt(i)===33?(n=`!`,i++):(n=null,a===0&&c(`"!"`)),n===null&&(t.charCodeAt(i)===37?(n=`%`,i++):(n=null,a===0&&c(`"%"`)),n===null&&(t.charCodeAt(i)===42?(n=`*`,i++):(n=null,a===0&&c(`"*"`)),n===null&&(t.charCodeAt(i)===95?(n=`_`,i++):(n=null,a===0&&c(`"_"`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===96?(n="`",i++):(n=null,a===0&&c('"`"')),n===null&&(t.charCodeAt(i)===39?(n=`'`,i++):(n=null,a===0&&c(`"'"`)),n===null&&(t.charCodeAt(i)===126?(n=`~`,i++):(n=null,a===0&&c(`"~"`)))))))))))),n!==null)for(e=[];n!==null;)e.push(n),n=v(),n===null&&(t.charCodeAt(i)===45?(n=`-`,i++):(n=null,a===0&&c(`"-"`)),n===null&&(t.charCodeAt(i)===46?(n=`.`,i++):(n=null,a===0&&c(`"."`)),n===null&&(t.charCodeAt(i)===33?(n=`!`,i++):(n=null,a===0&&c(`"!"`)),n===null&&(t.charCodeAt(i)===37?(n=`%`,i++):(n=null,a===0&&c(`"%"`)),n===null&&(t.charCodeAt(i)===42?(n=`*`,i++):(n=null,a===0&&c(`"*"`)),n===null&&(t.charCodeAt(i)===95?(n=`_`,i++):(n=null,a===0&&c(`"_"`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===96?(n="`",i++):(n=null,a===0&&c('"`"')),n===null&&(t.charCodeAt(i)===39?(n=`'`,i++):(n=null,a===0&&c(`"'"`)),n===null&&(t.charCodeAt(i)===126?(n=`~`,i++):(n=null,a===0&&c(`"~"`))))))))))));else e=null;return e!==null&&(e=function(e){return t.substring(i,e)}(r)),e===null&&(i=r),e}function P(){var e,n,r=i;if(n=v(),n===null&&(t.charCodeAt(i)===45?(n=`-`,i++):(n=null,a===0&&c(`"-"`)),n===null&&(t.charCodeAt(i)===33?(n=`!`,i++):(n=null,a===0&&c(`"!"`)),n===null&&(t.charCodeAt(i)===37?(n=`%`,i++):(n=null,a===0&&c(`"%"`)),n===null&&(t.charCodeAt(i)===42?(n=`*`,i++):(n=null,a===0&&c(`"*"`)),n===null&&(t.charCodeAt(i)===95?(n=`_`,i++):(n=null,a===0&&c(`"_"`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===96?(n="`",i++):(n=null,a===0&&c('"`"')),n===null&&(t.charCodeAt(i)===39?(n=`'`,i++):(n=null,a===0&&c(`"'"`)),n===null&&(t.charCodeAt(i)===126?(n=`~`,i++):(n=null,a===0&&c(`"~"`))))))))))),n!==null)for(e=[];n!==null;)e.push(n),n=v(),n===null&&(t.charCodeAt(i)===45?(n=`-`,i++):(n=null,a===0&&c(`"-"`)),n===null&&(t.charCodeAt(i)===33?(n=`!`,i++):(n=null,a===0&&c(`"!"`)),n===null&&(t.charCodeAt(i)===37?(n=`%`,i++):(n=null,a===0&&c(`"%"`)),n===null&&(t.charCodeAt(i)===42?(n=`*`,i++):(n=null,a===0&&c(`"*"`)),n===null&&(t.charCodeAt(i)===95?(n=`_`,i++):(n=null,a===0&&c(`"_"`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===96?(n="`",i++):(n=null,a===0&&c('"`"')),n===null&&(t.charCodeAt(i)===39?(n=`'`,i++):(n=null,a===0&&c(`"'"`)),n===null&&(t.charCodeAt(i)===126?(n=`~`,i++):(n=null,a===0&&c(`"~"`)))))))))));else e=null;return e!==null&&(e=function(e){return t.substring(i,e)}(r)),e===null&&(i=r),e}function F(){var e;return t.charCodeAt(i)===40?(e=`(`,i++):(e=null,a===0&&c(`"("`)),e===null&&(t.charCodeAt(i)===41?(e=`)`,i++):(e=null,a===0&&c(`")"`)),e===null&&(t.charCodeAt(i)===60?(e=`<`,i++):(e=null,a===0&&c(`"<"`)),e===null&&(t.charCodeAt(i)===62?(e=`>`,i++):(e=null,a===0&&c(`">"`)),e===null&&(t.charCodeAt(i)===64?(e=`@`,i++):(e=null,a===0&&c(`"@"`)),e===null&&(t.charCodeAt(i)===44?(e=`,`,i++):(e=null,a===0&&c(`","`)),e===null&&(t.charCodeAt(i)===59?(e=`;`,i++):(e=null,a===0&&c(`";"`)),e===null&&(t.charCodeAt(i)===58?(e=`:`,i++):(e=null,a===0&&c(`":"`)),e===null&&(t.charCodeAt(i)===92?(e=`\\`,i++):(e=null,a===0&&c(`"\\\\"`)),e===null&&(e=h(),e===null&&(t.charCodeAt(i)===47?(e=`/`,i++):(e=null,a===0&&c(`"/"`)),e===null&&(t.charCodeAt(i)===91?(e=`[`,i++):(e=null,a===0&&c(`"["`)),e===null&&(t.charCodeAt(i)===93?(e=`]`,i++):(e=null,a===0&&c(`"]"`)),e===null&&(t.charCodeAt(i)===63?(e=`?`,i++):(e=null,a===0&&c(`"?"`)),e===null&&(t.charCodeAt(i)===61?(e=`=`,i++):(e=null,a===0&&c(`"="`)),e===null&&(t.charCodeAt(i)===123?(e=`{`,i++):(e=null,a===0&&c(`"{"`)),e===null&&(t.charCodeAt(i)===125?(e=`}`,i++):(e=null,a===0&&c(`"}"`)),e===null&&(e=g(),e===null&&(e=_())))))))))))))))))),e}function I(){var e,n,r=i;if(n=v(),n===null&&(t.charCodeAt(i)===45?(n=`-`,i++):(n=null,a===0&&c(`"-"`)),n===null&&(t.charCodeAt(i)===46?(n=`.`,i++):(n=null,a===0&&c(`"."`)),n===null&&(t.charCodeAt(i)===33?(n=`!`,i++):(n=null,a===0&&c(`"!"`)),n===null&&(t.charCodeAt(i)===37?(n=`%`,i++):(n=null,a===0&&c(`"%"`)),n===null&&(t.charCodeAt(i)===42?(n=`*`,i++):(n=null,a===0&&c(`"*"`)),n===null&&(t.charCodeAt(i)===95?(n=`_`,i++):(n=null,a===0&&c(`"_"`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===96?(n="`",i++):(n=null,a===0&&c('"`"')),n===null&&(t.charCodeAt(i)===39?(n=`'`,i++):(n=null,a===0&&c(`"'"`)),n===null&&(t.charCodeAt(i)===126?(n=`~`,i++):(n=null,a===0&&c(`"~"`)),n===null&&(t.charCodeAt(i)===40?(n=`(`,i++):(n=null,a===0&&c(`"("`)),n===null&&(t.charCodeAt(i)===41?(n=`)`,i++):(n=null,a===0&&c(`")"`)),n===null&&(t.charCodeAt(i)===60?(n=`<`,i++):(n=null,a===0&&c(`"<"`)),n===null&&(t.charCodeAt(i)===62?(n=`>`,i++):(n=null,a===0&&c(`">"`)),n===null&&(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null&&(t.charCodeAt(i)===92?(n=`\\`,i++):(n=null,a===0&&c(`"\\\\"`)),n===null&&(n=h(),n===null&&(t.charCodeAt(i)===47?(n=`/`,i++):(n=null,a===0&&c(`"/"`)),n===null&&(t.charCodeAt(i)===91?(n=`[`,i++):(n=null,a===0&&c(`"["`)),n===null&&(t.charCodeAt(i)===93?(n=`]`,i++):(n=null,a===0&&c(`"]"`)),n===null&&(t.charCodeAt(i)===63?(n=`?`,i++):(n=null,a===0&&c(`"?"`)),n===null&&(t.charCodeAt(i)===123?(n=`{`,i++):(n=null,a===0&&c(`"{"`)),n===null&&(t.charCodeAt(i)===125?(n=`}`,i++):(n=null,a===0&&c(`"}"`))))))))))))))))))))))))),n!==null)for(e=[];n!==null;)e.push(n),n=v(),n===null&&(t.charCodeAt(i)===45?(n=`-`,i++):(n=null,a===0&&c(`"-"`)),n===null&&(t.charCodeAt(i)===46?(n=`.`,i++):(n=null,a===0&&c(`"."`)),n===null&&(t.charCodeAt(i)===33?(n=`!`,i++):(n=null,a===0&&c(`"!"`)),n===null&&(t.charCodeAt(i)===37?(n=`%`,i++):(n=null,a===0&&c(`"%"`)),n===null&&(t.charCodeAt(i)===42?(n=`*`,i++):(n=null,a===0&&c(`"*"`)),n===null&&(t.charCodeAt(i)===95?(n=`_`,i++):(n=null,a===0&&c(`"_"`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===96?(n="`",i++):(n=null,a===0&&c('"`"')),n===null&&(t.charCodeAt(i)===39?(n=`'`,i++):(n=null,a===0&&c(`"'"`)),n===null&&(t.charCodeAt(i)===126?(n=`~`,i++):(n=null,a===0&&c(`"~"`)),n===null&&(t.charCodeAt(i)===40?(n=`(`,i++):(n=null,a===0&&c(`"("`)),n===null&&(t.charCodeAt(i)===41?(n=`)`,i++):(n=null,a===0&&c(`")"`)),n===null&&(t.charCodeAt(i)===60?(n=`<`,i++):(n=null,a===0&&c(`"<"`)),n===null&&(t.charCodeAt(i)===62?(n=`>`,i++):(n=null,a===0&&c(`">"`)),n===null&&(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null&&(t.charCodeAt(i)===92?(n=`\\`,i++):(n=null,a===0&&c(`"\\\\"`)),n===null&&(n=h(),n===null&&(t.charCodeAt(i)===47?(n=`/`,i++):(n=null,a===0&&c(`"/"`)),n===null&&(t.charCodeAt(i)===91?(n=`[`,i++):(n=null,a===0&&c(`"["`)),n===null&&(t.charCodeAt(i)===93?(n=`]`,i++):(n=null,a===0&&c(`"]"`)),n===null&&(t.charCodeAt(i)===63?(n=`?`,i++):(n=null,a===0&&c(`"?"`)),n===null&&(t.charCodeAt(i)===123?(n=`{`,i++):(n=null,a===0&&c(`"{"`)),n===null&&(t.charCodeAt(i)===125?(n=`}`,i++):(n=null,a===0&&c(`"}"`)))))))))))))))))))))))));else e=null;return e!==null&&(e=function(e){return t.substring(i,e)}(r)),e===null&&(i=r),e}function L(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===42?(n=`*`,i++):(n=null,a===0&&c(`"*"`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`*`}(o)),e===null&&(i=o),e}function R(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===47?(n=`/`,i++):(n=null,a===0&&c(`"/"`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`/`}(o)),e===null&&(i=o),e}function z(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`=`}(o)),e===null&&(i=o),e}function B(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===40?(n=`(`,i++):(n=null,a===0&&c(`"("`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`(`}(o)),e===null&&(i=o),e}function ee(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===41?(n=`)`,i++):(n=null,a===0&&c(`")"`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`)`}(o)),e===null&&(i=o),e}function te(){var e,n,r=i,o=i;return t.charCodeAt(i)===62?(e=`>`,i++):(e=null,a===0&&c(`">"`)),e===null?(e=null,i=o):(n=w(),n===null?(e=null,i=o):e=[e,n]),e!==null&&(e=function(e){return`>`}(r)),e===null&&(i=r),e}function ne(){var e,n,r=i,o=i;return e=w(),e===null?(e=null,i=o):(t.charCodeAt(i)===60?(n=`<`,i++):(n=null,a===0&&c(`"<"`)),n===null?(e=null,i=o):e=[e,n]),e!==null&&(e=function(e){return`<`}(r)),e===null&&(i=r),e}function V(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===44?(n=`,`,i++):(n=null,a===0&&c(`","`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`,`}(o)),e===null&&(i=o),e}function H(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===59?(n=`;`,i++):(n=null,a===0&&c(`";"`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`;`}(o)),e===null&&(i=o),e}function re(){var e,n,r,o=i,s=i;return e=w(),e===null?(e=null,i=s):(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(e=null,i=s):(r=w(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return`:`}(o)),e===null&&(i=o),e}function U(){var e,t,n=i,r=i;return e=w(),e===null?(e=null,i=r):(t=h(),t===null?(e=null,i=r):e=[e,t]),e!==null&&(e=function(e){return`"`}(n)),e===null&&(i=n),e}function W(){var e,t,n=i,r=i;return e=h(),e===null?(e=null,i=r):(t=w(),t===null?(e=null,i=r):e=[e,t]),e!==null&&(e=function(e){return`"`}(n)),e===null&&(i=n),e}function ie(){var e,t,n,r=i;if(e=B(),e!==null){for(t=[],n=ae(),n===null&&(n=K(),n===null&&(n=ie()));n!==null;)t.push(n),n=ae(),n===null&&(n=K(),n===null&&(n=ie()));t===null?(e=null,i=r):(n=ee(),n===null?(e=null,i=r):e=[e,t,n])}else e=null,i=r;return e}function ae(){var e;return/^[!-']/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[!-']`)),e===null&&(/^[*-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[*-[]`)),e===null&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[\\]-~]`)),e===null&&(e=O(),e===null&&(e=C())))),e}function oe(){var e,n,r,a,o=i,s=i;if(e=w(),e!==null){if(n=h(),n!==null){for(r=[],a=se(),a===null&&(a=K());a!==null;)r.push(a),a=se(),a===null&&(a=K());r===null?(e=null,i=s):(a=h(),a===null?(e=null,i=s):e=[e,n,r,a])}else e=null,i=s}else e=null,i=s;return e!==null&&(e=function(e){return t.substring(i,e)}(o)),e===null&&(i=o),e}function G(){var e,n,r,a,o=i,s=i;if(e=w(),e!==null){if(n=h(),n!==null){for(r=[],a=se(),a===null&&(a=K());a!==null;)r.push(a),a=se(),a===null&&(a=K());r===null?(e=null,i=s):(a=h(),a===null?(e=null,i=s):e=[e,n,r,a])}else e=null,i=s}else e=null,i=s;return e!==null&&(e=function(e){var n=t.substring(i,e).trim();return n.substring(1,n.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,`$1`)}(o)),e===null&&(i=o),e}function se(){var e=C();return e===null&&(t.charCodeAt(i)===33?(e=`!`,i++):(e=null,a===0&&c(`"!"`)),e===null&&(/^[#-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[#-[]`)),e===null&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[\\]-~]`)),e===null&&(e=O())))),e}function K(){var e,n,r=i;return t.charCodeAt(i)===92?(e=`\\`,i++):(e=null,a===0&&c(`"\\\\"`)),e===null?(e=null,i=r):(/^[\0-\t]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,a===0&&c(`[\\0-\\t]`)),n===null&&(/^[\x0B-\f]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,a===0&&c(`[\\x0B-\\f]`)),n===null&&(/^[\x0E-]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,a===0&&c(`[\\x0E-]`)))),n===null?(e=null,i=r):e=[e,n]),e}function ce(){var e,n,r,o,s=i,l=i;return e=ue(),e===null?(e=null,i=l):(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(e=null,i=l):(r=pe(),r=r===null?``:r,r===null?(e=null,i=l):(o=_e(),o===null?(e=null,i=l):e=[e,n,r,o]))),e!==null&&(e=function(e){try{$.uri=new Tr($.scheme,$.user,$.host,$.port),delete $.scheme,delete $.user,delete $.host,delete $.host_type,delete $.port}catch{$=-1}}(s)),e===null&&(i=s),e}function le(){var e,r,o,s,l,u,d=i,f=i;return e=ue(),e===null?(e=null,i=f):(t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(e=null,i=f):(o=pe(),o=o===null?``:o,o===null?(e=null,i=f):(s=_e(),s===null?(e=null,i=f):(l=De(),l===null?(e=null,i=f):(u=Be(),u=u===null?``:u,u===null?(e=null,i=f):e=[e,r,o,s,l,u]))))),e!==null&&(e=function(e){try{$.uri=new Tr($.scheme,$.user,$.host,$.port,$.uri_params,$.uri_headers),delete $.scheme,delete $.user,delete $.host,delete $.host_type,delete $.port,delete $.uri_params,n===`SIP_URI`&&($=$.uri)}catch{$=-1}}(d)),e===null&&(i=d),e}function ue(){var e=de();return e===null&&(e=fe()),e}function de(){var e,n=i;return t.substr(i,4).toLowerCase()===`sips`?(e=t.substr(i,4),i+=4):(e=null,a===0&&c(`"sips"`)),e!==null&&(e=function(e,t){$.scheme=t.toLowerCase()}(n,e)),e===null&&(i=n),e}function fe(){var e,n=i;return t.substr(i,3).toLowerCase()===`sip`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"sip"`)),e!==null&&(e=function(e,t){$.scheme=t.toLowerCase()}(n,e)),e===null&&(i=n),e}function pe(){var e,n,r,o=i,s=i,l;return e=me(),e===null?(e=null,i=s):(l=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=l):(r=ge(),r===null?(n=null,i=l):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=s):(t.charCodeAt(i)===64?(r=`@`,i++):(r=null,a===0&&c(`"@"`)),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){$.user=decodeURIComponent(t.substring(i-1,e))}(o)),e===null&&(i=o),e}function me(){var e,t=b();if(t===null&&(t=S(),t===null&&(t=he())),t!==null)for(e=[];t!==null;)e.push(t),t=b(),t===null&&(t=S(),t===null&&(t=he()));else e=null;return e}function he(){var e;return t.charCodeAt(i)===38?(e=`&`,i++):(e=null,a===0&&c(`"&"`)),e===null&&(t.charCodeAt(i)===61?(e=`=`,i++):(e=null,a===0&&c(`"="`)),e===null&&(t.charCodeAt(i)===43?(e=`+`,i++):(e=null,a===0&&c(`"+"`)),e===null&&(t.charCodeAt(i)===36?(e=`$`,i++):(e=null,a===0&&c(`"$"`)),e===null&&(t.charCodeAt(i)===44?(e=`,`,i++):(e=null,a===0&&c(`","`)),e===null&&(t.charCodeAt(i)===59?(e=`;`,i++):(e=null,a===0&&c(`";"`)),e===null&&(t.charCodeAt(i)===63?(e=`?`,i++):(e=null,a===0&&c(`"?"`)),e===null&&(t.charCodeAt(i)===47?(e=`/`,i++):(e=null,a===0&&c(`"/"`))))))))),e}function ge(){var e,n,r=i;for(e=[],n=b(),n===null&&(n=S(),n===null&&(t.charCodeAt(i)===38?(n=`&`,i++):(n=null,a===0&&c(`"&"`)),n===null&&(t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===36?(n=`$`,i++):(n=null,a===0&&c(`"$"`)),n===null&&(t.charCodeAt(i)===44?(n=`,`,i++):(n=null,a===0&&c(`","`))))))));n!==null;)e.push(n),n=b(),n===null&&(n=S(),n===null&&(t.charCodeAt(i)===38?(n=`&`,i++):(n=null,a===0&&c(`"&"`)),n===null&&(t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)),n===null&&(t.charCodeAt(i)===36?(n=`$`,i++):(n=null,a===0&&c(`"$"`)),n===null&&(t.charCodeAt(i)===44?(n=`,`,i++):(n=null,a===0&&c(`","`))))))));return e!==null&&(e=function(e){$.password=t.substring(i,e)}(r)),e===null&&(i=r),e}function _e(){var e,n,r,o=i,s;return e=ve(),e===null?(e=null,i=o):(s=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=s):(r=Ee(),r===null?(n=null,i=s):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=o):e=[e,n]),e}function ve(){var e,n=i;return e=ye(),e===null&&(e=we(),e===null&&(e=Se())),e!==null&&(e=function(e){return $.host=t.substring(i,e).toLowerCase(),$.host}(n)),e===null&&(i=n),e}function ye(){var e,n,r,o=i,s=i,l;for(e=[],l=i,n=be(),n===null?(n=null,i=l):(t.charCodeAt(i)===46?(r=`.`,i++):(r=null,a===0&&c(`"."`)),r===null?(n=null,i=l):n=[n,r]);n!==null;)e.push(n),l=i,n=be(),n===null?(n=null,i=l):(t.charCodeAt(i)===46?(r=`.`,i++):(r=null,a===0&&c(`"."`)),r===null?(n=null,i=l):n=[n,r]);return e===null?(e=null,i=s):(n=xe(),n===null?(e=null,i=s):(t.charCodeAt(i)===46?(r=`.`,i++):(r=null,a===0&&c(`"."`)),r=r===null?``:r,r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return $.host_type=`domain`,t.substring(i,e)}(o)),e===null&&(i=o),e}function be(){var e,n,r,o=i;if(e=v(),e!==null){for(n=[],r=v(),r===null&&(t.charCodeAt(i)===45?(r=`-`,i++):(r=null,a===0&&c(`"-"`)),r===null&&(t.charCodeAt(i)===95?(r=`_`,i++):(r=null,a===0&&c(`"_"`))));r!==null;)n.push(r),r=v(),r===null&&(t.charCodeAt(i)===45?(r=`-`,i++):(r=null,a===0&&c(`"-"`)),r===null&&(t.charCodeAt(i)===95?(r=`_`,i++):(r=null,a===0&&c(`"_"`))));n===null?(e=null,i=o):e=[e,n]}else e=null,i=o;return e}function xe(){var e,n,r,o=i;if(e=d(),e!==null){for(n=[],r=v(),r===null&&(t.charCodeAt(i)===45?(r=`-`,i++):(r=null,a===0&&c(`"-"`)),r===null&&(t.charCodeAt(i)===95?(r=`_`,i++):(r=null,a===0&&c(`"_"`))));r!==null;)n.push(r),r=v(),r===null&&(t.charCodeAt(i)===45?(r=`-`,i++):(r=null,a===0&&c(`"-"`)),r===null&&(t.charCodeAt(i)===95?(r=`_`,i++):(r=null,a===0&&c(`"_"`))));n===null?(e=null,i=o):e=[e,n]}else e=null,i=o;return e}function Se(){var e,n,r,o=i,s=i;return t.charCodeAt(i)===91?(e=`[`,i++):(e=null,a===0&&c(`"["`)),e===null?(e=null,i=s):(n=Ce(),n===null?(e=null,i=s):(t.charCodeAt(i)===93?(r=`]`,i++):(r=null,a===0&&c(`"]"`)),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e){return $.host_type=`IPv6`,t.substring(i,e)}(o)),e===null&&(i=o),e}function Ce(){var e,n,r,o,s,l,u,d,f,p,m,h,g,_=i,v=i,y;return e=q(),e===null?(e=null,i=v):(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(e=null,i=v):(r=q(),r===null?(e=null,i=v):(t.charCodeAt(i)===58?(o=`:`,i++):(o=null,a===0&&c(`":"`)),o===null?(e=null,i=v):(s=q(),s===null?(e=null,i=v):(t.charCodeAt(i)===58?(l=`:`,i++):(l=null,a===0&&c(`":"`)),l===null?(e=null,i=v):(u=q(),u===null?(e=null,i=v):(t.charCodeAt(i)===58?(d=`:`,i++):(d=null,a===0&&c(`":"`)),d===null?(e=null,i=v):(f=q(),f===null?(e=null,i=v):(t.charCodeAt(i)===58?(p=`:`,i++):(p=null,a===0&&c(`":"`)),p===null?(e=null,i=v):(m=q(),m===null?(e=null,i=v):(t.charCodeAt(i)===58?(h=`:`,i++):(h=null,a===0&&c(`":"`)),h===null?(e=null,i=v):(g=J(),g===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d,f,p,m,h,g])))))))))))),e===null&&(v=i,t.substr(i,2)===`::`?(e=`::`,i+=2):(e=null,a===0&&c(`"::"`)),e===null?(e=null,i=v):(n=q(),n===null?(e=null,i=v):(t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(e=null,i=v):(o=q(),o===null?(e=null,i=v):(t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(e=null,i=v):(l=q(),l===null?(e=null,i=v):(t.charCodeAt(i)===58?(u=`:`,i++):(u=null,a===0&&c(`":"`)),u===null?(e=null,i=v):(d=q(),d===null?(e=null,i=v):(t.charCodeAt(i)===58?(f=`:`,i++):(f=null,a===0&&c(`":"`)),f===null?(e=null,i=v):(p=q(),p===null?(e=null,i=v):(t.charCodeAt(i)===58?(m=`:`,i++):(m=null,a===0&&c(`":"`)),m===null?(e=null,i=v):(h=J(),h===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d,f,p,m,h]))))))))))),e===null&&(v=i,t.substr(i,2)===`::`?(e=`::`,i+=2):(e=null,a===0&&c(`"::"`)),e===null?(e=null,i=v):(n=q(),n===null?(e=null,i=v):(t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(e=null,i=v):(o=q(),o===null?(e=null,i=v):(t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(e=null,i=v):(l=q(),l===null?(e=null,i=v):(t.charCodeAt(i)===58?(u=`:`,i++):(u=null,a===0&&c(`":"`)),u===null?(e=null,i=v):(d=q(),d===null?(e=null,i=v):(t.charCodeAt(i)===58?(f=`:`,i++):(f=null,a===0&&c(`":"`)),f===null?(e=null,i=v):(p=J(),p===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d,f,p]))))))))),e===null&&(v=i,t.substr(i,2)===`::`?(e=`::`,i+=2):(e=null,a===0&&c(`"::"`)),e===null?(e=null,i=v):(n=q(),n===null?(e=null,i=v):(t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(e=null,i=v):(o=q(),o===null?(e=null,i=v):(t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(e=null,i=v):(l=q(),l===null?(e=null,i=v):(t.charCodeAt(i)===58?(u=`:`,i++):(u=null,a===0&&c(`":"`)),u===null?(e=null,i=v):(d=J(),d===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d]))))))),e===null&&(v=i,t.substr(i,2)===`::`?(e=`::`,i+=2):(e=null,a===0&&c(`"::"`)),e===null?(e=null,i=v):(n=q(),n===null?(e=null,i=v):(t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(e=null,i=v):(o=q(),o===null?(e=null,i=v):(t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(e=null,i=v):(l=J(),l===null?(e=null,i=v):e=[e,n,r,o,s,l]))))),e===null&&(v=i,t.substr(i,2)===`::`?(e=`::`,i+=2):(e=null,a===0&&c(`"::"`)),e===null?(e=null,i=v):(n=q(),n===null?(e=null,i=v):(t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(e=null,i=v):(o=J(),o===null?(e=null,i=v):e=[e,n,r,o]))),e===null&&(v=i,t.substr(i,2)===`::`?(e=`::`,i+=2):(e=null,a===0&&c(`"::"`)),e===null?(e=null,i=v):(n=J(),n===null?(e=null,i=v):e=[e,n]),e===null&&(v=i,t.substr(i,2)===`::`?(e=`::`,i+=2):(e=null,a===0&&c(`"::"`)),e===null?(e=null,i=v):(n=q(),n===null?(e=null,i=v):e=[e,n]),e===null&&(v=i,e=q(),e===null?(e=null,i=v):(t.substr(i,2)===`::`?(n=`::`,i+=2):(n=null,a===0&&c(`"::"`)),n===null?(e=null,i=v):(r=q(),r===null?(e=null,i=v):(t.charCodeAt(i)===58?(o=`:`,i++):(o=null,a===0&&c(`":"`)),o===null?(e=null,i=v):(s=q(),s===null?(e=null,i=v):(t.charCodeAt(i)===58?(l=`:`,i++):(l=null,a===0&&c(`":"`)),l===null?(e=null,i=v):(u=q(),u===null?(e=null,i=v):(t.charCodeAt(i)===58?(d=`:`,i++):(d=null,a===0&&c(`":"`)),d===null?(e=null,i=v):(f=q(),f===null?(e=null,i=v):(t.charCodeAt(i)===58?(p=`:`,i++):(p=null,a===0&&c(`":"`)),p===null?(e=null,i=v):(m=J(),m===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d,f,p,m])))))))))),e===null&&(v=i,e=q(),e===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=y):(r=q(),r===null?(n=null,i=y):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=v):(t.substr(i,2)===`::`?(r=`::`,i+=2):(r=null,a===0&&c(`"::"`)),r===null?(e=null,i=v):(o=q(),o===null?(e=null,i=v):(t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(e=null,i=v):(l=q(),l===null?(e=null,i=v):(t.charCodeAt(i)===58?(u=`:`,i++):(u=null,a===0&&c(`":"`)),u===null?(e=null,i=v):(d=q(),d===null?(e=null,i=v):(t.charCodeAt(i)===58?(f=`:`,i++):(f=null,a===0&&c(`":"`)),f===null?(e=null,i=v):(p=J(),p===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d,f,p]))))))))),e===null&&(v=i,e=q(),e===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=y):(r=q(),r===null?(n=null,i=y):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(r=null,i=y):(o=q(),o===null?(r=null,i=y):r=[r,o]),r=r===null?``:r,r===null?(e=null,i=v):(t.substr(i,2)===`::`?(o=`::`,i+=2):(o=null,a===0&&c(`"::"`)),o===null?(e=null,i=v):(s=q(),s===null?(e=null,i=v):(t.charCodeAt(i)===58?(l=`:`,i++):(l=null,a===0&&c(`":"`)),l===null?(e=null,i=v):(u=q(),u===null?(e=null,i=v):(t.charCodeAt(i)===58?(d=`:`,i++):(d=null,a===0&&c(`":"`)),d===null?(e=null,i=v):(f=J(),f===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d,f])))))))),e===null&&(v=i,e=q(),e===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=y):(r=q(),r===null?(n=null,i=y):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(r=null,i=y):(o=q(),o===null?(r=null,i=y):r=[r,o]),r=r===null?``:r,r===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(o=`:`,i++):(o=null,a===0&&c(`":"`)),o===null?(o=null,i=y):(s=q(),s===null?(o=null,i=y):o=[o,s]),o=o===null?``:o,o===null?(e=null,i=v):(t.substr(i,2)===`::`?(s=`::`,i+=2):(s=null,a===0&&c(`"::"`)),s===null?(e=null,i=v):(l=q(),l===null?(e=null,i=v):(t.charCodeAt(i)===58?(u=`:`,i++):(u=null,a===0&&c(`":"`)),u===null?(e=null,i=v):(d=J(),d===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d]))))))),e===null&&(v=i,e=q(),e===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=y):(r=q(),r===null?(n=null,i=y):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(r=null,i=y):(o=q(),o===null?(r=null,i=y):r=[r,o]),r=r===null?``:r,r===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(o=`:`,i++):(o=null,a===0&&c(`":"`)),o===null?(o=null,i=y):(s=q(),s===null?(o=null,i=y):o=[o,s]),o=o===null?``:o,o===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(s=null,i=y):(l=q(),l===null?(s=null,i=y):s=[s,l]),s=s===null?``:s,s===null?(e=null,i=v):(t.substr(i,2)===`::`?(l=`::`,i+=2):(l=null,a===0&&c(`"::"`)),l===null?(e=null,i=v):(u=J(),u===null?(e=null,i=v):e=[e,n,r,o,s,l,u])))))),e===null&&(v=i,e=q(),e===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=y):(r=q(),r===null?(n=null,i=y):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(r=null,i=y):(o=q(),o===null?(r=null,i=y):r=[r,o]),r=r===null?``:r,r===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(o=`:`,i++):(o=null,a===0&&c(`":"`)),o===null?(o=null,i=y):(s=q(),s===null?(o=null,i=y):o=[o,s]),o=o===null?``:o,o===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(s=null,i=y):(l=q(),l===null?(s=null,i=y):s=[s,l]),s=s===null?``:s,s===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(l=`:`,i++):(l=null,a===0&&c(`":"`)),l===null?(l=null,i=y):(u=q(),u===null?(l=null,i=y):l=[l,u]),l=l===null?``:l,l===null?(e=null,i=v):(t.substr(i,2)===`::`?(u=`::`,i+=2):(u=null,a===0&&c(`"::"`)),u===null?(e=null,i=v):(d=q(),d===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d]))))))),e===null&&(v=i,e=q(),e===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(n=null,i=y):(r=q(),r===null?(n=null,i=y):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(r=`:`,i++):(r=null,a===0&&c(`":"`)),r===null?(r=null,i=y):(o=q(),o===null?(r=null,i=y):r=[r,o]),r=r===null?``:r,r===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(o=`:`,i++):(o=null,a===0&&c(`":"`)),o===null?(o=null,i=y):(s=q(),s===null?(o=null,i=y):o=[o,s]),o=o===null?``:o,o===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(s=`:`,i++):(s=null,a===0&&c(`":"`)),s===null?(s=null,i=y):(l=q(),l===null?(s=null,i=y):s=[s,l]),s=s===null?``:s,s===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(l=`:`,i++):(l=null,a===0&&c(`":"`)),l===null?(l=null,i=y):(u=q(),u===null?(l=null,i=y):l=[l,u]),l=l===null?``:l,l===null?(e=null,i=v):(y=i,t.charCodeAt(i)===58?(u=`:`,i++):(u=null,a===0&&c(`":"`)),u===null?(u=null,i=y):(d=q(),d===null?(u=null,i=y):u=[u,d]),u=u===null?``:u,u===null?(e=null,i=v):(t.substr(i,2)===`::`?(d=`::`,i+=2):(d=null,a===0&&c(`"::"`)),d===null?(e=null,i=v):e=[e,n,r,o,s,l,u,d]))))))))))))))))))))),e!==null&&(e=function(e){return $.host_type=`IPv6`,t.substring(i,e)}(_)),e===null&&(i=_),e}function q(){var e,t,n,r,a=i;return e=f(),e===null?(e=null,i=a):(t=f(),t=t===null?``:t,t===null?(e=null,i=a):(n=f(),n=n===null?``:n,n===null?(e=null,i=a):(r=f(),r=r===null?``:r,r===null?(e=null,i=a):e=[e,t,n,r]))),e}function J(){var e,n,r,o=i;return e=q(),e===null?(e=null,i=o):(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(e=null,i=o):(r=q(),r===null?(e=null,i=o):e=[e,n,r])),e===null&&(e=we()),e}function we(){var e,n,r,o,s,l,u,d=i,f=i;return e=Te(),e===null?(e=null,i=f):(t.charCodeAt(i)===46?(n=`.`,i++):(n=null,a===0&&c(`"."`)),n===null?(e=null,i=f):(r=Te(),r===null?(e=null,i=f):(t.charCodeAt(i)===46?(o=`.`,i++):(o=null,a===0&&c(`"."`)),o===null?(e=null,i=f):(s=Te(),s===null?(e=null,i=f):(t.charCodeAt(i)===46?(l=`.`,i++):(l=null,a===0&&c(`"."`)),l===null?(e=null,i=f):(u=Te(),u===null?(e=null,i=f):e=[e,n,r,o,s,l,u])))))),e!==null&&(e=function(e){return $.host_type=`IPv4`,t.substring(i,e)}(d)),e===null&&(i=d),e}function Te(){var e,n,r,o=i;return t.substr(i,2)===`25`?(e=`25`,i+=2):(e=null,a===0&&c(`"25"`)),e===null?(e=null,i=o):(/^[0-5]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,a===0&&c(`[0-5]`)),n===null?(e=null,i=o):e=[e,n]),e===null&&(o=i,t.charCodeAt(i)===50?(e=`2`,i++):(e=null,a===0&&c(`"2"`)),e===null?(e=null,i=o):(/^[0-4]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,a===0&&c(`[0-4]`)),n===null?(e=null,i=o):(r=u(),r===null?(e=null,i=o):e=[e,n,r])),e===null&&(o=i,t.charCodeAt(i)===49?(e=`1`,i++):(e=null,a===0&&c(`"1"`)),e===null?(e=null,i=o):(n=u(),n===null?(e=null,i=o):(r=u(),r===null?(e=null,i=o):e=[e,n,r])),e===null&&(o=i,/^[1-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,a===0&&c(`[1-9]`)),e===null?(e=null,i=o):(n=u(),n===null?(e=null,i=o):e=[e,n]),e===null&&(e=u())))),e}function Ee(){var e,t,n,r,a,o=i,s=i;return e=u(),e=e===null?``:e,e===null?(e=null,i=s):(t=u(),t=t===null?``:t,t===null?(e=null,i=s):(n=u(),n=n===null?``:n,n===null?(e=null,i=s):(r=u(),r=r===null?``:r,r===null?(e=null,i=s):(a=u(),a=a===null?``:a,a===null?(e=null,i=s):e=[e,t,n,r,a])))),e!==null&&(e=function(e,t){return t=parseInt(t.join(``)),$.port=t,t}(o,e)),e===null&&(i=o),e}function De(){var e=[],n,r,o=i;for(t.charCodeAt(i)===59?(n=`;`,i++):(n=null,a===0&&c(`";"`)),n===null?(n=null,i=o):(r=Oe(),r===null?(n=null,i=o):n=[n,r]);n!==null;)e.push(n),o=i,t.charCodeAt(i)===59?(n=`;`,i++):(n=null,a===0&&c(`";"`)),n===null?(n=null,i=o):(r=Oe(),r===null?(n=null,i=o):n=[n,r]);return e}function Oe(){var e=ke();return e===null&&(e=Ae(),e===null&&(e=je(),e===null&&(e=Me(),e===null&&(e=Ne(),e===null&&(e=Pe(),e===null&&(e=Fe())))))),e}function ke(){var e,n,r=i,o=i;return t.substr(i,10).toLowerCase()===`transport=`?(e=t.substr(i,10),i+=10):(e=null,a===0&&c(`"transport="`)),e===null?(e=null,i=o):(t.substr(i,3).toLowerCase()===`udp`?(n=t.substr(i,3),i+=3):(n=null,a===0&&c(`"udp"`)),n===null&&(t.substr(i,3).toLowerCase()===`tcp`?(n=t.substr(i,3),i+=3):(n=null,a===0&&c(`"tcp"`)),n===null&&(t.substr(i,4).toLowerCase()===`sctp`?(n=t.substr(i,4),i+=4):(n=null,a===0&&c(`"sctp"`)),n===null&&(t.substr(i,3).toLowerCase()===`tls`?(n=t.substr(i,3),i+=3):(n=null,a===0&&c(`"tls"`)),n===null&&(n=M())))),n===null?(e=null,i=o):e=[e,n]),e!==null&&(e=function(e,t){$.uri_params||($.uri_params={}),$.uri_params.transport=t.toLowerCase()}(r,e[1])),e===null&&(i=r),e}function Ae(){var e,n,r=i,o=i;return t.substr(i,5).toLowerCase()===`user=`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"user="`)),e===null?(e=null,i=o):(t.substr(i,5).toLowerCase()===`phone`?(n=t.substr(i,5),i+=5):(n=null,a===0&&c(`"phone"`)),n===null&&(t.substr(i,2).toLowerCase()===`ip`?(n=t.substr(i,2),i+=2):(n=null,a===0&&c(`"ip"`)),n===null&&(n=M())),n===null?(e=null,i=o):e=[e,n]),e!==null&&(e=function(e,t){$.uri_params||($.uri_params={}),$.uri_params.user=t.toLowerCase()}(r,e[1])),e===null&&(i=r),e}function je(){var e,n,r=i,o=i;return t.substr(i,7).toLowerCase()===`method=`?(e=t.substr(i,7),i+=7):(e=null,a===0&&c(`"method="`)),e===null?(e=null,i=o):(n=bt(),n===null?(e=null,i=o):e=[e,n]),e!==null&&(e=function(e,t){$.uri_params||($.uri_params={}),$.uri_params.method=t}(r,e[1])),e===null&&(i=r),e}function Me(){var e,n,r=i,o=i;return t.substr(i,4).toLowerCase()===`ttl=`?(e=t.substr(i,4),i+=4):(e=null,a===0&&c(`"ttl="`)),e===null?(e=null,i=o):(n=rr(),n===null?(e=null,i=o):e=[e,n]),e!==null&&(e=function(e,t){$.params||($.params={}),$.params.ttl=t}(r,e[1])),e===null&&(i=r),e}function Ne(){var e,n,r=i,o=i;return t.substr(i,6).toLowerCase()===`maddr=`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"maddr="`)),e===null?(e=null,i=o):(n=ve(),n===null?(e=null,i=o):e=[e,n]),e!==null&&(e=function(e,t){$.uri_params||($.uri_params={}),$.uri_params.maddr=t}(r,e[1])),e===null&&(i=r),e}function Pe(){var e,n,r,o=i,s=i,l;return t.substr(i,2).toLowerCase()===`lr`?(e=t.substr(i,2),i+=2):(e=null,a===0&&c(`"lr"`)),e===null?(e=null,i=s):(l=i,t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null?(n=null,i=l):(r=M(),r===null?(n=null,i=l):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=s):e=[e,n]),e!==null&&(e=function(e){$.uri_params||($.uri_params={}),$.uri_params.lr=void 0}(o)),e===null&&(i=o),e}function Fe(){var e,n,r,o=i,s=i,l;return e=Ie(),e===null?(e=null,i=s):(l=i,t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null?(n=null,i=l):(r=Le(),r===null?(n=null,i=l):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=s):e=[e,n]),e!==null&&(e=function(e,t,n){$.uri_params||($.uri_params={}),n=n===void 0?void 0:n[1],$.uri_params[t.toLowerCase()]=n}(o,e[0],e[1])),e===null&&(i=o),e}function Ie(){var e,t,n=i;if(t=Re(),t!==null)for(e=[];t!==null;)e.push(t),t=Re();else e=null;return e!==null&&(e=function(e,t){return t.join(``)}(n,e)),e===null&&(i=n),e}function Le(){var e,t,n=i;if(t=Re(),t!==null)for(e=[];t!==null;)e.push(t),t=Re();else e=null;return e!==null&&(e=function(e,t){return t.join(``)}(n,e)),e===null&&(i=n),e}function Re(){var e=ze();return e===null&&(e=b(),e===null&&(e=S())),e}function ze(){var e;return t.charCodeAt(i)===91?(e=`[`,i++):(e=null,a===0&&c(`"["`)),e===null&&(t.charCodeAt(i)===93?(e=`]`,i++):(e=null,a===0&&c(`"]"`)),e===null&&(t.charCodeAt(i)===47?(e=`/`,i++):(e=null,a===0&&c(`"/"`)),e===null&&(t.charCodeAt(i)===58?(e=`:`,i++):(e=null,a===0&&c(`":"`)),e===null&&(t.charCodeAt(i)===38?(e=`&`,i++):(e=null,a===0&&c(`"&"`)),e===null&&(t.charCodeAt(i)===43?(e=`+`,i++):(e=null,a===0&&c(`"+"`)),e===null&&(t.charCodeAt(i)===36?(e=`$`,i++):(e=null,a===0&&c(`"$"`)))))))),e}function Be(){var e,n,r,o,s,l=i,u;if(t.charCodeAt(i)===63?(e=`?`,i++):(e=null,a===0&&c(`"?"`)),e!==null){if(n=Ve(),n!==null){for(r=[],u=i,t.charCodeAt(i)===38?(o=`&`,i++):(o=null,a===0&&c(`"&"`)),o===null?(o=null,i=u):(s=Ve(),s===null?(o=null,i=u):o=[o,s]);o!==null;)r.push(o),u=i,t.charCodeAt(i)===38?(o=`&`,i++):(o=null,a===0&&c(`"&"`)),o===null?(o=null,i=u):(s=Ve(),s===null?(o=null,i=u):o=[o,s]);r===null?(e=null,i=l):e=[e,n,r]}else e=null,i=l}else e=null,i=l;return e}function Ve(){var e,n,r,o=i,s=i;return e=He(),e===null?(e=null,i=s):(t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null?(e=null,i=s):(r=Ue(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t,n){t=t.join(``).toLowerCase(),n=n.join(``),$.uri_headers||($.uri_headers={}),$.uri_headers[t]?$.uri_headers[t].push(n):$.uri_headers[t]=[n]}(o,e[0],e[2])),e===null&&(i=o),e}function He(){var e,t=We();if(t===null&&(t=b(),t===null&&(t=S())),t!==null)for(e=[];t!==null;)e.push(t),t=We(),t===null&&(t=b(),t===null&&(t=S()));else e=null;return e}function Ue(){var e=[],t=We();for(t===null&&(t=b(),t===null&&(t=S()));t!==null;)e.push(t),t=We(),t===null&&(t=b(),t===null&&(t=S()));return e}function We(){var e;return t.charCodeAt(i)===91?(e=`[`,i++):(e=null,a===0&&c(`"["`)),e===null&&(t.charCodeAt(i)===93?(e=`]`,i++):(e=null,a===0&&c(`"]"`)),e===null&&(t.charCodeAt(i)===47?(e=`/`,i++):(e=null,a===0&&c(`"/"`)),e===null&&(t.charCodeAt(i)===63?(e=`?`,i++):(e=null,a===0&&c(`"?"`)),e===null&&(t.charCodeAt(i)===58?(e=`:`,i++):(e=null,a===0&&c(`":"`)),e===null&&(t.charCodeAt(i)===43?(e=`+`,i++):(e=null,a===0&&c(`"+"`)),e===null&&(t.charCodeAt(i)===36?(e=`$`,i++):(e=null,a===0&&c(`"$"`)))))))),e}function Ge(){var e=xt();return e===null&&(e=Ke()),e}function Ke(){var e,t,n,r,a,o=i;return e=bt(),e===null?(e=null,i=o):(t=g(),t===null?(e=null,i=o):(n=qe(),n===null?(e=null,i=o):(r=g(),r===null?(e=null,i=o):(a=ut(),a===null?(e=null,i=o):e=[e,t,n,r,a])))),e}function qe(){var e=le();return e===null&&(e=Je()),e}function Je(){var e,n,r,o=i;return e=at(),e===null?(e=null,i=o):(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null?(e=null,i=o):(r=Ye(),r===null&&(r=Qe()),r===null?(e=null,i=o):e=[e,n,r])),e}function Ye(){var e,n,r,o=i,s;return e=Xe(),e===null&&(e=Ze()),e===null?(e=null,i=o):(s=i,t.charCodeAt(i)===63?(n=`?`,i++):(n=null,a===0&&c(`"?"`)),n===null?(n=null,i=s):(r=lt(),r===null?(n=null,i=s):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=o):e=[e,n]),e}function Xe(){var e,n,r,o=i;return t.substr(i,2)===`//`?(e=`//`,i+=2):(e=null,a===0&&c(`"//"`)),e===null?(e=null,i=o):(n=ot(),n===null?(e=null,i=o):(r=Ze(),r=r===null?``:r,r===null?(e=null,i=o):e=[e,n,r])),e}function Ze(){var e,n,r=i;return t.charCodeAt(i)===47?(e=`/`,i++):(e=null,a===0&&c(`"/"`)),e===null?(e=null,i=r):(n=tt(),n===null?(e=null,i=r):e=[e,n]),e}function Qe(){var e,t,n,r=i;if(e=et(),e!==null){for(t=[],n=$e();n!==null;)t.push(n),n=$e();t===null?(e=null,i=r):e=[e,t]}else e=null,i=r;return e}function $e(){var e=y();return e===null&&(e=b(),e===null&&(e=S())),e}function et(){var e=b();return e===null&&(e=S(),e===null&&(t.charCodeAt(i)===59?(e=`;`,i++):(e=null,a===0&&c(`";"`)),e===null&&(t.charCodeAt(i)===63?(e=`?`,i++):(e=null,a===0&&c(`"?"`)),e===null&&(t.charCodeAt(i)===58?(e=`:`,i++):(e=null,a===0&&c(`":"`)),e===null&&(t.charCodeAt(i)===64?(e=`@`,i++):(e=null,a===0&&c(`"@"`)),e===null&&(t.charCodeAt(i)===38?(e=`&`,i++):(e=null,a===0&&c(`"&"`)),e===null&&(t.charCodeAt(i)===61?(e=`=`,i++):(e=null,a===0&&c(`"="`)),e===null&&(t.charCodeAt(i)===43?(e=`+`,i++):(e=null,a===0&&c(`"+"`)),e===null&&(t.charCodeAt(i)===36?(e=`$`,i++):(e=null,a===0&&c(`"$"`)),e===null&&(t.charCodeAt(i)===44?(e=`,`,i++):(e=null,a===0&&c(`","`)))))))))))),e}function tt(){var e,n,r,o,s=i,l;if(e=nt(),e!==null){for(n=[],l=i,t.charCodeAt(i)===47?(r=`/`,i++):(r=null,a===0&&c(`"/"`)),r===null?(r=null,i=l):(o=nt(),o===null?(r=null,i=l):r=[r,o]);r!==null;)n.push(r),l=i,t.charCodeAt(i)===47?(r=`/`,i++):(r=null,a===0&&c(`"/"`)),r===null?(r=null,i=l):(o=nt(),o===null?(r=null,i=l):r=[r,o]);n===null?(e=null,i=s):e=[e,n]}else e=null,i=s;return e}function nt(){var e,n,r,o,s=i,l;for(e=[],n=it();n!==null;)e.push(n),n=it();if(e!==null){for(n=[],l=i,t.charCodeAt(i)===59?(r=`;`,i++):(r=null,a===0&&c(`";"`)),r===null?(r=null,i=l):(o=rt(),o===null?(r=null,i=l):r=[r,o]);r!==null;)n.push(r),l=i,t.charCodeAt(i)===59?(r=`;`,i++):(r=null,a===0&&c(`";"`)),r===null?(r=null,i=l):(o=rt(),o===null?(r=null,i=l):r=[r,o]);n===null?(e=null,i=s):e=[e,n]}else e=null,i=s;return e}function rt(){for(var e=[],t=it();t!==null;)e.push(t),t=it();return e}function it(){var e=b();return e===null&&(e=S(),e===null&&(t.charCodeAt(i)===58?(e=`:`,i++):(e=null,a===0&&c(`":"`)),e===null&&(t.charCodeAt(i)===64?(e=`@`,i++):(e=null,a===0&&c(`"@"`)),e===null&&(t.charCodeAt(i)===38?(e=`&`,i++):(e=null,a===0&&c(`"&"`)),e===null&&(t.charCodeAt(i)===61?(e=`=`,i++):(e=null,a===0&&c(`"="`)),e===null&&(t.charCodeAt(i)===43?(e=`+`,i++):(e=null,a===0&&c(`"+"`)),e===null&&(t.charCodeAt(i)===36?(e=`$`,i++):(e=null,a===0&&c(`"$"`)),e===null&&(t.charCodeAt(i)===44?(e=`,`,i++):(e=null,a===0&&c(`","`)))))))))),e}function at(){var e,n,r,o=i,s=i;if(e=d(),e!==null){for(n=[],r=d(),r===null&&(r=u(),r===null&&(t.charCodeAt(i)===43?(r=`+`,i++):(r=null,a===0&&c(`"+"`)),r===null&&(t.charCodeAt(i)===45?(r=`-`,i++):(r=null,a===0&&c(`"-"`)),r===null&&(t.charCodeAt(i)===46?(r=`.`,i++):(r=null,a===0&&c(`"."`))))));r!==null;)n.push(r),r=d(),r===null&&(r=u(),r===null&&(t.charCodeAt(i)===43?(r=`+`,i++):(r=null,a===0&&c(`"+"`)),r===null&&(t.charCodeAt(i)===45?(r=`-`,i++):(r=null,a===0&&c(`"-"`)),r===null&&(t.charCodeAt(i)===46?(r=`.`,i++):(r=null,a===0&&c(`"."`))))));n===null?(e=null,i=s):e=[e,n]}else e=null,i=s;return e!==null&&(e=function(e){$.scheme=t.substring(i,e)}(o)),e===null&&(i=o),e}function ot(){var e=st();return e===null&&(e=ct()),e}function st(){var e,n,r=i,o=i;return e=pe(),e===null?(e=null,i=o):(t.charCodeAt(i)===64?(n=`@`,i++):(n=null,a===0&&c(`"@"`)),n===null?(e=null,i=o):e=[e,n]),e=e===null?``:e,e===null?(e=null,i=r):(n=_e(),n===null?(e=null,i=r):e=[e,n]),e=e===null?``:e,e}function ct(){var e,n=b();if(n===null&&(n=S(),n===null&&(t.charCodeAt(i)===36?(n=`$`,i++):(n=null,a===0&&c(`"$"`)),n===null&&(t.charCodeAt(i)===44?(n=`,`,i++):(n=null,a===0&&c(`","`)),n===null&&(t.charCodeAt(i)===59?(n=`;`,i++):(n=null,a===0&&c(`";"`)),n===null&&(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null&&(t.charCodeAt(i)===64?(n=`@`,i++):(n=null,a===0&&c(`"@"`)),n===null&&(t.charCodeAt(i)===38?(n=`&`,i++):(n=null,a===0&&c(`"&"`)),n===null&&(t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`))))))))))),n!==null)for(e=[];n!==null;)e.push(n),n=b(),n===null&&(n=S(),n===null&&(t.charCodeAt(i)===36?(n=`$`,i++):(n=null,a===0&&c(`"$"`)),n===null&&(t.charCodeAt(i)===44?(n=`,`,i++):(n=null,a===0&&c(`","`)),n===null&&(t.charCodeAt(i)===59?(n=`;`,i++):(n=null,a===0&&c(`";"`)),n===null&&(t.charCodeAt(i)===58?(n=`:`,i++):(n=null,a===0&&c(`":"`)),n===null&&(t.charCodeAt(i)===64?(n=`@`,i++):(n=null,a===0&&c(`"@"`)),n===null&&(t.charCodeAt(i)===38?(n=`&`,i++):(n=null,a===0&&c(`"&"`)),n===null&&(t.charCodeAt(i)===61?(n=`=`,i++):(n=null,a===0&&c(`"="`)),n===null&&(t.charCodeAt(i)===43?(n=`+`,i++):(n=null,a===0&&c(`"+"`)))))))))));else e=null;return e}function lt(){for(var e=[],t=$e();t!==null;)e.push(t),t=$e();return e}function ut(){var e,n,r,o,s,l,d=i,f=i;if(t.substr(i,3).toLowerCase()===`sip`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"SIP"`)),e!==null){if(t.charCodeAt(i)===47?(n=`/`,i++):(n=null,a===0&&c(`"/"`)),n!==null){if(o=u(),o!==null)for(r=[];o!==null;)r.push(o),o=u();else r=null;if(r!==null){if(t.charCodeAt(i)===46?(o=`.`,i++):(o=null,a===0&&c(`"."`)),o!==null){if(l=u(),l!==null)for(s=[];l!==null;)s.push(l),l=u();else s=null;s===null?(e=null,i=f):e=[e,n,r,o,s]}else e=null,i=f}else e=null,i=f}else e=null,i=f}else e=null,i=f;return e!==null&&(e=function(e){$.sip_version=t.substring(i,e)}(d)),e===null&&(i=d),e}function dt(){var e;return t.substr(i,6)===`INVITE`?(e=`INVITE`,i+=6):(e=null,a===0&&c(`"INVITE"`)),e}function ft(){var e;return t.substr(i,3)===`ACK`?(e=`ACK`,i+=3):(e=null,a===0&&c(`"ACK"`)),e}function pt(){var e;return t.substr(i,7)===`OPTIONS`?(e=`OPTIONS`,i+=7):(e=null,a===0&&c(`"OPTIONS"`)),e}function mt(){var e;return t.substr(i,3)===`BYE`?(e=`BYE`,i+=3):(e=null,a===0&&c(`"BYE"`)),e}function ht(){var e;return t.substr(i,6)===`CANCEL`?(e=`CANCEL`,i+=6):(e=null,a===0&&c(`"CANCEL"`)),e}function gt(){var e;return t.substr(i,8)===`REGISTER`?(e=`REGISTER`,i+=8):(e=null,a===0&&c(`"REGISTER"`)),e}function _t(){var e;return t.substr(i,9)===`SUBSCRIBE`?(e=`SUBSCRIBE`,i+=9):(e=null,a===0&&c(`"SUBSCRIBE"`)),e}function vt(){var e;return t.substr(i,6)===`NOTIFY`?(e=`NOTIFY`,i+=6):(e=null,a===0&&c(`"NOTIFY"`)),e}function yt(){var e;return t.substr(i,5)===`REFER`?(e=`REFER`,i+=5):(e=null,a===0&&c(`"REFER"`)),e}function bt(){var e,n=i;return e=dt(),e===null&&(e=ft(),e===null&&(e=pt(),e===null&&(e=mt(),e===null&&(e=ht(),e===null&&(e=gt(),e===null&&(e=_t(),e===null&&(e=vt(),e===null&&(e=yt(),e===null&&(e=M()))))))))),e!==null&&(e=function(e){return $.method=t.substring(i,e),$.method}(n)),e===null&&(i=n),e}function xt(){var e,t,n,r,a,o=i;return e=ut(),e===null?(e=null,i=o):(t=g(),t===null?(e=null,i=o):(n=St(),n===null?(e=null,i=o):(r=g(),r===null?(e=null,i=o):(a=wt(),a===null?(e=null,i=o):e=[e,t,n,r,a])))),e}function St(){var e,t=i;return e=Ct(),e!==null&&(e=function(e,t){$.status_code=parseInt(t.join(``))}(t,e)),e===null&&(i=t),e}function Ct(){var e,t,n,r=i;return e=u(),e===null?(e=null,i=r):(t=u(),t===null?(e=null,i=r):(n=u(),n===null?(e=null,i=r):e=[e,t,n])),e}function wt(){var e,n,r=i;for(e=[],n=y(),n===null&&(n=b(),n===null&&(n=S(),n===null&&(n=O(),n===null&&(n=k(),n===null&&(n=g(),n===null&&(n=_()))))));n!==null;)e.push(n),n=y(),n===null&&(n=b(),n===null&&(n=S(),n===null&&(n=O(),n===null&&(n=k(),n===null&&(n=g(),n===null&&(n=_()))))));return e!==null&&(e=function(e){$.reason_phrase=t.substring(i,e)}(r)),e===null&&(i=r),e}function Tt(){var e,t,n,r,a=i,o;if(e=tn(),e!==null){for(t=[],o=i,n=V(),n===null?(n=null,i=o):(r=tn(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=V(),n===null?(n=null,i=o):(r=tn(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function Et(){var e,n,r,o=i,s=i,l;return e=I(),e===null?(e=null,i=s):(l=i,t.charCodeAt(i)===64?(n=`@`,i++):(n=null,a===0&&c(`"@"`)),n===null?(n=null,i=l):(r=I(),r===null?(n=null,i=l):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=s):e=[e,n]),e!==null&&(e=function(e){$=t.substring(i,e)}(o)),e===null&&(i=o),e}function Dt(){var e,t,n,r,a=i,o,s;if(e=L(),e===null){if(o=i,e=Ot(),e!==null){for(t=[],s=i,n=V(),n===null?(n=null,i=s):(r=Ot(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=V(),n===null?(n=null,i=s):(r=Ot(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o}return e!==null&&(e=function(e){var t,n=$.multi_header.length;for(t=0;t<n;t++)if($.multi_header[t].parsed===null){$=null;break}$=$===null?-1:$.multi_header}(a)),e===null&&(i=a),e}function Ot(){var e,t,n,r,a=i,o=i,s;if(e=ce(),e===null&&(e=Y()),e!==null){for(t=[],s=i,n=H(),n===null?(n=null,i=s):(r=At(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=H(),n===null?(n=null,i=s):(r=At(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e!==null&&(e=function(e){var t;$.multi_header||($.multi_header=[]);try{t=new Er($.uri,$.display_name,$.params),delete $.uri,delete $.display_name,delete $.params}catch{t=null}$.multi_header.push({possition:i,offset:e,parsed:t})}(a)),e===null&&(i=a),e}function Y(){var e,t,n,r,a=i;return e=kt(),e=e===null?``:e,e===null?(e=null,i=a):(t=ne(),t===null?(e=null,i=a):(n=le(),n===null?(e=null,i=a):(r=te(),r===null?(e=null,i=a):e=[e,t,n,r]))),e}function kt(){var e,t,n,r,a=i,o=i,s;if(e=M(),e!==null){for(t=[],s=i,n=C(),n===null?(n=null,i=s):(r=M(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=C(),n===null?(n=null,i=s):(r=M(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e===null&&(e=G()),e!==null&&(e=function(e,t){typeof t==`string`?$.display_name=t:$.display_name=t[1].reduce(function(e,t){return e+t[0]+t[1]},t[0])}(a,e)),e===null&&(i=a),e}function At(){var e=jt();return e===null&&(e=Mt(),e===null&&(e=Z())),e}function jt(){var e,n,r,o=i,s=i;return t.substr(i,1).toLowerCase()===`q`?(e=t.substr(i,1),i++):(e=null,a===0&&c(`"q"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=Nt(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.params||($.params={}),$.params.q=t}(o,e[2])),e===null&&(i=o),e}function Mt(){var e,n,r,o=i,s=i;return t.substr(i,7).toLowerCase()===`expires`?(e=t.substr(i,7),i+=7):(e=null,a===0&&c(`"expires"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=X(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.params||($.params={}),$.params.expires=t}(o,e[2])),e===null&&(i=o),e}function X(){var e,t,n=i;if(t=u(),t!==null)for(e=[];t!==null;)e.push(t),t=u();else e=null;return e!==null&&(e=function(e,t){return parseInt(t.join(``))}(n,e)),e===null&&(i=n),e}function Nt(){var e,n,r,o,s,l=i,d=i,f;return t.charCodeAt(i)===48?(e=`0`,i++):(e=null,a===0&&c(`"0"`)),e===null?(e=null,i=d):(f=i,t.charCodeAt(i)===46?(n=`.`,i++):(n=null,a===0&&c(`"."`)),n===null?(n=null,i=f):(r=u(),r=r===null?``:r,r===null?(n=null,i=f):(o=u(),o=o===null?``:o,o===null?(n=null,i=f):(s=u(),s=s===null?``:s,s===null?(n=null,i=f):n=[n,r,o,s]))),n=n===null?``:n,n===null?(e=null,i=d):e=[e,n]),e!==null&&(e=function(e){return parseFloat(t.substring(i,e))}(l)),e===null&&(i=l),e}function Z(){var e,t,n,r=i,a=i,o;return e=M(),e===null?(e=null,i=a):(o=i,t=z(),t===null?(t=null,i=o):(n=Pt(),n===null?(t=null,i=o):t=[t,n]),t=t===null?``:t,t===null?(e=null,i=a):e=[e,t]),e!==null&&(e=function(e,t,n){$.params||($.params={}),n=n===void 0?void 0:n[1],$.params[t.toLowerCase()]=n}(r,e[0],e[1])),e===null&&(i=r),e}function Pt(){var e=M();return e===null&&(e=ve(),e===null&&(e=oe())),e}function Ft(){var e,t,n,r,a=i,o;if(e=It(),e!==null){for(t=[],o=i,n=H(),n===null?(n=null,i=o):(r=Lt(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=H(),n===null?(n=null,i=o):(r=Lt(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function It(){var e;return t.substr(i,6).toLowerCase()===`render`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"render"`)),e===null&&(t.substr(i,7).toLowerCase()===`session`?(e=t.substr(i,7),i+=7):(e=null,a===0&&c(`"session"`)),e===null&&(t.substr(i,4).toLowerCase()===`icon`?(e=t.substr(i,4),i+=4):(e=null,a===0&&c(`"icon"`)),e===null&&(t.substr(i,5).toLowerCase()===`alert`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"alert"`)),e===null&&(e=M())))),e}function Lt(){var e=Rt();return e===null&&(e=Z()),e}function Rt(){var e,n,r,o=i;return t.substr(i,8).toLowerCase()===`handling`?(e=t.substr(i,8),i+=8):(e=null,a===0&&c(`"handling"`)),e===null?(e=null,i=o):(n=z(),n===null?(e=null,i=o):(t.substr(i,8).toLowerCase()===`optional`?(r=t.substr(i,8),i+=8):(r=null,a===0&&c(`"optional"`)),r===null&&(t.substr(i,8).toLowerCase()===`required`?(r=t.substr(i,8),i+=8):(r=null,a===0&&c(`"required"`)),r===null&&(r=M())),r===null?(e=null,i=o):e=[e,n,r])),e}function zt(){var e,t,n,r,a=i,o;if(e=M(),e!==null){for(t=[],o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function Bt(){var e,t,n=i;if(t=u(),t!==null)for(e=[];t!==null;)e.push(t),t=u();else e=null;return e!==null&&(e=function(e,t){$=parseInt(t.join(``))}(n,e)),e===null&&(i=n),e}function Vt(){var e,n=i;return e=Ht(),e!==null&&(e=function(e){$=t.substring(i,e)}(n)),e===null&&(i=n),e}function Ht(){var e,t,n,r,a,o,s=i,c;if(e=Ut(),e!==null){if(t=R(),t!==null){if(n=Jt(),n!==null){for(r=[],c=i,a=H(),a===null?(a=null,i=c):(o=Yt(),o===null?(a=null,i=c):a=[a,o]);a!==null;)r.push(a),c=i,a=H(),a===null?(a=null,i=c):(o=Yt(),o===null?(a=null,i=c):a=[a,o]);r===null?(e=null,i=s):e=[e,t,n,r]}else e=null,i=s}else e=null,i=s}else e=null,i=s;return e}function Ut(){var e=Wt();return e===null&&(e=Gt()),e}function Wt(){var e;return t.substr(i,4).toLowerCase()===`text`?(e=t.substr(i,4),i+=4):(e=null,a===0&&c(`"text"`)),e===null&&(t.substr(i,5).toLowerCase()===`image`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"image"`)),e===null&&(t.substr(i,5).toLowerCase()===`audio`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"audio"`)),e===null&&(t.substr(i,5).toLowerCase()===`video`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"video"`)),e===null&&(t.substr(i,11).toLowerCase()===`application`?(e=t.substr(i,11),i+=11):(e=null,a===0&&c(`"application"`)),e===null&&(e=Kt()))))),e}function Gt(){var e;return t.substr(i,7).toLowerCase()===`message`?(e=t.substr(i,7),i+=7):(e=null,a===0&&c(`"message"`)),e===null&&(t.substr(i,9).toLowerCase()===`multipart`?(e=t.substr(i,9),i+=9):(e=null,a===0&&c(`"multipart"`)),e===null&&(e=Kt())),e}function Kt(){var e=M();return e===null&&(e=qt()),e}function qt(){var e,n,r=i;return t.substr(i,2).toLowerCase()===`x-`?(e=t.substr(i,2),i+=2):(e=null,a===0&&c(`"x-"`)),e===null?(e=null,i=r):(n=M(),n===null?(e=null,i=r):e=[e,n]),e}function Jt(){var e=Kt();return e===null&&(e=M()),e}function Yt(){var e,t,n,r=i;return e=M(),e===null?(e=null,i=r):(t=z(),t===null?(e=null,i=r):(n=Xt(),n===null?(e=null,i=r):e=[e,t,n])),e}function Xt(){var e=M();return e===null&&(e=oe()),e}function Zt(){var e,t,n,r=i;return e=Qt(),e===null?(e=null,i=r):(t=C(),t===null?(e=null,i=r):(n=bt(),n===null?(e=null,i=r):e=[e,t,n])),e}function Qt(){var e,t,n=i;if(t=u(),t!==null)for(e=[];t!==null;)e.push(t),t=u();else e=null;return e!==null&&(e=function(e,t){$.value=parseInt(t.join(``))}(n,e)),e===null&&(i=n),e}function $t(){var e,t=i;return e=X(),e!==null&&(e=function(e,t){$=t}(t,e)),e===null&&(i=t),e}function en(){var e,t,n,r,a=i,o=i,s;if(e=tn(),e!==null){for(t=[],s=i,n=H(),n===null?(n=null,i=s):(r=Z(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=H(),n===null?(n=null,i=s):(r=Z(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e!==null&&(e=function(e,t){$.event=t.join(``).toLowerCase()}(a,e[0])),e===null&&(i=a),e}function tn(){var e,n,r,o,s=i,l;if(e=P(),e!==null){for(n=[],l=i,t.charCodeAt(i)===46?(r=`.`,i++):(r=null,a===0&&c(`"."`)),r===null?(r=null,i=l):(o=P(),o===null?(r=null,i=l):r=[r,o]);r!==null;)n.push(r),l=i,t.charCodeAt(i)===46?(r=`.`,i++):(r=null,a===0&&c(`"."`)),r===null?(r=null,i=l):(o=P(),o===null?(r=null,i=l):r=[r,o]);n===null?(e=null,i=s):e=[e,n]}else e=null,i=s;return e}function nn(){var e,t,n,r,a=i,o=i,s;if(e=ce(),e===null&&(e=Y()),e!==null){for(t=[],s=i,n=H(),n===null?(n=null,i=s):(r=rn(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=H(),n===null?(n=null,i=s):(r=rn(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e!==null&&(e=function(e){var t=$.tag;try{$=new Er($.uri,$.display_name,$.params),t&&$.setParam(`tag`,t)}catch{$=-1}}(a)),e===null&&(i=a),e}function rn(){var e=an();return e===null&&(e=Z()),e}function an(){var e,n,r,o=i,s=i;return t.substr(i,3).toLowerCase()===`tag`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"tag"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=M(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.tag=t}(o,e[2])),e===null&&(i=o),e}function on(){var e,t,n=i;if(t=u(),t!==null)for(e=[];t!==null;)e.push(t),t=u();else e=null;return e!==null&&(e=function(e,t){$=parseInt(t.join(``))}(n,e)),e===null&&(i=n),e}function sn(){var e,t=i;return e=X(),e!==null&&(e=function(e,t){$=t}(t,e)),e===null&&(i=t),e}function cn(){var e,t,n,r,a,o,s,c=i,l=i,u;for(e=[],t=kt();t!==null;)e.push(t),t=kt();if(e!==null){if(t=ne(),t!==null){if(n=le(),n!==null){if(r=te(),r!==null){for(a=[],u=i,o=H(),o===null?(o=null,i=u):(s=Z(),s===null?(o=null,i=u):o=[o,s]);o!==null;)a.push(o),u=i,o=H(),o===null?(o=null,i=u):(s=Z(),s===null?(o=null,i=u):o=[o,s]);a===null?(e=null,i=l):e=[e,t,n,r,a]}else e=null,i=l}else e=null,i=l}else e=null,i=l}else e=null,i=l;return e!==null&&(e=function(e){try{$=new Er($.uri,$.display_name,$.params)}catch{$=-1}}(c)),e===null&&(i=c),e}function ln(){return un()}function un(){var e,n,r,o,s,l,u=i,d;if(t.substr(i,6).toLowerCase()===`digest`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"Digest"`)),e!==null){if(n=C(),n!==null){if(r=pn(),r!==null){for(o=[],d=i,s=V(),s===null?(s=null,i=d):(l=pn(),l===null?(s=null,i=d):s=[s,l]);s!==null;)o.push(s),d=i,s=V(),s===null?(s=null,i=d):(l=pn(),l===null?(s=null,i=d):s=[s,l]);o===null?(e=null,i=u):e=[e,n,r,o]}else e=null,i=u}else e=null,i=u}else e=null,i=u;return e===null&&(e=dn()),e}function dn(){var e,t,n,r,a,o,s=i,c;if(e=M(),e!==null){if(t=C(),t!==null){if(n=fn(),n!==null){for(r=[],c=i,a=V(),a===null?(a=null,i=c):(o=fn(),o===null?(a=null,i=c):a=[a,o]);a!==null;)r.push(a),c=i,a=V(),a===null?(a=null,i=c):(o=fn(),o===null?(a=null,i=c):a=[a,o]);r===null?(e=null,i=s):e=[e,t,n,r]}else e=null,i=s}else e=null,i=s}else e=null,i=s;return e}function fn(){var e,t,n,r=i;return e=M(),e===null?(e=null,i=r):(t=z(),t===null?(e=null,i=r):(n=M(),n===null&&(n=oe()),n===null?(e=null,i=r):e=[e,t,n])),e}function pn(){var e=mn();return e===null&&(e=gn(),e===null&&(e=vn(),e===null&&(e=bn(),e===null&&(e=xn(),e===null&&(e=Sn(),e===null&&(e=Cn(),e===null&&(e=fn()))))))),e}function mn(){var e,n,r,o=i;return t.substr(i,5).toLowerCase()===`realm`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"realm"`)),e===null?(e=null,i=o):(n=z(),n===null?(e=null,i=o):(r=hn(),r===null?(e=null,i=o):e=[e,n,r])),e}function hn(){var e,t=i;return e=G(),e!==null&&(e=function(e,t){$.realm=t}(t,e)),e===null&&(i=t),e}function gn(){var e,n,r,o,s,l,u,d=i,f;if(t.substr(i,6).toLowerCase()===`domain`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"domain"`)),e!==null){if(n=z(),n!==null){if(r=U(),r!==null){if(o=_n(),o!==null){if(s=[],f=i,u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;for(l===null?(l=null,i=f):(u=_n(),u===null?(l=null,i=f):l=[l,u]);l!==null;){if(s.push(l),f=i,u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;l===null?(l=null,i=f):(u=_n(),u===null?(l=null,i=f):l=[l,u])}s===null?(e=null,i=d):(l=W(),l===null?(e=null,i=d):e=[e,n,r,o,s,l])}else e=null,i=d}else e=null,i=d}else e=null,i=d}else e=null,i=d;return e}function _n(){var e=Je();return e===null&&(e=Ze()),e}function vn(){var e,n,r,o=i;return t.substr(i,5).toLowerCase()===`nonce`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"nonce"`)),e===null?(e=null,i=o):(n=z(),n===null?(e=null,i=o):(r=yn(),r===null?(e=null,i=o):e=[e,n,r])),e}function yn(){var e,t=i;return e=G(),e!==null&&(e=function(e,t){$.nonce=t}(t,e)),e===null&&(i=t),e}function bn(){var e,n,r,o=i,s=i;return t.substr(i,6).toLowerCase()===`opaque`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"opaque"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=G(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.opaque=t}(o,e[2])),e===null&&(i=o),e}function xn(){var e,n,r,o=i,s;return t.substr(i,5).toLowerCase()===`stale`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"stale"`)),e===null?(e=null,i=o):(n=z(),n===null?(e=null,i=o):(s=i,t.substr(i,4).toLowerCase()===`true`?(r=t.substr(i,4),i+=4):(r=null,a===0&&c(`"true"`)),r!==null&&(r=function(e){$.stale=!0}(s)),r===null&&(i=s),r===null&&(s=i,t.substr(i,5).toLowerCase()===`false`?(r=t.substr(i,5),i+=5):(r=null,a===0&&c(`"false"`)),r!==null&&(r=function(e){$.stale=!1}(s)),r===null&&(i=s)),r===null?(e=null,i=o):e=[e,n,r])),e}function Sn(){var e,n,r,o=i,s=i;return t.substr(i,9).toLowerCase()===`algorithm`?(e=t.substr(i,9),i+=9):(e=null,a===0&&c(`"algorithm"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(t.substr(i,3).toLowerCase()===`md5`?(r=t.substr(i,3),i+=3):(r=null,a===0&&c(`"MD5"`)),r===null&&(t.substr(i,8).toLowerCase()===`md5-sess`?(r=t.substr(i,8),i+=8):(r=null,a===0&&c(`"MD5-sess"`)),r===null&&(r=M())),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.algorithm=t.toUpperCase()}(o,e[2])),e===null&&(i=o),e}function Cn(){var e,n,r,o,s,l,u,d=i,f,p;if(t.substr(i,3).toLowerCase()===`qop`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"qop"`)),e!==null){if(n=z(),n!==null){if(r=U(),r!==null){if(f=i,o=wn(),o!==null){for(s=[],p=i,t.charCodeAt(i)===44?(l=`,`,i++):(l=null,a===0&&c(`","`)),l===null?(l=null,i=p):(u=wn(),u===null?(l=null,i=p):l=[l,u]);l!==null;)s.push(l),p=i,t.charCodeAt(i)===44?(l=`,`,i++):(l=null,a===0&&c(`","`)),l===null?(l=null,i=p):(u=wn(),u===null?(l=null,i=p):l=[l,u]);s===null?(o=null,i=f):o=[o,s]}else o=null,i=f;o===null?(e=null,i=d):(s=W(),s===null?(e=null,i=d):e=[e,n,r,o,s])}else e=null,i=d}else e=null,i=d}else e=null,i=d;return e}function wn(){var e,n=i;return t.substr(i,8).toLowerCase()===`auth-int`?(e=t.substr(i,8),i+=8):(e=null,a===0&&c(`"auth-int"`)),e===null&&(t.substr(i,4).toLowerCase()===`auth`?(e=t.substr(i,4),i+=4):(e=null,a===0&&c(`"auth"`)),e===null&&(e=M())),e!==null&&(e=function(e,t){$.qop||($.qop=[]),$.qop.push(t.toLowerCase())}(n,e)),e===null&&(i=n),e}function Tn(){var e,t,n,r,a=i,o;if(e=M(),e!==null){for(t=[],o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function En(){var e,t,n,r,a=i,o=i,s;if(e=Dn(),e!==null){for(t=[],s=i,n=V(),n===null?(n=null,i=s):(r=Dn(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=V(),n===null?(n=null,i=s):(r=Dn(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e!==null&&(e=function(e){var t,n=$.multi_header.length;for(t=0;t<n;t++)if($.multi_header[t].parsed===null){$=null;break}$=$===null?-1:$.multi_header}(a)),e===null&&(i=a),e}function Dn(){var e,t,n,r,a=i,o=i,s;if(e=Y(),e!==null){for(t=[],s=i,n=H(),n===null?(n=null,i=s):(r=Z(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=H(),n===null?(n=null,i=s):(r=Z(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e!==null&&(e=function(e){var t;$.multi_header||($.multi_header=[]);try{t=new Er($.uri,$.display_name,$.params),delete $.uri,delete $.display_name,delete $.params}catch{t=null}$.multi_header.push({possition:i,offset:e,parsed:t})}(a)),e===null&&(i=a),e}function On(){var e,n,r,o,s=i,l=i,u;if(t.substr(i,3).toLowerCase()===`sip`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"SIP"`)),e===null&&(e=M()),e!==null){for(n=[],u=i,r=H(),r===null?(r=null,i=u):(o=kn(),o===null?(r=null,i=u):r=[r,o]);r!==null;)n.push(r),u=i,r=H(),r===null?(r=null,i=u):(o=kn(),o===null?(r=null,i=u):r=[r,o]);n===null?(e=null,i=l):e=[e,n]}else e=null,i=l;return e!==null&&(e=function(e,t){if($.protocol=t.toLowerCase(),$.params||($.params={}),$.params.text&&$.params.text[0]===`"`){var n=$.params.text;$.text=n.substring(1,n.length-1),delete $.params.text}}(s,e[0])),e===null&&(i=s),e}function kn(){var e=An();return e===null&&(e=Z()),e}function An(){var e,n,r,o,s=i,l=i;if(t.substr(i,5).toLowerCase()===`cause`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"cause"`)),e!==null){if(n=z(),n!==null){if(o=u(),o!==null)for(r=[];o!==null;)r.push(o),o=u();else r=null;r===null?(e=null,i=l):e=[e,n,r]}else e=null,i=l}else e=null,i=l;return e!==null&&(e=function(e,t){$.cause=parseInt(t.join(``))}(s,e[2])),e===null&&(i=s),e}function jn(){var e,t,n,r,a=i,o;if(e=M(),e!==null){for(t=[],o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function Mn(){var e,t,n,r,a=i,o;if(e=Nn(),e!==null){for(t=[],o=i,n=V(),n===null?(n=null,i=o):(r=Nn(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=V(),n===null?(n=null,i=o):(r=Nn(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function Nn(){var e,t,n,r,a=i,o;if(e=Y(),e!==null){for(t=[],o=i,n=H(),n===null?(n=null,i=o):(r=Z(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=H(),n===null?(n=null,i=o):(r=Z(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function Pn(){var e,t,n,r,a=i,o;if(e=Fn(),e!==null){for(t=[],o=i,n=H(),n===null?(n=null,i=o):(r=In(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=H(),n===null?(n=null,i=o):(r=In(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function Fn(){var e,n=i;return t.substr(i,6).toLowerCase()===`active`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"active"`)),e===null&&(t.substr(i,7).toLowerCase()===`pending`?(e=t.substr(i,7),i+=7):(e=null,a===0&&c(`"pending"`)),e===null&&(t.substr(i,10).toLowerCase()===`terminated`?(e=t.substr(i,10),i+=10):(e=null,a===0&&c(`"terminated"`)),e===null&&(e=M()))),e!==null&&(e=function(e){$.state=t.substring(i,e)}(n)),e===null&&(i=n),e}function In(){var e,n,r,o=i,s=i;return t.substr(i,6).toLowerCase()===`reason`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"reason"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=Ln(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){t!==void 0&&($.reason=t)}(o,e[2])),e===null&&(i=o),e===null&&(o=i,s=i,t.substr(i,7).toLowerCase()===`expires`?(e=t.substr(i,7),i+=7):(e=null,a===0&&c(`"expires"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=X(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){t!==void 0&&($.expires=t)}(o,e[2])),e===null&&(i=o),e===null&&(o=i,s=i,t.substr(i,11).toLowerCase()===`retry_after`?(e=t.substr(i,11),i+=11):(e=null,a===0&&c(`"retry_after"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=X(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){t!==void 0&&($.retry_after=t)}(o,e[2])),e===null&&(i=o),e===null&&(e=Z()))),e}function Ln(){var e;return t.substr(i,11).toLowerCase()===`deactivated`?(e=t.substr(i,11),i+=11):(e=null,a===0&&c(`"deactivated"`)),e===null&&(t.substr(i,9).toLowerCase()===`probation`?(e=t.substr(i,9),i+=9):(e=null,a===0&&c(`"probation"`)),e===null&&(t.substr(i,8).toLowerCase()===`rejected`?(e=t.substr(i,8),i+=8):(e=null,a===0&&c(`"rejected"`)),e===null&&(t.substr(i,7).toLowerCase()===`timeout`?(e=t.substr(i,7),i+=7):(e=null,a===0&&c(`"timeout"`)),e===null&&(t.substr(i,6).toLowerCase()===`giveup`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"giveup"`)),e===null&&(t.substr(i,10).toLowerCase()===`noresource`?(e=t.substr(i,10),i+=10):(e=null,a===0&&c(`"noresource"`)),e===null&&(t.substr(i,9).toLowerCase()===`invariant`?(e=t.substr(i,9),i+=9):(e=null,a===0&&c(`"invariant"`)),e===null&&(e=M()))))))),e}function Rn(){var e=E();return e=e===null?``:e,e}function zn(){var e,t,n,r,a=i,o;if(e=M(),e!==null){for(t=[],o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=V(),n===null?(n=null,i=o):(r=M(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e=e===null?``:e,e}function Bn(){var e,t,n,r,a=i,o=i,s;if(e=ce(),e===null&&(e=Y()),e!==null){for(t=[],s=i,n=H(),n===null?(n=null,i=s):(r=Vn(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=H(),n===null?(n=null,i=s):(r=Vn(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e!==null&&(e=function(e){var t=$.tag;try{$=new Er($.uri,$.display_name,$.params),t&&$.setParam(`tag`,t)}catch{$=-1}}(a)),e===null&&(i=a),e}function Vn(){var e=an();return e===null&&(e=Z()),e}function Hn(){var e,t,n,r,a=i,o;if(e=Un(),e!==null){for(t=[],o=i,n=V(),n===null?(n=null,i=o):(r=Un(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=V(),n===null?(n=null,i=o):(r=Un(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function Un(){var e,t,n,r,a,o,s=i,c;if(e=Zn(),e!==null){if(t=C(),t!==null){if(n=er(),n!==null){for(r=[],c=i,a=H(),a===null?(a=null,i=c):(o=Wn(),o===null?(a=null,i=c):a=[a,o]);a!==null;)r.push(a),c=i,a=H(),a===null?(a=null,i=c):(o=Wn(),o===null?(a=null,i=c):a=[a,o]);r===null?(e=null,i=s):e=[e,t,n,r]}else e=null,i=s}else e=null,i=s}else e=null,i=s;return e}function Wn(){var e=Gn();return e===null&&(e=Kn(),e===null&&(e=qn(),e===null&&(e=Jn(),e===null&&(e=Yn(),e===null&&(e=Z()))))),e}function Gn(){var e,n,r,o=i,s=i;return t.substr(i,3).toLowerCase()===`ttl`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"ttl"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=rr(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.ttl=t}(o,e[2])),e===null&&(i=o),e}function Kn(){var e,n,r,o=i,s=i;return t.substr(i,5).toLowerCase()===`maddr`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"maddr"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=ve(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.maddr=t}(o,e[2])),e===null&&(i=o),e}function qn(){var e,n,r,o=i,s=i;return t.substr(i,8).toLowerCase()===`received`?(e=t.substr(i,8),i+=8):(e=null,a===0&&c(`"received"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=we(),r===null&&(r=Ce()),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.received=t}(o,e[2])),e===null&&(i=o),e}function Jn(){var e,n,r,o=i,s=i;return t.substr(i,6).toLowerCase()===`branch`?(e=t.substr(i,6),i+=6):(e=null,a===0&&c(`"branch"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=M(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.branch=t}(o,e[2])),e===null&&(i=o),e}function Yn(){var e,n,r,o=i,s;return t.substr(i,5).toLowerCase()===`rport`?(e=t.substr(i,5),i+=5):(e=null,a===0&&c(`"rport"`)),e===null?(e=null,i=o):(s=i,n=z(),n===null?(n=null,i=s):(r=Xn(),r===null?(n=null,i=s):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=o):e=[e,n]),e}function Xn(){var e,t,n,r,a,o=i,s=i;return e=u(),e=e===null?``:e,e===null?(e=null,i=s):(t=u(),t=t===null?``:t,t===null?(e=null,i=s):(n=u(),n=n===null?``:n,n===null?(e=null,i=s):(r=u(),r=r===null?``:r,r===null?(e=null,i=s):(a=u(),a=a===null?``:a,a===null?(e=null,i=s):e=[e,t,n,r,a])))),e!==null&&(e=function(e,t){$.rport=parseInt(t.join(``))}(o,e)),e===null&&(i=o),e}function Zn(){var e,t,n,r,a,o=i;return e=Qn(),e===null?(e=null,i=o):(t=R(),t===null?(e=null,i=o):(n=M(),n===null?(e=null,i=o):(r=R(),r===null?(e=null,i=o):(a=$n(),a===null?(e=null,i=o):e=[e,t,n,r,a])))),e}function Qn(){var e,n=i;return t.substr(i,3).toLowerCase()===`sip`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"SIP"`)),e===null&&(e=M()),e!==null&&(e=function(e,t){$.protocol=t}(n,e)),e===null&&(i=n),e}function $n(){var e,n=i;return t.substr(i,3).toLowerCase()===`udp`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"UDP"`)),e===null&&(t.substr(i,3).toLowerCase()===`tcp`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"TCP"`)),e===null&&(t.substr(i,3).toLowerCase()===`tls`?(e=t.substr(i,3),i+=3):(e=null,a===0&&c(`"TLS"`)),e===null&&(t.substr(i,4).toLowerCase()===`sctp`?(e=t.substr(i,4),i+=4):(e=null,a===0&&c(`"SCTP"`)),e===null&&(e=M())))),e!==null&&(e=function(e,t){$.transport=t}(n,e)),e===null&&(i=n),e}function er(){var e,t,n,r=i,a;return e=tr(),e===null?(e=null,i=r):(a=i,t=re(),t===null?(t=null,i=a):(n=nr(),n===null?(t=null,i=a):t=[t,n]),t=t===null?``:t,t===null?(e=null,i=r):e=[e,t]),e}function tr(){var e,n=i;return e=we(),e===null&&(e=Se(),e===null&&(e=ye())),e!==null&&(e=function(e){$.host=t.substring(i,e)}(n)),e===null&&(i=n),e}function nr(){var e,t,n,r,a,o=i,s=i;return e=u(),e=e===null?``:e,e===null?(e=null,i=s):(t=u(),t=t===null?``:t,t===null?(e=null,i=s):(n=u(),n=n===null?``:n,n===null?(e=null,i=s):(r=u(),r=r===null?``:r,r===null?(e=null,i=s):(a=u(),a=a===null?``:a,a===null?(e=null,i=s):e=[e,t,n,r,a])))),e!==null&&(e=function(e,t){$.port=parseInt(t.join(``))}(o,e)),e===null&&(i=o),e}function rr(){var e,t,n,r=i,a=i;return e=u(),e===null?(e=null,i=a):(t=u(),t=t===null?``:t,t===null?(e=null,i=a):(n=u(),n=n===null?``:n,n===null?(e=null,i=a):e=[e,t,n])),e!==null&&(e=function(e,t){return parseInt(t.join(``))}(r,e)),e===null&&(i=r),e}function ir(){return un()}function ar(){var e,t,n,r,a=i,o;if(e=or(),e!==null){for(t=[],o=i,n=H(),n===null?(n=null,i=o):(r=sr(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=H(),n===null?(n=null,i=o):(r=sr(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function or(){var e,t=i;return e=X(),e!==null&&(e=function(e,t){$.expires=t}(t,e)),e===null&&(i=t),e}function sr(){var e=cr();return e===null&&(e=Z()),e}function cr(){var e,n,r,o=i,s=i;return t.substr(i,9).toLowerCase()===`refresher`?(e=t.substr(i,9),i+=9):(e=null,a===0&&c(`"refresher"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(t.substr(i,3).toLowerCase()===`uac`?(r=t.substr(i,3),i+=3):(r=null,a===0&&c(`"uac"`)),r===null&&(t.substr(i,3).toLowerCase()===`uas`?(r=t.substr(i,3),i+=3):(r=null,a===0&&c(`"uas"`))),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.refresher=t.toLowerCase()}(o,e[2])),e===null&&(i=o),e}function lr(){var e,t,n,r=i;return e=M(),e===null?(e=null,i=r):(t=T(),t===null?(e=null,i=r):(n=ur(),n===null?(e=null,i=r):e=[e,t,n])),e}function ur(){var e=[],t=D();for(t===null&&(t=k(),t===null&&(t=C()));t!==null;)e.push(t),t=D(),t===null&&(t=k(),t===null&&(t=C()));return e}function dr(){for(var e=[],t=m();t!==null;)e.push(t),t=m();return e}function fr(){var e,n,r=i;return t.substr(i,5)===`uuid:`?(e=`uuid:`,i+=5):(e=null,a===0&&c(`"uuid:"`)),e===null?(e=null,i=r):(n=pr(),n===null?(e=null,i=r):e=[e,n]),e}function pr(){var e,n,r,o,s,l,u,d,f,p=i,m=i;return e=mr(),e===null?(e=null,i=m):(t.charCodeAt(i)===45?(n=`-`,i++):(n=null,a===0&&c(`"-"`)),n===null?(e=null,i=m):(r=Q(),r===null?(e=null,i=m):(t.charCodeAt(i)===45?(o=`-`,i++):(o=null,a===0&&c(`"-"`)),o===null?(e=null,i=m):(s=Q(),s===null?(e=null,i=m):(t.charCodeAt(i)===45?(l=`-`,i++):(l=null,a===0&&c(`"-"`)),l===null?(e=null,i=m):(u=Q(),u===null?(e=null,i=m):(t.charCodeAt(i)===45?(d=`-`,i++):(d=null,a===0&&c(`"-"`)),d===null?(e=null,i=m):(f=hr(),f===null?(e=null,i=m):e=[e,n,r,o,s,l,u,d,f])))))))),e!==null&&(e=function(e,n){$=t.substring(i+5,e)}(p,e[0])),e===null&&(i=p),e}function Q(){var e,t,n,r,a=i;return e=f(),e===null?(e=null,i=a):(t=f(),t===null?(e=null,i=a):(n=f(),n===null?(e=null,i=a):(r=f(),r===null?(e=null,i=a):e=[e,t,n,r]))),e}function mr(){var e,t,n=i;return e=Q(),e===null?(e=null,i=n):(t=Q(),t===null?(e=null,i=n):e=[e,t]),e}function hr(){var e,t,n,r=i;return e=Q(),e===null?(e=null,i=r):(t=Q(),t===null?(e=null,i=r):(n=Q(),n===null?(e=null,i=r):e=[e,t,n])),e}function gr(){var e,t,n,r,a=i,o=i,s;if(e=ce(),e===null&&(e=Y()),e!==null){for(t=[],s=i,n=H(),n===null?(n=null,i=s):(r=Z(),r===null?(n=null,i=s):n=[n,r]);n!==null;)t.push(n),s=i,n=H(),n===null?(n=null,i=s):(r=Z(),r===null?(n=null,i=s):n=[n,r]);t===null?(e=null,i=o):e=[e,t]}else e=null,i=o;return e!==null&&(e=function(e){try{$=new Er($.uri,$.display_name,$.params)}catch{$=-1}}(a)),e===null&&(i=a),e}function _r(){var e,t,n,r,a=i,o;if(e=vr(),e!==null){for(t=[],o=i,n=H(),n===null?(n=null,i=o):(r=yr(),r===null?(n=null,i=o):n=[n,r]);n!==null;)t.push(n),o=i,n=H(),n===null?(n=null,i=o):(r=yr(),r===null?(n=null,i=o):n=[n,r]);t===null?(e=null,i=a):e=[e,t]}else e=null,i=a;return e}function vr(){var e,n,r,o=i,s=i,l;return e=I(),e===null?(e=null,i=s):(l=i,t.charCodeAt(i)===64?(n=`@`,i++):(n=null,a===0&&c(`"@"`)),n===null?(n=null,i=l):(r=I(),r===null?(n=null,i=l):n=[n,r]),n=n===null?``:n,n===null?(e=null,i=s):e=[e,n]),e!==null&&(e=function(e){$.call_id=t.substring(i,e)}(o)),e===null&&(i=o),e}function yr(){var e=br();return e===null&&(e=xr(),e===null&&(e=Sr(),e===null&&(e=Z()))),e}function br(){var e,n,r,o=i,s=i;return t.substr(i,6)===`to-tag`?(e=`to-tag`,i+=6):(e=null,a===0&&c(`"to-tag"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=M(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.to_tag=t}(o,e[2])),e===null&&(i=o),e}function xr(){var e,n,r,o=i,s=i;return t.substr(i,8)===`from-tag`?(e=`from-tag`,i+=8):(e=null,a===0&&c(`"from-tag"`)),e===null?(e=null,i=s):(n=z(),n===null?(e=null,i=s):(r=M(),r===null?(e=null,i=s):e=[e,n,r])),e!==null&&(e=function(e,t){$.from_tag=t}(o,e[2])),e===null&&(i=o),e}function Sr(){var e,n=i;return t.substr(i,10)===`early-only`?(e=`early-only`,i+=10):(e=null,a===0&&c(`"early-only"`)),e!==null&&(e=function(e){$.early_only=!0}(n)),e===null&&(i=n),e}function Cr(e){e.sort();for(var t=null,n=[],r=0;r<e.length;r++)e[r]!==t&&(n.push(e[r]),t=e[r]);return n}function wr(){for(var e=1,n=1,r=!1,a=0;a<Math.max(i,o);a++){var s=t.charAt(a);s===`
|
|
4
|
+
`?(r||e++,n=1,r=!1):s===`\r`||s===`\u2028`||s===`\u2029`?(e++,n=1,r=!0):(n++,r=!1)}return{line:e,column:n}}var Tr=N(),Er=j(),$={};if(r[n]()===null||i!==t.length){var Dr=Math.max(i,o),Or=Dr<t.length?t.charAt(Dr):null,kr=wr();return new this.SyntaxError(Cr(s),Or,Dr,kr.line,kr.column),-1}return $},toSource:function(){return this._source}};return t.SyntaxError=function(t,n,r,i,a){function o(t,n){var r,i;switch(t.length){case 0:r=`end of input`;break;case 1:r=t[0];break;default:r=t.slice(0,t.length-1).join(`, `)+` or `+t[t.length-1]}return i=n?e(n):`end of input`,`Expected `+r+` but `+i+` found.`}this.name=`SyntaxError`,this.expected=t,this.found=n,this.message=o(t,n),this.offset=r,this.line=i,this.column=a},t.SyntaxError.prototype=Error.prototype,t}()})),N=s(((e,t)=>{function n(e,t){var n;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(n=r(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&n.return!=null&&n.return()}finally{if(s)throw c}}}}function r(e,t){if(e){if(typeof e==`string`)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}}function i(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var c=k(),l=P(),u=M();t.exports=function(){s(e,null,[{key:`parse`,value:function(e){if(e=u.parse(e,`SIP_URI`),e!==-1)return e}}]);function e(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(a(this,e),!r)throw TypeError(`missing or invalid "host" parameter`);for(var l in this._parameters={},this._headers={},this._scheme=t||c.SIP,this._user=n,this._host=r,this._port=i,o)Object.prototype.hasOwnProperty.call(o,l)&&this.setParam(l,o[l]);for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&this.setHeader(u,s[u])}return s(e,[{key:`setParam`,value:function(e,t){e&&(this._parameters[e.toLowerCase()]=t==null?null:t.toString())}},{key:`getParam`,value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:`hasParam`,value:function(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}},{key:`deleteParam`,value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:`clearParams`,value:function(){this._parameters={}}},{key:`setHeader`,value:function(e,t){this._headers[l.headerize(e)]=Array.isArray(t)?t:[t]}},{key:`getHeader`,value:function(e){if(e)return this._headers[l.headerize(e)]}},{key:`hasHeader`,value:function(e){if(e)return this._headers.hasOwnProperty(l.headerize(e))&&!0||!1}},{key:`deleteHeader`,value:function(e){if(e=l.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:`clearHeaders`,value:function(){this._headers={}}},{key:`clone`,value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:`toString`,value:function(){var e=[],t=`${this._scheme}:`;for(var r in this._user&&(t+=`${l.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,r)&&(t+=`;${r}`,this._parameters[r]!==null&&(t+=`=${this._parameters[r]}`));for(var i in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,i)){var a=n(this._headers[i]),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;e.push(`${i}=${s}`)}}catch(e){a.e(e)}finally{a.f()}}return e.length>0&&(t+=`?${e.join(`&`)}`),t}},{key:`toAor`,value:function(e){var t=`${this._scheme}:`;return this._user&&(t+=`${l.escapeUser(this._user)}@`),t+=this._host,e&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},{key:`scheme`,get:function(){return this._scheme},set:function(e){this._scheme=e.toLowerCase()}},{key:`user`,get:function(){return this._user},set:function(e){this._user=e}},{key:`host`,get:function(){return this._host},set:function(e){this._host=e.toLowerCase()}},{key:`port`,get:function(){return this._port},set:function(e){this._port=e===0?e:parseInt(e,10)||null}}]),e}()})),P=s((e=>{function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,t){var n;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(n=r(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
6
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&n.return!=null&&n.return()}finally{if(s)throw c}}}}function r(e,t){if(e){if(typeof e==`string`)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}}function i(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var a=k(),o=N(),s=M();e.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length};var c=e.isFunction=function(e){return e!==void 0&&Object.prototype.toString.call(e)===`[object Function]`};e.isString=function(e){return e!==void 0&&Object.prototype.toString.call(e)===`[object String]`},e.isDecimal=function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},e.isEmpty=function(e){return e===null||e===``||e===void 0||Array.isArray(e)&&e.length===0||typeof e==`number`&&isNaN(e)},e.hasMethods=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];for(var i=0,a=n;i<a.length;i++){var o=a[i];if(c(e[o]))return!1}return!0};var l=e.createRandomToken=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,n,r,i=``;for(n=0;n<e;n++)r=Math.random()*t|0,i+=r.toString(t);return i};e.newTag=function(){return l(10)},e.newUUID=function(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){var t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})},e.hostType=function(e){if(e&&(e=s.parse(e,`host`),e!==-1))return e.host_type};var u=e.escapeUser=function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,`:`).replace(/%2B/gi,`+`).replace(/%3F/gi,`?`).replace(/%2F/gi,`/`)};e.normalizeTarget=function(e,t){if(e){if(e instanceof o)return e;if(typeof e==`string`){var n=e.split(`@`),r,i;switch(n.length){case 1:if(!t)return;r=e,i=t;break;case 2:r=n[0],i=n[1];break;default:r=n.slice(0,n.length-1).join(`@`),i=n[n.length-1]}r=r.replace(/^(sips?|tel):/i,``),/^[-.()]*\+?[0-9\-.()]+$/.test(r)&&(r=r.replace(/[-.()]/g,``)),e=`${a.SIP}:${u(r)}@${i}`;var s;return(s=o.parse(e))?s:void 0}}},e.headerize=function(e){for(var t={"Call-Id":`Call-ID`,Cseq:`CSeq`,"Www-Authenticate":`WWW-Authenticate`},n=e.toLowerCase().replace(/_/g,`-`).split(`-`),r=``,i=n.length,a=0;a<i;a++)a!==0&&(r+=`-`),r+=n[a].charAt(0).toUpperCase()+n[a].substring(1);return t[r]&&(r=t[r]),r},e.sipErrorCause=function(e){for(var t in a.SIP_ERROR_CAUSES)if(a.SIP_ERROR_CAUSES[t].indexOf(e)!==-1)return a.causes[t];return a.causes.SIP_FAILURE_CODE},e.getRandomTestNetIP=function(){function e(e,t){return Math.floor(Math.random()*(t-e+1)+e)}return`192.0.2.${e(1,254)}`},e.calculateMD5=function(e){function t(e,t){return e<<t|e>>>32-t}function n(e,t){var n=e&2147483648,r=t&2147483648,i=e&1073741824,a=t&1073741824,o=(e&1073741823)+(t&1073741823);return i&a?o^2147483648^n^r:i|a?o&1073741824?o^3221225472^n^r:o^1073741824^n^r:o^n^r}function r(e,t,n){return e&t|~e&n}function i(e,t,n){return e&n|t&~n}function a(e,t,n){return e^t^n}function o(e,t,n){return t^(e|~n)}function s(e,i,a,o,s,c,l){return e=n(e,n(n(r(i,a,o),s),l)),n(t(e,c),i)}function c(e,r,a,o,s,c,l){return e=n(e,n(n(i(r,a,o),s),l)),n(t(e,c),r)}function l(e,r,i,o,s,c,l){return e=n(e,n(n(a(r,i,o),s),l)),n(t(e,c),r)}function u(e,r,i,a,s,c,l){return e=n(e,n(n(o(r,i,a),s),l)),n(t(e,c),r)}function d(e){for(var t,n=e.length,r=n+8,i=((r-r%64)/64+1)*16,a=Array(i-1),o=0,s=0;s<n;)t=(s-s%4)/4,o=s%4*8,a[t]=a[t]|e.charCodeAt(s)<<o,s++;return t=(s-s%4)/4,o=s%4*8,a[t]=a[t]|128<<o,a[i-2]=n<<3,a[i-1]=n>>>29,a}function f(e){for(var t=``,n=``,r,i=0;i<=3;i++)r=e>>>i*8&255,n=`0${r.toString(16)}`,t+=n.substr(n.length-2,2);return t}function p(e){for(var t=``,n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(r&63|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(r&63|128))}return t}var m=[],h,g,_,v,y,b,x,S,C,w=7,T=12,E=17,D=22,O=5,k=9,A=14,j=20,M=4,N=11,P=16,F=23,I=6,L=10,R=15,z=21;for(e=p(e),m=d(e),b=1732584193,x=4023233417,S=2562383102,C=271733878,h=0;h<m.length;h+=16)g=b,_=x,v=S,y=C,b=s(b,x,S,C,m[h+0],w,3614090360),C=s(C,b,x,S,m[h+1],T,3905402710),S=s(S,C,b,x,m[h+2],E,606105819),x=s(x,S,C,b,m[h+3],D,3250441966),b=s(b,x,S,C,m[h+4],w,4118548399),C=s(C,b,x,S,m[h+5],T,1200080426),S=s(S,C,b,x,m[h+6],E,2821735955),x=s(x,S,C,b,m[h+7],D,4249261313),b=s(b,x,S,C,m[h+8],w,1770035416),C=s(C,b,x,S,m[h+9],T,2336552879),S=s(S,C,b,x,m[h+10],E,4294925233),x=s(x,S,C,b,m[h+11],D,2304563134),b=s(b,x,S,C,m[h+12],w,1804603682),C=s(C,b,x,S,m[h+13],T,4254626195),S=s(S,C,b,x,m[h+14],E,2792965006),x=s(x,S,C,b,m[h+15],D,1236535329),b=c(b,x,S,C,m[h+1],O,4129170786),C=c(C,b,x,S,m[h+6],k,3225465664),S=c(S,C,b,x,m[h+11],A,643717713),x=c(x,S,C,b,m[h+0],j,3921069994),b=c(b,x,S,C,m[h+5],O,3593408605),C=c(C,b,x,S,m[h+10],k,38016083),S=c(S,C,b,x,m[h+15],A,3634488961),x=c(x,S,C,b,m[h+4],j,3889429448),b=c(b,x,S,C,m[h+9],O,568446438),C=c(C,b,x,S,m[h+14],k,3275163606),S=c(S,C,b,x,m[h+3],A,4107603335),x=c(x,S,C,b,m[h+8],j,1163531501),b=c(b,x,S,C,m[h+13],O,2850285829),C=c(C,b,x,S,m[h+2],k,4243563512),S=c(S,C,b,x,m[h+7],A,1735328473),x=c(x,S,C,b,m[h+12],j,2368359562),b=l(b,x,S,C,m[h+5],M,4294588738),C=l(C,b,x,S,m[h+8],N,2272392833),S=l(S,C,b,x,m[h+11],P,1839030562),x=l(x,S,C,b,m[h+14],F,4259657740),b=l(b,x,S,C,m[h+1],M,2763975236),C=l(C,b,x,S,m[h+4],N,1272893353),S=l(S,C,b,x,m[h+7],P,4139469664),x=l(x,S,C,b,m[h+10],F,3200236656),b=l(b,x,S,C,m[h+13],M,681279174),C=l(C,b,x,S,m[h+0],N,3936430074),S=l(S,C,b,x,m[h+3],P,3572445317),x=l(x,S,C,b,m[h+6],F,76029189),b=l(b,x,S,C,m[h+9],M,3654602809),C=l(C,b,x,S,m[h+12],N,3873151461),S=l(S,C,b,x,m[h+15],P,530742520),x=l(x,S,C,b,m[h+2],F,3299628645),b=u(b,x,S,C,m[h+0],I,4096336452),C=u(C,b,x,S,m[h+7],L,1126891415),S=u(S,C,b,x,m[h+14],R,2878612391),x=u(x,S,C,b,m[h+5],z,4237533241),b=u(b,x,S,C,m[h+12],I,1700485571),C=u(C,b,x,S,m[h+3],L,2399980690),S=u(S,C,b,x,m[h+10],R,4293915773),x=u(x,S,C,b,m[h+1],z,2240044497),b=u(b,x,S,C,m[h+8],I,1873313359),C=u(C,b,x,S,m[h+15],L,4264355552),S=u(S,C,b,x,m[h+6],R,2734768916),x=u(x,S,C,b,m[h+13],z,1309151649),b=u(b,x,S,C,m[h+4],I,4149444226),C=u(C,b,x,S,m[h+11],L,3174756917),S=u(S,C,b,x,m[h+2],R,718787259),x=u(x,S,C,b,m[h+9],z,3951481745),b=n(b,g),x=n(x,_),S=n(S,v),C=n(C,y);return(f(b)+f(x)+f(S)+f(C)).toLowerCase()},e.closeMediaStream=function(e){if(e)try{var r;if(e.getTracks){r=e.getTracks();var i=n(r),a;try{for(i.s();!(a=i.n()).done;)a.value.stop()}catch(e){i.e(e)}finally{i.f()}}else{r=e.getAudioTracks();var o=n(r),s;try{for(o.s();!(s=o.n()).done;)s.value.stop()}catch(e){o.e(e)}finally{o.f()}r=e.getVideoTracks();var c=n(r),l;try{for(c.s();!(l=c.n()).done;)l.value.stop()}catch(e){c.e(e)}finally{c.f()}}}catch{(typeof e.stop==`function`||t(e.stop)===`object`)&&e.stop()}},e.cloneArray=function(e){return e&&e.slice()||[]},e.cloneObject=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e&&Object.assign({},e)||t}})),F=s(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.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},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),I=s(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),L=s(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=I(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),R=s(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!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`."))}})(),e.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`.split(`.`);function n(){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 e;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&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=L()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),z=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=R(),o=`JsSIP`;t.exports=function(){function e(t){n(this,e),t?(this._debug=a.default(`${o}:${t}`),this._warn=a.default(`${o}:WARN:${t}`),this._error=a.default(`${o}:ERROR:${t}`)):(this._debug=a.default(o),this._warn=a.default(`${o}:WARN`),this._error=a.default(`${o}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return i(e,[{key:`debug`,get:function(){return this._debug}},{key:`warn`,get:function(){return this._warn}},{key:`error`,get:function(){return this._error}}]),e}()})),B=s(((e,t)=>{var n=t.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(e){return e.encoding?`rtpmap:%d %s/%s/%s`:e.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(e){return e.address==null?`rtcp:%d`:`rtcp:%d %s IP%d %s`}},{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(e){return e.subtype==null?`rtcp-fb:%s %s`:`rtcp-fb:%s %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(e){return`extmap:%d`+(e.direction?`/%s`:`%v`)+(e[`encrypt-uri`]?` %s`:`%v`)+` %s`+(e.config?` %s`:``)}},{name:`extmapAllowMixed`,reg:/^(extmap-allow-mixed)/},{push:`crypto`,reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:[`id`,`suite`,`config`,`sessionConfig`],format:function(e){return e.sessionConfig==null?`crypto:%d %s %s`:`crypto:%d %s %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(e){var t=`candidate:%s %d %s %d %s %d typ %s`;return t+=e.raddr==null?`%v%v`:` raddr %s rport %d`,t+=e.tcptype==null?`%v`:` tcptype %s`,e.generation!=null&&(t+=` generation %d`),t+=e[`network-id`]==null?`%v`:` network-id %d`,t+=e[`network-cost`]==null?`%v`:` network-cost %d`,t}},{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(e){var t=`ssrc:%d`;return e.attribute!=null&&(t+=` %s`,e.value!=null&&(t+=`:%s`)),t}},{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(e){return e.maxMessageSize==null?`sctpmap:%s %s`:`sctpmap:%s %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(e){return e.params?`rid:%s %s %s`:`rid:%s %s`}},{push:`imageattrs`,reg: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(e){return`imageattr:%s %s %s`+(e.dir2?` %s %s`:``)}},{name:`simulcast`,reg:RegExp(`^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$`),names:[`dir1`,`list1`,`dir2`,`list2`],format:function(e){return`simulcast:%s %s`+(e.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(e){return`ts-refclk:%s`+(e.clksrcExt==null?``:`=%s`)}},{name:`mediaClk`,reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:[`id`,`mediaClockName`,`mediaClockValue`,`rateNumerator`,`rateDenominator`],format:function(e){var t=`mediaclk:`;return t+=e.id==null?`%v%s`:`id=%s %s`,t+=e.mediaClockValue==null?``:`=%s`,t+=e.rateNumerator==null?``:` rate=%s`,t+=e.rateDenominator==null?``:`/%s`,t}},{name:`keywords`,reg:/^keywds:(.+)$/,format:`keywds:%s`},{name:`content`,reg:/^content:(.+)/,format:`content:%s`},{name:`bfcpFloorCtrl`,reg:/^floorctrl:(c-only|s-only|c-s)/,format:`floorctrl:%s`},{name:`bfcpConfId`,reg:/^confid:(\d+)/,format:`confid:%s`},{name:`bfcpUserId`,reg:/^userid:(\d+)/,format:`userid:%s`},{name:`bfcpFloorId`,reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:[`id`,`mStream`],format:`floorid:%s mstrm:%s`},{push:`invalid`,names:[`value`]}]};Object.keys(n).forEach(function(e){n[e].forEach(function(e){e.reg||=/(.*)/,e.format||=`%s`})})})),ee=s((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var a=0;a<r.length;a+=1)e[a+1]!=null&&(n[r[a]]=t(e[a+1]))},r=function(e,t,r){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var a=e.push?{}:i?t[e.name]:t;n(r.match(e.reg),a,e.names,e.name),e.push&&t[e.push].push(a)},i=B(),a=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},n=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(a).forEach(function(e){var t=e[0],a=e.slice(2);t===`m`&&(n.push({rtp:[],fmtp:[]}),o=n[n.length-1]);for(var s=0;s<(i[t]||[]).length;s+=1){var c=i[t][s];if(c.reg.test(a))return r(c,o,a)}}),t.media=n,t};var o=function(e,n){var r=n.split(/=(.+)/,2);return r.length===2?e[r[0]]=t(r[1]):r.length===1&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(` `).map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(` `).map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(` `).map(function(e){return e.substring(1,e.length-1).split(`,`).reduce(o,{})})},e.parseSimulcastStreamList=function(e){return e.split(`;`).map(function(e){return e.split(`,`).map(function(e){var n,r=!1;return e[0]===`~`?(n=t(e.substring(1,e.length)),r=!0):n=t(e),{scid:n,paused:r}})})}})),te=s(((e,t)=>{var n=B(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case`%%`:return`%`;case`%s`:return String(r);case`%d`:return Number(r);case`%v`:return``}})},a=function(e,t,n){var r=t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format,a=[e+`=`+r];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?a.push(n[t.name][s]):a.push(n[t.names[o]])}else a.push(n[t.name]);return i.apply(null,a)},o=[`v`,`o`,`s`,`i`,`u`,`e`,`p`,`c`,`b`,`t`,`r`,`z`,`a`],s=[`i`,`c`,`b`,`a`];t.exports=function(e,t){t||={},e.version??=0,e.name??=` `,e.media.forEach(function(e){e.payloads??=``});var r=t.outerOrder||o,i=t.innerOrder||s,c=[];return r.forEach(function(t){n[t].forEach(function(n){n.name in e&&e[n.name]!=null?c.push(a(t,n,e)):n.push in e&&e[n.push]!=null&&e[n.push].forEach(function(e){c.push(a(t,n,e))})})}),e.media.forEach(function(e){c.push(a(`m`,n.m[0],e)),i.forEach(function(t){n[t].forEach(function(n){n.name in e&&e[n.name]!=null?c.push(a(t,n,e)):n.push in e&&e[n.push]!=null&&e[n.push].forEach(function(e){c.push(a(t,n,e))})})})}),c.join(`\r
|
|
7
|
+
`)+`\r
|
|
8
|
+
`}})),ne=s((e=>{var t=ee(),n=te();e.grammar=B(),e.write=n,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),V=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function a(e){var t=c();return function(){var n=l(e),r;if(t){var i=l(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return o(this,r)}}function o(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:s(e)}function s(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function c(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function u(e,t){var n;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(n=d(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
9
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,o=!1,s;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{!a&&n.return!=null&&n.return()}finally{if(o)throw s}}}}function d(e,t){if(e){if(typeof e==`string`)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}function f(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function p(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),e}var g=ne(),_=z(),v=k(),y=P(),b=j(),x=M(),S=new _(`SIPMessage`),C=function(){function e(t,n,r,i,a,o){if(p(this,e),!t||!n||!r)return null;i||={},this.ua=r,this.headers={},this.method=t,this.ruri=n,this.body=o,this.extraHeaders=y.cloneArray(a),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),i.route_set?this.setHeader(`route`,i.route_set):r.configuration.use_preloaded_route&&this.setHeader(`route`,`<${r.transport.sip_uri};lr>`),this.setHeader(`via`,``),this.setHeader(`max-forwards`,v.MAX_FORWARDS);var s=i.to_uri||n,c=i.to_tag?{tag:i.to_tag}:null,l=i.to_display_name===void 0?null:i.to_display_name;this.to=new b(s,l,c),this.setHeader(`to`,this.to.toString());var u=i.from_uri||r.configuration.uri,d={tag:i.from_tag||y.newTag()},f=i.from_display_name===void 0?r.configuration.display_name?r.configuration.display_name:null:i.from_display_name;this.from=new b(u,f,d),this.setHeader(`from`,this.from.toString());var m=i.call_id||r.configuration.jssip_id+y.createRandomToken(15);this.call_id=m,this.setHeader(`call-id`,m);var h=i.cseq||Math.floor(Math.random()*1e4);this.cseq=h,this.setHeader(`cseq`,`${h} ${t}`)}return h(e,[{key:`setHeader`,value:function(e,t){for(var n=RegExp(`^\\s*${e}\\s*:`,`i`),r=0;r<this.extraHeaders.length;r++)n.test(this.extraHeaders[r])&&this.extraHeaders.splice(r,1);this.headers[y.headerize(e)]=Array.isArray(t)?t:[t]}},{key:`getHeader`,value:function(e){var t=this.headers[y.headerize(e)];if(t){if(t[0])return t[0]}else{var n=RegExp(`^\\s*${e}\\s*:`,`i`),r=u(this.extraHeaders),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;if(n.test(a))return a.substring(a.indexOf(`:`)+1).trim()}}catch(e){r.e(e)}finally{r.f()}}}},{key:`getHeaders`,value:function(e){var t=this.headers[y.headerize(e)],n=[];if(t){var r=u(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;n.push(a)}}catch(e){r.e(e)}finally{r.f()}return n}var o=RegExp(`^\\s*${e}\\s*:`,`i`),s=u(this.extraHeaders),c;try{for(s.s();!(c=s.n()).done;){var l=c.value;o.test(l)&&n.push(l.substring(l.indexOf(`:`)+1).trim())}}catch(e){s.e(e)}finally{s.f()}return n}},{key:`hasHeader`,value:function(e){if(this.headers[y.headerize(e)])return!0;var t=RegExp(`^\\s*${e}\\s*:`,`i`),n=u(this.extraHeaders),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;if(t.test(i))return!0}}catch(e){n.e(e)}finally{n.f()}return!1}},{key:`parseSDP`,value:function(e){return!e&&this.sdp||(this.sdp=g.parse(this.body||``)),this.sdp}},{key:`toString`,value:function(){var e=`${this.method} ${this.ruri} SIP/2.0\r
|
|
10
|
+
`;for(var t in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,t)){var n=u(this.headers[t]),r;try{for(n.s();!(r=n.n()).done;){var i=r.value;e+=`${t}: ${i}\r
|
|
11
|
+
`}}catch(e){n.e(e)}finally{n.f()}}var a=u(this.extraHeaders),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;e+=`${s.trim()}\r
|
|
12
|
+
`}}catch(e){a.e(e)}finally{a.f()}var c=[];switch(this.method){case v.REGISTER:c.push(`path`,`gruu`);break;case v.INVITE:this.ua.configuration.session_timers&&c.push(`timer`),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&c.push(`gruu`),c.push(`ice`,`replaces`);break;case v.UPDATE:this.ua.configuration.session_timers&&c.push(`timer`),c.push(`ice`)}c.push(`outbound`);var l=this.ua.configuration.user_agent||v.USER_AGENT;if(e+=`Allow: ${v.ALLOWED_METHODS}\r
|
|
13
|
+
`,e+=`Supported: ${c}\r
|
|
14
|
+
`,e+=`User-Agent: ${l}\r
|
|
15
|
+
`,this.body){var d=y.str_utf8_length(this.body);e+=`Content-Length: ${d}\r
|
|
16
|
+
\r
|
|
17
|
+
`,e+=this.body}else e+=`Content-Length: 0\r
|
|
18
|
+
\r
|
|
19
|
+
`;return e}},{key:`clone`,value:function(){var t=new e(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(e){t.headers[e]=this.headers[e].slice()},this),t.body=this.body,t.extraHeaders=y.cloneArray(this.extraHeaders),t.to=this.to,t.from=this.from,t.call_id=this.call_id,t.cseq=this.cseq,t}}]),e}(),w=function(e){r(n,e);var t=a(n);function n(e,r,i,a,o){var s;return p(this,n),s=t.call(this,v.INVITE,e,r,i,a,o),s.transaction=null,s}return h(n,[{key:`cancel`,value:function(e){this.transaction.cancel(e)}},{key:`clone`,value:function(){var e=new n(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(t){e.headers[t]=this.headers[t].slice()},this),e.body=this.body,e.extraHeaders=y.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}}]),n}(C),T=function(){function e(){p(this,e),this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}return h(e,[{key:`addHeader`,value:function(e,t){var n={raw:t};e=y.headerize(e),this.headers[e]?this.headers[e].push(n):this.headers[e]=[n]}},{key:`getHeader`,value:function(e){var t=this.headers[y.headerize(e)];if(t){if(t[0])return t[0].raw}else return}},{key:`getHeaders`,value:function(e){var t=this.headers[y.headerize(e)],n=[];if(!t)return[];var r=u(t),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;n.push(a.raw)}}catch(e){r.e(e)}finally{r.f()}return n}},{key:`hasHeader`,value:function(e){return!!this.headers[y.headerize(e)]}},{key:`parseHeader`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(e=y.headerize(e),!this.headers[e]){S.debug(`header "${e}" not present`);return}if(t>=this.headers[e].length){S.debug(`not so many "${e}" headers present`);return}var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var i=x.parse(r,e.replace(/-/g,`_`));if(i===-1){this.headers[e].splice(t,1),S.debug(`error parsing "${e}" header field with value "${r}"`);return}return n.parsed=i,i}},{key:`s`,value:function(e,t){return this.parseHeader(e,t)}},{key:`setHeader`,value:function(e,t){var n={raw:t};this.headers[y.headerize(e)]=[n]}},{key:`parseSDP`,value:function(e){return!e&&this.sdp||(this.sdp=g.parse(this.body||``)),this.sdp}},{key:`toString`,value:function(){return this.data}}]),e}();t.exports={OutgoingRequest:C,InitialOutgoingInviteRequest:w,IncomingRequest:function(e){r(n,e);var t=a(n);function n(e){var r;return p(this,n),r=t.call(this),r.ua=e,r.headers={},r.ruri=null,r.transport=null,r.server_transaction=null,r}return h(n,[{key:`reply`,value:function(e,t,n,r,i,a){var o=[],s=this.getHeader(`To`);if(e||=null,t||=null,!e||e<100||e>699)throw TypeError(`Invalid status_code: ${e}`);if(t&&typeof t!=`string`&&!(t instanceof String))throw TypeError(`Invalid reason_phrase: ${t}`);t=t||v.REASON_PHRASE[e]||``,n=y.cloneArray(n),this.ua.configuration.extra_headers&&(n=n.concat(this.ua.configuration.extra_headers));var c=`SIP/2.0 ${e} ${t}\r
|
|
20
|
+
`;if(this.method===v.INVITE&&e>100&&e<=200){var l=u(this.getHeaders(`record-route`)),d;try{for(l.s();!(d=l.n()).done;){var f=d.value;c+=`Record-Route: ${f}\r
|
|
21
|
+
`}}catch(e){l.e(e)}finally{l.f()}}var p=u(this.getHeaders(`via`)),m;try{for(p.s();!(m=p.n()).done;){var h=m.value;c+=`Via: ${h}\r
|
|
22
|
+
`}}catch(e){p.e(e)}finally{p.f()}!this.to_tag&&e>100?s+=`;tag=${y.newTag()}`:this.to_tag&&!this.s(`to`).hasParam(`tag`)&&(s+=`;tag=${this.to_tag}`),c+=`To: ${s}\r
|
|
23
|
+
`,c+=`From: ${this.getHeader(`From`)}\r
|
|
24
|
+
`,c+=`Call-ID: ${this.call_id}\r
|
|
25
|
+
`,c+=`CSeq: ${this.cseq} ${this.method}\r
|
|
26
|
+
`;var g=u(n),_;try{for(g.s();!(_=g.n()).done;){var b=_.value;c+=`${b.trim()}\r
|
|
27
|
+
`}}catch(e){g.e(e)}finally{g.f()}switch(this.method){case v.INVITE:this.ua.configuration.session_timers&&o.push(`timer`),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&o.push(`gruu`),o.push(`ice`,`replaces`);break;case v.UPDATE:this.ua.configuration.session_timers&&o.push(`timer`),r&&o.push(`ice`),o.push(`replaces`)}if(o.push(`outbound`),this.method===v.OPTIONS?(c+=`Allow: ${v.ALLOWED_METHODS}\r
|
|
28
|
+
`,c+=`Accept: ${v.ACCEPTED_BODY_TYPES}\r
|
|
29
|
+
`):e===405?c+=`Allow: ${v.ALLOWED_METHODS}\r
|
|
30
|
+
`:e===415&&(c+=`Accept: ${v.ACCEPTED_BODY_TYPES}\r
|
|
31
|
+
`),c+=`Supported: ${o}\r
|
|
32
|
+
`,r){var x=y.str_utf8_length(r);c+=`Content-Type: application/sdp\r
|
|
33
|
+
`,c+=`Content-Length: ${x}\r
|
|
34
|
+
\r
|
|
35
|
+
`,c+=r}else c+=`Content-Length: 0\r
|
|
36
|
+
\r
|
|
37
|
+
`;this.server_transaction.receiveResponse(e,c,i,a)}},{key:`reply_sl`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=this.getHeaders(`via`);if(!e||e<100||e>699)throw TypeError(`Invalid status_code: ${e}`);if(t&&typeof t!=`string`&&!(t instanceof String))throw TypeError(`Invalid reason_phrase: ${t}`);t=t||v.REASON_PHRASE[e]||``;var r=`SIP/2.0 ${e} ${t}\r
|
|
38
|
+
`,i=u(n),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;r+=`Via: ${o}\r
|
|
39
|
+
`}}catch(e){i.e(e)}finally{i.f()}var s=this.getHeader(`To`);if(!this.to_tag&&e>100?s+=`;tag=${y.newTag()}`:this.to_tag&&!this.s(`to`).hasParam(`tag`)&&(s+=`;tag=${this.to_tag}`),r+=`To: ${s}\r
|
|
40
|
+
`,r+=`From: ${this.getHeader(`From`)}\r
|
|
41
|
+
`,r+=`Call-ID: ${this.call_id}\r
|
|
42
|
+
`,r+=`CSeq: ${this.cseq} ${this.method}\r
|
|
43
|
+
`,this.ua.configuration.extra_headers){var c=u(this.ua.configuration.extra_headers),l;try{for(c.s();!(l=c.n()).done;){var d=l.value;r+=`${d.trim()}\r
|
|
44
|
+
`}}catch(e){c.e(e)}finally{c.f()}}r+=`Content-Length: 0\r
|
|
45
|
+
\r
|
|
46
|
+
`,this.transport.send(r)}}]),n}(T),IncomingResponse:function(e){r(n,e);var t=a(n);function n(){var e;return p(this,n),e=t.call(this),e.headers={},e.status_code=null,e.reason_phrase=null,e}return n}(T)}})),H=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=P(),s=new a(`DigestAuthentication`);t.exports=function(){function e(t){n(this,e),this._credentials=t,this._cnonce=null,this._nc=0,this._ncHex=`00000000`,this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}return i(e,[{key:`get`,value:function(e){switch(e){case`realm`:return this._realm;case`ha1`:return this._ha1;default:s.warn(`get() | cannot get "%s" parameter`,e);return}}},{key:`authenticate`,value:function(e,t){var n=e.method,r=e.ruri,i=e.body,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(this._algorithm=t.algorithm,this._realm=t.realm,this._nonce=t.nonce,this._opaque=t.opaque,this._stale=t.stale,this._algorithm){if(this._algorithm!==`MD5`)return s.warn(`authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted`),!1}else this._algorithm=`MD5`;if(!this._nonce)return s.warn(`authenticate() | challenge without Digest nonce, authentication aborted`),!1;if(!this._realm)return s.warn(`authenticate() | challenge without Digest realm, authentication aborted`),!1;if(!this._credentials.password){if(!this._credentials.ha1)return s.warn(`authenticate() | no plain SIP password nor ha1 provided, authentication aborted`),!1;if(this._credentials.realm!==this._realm)return s.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(t.qop){if(t.qop.indexOf(`auth-int`)>-1)this._qop=`auth-int`;else if(t.qop.indexOf(`auth`)>-1)this._qop=`auth`;else return s.warn(`authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted`),!1}else this._qop=null;this._method=n,this._uri=r,this._cnonce=a||o.createRandomToken(12),this._nc+=1;var c=Number(this._nc).toString(16);this._ncHex=`00000000`.substr(0,8-c.length)+c,this._nc===4294967296&&(this._nc=1,this._ncHex=`00000001`),this._ha1=this._credentials.password?o.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._credentials.ha1;var l,u;return this._qop===`auth`?(l=`${this._method}:${this._uri}`,u=o.calculateMD5(l),s.debug(`authenticate() | using qop=auth [a2:"%s"]`,l),this._response=o.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${u}`)):this._qop===`auth-int`?(l=`${this._method}:${this._uri}:${o.calculateMD5(i||``)}`,u=o.calculateMD5(l),s.debug(`authenticate() | using qop=auth-int [a2:"%s"]`,l),this._response=o.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${u}`)):this._qop===null&&(l=`${this._method}:${this._uri}`,u=o.calculateMD5(l),s.debug(`authenticate() | using qop=null [a2:"%s"]`,l),this._response=o.calculateMD5(`${this._ha1}:${this._nonce}:${u}`)),s.debug(`authenticate() | response generated`),!0}},{key:`toString`,value:function(){var e=[];if(!this._response)throw Error(`response field does not exist, cannot generate Authorization header`);return e.push(`algorithm=${this._algorithm}`),e.push(`username="${this._credentials.username}"`),e.push(`realm="${this._realm}"`),e.push(`nonce="${this._nonce}"`),e.push(`uri="${this._uri}"`),e.push(`response="${this._response}"`),this._opaque&&e.push(`opaque="${this._opaque}"`),this._qop&&(e.push(`qop=${this._qop}`),e.push(`cnonce="${this._cnonce}"`),e.push(`nc=${this._ncHex}`)),`Digest ${e.join(`, `)}`}}]),e}()})),re=s(((e,t)=>{var n=500,r=4e3,i=5e3;t.exports={T1:n,T2:r,T4:i,TIMER_B:64*n,TIMER_D:0*n,TIMER_F:64*n,TIMER_H:64*n,TIMER_I:0*n,TIMER_J:0*n,TIMER_K:0*i,TIMER_L:64*n,TIMER_M:64*n,PROVISIONAL_RESPONSE_INTERVAL:6e4}})),U=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=V(),_=re(),v=new m(`NonInviteClientTransaction`),y=new m(`InviteClientTransaction`),b=new m(`AckClientTransaction`),x=new m(`NonInviteServerTransaction`),S=new m(`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`},w=function(e){o(n,e);var t=c(n);function n(e,i,a,o){var s;r(this,n),s=t.call(this),s.type=C.NON_INVITE_CLIENT,s.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,s.ua=e,s.transport=i,s.request=a,s.eventHandlers=o;var c=`SIP/2.0/${i.via_transport}`;return c+=` ${e.configuration.via_host};branch=${s.id}`,s.request.setHeader(`via`,c),s.ua.newTransaction(u(s)),s}return a(n,[{key:`stateChanged`,value:function(e){this.state=e,this.emit(`stateChanged`)}},{key:`send`,value:function(){var e=this;this.stateChanged(C.STATUS_TRYING),this.F=setTimeout(function(){e.timer_F()},_.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:`onTransportError`,value:function(){v.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()}},{key:`timer_F`,value:function(){v.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:`timer_K`,value:function(){this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:`receiveResponse`,value:function(e){var t=this,n=e.status_code;if(n<200)switch(this.state){case C.STATUS_TRYING:case C.STATUS_PROCEEDING:this.stateChanged(C.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e)}else switch(this.state){case C.STATUS_TRYING:case C.STATUS_PROCEEDING:this.stateChanged(C.STATUS_COMPLETED),clearTimeout(this.F),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(e),this.K=setTimeout(function(){t.timer_K()},_.TIMER_K);break;case C.STATUS_COMPLETED:}}},{key:`C`,get:function(){return C}}]),n}(p),T=function(e){o(n,e);var t=c(n);function n(e,i,a,o){var s;r(this,n),s=t.call(this),s.type=C.INVITE_CLIENT,s.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,s.ua=e,s.transport=i,s.request=a,s.eventHandlers=o,a.transaction=u(s);var c=`SIP/2.0/${i.via_transport}`;return c+=` ${e.configuration.via_host};branch=${s.id}`,s.request.setHeader(`via`,c),s.ua.newTransaction(u(s)),s}return a(n,[{key:`stateChanged`,value:function(e){this.state=e,this.emit(`stateChanged`)}},{key:`send`,value:function(){var e=this;this.stateChanged(C.STATUS_CALLING),this.B=setTimeout(function(){e.timer_B()},_.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:`onTransportError`,value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==C.STATUS_ACCEPTED&&(y.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:`timer_M`,value:function(){y.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))}},{key:`timer_B`,value:function(){y.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())}},{key:`timer_D`,value:function(){y.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:`sendACK`,value:function(e){var t=this,n=new g.OutgoingRequest(h.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders(`route`),call_id:this.request.getHeader(`call-id`),cseq:this.request.cseq});n.setHeader(`from`,this.request.getHeader(`from`)),n.setHeader(`via`,this.request.getHeader(`via`)),n.setHeader(`to`,e.getHeader(`to`)),this.D=setTimeout(function(){t.timer_D()},_.TIMER_D),this.transport.send(n)}},{key:`cancel`,value:function(e){if(this.state===C.STATUS_PROCEEDING){var t=new g.OutgoingRequest(h.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders(`route`),call_id:this.request.getHeader(`call-id`),cseq:this.request.cseq});t.setHeader(`from`,this.request.getHeader(`from`)),t.setHeader(`via`,this.request.getHeader(`via`)),t.setHeader(`to`,this.request.getHeader(`to`)),e&&t.setHeader(`reason`,e),this.transport.send(t)}}},{key:`receiveResponse`,value:function(e){var t=this,n=e.status_code;if(n>=100&&n<=199)switch(this.state){case C.STATUS_CALLING:this.stateChanged(C.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case C.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(n>=200&&n<=299)switch(this.state){case C.STATUS_CALLING:case C.STATUS_PROCEEDING:this.stateChanged(C.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},_.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case C.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(n>=300&&n<=699)switch(this.state){case C.STATUS_CALLING:case C.STATUS_PROCEEDING:this.stateChanged(C.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case C.STATUS_COMPLETED:this.sendACK(e)}}},{key:`C`,get:function(){return C}}]),n}(p),E=function(e){o(n,e);var t=c(n);function n(e,i,a,o){var s;r(this,n),s=t.call(this),s.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,s.transport=i,s.request=a,s.eventHandlers=o;var c=`SIP/2.0/${i.via_transport}`;return c+=` ${e.configuration.via_host};branch=${s.id}`,s.request.setHeader(`via`,c),s}return a(n,[{key:`send`,value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:`onTransportError`,value:function(){b.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}},{key:`C`,get:function(){return C}}]),n}(p),D=function(e){o(n,e);var t=c(n);function n(e,i,a){var o;return r(this,n),o=t.call(this),o.type=C.NON_INVITE_SERVER,o.id=a.via_branch,o.ua=e,o.transport=i,o.request=a,o.last_response=``,a.server_transaction=u(o),o.state=C.STATUS_TRYING,e.newTransaction(u(o)),o}return a(n,[{key:`stateChanged`,value:function(e){this.state=e,this.emit(`stateChanged`)}},{key:`timer_J`,value:function(){x.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:`onTransportError`,value:function(){this.transportError||(this.transportError=!0,x.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:`receiveResponse`,value:function(e,t,n,r){var i=this;if(e===100)switch(this.state){case C.STATUS_TRYING:this.stateChanged(C.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case C.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=200&&e<=699)switch(this.state){case C.STATUS_TRYING:case C.STATUS_PROCEEDING:this.stateChanged(C.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){i.timer_J()},_.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case C.STATUS_COMPLETED:}}},{key:`C`,get:function(){return C}}]),n}(p),O=function(e){o(n,e);var t=c(n);function n(e,i,a){var o;return r(this,n),o=t.call(this),o.type=C.INVITE_SERVER,o.id=a.via_branch,o.ua=e,o.transport=i,o.request=a,o.last_response=``,a.server_transaction=u(o),o.state=C.STATUS_PROCEEDING,e.newTransaction(u(o)),o.resendProvisionalTimer=null,a.reply(100),o}return a(n,[{key:`stateChanged`,value:function(e){this.state=e,this.emit(`stateChanged`)}},{key:`timer_H`,value:function(){S.debug(`Timer H expired for transaction ${this.id}`),this.state===C.STATUS_COMPLETED&&S.debug(`ACK not received, dialog will be terminated`),this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:`timer_I`,value:function(){this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:`timer_L`,value:function(){S.debug(`Timer L expired for transaction ${this.id}`),this.state===C.STATUS_ACCEPTED&&(this.stateChanged(C.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:`onTransportError`,value:function(){this.transportError||(this.transportError=!0,S.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))}},{key:`resend_provisional`,value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:`receiveResponse`,value:function(e,t,n,r){var i=this;if(e>=100&&e<=199)switch(this.state){case C.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t}if(e>100&&e<=199&&this.state===C.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){i.resend_provisional()},_.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case C.STATUS_PROCEEDING:this.stateChanged(C.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){i.timer_L()},_.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case C.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&e<=699)switch(this.state){case C.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(C.STATUS_COMPLETED),this.H=setTimeout(function(){i.timer_H()},_.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}}},{key:`C`,get:function(){return C}}]),n}(p);function A(e,t){var n=e._transactions,r;switch(t.method){case h.INVITE:if(r=n.ist[t.via_branch],r){switch(r.state){case C.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case C.STATUS_ACCEPTED:}return!0}break;case h.ACK:if(r=n.ist[t.via_branch],r){if(r.state===C.STATUS_ACCEPTED)return!1;if(r.state===C.STATUS_COMPLETED)return r.state=C.STATUS_CONFIRMED,r.I=setTimeout(function(){r.timer_I()},_.TIMER_I),!0}else return!1;break;case h.CANCEL:return r=n.ist[t.via_branch],r?(t.reply_sl(200),r.state!==C.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(r=n.nist[t.via_branch],r){switch(r.state){case C.STATUS_TRYING:break;case C.STATUS_PROCEEDING:case C.STATUS_COMPLETED:r.transport.send(r.last_response)}return!0}}}t.exports={C,NonInviteClientTransaction:w,InviteClientTransaction:T,AckClientTransaction:E,NonInviteServerTransaction:D,InviteServerTransaction:O,checkTransaction:A}})),W=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=k(),s=H(),c=U(),l=new a(`RequestSender`),u={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}};t.exports=function(){function e(t,r,i){for(var a in n(this,e),this._ua=t,this._eventHandlers=i,this._method=r.method,this._request=r,this._auth=null,this._challenged=!1,this._staled=!1,u)Object.prototype.hasOwnProperty.call(u,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=u[a]));t.status===t.C.STATUS_USER_CLOSED&&(this._method!==o.BYE||this._method!==o.ACK)&&this._eventHandlers.onTransportError()}return i(e,[{key:`send`,value:function(){var e=this,t={onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onReceiveResponse:function(t){e._receiveResponse(t)}};switch(this._method){case`INVITE`:this.clientTransaction=new c.InviteClientTransaction(this._ua,this._ua.transport,this._request,t);break;case`ACK`:this.clientTransaction=new c.AckClientTransaction(this._ua,this._ua.transport,this._request,t);break;default:this.clientTransaction=new c.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,t)}this._ua._configuration.authorization_jwt&&this._request.setHeader(`Authorization`,this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:`_receiveResponse`,value:function(e){var t,n,r=e.status_code;if((r===401||r===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(e.status_code===401?(t=e.parseHeader(`www-authenticate`),n=`authorization`):(t=e.parseHeader(`proxy-authenticate`),n=`proxy-authorization`),!t){l.debug(`${e.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(e);return}if(!this._challenged||!this._staled&&t.stale===!0){if(this._auth||=new s({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,t)){this._eventHandlers.onReceiveResponse(e);return}this._challenged=!0,this._ua.set(`realm`,this._auth.get(`realm`)),this._ua.set(`ha1`,this._auth.get(`ha1`)),t.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(n,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(e)}else this._eventHandlers.onReceiveResponse(e)}}]),e}()})),ie=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=P(),s=k(),c=V(),l=W(),u=new a(`Registrator`),d=10;t.exports=function(){function e(t,r){n(this,e),this._reg_id=1,this._ua=t,this._transport=r,this._registrar=t.configuration.registrar_server,this._expires=t.configuration.register_expires,this._call_id=o.createRandomToken(22),this._cseq=0,this._to_uri=t.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}`}return i(e,[{key:`setExtraHeaders`,value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:`setExtraContactParams`,value:function(e){for(var t in e instanceof Object||(e={}),this._extraContactParams=``,e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=`;${t}`,n&&(this._extraContactParams+=`=${n}`)}}},{key:`register`,value:function(){var e=this;if(this._registering){u.debug(`Register request in progress...`);return}var t=this._extraHeaders.slice();t.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),t.push(`Expires: ${this._expires}`);var n=new c.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new l(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){if(t.cseq===e._cseq)switch(e._registrationTimer!==null&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,!t.hasHeader(`Contact`)){u.debug(`no Contact header in response to REGISTER, response ignored`);break}var n=t.headers.Contact.reduce(function(e,t){return e.concat(t.parsed)},[]),r=n.find(function(t){return e._sipInstance===t.getParam(`+sip.instance`)&&e._reg_id===parseInt(t.getParam(`reg-id`))});if(r||=n.find(function(t){return t.uri.user===e._ua.contact.uri.user}),!r){u.debug(`no Contact header pointing to us, response ignored`);break}var i=r.getParam(`expires`);!i&&t.hasHeader(`expires`)&&(i=t.getHeader(`expires`)),i||=e._expires,i=Number(i),i<d&&(i=d);var a=i>64?i*1e3/2+Math.floor((i/2-32)*1e3*Math.random()):i*1e3-5e3;e._registrationTimer=setTimeout(function(){e._registrationTimer=null,e._ua.listeners(`registrationExpiring`).length===0?e.register():e._ua.emit(`registrationExpiring`)},a),r.hasParam(`temp-gruu`)&&(e._ua.contact.temp_gruu=r.getParam(`temp-gruu`).replace(/"/g,``)),r.hasParam(`pub-gruu`)&&(e._ua.contact.pub_gruu=r.getParam(`pub-gruu`).replace(/"/g,``)),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader(`min-expires`)?(e._expires=Number(t.getHeader(`min-expires`)),e._expires<d&&(e._expires=d),e.register()):(u.debug(`423 response received for REGISTER without Min-Expires`),e._registrationFailure(t,s.causes.SIP_FAILURE_CODE));break;default:var c=o.sipErrorCause(t.status_code);e._registrationFailure(t,c)}}});this._registering=!0,r.send()}},{key:`unregister`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){u.debug(`already unregistered`);return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push(`Contact: *${this._extraContactParams}`):n.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),n.push(`Expires: 0`);var r=new c.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new l(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=o.sipErrorCause(t.status_code);e._unregistered(t,n)}}}).send()}},{key:`close`,value:function(){this._registered&&this.unregister()}},{key:`onTransportClosed`,value:function(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:`_registrationFailure`,value:function(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}},{key:`_unregistered`,value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}},{key:`registered`,get:function(){return this._registered}}]),e}()})),ae=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=k(),o=U(),s=W(),c={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}};t.exports=function(){function e(t,r,i){for(var a in n(this,e),this._dialog=t,this._ua=t._ua,this._request=r,this._eventHandlers=i,this._reattempt=!1,this._reattemptTimer=null,c)Object.prototype.hasOwnProperty.call(c,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=c[a]))}return i(e,[{key:`send`,value:function(){var e=this,t=new s(this._ua,this._request,{onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onAuthenticated:function(t){e._eventHandlers.onAuthenticated(t)},onReceiveResponse:function(t){e._receiveResponse(t)}});t.send(),(this._request.method===a.INVITE||this._request.method===a.UPDATE&&this._request.body)&&t.clientTransaction.state!==o.C.STATUS_TERMINATED&&(this._dialog.uac_pending_reply=!0,t.clientTransaction.on(`stateChanged`,function n(){(t.clientTransaction.state===o.C.STATUS_ACCEPTED||t.clientTransaction.state===o.C.STATUS_COMPLETED||t.clientTransaction.state===o.C.STATUS_TERMINATED)&&(t.clientTransaction.removeListener(`stateChanged`,n),e._dialog.uac_pending_reply=!1)}))}},{key:`_receiveResponse`,value:function(e){var t=this;e.status_code===408||e.status_code===481?this._eventHandlers.onDialogError(e):e.method===a.INVITE&&e.status_code===491?this._reattempt?e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){t._dialog.isTerminated()||(t._reattempt=!0,t.send())},1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:`request`,get:function(){return this._request}}]),e}()})),oe=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=V(),s=k(),c=U(),l=ae(),u=P(),d=new a(`Dialog`),f={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};t.exports=function(){i(e,null,[{key:`C`,get:function(){return f}}]);function e(t,r,i){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:f.STATUS_CONFIRMED;if(n(this,e),this._owner=t,this._ua=t._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!r.hasHeader(`contact`))return{error:`unable to create a Dialog without Contact header field`};r instanceof o.IncomingResponse&&(a=r.status_code<200?f.STATUS_EARLY:f.STATUS_CONFIRMED);var s=r.parseHeader(`contact`);i===`UAS`?(this._id={call_id:r.call_id,local_tag:r.to_tag,remote_tag:r.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=r.cseq,this._local_uri=r.parseHeader(`to`).uri,this._remote_uri=r.parseHeader(`from`).uri,this._remote_target=s.uri,this._route_set=r.getHeaders(`record-route`),this._ack_seqnum=this._remote_seqnum):i===`UAC`&&(this._id={call_id:r.call_id,local_tag:r.from_tag,remote_tag:r.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=r.cseq,this._local_uri=r.parseHeader(`from`).uri,this._remote_uri=r.parseHeader(`to`).uri,this._remote_target=s.uri,this._route_set=r.getHeaders(`record-route`).reverse(),this._ack_seqnum=null),this._ua.newDialog(this),d.debug(`new ${i} dialog created with status ${this._state===f.STATUS_EARLY?`EARLY`:`CONFIRMED`}`)}return i(e,[{key:`isTerminated`,value:function(){return this._status===f.STATUS_TERMINATED}},{key:`update`,value:function(e,t){this._state=f.STATUS_CONFIRMED,d.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),t===`UAC`&&(this._route_set=e.getHeaders(`record-route`).reverse())}},{key:`terminate`,value:function(){d.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=f.STATUS_TERMINATED}},{key:`sendRequest`,value:function(e){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=u.cloneArray(n.extraHeaders),i=u.cloneObject(n.eventHandlers),a=n.body||null,o=this._createRequest(e,r,a);return i.onAuthenticated=function(){t._local_seqnum+=1},new l(this,o,i).send(),o}},{key:`receiveRequest`,value:function(e){this._checkInDialogRequest(e)&&(e.method===s.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:e.method===s.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:`_createRequest`,value:function(e,t,n){t=u.cloneArray(t),this._local_seqnum||=Math.floor(Math.random()*1e4);var r=e===s.CANCEL||e===s.ACK?this._local_seqnum:this._local_seqnum+=1;return new o.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,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},t,n)}},{key:`_checkInDialogRequest`,value:function(e){var t=this;if(!this._remote_seqnum)this._remote_seqnum=e.cseq;else if(e.cseq<this._remote_seqnum){if(e.method===s.ACK){if(this._ack_seqnum===null||e.cseq!==this._ack_seqnum)return!1}else return e.reply(500),!1}else e.cseq>this._remote_seqnum&&(this._remote_seqnum=e.cseq);if(e.method===s.INVITE||e.method===s.UPDATE&&e.body){if(this._uac_pending_reply===!0)e.reply(491);else if(this._uas_pending_reply===!0){var n=(Math.random()*10|0)+1;return e.reply(500,null,[`Retry-After:${n}`]),!1}else this._uas_pending_reply=!0,e.server_transaction.on(`stateChanged`,function n(){(e.server_transaction.state===c.C.STATUS_ACCEPTED||e.server_transaction.state===c.C.STATUS_COMPLETED||e.server_transaction.state===c.C.STATUS_TERMINATED)&&(e.server_transaction.removeListener(`stateChanged`,n),t._uas_pending_reply=!1)});e.hasHeader(`contact`)&&e.server_transaction.on(`stateChanged`,function(){e.server_transaction.state===c.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader(`contact`).uri)})}else e.method===s.NOTIFY&&e.hasHeader(`contact`)&&e.server_transaction.on(`stateChanged`,function(){e.server_transaction.state===c.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader(`contact`).uri)});return!0}},{key:`id`,get:function(){return this._id}},{key:`local_seqnum`,get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:`owner`,get:function(){return this._owner}},{key:`uac_pending_reply`,get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:`uas_pending_reply`,get:function(){return this._uas_pending_reply}}]),e}()})),G=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=A(),_=P(),v=new m(`RTCSession:DTMF`),y={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};t.exports=function(e){o(n,e);var t=c(n);function n(e){var i;return r(this,n),i=t.call(this),i._session=e,i._direction=null,i._tone=null,i._duration=null,i._request=null,i}return a(n,[{key:`send`,value:function(e){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e===void 0)throw TypeError(`Not enough arguments`);if(this._direction=`outgoing`,this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new g.InvalidStateError(this._session.status);var r=_.cloneArray(n.extraHeaders);if(this.eventHandlers=_.cloneObject(n.eventHandlers),typeof e==`string`)e=e.toUpperCase();else if(typeof e==`number`)e=e.toString();else throw TypeError(`Invalid tone: ${e}`);if(e.match(/^[0-9A-DR#*]$/))this._tone=e;else throw TypeError(`Invalid tone: ${e}`);this._duration=n.duration,r.push(`Content-Type: application/dtmf-relay`);var i=`Signal=${this._tone}\r
|
|
47
|
+
`;i+=`Duration=${this._duration}`,this._session.newDTMF({originator:`local`,dtmf:this,request:this._request}),this._session.sendRequest(h.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit(`succeeded`,{originator:`remote`,response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit(`failed`,{originator:`remote`,response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:i})}},{key:`init_incoming`,value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction=`incoming`,this._request=e,e.reply(200),e.body){var r=e.body.split(`
|
|
48
|
+
`);r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,`$2`)),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,`$2`),10))}this._duration||=y.DEFAULT_DURATION,this._tone?this._session.newDTMF({originator:`remote`,dtmf:this,request:e}):v.debug(`invalid INFO DTMF received, discarded`)}},{key:`tone`,get:function(){return this._tone}},{key:`duration`,get:function(){return this._duration}}]),n}(p),t.exports.C=y})),se=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=k(),h=A(),g=P();t.exports=function(e){o(n,e);var t=c(n);function n(e){var i;return r(this,n),i=t.call(this),i._session=e,i._direction=null,i._contentType=null,i._body=null,i}return a(n,[{key:`send`,value:function(e,t){var n=this,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this._direction=`outgoing`,e===void 0)throw 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 h.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var i=g.cloneArray(r.extraHeaders);i.push(`Content-Type: ${e}`),this._session.newInfo({originator:`local`,info:this,request:this.request}),this._session.sendRequest(m.INFO,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(e){n.emit(`succeeded`,{originator:`remote`,response:e})},onErrorResponse:function(e){n.emit(`failed`,{originator:`remote`,response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:`init_incoming`,value:function(e){this._direction=`incoming`,this.request=e,e.reply(200),this._contentType=e.hasHeader(`Content-Type`)?e.getHeader(`Content-Type`).toLowerCase():void 0,this._body=e.body,this._session.newInfo({originator:`remote`,info:this,request:e})}},{key:`contentType`,get:function(){return this._contentType}},{key:`body`,get:function(){return this._body}}]),n}(p)})),K=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=k(),s=new a(`RTCSession:ReferNotifier`),c={event_type:`refer`,body_type:`message/sipfrag;version=2.0`,expires:300};t.exports=function(){function e(t,r,i){n(this,e),this._session=t,this._id=r,this._expires=i||c.expires,this._active=!0,this.notify(100)}return i(e,[{key:`notify`,value:function(e,t){if(s.debug(`notify()`),this._active!==!1){t=t||o.REASON_PHRASE[e]||``;var n=e>=200?`terminated;reason=noresource`:`active;expires=${this._expires}`;this._session.sendRequest(o.NOTIFY,{extraHeaders:[`Event: ${c.event_type};id=${this._id}`,`Subscription-State: ${n}`,`Content-Type: ${c.body_type}`],body:`SIP/2.0 ${e} ${t}`,eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),e}()})),ce=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=M(),_=P(),v=new m(`RTCSession:ReferSubscriber`);t.exports=function(e){o(n,e);var t=c(n);function n(e){var i;return r(this,n),i=t.call(this),i._id=null,i._session=e,i}return a(n,[{key:`sendRefer`,value:function(e){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};v.debug(`sendRefer()`);var r=_.cloneArray(n.extraHeaders),i=_.cloneObject(n.eventHandlers);for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&this.on(a,i[a]);var o=null;n.replaces&&(o=n.replaces._request.call_id,o+=`;to-tag=${n.replaces._to_tag}`,o+=`;from-tag=${n.replaces._from_tag}`,o=encodeURIComponent(o));var s=`Refer-To: <${e}${o?`?Replaces=${o}`:``}>`;if(r.push(s),!r.some(function(e){return e.toLowerCase().startsWith(`referred-by:`)})){var c=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;r.push(c)}r.push(`Contact: ${this._session.contact}`);var l=this._session.sendRequest(h.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,h.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,h.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,h.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,h.causes.DIALOG_ERROR)}}});this._id=l.cseq}},{key:`receiveNotify`,value:function(e){if(v.debug(`receiveNotify()`),e.body){var t=g.parse(e.body.trim().split(`\r
|
|
49
|
+
`,1)[0],`Status_Line`);if(t===-1){v.debug(`receiveNotify() | error parsing NOTIFY body: "${e.body}"`);return}switch(!0){case/^100$/.test(t.status_code):this.emit(`trying`,{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit(`progress`,{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit(`accepted`,{request:e,status_line:t});break;default:this.emit(`failed`,{request:e,status_line:t})}}}},{key:`_requestSucceeded`,value:function(e){v.debug(`REFER succeeded`),v.debug(`emit "requestSucceeded"`),this.emit(`requestSucceeded`,{response:e})}},{key:`_requestFailed`,value:function(e,t){v.debug(`REFER failed`),v.debug(`emit "requestFailed"`),this.emit(`requestFailed`,{response:e||null,cause:t})}},{key:`id`,get:function(){return this._id}}]),n}(p)})),le=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){var n;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(n=i(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
50
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&n.return!=null&&n.return()}finally{if(s)throw c}}}}function i(e,t){if(e){if(typeof e==`string`)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}}function a(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function l(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function d(e){var t=m();return function(){var n=h(e),r;if(t){var i=h(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}function f(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:p(e)}function p(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function m(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}var g=F().EventEmitter,_=ne(),v=z(),y=k(),b=A(),x=U(),S=P(),C=re(),w=V(),T=oe(),E=W(),D=G(),O=se(),j=K(),M=ce(),I=N(),L=new v(`RTCSession`),R={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},B=[`audio`,`video`];t.exports=function(e){l(n,e);var t=d(n);c(n,null,[{key:`C`,get:function(){return R}}]);function n(e){var r;return o(this,n),L.debug(`new`),r=t.call(this),r._id=null,r._ua=e,r._status=R.STATUS_NULL,r._dialog=null,r._earlyDialogs={},r._contact=null,r._from_tag=null,r._to_tag=null,r._connection=null,r._connectionPromiseQueue=Promise.resolve(),r._request=null,r._is_canceled=!1,r._cancel_reason=``,r._is_confirmed=!1,r._late_sdp=!1,r._rtcOfferConstraints=null,r._rtcAnswerConstraints=null,r._localMediaStream=null,r._localMediaStreamLocallyGenerated=!1,r._rtcReady=!0,r._iceReady=!1,r._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},r._direction=null,r._local_identity=null,r._remote_identity=null,r._start_time=null,r._end_time=null,r._tones=null,r._audioMuted=!1,r._videoMuted=!1,r._localHold=!1,r._remoteHold=!1,r._sessionTimers={enabled:r._ua.configuration.session_timers,refreshMethod:r._ua.configuration.session_timers_refresh_method,defaultExpires:y.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},r._referSubscribers={},r._data={},r}return c(n,[{key:`isInProgress`,value:function(){switch(this._status){case R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:case R.STATUS_INVITE_RECEIVED:case R.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:`isEstablished`,value:function(){switch(this._status){case R.STATUS_ANSWERED:case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:return!0;default:return!1}}},{key:`isEnded`,value:function(){switch(this._status){case R.STATUS_CANCELED:case R.STATUS_TERMINATED:return!0;default:return!1}}},{key:`isMuted`,value:function(){return{audio:this._audioMuted,video:this._videoMuted}}},{key:`isOnHold`,value:function(){return{local:this._localHold,remote:this._remoteHold}}},{key:`connect`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;L.debug(`connect()`);var r=e,i=S.cloneObject(t.eventHandlers),a=S.cloneArray(t.extraHeaders),o=S.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),s=t.mediaStream||null,c=S.cloneObject(t.pcConfig,{iceServers:[]}),l=t.rtcConstraints||null,u=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=u,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,e===void 0)throw TypeError(`Not enough arguments`);if(this._status!==R.STATUS_NULL)throw new b.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new b.NotSupportedError(`WebRTC not supported`);if(e=this._ua.normalizeTarget(e),!e)throw TypeError(`Invalid target: ${r}`);for(var d in this._sessionTimers.enabled&&S.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=y.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=y.SESSION_EXPIRES),i)Object.prototype.hasOwnProperty.call(i,d)&&this.on(d,i[d]);this._from_tag=S.newTag();var f=t.anonymous||!1,p={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:f,outbound:!0}),f?(p.from_display_name=`Anonymous`,p.from_uri=new I(`sip`,`anonymous`,`anonymous.invalid`),a.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),a.push(`Privacy: id`)):t.fromUserName&&(p.from_uri=new I(`sip`,t.fromUserName,this._ua.configuration.uri.host),a.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),t.fromDisplayName&&(p.from_display_name=t.fromDisplayName),a.push(`Contact: ${this._contact}`),a.push(`Content-Type: application/sdp`),this._sessionTimers.enabled&&a.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?`;refresher=uac`:``}`),this._request=new w.InitialOutgoingInviteRequest(e,this._ua,p,a),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(c,l),this._direction=`outgoing`,this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession(`local`,this._request),this._sendInitialRequest(o,u,s)}},{key:`init_incoming`,value:function(e,t){var n=this;L.debug(`init_incoming()`);var r,i=e.hasHeader(`Content-Type`)?e.getHeader(`Content-Type`).toLowerCase():void 0;if(e.body&&i!==`application/sdp`){e.reply(415);return}if(this._status=R.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader(`expires`)&&(r=e.getHeader(`expires`)*1e3),e.to_tag=S.newTag(),!this._createDialog(e,`UAS`,!0)){e.reply(500,`Missing Contact header field`);return}this._late_sdp=!e.body,this._status=R.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){e.reply(408),n._failed(`local`,null,y.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),r&&(this._timers.expiresTimer=setTimeout(function(){n._status===R.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),n._failed(`system`,null,y.causes.EXPIRES))},r)),this._direction=`incoming`,this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession(`remote`,e),this._status!==R.STATUS_TERMINATED&&(e.reply(180,null,[`Contact: ${this._contact}`]),this._progress(`local`,null))}},{key:`answer`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};L.debug(`answer()`);var n=this._request,i=S.cloneArray(t.extraHeaders),a=S.cloneObject(t.mediaConstraints),o=t.mediaStream||null,s=S.cloneObject(t.pcConfig,{iceServers:[]}),c=t.rtcConstraints||null,l=t.rtcAnswerConstraints||null,u=S.cloneObject(t.rtcOfferConstraints),d,f=!1,p=!1,m=!1,h=!1;if(this._rtcAnswerConstraints=l,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,this._direction!==`incoming`)throw new b.NotSupportedError(`"answer" not supported for outgoing RTCSession`);if(this._status!==R.STATUS_WAITING_FOR_ANSWER)throw new b.InvalidStateError(this._status);if(this._sessionTimers.enabled&&S.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=y.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=y.SESSION_EXPIRES),this._status=R.STATUS_ANSWERED,!this._createDialog(n,`UAS`)){n.reply(500,`Error creating dialog`);return}clearTimeout(this._timers.userNoAnswerTimer),i.unshift(`Contact: ${this._contact}`);var g=n.parseSDP();Array.isArray(g.media)||(g.media=[g.media]);var _=r(g.media),v;try{for(_.s();!(v=_.n()).done;){var x=v.value;x.type===`audio`&&(f=!0,(!x.direction||x.direction===`sendrecv`)&&(m=!0)),x.type===`video`&&(p=!0,(!x.direction||x.direction===`sendrecv`)&&(h=!0))}}catch(e){_.e(e)}finally{_.f()}if(o&&a.audio===!1){d=o.getAudioTracks();var C=r(d),w;try{for(C.s();!(w=C.n()).done;){var T=w.value;o.removeTrack(T)}}catch(e){C.e(e)}finally{C.f()}}if(o&&a.video===!1){d=o.getVideoTracks();var E=r(d),D;try{for(E.s();!(D=E.n()).done;){var O=D.value;o.removeTrack(O)}}catch(e){E.e(e)}finally{E.f()}}!o&&a.audio===void 0&&(a.audio=m),!o&&a.video===void 0&&(a.video=h),!o&&!f&&!u.offerToReceiveAudio&&(a.audio=!1),!o&&!p&&!u.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(s,c),Promise.resolve().then(function(){if(o)return o;if(a.audio||a.video)return e._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(function(t){throw e._status===R.STATUS_TERMINATED?Error(`terminated`):(n.reply(480),e._failed(`local`,null,y.causes.USER_DENIED_MEDIA_ACCESS),L.warn(`emit "getusermediafailed" [error:%o]`,t),e.emit(`getusermediafailed`,t),Error(`getUserMedia() failed`))})}).then(function(t){if(e._status===R.STATUS_TERMINATED)throw Error(`terminated`);e._localMediaStream=t,t&&t.getTracks().forEach(function(n){e._connection.addTrack(n,t)})}).then(function(){if(!e._late_sdp){var t={originator:`remote`,type:`offer`,sdp:n.body};L.debug(`emit "sdp"`),e.emit(`sdp`,t);var r=new RTCSessionDescription({type:`offer`,sdp:t.sdp});return e._connectionPromiseQueue=e._connectionPromiseQueue.then(function(){return e._connection.setRemoteDescription(r)}).catch(function(t){throw n.reply(488),e._failed(`system`,null,y.causes.WEBRTC_ERROR),L.warn(`emit "peerconnection:setremotedescriptionfailed" [error:%o]`,t),e.emit(`peerconnection:setremotedescriptionfailed`,t),Error(`peerconnection.setRemoteDescription() failed`)}),e._connectionPromiseQueue}}).then(function(){if(e._status===R.STATUS_TERMINATED)throw Error(`terminated`);return e._connecting(n),e._late_sdp?e._createLocalDescription(`offer`,e._rtcOfferConstraints).catch(function(){throw n.reply(500),Error(`_createLocalDescription() failed`)}):e._createLocalDescription(`answer`,l).catch(function(){throw n.reply(500),Error(`_createLocalDescription() failed`)})}).then(function(t){if(e._status===R.STATUS_TERMINATED)throw Error(`terminated`);e._handleSessionTimersInIncomingRequest(n,i),n.reply(200,null,i,t,function(){e._status=R.STATUS_WAITING_FOR_ACK,e._setInvite2xxTimer(n,t),e._setACKTimer(),e._accepted(`local`)},function(){e._failed(`system`,null,y.causes.CONNECTION_ERROR)})}).catch(function(t){e._status!==R.STATUS_TERMINATED&&L.warn(t)})}},{key:`terminate`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};L.debug(`terminate()`);var n=t.cause||y.causes.BYE,r=S.cloneArray(t.extraHeaders),i=t.body,a,o=t.status_code,s=t.reason_phrase;if(this._status===R.STATUS_TERMINATED)throw new b.InvalidStateError(this._status);switch(this._status){case R.STATUS_NULL:case R.STATUS_INVITE_SENT:case R.STATUS_1XX_RECEIVED:if(L.debug(`canceling session`),o&&(o<200||o>=700))throw TypeError(`Invalid status_code: ${o}`);o&&(s=s||y.REASON_PHRASE[o]||``,a=`SIP ;cause=${o} ;text="${s}"`),this._status===R.STATUS_NULL||this._status===R.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=a):this._status===R.STATUS_1XX_RECEIVED&&this._request.cancel(a),this._status=R.STATUS_CANCELED,this._failed(`local`,null,y.causes.CANCELED);break;case R.STATUS_WAITING_FOR_ANSWER:case R.STATUS_ANSWERED:if(L.debug(`rejecting session`),o||=480,o<300||o>=700)throw TypeError(`Invalid status_code: ${o}`);this._request.reply(o,s,r,i),this._failed(`local`,null,y.causes.REJECTED);break;case R.STATUS_WAITING_FOR_ACK:case R.STATUS_CONFIRMED:if(L.debug(`terminating session`),s=t.reason_phrase||y.REASON_PHRASE[o]||``,o&&(o<200||o>=700))throw TypeError(`Invalid status_code: ${o}`);if(o&&r.push(`Reason: SIP ;cause=${o}; text="${s}"`),this._status===R.STATUS_WAITING_FOR_ACK&&this._direction===`incoming`&&this._request.server_transaction.state!==x.C.STATUS_TERMINATED){var c=this._dialog;this.receiveRequest=function(t){t.method===y.ACK&&(e.sendRequest(y.BYE,{extraHeaders:r,body:i}),c.terminate())},this._request.server_transaction.on(`stateChanged`,function(){e._request.server_transaction.state===x.C.STATUS_TERMINATED&&(e.sendRequest(y.BYE,{extraHeaders:r,body:i}),c.terminate())}),this._ended(`local`,null,n),this._dialog=c,this._ua.newDialog(c)}else this.sendRequest(y.BYE,{extraHeaders:r,body:i}),this._ended(`local`,null,n)}}},{key:`sendDTMF`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};L.debug(`sendDTMF() | tones: %s`,e);var n=0,r=t.duration||null,i=t.interToneGap||null,a=t.transportType||y.DTMF_TRANSPORT.INFO;if(e===void 0)throw TypeError(`Not enough arguments`);if(this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new b.InvalidStateError(this._status);if(a!==y.DTMF_TRANSPORT.INFO&&a!==y.DTMF_TRANSPORT.RFC2833)throw TypeError(`invalid transportType: ${a}`);if(typeof e==`number`&&(e=e.toString()),!e||typeof e!=`string`||!e.match(/^[0-9A-DR#*,]+$/i))throw TypeError(`Invalid tones: ${e}`);if(r&&!S.isDecimal(r))throw TypeError(`Invalid tone duration: ${r}`);if(r?r<D.C.MIN_DURATION?(L.debug(`"duration" value is lower than the minimum allowed, setting it to ${D.C.MIN_DURATION} milliseconds`),r=D.C.MIN_DURATION):r>D.C.MAX_DURATION?(L.debug(`"duration" value is greater than the maximum allowed, setting it to ${D.C.MAX_DURATION} milliseconds`),r=D.C.MAX_DURATION):r=Math.abs(r):r=D.C.DEFAULT_DURATION,t.duration=r,i&&!S.isDecimal(i))throw TypeError(`Invalid interToneGap: ${i}`);if(i?i<D.C.MIN_INTER_TONE_GAP?(L.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${D.C.MIN_INTER_TONE_GAP} milliseconds`),i=D.C.MIN_INTER_TONE_GAP):i=Math.abs(i):i=D.C.DEFAULT_INTER_TONE_GAP,a===y.DTMF_TRANSPORT.RFC2833){var o=this._getDTMFRTPSender();o&&(e=o.toneBuffer+e,o.insertDTMF(e,r,i));return}if(this._tones){this._tones+=e;return}this._tones=e,s.call(this);function s(){var e=this,a;if(this._status===R.STATUS_TERMINATED||!this._tones||n>=this._tones.length){this._tones=null;return}var o=this._tones[n];if(n+=1,o===`,`)a=2e3;else{var c=new D(this);t.eventHandlers={onFailed:function(){e._tones=null}},c.send(o,t),a=r+i}setTimeout(s.bind(this),a)}}},{key:`sendInfo`,value:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(L.debug(`sendInfo()`),this._status!==R.STATUS_CONFIRMED&&this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_1XX_RECEIVED)throw new b.InvalidStateError(this._status);new O(this).send(e,t,n)}},{key:`mute`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};L.debug(`mute()`);var t=!1,n=!1;this._audioMuted===!1&&e.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&e.video&&(n=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(t===!0||n===!0)&&this._onmute({audio:t,video:n})}},{key:`unmute`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};L.debug(`unmute()`);var t=!1,n=!1;this._audioMuted===!0&&e.audio&&(t=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&e.video&&(n=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(t===!0||n===!0)&&this._onunmute({audio:t,video:n})}},{key:`hold`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(L.debug(`hold()`),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold(`local`);var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:y.causes.WEBRTC_ERROR,status_code:500,reason_phrase:`Hold Failed`})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:`unhold`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(L.debug(`unhold()`),this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold(`local`);var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:y.causes.WEBRTC_ERROR,status_code:500,reason_phrase:`Unhold Failed`})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:`renegotiate`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;L.debug(`renegotiate()`);var r=t.rtcOfferConstraints||null;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var i={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:y.causes.WEBRTC_ERROR,status_code:500,reason_phrase:`Media Renegotiation Failed`})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:`refer`,value:function(e,t){var n=this;L.debug(`refer()`);var r=e;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;if(e=this._ua.normalizeTarget(e),!e)throw TypeError(`Invalid target: ${r}`);var i=new M(this);i.sendRefer(e,t);var a=i.id;return this._referSubscribers[a]=i,i.on(`requestFailed`,function(){delete n._referSubscribers[a]}),i.on(`accepted`,function(){delete n._referSubscribers[a]}),i.on(`failed`,function(){delete n._referSubscribers[a]}),i}},{key:`sendRequest`,value:function(e,t){return L.debug(`sendRequest()`),this._dialog.sendRequest(e,t)}},{key:`receiveRequest`,value:function(e){var t=this;if(L.debug(`receiveRequest()`),e.method===y.CANCEL)(this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED)&&(this._status=R.STATUS_CANCELED,this._request.reply(487),this._failed(`remote`,e,y.causes.CANCELED));else switch(e.method){case y.ACK:if(this._status!==R.STATUS_WAITING_FOR_ACK)return;if(this._status=R.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:y.causes.MISSING_SDP,status_code:400});break}var n={originator:`remote`,type:`answer`,sdp:e.body};L.debug(`emit "sdp"`),this.emit(`sdp`,n);var r=new RTCSessionDescription({type:`answer`,sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(r)}).then(function(){t._is_confirmed||t._confirmed(`remote`,e)}).catch(function(e){t.terminate({cause:y.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),L.warn(`emit "peerconnection:setremotedescriptionfailed" [error:%o]`,e),t.emit(`peerconnection:setremotedescriptionfailed`,e)})}else this._is_confirmed||this._confirmed(`remote`,e);break;case y.BYE:this._status===R.STATUS_CONFIRMED||this._status===R.STATUS_WAITING_FOR_ACK?(e.reply(200),this._ended(`remote`,e,y.causes.BYE)):this._status===R.STATUS_INVITE_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER?(e.reply(200),this._request.reply(487,`BYE Received`),this._ended(`remote`,e,y.causes.BYE)):e.reply(403,`Wrong Status`);break;case y.INVITE:this._status===R.STATUS_CONFIRMED?e.hasHeader(`replaces`)?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,`Wrong Status`);break;case y.INFO:if(this._status===R.STATUS_1XX_RECEIVED||this._status===R.STATUS_WAITING_FOR_ANSWER||this._status===R.STATUS_ANSWERED||this._status===R.STATUS_WAITING_FOR_ACK||this._status===R.STATUS_CONFIRMED){var i=e.hasHeader(`Content-Type`)?e.getHeader(`Content-Type`).toLowerCase():void 0;i&&i.match(/^application\/dtmf-relay/i)?new D(this).init_incoming(e):i===void 0?e.reply(415):new O(this).init_incoming(e)}else e.reply(403,`Wrong Status`);break;case y.UPDATE:this._status===R.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,`Wrong Status`);break;case y.REFER:this._status===R.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,`Wrong Status`);break;case y.NOTIFY:this._status===R.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,`Wrong Status`);break;default:e.reply(501)}}},{key:`onTransportError`,value:function(){L.warn(`onTransportError()`),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:y.causes.CONNECTION_ERROR,cause:y.causes.CONNECTION_ERROR})}},{key:`onRequestTimeout`,value:function(){L.warn(`onRequestTimeout()`),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:y.causes.REQUEST_TIMEOUT,cause:y.causes.REQUEST_TIMEOUT})}},{key:`onDialogError`,value:function(){L.warn(`onDialogError()`),this._status!==R.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:y.causes.DIALOG_ERROR,cause:y.causes.DIALOG_ERROR})}},{key:`newDTMF`,value:function(e){L.debug(`newDTMF()`),this.emit(`newDTMF`,e)}},{key:`newInfo`,value:function(e){L.debug(`newInfo()`),this.emit(`newInfo`,e)}},{key:`_isReadyToReOffer`,value:function(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(L.debug(`_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress`),!1):!0:(L.debug(`_isReadyToReOffer() | session not established yet`),!1):(L.debug(`_isReadyToReOffer() | internal WebRTC status not ready`),!1)}},{key:`_close`,value:function(){if(L.debug(`close()`),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(L.debug(`close() | closing local MediaStream`),S.closeMediaStream(this._localMediaStream)),this._status!==R.STATUS_TERMINATED){if(this._status=R.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){L.warn(`close() | error closing the RTCPeerConnection: %o`,e)}for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);for(var t in clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog),this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:`_setInvite2xxTimer`,value:function(e,t){var n=C.T1;function r(){this._status===R.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,[`Contact: ${this._contact}`],t),n<C.T2&&(n*=2,n>C.T2&&(n=C.T2)),this._timers.invite2xxTimer=setTimeout(r.bind(this),n))}this._timers.invite2xxTimer=setTimeout(r.bind(this),n)}},{key:`_setACKTimer`,value:function(){var e=this;this._timers.ackTimer=setTimeout(function(){e._status===R.STATUS_WAITING_FOR_ACK&&(L.debug(`no ACK received, terminating the session`),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(y.BYE),e._ended(`remote`,null,y.causes.NO_ACK))},C.TIMER_H)}},{key:`_createRTCConnection`,value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener(`iceconnectionstatechange`,function(){n._connection.iceConnectionState===`failed`&&n.terminate({cause:y.causes.RTP_TIMEOUT,status_code:408,reason_phrase:y.causes.RTP_TIMEOUT})}),L.debug(`emit "peerconnection"`),this.emit(`peerconnection`,{peerconnection:this._connection})}},{key:`_createLocalDescription`,value:function(e,t){var n=this;if(L.debug(`createLocalDescription()`),e!==`offer`&&e!==`answer`)throw Error(`createLocalDescription() | invalid type "${e}"`);var r=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return e===`offer`?r.createOffer(t).catch(function(e){return L.warn(`emit "peerconnection:createofferfailed" [error:%o]`,e),n.emit(`peerconnection:createofferfailed`,e),Promise.reject(e)}):r.createAnswer(t).catch(function(e){return L.warn(`emit "peerconnection:createanswerfailed" [error:%o]`,e),n.emit(`peerconnection:createanswerfailed`,e),Promise.reject(e)})}).then(function(e){return r.setLocalDescription(e).catch(function(e){return n._rtcReady=!0,L.warn(`emit "peerconnection:setlocaldescriptionfailed" [error:%o]`,e),n.emit(`peerconnection:setlocaldescriptionfailed`,e),Promise.reject(e)})}).then(function(){var i=t&&t.iceRestart;if(r.iceGatheringState===`complete`&&!i||r.iceGatheringState===`gathering`&&n._iceReady){n._rtcReady=!0;var a={originator:`local`,type:e,sdp:r.localDescription.sdp};return L.debug(`emit "sdp"`),n.emit(`sdp`,a),Promise.resolve(a.sdp)}return new Promise(function(t){var i=!1,a,o;n._iceReady=!1;var s=function(){if(!i){r.removeEventListener(`icecandidate`,a),r.removeEventListener(`icegatheringstatechange`,o),i=!0,n._rtcReady=!0,n._iceReady=!0;var s={originator:`local`,type:e,sdp:r.localDescription.sdp};L.debug(`emit "sdp"`),n.emit(`sdp`,s),t(s.sdp)}};r.addEventListener(`icecandidate`,a=function(e){var t=e.candidate;t?n.emit(`icecandidate`,{candidate:t,ready:s}):s()}),r.addEventListener(`icegatheringstatechange`,o=function(){r.iceGatheringState===`complete`&&s()})})})}},{key:`_createDialog`,value:function(e,t,n){var r=t===`UAS`?e.to_tag:e.from_tag,i=t===`UAS`?e.from_tag:e.to_tag,a=e.call_id+r+i,o=this._earlyDialogs[a];if(n)return o?!0:(o=new T(this,e,t,T.C.STATUS_EARLY),o.error?(L.debug(o.error),this._failed(`remote`,e,y.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[a]=o,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,o)return o.update(e,t),this._dialog=o,delete this._earlyDialogs[a],!0;var s=new T(this,e,t);return s.error?(L.debug(s.error),this._failed(`remote`,e,y.causes.INTERNAL_ERROR),!1):(this._dialog=s,!0)}},{key:`_receiveReinvite`,value:function(e){var t=this;L.debug(`receiveReinvite()`);var n=e.hasHeader(`Content-Type`)?e.getHeader(`Content-Type`).toLowerCase():void 0,r={request:e,callback:void 0,reject:a.bind(this)},i=!1;function a(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||``,a=S.cloneArray(t.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw TypeError(`Invalid status_code: ${n}`);e.reply(n,r,a)}if(this.emit(`reinvite`,r),i)return;if(this._late_sdp=!1,!e.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold(`remote`)),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._createLocalDescription(`offer`,t._rtcOfferConstraints)}).then(function(e){o.call(t,e)}).catch(function(){e.reply(500)});return}if(n!==`application/sdp`){L.debug(`invalid Content-Type`),e.reply(415);return}this._processInDialogSdpOffer(e).then(function(e){t._status!==R.STATUS_TERMINATED&&o.call(t,e)}).catch(function(e){L.warn(e)});function o(t){var n=this,i=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(e,i),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,i,t,function(){n._status=R.STATUS_WAITING_FOR_ACK,n._setInvite2xxTimer(e,t),n._setACKTimer()}),typeof r.callback==`function`&&r.callback()}}},{key:`_receiveUpdate`,value:function(e){var t=this;L.debug(`receiveUpdate()`);var n=e.hasHeader(`Content-Type`)?e.getHeader(`Content-Type`).toLowerCase():void 0,r={request:e,callback:void 0,reject:a.bind(this)},i=!1;function a(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||``,a=S.cloneArray(t.extraHeaders);if(this._status!==R.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw TypeError(`Invalid status_code: ${n}`);e.reply(n,r,a)}if(this.emit(`update`,r),i)return;if(!e.body){o.call(this,null);return}if(n!==`application/sdp`){L.debug(`invalid Content-Type`),e.reply(415);return}this._processInDialogSdpOffer(e).then(function(e){t._status!==R.STATUS_TERMINATED&&o.call(t,e)}).catch(function(e){L.warn(e)});function o(t){var n=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(e,n),e.reply(200,null,n,t),typeof r.callback==`function`&&r.callback()}}},{key:`_processInDialogSdpOffer`,value:function(e){var t=this;L.debug(`_processInDialogSdpOffer()`);var n=e.parseSDP(),i=!1,a=r(n.media),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(B.indexOf(s.type)!==-1){var c=s.direction||n.direction||`sendrecv`;if(c===`sendonly`||c===`inactive`)i=!0;else{i=!1;break}}}}catch(e){a.e(e)}finally{a.f()}var l={originator:`remote`,type:`offer`,sdp:e.body};L.debug(`emit "sdp"`),this.emit(`sdp`,l);var u=new RTCSessionDescription({type:`offer`,sdp:l.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===R.STATUS_TERMINATED)throw Error(`terminated`);return t._connection.setRemoteDescription(u).catch(function(n){throw e.reply(488),L.warn(`emit "peerconnection:setremotedescriptionfailed" [error:%o]`,n),t.emit(`peerconnection:setremotedescriptionfailed`,n),n})}).then(function(){if(t._status===R.STATUS_TERMINATED)throw Error(`terminated`);t._remoteHold===!0&&i===!1?(t._remoteHold=!1,t._onunhold(`remote`)):t._remoteHold===!1&&i===!0&&(t._remoteHold=!0,t._onhold(`remote`))}).then(function(){if(t._status===R.STATUS_TERMINATED)throw Error(`terminated`);return t._createLocalDescription(`answer`,t._rtcAnswerConstraints).catch(function(t){throw e.reply(500),L.warn(`emit "peerconnection:createtelocaldescriptionfailed" [error:%o]`,t),t})}).catch(function(e){L.warn(`_processInDialogSdpOffer() failed [error: %o]`,e)}),this._connectionPromiseQueue}},{key:`_receiveRefer`,value:function(e){var t=this;if(L.debug(`receiveRefer()`),!e.refer_to){L.debug(`no Refer-To header field present in REFER`),e.reply(400);return}if(e.refer_to.uri.scheme!==y.SIP){L.debug(`Refer-To header field points to a non-SIP URI scheme`),e.reply(416);return}e.reply(202);var r=new j(this,e.cseq);L.debug(`emit "refer"`),this.emit(`refer`,{request:e,accept:function(e,n){i.call(t,e,n)},reject:function(){a.call(t)}});function i(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t=typeof t==`function`?t:null,this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;var a=new n(this._ua);if(a.on(`progress`,function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)}),a.on(`accepted`,function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)}),a.on(`_failed`,function(e){var t=e.message,n=e.cause;t?r.notify(t.status_code,t.reason_phrase):r.notify(487,n)}),e.refer_to.uri.hasHeader(`replaces`)){var o=decodeURIComponent(e.refer_to.uri.getHeader(`replaces`));i.extraHeaders=S.cloneArray(i.extraHeaders),i.extraHeaders.push(`Replaces: ${o}`)}a.connect(e.refer_to.uri.toAor(),i,t)}function a(){r.notify(603)}}},{key:`_receiveNotify`,value:function(e){switch(L.debug(`receiveNotify()`),e.event||e.reply(400),e.event.event){case`refer`:var t,n;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else if(Object.keys(this._referSubscribers).length===1)n=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{e.reply(400,`Missing event id parameter`);return}if(!n){e.reply(481,`Subscription does not exist`);return}n.receiveNotify(e),e.reply(200);break;default:e.reply(489)}}},{key:`_receiveReplaces`,value:function(e){var t=this;L.debug(`receiveReplaces()`);function r(t){var r=this;if(this._status!==R.STATUS_WAITING_FOR_ACK&&this._status!==R.STATUS_CONFIRMED)return!1;var i=new n(this._ua);i.on(`confirmed`,function(){r.terminate()}),i.init_incoming(e,t)}function i(){L.debug(`Replaced INVITE rejected by the user`),e.reply(486)}this.emit(`replaces`,{request:e,accept:function(e){r.call(t,e)},reject:function(){i.call(t)}})}},{key:`_sendInitialRequest`,value:function(e,t,n){var r=this,i=new E(this._ua,this._request,{onRequestTimeout:function(){r.onRequestTimeout()},onTransportError:function(){r.onTransportError()},onAuthenticated:function(e){r._request=e},onReceiveResponse:function(e){r._receiveInviteResponse(e)}});Promise.resolve().then(function(){if(n)return n;if(e.audio||e.video)return r._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).catch(function(e){throw r._status===R.STATUS_TERMINATED?Error(`terminated`):(r._failed(`local`,null,y.causes.USER_DENIED_MEDIA_ACCESS),L.warn(`emit "getusermediafailed" [error:%o]`,e),r.emit(`getusermediafailed`,e),e)})}).then(function(e){if(r._status===R.STATUS_TERMINATED)throw Error(`terminated`);return r._localMediaStream=e,e&&e.getTracks().forEach(function(t){r._connection.addTrack(t,e)}),r._connecting(r._request),r._createLocalDescription(`offer`,t).catch(function(e){throw r._failed(`local`,null,y.causes.WEBRTC_ERROR),e})}).then(function(e){if(r._is_canceled||r._status===R.STATUS_TERMINATED)throw Error(`terminated`);r._request.body=e,r._status=R.STATUS_INVITE_SENT,L.debug(`emit "sending" [request:%o]`,r._request),r.emit(`sending`,{request:r._request}),i.send()}).catch(function(e){r._status!==R.STATUS_TERMINATED&&L.warn(e)})}},{key:`_getDTMFRTPSender`,value:function(){var e=this._connection.getSenders().find(function(e){return e.track&&e.track.kind===`audio`});if(!(e&&e.dtmf)){L.warn(`sendDTMF() | no local audio track to send DTMF with`);return}return e.dtmf}},{key:`_receiveInviteResponse`,value:function(e){var t=this;if(L.debug(`receiveInviteResponse()`),this._dialog&&e.status_code>=200&&e.status_code<=299){if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag){this.sendRequest(y.ACK);return}var n=new T(this,e,`UAC`);if(n.error!==void 0){L.debug(n.error);return}this.sendRequest(y.ACK),this.sendRequest(y.BYE);return}if(this._is_canceled){e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e);return}if(this._status===R.STATUS_INVITE_SENT||this._status===R.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=R.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){L.debug(`1xx response received without to tag`);break}if(e.hasHeader(`contact`)&&!this._createDialog(e,`UAC`,!0))break;if(this._status=R.STATUS_1XX_RECEIVED,!e.body){this._progress(`remote`,e);break}var r={originator:`remote`,type:`answer`,sdp:e.body};L.debug(`emit "sdp"`),this.emit(`sdp`,r);var i=new RTCSessionDescription({type:`answer`,sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){return t._progress(`remote`,e)}).catch(function(e){L.warn(`emit "peerconnection:setremotedescriptionfailed" [error:%o]`,e),t.emit(`peerconnection:setremotedescriptionfailed`,e)});break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=R.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,y.causes.MISSING_SDP),this._failed(`remote`,e,y.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,`UAC`))break;var a={originator:`remote`,type:`answer`,sdp:e.body};L.debug(`emit "sdp"`),this.emit(`sdp`,a);var o=new RTCSessionDescription({type:`answer`,sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._connection.signalingState===`stable`)return t._connection.createOffer(t._rtcOfferConstraints).then(function(e){return t._connection.setLocalDescription(e)}).catch(function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed(`local`,e,y.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(o).then(function(){t._handleSessionTimersInIncomingResponse(e),t._accepted(`remote`,e),t.sendRequest(y.ACK),t._confirmed(`local`,null)}).catch(function(n){t._acceptAndTerminate(e,488,`Not Acceptable Here`),t._failed(`remote`,e,y.causes.BAD_MEDIA_DESCRIPTION),L.warn(`emit "peerconnection:setremotedescriptionfailed" [error:%o]`,n),t.emit(`peerconnection:setremotedescriptionfailed`,n)})});break;default:var s=S.sipErrorCause(e.status_code);this._failed(`remote`,e,s)}}},{key:`_sendReinvite`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};L.debug(`sendReinvite()`);var n=S.cloneArray(t.extraHeaders),r=S.cloneObject(t.eventHandlers),i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,a=!1;n.push(`Contact: ${this._contact}`),n.push(`Content-Type: application/sdp`),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?`uac`:`uas`}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription(`offer`,i)}).then(function(t){t=e._mangleOffer(t);var r={originator:`local`,type:`offer`,sdp:t};L.debug(`emit "sdp"`),e.emit(`sdp`,r),e.sendRequest(y.INVITE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){o.call(e,t),a=!0},onErrorResponse:function(t){s.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){s()});function o(e){var t=this;if(this._status!==R.STATUS_TERMINATED&&(this.sendRequest(y.ACK),!a)){if(this._handleSessionTimersInIncomingResponse(e),!e.body){s.call(this);return}if(!e.hasHeader(`Content-Type`)||e.getHeader(`Content-Type`).toLowerCase()!==`application/sdp`){s.call(this);return}var n={originator:`remote`,type:`answer`,sdp:e.body};L.debug(`emit "sdp"`),this.emit(`sdp`,n);var i=new RTCSessionDescription({type:`answer`,sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){s.call(t),L.warn(`emit "peerconnection:setremotedescriptionfailed" [error:%o]`,e),t.emit(`peerconnection:setremotedescriptionfailed`,e)})}}function s(e){r.failed&&r.failed(e)}}},{key:`_sendUpdate`,value:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};L.debug(`sendUpdate()`);var n=S.cloneArray(t.extraHeaders),r=S.cloneObject(t.eventHandlers),i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,a=t.sdpOffer||!1,o=!1;n.push(`Contact: ${this._contact}`),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?`uac`:`uas`}`),a?(n.push(`Content-Type: application/sdp`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription(`offer`,i)}).then(function(t){t=e._mangleOffer(t);var r={originator:`local`,type:`offer`,sdp:t};L.debug(`emit "sdp"`),e.emit(`sdp`,r),e.sendRequest(y.UPDATE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){s.call(e,t),o=!0},onErrorResponse:function(t){c.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){c.call(e)})):this.sendRequest(y.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:function(t){s.call(e,t)},onErrorResponse:function(t){c.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}});function s(e){var t=this;if(this._status!==R.STATUS_TERMINATED&&!o){if(this._handleSessionTimersInIncomingResponse(e),a){if(!e.body){c.call(this);return}if(!e.hasHeader(`Content-Type`)||e.getHeader(`Content-Type`).toLowerCase()!==`application/sdp`){c.call(this);return}var n={originator:`remote`,type:`answer`,sdp:e.body};L.debug(`emit "sdp"`),this.emit(`sdp`,n);var i=new RTCSessionDescription({type:`answer`,sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){c.call(t),L.warn(`emit "peerconnection:setremotedescriptionfailed" [error:%o]`,e),t.emit(`peerconnection:setremotedescriptionfailed`,e)})}else r.succeeded&&r.succeeded(e)}}function c(e){r.failed&&r.failed(e)}}},{key:`_acceptAndTerminate`,value:function(e,t,n){L.debug(`acceptAndTerminate()`);var r=[];t&&(n=n||y.REASON_PHRASE[t]||``,r.push(`Reason: SIP ;cause=${t}; text="${n}"`)),(this._dialog||this._createDialog(e,`UAC`))&&(this.sendRequest(y.ACK),this.sendRequest(y.BYE,{extraHeaders:r})),this._status=R.STATUS_TERMINATED}},{key:`_mangleOffer`,value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=_.parse(e),this._localHold&&!this._remoteHold){L.debug(`mangleOffer() | me on hold, mangling offer`);var t=r(e.media),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;B.indexOf(i.type)!==-1&&(i.direction?i.direction===`sendrecv`?i.direction=`sendonly`:i.direction===`recvonly`&&(i.direction=`inactive`):i.direction=`sendonly`)}}catch(e){t.e(e)}finally{t.f()}}else if(this._localHold&&this._remoteHold){L.debug(`mangleOffer() | both on hold, mangling offer`);var a=r(e.media),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;B.indexOf(s.type)!==-1&&(s.direction=`inactive`)}}catch(e){a.e(e)}finally{a.f()}}else if(this._remoteHold){L.debug(`mangleOffer() | remote on hold, mangling offer`);var c=r(e.media),l;try{for(c.s();!(l=c.n()).done;){var u=l.value;B.indexOf(u.type)!==-1&&(u.direction?u.direction===`sendrecv`?u.direction=`recvonly`:u.direction===`recvonly`&&(u.direction=`inactive`):u.direction=`recvonly`)}}catch(e){c.e(e)}finally{c.f()}}return _.write(e)}},{key:`_setLocalMediaStatus`,value:function(){var e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toggleMuteAudio(!e),this._toggleMuteVideo(!t)}},{key:`_handleSessionTimersInIncomingRequest`,value:function(e,t){if(this._sessionTimers.enabled){var n;e.session_expires&&e.session_expires>=y.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||`uas`):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n=`uas`),t.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${n}`),this._sessionTimers.refresher=n===`uas`,this._runSessionTimer()}}},{key:`_handleSessionTimersInIncomingResponse`,value:function(e){if(this._sessionTimers.enabled){var t;e.session_expires&&e.session_expires>=y.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||`uac`):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t=`uac`),this._sessionTimers.refresher=t===`uac`,this._runSessionTimer()}}},{key:`_runSessionTimer`,value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){e._status!==R.STATUS_TERMINATED&&e._isReadyToReOffer()&&(L.debug(`runSessionTimer() | sending session refresh request`),e._sessionTimers.refreshMethod===y.UPDATE?e._sendUpdate():e._sendReinvite())},t*500):this._sessionTimers.timer=setTimeout(function(){e._status!==R.STATUS_TERMINATED&&(L.warn(`runSessionTimer() | timer expired, terminating the session`),e.terminate({cause:y.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:`Session Timer Expired`}))},t*1100)}},{key:`_toggleMuteAudio`,value:function(e){var t=r(this._connection.getSenders().filter(function(e){return e.track&&e.track.kind===`audio`})),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;i.track.enabled=!e}}catch(e){t.e(e)}finally{t.f()}}},{key:`_toggleMuteVideo`,value:function(e){var t=r(this._connection.getSenders().filter(function(e){return e.track&&e.track.kind===`video`})),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;i.track.enabled=!e}}catch(e){t.e(e)}finally{t.f()}}},{key:`_newRTCSession`,value:function(e,t){L.debug(`newRTCSession()`),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:`_connecting`,value:function(e){L.debug(`session connecting`),L.debug(`emit "connecting"`),this.emit(`connecting`,{request:e})}},{key:`_progress`,value:function(e,t){L.debug(`session progress`),L.debug(`emit "progress"`),this.emit(`progress`,{originator:e,response:t||null})}},{key:`_accepted`,value:function(e,t){L.debug(`session accepted`),this._start_time=new Date,L.debug(`emit "accepted"`),this.emit(`accepted`,{originator:e,response:t||null})}},{key:`_confirmed`,value:function(e,t){L.debug(`session confirmed`),this._is_confirmed=!0,L.debug(`emit "confirmed"`),this.emit(`confirmed`,{originator:e,ack:t||null})}},{key:`_ended`,value:function(e,t,n){L.debug(`session ended`),this._end_time=new Date,this._close(),L.debug(`emit "ended"`),this.emit(`ended`,{originator:e,message:t||null,cause:n})}},{key:`_failed`,value:function(e,t,n){L.debug(`session failed`),L.debug(`emit "_failed"`),this.emit(`_failed`,{originator:e,message:t||null,cause:n}),this._close(),L.debug(`emit "failed"`),this.emit(`failed`,{originator:e,message:t||null,cause:n})}},{key:`_onhold`,value:function(e){L.debug(`session onhold`),this._setLocalMediaStatus(),L.debug(`emit "hold"`),this.emit(`hold`,{originator:e})}},{key:`_onunhold`,value:function(e){L.debug(`session onunhold`),this._setLocalMediaStatus(),L.debug(`emit "unhold"`),this.emit(`unhold`,{originator:e})}},{key:`_onmute`,value:function(e){var t=e.audio,n=e.video;L.debug(`session onmute`),this._setLocalMediaStatus(),L.debug(`emit "muted"`),this.emit(`muted`,{audio:t,video:n})}},{key:`_onunmute`,value:function(e){var t=e.audio,n=e.video;L.debug(`session onunmute`),this._setLocalMediaStatus(),L.debug(`emit "unmuted"`),this.emit(`unmuted`,{audio:t,video:n})}},{key:`C`,get:function(){return R}},{key:`causes`,get:function(){return y.causes}},{key:`id`,get:function(){return this._id}},{key:`connection`,get:function(){return this._connection}},{key:`contact`,get:function(){return this._contact}},{key:`direction`,get:function(){return this._direction}},{key:`local_identity`,get:function(){return this._local_identity}},{key:`remote_identity`,get:function(){return this._remote_identity}},{key:`start_time`,get:function(){return this._start_time}},{key:`end_time`,get:function(){return this._end_time}},{key:`data`,get:function(){return this._data},set:function(e){this._data=e}},{key:`status`,get:function(){return this._status}}]),n}(g)})),ue=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=V(),_=P(),v=W(),y=A(),b=N(),x=new m(`Message`);t.exports=function(e){o(n,e);var t=c(n);function n(e){var i;return r(this,n),i=t.call(this),i._ua=e,i._request=null,i._closed=!1,i._direction=null,i._local_identity=null,i._remote_identity=null,i._is_replied=!1,i._data={},i}return a(n,[{key:`send`,value:function(e,t){var n=this,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=e;if(e===void 0||t===void 0)throw TypeError(`Not enough arguments`);if(e=this._ua.normalizeTarget(e),!e)throw TypeError(`Invalid target: ${i}`);var a=_.cloneArray(r.extraHeaders),o=_.cloneObject(r.eventHandlers),s=r.contentType||`text/plain`,c={};for(var l in r.fromUserName&&(c.from_uri=new b(`sip`,r.fromUserName,this._ua.configuration.uri.host),a.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),r.fromDisplayName&&(c.from_display_name=r.fromDisplayName),o)Object.prototype.hasOwnProperty.call(o,l)&&this.on(l,o[l]);a.push(`Content-Type: ${s}`),this._request=new g.OutgoingRequest(h.MESSAGE,e,this._ua,c,a),t&&(this._request.body=t);var u=new v(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage(`local`,this._request),u.send()}},{key:`init_incoming`,value:function(e){this._request=e,this._newMessage(`remote`,e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:`accept`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=_.cloneArray(e.extraHeaders),n=e.body;if(this._direction!==`incoming`)throw new y.NotSupportedError(`"accept" not supported for outgoing Message`);if(this._is_replied)throw Error(`incoming Message already replied`);this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:`reject`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=_.cloneArray(e.extraHeaders),i=e.body;if(this._direction!==`incoming`)throw new y.NotSupportedError(`"reject" not supported for outgoing Message`);if(this._is_replied)throw Error(`incoming Message already replied`);if(t<300||t>=700)throw TypeError(`Invalid status_code: ${t}`);this._is_replied=!0,this._request.reply(t,n,r,i)}},{key:`_receiveResponse`,value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded(`remote`,e);break;default:var t=_.sipErrorCause(e.status_code);this._failed(`remote`,e,t)}}},{key:`_onRequestTimeout`,value:function(){this._closed||this._failed(`system`,null,h.causes.REQUEST_TIMEOUT)}},{key:`_onTransportError`,value:function(){this._closed||this._failed(`system`,null,h.causes.CONNECTION_ERROR)}},{key:`_close`,value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:`_newMessage`,value:function(e,t){e===`remote`?(this._direction=`incoming`,this._local_identity=t.to,this._remote_identity=t.from):e===`local`&&(this._direction=`outgoing`,this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}},{key:`_failed`,value:function(e,t,n){x.debug(`MESSAGE failed`),this._close(),x.debug(`emit "failed"`),this.emit(`failed`,{originator:e,response:t||null,cause:n})}},{key:`_succeeded`,value:function(e,t){x.debug(`MESSAGE succeeded`),this._close(),x.debug(`emit "succeeded"`),this.emit(`succeeded`,{originator:e,response:t})}},{key:`direction`,get:function(){return this._direction}},{key:`local_identity`,get:function(){return this._local_identity}},{key:`remote_identity`,get:function(){return this._remote_identity}}]),n}(p)})),de=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=V(),_=P(),v=W(),y=A(),b=new m(`Options`);t.exports=function(e){o(n,e);var t=c(n);function n(e){var i;return r(this,n),i=t.call(this),i._ua=e,i._request=null,i._closed=!1,i._direction=null,i._local_identity=null,i._remote_identity=null,i._is_replied=!1,i._data={},i}return a(n,[{key:`send`,value:function(e,t){var n=this,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=e;if(e===void 0)throw TypeError(`A target is required for OPTIONS`);if(e=this._ua.normalizeTarget(e),!e)throw TypeError(`Invalid target: ${i}`);var a=_.cloneArray(r.extraHeaders),o=_.cloneObject(r.eventHandlers),s=r.contentType||`application/sdp`;for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&this.on(c,o[c]);a.push(`Content-Type: ${s}`),this._request=new g.OutgoingRequest(h.OPTIONS,e,this._ua,null,a),t&&(this._request.body=t);var l=new v(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newOptions(`local`,this._request),l.send()}},{key:`init_incoming`,value:function(e){this._request=e,this._newOptions(`remote`,e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:`accept`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=_.cloneArray(e.extraHeaders),n=e.body;if(this._direction!==`incoming`)throw new y.NotSupportedError(`"accept" not supported for outgoing Options`);if(this._is_replied)throw Error(`incoming Options already replied`);this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:`reject`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=_.cloneArray(e.extraHeaders),i=e.body;if(this._direction!==`incoming`)throw new y.NotSupportedError(`"reject" not supported for outgoing Options`);if(this._is_replied)throw Error(`incoming Options already replied`);if(t<300||t>=700)throw TypeError(`Invalid status_code: ${t}`);this._is_replied=!0,this._request.reply(t,n,r,i)}},{key:`_receiveResponse`,value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded(`remote`,e);break;default:var t=_.sipErrorCause(e.status_code);this._failed(`remote`,e,t)}}},{key:`_onRequestTimeout`,value:function(){this._closed||this._failed(`system`,null,h.causes.REQUEST_TIMEOUT)}},{key:`_onTransportError`,value:function(){this._closed||this._failed(`system`,null,h.causes.CONNECTION_ERROR)}},{key:`_close`,value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:`_newOptions`,value:function(e,t){e===`remote`?(this._direction=`incoming`,this._local_identity=t.to,this._remote_identity=t.from):e===`local`&&(this._direction=`outgoing`,this._local_identity=t.from,this._remote_identity=t.to),this._ua.newOptions(this,{originator:e,message:this,request:t})}},{key:`_failed`,value:function(e,t,n){b.debug(`OPTIONS failed`),this._close(),b.debug(`emit "failed"`),this.emit(`failed`,{originator:e,response:t||null,cause:n})}},{key:`_succeeded`,value:function(e,t){b.debug(`OPTIONS succeeded`),this._close(),b.debug(`emit "succeeded"`),this.emit(`succeeded`,{originator:e,response:t})}},{key:`direction`,get:function(){return this._direction}},{key:`local_identity`,get:function(){return this._local_identity}},{key:`remote_identity`,get:function(){return this._remote_identity}}]),n}(p)})),fe=s((e=>{var t=z(),n=P(),r=M(),i=new t(`Socket`);e.isSocket=function(e){if(Array.isArray(e))return!1;if(e===void 0)return i.warn(`undefined JsSIP.Socket instance`),!1;try{if(!n.isString(e.url))throw i.warn(`missing or invalid JsSIP.Socket url property`),Error(`Missing or invalid JsSIP.Socket url property`);if(!n.isString(e.via_transport))throw i.warn(`missing or invalid JsSIP.Socket via_transport property`),Error(`Missing or invalid JsSIP.Socket via_transport property`);if(r.parse(e.sip_uri,`SIP_URI`)===-1)throw i.warn(`missing or invalid JsSIP.Socket sip_uri property`),Error(`missing or invalid JsSIP.Socket sip_uri property`)}catch{return!1}try{[`connect`,`disconnect`,`send`].forEach(function(t){if(!n.isFunction(e[t]))throw i.warn(`missing or invalid JsSIP.Socket method: ${t}`),Error(`Missing or invalid JsSIP.Socket method: ${t}`)})}catch{return!1}return!0}})),pe=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=fe(),s=k(),c=new a(`Transport`),l={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:s.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:s.CONNECTION_RECOVERY_MAX_INTERVAL}};t.exports=function(){function e(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:l.recovery_options;n(this,e),c.debug(`new()`),this.status=l.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=r,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder(`utf8`)}catch(e){c.warn(`cannot use TextDecoder: ${e}`)}if(t===void 0)throw TypeError(`Invalid argument. undefined 'sockets' argument`);t instanceof Array||(t=[t]),t.forEach(function(e){if(!o.isSocket(e.socket))throw TypeError(`Invalid argument. invalid 'JsSIP.Socket' instance`);if(e.weight&&!Number(e.weight))throw TypeError(`Invalid argument. 'weight' attribute is not a number`);this.sockets.push({socket:e.socket,weight:e.weight||0,status:l.SOCKET_STATUS_READY})},this),this._getSocket()}return i(e,[{key:`connect`,value:function(){if(c.debug(`connect()`),this.isConnected()){c.debug(`Transport is already connected`);return}if(this.isConnecting()){c.debug(`Transport is connecting`);return}this.close_requested=!1,this.status=l.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect())}},{key:`disconnect`,value:function(){c.debug(`close()`),this.close_requested=!0,this.recover_attempts=0,this.status=l.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}},{key:`send`,value:function(e){if(c.debug(`send()`),!this.isConnected())return c.warn(`unable to send message, transport is not connected`),!1;var t=e.toString();return c.debug(`sending message:
|
|
51
|
+
|
|
52
|
+
${t}
|
|
53
|
+
`),this.socket.send(t)}},{key:`isConnected`,value:function(){return this.status===l.STATUS_CONNECTED}},{key:`isConnecting`,value:function(){return this.status===l.STATUS_CONNECTING}},{key:`_reconnect`,value:function(){var e=this;this.recover_attempts+=1;var t=Math.floor(Math.random()*2**this.recover_attempts+1);t<this.recovery_options.min_interval?t=this.recovery_options.min_interval:t>this.recovery_options.max_interval&&(t=this.recovery_options.max_interval),c.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${t} seconds`),this.recovery_timer=setTimeout(function(){!e.close_requested&&!(e.isConnected()||e.isConnecting())&&(e._getSocket(),e.connect())},t*1e3)}},{key:`_getSocket`,value:function(){var e=[];if(this.sockets.forEach(function(t){t.status!==l.SOCKET_STATUS_ERROR&&(e.length===0?e.push(t):t.weight>e[0].weight?e=[t]:t.weight===e[0].weight&&e.push(t))}),e.length===0){this.sockets.forEach(function(e){e.status=l.SOCKET_STATUS_READY}),this._getSocket();return}var t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}},{key:`_onConnect`,value:function(){this.recover_attempts=0,this.status=l.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:`_onDisconnect`,value:function(e,t,n){this.status=l.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:n}),!this.close_requested&&(this.sockets.forEach(function(e){this.socket===e.socket&&(e.status=l.SOCKET_STATUS_ERROR)},this),this._reconnect(e))}},{key:`_onData`,value:function(e){if(e===`\r
|
|
54
|
+
\r
|
|
55
|
+
`){c.debug(`received message with double-CRLF Keep Alive request`);try{this.socket.send(`\r
|
|
56
|
+
`)}catch(e){c.warn(`error sending Keep Alive response: ${e}`)}return}if(e===`\r
|
|
57
|
+
`){c.debug(`received message with CRLF Keep Alive response`);return}if(typeof e!=`string`){try{e=this.textDecoder?this.textDecoder.decode(e):String.fromCharCode.apply(null,new Uint8Array(e))}catch{c.debug(`received binary message failed to be converted into string, message discarded`);return}c.debug(`received binary message:
|
|
58
|
+
|
|
59
|
+
${e}
|
|
60
|
+
`)}else c.debug(`received text message:
|
|
61
|
+
|
|
62
|
+
${e}
|
|
63
|
+
`);this.ondata({transport:this,message:e})}},{key:`via_transport`,get:function(){return this.socket.via_transport}},{key:`url`,get:function(){return this.socket.url}},{key:`sip_uri`,get:function(){return this.socket.sip_uri}}]),e}()})),me=s((e=>{function t(e,t){var r;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(r=n(e))||t&&e&&typeof e.length==`number`){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
64
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw c}}}}function n(e,t){if(e){if(typeof e==`string`)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}}function r(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var i=z(),a=M(),o=V(),s=new i(`Parser`);e.parseMessage=function(e,t){var n,r,i=e.indexOf(`\r
|
|
65
|
+
`);if(i===-1){s.warn(`parseMessage() | no CRLF found, not a SIP message`);return}var u=e.substring(0,i),d=a.parse(u,`Request_Response`);if(d===-1){s.warn(`parseMessage() | error parsing first line of SIP message: "${u}"`);return}d.status_code?(n=new o.IncomingResponse,n.status_code=d.status_code,n.reason_phrase=d.reason_phrase):(n=new o.IncomingRequest(t),n.method=d.method,n.ruri=d.uri),n.data=e;for(var f=i+2;;){if(i=c(e,f),i===-2){r=f+2;break}if(i===-1){s.warn(`parseMessage() | malformed message`);return}if(d=l(n,e,f,i),d!==!0){s.warn(`parseMessage() |`,d.error);return}f=i+2}if(n.hasHeader(`content-length`)){var p=n.getHeader(`content-length`);n.body=e.substr(r,p)}else n.body=e.substring(r);return n};function c(e,t){var n=t,r=0,i=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;r===0;){if(i=e.indexOf(`\r
|
|
66
|
+
`,n),i===-1)return i;!e.substring(i+2,i+4).match(/(^\r\n)/)&&e.charAt(i+2).match(/(^\s+)/)?n=i+2:r=i}return r}function l(e,n,r,i){var s,c=n.indexOf(`:`,r),l=n.substring(r,c).trim(),u=n.substring(c+1,i).trim();switch(l.toLowerCase()){case`via`:case`v`:e.addHeader(`via`,u),e.getHeaders(`via`).length===1?(s=e.parseHeader(`Via`),s&&(e.via=s,e.via_branch=s.branch)):s=0;break;case`from`:case`f`:e.setHeader(`from`,u),s=e.parseHeader(`from`),s&&(e.from=s,e.from_tag=s.getParam(`tag`));break;case`to`:case`t`:e.setHeader(`to`,u),s=e.parseHeader(`to`),s&&(e.to=s,e.to_tag=s.getParam(`tag`));break;case`record-route`:if(s=a.parse(u,`Record_Route`),s===-1)s=void 0;else{var d=t(s),f;try{for(d.s();!(f=d.n()).done;){var p=f.value;e.addHeader(`record-route`,u.substring(p.possition,p.offset)),e.headers[`Record-Route`][e.getHeaders(`record-route`).length-1].parsed=p.parsed}}catch(e){d.e(e)}finally{d.f()}}break;case`call-id`:case`i`:e.setHeader(`call-id`,u),s=e.parseHeader(`call-id`),s&&(e.call_id=u);break;case`contact`:case`m`:if(s=a.parse(u,`Contact`),s===-1)s=void 0;else{var m=t(s),h;try{for(m.s();!(h=m.n()).done;){var g=h.value;e.addHeader(`contact`,u.substring(g.possition,g.offset)),e.headers.Contact[e.getHeaders(`contact`).length-1].parsed=g.parsed}}catch(e){m.e(e)}finally{m.f()}}break;case`content-length`:case`l`:e.setHeader(`content-length`,u),s=e.parseHeader(`content-length`);break;case`content-type`:case`c`:e.setHeader(`content-type`,u),s=e.parseHeader(`content-type`);break;case`cseq`:e.setHeader(`cseq`,u),s=e.parseHeader(`cseq`),s&&(e.cseq=s.value),e instanceof o.IncomingResponse&&(e.method=s.method);break;case`max-forwards`:e.setHeader(`max-forwards`,u),s=e.parseHeader(`max-forwards`);break;case`www-authenticate`:e.setHeader(`www-authenticate`,u),s=e.parseHeader(`www-authenticate`);break;case`proxy-authenticate`:e.setHeader(`proxy-authenticate`,u),s=e.parseHeader(`proxy-authenticate`);break;case`session-expires`:case`x`:e.setHeader(`session-expires`,u),s=e.parseHeader(`session-expires`),s&&(e.session_expires=s.expires,e.session_expires_refresher=s.refresher);break;case`refer-to`:case`r`:e.setHeader(`refer-to`,u),s=e.parseHeader(`refer-to`),s&&(e.refer_to=s);break;case`replaces`:e.setHeader(`replaces`,u),s=e.parseHeader(`replaces`),s&&(e.replaces=s);break;case`event`:case`o`:e.setHeader(`event`,u),s=e.parseHeader(`event`),s&&(e.event=s);break;default:e.addHeader(l,u),s=0}return s!==void 0||{error:`error parsing header "${l}"`}}})),he=s(((e,t)=>{function n(e,t){var n;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(n=r(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
67
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&n.return!=null&&n.return()}finally{if(s)throw c}}}}function r(e,t){if(e){if(typeof e==`string`)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}}function i(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var a=z(),o=k(),s=V(),c=P(),l=new a(`sanityCheck`),u=[S],d=[g,_,v,y],f=[b,x],p,m,h;t.exports=function(e,t,r){p=e,m=t,h=r;var i=n(u),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(o()===!1)return!1}}catch(e){i.e(e)}finally{i.f()}if(p instanceof s.IncomingRequest){var c=n(d),l;try{for(c.s();!(l=c.n()).done;){var g=l.value;if(g()===!1)return!1}}catch(e){c.e(e)}finally{c.f()}}else if(p instanceof s.IncomingResponse){var _=n(f),v;try{for(_.s();!(v=_.n()).done;){var y=v.value;if(y()===!1)return!1}}catch(e){_.e(e)}finally{_.f()}}return!0};function g(){if(p.s(`to`).uri.scheme!==`sip`)return C(416),!1}function _(){if(!p.to_tag&&p.call_id.substr(0,5)===m.configuration.jssip_id)return C(482),!1}function v(){if(c.str_utf8_length(p.body)<p.getHeader(`content-length`))return C(400),!1}function y(){var e=p.from_tag,t=p.call_id,n=p.cseq,r;if(!p.to_tag){if(p.method===o.INVITE){if(m._transactions.ist[p.via_branch])return!1;for(var i in m._transactions.ist)if(Object.prototype.hasOwnProperty.call(m._transactions.ist,i)&&(r=m._transactions.ist[i],r.request.from_tag===e&&r.request.call_id===t&&r.request.cseq===n))return C(482),!1}else if(m._transactions.nist[p.via_branch])return!1;else for(var a in m._transactions.nist)if(Object.prototype.hasOwnProperty.call(m._transactions.nist,a)&&(r=m._transactions.nist[a],r.request.from_tag===e&&r.request.call_id===t&&r.request.cseq===n))return C(482),!1}}function b(){if(p.getHeaders(`via`).length>1)return l.debug(`more than one Via header field present in the response, dropping the response`),!1}function x(){if(c.str_utf8_length(p.body)<p.getHeader(`content-length`))return l.debug(`message body length is lower than the value in Content-Length header field, dropping the response`),!1}function S(){for(var e=[`from`,`to`,`call_id`,`cseq`,`via`],t=0,n=e;t<n.length;t++){var r=n[t];if(!p.hasHeader(r))return l.debug(`missing mandatory header field : ${r}, dropping the response`),!1}}function C(e){var t=p.getHeaders(`via`),r,i=`SIP/2.0 ${e} ${o.REASON_PHRASE[e]}\r
|
|
68
|
+
`,a=n(t),s;try{for(a.s();!(s=a.n()).done;){var l=s.value;i+=`Via: ${l}\r
|
|
69
|
+
`}}catch(e){a.e(e)}finally{a.f()}r=p.getHeader(`To`),p.to_tag||(r+=`;tag=${c.newTag()}`),i+=`To: ${r}\r
|
|
70
|
+
`,i+=`From: ${p.getHeader(`From`)}\r
|
|
71
|
+
`,i+=`Call-ID: ${p.call_id}\r
|
|
72
|
+
`,i+=`CSeq: ${p.cseq} ${p.method}\r
|
|
73
|
+
`,i+=`\r
|
|
74
|
+
`,h.send(i)}})),ge=s((e=>{function t(e,t){var r;if(typeof Symbol>`u`||e[Symbol.iterator]==null){if(Array.isArray(e)||(r=n(e))||t&&e&&typeof e.length==`number`){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
75
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw c}}}}function n(e,t){if(e){if(typeof e==`string`)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}}function r(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var i=P(),a=k(),o=M(),s=N(),c=fe(),l=A();e.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:a.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:a.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:a.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${i.createRandomToken(12)}.invalid`};var u={mandatory:{sockets:function(e){var n=[];if(c.isSocket(e))n.push({socket:e});else if(Array.isArray(e)&&e.length){var r=t(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;Object.prototype.hasOwnProperty.call(a,`socket`)&&c.isSocket(a.socket)?n.push(a):c.isSocket(a)&&n.push({socket:a})}}catch(e){r.e(e)}finally{r.f()}}else return;return n},uri:function(e){/^sip:/i.test(e)||(e=`${a.SIP}:${e}`);var t=s.parse(e);if(t&&t.user)return t}},optional:{authorization_user:function(e){if(o.parse(`"${e}"`,`quoted_string`)!==-1)return e},authorization_jwt:function(e){if(typeof e==`string`)return e},user_agent:function(e){if(typeof e==`string`)return e},connection_recovery_max_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},connection_recovery_min_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if(typeof e==`string`){var t=o.parse(e,`SIP_URI`);if(t!==-1)return t}},display_name:function(e){return e},instance_id:function(e){if(/^uuid:/i.test(e)&&(e=e.substr(5)),o.parse(e,`uuid`)!==-1)return e},no_answer_timeout:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if(typeof e==`boolean`)return e},session_timers_refresh_method:function(e){if(typeof e==`string`&&(e=e.toUpperCase(),e===a.INVITE||e===a.UPDATE))return e},session_timers_force_refresher:function(e){if(typeof e==`boolean`)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if(typeof e==`boolean`)return e},register_expires:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=`${a.SIP}:${e}`);var t=s.parse(e);if(t&&!t.user)return t},use_preloaded_route:function(e){if(typeof e==`boolean`)return e},extra_headers:function(e){var n=[];if(Array.isArray(e)&&e.length){var r=t(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;typeof a==`string`&&n.push(a)}}catch(e){r.e(e)}finally{r.f()}}else return;return n}}};e.load=function(e,t){for(var n in u.mandatory)if(t.hasOwnProperty(n)){var r=t[n],a=u.mandatory[n](r);if(a!==void 0)e[n]=a;else throw new l.ConfigurationError(n,r)}else throw new l.ConfigurationError(n);for(var o in u.optional)if(t.hasOwnProperty(o)){var s=t[o];if(i.isEmpty(s))continue;var c=u.optional[o](s);if(c!==void 0)e[o]=c;else throw new l.ConfigurationError(o,s)}}})),_e=s(((e,t)=>{function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function c(e){var t=d();return function(){var n=f(e),r;if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function l(e,t){return t&&(n(t)===`object`||typeof t==`function`)?t:u(e)}function u(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function d(){if(typeof Reflect>`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var p=F().EventEmitter,m=z(),h=k(),g=ie(),_=le(),v=ue(),y=de(),b=U(),x=pe(),S=P(),C=A(),w=N(),T=me(),E=V(),D=he(),O=ge(),j=new m(`UA`),M={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};t.exports=function(e){o(n,e);var t=c(n);a(n,null,[{key:`C`,get:function(){return M}}]);function n(e){var i;if(r(this,n),j.debug(`new() [configuration:%o]`,e),i=t.call(this),i._cache={credentials:{}},i._configuration=Object.assign({},O.settings),i._dynConfiguration={},i._dialogs={},i._applicants={},i._sessions={},i._transport=null,i._contact=null,i._status=M.STATUS_INIT,i._error=null,i._transactions={nist:{},nict:{},ist:{},ict:{}},i._data={},i._closeTimer=null,e===void 0)throw TypeError(`Not enough arguments`);try{i._loadConfig(e)}catch(e){throw i._status=M.STATUS_NOT_READY,i._error=M.CONFIGURATION_ERROR,e}return i._registrator=new g(u(i)),i}return a(n,[{key:`start`,value:function(){j.debug(`start()`),this._status===M.STATUS_INIT?this._transport.connect():this._status===M.STATUS_USER_CLOSED?(j.debug(`restarting UA`),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=M.STATUS_INIT,this._transport.connect()):this._status===M.STATUS_READY?j.debug(`UA is in READY status, not restarted`):j.debug(`ERROR: connection is down, Auto-Recovery system is trying to reconnect`),this._dynConfiguration.register=this._configuration.register}},{key:`register`,value:function(){j.debug(`register()`),this._dynConfiguration.register=!0,this._registrator.register()}},{key:`unregister`,value:function(e){j.debug(`unregister()`),this._dynConfiguration.register=!1,this._registrator.unregister(e)}},{key:`registrator`,value:function(){return this._registrator}},{key:`isRegistered`,value:function(){return this._registrator.registered}},{key:`isConnected`,value:function(){return this._transport.isConnected()}},{key:`call`,value:function(e,t){j.debug(`call()`);var n=new _(this);return n.connect(e,t),n}},{key:`sendMessage`,value:function(e,t,n){j.debug(`sendMessage()`);var r=new v(this);return r.send(e,t,n),r}},{key:`sendOptions`,value:function(e,t,n){j.debug(`sendOptions()`);var r=new y(this);return r.send(e,t,n),r}},{key:`terminateSessions`,value:function(e){for(var t in j.debug(`terminateSessions()`),this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(e)}},{key:`stop`,value:function(){var e=this;if(j.debug(`stop()`),this._dynConfiguration={},this._status===M.STATUS_USER_CLOSED){j.debug(`UA already closed`);return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var n in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,n)){j.debug(`closing session ${n}`);try{this._sessions[n].terminate()}catch{}}for(var r in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,r))try{this._applicants[r].close()}catch{}this._status=M.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&&t===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){e._closeTimer=null,e._transport.disconnect()},2e3)}},{key:`normalizeTarget`,value:function(e){return S.normalizeTarget(e,this._configuration.hostport_params)}},{key:`get`,value:function(e){switch(e){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:j.warn(`get() | cannot get "%s" parameter in runtime`,e);return}}},{key:`set`,value:function(e,t){switch(e){case`authorization_user`:this._configuration.authorization_user=String(t);break;case`password`:this._configuration.password=String(t);break;case`realm`:this._configuration.realm=String(t);break;case`ha1`:this._configuration.ha1=String(t),this._configuration.password=null;break;case`authorization_jwt`:this._configuration.authorization_jwt=String(t);break;case`display_name`:this._configuration.display_name=t;break;case`extra_headers`:this._configuration.extra_headers=t;break;default:return j.warn(`set() | cannot set "%s" parameter in runtime`,e),!1}return!0}},{key:`newTransaction`,value:function(e){this._transactions[e.type][e.id]=e,this.emit(`newTransaction`,{transaction:e})}},{key:`destroyTransaction`,value:function(e){delete this._transactions[e.type][e.id],this.emit(`transactionDestroyed`,{transaction:e})}},{key:`newDialog`,value:function(e){this._dialogs[e.id]=e}},{key:`destroyDialog`,value:function(e){delete this._dialogs[e.id]}},{key:`newMessage`,value:function(e,t){this._applicants[e]=e,this.emit(`newMessage`,t)}},{key:`newOptions`,value:function(e,t){this._applicants[e]=e,this.emit(`newOptions`,t)}},{key:`destroyMessage`,value:function(e){delete this._applicants[e]}},{key:`newRTCSession`,value:function(e,t){this._sessions[e.id]=e,this.emit(`newRTCSession`,t)}},{key:`destroyRTCSession`,value:function(e){delete this._sessions[e.id]}},{key:`registered`,value:function(e){this.emit(`registered`,e)}},{key:`unregistered`,value:function(e){this.emit(`unregistered`,e)}},{key:`registrationFailed`,value:function(e){this.emit(`registrationFailed`,e)}},{key:`receiveRequest`,value:function(e){var t=e.method;if(e.ruri.user!==this._configuration.uri.user&&e.ruri.user!==this._contact.uri.user){j.debug(`Request-URI does not point to us`),e.method!==h.ACK&&e.reply_sl(404);return}if(e.ruri.scheme===h.SIPS){e.reply_sl(416);return}if(!b.checkTransaction(this,e)){if(t===h.INVITE?new b.InviteServerTransaction(this,this._transport,e):t!==h.ACK&&t!==h.CANCEL&&new b.NonInviteServerTransaction(this,this._transport,e),t===h.OPTIONS){if(this.listeners(`newOptions`).length===0){e.reply(200);return}new y(this).init_incoming(e)}else if(t===h.MESSAGE){if(this.listeners(`newMessage`).length===0){e.reply(405);return}new v(this).init_incoming(e)}else if(t===h.INVITE&&!e.to_tag&&this.listeners(`newRTCSession`).length===0){e.reply(405);return}var n,r;if(e.to_tag)n=this._findDialog(e.call_id,e.from_tag,e.to_tag),n?n.receiveRequest(e):t===h.NOTIFY?(r=this._findSession(e),r?r.receiveRequest(e):(j.debug(`received NOTIFY request for a non existent subscription`),e.reply(481,`Subscription does not exist`))):t!==h.ACK&&e.reply(481);else switch(t){case h.INVITE:if(window.RTCPeerConnection){if(e.hasHeader(`replaces`)){var i=e.replaces;n=this._findDialog(i.call_id,i.from_tag,i.to_tag),n?(r=n.owner,r.isEnded()?e.reply(603):r.receiveRequest(e)):e.reply(481)}else r=new _(this),r.init_incoming(e)}else j.warn(`INVITE received but WebRTC is not supported`),e.reply(488);break;case h.BYE:e.reply(481);break;case h.CANCEL:r=this._findSession(e),r?r.receiveRequest(e):j.debug(`received CANCEL request for a non existent session`);break;case h.ACK:break;case h.NOTIFY:this.emit(`sipEvent`,{event:e.event,request:e}),e.reply(200);break;default:e.reply(405)}}}},{key:`_findSession`,value:function(e){var t=e.call_id,n=e.from_tag,r=e.to_tag,i=t+n,a=this._sessions[i],o=t+r,s=this._sessions[o];return a||s||null}},{key:`_findDialog`,value:function(e,t,n){var r=e+t+n,i=this._dialogs[r];return i||(r=e+n+t,i=this._dialogs[r],i||null)}},{key:`_loadConfig`,value:function(e){try{O.load(this._configuration,e)}catch(e){throw e}this._configuration.display_name===0&&(this._configuration.display_name=`0`),this._configuration.instance_id||(this._configuration.instance_id=S.newUUID()),this._configuration.jssip_id=S.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,``);try{this._transport=new x(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=I.bind(this),this._transport.onconnect=L.bind(this),this._transport.ondisconnect=R.bind(this),this._transport.ondata=B.bind(this)}catch(e){throw j.warn(e),new C.ConfigurationError(`sockets`,this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){var n=this._configuration.uri.clone();n.user=null,n.clearParams(),n.clearHeaders(),this._configuration.registrar_server=n}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new w(`sip`,S.createRandomToken(8),this._configuration.via_host,null,{transport:`ws`}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r=`<`;return r+=t?this.temp_gruu||`sip:anonymous@anonymous.invalid;transport=ws`:this.pub_gruu||this.uri.toString(),n&&(t?!this.temp_gruu:!this.pub_gruu)&&(r+=`;ob`),r+=`>`,r}};var r=[`authorization_user`,`password`,`realm`,`ha1`,`authorization_jwt`,`display_name`,`register`,`extra_headers`];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(r.indexOf(i)===-1?Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}));for(var a in j.debug(`configuration parameters after validation:`),this._configuration)if(Object.prototype.hasOwnProperty.call(O.settings,a))switch(a){case`uri`:case`registrar_server`:j.debug(`- ${a}: ${this._configuration[a]}`);break;case`password`:case`ha1`:case`authorization_jwt`:j.debug(`- ${a}: NOT SHOWN`);break;default:j.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}},{key:`C`,get:function(){return M}},{key:`status`,get:function(){return this._status}},{key:`contact`,get:function(){return this._contact}},{key:`configuration`,get:function(){return this._configuration}},{key:`transport`,get:function(){return this._transport}}]),n}(p);function I(e){this.emit(`connecting`,e)}function L(e){this._status!==M.STATUS_USER_CLOSED&&(this._status=M.STATUS_READY,this._error=null,this.emit(`connected`,e),this._dynConfiguration.register&&this._registrator.register())}function R(e){for(var t=[`nict`,`ict`,`nist`,`ist`],n=0,r=t;n<r.length;n++){var i=r[n];for(var a in this._transactions[i])Object.prototype.hasOwnProperty.call(this._transactions[i],a)&&this._transactions[i][a].onTransportError()}this.emit(`disconnected`,e),this._registrator.onTransportClosed(),this._status!==M.STATUS_USER_CLOSED&&(this._status=M.STATUS_NOT_READY,this._error=M.NETWORK_ERROR)}function B(e){var t=e.transport,n=e.message;if(n=T.parseMessage(n,this),n&&!(this._status===M.STATUS_USER_CLOSED&&n instanceof E.IncomingRequest)&&D(n,this,t)){if(n instanceof E.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof E.IncomingResponse){var r;switch(n.method){case h.INVITE:r=this._transactions.ict[n.via_branch],r&&r.receiveResponse(n);break;case h.ACK:break;default:r=this._transactions.nict[n.via_branch],r&&r.receiveResponse(n)}}}}})),ve=s(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=z(),o=M(),s=new a(`WebSocketInterface`);t.exports=function(){function e(t){n(this,e),s.debug(`new() [url:"%s"]`,t),this._url=t,this._sip_uri=null,this._via_transport=null,this._ws=null;var r=o.parse(t,`absoluteURI`);if(r===-1)throw s.warn(`invalid WebSocket URI: ${t}`),TypeError(`Invalid argument: ${t}`);if(r.scheme!==`wss`&&r.scheme!==`ws`)throw s.warn(`invalid WebSocket URI scheme: ${r.scheme}`),TypeError(`Invalid argument: ${t}`);this._sip_uri=`sip:${r.host}${r.port?`:${r.port}`:``};transport=ws`,this._via_transport=r.scheme.toUpperCase()}return i(e,[{key:`connect`,value:function(){if(s.debug(`connect()`),this.isConnected()){s.debug(`WebSocket ${this._url} is already connected`);return}if(this.isConnecting()){s.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),s.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(e){this._onError(e)}}},{key:`disconnect`,value:function(){s.debug(`disconnect()`),this._ws&&=(this._ws.onopen=function(){},this._ws.onclose=function(){},this._ws.onmessage=function(){},this._ws.onerror=function(){},this._ws.close(),null)}},{key:`send`,value:function(e){return s.debug(`send()`),this.isConnected()?(this._ws.send(e),!0):(s.warn(`unable to send message, WebSocket is not open`),!1)}},{key:`isConnected`,value:function(){return this._ws&&this._ws.readyState===this._ws.OPEN}},{key:`isConnecting`,value:function(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}},{key:`_onOpen`,value:function(){s.debug(`WebSocket ${this._url} connected`),this.onconnect()}},{key:`_onClose`,value:function(e){var t=e.wasClean,n=e.code,r=e.reason;s.debug(`WebSocket ${this._url} closed`),t===!1&&s.debug(`WebSocket abrupt disconnection`),this.ondisconnect(!t,n,r)}},{key:`_onMessage`,value:function(e){var t=e.data;s.debug(`received WebSocket message`),this.ondata(t)}},{key:`_onError`,value:function(e){s.warn(`WebSocket ${this._url} error: `,e)}},{key:`via_transport`,get:function(){return this._via_transport},set:function(e){this._via_transport=e.toUpperCase()}},{key:`sip_uri`,get:function(){return this._sip_uri}},{key:`url`,get:function(){return this._url}}]),e}()})),ye=u(s(((e,t)=>{var n=(O(),d(f).default),r=k(),i=A(),a=P(),o=_e(),s=N(),c=j(),l=M(),u=ve();R()(`JsSIP`)(`version %s`,n.version),t.exports={C:r,Exceptions:i,Utils:a,UA:o,URI:s,NameAddrHeader:c,WebSocketInterface:u,Grammar:l,debug:R(),get name(){return n.title},get version(){return n.version}}}))(),1);function be(){return{createSocket:(e,t)=>new xe(e,t),createUa:e=>new ye.UA(e)}}var xe=class extends ye.WebSocketInterface{ticket;constructor(e,t){super(e),this.ticket=t}protocols(){return this.ticket===``?[`sip`]:[`xcall-ticket.${this.ticket}`,`sip`]}connect(){if(this.isConnected()||this.isConnecting())return;let e=this;e._ws&&this.disconnect();try{e._ws=new WebSocket(this.url,this.protocols()),e._ws.binaryType=`arraybuffer`,e._ws.onopen=e._onOpen.bind(this),e._ws.onclose=e._onClose.bind(this),e._ws.onmessage=e._onMessage.bind(this),e._ws.onerror=e._onError.bind(this)}catch(t){e._onError.call(this,t)}}};exports.createJsSipFactory=be,exports.t=d;
|