@zoom/meetingsdk 3.0.0-rc
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 +54 -0
- package/LICENSE.pdf +0 -0
- package/README.md +182 -0
- package/dist/css/bootstrap.css +5 -0
- package/dist/css/react-select.css +434 -0
- package/dist/fonts/glyphicons-halflings-regular.eot +0 -0
- package/dist/fonts/glyphicons-halflings-regular.svg +229 -0
- package/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/dist/fonts/glyphicons-halflings-regular.woff +0 -0
- package/dist/lib/audio/archival.mp3 +0 -0
- package/dist/lib/audio/incoming-msg-chime.mp3 +0 -0
- package/dist/lib/audio/m-entry.mp3 +0 -0
- package/dist/lib/audio/m-exit.mp3 +0 -0
- package/dist/lib/audio/m-wr.mp3 +0 -0
- package/dist/lib/audio/meeting_is_now_recorded.mp3 +0 -0
- package/dist/lib/audio/raise-hand-chime.mp3 +0 -0
- package/dist/lib/audio/recording_is_now_stopped.mp3 +0 -0
- package/dist/lib/audio/ring.mp3 +0 -0
- package/dist/lib/av/audio.encode.wasm +0 -0
- package/dist/lib/av/audio.simd.wasm +0 -0
- package/dist/lib/av/audio_simd.min.js +10 -0
- package/dist/lib/av/js_audio_process.min.js +10 -0
- package/dist/lib/av/js_audio_worklet.min.js +2 -0
- package/dist/lib/av/js_audio_worklet_process.min.js +25 -0
- package/dist/lib/av/js_audio_worklet_simd.min.js +25 -0
- package/dist/lib/av/js_media.min.js +2 -0
- package/dist/lib/av/js_sharing_audio_worklet.min.js +2 -0
- package/dist/lib/av/sharing_m.min.js +31 -0
- package/dist/lib/av/sharing_mtsimd.min.js +31 -0
- package/dist/lib/av/sharing_s.min.js +10 -0
- package/dist/lib/av/sharing_simd.min.js +10 -0
- package/dist/lib/av/vb-resource/dualModel.bin +0 -0
- package/dist/lib/av/vb-resource/tf.min.js +18 -0
- package/dist/lib/av/vb-resource/vbPreload.js +1 -0
- package/dist/lib/av/vb-resource/vbPreloadWorker.js +1 -0
- package/dist/lib/av/video.decode.wasm +0 -0
- package/dist/lib/av/video.mt.wasm +0 -0
- package/dist/lib/av/video.mtsimd.wasm +0 -0
- package/dist/lib/av/video.simd.wasm +0 -0
- package/dist/lib/av/video_m.min.js +31 -0
- package/dist/lib/av/video_mtsimd.min.js +31 -0
- package/dist/lib/av/video_s.min.js +10 -0
- package/dist/lib/av/video_share_mtsimd.min.js +31 -0
- package/dist/lib/av/video_simd.min.js +10 -0
- package/dist/lib/av/websipclient.min.js +1 -0
- package/dist/lib/image/SanFrancisco.jpg +0 -0
- package/dist/lib/image/animation-sprite.png +0 -0
- package/dist/lib/image/blur.png +0 -0
- package/dist/lib/image/earth.jpg +0 -0
- package/dist/lib/image/grass.jpg +0 -0
- package/dist/lib/image/mask-circle.png +0 -0
- package/dist/lib/image/mask-heart.png +0 -0
- package/dist/lib/image/mask-rectangle.png +0 -0
- package/dist/lib/image/notification.png +0 -0
- package/dist/lib/lang/de-DE.json +1727 -0
- package/dist/lib/lang/en-US.json +1727 -0
- package/dist/lib/lang/es-ES.json +1727 -0
- package/dist/lib/lang/fr-FR.json +1727 -0
- package/dist/lib/lang/id-ID.json +1727 -0
- package/dist/lib/lang/it-IT.json +1727 -0
- package/dist/lib/lang/jp-JP.json +1727 -0
- package/dist/lib/lang/ko-KO.json +1727 -0
- package/dist/lib/lang/nl-NL.json +1727 -0
- package/dist/lib/lang/pl-PL.json +1727 -0
- package/dist/lib/lang/pt-PT.json +1727 -0
- package/dist/lib/lang/ru-RU.json +1727 -0
- package/dist/lib/lang/tr-TR.json +1727 -0
- package/dist/lib/lang/vi-VN.json +1727 -0
- package/dist/lib/lang/zh-CN.json +1727 -0
- package/dist/lib/lang/zh-TW.json +1727 -0
- package/dist/lib/vendor/lodash.min.js +140 -0
- package/dist/lib/vendor/react-dom.min.js +239 -0
- package/dist/lib/vendor/react.min.js +32 -0
- package/dist/lib/vendor/redux-thunk.min.js +1 -0
- package/dist/lib/vendor/redux.min.js +1 -0
- package/dist/lib/webim.min.js +23 -0
- package/dist/ui/33f06.svg +647 -0
- package/dist/ui/zoomus-websdk-806.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-MobileReportProblemContent.umd.min.js +2 -0
- package/dist/ui/zoomus-websdk-ReportProblemContent.umd.min.js +2 -0
- package/dist/ui/zoomus-websdk-editor_de-DE.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_es-ES.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_fr-FR.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_id-ID.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_it-IT.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_ja-JP.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_ko-KR.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_nl-NL.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_pl-PL.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_pt-PT.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_ru-RU.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_tr-TR.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_vi-VN.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_zh-CN.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-editor_zh-TW.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-icons.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-loginview.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-lottie-web.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-lottie.umd.min.js +1 -0
- package/dist/ui/zoomus-websdk-main-client.umd.min.js +2 -0
- package/dist/ui/zoomus-websdk-preview.umd.min.js +2 -0
- package/dist/ui/zoomus-websdk-zoommtgMain.umd.min.js +2 -0
- package/dist/zoom-meeting-3.0.0.min.js +2 -0
- package/dist/zoom-meeting-embedded-ES5.min.js +2 -0
- package/dist/zoomus-websdk-embedded.umd.min.js +2 -0
- package/dist/zoomus-websdk.umd.min.js +2 -0
- package/embedded.d.ts +1567 -0
- package/embedded.js +3 -0
- package/index.d.ts +2101 -0
- package/index.js +4 -0
- package/oss_attribution.txt +6432 -0
- package/package.json +53 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WebSipClient=t():e.WebSipClient=t()}(window,(function(){return function(e){var t={};function s(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=e,s.c=t,s.d=function(e,t,i){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)s.d(i,r,function(t){return e[t]}.bind(null,r));return i},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=47)}([function(e,t,s){"use strict";var i;s.d(t,"a",(function(){return i})),function(e){e.Initial="Initial",e.Establishing="Establishing",e.Established="Established",e.Terminating="Terminating",e.Terminated="Terminated"}(i||(i={}))},function(e,t,s){"use strict";s.d(t,"a",(function(){return r})),s.d(t,"b",(function(){return n})),s.d(t,"d",(function(){return o})),s.d(t,"c",(function(){return a})),s.d(t,"e",(function(){return c}));const i={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",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:"Internal Server 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"};function r(e,t=32){let s="";for(let i=0;i<e;i++){s+=Math.floor(Math.random()*t).toString(t)}return s}function n(e){return i[e]||""}function o(){return r(10)}function a(e){const t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},s=e.toLowerCase().replace(/_/g,"-").split("-"),i=s.length;let r="";for(let e=0;e<i;e++)0!==e&&(r+="-"),r+=s[e].charAt(0).toUpperCase()+s[e].substring(1);return t[r]&&(r=t[r]),r}function c(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length}},function(e,t,s){var i=s(52)();e.exports=i;try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}},,function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));const i=500,r={T1:i,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,TIMER_N:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},function(e,t){function s(e,t,s,i,r,n,o){try{var a=e[n](o),c=a.value}catch(e){return void s(e)}a.done?t(c):Promise.resolve(c).then(i,r)}e.exports=function(e){return function(){var t=this,i=arguments;return new Promise((function(r,n){var o=e.apply(t,i);function a(e){s(o,r,n,a,c,"next",e)}function c(e){s(o,r,n,a,c,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},,function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){var i=s(38);function r(e,t){for(var s=0;s<t.length;s++){var r=t[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}e.exports=function(e,t,s){return t&&r(e.prototype,t),s&&r(e,s),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";var i;s.d(t,"a",(function(){return i})),function(e){e.Started="Started",e.Stopped="Stopped"}(i||(i={}))},function(e,t,s){"use strict";var i;s.d(t,"a",(function(){return i})),function(e){e.ACK="ACK",e.BYE="BYE",e.CANCEL="CANCEL",e.INFO="INFO",e.INVITE="INVITE",e.MESSAGE="MESSAGE",e.NOTIFY="NOTIFY",e.OPTIONS="OPTIONS",e.REGISTER="REGISTER",e.UPDATE="UPDATE",e.SUBSCRIBE="SUBSCRIBE",e.PUBLISH="PUBLISH",e.REFER="REFER",e.PRACK="PRACK"}(i||(i={}))},,function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s(10);const r=[i.a.ACK,i.a.BYE,i.a.CANCEL,i.a.INFO,i.a.INVITE,i.a.MESSAGE,i.a.NOTIFY,i.a.OPTIONS,i.a.PRACK,i.a.REFER,i.a.REGISTER,i.a.SUBSCRIBE]},function(e,t,s){"use strict";var i;s.d(t,"a",(function(){return i})),s.d(t,"b",(function(){return r})),function(e){e.Required="Required",e.Supported="Supported",e.Unsupported="Unsupported"}(i||(i={}));const r={"100rel":!0,199:!0,answermode:!0,"early-session":!0,eventlist:!0,explicitsub:!0,"from-change":!0,"geolocation-http":!0,"geolocation-sip":!0,gin:!0,gruu:!0,histinfo:!0,ice:!0,join:!0,"multiple-refer":!0,norefersub:!0,nosub:!0,outbound:!0,path:!0,policy:!0,precondition:!0,pref:!0,privacy:!0,"recipient-list-invite":!0,"recipient-list-message":!0,"recipient-list-subscribe":!0,replaces:!0,"resource-priority":!0,"sdp-anat":!0,"sec-agree":!0,tdialog:!0,timer:!0,uui:!0}},function(e,t,s){"use strict";var i,r;s.d(t,"a",(function(){return i})),s.d(t,"b",(function(){return r})),function(e){e.Initial="Initial",e.Early="Early",e.AckWait="AckWait",e.Confirmed="Confirmed",e.Terminated="Terminated"}(i||(i={})),function(e){e.Initial="Initial",e.HaveLocalOffer="HaveLocalOffer",e.HaveRemoteOffer="HaveRemoteOffer",e.Stable="Stable",e.Closed="Closed"}(r||(r={}))},function(e,t){function s(t){return e.exports=s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,s(t)}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";s.d(t,"a",(function(){return i}));class i{constructor(){this.listeners=new Array}addListener(e,t){const s=t=>{this.removeListener(s),e(t)};!0===(null==t?void 0:t.once)?this.listeners.push(s):this.listeners.push(e)}emit(e){this.listeners.slice().forEach(t=>t(e))}removeAllListeners(){this.listeners=[]}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}on(e){return this.addListener(e)}off(e){return this.removeListener(e)}once(e){return this.addListener(e,{once:!0})}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s(24);class r extends i.a{constructor(e,t,s){super(s),this.uri=e,this._displayName=t}get friendlyName(){return this.displayName||this.uri.aor}get displayName(){return this._displayName}set displayName(e){this._displayName=e}clone(){return new r(this.uri.clone(),this._displayName,JSON.parse(JSON.stringify(this.parameters)))}toString(){let e=this.displayName||"0"===this.displayName?'"'+this.displayName+'" ':"";e+="<"+this.uri.toString()+">";for(const t in this.parameters)this.parameters.hasOwnProperty(t)&&(e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]));return e}}},function(e,t,s){var i=s(38);e.exports=function(e,t,s){return(t=i(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";s.d(t,"a",(function(){return i}));class i extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s(26);class r extends i.a{constructor(){super()}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return i}));class i{constructor(e){this.incomingNotifyRequest=e}get request(){return this.incomingNotifyRequest.message}accept(e){return this.incomingNotifyRequest.accept(e),Promise.resolve()}reject(e){return this.incomingNotifyRequest.reject(e),Promise.resolve()}}},function(e,t,s){"use strict";var i=s(66),r=s(14),n=s(23),o=s(28),a=s(1),c=s(12);class h{constructor(e){this.incomingAckRequest=e}get request(){return this.incomingAckRequest.message}}class d{constructor(e){this.incomingByeRequest=e}get request(){return this.incomingByeRequest.message}accept(e){return this.incomingByeRequest.accept(e),Promise.resolve()}reject(e){return this.incomingByeRequest.reject(e),Promise.resolve()}}var l=s(16),u=s(65),g=s(67);class p{constructor(e){this.incomingInfoRequest=e}get request(){return this.incomingInfoRequest.message}accept(e){return this.incomingInfoRequest.accept(e),Promise.resolve()}reject(e){return this.incomingInfoRequest.reject(e),Promise.resolve()}}var f=s(27),m=s(21),v=s(17);class w{constructor(e,t){this.incomingReferRequest=e,this.session=t}get referTo(){const e=this.incomingReferRequest.message.parseHeader("refer-to");if(!(e instanceof v.a))throw new Error("Failed to parse Refer-To header.");return e}get referredBy(){return this.incomingReferRequest.message.getHeader("referred-by")}get replaces(){const e=this.referTo.uri.getHeader("replaces");return e instanceof Array?e[0]:e}get request(){return this.incomingReferRequest.message}accept(e={statusCode:202}){return this.incomingReferRequest.accept(e),Promise.resolve()}reject(e){return this.incomingReferRequest.reject(e),Promise.resolve()}makeInviter(e){if(this.inviter)return this.inviter;const t=this.referTo.uri.clone();t.clearHeaders();const s=((e=e||{}).extraHeaders||[]).slice(),i=this.replaces;i&&s.push("Replaces: "+decodeURIComponent(i));const r=this.referredBy;return r&&s.push("Referred-By: "+r),e.extraHeaders=s,this.inviter=this.session.userAgent._makeInviter(t,e),this.inviter._referred=this.session,this.session._referral=this.inviter,this.inviter}}var b=s(0);s.d(t,"a",(function(){return y}));class y{constructor(e,t={}){this.pendingReinvite=!1,this.pendingReinviteAck=!1,this._state=b.a.Initial,this.delegate=t.delegate,this._stateEventEmitter=new l.a,this._userAgent=e}dispose(){switch(this.logger.log(`Session ${this.id} in state ${this._state} is being disposed`),delete this.userAgent._sessions[this.id],this._sessionDescriptionHandler&&this._sessionDescriptionHandler.close(),this.state){case b.a.Initial:case b.a.Establishing:break;case b.a.Established:return new Promise(e=>{this._bye({onAccept:()=>e(),onRedirect:()=>e(),onReject:()=>e()})});case b.a.Terminating:case b.a.Terminated:break;default:throw new Error("Unknown state.")}return Promise.resolve()}get assertedIdentity(){return this._assertedIdentity}get dialog(){return this._dialog}get id(){return this._id}get replacee(){return this._replacee}get sessionDescriptionHandler(){return this._sessionDescriptionHandler}get sessionDescriptionHandlerFactory(){return this.userAgent.configuration.sessionDescriptionHandlerFactory}get sessionDescriptionHandlerModifiers(){return this._sessionDescriptionHandlerModifiers||[]}set sessionDescriptionHandlerModifiers(e){this._sessionDescriptionHandlerModifiers=e.slice()}get sessionDescriptionHandlerOptions(){return this._sessionDescriptionHandlerOptions||{}}set sessionDescriptionHandlerOptions(e){this._sessionDescriptionHandlerOptions=Object.assign({},e)}get sessionDescriptionHandlerModifiersReInvite(){return this._sessionDescriptionHandlerModifiersReInvite||[]}set sessionDescriptionHandlerModifiersReInvite(e){this._sessionDescriptionHandlerModifiersReInvite=e.slice()}get sessionDescriptionHandlerOptionsReInvite(){return this._sessionDescriptionHandlerOptionsReInvite||{}}set sessionDescriptionHandlerOptionsReInvite(e){this._sessionDescriptionHandlerOptionsReInvite=Object.assign({},e)}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get userAgent(){return this._userAgent}bye(e={}){let t="Session.bye() may only be called if established session.";switch(this.state){case b.a.Initial:"function"==typeof this.cancel?(t+=" However Inviter.invite() has not yet been called.",t+=" Perhaps you should have called Inviter.cancel()?"):"function"==typeof this.reject&&(t+=" However Invitation.accept() has not yet been called.",t+=" Perhaps you should have called Invitation.reject()?");break;case b.a.Establishing:"function"==typeof this.cancel?(t+=" However a dialog does not yet exist.",t+=" Perhaps you should have called Inviter.cancel()?"):"function"==typeof this.reject&&(t+=" However Invitation.accept() has not yet been called (or not yet resolved).",t+=" Perhaps you should have called Invitation.reject()?");break;case b.a.Established:{const t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._bye(t,s)}case b.a.Terminating:t+=" However this session is already terminating.","function"==typeof this.cancel?t+=" Perhaps you have already called Inviter.cancel()?":"function"==typeof this.reject&&(t+=" Perhaps you have already called Session.bye()?");break;case b.a.Terminated:t+=" However this session is already terminated.";break;default:throw new Error("Unknown state")}return this.logger.error(t),Promise.reject(new Error("Invalid session state "+this.state))}info(e={}){if(this.state!==b.a.Established){const e="Session.info() may only be called if established session.";return this.logger.error(e),Promise.reject(new Error("Invalid session state "+this.state))}const t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._info(t,s)}invite(e={}){if(this.logger.log("Session.invite"),this.state!==b.a.Established)return Promise.reject(new Error("Invalid session state "+this.state));if(this.pendingReinvite)return Promise.reject(new u.a("Reinvite in progress. Please wait until complete, then try again."));this.pendingReinvite=!0,e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiersReInvite=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptionsReInvite=e.sessionDescriptionHandlerOptions);const t={onAccept:t=>{const s=Object(i.b)(t.message);if(!s)return this.logger.error("Received 2xx response to re-INVITE without a session description"),this.ackAndBye(t,400,"Missing session description"),this.stateTransition(b.a.Terminated),void(this.pendingReinvite=!1);if(e.withoutSdp){const i={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.setOfferAndGetAnswer(s,i).then(e=>{t.ack({body:e})}).catch(e=>{this.logger.error("Failed to handle offer in 2xx response to re-INVITE"),this.logger.error(e.message),this.state===b.a.Terminated?t.ack():(this.ackAndBye(t,488,"Bad Media Description"),this.stateTransition(b.a.Terminated))}).then(()=>{this.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t)})}else{const i={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.setAnswer(s,i).then(()=>{t.ack()}).catch(e=>{this.logger.error("Failed to handle answer in 2xx response to re-INVITE"),this.logger.error(e.message),this.state!==b.a.Terminated?(this.ackAndBye(t,488,"Bad Media Description"),this.stateTransition(b.a.Terminated)):t.ack()}).then(()=>{this.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t)})}},onProgress:e=>{},onRedirect:e=>{},onReject:t=>{this.logger.warn("Received a non-2xx response to re-INVITE"),this.pendingReinvite=!1,e.withoutSdp?e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t):this.rollbackOffer().catch(e=>{if(this.logger.error("Failed to rollback offer on non-2xx response to re-INVITE"),this.logger.error(e.message),this.state!==b.a.Terminated){if(!this.dialog)throw new Error("Dialog undefined.");const e=[];e.push("Reason: "+this.getReasonHeaderValue(500,"Internal Server Error")),this.dialog.bye(void 0,{extraHeaders:e}),this.stateTransition(b.a.Terminated)}}).then(()=>{e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t)})},onTrying:e=>{}},s=e.requestOptions||{};if(s.extraHeaders=(s.extraHeaders||[]).slice(),s.extraHeaders.push("Allow: "+c.a.toString()),s.extraHeaders.push("Contact: "+this._contact),e.withoutSdp){if(!this.dialog)throw this.pendingReinvite=!1,new Error("Dialog undefined.");return Promise.resolve(this.dialog.invite(t,s))}const r={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};return this.getOffer(r).then(e=>{if(!this.dialog)throw this.pendingReinvite=!1,new Error("Dialog undefined.");return s.body=e,this.dialog.invite(t,s)}).catch(e=>{throw this.logger.error(e.message),this.logger.error("Failed to send re-INVITE"),this.pendingReinvite=!1,e})}message(e={}){if(this.state!==b.a.Established){const e="Session.message() may only be called if established session.";return this.logger.error(e),Promise.reject(new Error("Invalid session state "+this.state))}const t=e.requestDelegate,s=this.copyRequestOptions(e.requestOptions);return this._message(t,s)}refer(e,t={}){if(this.state!==b.a.Established){const e="Session.refer() may only be called if established session.";return this.logger.error(e),Promise.reject(new Error("Invalid session state "+this.state))}const s=t.requestDelegate,i=this.copyRequestOptions(t.requestOptions);return i.extraHeaders=i.extraHeaders?i.extraHeaders.concat(this.referExtraHeaders(this.referToString(e))):this.referExtraHeaders(this.referToString(e)),this._refer(t.onNotify,s,i)}_bye(e,t){if(!this.dialog)return Promise.reject(new Error("Session dialog undefined."));const s=this.dialog;switch(s.sessionState){case r.a.Initial:case r.a.Early:throw new Error("Invalid dialog state "+s.sessionState);case r.a.AckWait:return this.stateTransition(b.a.Terminating),new Promise(i=>{s.delegate={onAck:()=>{const r=s.bye(e,t);return this.stateTransition(b.a.Terminated),i(r),Promise.resolve()},onAckTimeout:()=>{const r=s.bye(e,t);this.stateTransition(b.a.Terminated),i(r)}}});case r.a.Confirmed:{const i=s.bye(e,t);return this.stateTransition(b.a.Terminated),Promise.resolve(i)}case r.a.Terminated:throw new Error("Invalid dialog state "+s.sessionState);default:throw new Error("Unrecognized state.")}}_info(e,t){return this.dialog?Promise.resolve(this.dialog.info(e,t)):Promise.reject(new Error("Session dialog undefined."))}_message(e,t){return this.dialog?Promise.resolve(this.dialog.message(e,t)):Promise.reject(new Error("Session dialog undefined."))}_refer(e,t,s){return this.dialog?(this.onNotify=e,Promise.resolve(this.dialog.refer(t,s))):Promise.reject(new Error("Session dialog undefined."))}ackAndBye(e,t,s){e.ack();const i=[];t&&i.push("Reason: "+this.getReasonHeaderValue(t,s)),e.session.bye(void 0,{extraHeaders:i})}onAckRequest(e){if(this.logger.log("Session.onAckRequest"),this.state!==b.a.Established&&this.state!==b.a.Terminating)return this.logger.error(`ACK received while in state ${this.state}, dropping request`),Promise.resolve();const t=this.dialog;if(!t)throw new Error("Dialog undefined.");const s={sessionDescriptionHandlerOptions:this.pendingReinviteAck?this.sessionDescriptionHandlerOptionsReInvite:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.pendingReinviteAck?this._sessionDescriptionHandlerModifiersReInvite:this._sessionDescriptionHandlerModifiers};if(this.delegate&&this.delegate.onAck){const t=new h(e);this.delegate.onAck(t)}switch(this.pendingReinviteAck=!1,t.signalingState){case r.b.Initial:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);const e=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:e}),this.stateTransition(b.a.Terminated),Promise.resolve()}case r.b.Stable:{const r=Object(i.b)(e.message);return r?"render"===r.contentDisposition?(this._renderbody=r.content,this._rendertype=r.contentType,Promise.resolve()):"session"!==r.contentDisposition?Promise.resolve():this.setAnswer(r,s).catch(e=>{this.logger.error(e.message);const s=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];t.bye(void 0,{extraHeaders:s}),this.stateTransition(b.a.Terminated)}):Promise.resolve()}case r.b.HaveLocalOffer:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);const e=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:e}),this.stateTransition(b.a.Terminated),Promise.resolve()}case r.b.HaveRemoteOffer:{this.logger.error(`Invalid signaling state ${t.signalingState}.`);const e=["Reason: "+this.getReasonHeaderValue(488,"Bad Media Description")];return t.bye(void 0,{extraHeaders:e}),this.stateTransition(b.a.Terminated),Promise.resolve()}case r.b.Closed:default:throw new Error(`Invalid signaling state ${t.signalingState}.`)}}onByeRequest(e){if(this.logger.log("Session.onByeRequest"),this.state===b.a.Established){if(this.delegate&&this.delegate.onBye){const t=new d(e);this.delegate.onBye(t)}else e.accept();this.stateTransition(b.a.Terminated)}else this.logger.error(`BYE received while in state ${this.state}, dropping request`)}onInfoRequest(e){if(this.logger.log("Session.onInfoRequest"),this.state===b.a.Established)if(this.delegate&&this.delegate.onInfo){const t=new p(e);this.delegate.onInfo(t)}else e.accept();else this.logger.error(`INFO received while in state ${this.state}, dropping request`)}onInviteRequest(e){if(this.logger.log("Session.onInviteRequest"),this.state!==b.a.Established)return void this.logger.error(`INVITE received while in state ${this.state}, dropping request`);this.pendingReinviteAck=!0;const t=["Contact: "+this._contact];if(e.message.hasHeader("P-Asserted-Identity")){const t=e.message.getHeader("P-Asserted-Identity");if(!t)throw new Error("Header undefined.");this._assertedIdentity=n.a.nameAddrHeaderParse(t)}const s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptionsReInvite,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiersReInvite};this.generateResponseOfferAnswerInDialog(s).then(s=>{const i=e.accept({statusCode:200,extraHeaders:t,body:s});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,i.message,200)}).catch(s=>{if(this.logger.error(s.message),this.logger.error("Failed to handle to re-INVITE request"),!this.dialog)throw new Error("Dialog undefined.");if(this.logger.error(this.dialog.signalingState),this.dialog.signalingState!==r.b.Stable)this.rollbackOffer().then(()=>{const t=e.reject({statusCode:488});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,t.message,488)}).catch(s=>{this.logger.error(s.message),this.logger.error("Failed to rollback offer on re-INVITE request");const i=e.reject({statusCode:488});if(this.state!==b.a.Terminated){if(!this.dialog)throw new Error("Dialog undefined.");[].push("Reason: "+this.getReasonHeaderValue(500,"Internal Server Error")),this.dialog.bye(void 0,{extraHeaders:t}),this.stateTransition(b.a.Terminated)}this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,i.message,488)});else{const t=e.reject({statusCode:488});this.delegate&&this.delegate.onInvite&&this.delegate.onInvite(e.message,t.message,488)}})}onMessageRequest(e){if(this.logger.log("Session.onMessageRequest"),this.state===b.a.Established)if(this.delegate&&this.delegate.onMessage){const t=new f.a(e);this.delegate.onMessage(t)}else e.accept();else this.logger.error(`MESSAGE received while in state ${this.state}, dropping request`)}onNotifyRequest(e){if(this.logger.log("Session.onNotifyRequest"),this.state===b.a.Established)if(this.onNotify){const t=new m.a(e);this.onNotify(t)}else if(this.delegate&&this.delegate.onNotify){const t=new m.a(e);this.delegate.onNotify(t)}else e.accept();else this.logger.error(`NOTIFY received while in state ${this.state}, dropping request`)}onPrackRequest(e){if(this.logger.log("Session.onPrackRequest"),this.state===b.a.Established)throw new Error("Unimplemented.");this.logger.error(`PRACK received while in state ${this.state}, dropping request`)}onReferRequest(e){if(this.logger.log("Session.onReferRequest"),this.state!==b.a.Established)return void this.logger.error(`REFER received while in state ${this.state}, dropping request`);if(!e.message.hasHeader("refer-to"))return this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting."),void e.reject();const t=new w(e,this);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(t):(this.logger.log("No delegate available to handle REFER, automatically accepting and following."),t.accept().then(()=>t.makeInviter(this._referralInviterOptions).invite()).catch(e=>{this.logger.error(e.message)}))}generateResponseOfferAnswer(e,t){if(this.dialog)return this.generateResponseOfferAnswerInDialog(t);const s=Object(i.b)(e.message);return s&&"session"===s.contentDisposition?this.setOfferAndGetAnswer(s,t):this.getOffer(t)}generateResponseOfferAnswerInDialog(e){if(!this.dialog)throw new Error("Dialog undefined.");switch(this.dialog.signalingState){case r.b.Initial:return this.getOffer(e);case r.b.HaveLocalOffer:return Promise.resolve(void 0);case r.b.HaveRemoteOffer:if(!this.dialog.offer)throw new Error(`Session offer undefined in signaling state ${this.dialog.signalingState}.`);return this.setOfferAndGetAnswer(this.dialog.offer,e);case r.b.Stable:return this.state!==b.a.Established?Promise.resolve(void 0):this.getOffer(e);case r.b.Closed:default:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`)}}getOffer(e){const t=this.setupSessionDescriptionHandler(),s=e.sessionDescriptionHandlerOptions,r=e.sessionDescriptionHandlerModifiers;try{return t.getDescription(s,r).then(e=>Object(i.a)(e)).catch(e=>{this.logger.error("Session.getOffer: SDH getDescription rejected...");const t=e instanceof Error?e:new Error("Session.getOffer unknown error.");throw this.logger.error(t.message),t})}catch(e){this.logger.error("Session.getOffer: SDH getDescription threw...");const t=e instanceof Error?e:new Error(e);return this.logger.error(t.message),Promise.reject(t)}}rollbackOffer(){const e=this.setupSessionDescriptionHandler();if(void 0===e.rollbackDescription)return Promise.resolve();try{return e.rollbackDescription().catch(e=>{this.logger.error("Session.rollbackOffer: SDH rollbackDescription rejected...");const t=e instanceof Error?e:new Error("Session.rollbackOffer unknown error.");throw this.logger.error(t.message),t})}catch(e){this.logger.error("Session.rollbackOffer: SDH rollbackDescription threw...");const t=e instanceof Error?e:new Error(e);return this.logger.error(t.message),Promise.reject(t)}}setAnswer(e,t){const s=this.setupSessionDescriptionHandler(),i=t.sessionDescriptionHandlerOptions,r=t.sessionDescriptionHandlerModifiers;try{if(!s.hasDescription(e.contentType))return Promise.reject(new g.a)}catch(e){this.logger.error("Session.setAnswer: SDH hasDescription threw...");const t=e instanceof Error?e:new Error(e);return this.logger.error(t.message),Promise.reject(t)}try{return s.setDescription(e.content,i,r).catch(e=>{this.logger.error("Session.setAnswer: SDH setDescription rejected...");const t=e instanceof Error?e:new Error("Session.setAnswer unknown error.");throw this.logger.error(t.message),t})}catch(e){this.logger.error("Session.setAnswer: SDH setDescription threw...");const t=e instanceof Error?e:new Error(e);return this.logger.error(t.message),Promise.reject(t)}}setOfferAndGetAnswer(e,t){const s=this.setupSessionDescriptionHandler(),r=t.sessionDescriptionHandlerOptions,n=t.sessionDescriptionHandlerModifiers;try{if(!s.hasDescription(e.contentType))return Promise.reject(new g.a)}catch(e){this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");const t=e instanceof Error?e:new Error(e);return this.logger.error(t.message),Promise.reject(t)}try{return s.setDescription(e.content,r,n).then(()=>s.getDescription(r,n)).then(e=>Object(i.a)(e)).catch(e=>{this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription rejected...");const t=e instanceof Error?e:new Error("Session.setOfferAndGetAnswer unknown error.");throw this.logger.error(t.message),t})}catch(e){this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription threw...");const t=e instanceof Error?e:new Error(e);return this.logger.error(t.message),Promise.reject(t)}}setSessionDescriptionHandler(e){if(this._sessionDescriptionHandler)throw new Error("Session description handler defined.");this._sessionDescriptionHandler=e}setupSessionDescriptionHandler(){var e;return this._sessionDescriptionHandler||(this._sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions),(null===(e=this.delegate)||void 0===e?void 0:e.onSessionDescriptionHandler)&&this.delegate.onSessionDescriptionHandler(this._sessionDescriptionHandler,!1)),this._sessionDescriptionHandler}stateTransition(e){const t=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case b.a.Initial:e!==b.a.Establishing&&e!==b.a.Established&&e!==b.a.Terminating&&e!==b.a.Terminated&&t();break;case b.a.Establishing:e!==b.a.Established&&e!==b.a.Terminating&&e!==b.a.Terminated&&t();break;case b.a.Established:e!==b.a.Terminating&&e!==b.a.Terminated&&t();break;case b.a.Terminating:e!==b.a.Terminated&&t();break;case b.a.Terminated:t();break;default:throw new Error("Unrecognized state.")}this._state=e,this.logger.log(`Session ${this.id} transitioned to state ${this._state}`),this._stateEventEmitter.emit(this._state),e===b.a.Terminated&&this.dispose()}copyRequestOptions(e={}){return{extraHeaders:e.extraHeaders?e.extraHeaders.slice():void 0,body:e.body?{contentDisposition:e.body.contentDisposition||"render",contentType:e.body.contentType||"text/plain",content:e.body.content||""}:void 0}}getReasonHeaderValue(e,t){const s=e;let i=Object(a.b)(e);return!i&&t&&(i=t),"SIP;cause="+s+';text="'+i+'"'}referExtraHeaders(e){const t=[];return t.push("Referred-By: <"+this.userAgent.configuration.uri+">"),t.push("Contact: "+this._contact),t.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),t.push("Refer-To: "+e),t}referToString(e){let t;if(e instanceof o.a)t=e.toString();else{if(!e.dialog)throw new Error("Dialog undefined.");const s=e.remoteIdentity.friendlyName,i=e.dialog.remoteTarget.toString(),r=e.dialog.callId,n=e.dialog.remoteTag,o=e.dialog.localTag;t=`"${s}" <${i}?Replaces=${encodeURIComponent(`${r};to-tag=${n};from-tag=${o}`)}>`}return t}}},function(e,t,s){"use strict";var i=s(17),r=s(28);class n extends Error{constructor(e,t,s,i){super(),this.message=e,this.expected=t,this.found=s,this.location=i,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,n)}static buildMessage(e,t){function s(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+s(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+s(e))}function r(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+s(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+s(e))}function n(e){switch(e.type){case"literal":return'"'+i(e.text)+'"';case"class":const t=e.parts.map(e=>Array.isArray(e)?r(e[0])+"-"+r(e[1]):r(e));return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){const t=e.map(n);let s,i;if(t.sort(),t.length>0){for(s=1,i=1;s<t.length;s++)t[s-1]!==t[s]&&(t[i]=t[s],i++);t.length=i}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+(((o=t)?'"'+i(o)+'"':"end of input")+" found.");var o}}const o=function(e,t){t=void 0!==t?t:{};const s={},o={Contact:119,Name_Addr_Header:156,Record_Route:176,Request_Response:81,SIP_URI:45,Subscription_State:186,Supported:191,Require:182,Via:194,absoluteURI:84,Call_ID:118,Content_Disposition:130,Content_Length:135,Content_Type:136,CSeq:146,displayName:122,Event:149,From:151,host:52,Max_Forwards:154,Min_SE:213,Proxy_Authenticate:157,quoted_string:40,Refer_To:178,Replaces:179,Session_Expires:210,stun_URI:217,To:192,turn_URI:223,uuid:226,WWW_Authenticate:209,challenge:158,sipfrag:230,Referred_By:231};let a=119;const c=["\r\n",b("\r\n",!1),/^[0-9]/,y([["0","9"]],!1,!1),/^[a-zA-Z]/,y([["a","z"],["A","Z"]],!1,!1),/^[0-9a-fA-F]/,y([["0","9"],["a","f"],["A","F"]],!1,!1),/^[\0-\xFF]/,y([["\0","ÿ"]],!1,!1),/^["]/,y(['"'],!1,!1)," ",b(" ",!1),"\t",b("\t",!1),/^[a-zA-Z0-9]/,y([["a","z"],["A","Z"],["0","9"]],!1,!1),";",b(";",!1),"/",b("/",!1),"?",b("?",!1),":",b(":",!1),"@",b("@",!1),"&",b("&",!1),"=",b("=",!1),"+",b("+",!1),"$",b("$",!1),",",b(",",!1),"-",b("-",!1),"_",b("_",!1),".",b(".",!1),"!",b("!",!1),"~",b("~",!1),"*",b("*",!1),"'",b("'",!1),"(",b("(",!1),")",b(")",!1),"%",b("%",!1),function(){return" "},function(){return":"},/^[!-~]/,y([["!","~"]],!1,!1),/^[\x80-\uFFFF]/,y([["",""]],!1,!1),/^[\x80-\xBF]/,y([["","¿"]],!1,!1),/^[a-f]/,y([["a","f"]],!1,!1),"`",b("`",!1),"<",b("<",!1),">",b(">",!1),"\\",b("\\",!1),"[",b("[",!1),"]",b("]",!1),"{",b("{",!1),"}",b("}",!1),function(){return"*"},function(){return"/"},function(){return"="},function(){return"("},function(){return")"},function(){return">"},function(){return"<"},function(){return","},function(){return";"},function(){return":"},function(){return'"'},/^[!-']/,y([["!","'"]],!1,!1),/^[*-[]/,y([["*","["]],!1,!1),/^[\]-~]/,y([["]","~"]],!1,!1),function(e){return e},/^[#-[]/,y([["#","["]],!1,!1),/^[\0-\t]/,y([["\0","\t"]],!1,!1),/^[\x0B-\f]/,y([["\v","\f"]],!1,!1),/^[\x0E-\x7F]/,y([["",""]],!1,!1),function(){(t=t||{data:{}}).data.uri=new r.a(t.data.scheme,t.data.user,t.data.host,t.data.port),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port},function(){(t=t||{data:{}}).data.uri=new r.a(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params,"SIP_URI"===t.startRule&&(t.data=t.data.uri)},"sips",b("sips",!0),"sip",b("sip",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(){(t=t||{data:{}}).data.user=decodeURIComponent(v().slice(0,-1))},function(){(t=t||{data:{}}).data.password=v()},function(){return(t=t||{data:{}}).data.host=v(),t.data.host},function(){return(t=t||{data:{}}).data.host_type="domain",v()},/^[a-zA-Z0-9_\-]/,y([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),/^[a-zA-Z0-9\-]/,y([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",v()},"::",b("::",!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",v()},function(){return(t=t||{data:{}}).data.host_type="IPv4",v()},"25",b("25",!1),/^[0-5]/,y([["0","5"]],!1,!1),"2",b("2",!1),/^[0-4]/,y([["0","4"]],!1,!1),"1",b("1",!1),/^[1-9]/,y([["1","9"]],!1,!1),function(e){return t=t||{data:{}},e=parseInt(e.join("")),t.data.port=e,e},"transport=",b("transport=",!0),"udp",b("udp",!0),"tcp",b("tcp",!0),"sctp",b("sctp",!0),"tls",b("tls",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.transport=e.toLowerCase()},"user=",b("user=",!0),"phone",b("phone",!0),"ip",b("ip",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.user=e.toLowerCase()},"method=",b("method=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.method=e},"ttl=",b("ttl=",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.ttl=e},"maddr=",b("maddr=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.maddr=e},"lr",b("lr",!0),function(){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.lr=void 0},function(e,s){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),s=null===s?void 0:s[1],t.data.uri_params[e.toLowerCase()]=s},function(e,s){e=e.join("").toLowerCase(),s=s.join(""),(t=t||{data:{}}).data.uri_headers||(t.data.uri_headers={}),t.data.uri_headers[e]?t.data.uri_headers[e].push(s):t.data.uri_headers[e]=[s]},function(){"Refer_To"===(t=t||{data:{}}).startRule&&(t.data.uri=new r.a(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params)},"//",b("//",!1),function(){(t=t||{data:{}}).data.scheme=v()},b("SIP",!0),function(){(t=t||{data:{}}).data.sip_version=v()},"INVITE",b("INVITE",!1),"ACK",b("ACK",!1),"VXACH",b("VXACH",!1),"OPTIONS",b("OPTIONS",!1),"BYE",b("BYE",!1),"CANCEL",b("CANCEL",!1),"REGISTER",b("REGISTER",!1),"SUBSCRIBE",b("SUBSCRIBE",!1),"NOTIFY",b("NOTIFY",!1),"REFER",b("REFER",!1),"PUBLISH",b("PUBLISH",!1),function(){return(t=t||{data:{}}).data.method=v(),t.data.method},function(e){(t=t||{data:{}}).data.status_code=parseInt(e.join(""))},function(){(t=t||{data:{}}).data.reason_phrase=v()},function(){(t=t||{data:{}}).data=v()},function(){var e,s;for(s=(t=t||{data:{}}).data.multi_header.length,e=0;e<s;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new i.a(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:d,offset:w().start.offset,parsed:e})},function(e){'"'===(e=v().trim())[0]&&(e=e.substring(1,e.length-1)),(t=t||{data:{}}).data.displayName=e},"q",b("q",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.q=e},"expires",b("expires",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.expires=e},function(e){return parseInt(e.join(""))},"0",b("0",!1),function(){return parseFloat(v())},function(e,s){(t=t||{data:{}}).data.params||(t.data.params={}),s=null===s?void 0:s[1],t.data.params[e.toLowerCase()]=s},"render",b("render",!0),"session",b("session",!0),"icon",b("icon",!0),"alert",b("alert",!0),function(){"Content_Disposition"===(t=t||{data:{}}).startRule&&(t.data.type=v().toLowerCase())},"handling",b("handling",!0),"optional",b("optional",!0),"required",b("required",!0),function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(){(t=t||{data:{}}).data=v()},"text",b("text",!0),"image",b("image",!0),"audio",b("audio",!0),"video",b("video",!0),"application",b("application",!0),"message",b("message",!0),"multipart",b("multipart",!0),"x-",b("x-",!0),function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(e){(t=t||{data:{}}).data.event=e.toLowerCase()},function(){var e=(t=t||{data:{}}).data.tag;t.data=new i.a(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"tag",b("tag",!0),function(e){(t=t||{data:{}}).data.tag=e},function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(){(t=t||{data:{}}).data=new i.a(t.data.uri,t.data.displayName,t.data.params)},"digest",b("Digest",!0),"realm",b("realm",!0),function(e){(t=t||{data:{}}).data.realm=e},"domain",b("domain",!0),"nonce",b("nonce",!0),function(e){(t=t||{data:{}}).data.nonce=e},"opaque",b("opaque",!0),function(e){(t=t||{data:{}}).data.opaque=e},"stale",b("stale",!0),"true",b("true",!0),function(){(t=t||{data:{}}).data.stale=!0},"false",b("false",!0),function(){(t=t||{data:{}}).data.stale=!1},"algorithm",b("algorithm",!0),"md5",b("MD5",!0),"md5-sess",b("MD5-sess",!0),function(e){(t=t||{data:{}}).data.algorithm=e.toUpperCase()},"qop",b("qop",!0),"auth-int",b("auth-int",!0),"auth",b("auth",!0),function(e){(t=t||{data:{}}).data.qop||(t.data.qop=[]),t.data.qop.push(e.toLowerCase())},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(){var e,s;for(s=(t=t||{data:{}}).data.multi_header.length,e=0;e<s;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new i.a(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:d,offset:w().start.offset,parsed:e})},function(){(t=t||{data:{}}).data=new i.a(t.data.uri,t.data.displayName,t.data.params)},function(){(t=t||{data:{}}).data.replaces_from_tag&&t.data.replaces_to_tag||(t.data=-1)},function(){(t=t||{data:{}}).data={call_id:t.data}},"from-tag",b("from-tag",!0),function(e){(t=t||{data:{}}).data.replaces_from_tag=e},"to-tag",b("to-tag",!0),function(e){(t=t||{data:{}}).data.replaces_to_tag=e},"early-only",b("early-only",!0),function(){(t=t||{data:{}}).data.early_only=!0},function(e,t){return t},function(e,t){return function(e,t){return[e].concat(t)}(e,t)},function(e){"Require"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},"active",b("active",!0),"pending",b("pending",!0),"terminated",b("terminated",!0),function(){(t=t||{data:{}}).data.state=v()},"reason",b("reason",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.reason=e)},function(e){t=t||{data:{}},void 0!==e&&(t.data.expires=e)},"retry_after",b("retry_after",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.retry_after=e)},"deactivated",b("deactivated",!0),"probation",b("probation",!0),"rejected",b("rejected",!0),"timeout",b("timeout",!0),"giveup",b("giveup",!0),"noresource",b("noresource",!0),"invariant",b("invariant",!0),function(e){"Supported"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(){var e=(t=t||{data:{}}).data.tag;t.data=new i.a(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"ttl",b("ttl",!0),function(e){(t=t||{data:{}}).data.ttl=e},"maddr",b("maddr",!0),function(e){(t=t||{data:{}}).data.maddr=e},"received",b("received",!0),function(e){(t=t||{data:{}}).data.received=e},"branch",b("branch",!0),function(e){(t=t||{data:{}}).data.branch=e},"rport",b("rport",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.rport=e.join(""))},function(e){(t=t||{data:{}}).data.protocol=e},b("UDP",!0),b("TCP",!0),b("TLS",!0),b("SCTP",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data.host=v()},function(e){(t=t||{data:{}}).data.port=parseInt(e.join(""))},function(e){return parseInt(e.join(""))},function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.deltaSeconds=e)},"refresher",b("refresher",!1),"uas",b("uas",!1),"uac",b("uac",!1),function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.refresher=e)},function(e){"Min_SE"===(t=t||{data:{}}).startRule&&(t.data=e)},"stuns",b("stuns",!0),"stun",b("stun",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(e){(t=t||{data:{}}).data.host=e},"?transport=",b("?transport=",!1),"turns",b("turns",!0),"turn",b("turn",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data=v()},"Referred-By",b("Referred-By",!1),"b",b("b",!1),"cid",b("cid",!1)],h=[R('2 ""6 7!'),R('4"""5!7#'),R('4$""5!7%'),R('4&""5!7\''),R(";'.# &;("),R('4(""5!7)'),R('4*""5!7+'),R('2,""6,7-'),R('2.""6.7/'),R('40""5!71'),R('22""6273. &24""6475.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),R(";).# &;,"),R('2F""6F7G.} &2H""6H7I.q &2J""6J7K.e &2L""6L7M.Y &2N""6N7O.M &2P""6P7Q.A &2R""6R7S.5 &2T""6T7U.) &2V""6V7W'),R('%%2X""6X7Y/5#;#/,$;#/#$+#)(#\'#("\'#&\'#/"!&,)'),R('%%$;$0#*;$&/,#; /#$+")("\'#&\'#." &"/=#$;$/�#*;$&&&#/\'$8":Z" )("\'#&\'#'),R(';.." &"'),R("%$;'.# &;(0)*;'.# &;(&/?#28\"\"6879/0$;//'$8#:[# )(#'#(\"'#&'#"),R('%%$;2/�#*;2&&&#/g#$%$;.0#*;.&/,#;2/#$+")("\'#&\'#0=*%$;.0#*;.&/,#;2/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),R('4\\""5!7].# &;3'),R('4^""5!7_'),R('4`""5!7a'),R(';!.) &4b""5!7c'),R('%$;). &2F""6F7G. &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/#0*;). &2F""6F7G. &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),R('%$;). &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/#0*;). &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),R('2T""6T7U.ã &2V""6V7W.× &2f""6f7g.Ë &2h""6h7i.¿ &2:""6:7;.³ &2D""6D7E.§ &22""6273. &28""6879. &2j""6j7k. &;&.} &24""6475.q &2l""6l7m.e &2n""6n7o.Y &26""6677.M &2>""6>7?.A &2p""6p7q.5 &2r""6r7s.) &;\'.# &;('),R('%$;).ī &2F""6F7G.ğ &2J""6J7K.ē &2L""6L7M.ć &2X""6X7Y.û &2P""6P7Q.ï &2H""6H7I.ã &2@""6@7A.× &2d""6d7e.Ë &2R""6R7S.¿ &2N""6N7O.³ &2T""6T7U.§ &2V""6V7W. &2f""6f7g. &2h""6h7i. &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s/Ĵ#0ı*;).ī &2F""6F7G.ğ &2J""6J7K.ē &2L""6L7M.ć &2X""6X7Y.û &2P""6P7Q.ï &2H""6H7I.ã &2@""6@7A.× &2d""6d7e.Ë &2R""6R7S.¿ &2N""6N7O.³ &2T""6T7U.§ &2V""6V7W. &2f""6f7g. &2h""6h7i. &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s&&&#/"!&,)'),R("%;//?#2P\"\"6P7Q/0$;//'$8#:t# )(#'#(\"'#&'#"),R("%;//?#24\"\"6475/0$;//'$8#:u# )(#'#(\"'#&'#"),R("%;//?#2>\"\"6>7?/0$;//'$8#:v# )(#'#(\"'#&'#"),R("%;//?#2T\"\"6T7U/0$;//'$8#:w# )(#'#(\"'#&'#"),R("%;//?#2V\"\"6V7W/0$;//'$8#:x# )(#'#(\"'#&'#"),R('%2h""6h7i/0#;//\'$8":y" )("\'#&\'#'),R('%;//6#2f""6f7g/\'$8":z" )("\'#&\'#'),R("%;//?#2D\"\"6D7E/0$;//'$8#:{# )(#'#(\"'#&'#"),R("%;//?#22\"\"6273/0$;//'$8#:|# )(#'#(\"'#&'#"),R("%;//?#28\"\"6879/0$;//'$8#:}# )(#'#(\"'#&'#"),R("%;//0#;&/'$8\":~\" )(\"'#&'#"),R("%;&/0#;//'$8\":~\" )(\"'#&'#"),R("%;=/T#$;G.) &;K.# &;F0/*;G.) &;K.# &;F&/,$;>/#$+#)(#'#(\"'#&'#"),R('4""5!7.A &4""5!7.5 &4""5!7.) &;3.# &;.'),R("%%;//Q#;&/H$$;J.# &;K0)*;J.# &;K&/,$;&/#$+$)($'#(#'#(\"'#&'#/\"!&,)"),R("%;//]#;&/T$%$;J.# &;K0)*;J.# &;K&/\"!&,)/1$;&/($8$:
$!!)($'#(#'#(\"'#&'#"),R(';..G &2L""6L7M.; &4""5!7./ &4""5!7.# &;3'),R('%2j""6j7k/J#4""5!7.5 &4""5!7.) &4""5!7/#$+")("\'#&\'#'),R("%;N/M#28\"\"6879/>$;O.\" &\"/0$;S/'$8$:$ )($'#(#'#(\"'#&'#"),R("%;N/d#28\"\"6879/U$;O.\" &\"/G$;S/>$;_/5$;l.\" &\"/'$8&:& )(&'#(%'#($'#(#'#(\"'#&'#"),R('%3""5$7.) &3""5#7/\' 8!:!! )'),R('%;P/]#%28""6879/,#;R/#$+")("\'#&\'#." &"/6$2:""6:7;/\'$8#:# )(#\'#("\'#&\'#'),R("$;+.) &;-.# &;Q/2#0/*;+.) &;-.# &;Q&&&#"),R('2<""6<7=.q &2>""6>7?.e &2@""6@7A.Y &2B""6B7C.M &2D""6D7E.A &22""6273.5 &26""6677.) &24""6475'),R('%$;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E0e*;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E&/& 8!:! )'),R('%;T/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),R("%;U.) &;\\.# &;X/& 8!:! )"),R('%$%;V/2#2J""6J7K/#$+")("\'#&\'#0<*%;V/2#2J""6J7K/#$+")("\'#&\'#&/D#;W/;$2J""6J7K." &"/\'$8#:# )(#\'#("\'#&\'#'),R('$4""5!7/,#0)*4""5!7&&&#'),R('%4$""5!7%/?#$4""5!70)*4""5!7&/#$+")("\'#&\'#'),R('%2l""6l7m/?#;Y/6$2n""6n7o/\'$8#:# )(#\'#("\'#&\'#'),R('%%;Z/³#28""6879/¤$;Z/$28""6879/$;Z/$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+-)(-\'#(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.ސ &%2""67/¤#;Z/$28""6879/$;Z/$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+,)(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.۹ &%2""67/#;Z/$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.ٺ &%2""67/t#;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.ؓ &%2""67/\\#;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+&)(&\'#(%\'#($\'#(#\'#("\'#&\'#.ׄ &%2""67/D#;Z/;$28""6879/,$;[/#$+$)($\'#(#\'#("\'#&\'#.֍ &%2""67/,#;[/#$+")("\'#&\'#.ծ &%2""67/,#;Z/#$+")("\'#&\'#.Տ &%;Z/#2""67/$;Z/$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$++)(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Ӈ &%;Z/ª#%28""6879/,#;Z/#$+")("\'#&\'#." &"/$2""67/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.а &%;Z/¹#%28""6879/,#;Z/#$+")("\'#&\'#." &"/$%28""6879/,#;Z/#$+")("\'#&\'#." &"/k$2""67/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+))()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Ί &%;Z/È#%28""6879/,#;Z/#$+")("\'#&\'#." &"/¡$%28""6879/,#;Z/#$+")("\'#&\'#." &"/z$%28""6879/,#;Z/#$+")("\'#&\'#." &"/S$2""67/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.˕ &%;Z/×#%28""6879/,#;Z/#$+")("\'#&\'#." &"/°$%28""6879/,#;Z/#$+")("\'#&\'#." &"/$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2""67/,$;[/#$+\')(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.ȑ &%;Z/þ#%28""6879/,#;Z/#$+")("\'#&\'#." &"/×$%28""6879/,#;Z/#$+")("\'#&\'#." &"/°$%28""6879/,#;Z/#$+")("\'#&\'#." &"/$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2""67/,$;Z/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.Ħ &%;Z/Ĝ#%28""6879/,#;Z/#$+")("\'#&\'#." &"/õ$%28""6879/,#;Z/#$+")("\'#&\'#." &"/Î$%28""6879/,#;Z/#$+")("\'#&\'#." &"/§$%28""6879/,#;Z/#$+")("\'#&\'#." &"/$%28""6879/,#;Z/#$+")("\'#&\'#." &"/Y$%28""6879/,#;Z/#$+")("\'#&\'#." &"/2$2""67/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#/& 8!: ! )'),R('%;#/M#;#." &"/?$;#." &"/1$;#." &"/#$+$)($\'#(#\'#("\'#&\'#'),R("%;Z/;#28\"\"6879/,$;Z/#$+#)(#'#(\"'#&'#.# &;\\"),R("%;]/o#2J\"\"6J7K/`$;]/W$2J\"\"6J7K/H$;]/?$2J\"\"6J7K/0$;]/'$8':¡' )(''#(&'#(%'#($'#(#'#(\"'#&'#"),R('%2¢""6¢7£/2#4¤""5!7¥/#$+")("\'#&\'#. &%2¦""6¦7§/;#4¨""5!7©/,$;!/#$+#)(#\'#("\'#&\'#.j &%2ª""6ª7«/5#;!/,$;!/#$+#)(#\'#("\'#&\'#.B &%4¬""5!7/,#;!/#$+")("\'#&\'#.# &;!'),R('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:®!! )'),R('$%22""6273/,#;`/#$+")("\'#&\'#0<*%22""6273/,#;`/#$+")("\'#&\'#&'),R(";a.A &;b.; &;c.5 &;d./ &;e.) &;f.# &;g"),R('%3¯""5*7°/a#3±""5#7².G &3³""5#7´.; &3µ""5$7¶./ &3·""5#7¸.# &;6/($8":¹"! )("\'#&\'#'),R('%3º""5%7»/I#3¼""5%7½./ &3¾""5"7¿.# &;6/($8":À"! )("\'#&\'#'),R('%3Á""5\'7Â/1#;/($8":Ã"! )("\'#&\'#'),R('%3Ä""5$7Å/1#;ð/($8":Æ"! )("\'#&\'#'),R('%3Ç""5&7È/1#;T/($8":É"! )("\'#&\'#'),R('%3Ê""5"7Ë/N#%2>""6>7?/,#;6/#$+")("\'#&\'#." &"/\'$8":Ì" )("\'#&\'#'),R('%;h/P#%2>""6>7?/,#;i/#$+")("\'#&\'#." &"/)$8":Í""! )("\'#&\'#'),R('%$;j/�#*;j&&&#/"!&,)'),R('%$;j/�#*;j&&&#/"!&,)'),R(";k.) &;+.# &;-"),R('2l""6l7m.e &2n""6n7o.Y &24""6475.M &28""6879.A &2<""6<7=.5 &2@""6@7A.) &2B""6B7C'),R('%26""6677/n#;m/e$$%2<""6<7=/,#;m/#$+")("\'#&\'#0<*%2<""6<7=/,#;m/#$+")("\'#&\'#&/#$+#)(#\'#("\'#&\'#'),R('%;n/A#2>""6>7?/2$;o/)$8#:Î#"" )(#\'#("\'#&\'#'),R("$;p.) &;+.# &;-/2#0/*;p.) &;+.# &;-&&&#"),R("$;p.) &;+.# &;-0/*;p.) &;+.# &;-&"),R('2l""6l7m.e &2n""6n7o.Y &24""6475.M &26""6677.A &28""6879.5 &2@""6@7A.) &2B""6B7C'),R(";.# &;r"),R("%;/G#;'/>$;s/5$;'/,$;/#$+%)(%'#($'#(#'#(\"'#&'#"),R(";M.# &;t"),R("%;/E#28\"\"6879/6$;u.# &;x/'$8#:Ï# )(#'#(\"'#&'#"),R('%;v.# &;w/J#%26""6677/,#;/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),R('%2Ð""6Ð7Ñ/:#;/1$;w." &"/#$+#)(#\'#("\'#&\'#'),R('%24""6475/,#;{/#$+")("\'#&\'#'),R("%;z/3#$;y0#*;y&/#$+\")(\"'#&'#"),R(";*.) &;+.# &;-"),R(';+. &;-. &22""6273.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),R('%;|/e#$%24""6475/,#;|/#$+")("\'#&\'#0<*%24""6475/,#;|/#$+")("\'#&\'#&/#$+")("\'#&\'#'),R('%$;~0#*;~&/e#$%22""6273/,#;}/#$+")("\'#&\'#0<*%22""6273/,#;}/#$+")("\'#&\'#&/#$+")("\'#&\'#'),R("$;~0#*;~&"),R(';+.w &;-.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),R('%%;"/#$;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K0M*;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K&/#$+")("\'#&\'#/& 8!:Ò! )'),R(";.# &;"),R('%%;O/2#2:""6:7;/#$+")("\'#&\'#." &"/,#;S/#$+")("\'#&\'#." &"'),R('$;+. &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A/#0*;+. &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A&&&#'),R("$;y0#*;y&"),R('%3""5#7Ó/q#24""6475/b$$;!/�#*;!&&&#/L$2J""6J7K/=$$;!/�#*;!&&&#/\'$8%:Ô% )(%\'#($\'#(#\'#("\'#&\'#'),R('2Õ""6Õ7Ö'),R('2×""6×7Ø'),R('2Ù""6Ù7Ú'),R('2Û""6Û7Ü'),R('2Ý""6Ý7Þ'),R('2ß""6ß7à'),R('2á""6á7â'),R('2ã""6ã7ä'),R('2å""6å7æ'),R('2ç""6ç7è'),R('2é""6é7ê'),R("%;
.Y &;.S &;.M &;.G &;.A &;.; &;.5 &;./ &;.) &;.# &;6/& 8!:ë! )"),R("%;/G#;'/>$;/5$;'/,$;/#$+%)(%'#($'#(#'#(\"'#&'#"),R("%;/' 8!:ì!! )"),R("%;!/5#;!/,$;!/#$+#)(#'#(\"'#&'#"),R("%$;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(0G*;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(&/& 8!:í! )"),R("%;¶/Y#$%;A/,#;¶/#$+\")(\"'#&'#06*%;A/,#;¶/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R('%;9/N#%2:""6:7;/,#;9/#$+")("\'#&\'#." &"/\'$8":î" )("\'#&\'#'),R("%;:.c &%;/Y#$%;A/,#;/#$+\")(\"'#&'#06*%;A/,#;/#$+\")(\"'#&'#&/#$+\")(\"'#&'#/& 8!:ï! )"),R("%;L.# &;/]#$%;B/,#;/#$+\")(\"'#&'#06*%;B/,#;/#$+\")(\"'#&'#&/'$8\":ð\" )(\"'#&'#"),R("%;.\" &\"/>#;@/5$;M/,$;?/#$+$)($'#(#'#(\"'#&'#"),R("%%;6/Y#$%;./,#;6/#$+\")(\"'#&'#06*%;./,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#.# &;H/' 8!:ñ!! )"),R(";.) &;.# &; "),R("%3ò\"\"5!7ó/:#;</1$;/($8#:ô#! )(#'#(\"'#&'#"),R("%3õ\"\"5'7ö/:#;</1$;/($8#:÷#! )(#'#(\"'#&'#"),R("%$;!/�#*;!&&&#/' 8!:ø!! )"),R('%2ù""6ù7ú/o#%2J""6J7K/M#;!." &"/?$;!." &"/1$;!." &"/#$+$)($\'#(#\'#("\'#&\'#." &"/\'$8":û" )("\'#&\'#'),R('%;6/J#%;</,#;¡/#$+")("\'#&\'#." &"/)$8":ü""! )("\'#&\'#'),R(";6.) &;T.# &;H"),R("%;£/Y#$%;B/,#;¤/#$+\")(\"'#&'#06*%;B/,#;¤/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R('%3ý""5&7þ.G &3ÿ""5\'7Ā.; &3ā""5$7Ă./ &3ă""5%7Ą.# &;6/& 8!:ą! )'),R(";¥.# &; "),R('%3Ć""5(7ć/M#;</D$3Ĉ""5(7ĉ./ &3Ċ""5(7ċ.# &;6/#$+#)(#\'#("\'#&\'#'),R("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R("%$;!/�#*;!&&&#/' 8!:Č!! )"),R("%;©/& 8!:č! )"),R("%;ª/k#;;/b$;¯/Y$$%;B/,#;°/#$+\")(\"'#&'#06*%;B/,#;°/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),R(";«.# &;¬"),R('3Ď""5$7ď.S &3Đ""5%7đ.G &3Ē""5%7ē.; &3Ĕ""5%7ĕ./ &3Ė""5+7ė.# &;'),R('3Ę""5\'7ę./ &3Ě""5)7ě.# &;'),R(";6.# &;®"),R('%3Ĝ""5"7ĝ/,#;6/#$+")("\'#&\'#'),R(";.# &;6"),R("%;6/5#;</,$;±/#$+#)(#'#(\"'#&'#"),R(";6.# &;H"),R("%;³/5#;./,$;/#$+#)(#'#(\"'#&'#"),R("%$;!/�#*;!&&&#/' 8!:Ğ!! )"),R("%;/' 8!:ğ!! )"),R('%;¶/^#$%;B/,#; /#$+")("\'#&\'#06*%;B/,#; /#$+")("\'#&\'#&/($8":Ġ"!!)("\'#&\'#'),R('%%;7/e#$%2J""6J7K/,#;7/#$+")("\'#&\'#0<*%2J""6J7K/,#;7/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),R("%;L.# &;/]#$%;B/,#;¸/#$+\")(\"'#&'#06*%;B/,#;¸/#$+\")(\"'#&'#&/'$8\":ġ\" )(\"'#&'#"),R(";¹.# &; "),R("%3Ģ\"\"5#7ģ/:#;</1$;6/($8#:Ĥ#! )(#'#(\"'#&'#"),R("%$;!/�#*;!&&&#/' 8!:ĥ!! )"),R("%;/' 8!:Ħ!! )"),R("%$;0#*;&/x#;@/o$;M/f$;?/]$$%;B/,#; /#$+\")(\"'#&'#06*%;B/,#; /#$+\")(\"'#&'#&/'$8%:ħ% )(%'#($'#(#'#(\"'#&'#"),R(";¾"),R("%3Ĩ\"\"5&7ĩ/k#;./b$;Á/Y$$%;A/,#;Á/#$+\")(\"'#&'#06*%;A/,#;Á/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#.# &;¿"),R("%;6/k#;./b$;À/Y$$%;A/,#;À/#$+\")(\"'#&'#06*%;A/,#;À/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),R("%;6/;#;</2$;6.# &;H/#$+#)(#'#(\"'#&'#"),R(";Â.G &;Ä.A &;Æ.; &;È.5 &;É./ &;Ê.) &;Ë.# &;À"),R("%3Ī\"\"5%7ī/5#;</,$;Ã/#$+#)(#'#(\"'#&'#"),R("%;I/' 8!:Ĭ!! )"),R("%3ĭ\"\"5&7Į/#;</$;D/
$;Å/|$$%$;'/�#*;'&&&#/,#;Å/#$+\")(\"'#&'#0C*%$;'/�#*;'&&&#/,#;Å/#$+\")(\"'#&'#&/,$;E/#$+&)(&'#(%'#($'#(#'#(\"'#&'#"),R(";t.# &;w"),R("%3į\"\"5%7İ/5#;</,$;Ç/#$+#)(#'#(\"'#&'#"),R("%;I/' 8!:ı!! )"),R("%3IJ\"\"5&7ij/:#;</1$;I/($8#:Ĵ#! )(#'#(\"'#&'#"),R('%3ĵ""5%7Ķ/]#;</T$%3ķ""5$7ĸ/& 8!:Ĺ! ).4 &%3ĺ""5%7Ļ/& 8!:ļ! )/#$+#)(#\'#("\'#&\'#'),R('%3Ľ""5)7ľ/R#;</I$3Ŀ""5#7ŀ./ &3Ł""5(7ł.# &;6/($8#:Ń#! )(#\'#("\'#&\'#'),R('%3ń""5#7Ņ/#;</$;D/$%;Ì/e#$%2D""6D7E/,#;Ì/#$+")("\'#&\'#0<*%2D""6D7E/,#;Ì/#$+")("\'#&\'#&/#$+")("\'#&\'#/,$;E/#$+%)(%\'#($\'#(#\'#("\'#&\'#'),R('%3ņ""5(7Ň./ &3ň""5$7ʼn.# &;6/\' 8!:Ŋ!! )'),R("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R("%;Ï/G#;./>$;Ï/5$;./,$;/#$+%)(%'#($'#(#'#(\"'#&'#"),R("%$;!/�#*;!&&&#/' 8!:ŋ!! )"),R("%;Ñ/]#$%;A/,#;Ñ/#$+\")(\"'#&'#06*%;A/,#;Ñ/#$+\")(\"'#&'#&/'$8\":Ō\" )(\"'#&'#"),R("%;/]#$%;B/,#; /#$+\")(\"'#&'#06*%;B/,#; /#$+\")(\"'#&'#&/'$8\":ō\" )(\"'#&'#"),R('%;L.O &;.I &%;@." &"/:#;t/1$;?." &"/#$+#)(#\'#("\'#&\'#/]#$%;B/,#; /#$+")("\'#&\'#06*%;B/,#; /#$+")("\'#&\'#&/\'$8":Ŏ" )("\'#&\'#'),R("%;Ô/]#$%;B/,#;Õ/#$+\")(\"'#&'#06*%;B/,#;Õ/#$+\")(\"'#&'#&/'$8\":ŏ\" )(\"'#&'#"),R("%;/& 8!:Ő! )"),R('%3ő""5(7Œ/:#;</1$;6/($8#:œ#! )(#\'#("\'#&\'#.g &%3Ŕ""5&7ŕ/:#;</1$;6/($8#:Ŗ#! )(#\'#("\'#&\'#.: &%3ŗ""5*7Ř/& 8!:ř! ).# &; '),R('%%;6/k#$%;A/2#;6/)$8":Ś""$ )("\'#&\'#0<*%;A/2#;6/)$8":Ś""$ )("\'#&\'#&/)$8":ś""! )("\'#&\'#." &"/\' 8!:Ŝ!! )'),R("%;Ø/Y#$%;A/,#;Ø/#$+\")(\"'#&'#06*%;A/,#;Ø/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R("%;/Y#$%;B/,#; /#$+\")(\"'#&'#06*%;B/,#; /#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R("%$;!/�#*;!&&&#/' 8!:ŝ!! )"),R("%;Û/Y#$%;B/,#;Ü/#$+\")(\"'#&'#06*%;B/,#;Ü/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R('%3Ş""5&7ş.; &3Š""5\'7š./ &3Ţ""5*7ţ.# &;6/& 8!:Ť! )'),R("%3ť\"\"5&7Ŧ/:#;</1$;Ý/($8#:ŧ#! )(#'#(\"'#&'#.} &%3õ\"\"5'7ö/:#;</1$;/($8#:Ũ#! )(#'#(\"'#&'#.P &%3ũ\"\"5+7Ū/:#;</1$;/($8#:ū#! )(#'#(\"'#&'#.# &; "),R('3Ŭ""5+7ŭ.k &3Ů""5)7ů._ &3Ű""5(7ű.S &3Ų""5\'7ų.G &3Ŵ""5&7ŵ.; &3Ŷ""5*7ŷ./ &3Ÿ""5)7Ź.# &;6'),R(';1." &"'),R('%%;6/k#$%;A/2#;6/)$8":Ś""$ )("\'#&\'#0<*%;A/2#;6/)$8":Ś""$ )("\'#&\'#&/)$8":ś""! )("\'#&\'#." &"/\' 8!:ź!! )'),R("%;L.# &;/]#$%;B/,#;á/#$+\")(\"'#&'#06*%;B/,#;á/#$+\")(\"'#&'#&/'$8\":Ż\" )(\"'#&'#"),R(";¹.# &; "),R("%;ã/Y#$%;A/,#;ã/#$+\")(\"'#&'#06*%;A/,#;ã/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),R("%;ê/k#;./b$;í/Y$$%;B/,#;ä/#$+\")(\"'#&'#06*%;B/,#;ä/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),R(";å.; &;æ.5 &;ç./ &;è.) &;é.# &; "),R("%3ż\"\"5#7Ž/:#;</1$;ð/($8#:ž#! )(#'#(\"'#&'#"),R("%3ſ\"\"5%7ƀ/:#;</1$;T/($8#:Ɓ#! )(#'#(\"'#&'#"),R("%3Ƃ\"\"5(7ƃ/F#;</=$;\\.) &;Y.# &;X/($8#:Ƅ#! )(#'#(\"'#&'#"),R("%3ƅ\"\"5&7Ɔ/:#;</1$;6/($8#:Ƈ#! )(#'#(\"'#&'#"),R("%3ƈ\"\"5%7Ɖ/A#;</8$$;!0#*;!&/($8#:Ɗ#! )(#'#(\"'#&'#"),R("%;ë/G#;;/>$;6/5$;;/,$;ì/#$+%)(%'#($'#(#'#(\"'#&'#"),R('%3""5#7Ó.# &;6/\' 8!:Ƌ!! )'),R('%3±""5#7ƌ.G &3³""5#7ƍ.; &3·""5#7Ǝ./ &3µ""5$7Ə.# &;6/\' 8!:Ɛ!! )'),R('%;î/D#%;C/,#;ï/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),R("%;U.) &;\\.# &;X/& 8!:Ƒ! )"),R('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:ƒ!! )'),R('%%;!/?#;!." &"/1$;!." &"/#$+#)(#\'#("\'#&\'#/\' 8!:Ɠ!! )'),R(";¾"),R('%;/^#$%;B/,#;ó/#$+")("\'#&\'#06*%;B/,#;ó/#$+")("\'#&\'#&/($8":Ɣ"!!)("\'#&\'#'),R(";ô.# &; "),R('%2ƕ""6ƕ7Ɩ/L#;</C$2Ɨ""6Ɨ7Ƙ.) &2ƙ""6ƙ7ƚ/($8#:ƛ#! )(#\'#("\'#&\'#'),R('%;/^#$%;B/,#; /#$+")("\'#&\'#06*%;B/,#; /#$+")("\'#&\'#&/($8":Ɯ"!!)("\'#&\'#'),R("%;6/5#;0/,$;÷/#$+#)(#'#(\"'#&'#"),R("$;2.) &;4.# &;.0/*;2.) &;4.# &;.&"),R("$;%0#*;%&"),R("%;ú/;#28\"\"6879/,$;û/#$+#)(#'#(\"'#&'#"),R('%3Ɲ""5%7ƞ.) &3Ɵ""5$7Ơ/\' 8!:ơ!! )'),R('%;ü/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),R("%;\\.) &;X.# &;/' 8!:Ƣ!! )"),R(';".S &;!.M &2F""6F7G.A &2J""6J7K.5 &2H""6H7I.) &2N""6N7O'),R('2L""6L7M. &2B""6B7C. &2<""6<7=.} &2R""6R7S.q &2T""6T7U.e &2V""6V7W.Y &2P""6P7Q.M &2@""6@7A.A &2D""6D7E.5 &22""6273.) &2>""6>7?'),R('%;Ā/b#28""6879/S$;û/J$%2ƣ""6ƣ7Ƥ/,#;ì/#$+")("\'#&\'#." &"/#$+$)($\'#(#\'#("\'#&\'#'),R('%3ƥ""5%7Ʀ.) &3Ƨ""5$7ƨ/\' 8!:ơ!! )'),R('%3±""5#7².6 &3³""5#7´.* &$;+0#*;+&/\' 8!:Ʃ!! )'),R("%;Ą/#2F\"\"6F7G/x$;ă/o$2F\"\"6F7G/`$;ă/W$2F\"\"6F7G/H$;ă/?$2F\"\"6F7G/0$;ą/'$8):ƪ) )()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"),R("%;#/>#;#/5$;#/,$;#/#$+$)($'#(#'#(\"'#&'#"),R("%;ă/,#;ă/#$+\")(\"'#&'#"),R("%;ă/5#;ă/,$;ă/#$+#)(#'#(\"'#&'#"),R("%;q/T#$;m0#*;m&/D$%; /,#;ø/#$+\")(\"'#&'#.\" &\"/#$+#)(#'#(\"'#&'#"),R('%2ƫ""6ƫ7Ƭ.) &2ƭ""6ƭ7Ʈ/w#;0/n$;Ĉ/e$$%;B/2#;ĉ.# &; /#$+")("\'#&\'#0<*%;B/2#;ĉ.# &; /#$+")("\'#&\'#&/#$+$)($\'#(#\'#("\'#&\'#'),R(";.# &;L"),R("%2Ư\"\"6Ư7ư/5#;</,$;Ċ/#$+#)(#'#(\"'#&'#"),R("%;D/S#;,/J$2:\"\"6:7;/;$;,.# &;T/,$;E/#$+%)(%'#($'#(#'#(\"'#&'#")];let d=0,l=0;const u=[{line:1,column:1}];let g,p=0,f=[],m=0;if(void 0!==t.startRule){if(!(t.startRule in o))throw new Error("Can't start parsing from rule \""+t.startRule+'".');a=o[t.startRule]}function v(){return e.substring(l,d)}function w(){return S(l,d)}function b(e,t){return{type:"literal",text:e,ignoreCase:t}}function y(e,t,s){return{type:"class",parts:e,inverted:t,ignoreCase:s}}function T(t){let s,i=u[t];if(i)return i;for(s=t-1;!u[s];)s--;for(i=u[s],i={line:i.line,column:i.column};s<t;)10===e.charCodeAt(s)?(i.line++,i.column=1):i.column++,s++;return u[t]=i,i}function S(e,t){const s=T(e),i=T(t);return{start:{offset:e,line:s.line,column:s.column},end:{offset:t,line:i.line,column:i.column}}}function E(e){d<p||(d>p&&(p=d,f=[]),f.push(e))}function I(e,t,s){return new n(n.buildMessage(e,t),e,t,s)}function R(e){return e.split("").map(e=>e.charCodeAt(0)-32)}if(t.data={},g=function t(i){const r=h[i];let n=0;const o=[];let a=r.length;const u=[],g=[];let p;for(;;){for(;n<a;)switch(r[n]){case 0:g.push(c[r[n+1]]),n+=2;break;case 1:g.push(void 0),n++;break;case 2:g.push(null),n++;break;case 3:g.push(s),n++;break;case 4:g.push([]),n++;break;case 5:g.push(d),n++;break;case 6:g.pop(),n++;break;case 7:d=g.pop(),n++;break;case 8:g.length-=r[n+1],n+=2;break;case 9:g.splice(-2,1),n++;break;case 10:g[g.length-2].push(g.pop()),n++;break;case 11:g.push(g.splice(g.length-r[n+1],r[n+1])),n+=2;break;case 12:g.push(e.substring(g.pop(),d)),n++;break;case 13:u.push(a),o.push(n+3+r[n+1]+r[n+2]),g[g.length-1]?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 14:u.push(a),o.push(n+3+r[n+1]+r[n+2]),g[g.length-1]===s?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 15:u.push(a),o.push(n+3+r[n+1]+r[n+2]),g[g.length-1]!==s?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 16:g[g.length-1]!==s?(u.push(a),o.push(n),a=n+2+r[n+1],n+=2):n+=2+r[n+1];break;case 17:u.push(a),o.push(n+3+r[n+1]+r[n+2]),e.length>d?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 18:u.push(a),o.push(n+4+r[n+2]+r[n+3]),e.substr(d,c[r[n+1]].length)===c[r[n+1]]?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 19:u.push(a),o.push(n+4+r[n+2]+r[n+3]),e.substr(d,c[r[n+1]].length).toLowerCase()===c[r[n+1]]?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 20:u.push(a),o.push(n+4+r[n+2]+r[n+3]),c[r[n+1]].test(e.charAt(d))?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 21:g.push(e.substr(d,r[n+1])),d+=r[n+1],n+=2;break;case 22:g.push(c[r[n+1]]),d+=c[r[n+1]].length,n+=2;break;case 23:g.push(s),0===m&&E(c[r[n+1]]),n+=2;break;case 24:l=g[g.length-1-r[n+1]],n+=2;break;case 25:l=d,n++;break;case 26:p=r.slice(n+4,n+4+r[n+3]).map((function(e){return g[g.length-1-e]})),g.splice(g.length-r[n+2],r[n+2],c[r[n+1]].apply(null,p)),n+=4+r[n+3];break;case 27:g.push(t(r[n+1])),n+=2;break;case 28:m++,n++;break;case 29:m--,n++;break;default:throw new Error("Invalid opcode: "+r[n]+".")}if(!(u.length>0))break;a=u.pop(),n=o.pop()}return g[0]}(a),g!==s&&d===e.length)return g;throw g!==s&&d<e.length&&E({type:"end"}),I(f,p<e.length?e.charAt(p):null,p<e.length?S(p,p+1):S(p,p))};var a,c;s.d(t,"a",(function(){return a})),(c=a||(a={})).parse=function(e,t){const s={startRule:t};try{o(e,s)}catch(e){s.data=-1}return s.data},c.nameAddrHeaderParse=function(e){const t=c.parse(e,"Name_Addr_Header");return-1!==t?t:void 0},c.URIParse=function(e){const t=c.parse(e,"SIP_URI");return-1!==t?t:void 0}},function(e,t,s){"use strict";s.d(t,"a",(function(){return i}));class i{constructor(e){this.parameters={};for(const t in e)e.hasOwnProperty(t)&&this.setParam(t,e[t])}setParam(e,t){e&&(this.parameters[e.toLowerCase()]=null==t?null:t.toString())}getParam(e){if(e)return this.parameters[e.toLowerCase()]}hasParam(e){return!(!e||void 0===this.parameters[e.toLowerCase()])}deleteParam(e){if(e=e.toLowerCase(),this.hasParam(e)){const t=this.parameters[e];return delete this.parameters[e],t}}clearParams(){this.parameters={}}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s(26);class r extends i.a{constructor(){super()}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return n}));var i=s(23),r=s(1);class n{constructor(){this.headers={}}addHeader(e,t){const s={raw:t};e=Object(r.c)(e),this.headers[e]?this.headers[e].push(s):this.headers[e]=[s]}getHeader(e){const t=this.headers[Object(r.c)(e)];if(t)return t[0]?t[0].raw:void 0}getHeaders(e){const t=this.headers[Object(r.c)(e)],s=[];if(!t)return[];for(const e of t)s.push(e.raw);return s}hasHeader(e){return!!this.headers[Object(r.c)(e)]}parseHeader(e,t=0){if(e=Object(r.c)(e),!this.headers[e])return;if(t>=this.headers[e].length)return;const s=this.headers[e][t],n=s.raw;if(s.parsed)return s.parsed;const o=i.a.parse(n,e.replace(/-/g,"_"));return-1===o?void this.headers[e].splice(t,1):(s.parsed=o,o)}s(e,t=0){return this.parseHeader(e,t)}setHeader(e,t){this.headers[Object(r.c)(e)]=[{raw:t}]}toString(){return this.data}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return i}));class i{constructor(e){this.incomingMessageRequest=e}get request(){return this.incomingMessageRequest.message}accept(e){return this.incomingMessageRequest.accept(e),Promise.resolve()}reject(e){return this.incomingMessageRequest.reject(e),Promise.resolve()}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return r})),s.d(t,"b",(function(){return n}));var i=s(24);class r extends i.a{constructor(e="sip",t,s,i,r,n){if(super(r||{}),this.headers={},!s)throw new TypeError('missing or invalid "host" parameter');for(const e in n)n.hasOwnProperty(e)&&this.setHeader(e,n[e]);this.raw={scheme:e,user:t,host:s,port:i},this.normal={scheme:e.toLowerCase(),user:t,host:s.toLowerCase(),port:i}}get scheme(){return this.normal.scheme}set scheme(e){this.raw.scheme=e,this.normal.scheme=e.toLowerCase()}get user(){return this.normal.user}set user(e){this.normal.user=this.raw.user=e}get host(){return this.normal.host}set host(e){this.raw.host=e,this.normal.host=e.toLowerCase()}get aor(){return this.normal.user+"@"+this.normal.host}get port(){return this.normal.port}set port(e){this.normal.port=this.raw.port=e}setHeader(e,t){this.headers[this.headerize(e)]=t instanceof Array?t:[t]}getHeader(e){if(e)return this.headers[this.headerize(e)]}hasHeader(e){return!!e&&!!this.headers.hasOwnProperty(this.headerize(e))}deleteHeader(e){if(e=this.headerize(e),this.headers.hasOwnProperty(e)){const t=this.headers[e];return delete this.headers[e],t}}clearHeaders(){this.headers={}}clone(){return new r(this._raw.scheme,this._raw.user||"",this._raw.host,this._raw.port,JSON.parse(JSON.stringify(this.parameters)),JSON.parse(JSON.stringify(this.headers)))}toRaw(){return this._toString(this._raw)}toString(){return this._toString(this._normal)}get _normal(){return this.normal}get _raw(){return this.raw}_toString(e){let t=e.scheme+":";e.scheme.toLowerCase().match("^sips?$")||(t+="//"),e.user&&(t+=this.escapeUser(e.user)+"@"),t+=e.host,(e.port||0===e.port)&&(t+=":"+e.port);for(const e in this.parameters)this.parameters.hasOwnProperty(e)&&(t+=";"+e,null!==this.parameters[e]&&(t+="="+this.parameters[e]));const s=[];for(const e in this.headers)if(this.headers.hasOwnProperty(e))for(const t in this.headers[e])this.headers[e].hasOwnProperty(t)&&s.push(e+"="+this.headers[e][t]);return s.length>0&&(t+="?"+s.join("&")),t}escapeUser(e){let t;try{t=decodeURIComponent(e)}catch(e){throw e}return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")}headerize(e){const t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},s=e.toLowerCase().replace(/_/g,"-").split("-"),i=s.length;let r="";for(let e=0;e<i;e++)0!==e&&(r+="-"),r+=s[e].charAt(0).toUpperCase()+s[e].substring(1);return t[r]&&(r=t[r]),r}}function n(e,t){if(e.scheme!==t.scheme)return!1;if(e.user!==t.user||e.host!==t.host||e.port!==t.port)return!1;if(!function(e,t){const s=Object.keys(e.parameters),i=Object.keys(t.parameters);return!!s.filter(e=>i.includes(e)).every(s=>e.parameters[s]===t.parameters[s])&&(!!["user","ttl","method","transport"].every(s=>e.hasParam(s)&&t.hasParam(s)||!e.hasParam(s)&&!t.hasParam(s))&&!!["maddr"].every(s=>e.hasParam(s)&&t.hasParam(s)||!e.hasParam(s)&&!t.hasParam(s)))}(e,t))return!1;const s=Object.keys(e.headers),i=Object.keys(t.headers);if(0!==s.length||0!==i.length){if(s.length!==i.length)return!1;const r=s.filter(e=>i.includes(e));if(r.length!==i.length)return!1;if(!r.every(s=>e.headers[s].length&&t.headers[s].length&&e.headers[s][0]===t.headers[s][0]))return!1}return!0}},function(e,t,s){var i=s(55);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},,function(e,t,s){"use strict";s.r(t);var i=s(40);s.d(t,"Transport",(function(){return i.a}))},function(e,t){function s(t){return e.exports=s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,s(t)}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){var i=s(57),r=s(58),n=s(59),o=s(60);e.exports=function(e){return i(e)||r(e)||n(e)||o()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";var i,r=s(28);!function(e){e[e.error=0]="error",e[e.warn=1]="warn",e[e.log=2]="log",e[e.debug=3]="debug"}(i||(i={}));class n{constructor(e,t,s){this.logger=e,this.category=t,this.label=s}error(e){this.genericLog(i.error,e)}warn(e){this.genericLog(i.warn,e)}log(e){this.genericLog(i.log,e)}debug(e){this.genericLog(i.debug,e)}genericLog(e,t){this.logger.genericLog(e,this.category,this.label,t)}get level(){return this.logger.level}set level(e){this.logger.level=e}}class o{constructor(){this.builtinEnabled=!0,this._level=i.log,this.loggers={},this.logger=this.getLogger("sip:loggerfactory")}get level(){return this._level}set level(e){e>=0&&e<=3?this._level=e:e>3?this._level=3:i.hasOwnProperty(e)?this._level=e:this.logger.error("invalid 'level' parameter value: "+JSON.stringify(e))}get connector(){return this._connector}set connector(e){e?"function"==typeof e?this._connector=e:this.logger.error("invalid 'connector' parameter value: "+JSON.stringify(e)):this._connector=void 0}getLogger(e,t){if(t&&3===this.level)return new n(this,e,t);if(this.loggers[e])return this.loggers[e];{const t=new n(this,e);return this.loggers[e]=t,t}}genericLog(e,t,s,r){this.level>=e&&this.builtinEnabled&&this.print(e,t,s,r),this.connector&&this.connector(i[e],t,s,r)}print(e,t,s,r){if("string"==typeof r){const e=[new Date,t];s&&e.push(s),r=e.concat(r).join(" | ")}switch(e){case i.error:console.error(r);break;case i.warn:console.warn(r);break;case i.log:console.log(r);break;case i.debug:console.debug(r)}}}var a=s(23);class c{constructor(){this._dataLength=0,this._bufferLength=0,this._state=new Int32Array(4),this._buffer=new ArrayBuffer(68),this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this._buffer,0,17),this.start()}static hashStr(e,t=!1){return this.onePassHasher.start().appendStr(e).end(t)}static hashAsciiStr(e,t=!1){return this.onePassHasher.start().appendAsciiStr(e).end(t)}static _hex(e){const t=c.hexChars,s=c.hexOut;let i,r,n,o;for(o=0;o<4;o+=1)for(r=8*o,i=e[o],n=0;n<8;n+=2)s[r+1+n]=t.charAt(15&i),i>>>=4,s[r+0+n]=t.charAt(15&i),i>>>=4;return s.join("")}static _md5cycle(e,t){let s=e[0],i=e[1],r=e[2],n=e[3];s+=(i&r|~i&n)+t[0]-680876936|0,s=(s<<7|s>>>25)+i|0,n+=(s&i|~s&r)+t[1]-389564586|0,n=(n<<12|n>>>20)+s|0,r+=(n&s|~n&i)+t[2]+606105819|0,r=(r<<17|r>>>15)+n|0,i+=(r&n|~r&s)+t[3]-1044525330|0,i=(i<<22|i>>>10)+r|0,s+=(i&r|~i&n)+t[4]-176418897|0,s=(s<<7|s>>>25)+i|0,n+=(s&i|~s&r)+t[5]+1200080426|0,n=(n<<12|n>>>20)+s|0,r+=(n&s|~n&i)+t[6]-1473231341|0,r=(r<<17|r>>>15)+n|0,i+=(r&n|~r&s)+t[7]-45705983|0,i=(i<<22|i>>>10)+r|0,s+=(i&r|~i&n)+t[8]+1770035416|0,s=(s<<7|s>>>25)+i|0,n+=(s&i|~s&r)+t[9]-1958414417|0,n=(n<<12|n>>>20)+s|0,r+=(n&s|~n&i)+t[10]-42063|0,r=(r<<17|r>>>15)+n|0,i+=(r&n|~r&s)+t[11]-1990404162|0,i=(i<<22|i>>>10)+r|0,s+=(i&r|~i&n)+t[12]+1804603682|0,s=(s<<7|s>>>25)+i|0,n+=(s&i|~s&r)+t[13]-40341101|0,n=(n<<12|n>>>20)+s|0,r+=(n&s|~n&i)+t[14]-1502002290|0,r=(r<<17|r>>>15)+n|0,i+=(r&n|~r&s)+t[15]+1236535329|0,i=(i<<22|i>>>10)+r|0,s+=(i&n|r&~n)+t[1]-165796510|0,s=(s<<5|s>>>27)+i|0,n+=(s&r|i&~r)+t[6]-1069501632|0,n=(n<<9|n>>>23)+s|0,r+=(n&i|s&~i)+t[11]+643717713|0,r=(r<<14|r>>>18)+n|0,i+=(r&s|n&~s)+t[0]-373897302|0,i=(i<<20|i>>>12)+r|0,s+=(i&n|r&~n)+t[5]-701558691|0,s=(s<<5|s>>>27)+i|0,n+=(s&r|i&~r)+t[10]+38016083|0,n=(n<<9|n>>>23)+s|0,r+=(n&i|s&~i)+t[15]-660478335|0,r=(r<<14|r>>>18)+n|0,i+=(r&s|n&~s)+t[4]-405537848|0,i=(i<<20|i>>>12)+r|0,s+=(i&n|r&~n)+t[9]+568446438|0,s=(s<<5|s>>>27)+i|0,n+=(s&r|i&~r)+t[14]-1019803690|0,n=(n<<9|n>>>23)+s|0,r+=(n&i|s&~i)+t[3]-187363961|0,r=(r<<14|r>>>18)+n|0,i+=(r&s|n&~s)+t[8]+1163531501|0,i=(i<<20|i>>>12)+r|0,s+=(i&n|r&~n)+t[13]-1444681467|0,s=(s<<5|s>>>27)+i|0,n+=(s&r|i&~r)+t[2]-51403784|0,n=(n<<9|n>>>23)+s|0,r+=(n&i|s&~i)+t[7]+1735328473|0,r=(r<<14|r>>>18)+n|0,i+=(r&s|n&~s)+t[12]-1926607734|0,i=(i<<20|i>>>12)+r|0,s+=(i^r^n)+t[5]-378558|0,s=(s<<4|s>>>28)+i|0,n+=(s^i^r)+t[8]-2022574463|0,n=(n<<11|n>>>21)+s|0,r+=(n^s^i)+t[11]+1839030562|0,r=(r<<16|r>>>16)+n|0,i+=(r^n^s)+t[14]-35309556|0,i=(i<<23|i>>>9)+r|0,s+=(i^r^n)+t[1]-1530992060|0,s=(s<<4|s>>>28)+i|0,n+=(s^i^r)+t[4]+1272893353|0,n=(n<<11|n>>>21)+s|0,r+=(n^s^i)+t[7]-155497632|0,r=(r<<16|r>>>16)+n|0,i+=(r^n^s)+t[10]-1094730640|0,i=(i<<23|i>>>9)+r|0,s+=(i^r^n)+t[13]+681279174|0,s=(s<<4|s>>>28)+i|0,n+=(s^i^r)+t[0]-358537222|0,n=(n<<11|n>>>21)+s|0,r+=(n^s^i)+t[3]-722521979|0,r=(r<<16|r>>>16)+n|0,i+=(r^n^s)+t[6]+76029189|0,i=(i<<23|i>>>9)+r|0,s+=(i^r^n)+t[9]-640364487|0,s=(s<<4|s>>>28)+i|0,n+=(s^i^r)+t[12]-421815835|0,n=(n<<11|n>>>21)+s|0,r+=(n^s^i)+t[15]+530742520|0,r=(r<<16|r>>>16)+n|0,i+=(r^n^s)+t[2]-995338651|0,i=(i<<23|i>>>9)+r|0,s+=(r^(i|~n))+t[0]-198630844|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[7]+1126891415|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[14]-1416354905|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[5]-57434055|0,i=(i<<21|i>>>11)+r|0,s+=(r^(i|~n))+t[12]+1700485571|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[3]-1894986606|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[10]-1051523|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[1]-2054922799|0,i=(i<<21|i>>>11)+r|0,s+=(r^(i|~n))+t[8]+1873313359|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[15]-30611744|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[6]-1560198380|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[13]+1309151649|0,i=(i<<21|i>>>11)+r|0,s+=(r^(i|~n))+t[4]-145523070|0,s=(s<<6|s>>>26)+i|0,n+=(i^(s|~r))+t[11]-1120210379|0,n=(n<<10|n>>>22)+s|0,r+=(s^(n|~i))+t[2]+718787259|0,r=(r<<15|r>>>17)+n|0,i+=(n^(r|~s))+t[9]-343485551|0,i=(i<<21|i>>>11)+r|0,e[0]=s+e[0]|0,e[1]=i+e[1]|0,e[2]=r+e[2]|0,e[3]=n+e[3]|0}start(){return this._dataLength=0,this._bufferLength=0,this._state.set(c.stateIdentity),this}appendStr(e){const t=this._buffer8,s=this._buffer32;let i,r,n=this._bufferLength;for(r=0;r<e.length;r+=1){if(i=e.charCodeAt(r),i<128)t[n++]=i;else if(i<2048)t[n++]=192+(i>>>6),t[n++]=63&i|128;else if(i<55296||i>56319)t[n++]=224+(i>>>12),t[n++]=i>>>6&63|128,t[n++]=63&i|128;else{if(i=1024*(i-55296)+(e.charCodeAt(++r)-56320)+65536,i>1114111)throw new Error("Unicode standard supports code points up to U+10FFFF");t[n++]=240+(i>>>18),t[n++]=i>>>12&63|128,t[n++]=i>>>6&63|128,t[n++]=63&i|128}n>=64&&(this._dataLength+=64,c._md5cycle(this._state,s),n-=64,s[0]=s[16])}return this._bufferLength=n,this}appendAsciiStr(e){const t=this._buffer8,s=this._buffer32;let i,r=this._bufferLength,n=0;for(;;){for(i=Math.min(e.length-n,64-r);i--;)t[r++]=e.charCodeAt(n++);if(r<64)break;this._dataLength+=64,c._md5cycle(this._state,s),r=0}return this._bufferLength=r,this}appendByteArray(e){const t=this._buffer8,s=this._buffer32;let i,r=this._bufferLength,n=0;for(;;){for(i=Math.min(e.length-n,64-r);i--;)t[r++]=e[n++];if(r<64)break;this._dataLength+=64,c._md5cycle(this._state,s),r=0}return this._bufferLength=r,this}getState(){const e=this._state;return{buffer:String.fromCharCode.apply(null,this._buffer8),buflen:this._bufferLength,length:this._dataLength,state:[e[0],e[1],e[2],e[3]]}}setState(e){const t=e.buffer,s=e.state,i=this._state;let r;for(this._dataLength=e.length,this._bufferLength=e.buflen,i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],r=0;r<t.length;r+=1)this._buffer8[r]=t.charCodeAt(r)}end(e=!1){const t=this._bufferLength,s=this._buffer8,i=this._buffer32,r=1+(t>>2);let n;if(this._dataLength+=t,s[t]=128,s[t+1]=s[t+2]=s[t+3]=0,i.set(c.buffer32Identity.subarray(r),r),t>55&&(c._md5cycle(this._state,i),i.set(c.buffer32Identity)),n=8*this._dataLength,n<=4294967295)i[14]=n;else{const e=n.toString(16).match(/(.*?)(.{0,8})$/);if(null===e)return;const t=parseInt(e[2],16),s=parseInt(e[1],16)||0;i[14]=t,i[15]=s}return c._md5cycle(this._state,i),e?this._state:c._hex(this._state)}}c.stateIdentity=new Int32Array([1732584193,-271733879,-1732584194,271733878]),c.buffer32Identity=new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),c.hexChars="0123456789abcdef",c.hexOut=[],c.onePassHasher=new c,"5d41402abc4b2a76b9719d911017c592"!==c.hashStr("hello")&&console.error("Md5 self test failed.");var h=s(1);function d(e){return c.hashStr(e)}class l{constructor(e,t,s,i){this.logger=e.getLogger("sipjs.digestauthentication"),this.username=s,this.password=i,this.ha1=t,this.nc=0,this.ncHex="00000000"}authenticate(e,t,s){if(this.algorithm=t.algorithm,this.realm=t.realm,this.nonce=t.nonce,this.opaque=t.opaque,this.stale=t.stale,this.algorithm){if("MD5"!==this.algorithm)return this.logger.warn("challenge with Digest algorithm different than 'MD5', authentication aborted"),!1}else this.algorithm="MD5";if(!this.realm)return this.logger.warn("challenge without Digest realm, authentication aborted"),!1;if(!this.nonce)return this.logger.warn("challenge without Digest nonce, authentication aborted"),!1;if(t.qop)if(t.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(t.qop.indexOf("auth-int")>-1))return this.logger.warn("challenge without Digest qop different than 'auth' or 'auth-int', authentication aborted"),!1;this.qop="auth-int"}else this.qop=void 0;return this.method=e.method,this.uri=e.ruri,this.cnonce=Object(h.a)(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(s),!0}toString(){const e=[];if(!this.response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this.algorithm),e.push('username="'+this.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(", ")}updateNcHex(){const e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e}calculateResponse(e){let t,s;t=this.ha1,""!==t&&void 0!==t||(t=d(this.username+":"+this.realm+":"+this.password)),"auth"===this.qop?(s=d(this.method+":"+this.uri),this.response=d(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+s)):"auth-int"===this.qop?(s=d(this.method+":"+this.uri+":"+d(e||"")),this.response=d(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+s)):void 0===this.qop&&(s=d(this.method+":"+this.uri),this.response=d(t+":"+this.nonce+":"+s))}}var u=s(10),g=s(44);function p(e,t){if(t.statusCode<100||t.statusCode>699)throw new TypeError("Invalid statusCode: "+t.statusCode);const s=t.reasonPhrase?t.reasonPhrase:Object(h.b)(t.statusCode);let i="SIP/2.0 "+t.statusCode+" "+s+"\r\n";t.statusCode>=100&&t.statusCode,t.statusCode;const r="From: "+e.getHeader("From")+"\r\n",n="Call-ID: "+e.callId+"\r\n",o="CSeq: "+e.cseq+" "+e.method+"\r\n",a=e.getHeaders("via").reduce((e,t)=>e+"Via: "+t+"\r\n","");let c="To: "+e.getHeader("to");if(t.statusCode>100&&!e.parseHeader("to").hasParam("tag")){let e=t.toTag;e||(e=Object(h.d)()),c+=";tag="+e}c+="\r\n";let d="";t.supported&&(d="Supported: "+t.supported.join(", ")+"\r\n");let l="";t.userAgent&&(l="User-Agent: "+t.userAgent+"\r\n");let u="";return t.extraHeaders&&(u=t.extraHeaders.reduce((e,t)=>e+t.trim()+"\r\n","")),i+=a,i+=r,i+=c,i+=o,i+=n,i+=d,i+=l,i+=u,t.body?(i+="Content-Type: "+t.body.contentType+"\r\n",i+="Content-Length: "+Object(h.e)(t.body.content)+"\r\n\r\n",i+=t.body.content):i+="Content-Length: 0\r\n\r\n",{message:i}}var f,m=s(4),v=s(19);class w extends v.a{constructor(e){super(e||"Unspecified transport error.")}}class b{constructor(e,t,s,i,r){this._transport=e,this._user=t,this._id=s,this._state=i,this.listeners=new Array,this.logger=t.loggerFactory.getLogger(r,s),this.logger.debug(`Constructing ${this.typeToString()} with id ${this.id}.`)}dispose(){this.logger.debug(`Destroyed ${this.typeToString()} with id ${this.id}.`)}get id(){return this._id}get kind(){throw new Error("Invalid kind.")}get state(){return this._state}get transport(){return this._transport}addStateChangeListener(e,t){const s=()=>{this.removeStateChangeListener(s),e()};!0===(null==t?void 0:t.once)?this.listeners.push(s):this.listeners.push(e)}notifyStateChangeListeners(){this.listeners.slice().forEach(e=>e())}removeStateChangeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}logTransportError(e,t){this.logger.error(e.message),this.logger.error(`Transport error occurred in ${this.typeToString()} with id ${this.id}.`),this.logger.error(t)}send(e){return this.transport.send(e).catch(e=>{if(e instanceof w)throw this.onTransportError(e),e;let t;throw t=e&&"string"==typeof e.message?new w(e.message):new w,this.onTransportError(t),t})}setState(e){this.logger.debug(`State change to "${e}" on ${this.typeToString()} with id ${this.id}.`),this._state=e,this._user.onStateChange&&this._user.onStateChange(e),this.notifyStateChangeListeners()}typeToString(){return"UnknownType"}}class y extends b{constructor(e,t,s,i,r){super(t,s,y.makeId(e),i,r),this._request=e,this.user=s,e.setViaHeader(this.id,t.protocol)}static makeId(e){if("CANCEL"===e.method){if(!e.branch)throw new Error("Outgoing CANCEL request without a branch.");return e.branch}return"z9hG4bK"+Math.floor(1e7*Math.random())}get request(){return this._request}onRequestTimeout(){this.user.onRequestTimeout&&this.user.onRequestTimeout()}}!function(e){e.Accepted="Accepted",e.Calling="Calling",e.Completed="Completed",e.Confirmed="Confirmed",e.Proceeding="Proceeding",e.Terminated="Terminated",e.Trying="Trying"}(f||(f={}));class T extends y{constructor(e,t,s){super(e,t,s,f.Trying,"sip.transaction.nict"),this.F=setTimeout(()=>this.timerF(),m.a.TIMER_F),this.send(e.toString()).catch(e=>{this.logTransportError(e,"Failed to send initial outgoing request.")})}dispose(){this.F&&(clearTimeout(this.F),this.F=void 0),this.K&&(clearTimeout(this.K),this.K=void 0),super.dispose()}get kind(){return"nict"}receiveResponse(e){const t=e.statusCode;if(!t||t<100||t>699)throw new Error("Invalid status code "+t);switch(this.state){case f.Trying:if(t>=100&&t<=199)return this.stateTransition(f.Proceeding),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(t>=200&&t<=699)return this.stateTransition(f.Completed),408===t?void this.onRequestTimeout():void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case f.Proceeding:if(t>=100&&t<=199&&this.user.receiveResponse)return this.user.receiveResponse(e);if(t>=200&&t<=699)return this.stateTransition(f.Completed),408===t?void this.onRequestTimeout():void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case f.Completed:case f.Terminated:return;default:throw new Error("Invalid state "+this.state)}const s=`Non-INVITE client transaction received unexpected ${t} response while in state ${this.state}.`;this.logger.warn(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(f.Terminated,!0)}typeToString(){return"non-INVITE client transaction"}stateTransition(e,t=!1){const s=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case f.Trying:s();break;case f.Proceeding:this.state!==f.Trying&&s();break;case f.Completed:this.state!==f.Trying&&this.state!==f.Proceeding&&s();break;case f.Terminated:this.state!==f.Trying&&this.state!==f.Proceeding&&this.state!==f.Completed&&(t||s());break;default:s()}e===f.Completed&&(this.F&&(clearTimeout(this.F),this.F=void 0),this.K=setTimeout(()=>this.timerK(),m.a.TIMER_K)),e===f.Terminated&&this.dispose(),this.setState(e)}timerF(){this.logger.debug(`Timer F expired for non-INVITE client transaction ${this.id}.`),this.state!==f.Trying&&this.state!==f.Proceeding||(this.onRequestTimeout(),this.stateTransition(f.Terminated))}timerK(){this.state===f.Completed&&this.stateTransition(f.Terminated)}}class S extends b{constructor(e,t,s,i,r){super(t,s,e.viaBranch,i,r),this._request=e,this.user=s}get request(){return this._request}}class E extends S{constructor(e,t,s){super(e,t,s,f.Proceeding,"sip.transaction.ist")}dispose(){this.stopProgressExtensionTimer(),this.H&&(clearTimeout(this.H),this.H=void 0),this.I&&(clearTimeout(this.I),this.I=void 0),this.L&&(clearTimeout(this.L),this.L=void 0),super.dispose()}get kind(){return"ist"}receiveRequest(e){switch(this.state){case f.Proceeding:if(e.method===u.a.INVITE)return void(this.lastProvisionalResponse&&this.send(this.lastProvisionalResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of provisional response.")}));break;case f.Accepted:if(e.method===u.a.INVITE)return;break;case f.Completed:if(e.method===u.a.INVITE){if(!this.lastFinalResponse)throw new Error("Last final response undefined.");return void this.send(this.lastFinalResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of final response.")})}if(e.method===u.a.ACK)return void this.stateTransition(f.Confirmed);break;case f.Confirmed:case f.Terminated:if(e.method===u.a.INVITE||e.method===u.a.ACK)return;break;default:throw new Error("Invalid state "+this.state)}const t=`INVITE server transaction received unexpected ${e.method} request while in state ${this.state}.`;this.logger.warn(t)}receiveResponse(e,t){if(e<100||e>699)throw new Error("Invalid status code "+e);switch(this.state){case f.Proceeding:if(e>=100&&e<=199)return this.lastProvisionalResponse=t,e>100&&this.startProgressExtensionTimer(),void this.send(t).catch(e=>{this.logTransportError(e,"Failed to send 1xx response.")});if(e>=200&&e<=299)return this.lastFinalResponse=t,this.stateTransition(f.Accepted),void this.send(t).catch(e=>{this.logTransportError(e,"Failed to send 2xx response.")});if(e>=300&&e<=699)return this.lastFinalResponse=t,this.stateTransition(f.Completed),void this.send(t).catch(e=>{this.logTransportError(e,"Failed to send non-2xx final response.")});break;case f.Accepted:if(e>=200&&e<=299)return void this.send(t).catch(e=>{this.logTransportError(e,"Failed to send 2xx response.")});break;case f.Completed:case f.Confirmed:case f.Terminated:break;default:throw new Error("Invalid state "+this.state)}const s=`INVITE server transaction received unexpected ${e} response from TU while in state ${this.state}.`;throw this.logger.error(s),new Error(s)}retransmitAcceptedResponse(){this.state===f.Accepted&&this.lastFinalResponse&&this.send(this.lastFinalResponse).catch(e=>{this.logTransportError(e,"Failed to send 2xx response.")})}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e)}typeToString(){return"INVITE server transaction"}stateTransition(e){const t=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case f.Proceeding:t();break;case f.Accepted:case f.Completed:this.state!==f.Proceeding&&t();break;case f.Confirmed:this.state!==f.Completed&&t();break;case f.Terminated:this.state!==f.Accepted&&this.state!==f.Completed&&this.state!==f.Confirmed&&t();break;default:t()}this.stopProgressExtensionTimer(),e===f.Accepted&&(this.L=setTimeout(()=>this.timerL(),m.a.TIMER_L)),e===f.Completed&&(this.H=setTimeout(()=>this.timerH(),m.a.TIMER_H)),e===f.Confirmed&&(this.I=setTimeout(()=>this.timerI(),m.a.TIMER_I)),e===f.Terminated&&this.dispose(),this.setState(e)}startProgressExtensionTimer(){void 0===this.progressExtensionTimer&&(this.progressExtensionTimer=setInterval(()=>{if(this.logger.debug(`Progress extension timer expired for INVITE server transaction ${this.id}.`),!this.lastProvisionalResponse)throw new Error("Last provisional response undefined.");this.send(this.lastProvisionalResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of provisional response.")})},m.a.PROVISIONAL_RESPONSE_INTERVAL))}stopProgressExtensionTimer(){void 0!==this.progressExtensionTimer&&(clearInterval(this.progressExtensionTimer),this.progressExtensionTimer=void 0)}timerG(){}timerH(){this.logger.debug(`Timer H expired for INVITE server transaction ${this.id}.`),this.state===f.Completed&&(this.logger.warn("ACK to negative final response was never received, terminating transaction."),this.stateTransition(f.Terminated))}timerI(){this.logger.debug(`Timer I expired for INVITE server transaction ${this.id}.`),this.stateTransition(f.Terminated)}timerL(){this.logger.debug(`Timer L expired for INVITE server transaction ${this.id}.`),this.state===f.Accepted&&this.stateTransition(f.Terminated)}}var I=s(17);class R{constructor(e,t){this.core=e,this.dialogState=t,this.core.dialogs.set(this.id,this)}static initialDialogStateForUserAgentClient(e,t){const s=t.getHeaders("record-route").reverse(),i=t.parseHeader("contact");if(!i)throw new Error("Contact undefined.");if(!(i instanceof I.a))throw new Error("Contact not instance of NameAddrHeader.");const r=i.uri,n=e.cseq,o=e.callId,a=e.fromTag,c=t.toTag;if(!o)throw new Error("Call id undefined.");if(!a)throw new Error("From tag undefined.");if(!c)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");const h=e.from.uri,d=e.to.uri;if(!t.statusCode)throw new Error("Incoming response status code undefined.");return{id:o+a+c,early:t.statusCode<200,callId:o,localTag:a,remoteTag:c,localSequenceNumber:n,remoteSequenceNumber:void 0,localURI:h,remoteURI:d,remoteTarget:r,routeSet:s,secure:!1}}static initialDialogStateForUserAgentServer(e,t,s=!1){const i=e.getHeaders("record-route"),r=e.parseHeader("contact");if(!r)throw new Error("Contact undefined.");if(!(r instanceof I.a))throw new Error("Contact not instance of NameAddrHeader.");const n=r.uri,o=e.cseq,a=e.callId,c=t,h=e.fromTag,d=e.from.uri;return{id:a+c+h,early:s,callId:a,localTag:c,remoteTag:h,localSequenceNumber:void 0,remoteSequenceNumber:o,localURI:e.to.uri,remoteURI:d,remoteTarget:n,routeSet:i,secure:!1}}dispose(){this.core.dialogs.delete(this.id)}get id(){return this.dialogState.id}get early(){return this.dialogState.early}get callId(){return this.dialogState.callId}get localTag(){return this.dialogState.localTag}get remoteTag(){return this.dialogState.remoteTag}get localSequenceNumber(){return this.dialogState.localSequenceNumber}get remoteSequenceNumber(){return this.dialogState.remoteSequenceNumber}get localURI(){return this.dialogState.localURI}get remoteURI(){return this.dialogState.remoteURI}get remoteTarget(){return this.dialogState.remoteTarget}get routeSet(){return this.dialogState.routeSet}get secure(){return this.dialogState.secure}get userAgentCore(){return this.core}confirm(){this.dialogState.early=!1}receiveRequest(e){if(e.method!==u.a.ACK){if(this.remoteSequenceNumber){if(e.cseq<=this.remoteSequenceNumber)throw new Error("Out of sequence in dialog request. Did you forget to call sequenceGuard()?");this.dialogState.remoteSequenceNumber=e.cseq}this.remoteSequenceNumber||(this.dialogState.remoteSequenceNumber=e.cseq)}}recomputeRouteSet(e){this.dialogState.routeSet=e.getHeaders("record-route").reverse()}createOutgoingRequestMessage(e,t){const s=this.remoteURI,i=this.remoteTag,r=this.localURI,n=this.localTag,o=this.callId;let a;a=t&&t.cseq?t.cseq:this.dialogState.localSequenceNumber?this.dialogState.localSequenceNumber+=1:this.dialogState.localSequenceNumber=1;const c=this.remoteTarget,h=this.routeSet,d=t&&t.extraHeaders,l=t&&t.body;return this.userAgentCore.makeOutgoingRequestMessage(e,c,r,s,{callId:o,cseq:a,fromTag:n,toTag:i,routeSet:h},d,l)}incrementLocalSequenceNumber(){if(!this.dialogState.localSequenceNumber)throw new Error("Local sequence number undefined.");this.dialogState.localSequenceNumber+=1}sequenceGuard(e){return e.method===u.a.ACK||(!(this.remoteSequenceNumber&&e.cseq<=this.remoteSequenceNumber)||(this.core.replyStateless(e,{statusCode:500}),!1))}}var C=s(66),$=s(25),x=s(20),k=s(14);class _ extends y{constructor(e,t,s){super(e,t,s,f.Calling,"sip.transaction.ict"),this.ackRetransmissionCache=new Map,this.B=setTimeout(()=>this.timerB(),m.a.TIMER_B),this.send(e.toString()).catch(e=>{this.logTransportError(e,"Failed to send initial outgoing request.")})}dispose(){this.B&&(clearTimeout(this.B),this.B=void 0),this.D&&(clearTimeout(this.D),this.D=void 0),this.M&&(clearTimeout(this.M),this.M=void 0),super.dispose()}get kind(){return"ict"}ackResponse(e){const t=e.toTag;if(!t)throw new Error("To tag undefined.");const s="z9hG4bK"+Math.floor(1e7*Math.random());e.setViaHeader(s,this.transport.protocol),this.ackRetransmissionCache.set(t,e),this.send(e.toString()).catch(e=>{this.logTransportError(e,"Failed to send ACK to 2xx response.")})}receiveResponse(e){const t=e.statusCode;if(!t||t<100||t>699)throw new Error("Invalid status code "+t);switch(this.state){case f.Calling:if(t>=100&&t<=199)return this.stateTransition(f.Proceeding),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(t>=200&&t<=299)return this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(f.Accepted),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(t>=300&&t<=699)return this.stateTransition(f.Completed),this.ack(e),void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case f.Proceeding:if(t>=100&&t<=199)return void(this.user.receiveResponse&&this.user.receiveResponse(e));if(t>=200&&t<=299)return this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(f.Accepted),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(t>=300&&t<=699)return this.stateTransition(f.Completed),this.ack(e),void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case f.Accepted:if(t>=200&&t<=299){if(!this.ackRetransmissionCache.has(e.toTag))return this.ackRetransmissionCache.set(e.toTag,void 0),void(this.user.receiveResponse&&this.user.receiveResponse(e));const t=this.ackRetransmissionCache.get(e.toTag);return t?void this.send(t.toString()).catch(e=>{this.logTransportError(e,"Failed to send retransmission of ACK to 2xx response.")}):void 0}break;case f.Completed:if(t>=300&&t<=699)return void this.ack(e);break;case f.Terminated:break;default:throw new Error("Invalid state "+this.state)}const s=`Received unexpected ${t} response while in state ${this.state}.`;this.logger.warn(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(f.Terminated,!0)}typeToString(){return"INVITE client transaction"}ack(e){const t=this.request.ruri,s=this.request.callId,i=this.request.cseq,r=this.request.getHeader("from"),n=e.getHeader("to"),o=this.request.getHeader("via"),a=this.request.getHeader("route");if(!r)throw new Error("From undefined.");if(!n)throw new Error("To undefined.");if(!o)throw new Error("Via undefined.");let c=`ACK ${t} SIP/2.0\r\n`;a&&(c+=`Route: ${a}\r\n`),c+=`Via: ${o}\r\n`,c+=`To: ${n}\r\n`,c+=`From: ${r}\r\n`,c+=`Call-ID: ${s}\r\n`,c+=`CSeq: ${i} ACK\r\n`,c+="Max-Forwards: 70\r\n",c+="Content-Length: 0\r\n\r\n",this.send(c).catch(e=>{this.logTransportError(e,"Failed to send ACK to non-2xx response.")})}stateTransition(e,t=!1){const s=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case f.Calling:s();break;case f.Proceeding:this.state!==f.Calling&&s();break;case f.Accepted:case f.Completed:this.state!==f.Calling&&this.state!==f.Proceeding&&s();break;case f.Terminated:this.state!==f.Calling&&this.state!==f.Accepted&&this.state!==f.Completed&&(t||s());break;default:s()}this.B&&(clearTimeout(this.B),this.B=void 0),f.Proceeding,e===f.Completed&&(this.D=setTimeout(()=>this.timerD(),m.a.TIMER_D)),e===f.Accepted&&(this.M=setTimeout(()=>this.timerM(),m.a.TIMER_M)),e===f.Terminated&&this.dispose(),this.setState(e)}timerA(){}timerB(){this.logger.debug(`Timer B expired for INVITE client transaction ${this.id}.`),this.state===f.Calling&&(this.onRequestTimeout(),this.stateTransition(f.Terminated))}timerD(){this.logger.debug(`Timer D expired for INVITE client transaction ${this.id}.`),this.state===f.Completed&&this.stateTransition(f.Terminated)}timerM(){this.logger.debug(`Timer M expired for INVITE client transaction ${this.id}.`),this.state===f.Accepted&&this.stateTransition(f.Terminated)}}class D{constructor(e,t,s,i){this.transactionConstructor=e,this.core=t,this.message=s,this.delegate=i,this.challenged=!1,this.stale=!1,this.logger=this.loggerFactory.getLogger("sip.user-agent-client"),this.init()}dispose(){this.transaction.dispose()}get loggerFactory(){return this.core.loggerFactory}get transaction(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction}cancel(e,t={}){if(!this.transaction)throw new Error("Transaction undefined.");if(!this.message.to)throw new Error("To undefined.");if(!this.message.from)throw new Error("From undefined.");const s=this.core.makeOutgoingRequestMessage(u.a.CANCEL,this.message.ruri,this.message.from.uri,this.message.to.uri,{toTag:this.message.toTag,fromTag:this.message.fromTag,callId:this.message.callId,cseq:this.message.cseq},t.extraHeaders);return s.branch=this.message.branch,this.message.headers.Route&&(s.headers.Route=this.message.headers.Route),e&&s.setHeader("Reason",e),this.transaction.state===f.Proceeding?new D(T,this.core,s):this.transaction.addStateChangeListener(()=>{this.transaction&&this.transaction.state===f.Proceeding&&new D(T,this.core,s)},{once:!0}),s}authenticationGuard(e,t){const s=e.statusCode;if(!s)throw new Error("Response status code undefined.");if(401!==s&&407!==s)return!0;let i,r;if(401===s?(i=e.parseHeader("www-authenticate"),r="authorization"):(i=e.parseHeader("proxy-authenticate"),r="proxy-authorization"),!i)return this.logger.warn(s+" with wrong or missing challenge, cannot authenticate"),!0;if(this.challenged&&(this.stale||!0!==i.stale))return this.logger.warn(s+" apparently in authentication loop, cannot authenticate"),!0;if(!this.credentials&&(this.credentials=this.core.configuration.authenticationFactory(),!this.credentials))return this.logger.warn("Unable to obtain credentials, cannot authenticate"),!0;if(!this.credentials.authenticate(this.message,i))return!0;this.challenged=!0,i.stale&&(this.stale=!0);let n=this.message.cseq+=1;return t&&t.localSequenceNumber&&(t.incrementLocalSequenceNumber(),n=this.message.cseq=t.localSequenceNumber),this.message.setHeader("cseq",n+" "+this.message.method),this.message.setHeader(r,this.credentials.toString()),this.init(),!1}onRequestTimeout(){this.logger.warn("User agent client request timed out. Generating internal 408 Request Timeout.");const e=new x.a;e.statusCode=408,e.reasonPhrase="Request Timeout",this.receiveResponse(e)}onTransportError(e){this.logger.error(e.message),this.logger.error("User agent client request transport error. Generating internal 503 Service Unavailable.");const t=new x.a;t.statusCode=503,t.reasonPhrase="Service Unavailable",this.receiveResponse(t)}receiveResponse(e){if(!this.authenticationGuard(e))return;const t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e});break;case/^2[0-9]{2}$/.test(t):this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e});break;case/^3[0-9]{2}$/.test(t):this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error("Invalid status code "+t)}}init(){const e={loggerFactory:this.loggerFactory,onRequestTimeout:()=>this.onRequestTimeout(),onStateChange:e=>{e===f.Terminated&&(this.core.userAgentClients.delete(s),t===this._transaction&&this.dispose())},onTransportError:e=>this.onTransportError(e),receiveResponse:e=>this.receiveResponse(e)},t=new this.transactionConstructor(this.message,this.core.transport,e);this._transaction=t;const s=t.id+t.request.method;this.core.userAgentClients.set(s,this)}}class A extends D{constructor(e,t,s){const i=e.createOutgoingRequestMessage(u.a.BYE,s);super(T,e.userAgentCore,i,t),e.dispose()}}class P extends S{constructor(e,t,s){super(e,t,s,f.Trying,"sip.transaction.nist")}dispose(){this.J&&(clearTimeout(this.J),this.J=void 0),super.dispose()}get kind(){return"nist"}receiveRequest(e){switch(this.state){case f.Trying:break;case f.Proceeding:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of provisional response.")});break;case f.Completed:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch(e=>{this.logTransportError(e,"Failed to send retransmission of final response.")});break;case f.Terminated:break;default:throw new Error("Invalid state "+this.state)}}receiveResponse(e,t){if(e<100||e>699)throw new Error("Invalid status code "+e);if(e>100&&e<=199)throw new Error("Provisional response other than 100 not allowed.");switch(this.state){case f.Trying:if(this.lastResponse=t,e>=100&&e<200)return this.stateTransition(f.Proceeding),void this.send(t).catch(e=>{this.logTransportError(e,"Failed to send provisional response.")});if(e>=200&&e<=699)return this.stateTransition(f.Completed),void this.send(t).catch(e=>{this.logTransportError(e,"Failed to send final response.")});break;case f.Proceeding:if(this.lastResponse=t,e>=200&&e<=699)return this.stateTransition(f.Completed),void this.send(t).catch(e=>{this.logTransportError(e,"Failed to send final response.")});break;case f.Completed:return;case f.Terminated:break;default:throw new Error("Invalid state "+this.state)}const s=`Non-INVITE server transaction received unexpected ${e} response from TU while in state ${this.state}.`;throw this.logger.error(s),new Error(s)}onTransportError(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(f.Terminated,!0)}typeToString(){return"non-INVITE server transaction"}stateTransition(e,t=!1){const s=()=>{throw new Error(`Invalid state transition from ${this.state} to ${e}`)};switch(e){case f.Trying:s();break;case f.Proceeding:this.state!==f.Trying&&s();break;case f.Completed:this.state!==f.Trying&&this.state!==f.Proceeding&&s();break;case f.Terminated:this.state!==f.Proceeding&&this.state!==f.Completed&&(t||s());break;default:s()}e===f.Completed&&(this.J=setTimeout(()=>this.timerJ(),m.a.TIMER_J)),e===f.Terminated&&this.dispose(),this.setState(e)}timerJ(){this.logger.debug(`Timer J expired for NON-INVITE server transaction ${this.id}.`),this.state===f.Completed&&this.stateTransition(f.Terminated)}}var H,q=s(68);class O{constructor(e,t,s,i){this.transactionConstructor=e,this.core=t,this.message=s,this.delegate=i,this.logger=this.loggerFactory.getLogger("sip.user-agent-server"),this.toTag=s.toTag?s.toTag:Object(h.d)(),this.init()}dispose(){this.transaction.dispose()}get loggerFactory(){return this.core.loggerFactory}get transaction(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction}accept(e={statusCode:200}){if(!this.acceptable)throw new q.a(`${this.message.method} not acceptable in state ${this.transaction.state}.`);const t=e.statusCode;if(t<200||t>299)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)}progress(e={statusCode:180}){if(!this.progressable)throw new q.a(`${this.message.method} not progressable in state ${this.transaction.state}.`);const t=e.statusCode;if(t<101||t>199)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)}redirect(e,t={statusCode:302}){if(!this.redirectable)throw new q.a(`${this.message.method} not redirectable in state ${this.transaction.state}.`);const s=t.statusCode;if(s<300||s>399)throw new TypeError("Invalid statusCode: "+s);const i=new Array;e.forEach(e=>i.push("Contact: "+e.toString())),t.extraHeaders=(t.extraHeaders||[]).concat(i);return this.reply(t)}reject(e={statusCode:480}){if(!this.rejectable)throw new q.a(`${this.message.method} not rejectable in state ${this.transaction.state}.`);const t=e.statusCode;if(t<400||t>699)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)}trying(e){if(!this.tryingable)throw new q.a(`${this.message.method} not tryingable in state ${this.transaction.state}.`);return this.reply({statusCode:100})}receiveCancel(e){this.delegate&&this.delegate.onCancel&&this.delegate.onCancel(e)}get acceptable(){if(this.transaction instanceof E)return this.transaction.state===f.Proceeding||this.transaction.state===f.Accepted;if(this.transaction instanceof P)return this.transaction.state===f.Trying||this.transaction.state===f.Proceeding;throw new Error("Unknown transaction type.")}get progressable(){if(this.transaction instanceof E)return this.transaction.state===f.Proceeding;if(this.transaction instanceof P)return!1;throw new Error("Unknown transaction type.")}get redirectable(){if(this.transaction instanceof E)return this.transaction.state===f.Proceeding;if(this.transaction instanceof P)return this.transaction.state===f.Trying||this.transaction.state===f.Proceeding;throw new Error("Unknown transaction type.")}get rejectable(){if(this.transaction instanceof E)return this.transaction.state===f.Proceeding;if(this.transaction instanceof P)return this.transaction.state===f.Trying||this.transaction.state===f.Proceeding;throw new Error("Unknown transaction type.")}get tryingable(){if(this.transaction instanceof E)return this.transaction.state===f.Proceeding;if(this.transaction instanceof P)return this.transaction.state===f.Trying;throw new Error("Unknown transaction type.")}reply(e){e.toTag||100===e.statusCode||(e.toTag=this.toTag),e.userAgent=e.userAgent||this.core.configuration.userAgentHeaderFieldValue,e.supported=e.supported||this.core.configuration.supportedOptionTagsResponse;const t=p(this.message,e);return this.transaction.receiveResponse(e.statusCode,t.message),t}init(){const e={loggerFactory:this.loggerFactory,onStateChange:e=>{e===f.Terminated&&(this.core.userAgentServers.delete(s),this.dispose())},onTransportError:e=>{this.logger.error(e.message),this.delegate&&this.delegate.onTransportError?this.delegate.onTransportError(e):this.logger.error("User agent server response transport error.")}},t=new this.transactionConstructor(this.message,this.core.transport,e);this._transaction=t;const s=t.id;this.core.userAgentServers.set(t.id,this)}}class M extends O{constructor(e,t,s){super(P,e.userAgentCore,t,s)}}class N extends D{constructor(e,t,s){const i=e.createOutgoingRequestMessage(u.a.INFO,s);super(T,e.userAgentCore,i,t)}}class j extends O{constructor(e,t,s){super(P,e.userAgentCore,t,s)}}class F extends D{constructor(e,t,s){super(T,e,t,s)}}class U extends O{constructor(e,t,s){super(P,e,t,s)}}class L extends D{constructor(e,t,s){const i=e.createOutgoingRequestMessage(u.a.NOTIFY,s);super(T,e.userAgentCore,i,t)}}class B extends O{constructor(e,t,s){const i=void 0!==e.userAgentCore?e.userAgentCore:e;super(P,i,t,s)}}class V extends D{constructor(e,t,s){const i=e.createOutgoingRequestMessage(u.a.PRACK,s);super(T,e.userAgentCore,i,t),e.signalingStateTransition(i)}}class G extends O{constructor(e,t,s){super(P,e.userAgentCore,t,s),e.signalingStateTransition(t),this.dialog=e}accept(e={statusCode:200}){return e.body&&this.dialog.signalingStateTransition(e.body),super.accept(e)}}class W extends D{constructor(e,t,s){const i=e.createOutgoingRequestMessage(u.a.INVITE,s);super(_,e.userAgentCore,i,t),this.delegate=t,e.signalingStateTransition(i),e.reinviteUserAgentClient=this,this.dialog=e}receiveResponse(e){if(!this.authenticationGuard(e,this.dialog))return;const t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:this.dialog,prack:e=>{throw new Error("Unimplemented.")}});break;case/^2[0-9]{2}$/.test(t):this.dialog.signalingStateTransition(e),this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e,session:this.dialog,ack:e=>this.dialog.ack(e)});break;case/^3[0-9]{2}$/.test(t):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error("Invalid status code "+t)}}}class K extends O{constructor(e,t,s){super(E,e.userAgentCore,t,s),e.reinviteUserAgentServer=this,this.dialog=e}accept(e={statusCode:200}){e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(this.dialog.routeSet.map(e=>"Record-Route: "+e));const t=super.accept(e),s=this.dialog,i=Object.assign(Object.assign({},t),{session:s});return e.body&&this.dialog.signalingStateTransition(e.body),this.dialog.reConfirm(),i}progress(e={statusCode:180}){const t=super.progress(e),s=this.dialog,i=Object.assign(Object.assign({},t),{session:s});return e.body&&this.dialog.signalingStateTransition(e.body),i}redirect(e,t={statusCode:302}){throw this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,new Error("Unimplemented.")}reject(e={statusCode:488}){return this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,super.reject(e)}}class Y extends D{constructor(e,t,s){const i=e.createOutgoingRequestMessage(u.a.REFER,s);super(T,e.userAgentCore,i,t)}}class Z extends O{constructor(e,t,s){const i=void 0!==e.userAgentCore?e.userAgentCore:e;super(P,i,t,s)}}class J extends R{constructor(e,t,s,i){super(t,s),this.initialTransaction=e,this._signalingState=k.b.Initial,this.ackWait=!1,this.ackProcessing=!1,this.delegate=i,e instanceof E&&(this.ackWait=!0),this.early||this.start2xxRetransmissionTimer(),this.signalingStateTransition(e.request),this.logger=t.loggerFactory.getLogger("sip.invite-dialog"),this.logger.log(`INVITE dialog ${this.id} constructed`)}dispose(){super.dispose(),this._signalingState=k.b.Closed,this._offer=void 0,this._answer=void 0,this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.logger.log(`INVITE dialog ${this.id} destroyed`)}get sessionState(){return this.early?k.a.Early:this.ackWait?k.a.AckWait:this._signalingState===k.b.Closed?k.a.Terminated:k.a.Confirmed}get signalingState(){return this._signalingState}get offer(){return this._offer}get answer(){return this._answer}confirm(){this.early&&this.start2xxRetransmissionTimer(),super.confirm()}reConfirm(){this.reinviteUserAgentServer&&this.startReInvite2xxRetransmissionTimer()}ack(e={}){let t;if(this.logger.log(`INVITE dialog ${this.id} sending ACK request`),this.reinviteUserAgentClient){if(!(this.reinviteUserAgentClient.transaction instanceof _))throw new Error("Transaction not instance of InviteClientTransaction.");t=this.reinviteUserAgentClient.transaction,this.reinviteUserAgentClient=void 0}else{if(!(this.initialTransaction instanceof _))throw new Error("Initial transaction not instance of InviteClientTransaction.");t=this.initialTransaction}const s=this.createOutgoingRequestMessage(u.a.ACK,{cseq:t.request.cseq,extraHeaders:e.extraHeaders,body:e.body});return t.ackResponse(s),this.signalingStateTransition(s),{message:s}}bye(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending BYE request`),this.initialTransaction instanceof E){if(this.early)throw new Error("UAS MUST NOT send a BYE on early dialogs.");if(this.ackWait&&this.initialTransaction.state!==f.Terminated)throw new Error("UAS MUST NOT send a BYE on a confirmed dialog until it has received an ACK for its 2xx response or until the server transaction times out.")}return new A(this,e,t)}info(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending INFO request`),this.early)throw new Error("Dialog not confirmed.");return new N(this,e,t)}invite(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending INVITE request`),this.early)throw new Error("Dialog not confirmed.");if(this.reinviteUserAgentClient)throw new Error("There is an ongoing re-INVITE client transaction.");if(this.reinviteUserAgentServer)throw new Error("There is an ongoing re-INVITE server transaction.");return new W(this,e,t)}message(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending MESSAGE request`),this.early)throw new Error("Dialog not confirmed.");const s=this.createOutgoingRequestMessage(u.a.MESSAGE,t);return new F(this.core,s,e)}notify(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending NOTIFY request`),this.early)throw new Error("Dialog not confirmed.");return new L(this,e,t)}prack(e,t){return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`),new V(this,e,t)}refer(e,t){if(this.logger.log(`INVITE dialog ${this.id} sending REFER request`),this.early)throw new Error("Dialog not confirmed.");return new Y(this,e,t)}receiveRequest(e){if(this.logger.log(`INVITE dialog ${this.id} received ${e.method} request`),e.method!==u.a.ACK)if(this.sequenceGuard(e)){if(super.receiveRequest(e),e.method===u.a.INVITE){const t=()=>{const e=this.ackWait?"waiting for initial ACK":"processing initial ACK";this.logger.warn(`INVITE dialog ${this.id} received re-INVITE while ${e}`);let t="RFC 5407 suggests the following to avoid this race condition... ";t+=" Note: Implementation issues are outside the scope of this document,",t+=" but the following tip is provided for avoiding race conditions of",t+=" this type. The caller can delay sending re-INVITE F6 for some period",t+=" of time (2 seconds, perhaps), after which the caller can reasonably",t+=" assume that its ACK has been received. Implementors can decouple the",t+=" actions of the user (e.g., pressing the hold button) from the actions",t+=" of the protocol (the sending of re-INVITE F6), so that the UA can",t+=" behave like this. In this case, it is the implementor's choice as to",t+=" how long to wait. In most cases, such an implementation may be",t+=" useful to prevent the type of race condition shown in this section.",t+=" This document expresses no preference about whether or not they",t+=" should wait for an ACK to be delivered. After considering the impact",t+=" on user experience, implementors should decide whether or not to wait",t+=" for a while, because the user experience depends on the",t+=" implementation and has no direct bearing on protocol behavior.",this.logger.warn("RFC 5407 suggests the following to avoid this race condition... Note: Implementation issues are outside the scope of this document, but the following tip is provided for avoiding race conditions of this type. The caller can delay sending re-INVITE F6 for some period of time (2 seconds, perhaps), after which the caller can reasonably assume that its ACK has been received. Implementors can decouple the actions of the user (e.g., pressing the hold button) from the actions of the protocol (the sending of re-INVITE F6), so that the UA can behave like this. In this case, it is the implementor's choice as to how long to wait. In most cases, such an implementation may be useful to prevent the type of race condition shown in this section. This document expresses no preference about whether or not they should wait for an ACK to be delivered. After considering the impact on user experience, implementors should decide whether or not to wait for a while, because the user experience depends on the implementation and has no direct bearing on protocol behavior.")},s=["Retry-After: "+(Math.floor(10*Math.random())+1)];if(this.ackProcessing)return this.core.replyStateless(e,{statusCode:500,extraHeaders:s}),void t();if(this.ackWait&&this.signalingState!==k.b.Stable)return this.core.replyStateless(e,{statusCode:500,extraHeaders:s}),void t();if(this.reinviteUserAgentServer)return void this.core.replyStateless(e,{statusCode:500,extraHeaders:s});if(this.reinviteUserAgentClient)return void this.core.replyStateless(e,{statusCode:491})}if(e.method===u.a.INVITE){const t=e.parseHeader("contact");if(!t)throw new Error("Contact undefined.");if(!(t instanceof I.a))throw new Error("Contact not instance of NameAddrHeader.");this.dialogState.remoteTarget=t.uri}switch(e.method){case u.a.BYE:{const t=new M(this,e);this.delegate&&this.delegate.onBye?this.delegate.onBye(t):t.accept(),this.dispose()}break;case u.a.INFO:{const t=new j(this,e);this.delegate&&this.delegate.onInfo?this.delegate.onInfo(t):t.reject({statusCode:469,extraHeaders:["Recv-Info:"]})}break;case u.a.INVITE:{const t=new K(this,e);this.signalingStateTransition(e),this.delegate&&this.delegate.onInvite?this.delegate.onInvite(t):t.reject({statusCode:488})}break;case u.a.MESSAGE:{const t=new U(this.core,e);this.delegate&&this.delegate.onMessage?this.delegate.onMessage(t):t.accept()}break;case u.a.NOTIFY:{const t=new B(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(t):t.accept()}break;case u.a.PRACK:{const t=new G(this,e);this.delegate&&this.delegate.onPrack?this.delegate.onPrack(t):t.accept()}break;case u.a.REFER:{const t=new Z(this,e);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(t):t.reject()}break;default:this.logger.log(`INVITE dialog ${this.id} received unimplemented ${e.method} request`),this.core.replyStateless(e,{statusCode:501})}}else this.logger.log(`INVITE dialog ${this.id} rejected out of order ${e.method} request.`);else{if(this.ackWait){if(this.initialTransaction instanceof _)return void this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);if(this.initialTransaction.request.cseq!==e.cseq)return void this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);this.ackWait=!1}else{if(!this.reinviteUserAgentServer)return void this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);if(this.reinviteUserAgentServer.transaction.request.cseq!==e.cseq)return void this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);this.reinviteUserAgentServer=void 0}if(this.signalingStateTransition(e),this.delegate&&this.delegate.onAck){const t=this.delegate.onAck({message:e});t instanceof Promise&&(this.ackProcessing=!0,t.then(()=>this.ackProcessing=!1).catch(()=>this.ackProcessing=!1))}}}reliableSequenceGuard(e){const t=e.statusCode;if(!t)throw new Error("Status code undefined");if(t>100&&t<200){const t=e.getHeader("require"),s=e.getHeader("rseq"),i=t&&t.includes("100rel")&&s?Number(s):void 0;if(i){if(this.rseq&&this.rseq+1!==i)return!1;this.rseq=this.rseq?this.rseq+1:i}}return!0}signalingStateRollback(){this._signalingState!==k.b.HaveLocalOffer&&this.signalingState!==k.b.HaveRemoteOffer||this._rollbackOffer&&this._rollbackAnswer&&(this._signalingState=k.b.Stable,this._offer=this._rollbackOffer,this._answer=this._rollbackAnswer)}signalingStateTransition(e){const t=Object(C.b)(e);if(t&&"session"===t.contentDisposition){if(this._signalingState===k.b.Stable&&(this._rollbackOffer=this._offer,this._rollbackAnswer=this._answer),e instanceof $.a)switch(this._signalingState){case k.b.Initial:case k.b.Stable:this._signalingState=k.b.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case k.b.HaveLocalOffer:this._signalingState=k.b.Stable,this._answer=t;break;case k.b.HaveRemoteOffer:case k.b.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof x.a)switch(this._signalingState){case k.b.Initial:case k.b.Stable:this._signalingState=k.b.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case k.b.HaveLocalOffer:this._signalingState=k.b.Stable,this._answer=t;break;case k.b.HaveRemoteOffer:case k.b.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof g.a)switch(this._signalingState){case k.b.Initial:case k.b.Stable:this._signalingState=k.b.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case k.b.HaveLocalOffer:break;case k.b.HaveRemoteOffer:this._signalingState=k.b.Stable,this._answer=t;break;case k.b.Closed:break;default:throw new Error("Unexpected signaling state.")}if(Object(C.c)(e))switch(this._signalingState){case k.b.Initial:case k.b.Stable:this._signalingState=k.b.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case k.b.HaveLocalOffer:break;case k.b.HaveRemoteOffer:this._signalingState=k.b.Stable,this._answer=t;break;case k.b.Closed:break;default:throw new Error("Unexpected signaling state.")}}}start2xxRetransmissionTimer(){if(this.initialTransaction instanceof E){const e=this.initialTransaction;let t=m.a.T1;const s=()=>{this.ackWait?(this.logger.log("No ACK for 2xx response received, attempting retransmission"),e.retransmitAcceptedResponse(),t=Math.min(2*t,m.a.T2),this.invite2xxTimer=setTimeout(s,t)):this.invite2xxTimer=void 0};this.invite2xxTimer=setTimeout(s,t);const i=()=>{e.state===f.Terminated&&(e.removeStateChangeListener(i),this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.ackWait&&(this.delegate&&this.delegate.onAckTimeout?this.delegate.onAckTimeout():this.bye()))};e.addStateChangeListener(i)}}startReInvite2xxRetransmissionTimer(){if(this.reinviteUserAgentServer&&this.reinviteUserAgentServer.transaction instanceof E){const e=this.reinviteUserAgentServer.transaction;let t=m.a.T1;const s=()=>{this.reinviteUserAgentServer?(this.logger.log("No ACK for 2xx response received, attempting retransmission"),e.retransmitAcceptedResponse(),t=Math.min(2*t,m.a.T2),this.invite2xxTimer=setTimeout(s,t)):this.invite2xxTimer=void 0};this.invite2xxTimer=setTimeout(s,t);const i=()=>{e.state===f.Terminated&&(e.removeStateChangeListener(i),this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.reinviteUserAgentServer)};e.addStateChangeListener(i)}}}class z extends D{constructor(e,t,s){super(_,e,t,s),this.confirmedDialogAcks=new Map,this.confirmedDialogs=new Map,this.earlyDialogs=new Map,this.delegate=s}dispose(){this.earlyDialogs.forEach(e=>e.dispose()),this.earlyDialogs.clear(),super.dispose()}onTransportError(e){if(this.transaction.state===f.Calling)return super.onTransportError(e);this.logger.error(e.message),this.logger.error("User agent client request transport error while sending ACK.")}receiveResponse(e){if(!this.authenticationGuard(e))return;const t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):return void(this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e}));case/^1[0-9]{2}$/.test(t):{if(!e.toTag)return void this.logger.warn("Non-100 1xx INVITE response received without a to tag, dropping.");if(!e.parseHeader("contact"))return void this.logger.error("Non-100 1xx INVITE response received without a Contact header field, dropping.");const t=R.initialDialogStateForUserAgentClient(this.message,e);let s=this.earlyDialogs.get(t.id);if(!s){const e=this.transaction;if(!(e instanceof _))throw new Error("Transaction not instance of InviteClientTransaction.");s=new J(e,this.core,t),this.earlyDialogs.set(s.id,s)}if(!s.reliableSequenceGuard(e))return void this.logger.warn("1xx INVITE reliable response received out of order or is a retransmission, dropping.");s.signalingState!==k.b.Initial&&s.signalingState!==k.b.HaveLocalOffer||s.signalingStateTransition(e);const i=s;this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:i,prack:e=>i.prack(void 0,e)})}return;case/^2[0-9]{2}$/.test(t):{if(!e.toTag)return void this.logger.error("2xx INVITE response received without a to tag, dropping.");if(!e.parseHeader("contact"))return void this.logger.error("2xx INVITE response received without a Contact header field, dropping.");const t=R.initialDialogStateForUserAgentClient(this.message,e);let s=this.confirmedDialogs.get(t.id);if(s){const e=this.confirmedDialogAcks.get(t.id);if(e){const t=this.transaction;if(!(t instanceof _))throw new Error("Client transaction not instance of InviteClientTransaction.");t.ackResponse(e.message)}return}if(s=this.earlyDialogs.get(t.id),s)s.confirm(),s.recomputeRouteSet(e),this.earlyDialogs.delete(s.id),this.confirmedDialogs.set(s.id,s);else{const e=this.transaction;if(!(e instanceof _))throw new Error("Transaction not instance of InviteClientTransaction.");s=new J(e,this.core,t),this.confirmedDialogs.set(s.id,s)}s.signalingState!==k.b.Initial&&s.signalingState!==k.b.HaveLocalOffer||s.signalingStateTransition(e);const i=s;if(this.delegate&&this.delegate.onAccept)this.delegate.onAccept({message:e,session:i,ack:e=>{const t=i.ack(e);return this.confirmedDialogAcks.set(i.id,t),t}});else{const e=i.ack();this.confirmedDialogAcks.set(i.id,e)}}return;case/^3[0-9]{2}$/.test(t):return this.earlyDialogs.forEach(e=>e.dispose()),this.earlyDialogs.clear(),void(this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e}));case/^[4-6][0-9]{2}$/.test(t):return this.earlyDialogs.forEach(e=>e.dispose()),this.earlyDialogs.clear(),void(this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e}));default:throw new Error("Invalid status code "+t)}throw new Error(`Executing what should be an unreachable code path receiving ${t} response.`)}}class X extends D{constructor(e,t,s){super(T,e,t,s)}}class Q extends D{constructor(e,t,s){super(T,e,t,s)}}!function(e){e.Initial="Initial",e.NotifyWait="NotifyWait",e.Pending="Pending",e.Active="Active",e.Terminated="Terminated"}(H||(H={}));var ee=s(12);class te extends D{constructor(e,t,s){const i=e.createOutgoingRequestMessage(u.a.SUBSCRIBE,s);super(T,e.userAgentCore,i,t),this.dialog=e}waitNotifyStop(){}receiveResponse(e){if(e.statusCode&&e.statusCode>=200&&e.statusCode<300){const t=e.getHeader("Expires");if(t){const e=Number(t);this.dialog.subscriptionExpires>e&&(this.dialog.subscriptionExpires=e)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE")}if(e.statusCode&&e.statusCode>=400&&e.statusCode<700){[404,405,410,416,480,481,482,483,484,485,489,501,604].includes(e.statusCode)&&this.dialog.terminate()}super.receiveResponse(e)}}class se extends R{constructor(e,t,s,i,r,n){super(i,r),this.delegate=n,this._autoRefresh=!1,this._subscriptionEvent=e,this._subscriptionExpires=t,this._subscriptionExpiresInitial=t,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this._subscriptionRefresh=void 0,this._subscriptionRefreshLastSet=void 0,this._subscriptionState=s,this.logger=i.loggerFactory.getLogger("sip.subscribe-dialog"),this.logger.log(`SUBSCRIBE dialog ${this.id} constructed`)}static initialDialogStateForSubscription(e,t){const s=t.getHeaders("record-route"),i=t.parseHeader("contact");if(!i)throw new Error("Contact undefined.");if(!(i instanceof I.a))throw new Error("Contact not instance of NameAddrHeader.");const r=i.uri,n=e.cseq,o=e.callId,a=e.fromTag,c=t.fromTag;if(!o)throw new Error("Call id undefined.");if(!a)throw new Error("From tag undefined.");if(!c)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");return{id:o+a+c,early:!1,callId:o,localTag:a,remoteTag:c,localSequenceNumber:n,remoteSequenceNumber:void 0,localURI:e.from.uri,remoteURI:e.to.uri,remoteTarget:r,routeSet:s,secure:!1}}dispose(){super.dispose(),this.N&&(clearTimeout(this.N),this.N=void 0),this.refreshTimerClear(),this.logger.log(`SUBSCRIBE dialog ${this.id} destroyed`)}get autoRefresh(){return this._autoRefresh}set autoRefresh(e){this._autoRefresh=!0,this.refreshTimerSet()}get subscriptionEvent(){return this._subscriptionEvent}get subscriptionExpires(){const e=Math.floor(Date.now()/1e3)-this._subscriptionExpiresLastSet,t=this._subscriptionExpires-e;return Math.max(t,0)}set subscriptionExpires(e){if(e<0)throw new Error("Expires must be greater than or equal to zero.");if(this._subscriptionExpires=e,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this.autoRefresh){const t=this.subscriptionRefresh;(void 0===t||t>=e)&&this.refreshTimerSet()}}get subscriptionExpiresInitial(){return this._subscriptionExpiresInitial}get subscriptionRefresh(){if(void 0===this._subscriptionRefresh||void 0===this._subscriptionRefreshLastSet)return;const e=Math.floor(Date.now()/1e3)-this._subscriptionRefreshLastSet,t=this._subscriptionRefresh-e;return Math.max(t,0)}get subscriptionState(){return this._subscriptionState}receiveRequest(e){if(this.logger.log(`SUBSCRIBE dialog ${this.id} received ${e.method} request`),this.sequenceGuard(e))switch(super.receiveRequest(e),e.method){case u.a.NOTIFY:this.onNotify(e);break;default:this.logger.log(`SUBSCRIBE dialog ${this.id} received unimplemented ${e.method} request`),this.core.replyStateless(e,{statusCode:501})}else this.logger.log(`SUBSCRIBE dialog ${this.id} rejected out of order ${e.method} request.`)}refresh(){const e="Allow: "+ee.a.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: "+this.subscriptionExpiresInitial),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)}subscribe(e,t={}){if(this.subscriptionState!==H.Pending&&this.subscriptionState!==H.Active)throw new Error(`Invalid state ${this.subscriptionState}. May only re-subscribe while in state "pending" or "active".`);this.logger.log(`SUBSCRIBE dialog ${this.id} sending SUBSCRIBE request`);const s=new te(this,e,t);return this.N&&(clearTimeout(this.N),this.N=void 0),this.N=setTimeout(()=>this.timerN(),m.a.TIMER_N),s}terminate(){this.stateTransition(H.Terminated),this.onTerminated()}unsubscribe(){const e="Allow: "+ee.a.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: 0"),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)}onNotify(e){const t=e.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent)return void this.core.replyStateless(e,{statusCode:489});this.N&&(clearTimeout(this.N),this.N=void 0);const s=e.parseHeader("Subscription-State");if(!s||!s.state)return void this.core.replyStateless(e,{statusCode:489});const i=s.state,r=s.expires?Math.max(s.expires,0):void 0;switch(i){case"pending":this.stateTransition(H.Pending,r);break;case"active":this.stateTransition(H.Active,r);break;case"terminated":this.stateTransition(H.Terminated,r);break;default:this.logger.warn("Unrecognized subscription state.")}const n=new B(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(n):n.accept()}onRefresh(e){this.delegate&&this.delegate.onRefresh&&this.delegate.onRefresh(e)}onTerminated(){this.delegate&&this.delegate.onTerminated&&this.delegate.onTerminated()}refreshTimerClear(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=void 0)}refreshTimerSet(){if(this.refreshTimerClear(),this.autoRefresh&&this.subscriptionExpires>0){const e=900*this.subscriptionExpires;this._subscriptionRefresh=Math.floor(e/1e3),this._subscriptionRefreshLastSet=Math.floor(Date.now()/1e3),this.refreshTimer=setTimeout(()=>{this.refreshTimer=void 0,this._subscriptionRefresh=void 0,this._subscriptionRefreshLastSet=void 0,this.onRefresh(this.refresh())},e)}}stateTransition(e,t){const s=()=>{this.logger.warn(`Invalid subscription state transition from ${this.subscriptionState} to ${e}`)};switch(e){case H.Initial:case H.NotifyWait:return void s();case H.Pending:if(this.subscriptionState!==H.NotifyWait&&this.subscriptionState!==H.Pending)return void s();break;case H.Active:case H.Terminated:if(this.subscriptionState!==H.NotifyWait&&this.subscriptionState!==H.Pending&&this.subscriptionState!==H.Active)return void s();break;default:return void s()}e===H.Pending&&t&&(this.subscriptionExpires=t),e===H.Active&&t&&(this.subscriptionExpires=t),e===H.Terminated&&this.dispose(),this._subscriptionState=e}timerN(){this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."),this.subscriptionState!==H.Terminated&&(this.stateTransition(H.Terminated),this.onTerminated())}}class ie extends D{constructor(e,t,s){const i=t.getHeader("Event");if(!i)throw new Error("Event undefined");const r=t.getHeader("Expires");if(!r)throw new Error("Expires undefined");super(T,e,t,s),this.delegate=s,this.subscriberId=t.callId+t.fromTag+i,this.subscriptionExpiresRequested=this.subscriptionExpires=Number(r),this.subscriptionEvent=i,this.subscriptionState=H.NotifyWait,this.waitNotifyStart()}dispose(){super.dispose()}onNotify(e){const t=e.message.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent)return this.logger.warn("Failed to parse event."),void e.reject({statusCode:489});const s=e.message.parseHeader("Subscription-State");if(!s||!s.state)return this.logger.warn("Failed to parse subscription state."),void e.reject({statusCode:489});const i=s.state;switch(i){case"pending":case"active":case"terminated":break;default:return this.logger.warn("Invalid subscription state "+i),void e.reject({statusCode:489})}if("terminated"!==i){if(!e.message.parseHeader("contact"))return this.logger.warn("Failed to parse contact."),void e.reject({statusCode:489})}if(this.dialog)throw new Error("Dialog already created. This implementation only supports install of single subscriptions.");switch(this.waitNotifyStop(),this.subscriptionExpires=s.expires?Math.min(this.subscriptionExpires,Math.max(s.expires,0)):this.subscriptionExpires,i){case"pending":this.subscriptionState=H.Pending;break;case"active":this.subscriptionState=H.Active;break;case"terminated":this.subscriptionState=H.Terminated;break;default:throw new Error(`Unrecognized state ${i}.`)}if(this.subscriptionState!==H.Terminated){const t=se.initialDialogStateForSubscription(this.message,e.message);this.dialog=new se(this.subscriptionEvent,this.subscriptionExpires,this.subscriptionState,this.core,t)}if(this.delegate&&this.delegate.onNotify){const t=e,s=this.dialog;this.delegate.onNotify({request:t,subscription:s})}else e.accept()}waitNotifyStart(){this.N||(this.core.subscribers.set(this.subscriberId,this),this.N=setTimeout(()=>this.timerN(),m.a.TIMER_N))}waitNotifyStop(){this.N&&(this.core.subscribers.delete(this.subscriberId),clearTimeout(this.N),this.N=void 0)}receiveResponse(e){if(this.authenticationGuard(e)){if(e.statusCode&&e.statusCode>=200&&e.statusCode<300){const t=e.getHeader("Expires");if(t){const e=Number(t);e>this.subscriptionExpiresRequested&&this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),e<this.subscriptionExpires&&(this.subscriptionExpires=e)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE");this.dialog&&this.dialog.subscriptionExpires>this.subscriptionExpires&&(this.dialog.subscriptionExpires=this.subscriptionExpires)}e.statusCode&&e.statusCode>=300&&e.statusCode<700&&this.waitNotifyStop(),super.receiveResponse(e)}}timerN(){this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."),this.waitNotifyStop(),this.delegate&&this.delegate.onNotifyTimeout&&this.delegate.onNotifyTimeout()}}class re extends O{constructor(e,t,s){super(E,e,t,s),this.core=e}dispose(){this.earlyDialog&&this.earlyDialog.dispose(),super.dispose()}accept(e={statusCode:200}){if(!this.acceptable)throw new q.a(`${this.message.method} not acceptable in state ${this.transaction.state}.`);if(!this.confirmedDialog)if(this.earlyDialog)this.earlyDialog.confirm(),this.confirmedDialog=this.earlyDialog,this.earlyDialog=void 0;else{const e=this.transaction;if(!(e instanceof E))throw new Error("Transaction not instance of InviteClientTransaction.");const t=R.initialDialogStateForUserAgentServer(this.message,this.toTag);this.confirmedDialog=new J(e,this.core,t)}const t=this.message.getHeaders("record-route").map(e=>"Record-Route: "+e),s="Contact: "+this.core.configuration.contact.toString(),i="Allow: "+ee.a.toString();if(!e.body)if(this.confirmedDialog.signalingState===k.b.Stable)e.body=this.confirmedDialog.answer;else if(this.confirmedDialog.signalingState===k.b.Initial||this.confirmedDialog.signalingState===k.b.HaveRemoteOffer)throw new Error("Response must have a body.");e.statusCode=e.statusCode||200,e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(t),e.extraHeaders.push(i),e.extraHeaders.push(s);const r=super.accept(e),n=this.confirmedDialog,o=Object.assign(Object.assign({},r),{session:n});return e.body&&this.confirmedDialog.signalingState!==k.b.Stable&&this.confirmedDialog.signalingStateTransition(e.body),o}progress(e={statusCode:180}){if(!this.progressable)throw new q.a(`${this.message.method} not progressable in state ${this.transaction.state}.`);if(!this.earlyDialog){const e=this.transaction;if(!(e instanceof E))throw new Error("Transaction not instance of InviteClientTransaction.");const t=R.initialDialogStateForUserAgentServer(this.message,this.toTag,!0);this.earlyDialog=new J(e,this.core,t)}const t=this.message.getHeaders("record-route").map(e=>"Record-Route: "+e),s="Contact: "+this.core.configuration.contact;e.extraHeaders=e.extraHeaders||[],e.extraHeaders=e.extraHeaders.concat(t),e.extraHeaders.push(s);const i=super.progress(e),r=this.earlyDialog,n=Object.assign(Object.assign({},i),{session:r});return e.body&&this.earlyDialog.signalingState!==k.b.Stable&&this.earlyDialog.signalingStateTransition(e.body),n}redirect(e,t={statusCode:302}){return super.redirect(e,t)}reject(e={statusCode:486}){return super.reject(e)}}class ne extends O{constructor(e,t,s){super(P,e,t,s),this.core=e}}class oe extends O{constructor(e,t,s){super(P,e,t,s),this.core=e}}const ae=["application/sdp","application/dtmf-relay"];class ce{constructor(e,t={}){this.userAgentClients=new Map,this.userAgentServers=new Map,this.configuration=e,this.delegate=t,this.dialogs=new Map,this.subscribers=new Map,this.logger=e.loggerFactory.getLogger("sip.user-agent-core")}dispose(){this.reset()}reset(){this.dialogs.forEach(e=>e.dispose()),this.dialogs.clear(),this.subscribers.forEach(e=>e.dispose()),this.subscribers.clear(),this.userAgentClients.forEach(e=>e.dispose()),this.userAgentClients.clear(),this.userAgentServers.forEach(e=>e.dispose()),this.userAgentServers.clear()}get loggerFactory(){return this.configuration.loggerFactory}get transport(){const e=this.configuration.transportAccessor();if(!e)throw new Error("Transport undefined.");return e}invite(e,t){return new z(this,e,t)}message(e,t){return new F(this,e,t)}publish(e,t){return new X(this,e,t)}register(e,t){return new Q(this,e,t)}subscribe(e,t){return new ie(this,e,t)}request(e,t){return new D(T,this,e,t)}makeOutgoingRequestMessage(e,t,s,i,r,n,o){const a=this.configuration.sipjsId,c=this.configuration.displayName,h=this.configuration.viaForceRport,d=this.configuration.hackViaTcp,l=this.configuration.supportedOptionTags.slice();e===u.a.REGISTER&&l.push("path","gruu"),e===u.a.INVITE&&(this.configuration.contact.pubGruu||this.configuration.contact.tempGruu)&&l.push("gruu");const p={callIdPrefix:a,forceRport:h,fromDisplayName:c,hackViaTcp:d,optionTags:l,routeSet:this.configuration.routeSet,userAgentString:this.configuration.userAgentHeaderFieldValue,viaHost:this.configuration.viaHost},f=Object.assign(Object.assign({},p),r);return new g.a(e,t,s,i,f,n,o)}receiveIncomingRequestFromTransport(e){this.receiveRequestFromTransport(e)}receiveIncomingResponseFromTransport(e){this.receiveResponseFromTransport(e)}replyStateless(e,t){const s=this.configuration.userAgentHeaderFieldValue,i=this.configuration.supportedOptionTagsResponse;t=Object.assign(Object.assign({},t),{userAgent:s,supported:i});const r=p(e,t);return this.transport.send(r.message).catch(t=>{t instanceof Error&&this.logger.error(t.message),this.logger.error(`Transport error occurred sending stateless reply to ${e.method} request.`)}),r}receiveRequestFromTransport(e){const t=e.viaBranch,s=this.userAgentServers.get(t);e.method===u.a.ACK&&s&&s.transaction.state===f.Accepted&&s instanceof re?this.logger.warn(`Discarding out of dialog ACK after 2xx response sent on transaction ${t}.`):e.method!==u.a.CANCEL?s?s.transaction.receiveRequest(e):this.receiveRequest(e):s?(this.replyStateless(e,{statusCode:200}),s.transaction instanceof E&&s.transaction.state===f.Proceeding&&s instanceof re&&s.receiveCancel(e)):this.replyStateless(e,{statusCode:481})}receiveRequest(e){if(!ee.a.includes(e.method)){const t="Allow: "+ee.a.toString();return void this.replyStateless(e,{statusCode:405,extraHeaders:[t]})}if(!e.ruri)throw new Error("Request-URI undefined.");if("sip"!==e.ruri.scheme)return void this.replyStateless(e,{statusCode:416});const t=e.ruri,s=e=>!!e&&e.user===t.user;if(!s(this.configuration.aor)&&!(s(this.configuration.contact.uri)||s(this.configuration.contact.pubGruu)||s(this.configuration.contact.tempGruu)))return this.logger.warn("Request-URI does not point to us."),void(e.method!==u.a.ACK&&this.replyStateless(e,{statusCode:404}));if(e.method!==u.a.INVITE||e.hasHeader("Contact")){if(!e.toTag){const t=e.viaBranch;if(!this.userAgentServers.has(t)){if(Array.from(this.userAgentServers.values()).some(t=>t.transaction.request.fromTag===e.fromTag&&t.transaction.request.callId===e.callId&&t.transaction.request.cseq===e.cseq))return void this.replyStateless(e,{statusCode:482})}}e.toTag?this.receiveInsideDialogRequest(e):this.receiveOutsideDialogRequest(e)}else this.replyStateless(e,{statusCode:400,reasonPhrase:"Missing Contact Header"})}receiveInsideDialogRequest(e){if(e.method===u.a.NOTIFY){const t=e.parseHeader("Event");if(!t||!t.event)return void this.replyStateless(e,{statusCode:489});const s=e.callId+e.toTag+t.event,i=this.subscribers.get(s);if(i){const t=new B(this,e);return void i.onNotify(t)}}const t=e.callId+e.toTag+e.fromTag,s=this.dialogs.get(t);if(s){if(e.method===u.a.OPTIONS){const t="Allow: "+ee.a.toString(),s="Accept: "+ae.toString();return void this.replyStateless(e,{statusCode:200,extraHeaders:[t,s]})}s.receiveRequest(e)}else e.method!==u.a.ACK&&this.replyStateless(e,{statusCode:481})}receiveOutsideDialogRequest(e){switch(e.method){case u.a.ACK:break;case u.a.BYE:this.replyStateless(e,{statusCode:481});break;case u.a.CANCEL:throw new Error(`Unexpected out of dialog request method ${e.method}.`);case u.a.INFO:this.replyStateless(e,{statusCode:405});break;case u.a.INVITE:{const t=new re(this,e);this.delegate.onInvite?this.delegate.onInvite(t):t.reject()}break;case u.a.MESSAGE:{const t=new U(this,e);this.delegate.onMessage?this.delegate.onMessage(t):t.accept()}break;case u.a.NOTIFY:{const t=new B(this,e);this.delegate.onNotify?this.delegate.onNotify(t):t.reject({statusCode:405})}break;case u.a.OPTIONS:{const t="Allow: "+ee.a.toString(),s="Accept: "+ae.toString();this.replyStateless(e,{statusCode:200,extraHeaders:[t,s]})}break;case u.a.REFER:{const t=new Z(this,e);this.delegate.onRefer?this.delegate.onRefer(t):t.reject({statusCode:405})}break;case u.a.REGISTER:{const t=new ne(this,e);this.delegate.onRegister?this.delegate.onRegister(t):t.reject({statusCode:405})}break;case u.a.SUBSCRIBE:{const t=new oe(this,e);this.delegate.onSubscribe?this.delegate.onSubscribe(t):t.reject({statusCode:480})}break;default:throw new Error(`Unexpected out of dialog request method ${e.method}.`)}}receiveResponseFromTransport(e){if(e.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response, dropping");const t=e.viaBranch+e.method,s=this.userAgentClients.get(t);s?s.transaction.receiveResponse(e):this.logger.warn(`Discarding unmatched ${e.statusCode} response to ${e.method} ${t}.`)}}var he;!function(e){function t(e,t){let s=t,i=0,r=0;if(e.substring(s,s+2).match(/(^\r\n)/))return-2;for(;0===i;){if(r=e.indexOf("\r\n",s),-1===r)return r;!e.substring(r+2,r+4).match(/(^\r\n)/)&&e.charAt(r+2).match(/(^\s+)/)?s=r+2:i=r}return i}function s(e,t,s,i){const r=t.indexOf(":",s),n=t.substring(s,r).trim(),o=t.substring(r+1,i).trim();let c;switch(n.toLowerCase()){case"via":case"v":e.addHeader("via",o),1===e.getHeaders("via").length?(c=e.parseHeader("Via"),c&&(e.via=c,e.viaBranch=c.branch)):c=0;break;case"from":case"f":e.setHeader("from",o),c=e.parseHeader("from"),c&&(e.from=c,e.fromTag=c.getParam("tag"));break;case"to":case"t":e.setHeader("to",o),c=e.parseHeader("to"),c&&(e.to=c,e.toTag=c.getParam("tag"));break;case"record-route":if(c=a.a.parse(o,"Record_Route"),-1===c){c=void 0;break}if(!(c instanceof Array)){c=void 0;break}c.forEach(t=>{e.addHeader("record-route",o.substring(t.position,t.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=t.parsed});break;case"call-id":case"i":e.setHeader("call-id",o),c=e.parseHeader("call-id"),c&&(e.callId=o);break;case"contact":case"m":if(c=a.a.parse(o,"Contact"),-1===c){c=void 0;break}if(!(c instanceof Array)){c=void 0;break}c.forEach(t=>{e.addHeader("contact",o.substring(t.position,t.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=t.parsed});break;case"content-length":case"l":e.setHeader("content-length",o),c=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",o),c=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",o),c=e.parseHeader("cseq"),c&&(e.cseq=c.value),e instanceof x.a&&(e.method=c.method);break;case"max-forwards":e.setHeader("max-forwards",o),c=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",o),c=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",o),c=e.parseHeader("proxy-authenticate");break;case"refer-to":case"r":e.setHeader("refer-to",o),c=e.parseHeader("refer-to"),c&&(e.referTo=c);break;default:e.addHeader(n.toLowerCase(),o),c=0}return void 0!==c||{error:"error parsing header '"+n+"'"}}e.getHeader=t,e.parseHeader=s,e.parseMessage=function(e,i){let r=0,n=e.indexOf("\r\n");if(-1===n)return void i.warn("no CRLF found, not a SIP message, discarded");const o=e.substring(0,n),c=a.a.parse(o,"Request_Response");let h,d;if(-1!==c){for(c.status_code?(h=new x.a,h.statusCode=c.status_code,h.reasonPhrase=c.reason_phrase):(h=new $.a,h.method=c.method,h.ruri=c.uri),h.data=e,r=n+2;;){if(n=t(e,r),-2===n){d=r+2;break}if(-1===n)return void i.error("malformed message");const o=s(h,e,r,n);if(o&&!0!==o)return void i.error(o.error);r=n+2}return h.hasHeader("content-length")?h.body=e.substr(d,Number(h.getHeader("content-length"))):h.body=e.substring(d),h}i.warn('error parsing first line of SIP message: "'+o+'"')}}(he||(he={}));var de=s(42);function le(e){return(t,s)=>{void 0===e&&(e=e=>e.audio||e.video?void 0===navigator.mediaDevices?Promise.reject(new Error("Media devices not available in insecure contexts.")):navigator.mediaDevices.getUserMedia.call(navigator.mediaDevices,e):Promise.resolve(new MediaStream));const i={iceGatheringTimeout:void 0!==(null==s?void 0:s.iceGatheringTimeout)?null==s?void 0:s.iceGatheringTimeout:5e3,peerConnectionConfiguration:Object.assign(Object.assign({},{bundlePolicy:"balanced",certificates:void 0,iceCandidatePoolSize:0,iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all",peerIdentity:void 0,rtcpMuxPolicy:"require"}),null==s?void 0:s.peerConnectionConfiguration)},r=t.userAgent.getLogger("sip.SessionDescriptionHandler");return new de.a(r,e,i)}}var ue=s(40);var ge=s(16),pe=s(46),fe=s(43),me=s(27),ve=s(21),we=s(13),be=s(9);s.d(t,"a",(function(){return ye}));class ye{constructor(e={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=be.a.Stopped,this.unloadListener=()=>{this.stop()},this._stateEventEmitter=new ge.a,this.delegate=e.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ye.defaultOptions()),{sipjsId:Object(h.a)(5)}),{uri:new r.a("sip","anonymous."+Object(h.a)(6),"anonymous.invalid")}),{viaHost:Object(h.a)(12)+".invalid"}),ye.stripUndefinedProperties(e)),this.options.hackIpInContact)if("boolean"==typeof this.options.hackIpInContact&&this.options.hackIpInContact){const e=1,t=254,s=Math.floor(Math.random()*(t-e+1)+e);this.options.viaHost="192.0.2."+s}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new o,this.logger=this.loggerFactory.getLogger("sip.UserAgent"),this.loggerFactory.builtinEnabled=this.options.logBuiltinEnabled,this.loggerFactory.connector=this.options.logConnector,this.options.logLevel){case"error":this.loggerFactory.level=i.error;break;case"warn":this.loggerFactory.level=i.warn;break;case"log":this.loggerFactory.level=i.log;break;case"debug":this.loggerFactory.level=i.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(e=>{const t=this.options[e];switch(e){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+e+": "+t);break;case"authorizationPassword":this.logger.log("· "+e+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+e+": "+t.name);break;default:this.logger.log("· "+e+": "+JSON.stringify(t))}})),this.options.transportOptions){const t=this.options.transportOptions,s=t.maxReconnectionAttempts,i=t.reconnectionTimeout;if(void 0!==s){const e='The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.';this.logger.warn(e)}if(void 0!==i){const e='The transport option "reconnectionTimeout" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.';this.logger.warn(e)}void 0===e.reconnectionDelay&&void 0!==i&&(this.options.reconnectionDelay=i),void 0===e.reconnectionAttempts&&void 0!==s&&(this.options.reconnectionAttempts=s)}if(void 0!==e.reconnectionDelay){const e='The user agent option "reconnectionDelay" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.';this.logger.warn(e)}if(void 0!==e.reconnectionAttempts){const e='The user agent option "reconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.';this.logger.warn(e)}this._transport=new this.options.transportConstructor(this.getLogger("sip.Transport"),this.options.transportOptions),this.initTransportCallbacks(),this._contact=this.initContact(),this._userAgentCore=this.initCore(),this.options.autoStart&&this.start()}static makeURI(e){return a.a.URIParse(e)}static defaultOptions(){return{allowLegacyNotifications:!1,authorizationHa1:"",authorizationPassword:"",authorizationUsername:"",autoStart:!1,autoStop:!0,delegate:{},contactName:"",contactParams:{transport:"ws"},displayName:"",forceRport:!1,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:()=>{},logLevel:"log",noAnswerTimeout:60,preloadedRouteSet:[],reconnectionAttempts:0,reconnectionDelay:4,sendInitialProvisionalResponse:!0,sessionDescriptionHandlerFactory:le(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:we.a.Unsupported,sipExtensionReplaces:we.a.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:ue.a,transportOptions:{},uri:new r.a("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/0.20.0",viaHost:""}}static stripUndefinedProperties(e){return Object.keys(e).reduce((t,s)=>(void 0!==e[s]&&(t[s]=e[s]),t),{})}get configuration(){return this.options}get contact(){return this._contact}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get transport(){return this._transport}get userAgentCore(){return this._userAgentCore}getLogger(e,t){return this.loggerFactory.getLogger(e,t)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===be.a.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){if(this.state===be.a.Started)return this.logger.warn("User agent already started"),Promise.resolve();if(this.logger.log("Starting "+this.configuration.uri),this.transitionState(be.a.Started),this.options.autoStop){const e=!("undefined"==typeof chrome||!chrome.app||!chrome.app.runtime);"undefined"==typeof window||"function"!=typeof window.addEventListener||e||window.addEventListener("unload",this.unloadListener)}return this.transport.connect()}async stop(){if(this.state===be.a.Stopped)return this.logger.warn("User agent already stopped"),Promise.resolve();if(this.logger.log("Stopping "+this.configuration.uri),this.transitionState(be.a.Stopped),this.options.autoStop){const e=!("undefined"==typeof chrome||!chrome.app||!chrome.app.runtime);"undefined"!=typeof window&&window.removeEventListener&&!e&&window.removeEventListener("unload",this.unloadListener)}const e=Object.assign({},this._publishers),t=Object.assign({},this._registerers),s=Object.assign({},this._sessions),i=Object.assign({},this._subscriptions),r=this.transport,n=this.userAgentCore;this.logger.log("Dispose of registerers");for(const e in t)t[e]&&await t[e].dispose().catch(t=>{throw this.logger.error(t.message),delete this._registerers[e],t});this.logger.log("Dispose of sessions");for(const e in s)s[e]&&await s[e].dispose().catch(t=>{throw this.logger.error(t.message),delete this._sessions[e],t});this.logger.log("Dispose of subscriptions");for(const e in i)i[e]&&await i[e].dispose().catch(t=>{throw this.logger.error(t.message),delete this._subscriptions[e],t});this.logger.log("Dispose of publishers");for(const t in e)e[t]&&await e[t].dispose().catch(e=>{throw this.logger.error(e.message),delete this._publishers[t],e});this.logger.log("Dispose of transport"),await r.dispose().catch(e=>{throw this.logger.error(e.message),e}),this.logger.log("Dispose of core"),n.dispose()}_makeInviter(e,t){return new fe.a(this,e,t)}attemptReconnection(e=1){const t=this.options.reconnectionAttempts,s=this.options.reconnectionDelay;e>t?this.logger.log("Maximum reconnection attempts reached"):(this.logger.log(`Reconnection attempt ${e} of ${t} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${e} of ${t} - succeeded`)}).catch(s=>{this.logger.error(s.message),this.logger.log(`Reconnection attempt ${e} of ${t} - failed`),this.attemptReconnection(++e)})},1===e?0:1e3*s))}initContact(){const e=""!==this.options.contactName?this.options.contactName:Object(h.a)(8),t=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new r.a("sip",e,this.options.viaHost,void 0,t),toString:(e={})=>{const s=e.anonymous||!1,i=e.outbound||!1;let r="<";return r+=s?this.contact.tempGruu||"sip:anonymous@anonymous.invalid;transport="+(t.transport?t.transport:"ws"):this.contact.pubGruu||this.contact.uri,i&&(r+=";ob"),r+=">",r}}}initCore(){let e=[];e.push("outbound"),this.options.sipExtension100rel===we.a.Supported&&e.push("100rel"),this.options.sipExtensionReplaces===we.a.Supported&&e.push("replaces"),this.options.sipExtensionExtraSupported&&e.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(e=e.filter(e=>we.b[e])),e=Array.from(new Set(e));const t=e.slice();(this.contact.pubGruu||this.contact.tempGruu)&&t.push("gruu");const s={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:e,supportedOptionTagsResponse:t,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const e=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,t=this.options.authorizationPassword?this.options.authorizationPassword:void 0,s=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new l(this.getLoggerFactory(),s,e,t)},transportAccessor:()=>this.transport};return new ce(s,{onInvite:e=>{var t;const s=new pe.a(this,e);if(e.delegate={onCancel:e=>{s._onCancel(e)},onTransportError:e=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},e.trying(),this.options.sipExtensionReplaces!==we.a.Unsupported){const t=e.message.parseHeader("replaces");if(t){const e=t.call_id;if("string"!=typeof e)throw new Error("Type of call id is not string");const i=t.replaces_to_tag;if("string"!=typeof i)throw new Error("Type of to tag is not string");const r=t.replaces_from_tag;if("string"!=typeof r)throw new Error("type of from tag is not string");const n=e+i+r,o=this.userAgentCore.dialogs.get(n);if(!o)return void s.reject({statusCode:481});if(!o.early&&!0===t.early_only)return void s.reject({statusCode:486});const a=this._sessions[e+r]||this._sessions[e+i]||void 0;if(!a)throw new Error("Session does not exist.");s._replacee=a}}if(null===(t=this.delegate)||void 0===t?void 0:t.onInvite)return s.autoSendAnInitialProvisionalResponse?void s.progress().then(()=>{var e;if(void 0===(null===(e=this.delegate)||void 0===e?void 0:e.onInvite))throw new Error("onInvite undefined.");this.delegate.onInvite(s)}):void this.delegate.onInvite(s);s.reject({statusCode:486})},onMessage:e=>{if(this.delegate&&this.delegate.onMessage){const t=new me.a(e);this.delegate.onMessage(t)}else e.accept()},onNotify:e=>{if(this.delegate&&this.delegate.onNotify){const t=new ve.a(e);this.delegate.onNotify(t)}else this.options.allowLegacyNotifications?e.accept():e.reject({statusCode:481})},onRefer:e=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(e):e.reject({statusCode:405})},onRegister:e=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(e):e.reject({statusCode:405})},onSubscribe:e=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(e):e.reject({statusCode:405})}})}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=e=>this.onTransportDisconnect(e),this.transport.onMessage=e=>this.onTransportMessage(e)}onTransportConnect(){this.state!==be.a.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(e){this.state!==be.a.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(e),e&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(e){const t=he.parseMessage(e,this.getLogger("sip.Parser"));if(!t)return void this.logger.warn("Failed to parse incoming message. Dropping.");if(this.state===be.a.Stopped&&t instanceof $.a)return void this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);const s=()=>{const e=["from","to","call_id","cseq","via"];for(const s of e)if(!t.hasHeader(s))return this.logger.warn(`Missing mandatory header field : ${s}.`),!1;return!0};if(t instanceof $.a){if(!s())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!t.toTag&&t.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(t,{statusCode:482});const e=Object(h.e)(t.body),i=t.getHeader("content-length");if(i&&e<Number(i))return void this.userAgentCore.replyStateless(t,{statusCode:400})}if(t instanceof x.a){if(!s())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(t.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(t.via.host!==this.options.viaHost||void 0!==t.via.port)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");const e=Object(h.e)(t.body),i=t.getHeader("content-length");if(i&&e<Number(i))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(t instanceof $.a)this.userAgentCore.receiveIncomingRequestFromTransport(t);else{if(!(t instanceof x.a))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(t)}}transitionState(e,t){const s=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case be.a.Started:e!==be.a.Stopped&&s();break;case be.a.Stopped:e!==be.a.Started&&s();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${e}`),this._state=e,this._stateEventEmitter.emit(this._state)}}},,,,function(e,t,s){var i=s(15).default,r=s(54);e.exports=function(e){var t=r(e,"string");return"symbol"===i(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,i=new Array(t);s<t;s++)i[s]=e[s];return i},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";var i,r=s(16),n=s(19);class o extends n.a{constructor(e){super(e||"An error occurred during state transition.")}}!function(e){e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Disconnected="Disconnected"}(i||(i={}));var a=s(23);s.d(t,"a",(function(){return c}));class c{constructor(e,t){if(this._state=i.Disconnected,this.transitioningState=!1,this._stateEventEmitter=new r.a,this.logger=e,t){const e=t,s=null==e?void 0:e.wsServers,i=null==e?void 0:e.maxReconnectionAttempts;if(void 0!==s){const e='The transport option "wsServers" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.';this.logger.warn(e)}if(void 0!==i){const e='The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.';this.logger.warn(e)}s&&!t.server&&("string"==typeof s&&(t.server=s),s instanceof Array&&(t.server=s[0]))}this.configuration=Object.assign(Object.assign({},c.defaultOptions),t);const s=this.configuration.server,n=a.a.parse(s,"absoluteURI");if(-1===n)throw this.logger.error(`Invalid WebSocket Server URL "${s}"`),new Error("Invalid WebSocket Server URL");if(!["wss","ws","udp"].includes(n.scheme))throw this.logger.error(`Invalid scheme in WebSocket Server URL "${s}"`),new Error("Invalid scheme in WebSocket Server URL");this._protocol=n.scheme.toUpperCase()}dispose(){return this.disconnect()}get protocol(){return this._protocol}get server(){return this.configuration.server}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get ws(){return this._ws}connect(){return this._connect()}disconnect(){return this._disconnect()}isConnected(){return this.state===i.Connected}send(e){return this._send(e)}_connect(){switch(this.logger.log("Connecting "+this.server),this.state){case i.Connecting:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(i.Connecting));if(!this.connectPromise)throw new Error("Connect promise must be defined.");return this.connectPromise;case i.Connected:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(i.Connecting));if(this.connectPromise)throw new Error("Connect promise must not be defined.");return Promise.resolve();case i.Disconnecting:if(this.connectPromise)throw new Error("Connect promise must not be defined.");try{this.transitionState(i.Connecting)}catch(e){if(e instanceof o)return Promise.reject(e);throw e}break;case i.Disconnected:if(this.connectPromise)throw new Error("Connect promise must not be defined.");try{this.transitionState(i.Connecting)}catch(e){if(e instanceof o)return Promise.reject(e);throw e}break;default:throw new Error("Unknown state")}let e;try{e=new WebSocket(this.server,"sip"),e.binaryType="arraybuffer",e.addEventListener("close",t=>this.onWebSocketClose(t,e)),e.addEventListener("error",t=>this.onWebSocketError(t,e)),e.addEventListener("open",t=>this.onWebSocketOpen(t,e)),e.addEventListener("message",t=>this.onWebSocketMessage(t,e)),this._ws=e}catch(e){return this._ws=void 0,this.logger.error("WebSocket construction failed."),this.logger.error(e),new Promise((t,s)=>{this.connectResolve=t,this.connectReject=s,this.transitionState(i.Disconnected,e)})}return this.connectPromise=new Promise((t,s)=>{this.connectResolve=t,this.connectReject=s,this.connectTimeout=setTimeout(()=>{this.logger.warn("Connect timed out. Exceeded time set in configuration.connectionTimeout: "+this.configuration.connectionTimeout+"s."),e.close(1e3)},1e3*this.configuration.connectionTimeout)}),this.connectPromise}_disconnect(){switch(this.logger.log("Disconnecting "+this.server),this.state){case i.Connecting:if(this.disconnectPromise)throw new Error("Disconnect promise must not be defined.");try{this.transitionState(i.Disconnecting)}catch(e){if(e instanceof o)return Promise.reject(e);throw e}break;case i.Connected:if(this.disconnectPromise)throw new Error("Disconnect promise must not be defined.");try{this.transitionState(i.Disconnecting)}catch(e){if(e instanceof o)return Promise.reject(e);throw e}break;case i.Disconnecting:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(i.Disconnecting));if(!this.disconnectPromise)throw new Error("Disconnect promise must be defined.");return this.disconnectPromise;case i.Disconnected:if(this.transitioningState)return Promise.reject(this.transitionLoopDetectedError(i.Disconnecting));if(this.disconnectPromise)throw new Error("Disconnect promise must not be defined.");return Promise.resolve();default:throw new Error("Unknown state")}if(!this._ws)throw new Error("WebSocket must be defined.");const e=this._ws;return this.disconnectPromise=new Promise((t,s)=>{this.disconnectResolve=t,this.disconnectReject=s;try{e.close(1e3)}catch(e){throw this.logger.error("WebSocket close failed."),this.logger.error(e),e}}),this.disconnectPromise}_send(e){if(!0===this.configuration.traceSip&&this.logger.log("Sending WebSocket message:\n\n"+e+"\n"),this._state!==i.Connected)return Promise.reject(new Error("Not connected."));if(!this._ws)throw new Error("WebSocket undefined.");try{this._ws.send(e)}catch(e){return e instanceof Error?Promise.reject(e):Promise.reject(new Error("WebSocket send failed."))}return Promise.resolve()}onWebSocketClose(e,t){if(t!==this._ws)return;const s=`WebSocket closed ${this.server} (code: ${e.code})`,r=this.disconnectPromise?void 0:new Error(s);r&&this.logger.warn("WebSocket closed unexpectedly"),this.logger.log(s),this._ws=void 0,this.transitionState(i.Disconnected,r)}onWebSocketError(e,t){t===this._ws&&this.logger.error("WebSocket error occurred.")}onWebSocketMessage(e,t){if(t!==this._ws)return;const s=e.data;let r;if(/^(\r\n)+$/.test(s))return this.clearKeepAliveTimeout(),void(!0===this.configuration.traceSip&&this.logger.log("Received WebSocket message with CRLF Keep Alive response"));if(s){if("string"!=typeof s){try{r=(new TextDecoder).decode(new Uint8Array(s))}catch(e){return this.logger.error(e),void this.logger.error("Received WebSocket binary message failed to be converted into string, message discarded")}!0===this.configuration.traceSip&&this.logger.log("Received WebSocket binary message:\n\n"+r+"\n")}else r=s,!0===this.configuration.traceSip&&this.logger.log("Received WebSocket text message:\n\n"+r+"\n");if(this.state===i.Connected){if(this.onMessage)try{this.onMessage(r)}catch(e){throw this.logger.error(e),this.logger.error("Exception thrown by onMessage callback"),e}}else this.logger.warn("Received message while not connected, discarding...")}else this.logger.warn("Received empty message, discarding...")}onWebSocketOpen(e,t){t===this._ws&&this._state===i.Connecting&&(this.logger.log("WebSocket opened "+this.server),this.transitionState(i.Connected))}transitionLoopDetectedError(e){let t="A state transition loop has been detected.";return t+=` An attempt to transition from ${this._state} to ${e} before the prior transition completed.`,t+=" Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?",this.logger.error(t),new o("Loop detected.")}transitionState(e,t){const s=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};if(this.transitioningState)throw this.transitionLoopDetectedError(e);switch(this.transitioningState=!0,this._state){case i.Connecting:e!==i.Connected&&e!==i.Disconnecting&&e!==i.Disconnected&&s();break;case i.Connected:e!==i.Disconnecting&&e!==i.Disconnected&&s();break;case i.Disconnecting:e!==i.Connecting&&e!==i.Disconnected&&s();break;case i.Disconnected:e!==i.Connecting&&s();break;default:throw new Error("Unknown state.")}const r=this._state;this._state=e;const n=this.connectResolve,o=this.connectReject;r===i.Connecting&&(this.connectPromise=void 0,this.connectResolve=void 0,this.connectReject=void 0);const a=this.disconnectResolve,c=this.disconnectReject;if(r===i.Disconnecting&&(this.disconnectPromise=void 0,this.disconnectResolve=void 0,this.disconnectReject=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),this.logger.log(`Transitioned from ${r} to ${this._state}`),this._stateEventEmitter.emit(this._state),e===i.Connected&&(this.startSendingKeepAlives(),this.onConnect))try{this.onConnect()}catch(e){throw this.logger.error(e),this.logger.error("Exception thrown by onConnect callback"),e}if(r===i.Connected&&(this.stopSendingKeepAlives(),this.onDisconnect))try{t?this.onDisconnect(t):this.onDisconnect()}catch(e){throw this.logger.error(e),this.logger.error("Exception thrown by onDisconnect callback"),e}if(r===i.Connecting){if(!n)throw new Error("Connect resolve undefined.");if(!o)throw new Error("Connect reject undefined.");e===i.Connected?n():o(t||new Error("Connect aborted."))}if(r===i.Disconnecting){if(!a)throw new Error("Disconnect resolve undefined.");if(!c)throw new Error("Disconnect reject undefined.");e===i.Disconnected?a():c(t||new Error("Disconnect aborted."))}this.transitioningState=!1}clearKeepAliveTimeout(){this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveDebounceTimeout=void 0}sendKeepAlive(){return this.keepAliveDebounceTimeout?Promise.resolve():(this.keepAliveDebounceTimeout=setTimeout(()=>{this.clearKeepAliveTimeout()},1e3*this.configuration.keepAliveDebounce),this.send("\r\n\r\n"))}startSendingKeepAlives(){this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},(e=>{const t=.8*e;return 1e3*(Math.random()*(e-t)+t)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}}c.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0}},function(e,t,s){"use strict";var i=this&&this.__awaiter||function(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.WebSipClientAgent=void 0;const r=s(53),n=s(62);t.WebSipClientAgent=class{constructor(e,t,s,i,r,n,o,a){this.server=e,this.meetingnumber=t,this.participantId=s,this.sipsbc="sip:"+i+"@"+this.getDomain(this.server),this.username=r,this.audiodom=n,this.delegate=a,this.reconnectTimes=o,this.override=0}createInstance(){let e=this;const t={aor:this.username,delegate:{onServerConnect:()=>{e.delegate&&e.delegate.onServerConnect&&e.delegate.onServerConnect()},onMessageReceived:t=>{e.delegate&&e.delegate.onMessageReceived&&e.delegate.onMessageReceived(t)},onCallAnswered:()=>{e.delegate&&e.delegate.onCallAnswered&&e.delegate.onCallAnswered()},onNotify:t=>{e.delegate&&e.delegate.onNotify&&e.delegate.onNotify(t)},onCallHangup:()=>{e.delegate&&e.delegate.onCallHangup&&e.delegate.onCallHangup()},onCallCreated:()=>{e.delegate&&e.delegate.onCallCreated&&e.delegate.onCallCreated()},onServerDisconnect:t=>{e.delegate&&e.delegate.onServerDisconnect&&e.delegate.onServerDisconnect(t)}},media:{constraints:{audio:!0,video:!1},remote:{audio:this.audiodom}},userAgentOptions:{transportConstructor:r.WebPhoneTransport,delegate:{onMessage:e=>{console.error(e)},onNotify:e=>{console.error(e)}},logBuiltinEnabled:!1,transportOptions:{server:this.server,keepAliveInterval:0}},reconnectionAttempts:this.reconnectTimes,onFailedReconnect:()=>{this.delegate&&this.delegate.onFailedReconnect&&this.delegate.onFailedReconnect()}};this.handle=new n.SimpleUser(this.server,t)}connect(){return i(this,void 0,void 0,(function*(){return this.instance.connect()}))}call(){return i(this,void 0,void 0,(function*(){return this.instance.call(this.sipsbc,{},{requestDelegate:{onReject:e=>{this.delegate&&this.delegate.onRejectInvite&&this.delegate.onRejectInvite(e)}}})}))}message(){return i(this,void 0,void 0,(function*(){return this.instance.message("sip:zoom.us@zoom.us","zoom.us@zoom.us")}))}hangup(){return i(this,void 0,void 0,(function*(){return this.instance.hangup()}))}disconnect(){return i(this,void 0,void 0,(function*(){return this.instance.disconnect()}))}mute(){if(this.instance){let e=this.instance.localMediaStream;e&&e.getAudioTracks().forEach((function(e){e.enabled=!1}))}}unmute(){if(this.instance){let e=this.instance.localMediaStream;e&&e.getAudioTracks().forEach((function(e){e.enabled=!0}))}}getDomain(e){var t=e.match(/wss:\/\/([^\/]+)/i);return null!=t&&t.length>0?t[0].substring(6):""}get instance(){return this.handle||this.createInstance(),this.handle}set instance(e){this.handle=e}failover(){this.override=1}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return i}));class i{constructor(e,t,s){e.debug("SessionDescriptionHandler.constructor"),this.logger=e,this.mediaStreamFactory=t,this.sessionDescriptionHandlerConfiguration=s,this._localMediaStream=new MediaStream,this._remoteMediaStream=new MediaStream,this._peerConnection=new RTCPeerConnection(null==s?void 0:s.peerConnectionConfiguration),this.initPeerConnectionEventHandlers()}get localMediaStream(){return this._localMediaStream}get remoteMediaStream(){return this._remoteMediaStream}get dataChannel(){return this._dataChannel}get peerConnection(){return this._peerConnection}get peerConnectionDelegate(){return this._peerConnectionDelegate}set peerConnectionDelegate(e){this._peerConnectionDelegate=e}static dispatchAddTrackEvent(e,t){e.dispatchEvent(new MediaStreamTrackEvent("addtrack",{track:t}))}static dispatchRemoveTrackEvent(e,t){e.dispatchEvent(new MediaStreamTrackEvent("removetrack",{track:t}))}close(){this.logger.debug("SessionDescriptionHandler.close"),void 0!==this._peerConnection&&(this._peerConnection.getReceivers().forEach(e=>{e.track&&e.track.stop()}),this._peerConnection.getSenders().forEach(e=>{e.track&&e.track.stop()}),this._dataChannel&&this._dataChannel.close(),this._peerConnection.close(),this._peerConnection=void 0)}getDescription(e,t){var s,i;if(this.logger.debug("SessionDescriptionHandler.getDescription"),void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));this.onDataChannel=null==e?void 0:e.onDataChannel;const r=null===(s=null==e?void 0:e.offerOptions)||void 0===s?void 0:s.iceRestart,n=void 0===(null==e?void 0:e.iceGatheringTimeout)?null===(i=this.sessionDescriptionHandlerConfiguration)||void 0===i?void 0:i.iceGatheringTimeout:null==e?void 0:e.iceGatheringTimeout;return this.getLocalMediaStream(e).then(()=>this.updateDirection(e)).then(()=>this.createDataChannel(e)).then(()=>this.createLocalOfferOrAnswer(e)).then(e=>this.applyModifiers(e,t)).then(e=>this.setLocalSessionDescription(e)).then(()=>this.waitForIceGatheringComplete(r,n)).then(()=>this.getLocalSessionDescription()).then(e=>({body:e.sdp,contentType:"application/sdp"})).catch(e=>{throw this.logger.error("SessionDescriptionHandler.getDescription failed - "+e),e})}hasDescription(e){return this.logger.debug("SessionDescriptionHandler.hasDescription"),"application/sdp"===e}sendDtmf(e,t){if(this.logger.debug("SessionDescriptionHandler.sendDtmf"),void 0===this._peerConnection)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - peer connection closed"),!1;const s=this._peerConnection.getSenders();if(0===s.length)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - no senders"),!1;const i=s[0].dtmf;if(!i)return this.logger.error("SessionDescriptionHandler.sendDtmf failed - no DTMF sender"),!1;const r=null==t?void 0:t.duration,n=null==t?void 0:t.interToneGap;try{i.insertDTMF(e,r,n)}catch(e){return this.logger.error(e),!1}return this.logger.log("SessionDescriptionHandler.sendDtmf sent via RTP: "+e.toString()),!0}setDescription(e,t,s){if(this.logger.debug("SessionDescriptionHandler.setDescription"),void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));this.onDataChannel=null==t?void 0:t.onDataChannel;const i="have-local-offer"===this._peerConnection.signalingState?"answer":"offer";return this.getLocalMediaStream(t).then(()=>this.applyModifiers({sdp:e,type:i},s)).then(e=>this.setRemoteSessionDescription(e)).catch(e=>{throw this.logger.error("SessionDescriptionHandler.setDescription failed - "+e),e})}applyModifiers(e,t){return this.logger.debug("SessionDescriptionHandler.applyModifiers"),t&&0!==t.length?t.reduce((e,t)=>e.then(t),Promise.resolve(e)).then(e=>{if(this.logger.debug("SessionDescriptionHandler.applyModifiers - modified sdp"),!e.sdp||!e.type)throw new Error("Invalid SDP.");return{sdp:e.sdp,type:e.type}}):Promise.resolve(e)}createDataChannel(e){if(void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));if(!0!==(null==e?void 0:e.dataChannel))return Promise.resolve();if(this._dataChannel)return Promise.resolve();switch(this._peerConnection.signalingState){case"stable":this.logger.debug("SessionDescriptionHandler.createDataChannel - creating data channel");try{return this._dataChannel=this._peerConnection.createDataChannel((null==e?void 0:e.dataChannelLabel)||"",null==e?void 0:e.dataChannelOptions),this.onDataChannel&&this.onDataChannel(this._dataChannel),Promise.resolve()}catch(e){return Promise.reject(e)}case"have-remote-offer":return Promise.resolve();case"have-local-offer":case"have-local-pranswer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}}createLocalOfferOrAnswer(e){if(void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));switch(this._peerConnection.signalingState){case"stable":return this.logger.debug("SessionDescriptionHandler.createLocalOfferOrAnswer - creating SDP offer"),this._peerConnection.createOffer(null==e?void 0:e.offerOptions);case"have-remote-offer":return this.logger.debug("SessionDescriptionHandler.createLocalOfferOrAnswer - creating SDP answer"),this._peerConnection.createAnswer(null==e?void 0:e.answerOptions);case"have-local-offer":case"have-local-pranswer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}}getLocalMediaStream(e){if(this.logger.debug("SessionDescriptionHandler.getLocalMediaStream"),void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));let t=Object.assign({},null==e?void 0:e.constraints);if(this.localMediaStreamConstraints){if(t.audio=t.audio||this.localMediaStreamConstraints.audio,t.video=t.video||this.localMediaStreamConstraints.video,JSON.stringify(this.localMediaStreamConstraints.audio)===JSON.stringify(t.audio)&&JSON.stringify(this.localMediaStreamConstraints.video)===JSON.stringify(t.video))return Promise.resolve()}else void 0===t.audio&&void 0===t.video&&(t={audio:!0});return this.localMediaStreamConstraints=t,this.mediaStreamFactory(t,this).then(e=>this.setLocalMediaStream(e))}setLocalMediaStream(e){if(this.logger.debug("SessionDescriptionHandler.setLocalMediaStream"),!this._peerConnection)throw new Error("Peer connection undefined.");const t=this._peerConnection,s=this._localMediaStream,r=[],n=e=>{const n=e.kind;if("audio"!==n&&"video"!==n)throw new Error(`Unknown new track kind ${n}.`);const o=t.getSenders().find(e=>e.track&&e.track.kind===n);o?r.push(new Promise(e=>{this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${n} track`),e()}).then(()=>o.replaceTrack(e).then(()=>{const t=s.getTracks().find(e=>e.kind===n);t&&(t.stop(),s.removeTrack(t),i.dispatchRemoveTrackEvent(s,t)),s.addTrack(e),i.dispatchAddTrackEvent(s,e)}).catch(e=>{throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to replace sender ${n} track`),e}))):r.push(new Promise(e=>{this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - adding sender ${n} track`),e()}).then(()=>{try{t.addTrack(e,s)}catch(e){throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${n} track`),e}s.addTrack(e),i.dispatchAddTrackEvent(s,e)}))},o=e.getAudioTracks();o.length&&n(o[0]);const a=e.getVideoTracks();return a.length&&n(a[0]),r.reduce((e,t)=>e.then(()=>t),Promise.resolve())}getLocalSessionDescription(){if(this.logger.debug("SessionDescriptionHandler.getLocalSessionDescription"),void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));const e=this._peerConnection.localDescription;return e?Promise.resolve(e):Promise.reject(new Error("Failed to get local session description"))}setLocalSessionDescription(e){return this.logger.debug("SessionDescriptionHandler.setLocalSessionDescription"),void 0===this._peerConnection?Promise.reject(new Error("Peer connection closed.")):this._peerConnection.setLocalDescription(e)}setRemoteSessionDescription(e){if(this.logger.debug("SessionDescriptionHandler.setRemoteSessionDescription"),void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));const t=e.sdp;let s;switch(this._peerConnection.signalingState){case"stable":s="offer";break;case"have-local-offer":s="answer";break;case"have-local-pranswer":case"have-remote-offer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}return t?this._peerConnection.setRemoteDescription({sdp:t,type:s}):(this.logger.error("SessionDescriptionHandler.setRemoteSessionDescription failed - cannot set null sdp"),Promise.reject(new Error("SDP is undefined")))}setRemoteTrack(e){this.logger.debug("SessionDescriptionHandler.setRemoteTrack");const t=this._remoteMediaStream;t.getTrackById(e.id)?this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - have remote ${e.kind} track`):"audio"===e.kind?(this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind} track`),t.getAudioTracks().forEach(e=>{e.stop(),t.removeTrack(e),i.dispatchRemoveTrackEvent(t,e)}),t.addTrack(e),i.dispatchAddTrackEvent(t,e)):"video"===e.kind&&(this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind} track`),t.getVideoTracks().forEach(e=>{e.stop(),t.removeTrack(e),i.dispatchRemoveTrackEvent(t,e)}),t.addTrack(e),i.dispatchAddTrackEvent(t,e))}updateDirection(e){if(void 0===this._peerConnection)return Promise.reject(new Error("Peer connection closed."));switch(this._peerConnection.signalingState){case"stable":this.logger.debug("SessionDescriptionHandler.updateDirection - setting offer direction");{const t=t=>{switch(t){case"inactive":case"recvonly":return(null==e?void 0:e.hold)?"inactive":"recvonly";case"sendonly":case"sendrecv":return(null==e?void 0:e.hold)?"sendonly":"sendrecv";case"stopped":return"stopped";default:throw new Error("Should never happen")}};this._peerConnection.getTransceivers().forEach(e=>{if(e.direction){const s=t(e.direction);e.direction!==s&&(e.direction=s)}})}break;case"have-remote-offer":this.logger.debug("SessionDescriptionHandler.updateDirection - setting answer direction");{const t=(()=>{const e=this._peerConnection.remoteDescription;if(!e)throw new Error("Failed to read remote offer");const t=/a=sendrecv\r\n|a=sendonly\r\n|a=recvonly\r\n|a=inactive\r\n/.exec(e.sdp);if(t)switch(t[0]){case"a=inactive\r\n":return"inactive";case"a=recvonly\r\n":return"recvonly";case"a=sendonly\r\n":return"sendonly";case"a=sendrecv\r\n":return"sendrecv";default:throw new Error("Should never happen")}return"sendrecv"})(),s=(()=>{switch(t){case"inactive":return"inactive";case"recvonly":return"sendonly";case"sendonly":return(null==e?void 0:e.hold)?"inactive":"recvonly";case"sendrecv":return(null==e?void 0:e.hold)?"sendonly":"sendrecv";default:throw new Error("Should never happen")}})();this._peerConnection.getTransceivers().forEach(e=>{e.direction&&"stopped"!==e.direction&&e.direction!==s&&(e.direction=s)})}break;case"have-local-offer":case"have-local-pranswer":case"have-remote-pranswer":case"closed":default:return Promise.reject(new Error("Invalid signaling state "+this._peerConnection.signalingState))}return Promise.resolve()}iceGatheringComplete(){this.logger.debug("SessionDescriptionHandler.iceGatheringComplete"),void 0!==this.iceGatheringCompleteTimeoutId&&(this.logger.debug("SessionDescriptionHandler.iceGatheringComplete - clearing timeout"),clearTimeout(this.iceGatheringCompleteTimeoutId),this.iceGatheringCompleteTimeoutId=void 0),void 0!==this.iceGatheringCompletePromise&&(this.logger.debug("SessionDescriptionHandler.iceGatheringComplete - resolving promise"),this.iceGatheringCompleteResolve&&this.iceGatheringCompleteResolve(),this.iceGatheringCompletePromise=void 0,this.iceGatheringCompleteResolve=void 0,this.iceGatheringCompleteReject=void 0)}waitForIceGatheringComplete(e=!1,t=0){return this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete"),void 0===this._peerConnection?Promise.reject("Peer connection closed."):e||"complete"!==this._peerConnection.iceGatheringState?(void 0!==this.iceGatheringCompletePromise&&(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - rejecting prior waiting promise"),this.iceGatheringCompleteReject&&this.iceGatheringCompleteReject(new Error("Promise superseded.")),this.iceGatheringCompletePromise=void 0,this.iceGatheringCompleteResolve=void 0,this.iceGatheringCompleteReject=void 0),this.iceGatheringCompletePromise=new Promise((e,s)=>{this.iceGatheringCompleteResolve=e,this.iceGatheringCompleteReject=s,t>0&&(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - timeout in "+t),this.iceGatheringCompleteTimeoutId=setTimeout(()=>{this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - timeout"),this.iceGatheringComplete()},t))}),this.iceGatheringCompletePromise):(this.logger.debug("SessionDescriptionHandler.waitForIceGatheringToComplete - already complete"),Promise.resolve())}initPeerConnectionEventHandlers(){if(this.logger.debug("SessionDescriptionHandler.initPeerConnectionEventHandlers"),!this._peerConnection)throw new Error("Peer connection undefined.");const e=this._peerConnection;e.onconnectionstatechange=t=>{var s;const i=e.connectionState;this.logger.debug("SessionDescriptionHandler.onconnectionstatechange "+i),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.onconnectionstatechange)&&this._peerConnectionDelegate.onconnectionstatechange(t)},e.ondatachannel=e=>{var t;this.logger.debug("SessionDescriptionHandler.ondatachannel"),this._dataChannel=e.channel,this.onDataChannel&&this.onDataChannel(this._dataChannel),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.ondatachannel)&&this._peerConnectionDelegate.ondatachannel(e)},e.onicecandidate=e=>{var t;this.logger.debug("SessionDescriptionHandler.onicecandidate"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onicecandidate)&&this._peerConnectionDelegate.onicecandidate(e)},e.onicecandidateerror=e=>{var t;this.logger.debug("SessionDescriptionHandler.onicecandidateerror"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onicecandidateerror)&&this._peerConnectionDelegate.onicecandidateerror(e)},e.oniceconnectionstatechange=t=>{var s;const i=e.iceConnectionState;this.logger.debug("SessionDescriptionHandler.oniceconnectionstatechange "+i),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.oniceconnectionstatechange)&&this._peerConnectionDelegate.oniceconnectionstatechange(t)},e.onicegatheringstatechange=t=>{var s;const i=e.iceGatheringState;this.logger.debug("SessionDescriptionHandler.onicegatheringstatechange "+i),"complete"===i&&this.iceGatheringComplete(),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.onicegatheringstatechange)&&this._peerConnectionDelegate.onicegatheringstatechange(t)},e.onnegotiationneeded=e=>{var t;this.logger.debug("SessionDescriptionHandler.onnegotiationneeded"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onnegotiationneeded)&&this._peerConnectionDelegate.onnegotiationneeded(e)},e.onsignalingstatechange=t=>{var s;const i=e.signalingState;this.logger.debug("SessionDescriptionHandler.onsignalingstatechange "+i),(null===(s=this._peerConnectionDelegate)||void 0===s?void 0:s.onsignalingstatechange)&&this._peerConnectionDelegate.onsignalingstatechange(t)},e.onstatsended=e=>{var t;this.logger.debug("SessionDescriptionHandler.onstatsended"),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.onstatsended)&&this._peerConnectionDelegate.onstatsended(e)},e.ontrack=e=>{var t;const s=e.track.kind,i=e.track.enabled?"enabled":"disabled";this.logger.debug(`SessionDescriptionHandler.ontrack ${s} ${i}`),this.setRemoteTrack(e.track),(null===(t=this._peerConnectionDelegate)||void 0===t?void 0:t.ontrack)&&this._peerConnectionDelegate.ontrack(e)}}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return d}));var i=s(23),r=s(10),n=s(14),o=s(1),a=s(22),c=s(0),h=s(13);class d extends a.a{constructor(e,t,s={}){super(e,s),this.disposed=!1,this.earlyMedia=!1,this.earlyMediaSessionDescriptionHandlers=new Map,this.isCanceled=!1,this.inviteWithoutSdp=!1,this.logger=e.getLogger("sip.Inviter"),this.earlyMedia=void 0!==s.earlyMedia?s.earlyMedia:this.earlyMedia,this.fromTag=Object(o.d)(),this.inviteWithoutSdp=void 0!==s.inviteWithoutSdp?s.inviteWithoutSdp:this.inviteWithoutSdp;const n=Object.assign({},s);n.params=Object.assign({},s.params);const a=s.anonymous||!1,c=e.contact.toString({anonymous:a,outbound:a?!e.contact.tempGruu:!e.contact.pubGruu});a&&e.configuration.uri&&(n.params.fromDisplayName="Anonymous",n.params.fromUri="sip:anonymous@anonymous.invalid");let d=e.userAgentCore.configuration.aor;if(n.params.fromUri&&(d="string"==typeof n.params.fromUri?i.a.URIParse(n.params.fromUri):n.params.fromUri),!d)throw new TypeError("Invalid from URI: "+n.params.fromUri);let l=t;if(n.params.toUri&&(l="string"==typeof n.params.toUri?i.a.URIParse(n.params.toUri):n.params.toUri),!l)throw new TypeError("Invalid to URI: "+n.params.toUri);const u=Object.assign({},n.params);u.fromTag=this.fromTag;const g=(n.extraHeaders||[]).slice();a&&e.configuration.uri&&(g.push("P-Preferred-Identity: "+e.configuration.uri.toString()),g.push("Privacy: id")),g.push("Contact: "+c),g.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),e.configuration.sipExtension100rel===h.a.Required&&g.push("Require: 100rel"),e.configuration.sipExtensionReplaces===h.a.Required&&g.push("Require: replaces"),n.extraHeaders=g;this.outgoingRequestMessage=e.userAgentCore.makeOutgoingRequestMessage(r.a.INVITE,t,d,l,u,g,void 0),this._contact=c,this._referralInviterOptions=n,this._renderbody=s.renderbody,this._rendertype=s.rendertype,s.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=s.sessionDescriptionHandlerModifiers),s.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=s.sessionDescriptionHandlerOptions),s.sessionDescriptionHandlerModifiersReInvite&&(this.sessionDescriptionHandlerModifiersReInvite=s.sessionDescriptionHandlerModifiersReInvite),s.sessionDescriptionHandlerOptionsReInvite&&(this.sessionDescriptionHandlerOptionsReInvite=s.sessionDescriptionHandlerOptionsReInvite),this._id=this.outgoingRequestMessage.callId+this.fromTag,this.userAgent._sessions[this._id]=this}dispose(){if(this.disposed)return Promise.resolve();switch(this.disposed=!0,this.disposeEarlyMedia(),this.state){case c.a.Initial:case c.a.Establishing:return this.cancel().then(()=>super.dispose());case c.a.Established:case c.a.Terminating:case c.a.Terminated:return super.dispose();default:throw new Error("Unknown state.")}}get body(){return this.outgoingRequestMessage.body}get localIdentity(){return this.outgoingRequestMessage.from}get remoteIdentity(){return this.outgoingRequestMessage.to}get request(){return this.outgoingRequestMessage}cancel(e={}){if(this.logger.log("Inviter.cancel"),this.state!==c.a.Initial&&this.state!==c.a.Establishing){const e=new Error("Invalid session state "+this.state);return this.logger.error(e.message),Promise.reject(e)}if(this.isCanceled=!0,this.stateTransition(c.a.Terminating),this.outgoingInviteRequest){let t;e.statusCode&&e.reasonPhrase&&(t=function(e,t){if(e&&e<200||e>699)throw new TypeError("Invalid statusCode: "+e);if(e){return"SIP;cause="+e+';text="'+(Object(o.b)(e)||t)+'"'}}(e.statusCode,e.reasonPhrase)),this.outgoingInviteRequest.cancel(t,e)}else this.logger.warn("Canceled session before INVITE was sent"),this.stateTransition(c.a.Terminated);return Promise.resolve()}invite(e={}){if(this.logger.log("Inviter.invite"),this.state!==c.a.Initial)return super.invite(e);if(e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),e.withoutSdp||this.inviteWithoutSdp)return this._renderbody&&this._rendertype&&(this.outgoingRequestMessage.body={contentType:this._rendertype,body:this._renderbody}),this.stateTransition(c.a.Establishing),Promise.resolve(this.sendInvite(e));const t={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.getOffer(t).then(t=>(this.outgoingRequestMessage.body={body:t.content,contentType:t.contentType},this.stateTransition(c.a.Establishing),this.sendInvite(e))).catch(e=>{throw this.logger.log(e.message),this.stateTransition(c.a.Terminated),e})}sendInvite(e={}){return this.outgoingInviteRequest=this.userAgent.userAgentCore.invite(this.outgoingRequestMessage,{onAccept:t=>this.dialog?(this.logger.log("Additional confirmed dialog, sending ACK and BYE"),void this.ackAndBye(t)):this.isCanceled?(this.logger.log("Canceled session accepted, sending ACK and BYE"),this.ackAndBye(t),void this.stateTransition(c.a.Terminated)):(this.notifyReferer(t),void this.onAccept(t).then(()=>{this.disposeEarlyMedia()}).catch(()=>{this.disposeEarlyMedia()}).then(()=>{e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t)})),onProgress:t=>{this.isCanceled||(this.notifyReferer(t),this.onProgress(t).catch(()=>{this.disposeEarlyMedia()}).then(()=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(t)}))},onRedirect:t=>{this.notifyReferer(t),this.onRedirect(t),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(t)},onReject:t=>{this.notifyReferer(t),this.onReject(t),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t)},onTrying:t=>{this.notifyReferer(t),this.onTrying(t),e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(t)}}),this.outgoingInviteRequest}disposeEarlyMedia(){this.earlyMediaSessionDescriptionHandlers.forEach(e=>{e.close()}),this.earlyMediaSessionDescriptionHandlers.clear()}notifyReferer(e){if(!this._referred)return;if(!(this._referred instanceof a.a))throw new Error("Referred session not instance of session");if(!this._referred.dialog)return;if(!e.message.statusCode)throw new Error("Status code undefined.");if(!e.message.reasonPhrase)throw new Error("Reason phrase undefined.");const t=`SIP/2.0 ${e.message.statusCode} ${e.message.reasonPhrase}`.trim();this._referred.dialog.notify(void 0,{extraHeaders:["Event: refer","Subscription-State: terminated"],body:{contentDisposition:"render",contentType:"message/sipfrag",content:t}}).delegate={onReject:()=>{this._referred=void 0}}}onAccept(e){if(this.logger.log("Inviter.onAccept"),this.state!==c.a.Establishing)return this.logger.error(`Accept received while in state ${this.state}, dropping response`),Promise.reject(new Error("Invalid session state "+this.state));const t=e.message,s=e.session;switch(t.hasHeader("P-Asserted-Identity")&&(this._assertedIdentity=i.a.nameAddrHeaderParse(t.getHeader("P-Asserted-Identity"))),s.delegate={onAck:e=>this.onAckRequest(e),onBye:e=>this.onByeRequest(e),onInfo:e=>this.onInfoRequest(e),onInvite:e=>this.onInviteRequest(e),onMessage:e=>this.onMessageRequest(e),onNotify:e=>this.onNotifyRequest(e),onPrack:e=>this.onPrackRequest(e),onRefer:e=>this.onReferRequest(e)},this._dialog=s,s.signalingState){case n.b.Initial:case n.b.HaveLocalOffer:return this.logger.error("Received 2xx response to INVITE without a session description"),this.ackAndBye(e,400,"Missing session description"),this.stateTransition(c.a.Terminated),Promise.reject(new Error("Bad Media Description"));case n.b.HaveRemoteOffer:{if(!this._dialog.offer)throw new Error(`Session offer undefined in signaling state ${this._dialog.signalingState}.`);const t={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setOfferAndGetAnswer(this._dialog.offer,t).then(t=>{e.ack({body:t}),this.stateTransition(c.a.Established)}).catch(t=>{throw this.ackAndBye(e,488,"Invalid session description"),this.stateTransition(c.a.Terminated),t})}case n.b.Stable:{if(this.earlyMediaSessionDescriptionHandlers.size>0){const t=this.earlyMediaSessionDescriptionHandlers.get(s.id);if(!t)throw new Error("Session description handler undefined.");return this.setSessionDescriptionHandler(t),this.earlyMediaSessionDescriptionHandlers.delete(s.id),e.ack(),this.stateTransition(c.a.Established),Promise.resolve()}if(this.earlyMediaDialog){if(this.earlyMediaDialog!==s){if(this.earlyMedia){const e="You have set the 'earlyMedia' option to 'true' which requires that your INVITE requests do not fork and yet this INVITE request did in fact fork. Consequentially and not surprisingly the end point which accepted the INVITE (confirmed dialog) does not match the end point with which early media has been setup (early dialog) and thus this session is unable to proceed. In accordance with the SIP specifications, the SIP servers your end point is connected to determine if an INVITE forks and the forking behavior of those servers cannot be controlled by this library. If you wish to use early media with this library you must configure those servers accordingly. Alternatively you may set the 'earlyMedia' to 'false' which will allow this library to function with any INVITE requests which do fork.";this.logger.error(e)}const t=new Error("Early media dialog does not equal confirmed dialog, terminating session");return this.logger.error(t.message),this.ackAndBye(e,488,"Not Acceptable Here"),this.stateTransition(c.a.Terminated),Promise.reject(t)}return e.ack(),this.stateTransition(c.a.Established),Promise.resolve()}const t=s.answer;if(!t)throw new Error("Answer is undefined.");const i={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setAnswer(t,i).then(()=>{let t;this._renderbody&&this._rendertype&&(t={body:{contentDisposition:"render",contentType:this._rendertype,content:this._renderbody}}),e.ack(t),this.stateTransition(c.a.Established)}).catch(t=>{throw this.logger.error(t.message),this.ackAndBye(e,488,"Not Acceptable Here"),this.stateTransition(c.a.Terminated),t})}case n.b.Closed:return Promise.reject(new Error("Terminated."));default:throw new Error("Unknown session signaling state.")}}onProgress(e){var t;if(this.logger.log("Inviter.onProgress"),this.state!==c.a.Establishing)return this.logger.error(`Progress received while in state ${this.state}, dropping response`),Promise.reject(new Error("Invalid session state "+this.state));if(!this.outgoingInviteRequest)throw new Error("Outgoing INVITE request undefined.");const s=e.message,r=e.session;s.hasHeader("P-Asserted-Identity")&&(this._assertedIdentity=i.a.nameAddrHeaderParse(s.getHeader("P-Asserted-Identity")));const o=s.getHeader("require"),a=s.getHeader("rseq"),h=!!(o&&o.includes("100rel")&&a?Number(a):void 0),d=[];switch(h&&d.push("RAck: "+s.getHeader("rseq")+" "+s.getHeader("cseq")),r.signalingState){case n.b.Initial:return h&&(this.logger.warn("First reliable provisional response received MUST contain an offer when INVITE does not contain an offer."),e.prack({extraHeaders:d})),Promise.resolve();case n.b.HaveLocalOffer:return h&&e.prack({extraHeaders:d}),Promise.resolve();case n.b.HaveRemoteOffer:if(!h)return this.logger.warn("Non-reliable provisional response MUST NOT contain an initial offer, discarding response."),Promise.resolve();{const i=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions||{});return(null===(t=this.delegate)||void 0===t?void 0:t.onSessionDescriptionHandler)&&this.delegate.onSessionDescriptionHandler(i,!0),this.earlyMediaSessionDescriptionHandlers.set(r.id,i),i.setDescription(s.body,this.sessionDescriptionHandlerOptions,this.sessionDescriptionHandlerModifiers).then(()=>i.getDescription(this.sessionDescriptionHandlerOptions,this.sessionDescriptionHandlerModifiers)).then(t=>{const s={contentDisposition:"session",contentType:t.contentType,content:t.body};e.prack({extraHeaders:d,body:s})}).catch(e=>{throw this.stateTransition(c.a.Terminated),e})}case n.b.Stable:if(h&&e.prack({extraHeaders:d}),this.earlyMedia&&!this.earlyMediaDialog){this.earlyMediaDialog=r;const e=r.answer;if(!e)throw new Error("Answer is undefined.");const t={sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers,sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions};return this.setAnswer(e,t).catch(e=>{throw this.stateTransition(c.a.Terminated),e})}return Promise.resolve();case n.b.Closed:return Promise.reject(new Error("Terminated."));default:throw new Error("Unknown session signaling state.")}}onRedirect(e){this.logger.log("Inviter.onRedirect"),this.state===c.a.Establishing||this.state===c.a.Terminating?this.stateTransition(c.a.Terminated):this.logger.error(`Redirect received while in state ${this.state}, dropping response`)}onReject(e){this.logger.log("Inviter.onReject"),this.state===c.a.Establishing||this.state===c.a.Terminating?this.stateTransition(c.a.Terminated):this.logger.error(`Reject received while in state ${this.state}, dropping response`)}onTrying(e){this.logger.log("Inviter.onTrying"),this.state===c.a.Establishing||this.logger.error(`Trying received while in state ${this.state}, dropping response`)}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return n}));var i=s(17),r=s(1);class n{constructor(e,t,s,i,o,a,c){this.headers={},this.extraHeaders=[],this.options=n.getDefaultOptions(),o&&(this.options=Object.assign(Object.assign({},this.options),o),this.options.optionTags&&this.options.optionTags.length&&(this.options.optionTags=this.options.optionTags.slice()),this.options.routeSet&&this.options.routeSet.length&&(this.options.routeSet=this.options.routeSet.slice())),a&&a.length&&(this.extraHeaders=a.slice()),c&&(this.body={body:c.content,contentType:c.contentType}),this.method=e,this.ruri=t.clone(),this.fromURI=s.clone(),this.fromTag=this.options.fromTag?this.options.fromTag:Object(r.d)(),this.from=n.makeNameAddrHeader(this.fromURI,this.options.fromDisplayName,this.fromTag),this.toURI=i.clone(),this.toTag=this.options.toTag,this.to=n.makeNameAddrHeader(this.toURI,this.options.toDisplayName,this.toTag),this.callId=this.options.callId?this.options.callId:this.options.callIdPrefix+Object(r.a)(15),this.cseq=this.options.cseq,this.setHeader("route",this.options.routeSet),this.setHeader("via",""),this.setHeader("to",this.to.toString()),this.setHeader("from",this.from.toString()),this.setHeader("cseq",this.cseq+" "+this.method),this.setHeader("call-id",this.callId),this.setHeader("max-forwards","70")}static getDefaultOptions(){return{callId:"",callIdPrefix:"",cseq:1,toDisplayName:"",toTag:"",fromDisplayName:"",fromTag:"",forceRport:!1,hackViaTcp:!1,optionTags:["outbound"],routeSet:[],userAgentString:"sip.js",viaHost:""}}static makeNameAddrHeader(e,t,s){const r={};return s&&(r.tag=s),new i.a(e,t,r)}getHeader(e){const t=this.headers[Object(r.c)(e)];if(t){if(t[0])return t[0]}else{const t=new RegExp("^\\s*"+e+"\\s*:","i");for(const e of this.extraHeaders)if(t.test(e))return e.substring(e.indexOf(":")+1).trim()}}getHeaders(e){const t=[],s=this.headers[Object(r.c)(e)];if(s)for(const e of s)t.push(e);else{const s=new RegExp("^\\s*"+e+"\\s*:","i");for(const e of this.extraHeaders)s.test(e)&&t.push(e.substring(e.indexOf(":")+1).trim())}return t}hasHeader(e){if(this.headers[Object(r.c)(e)])return!0;{const t=new RegExp("^\\s*"+e+"\\s*:","i");for(const e of this.extraHeaders)if(t.test(e))return!0}return!1}setHeader(e,t){this.headers[Object(r.c)(e)]=t instanceof Array?t:[t]}setViaHeader(e,t){this.options.hackViaTcp&&(t="TCP");let s="SIP/2.0/"+t;s+=" "+this.options.viaHost+";branch="+e,this.options.forceRport&&(s+=";rport"),this.setHeader("via",s),this.branch=e}toString(){let e="";e+=this.method+" "+this.ruri.toRaw()+" SIP/2.0\r\n";for(const t in this.headers)if(this.headers[t])for(const s of this.headers[t])e+=t+": "+s+"\r\n";for(const t of this.extraHeaders)e+=t.trim()+"\r\n";return e+="Supported: "+this.options.optionTags.join(", ")+"\r\n",e+="User-Agent: "+this.options.userAgentString+"\r\n",this.body?"string"==typeof this.body?(e+="Content-Length: "+Object(r.e)(this.body)+"\r\n\r\n",e+=this.body):this.body.body&&this.body.contentType?(e+="Content-Type: "+this.body.contentType+"\r\n",e+="Content-Length: "+Object(r.e)(this.body.body)+"\r\n\r\n",e+=this.body.body):e+="Content-Length: 0\r\n\r\n":e+="Content-Length: 0\r\n\r\n",e}}},function(e,t,s){var i=s(15).default,r=s(56);e.exports=function(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";var i=s(23),r=s(66),n=s(14),o=s(68),a=s(4),c=s(1),h=s(67),d=s(19);class l extends d.a{constructor(e){super(e||"Unspecified session description handler error.")}}class u extends d.a{constructor(){super("The session has terminated.")}}var g=s(22),p=s(0),f=s(13);s.d(t,"a",(function(){return m}));class m extends g.a{constructor(e,t){super(e),this.incomingInviteRequest=t,this.disposed=!1,this.expiresTimer=void 0,this.isCanceled=!1,this.rel100="none",this.rseq=Math.floor(1e4*Math.random()),this.userNoAnswerTimer=void 0,this.waitingForPrack=!1,this.logger=e.getLogger("sip.Invitation");const s=this.incomingInviteRequest.message,r=s.getHeader("require");r&&r.toLowerCase().includes("100rel")&&(this.rel100="required");const n=s.getHeader("supported");if(n&&n.toLowerCase().includes("100rel")&&(this.rel100="supported"),s.toTag=t.toTag,"string"!=typeof s.toTag)throw new TypeError("toTag should have been a string.");if(this.userNoAnswerTimer=setTimeout(()=>{t.reject({statusCode:480}),this.stateTransition(p.a.Terminated)},this.userAgent.configuration.noAnswerTimeout?1e3*this.userAgent.configuration.noAnswerTimeout:6e4),s.hasHeader("expires")){const e=1e3*Number(s.getHeader("expires")||0);this.expiresTimer=setTimeout(()=>{this.state===p.a.Initial&&(t.reject({statusCode:487}),this.stateTransition(p.a.Terminated))},e)}const o=this.request.getHeader("P-Asserted-Identity");o&&(this._assertedIdentity=i.a.nameAddrHeaderParse(o)),this._contact=this.userAgent.contact.toString();const a=s.parseHeader("Content-Disposition");a&&"render"===a.type&&(this._renderbody=s.body,this._rendertype=s.getHeader("Content-Type")),this._id=s.callId+s.fromTag,this.userAgent._sessions[this._id]=this}dispose(){if(this.disposed)return Promise.resolve();switch(this.disposed=!0,this.expiresTimer&&(clearTimeout(this.expiresTimer),this.expiresTimer=void 0),this.userNoAnswerTimer&&(clearTimeout(this.userNoAnswerTimer),this.userNoAnswerTimer=void 0),this.prackNeverArrived(),this.state){case p.a.Initial:case p.a.Establishing:return this.reject().then(()=>super.dispose());case p.a.Established:case p.a.Terminating:case p.a.Terminated:return super.dispose();default:throw new Error("Unknown state.")}}get autoSendAnInitialProvisionalResponse(){return"required"!==this.rel100&&this.userAgent.configuration.sendInitialProvisionalResponse}get body(){return this.incomingInviteRequest.message.body}get localIdentity(){return this.request.to}get remoteIdentity(){return this.request.from}get request(){return this.incomingInviteRequest.message}accept(e={}){if(this.logger.log("Invitation.accept"),this.state!==p.a.Initial){const e=new Error("Invalid session state "+this.state);return this.logger.error(e.message),Promise.reject(e)}return e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),this.stateTransition(p.a.Establishing),this.sendAccept(e).then(({message:e,session:t})=>{t.delegate={onAck:e=>this.onAckRequest(e),onAckTimeout:()=>this.onAckTimeout(),onBye:e=>this.onByeRequest(e),onInfo:e=>this.onInfoRequest(e),onInvite:e=>this.onInviteRequest(e),onMessage:e=>this.onMessageRequest(e),onNotify:e=>this.onNotifyRequest(e),onPrack:e=>this.onPrackRequest(e),onRefer:e=>this.onReferRequest(e)},this._dialog=t,this.stateTransition(p.a.Established),this._replacee&&this._replacee._bye()}).catch(e=>this.handleResponseError(e))}progress(e={}){if(this.logger.log("Invitation.progress"),this.state!==p.a.Initial){const e=new Error("Invalid session state "+this.state);return this.logger.error(e.message),Promise.reject(e)}const t=e.statusCode||180;if(t<100||t>199)throw new TypeError("Invalid statusCode: "+t);return e.sessionDescriptionHandlerModifiers&&(this.sessionDescriptionHandlerModifiers=e.sessionDescriptionHandlerModifiers),e.sessionDescriptionHandlerOptions&&(this.sessionDescriptionHandlerOptions=e.sessionDescriptionHandlerOptions),this.waitingForPrack?(this.logger.warn("Unexpected call for progress while waiting for prack, ignoring"),Promise.resolve()):100===e.statusCode?this.sendProgressTrying().then(()=>{}).catch(e=>this.handleResponseError(e)):"required"===this.rel100||"supported"===this.rel100&&e.rel100||"supported"===this.rel100&&this.userAgent.configuration.sipExtension100rel===f.a.Required?this.sendProgressReliableWaitForPrack(e).then(()=>{}).catch(e=>this.handleResponseError(e)):this.sendProgress(e).then(()=>{}).catch(e=>this.handleResponseError(e))}reject(e={}){if(this.logger.log("Invitation.reject"),this.state!==p.a.Initial&&this.state!==p.a.Establishing){const e=new Error("Invalid session state "+this.state);return this.logger.error(e.message),Promise.reject(e)}const t=e.statusCode||480,s=e.reasonPhrase?e.reasonPhrase:Object(c.b)(t),i=e.extraHeaders||[];if(t<300||t>699)throw new TypeError("Invalid statusCode: "+t);const n=e.body?Object(r.a)(e.body):void 0;return t<400?this.incomingInviteRequest.redirect([],{statusCode:t,reasonPhrase:s,extraHeaders:i,body:n}):this.incomingInviteRequest.reject({statusCode:t,reasonPhrase:s,extraHeaders:i,body:n}),this.stateTransition(p.a.Terminated),Promise.resolve()}_onCancel(e){this.logger.log("Invitation._onCancel"),this.state===p.a.Initial||this.state===p.a.Establishing?(this.isCanceled=!0,this.incomingInviteRequest.reject({statusCode:487}),this.stateTransition(p.a.Terminated)):this.logger.error(`CANCEL received while in state ${this.state}, dropping request`)}handlePrackOfferAnswer(e){if(!this.dialog)throw new Error("Dialog undefined.");const t=Object(r.b)(e.message);if(!t||"session"!==t.contentDisposition)return Promise.resolve(void 0);const s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};switch(this.dialog.signalingState){case n.b.Initial:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);case n.b.Stable:return this.setAnswer(t,s).then(()=>{});case n.b.HaveLocalOffer:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);case n.b.HaveRemoteOffer:return this.setOfferAndGetAnswer(t,s);case n.b.Closed:default:throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`)}}handleResponseError(e){let t=480;if(e instanceof Error?this.logger.error(e.message):this.logger.error(e),e instanceof h.a?(this.logger.error("A session description handler occurred while sending response (content type unsupported"),t=415):e instanceof l?this.logger.error("A session description handler occurred while sending response"):e instanceof u?this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)"):e instanceof o.a&&this.logger.error("Session changed state before response could be formulated and sent"),this.state===p.a.Initial||this.state===p.a.Establishing)try{this.incomingInviteRequest.reject({statusCode:t}),this.stateTransition(p.a.Terminated)}catch(e){throw this.logger.error("An error occurred attempting to reject the request while handling another error"),e}if(!this.isCanceled)throw e;this.logger.warn("An error occurred while attempting to formulate and send a response to an incoming INVITE. However a CANCEL was received and processed while doing so which can (and often does) result in errors occurring as the session terminates in the meantime. Said error is being ignored.")}onAckTimeout(){if(this.logger.log("Invitation.onAckTimeout"),!this.dialog)throw new Error("Dialog undefined.");this.logger.log("No ACK received for an extended period of time, terminating session"),this.dialog.bye(),this.stateTransition(p.a.Terminated)}sendAccept(e={}){const t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.extraHeaders||[];return this.waitingForPrack?this.waitForArrivalOfPrack().then(()=>clearTimeout(this.userNoAnswerTimer)).then(()=>this.generateResponseOfferAnswer(this.incomingInviteRequest,t)).then(e=>this.incomingInviteRequest.accept({statusCode:200,body:e,extraHeaders:s})):(clearTimeout(this.userNoAnswerTimer),this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(e=>this.incomingInviteRequest.accept({statusCode:200,body:e,extraHeaders:s})))}sendProgress(e={}){const t=e.statusCode||180,s=e.reasonPhrase,i=(e.extraHeaders||[]).slice(),n=e.body?Object(r.a)(e.body):void 0;if(183===t&&!n)return this.sendProgressWithSDP(e);try{const e=this.incomingInviteRequest.progress({statusCode:t,reasonPhrase:s,extraHeaders:i,body:n});return this._dialog=e.session,Promise.resolve(e)}catch(e){return Promise.reject(e)}}sendProgressWithSDP(e={}){const t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.statusCode||183,i=e.reasonPhrase,r=(e.extraHeaders||[]).slice();return this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(e=>this.incomingInviteRequest.progress({statusCode:s,reasonPhrase:i,extraHeaders:r,body:e})).then(e=>(this._dialog=e.session,e))}sendProgressReliable(e={}){return e.extraHeaders=(e.extraHeaders||[]).slice(),e.extraHeaders.push("Require: 100rel"),e.extraHeaders.push("RSeq: "+Math.floor(1e4*Math.random())),this.sendProgressWithSDP(e)}sendProgressReliableWaitForPrack(e={}){const t={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers},s=e.statusCode||183,i=e.reasonPhrase,r=(e.extraHeaders||[]).slice();let n;return r.push("Require: 100rel"),r.push("RSeq: "+this.rseq++),new Promise((e,o)=>{this.waitingForPrack=!0,this.generateResponseOfferAnswer(this.incomingInviteRequest,t).then(e=>(n=e,this.incomingInviteRequest.progress({statusCode:s,reasonPhrase:i,extraHeaders:r,body:n}))).then(t=>{let c,h;this._dialog=t.session,t.session.delegate={onPrack:s=>{c=s,clearTimeout(d),clearTimeout(p),this.waitingForPrack&&(this.waitingForPrack=!1,this.handlePrackOfferAnswer(c).then(s=>{try{h=c.accept({statusCode:200,body:s}),this.prackArrived(),e({prackRequest:c,prackResponse:h,progressResponse:t})}catch(e){o(e)}}).catch(e=>o(e)))}};const d=setTimeout(()=>{this.waitingForPrack&&(this.waitingForPrack=!1,this.logger.warn("No PRACK received, rejecting INVITE."),clearTimeout(p),this.reject({statusCode:504}).then(()=>o(new u)).catch(e=>o(e)))},64*a.a.T1),l=()=>{try{this.incomingInviteRequest.progress({statusCode:s,reasonPhrase:i,extraHeaders:r,body:n})}catch(e){return this.waitingForPrack=!1,void o(e)}p=setTimeout(l,g*=2)};let g=a.a.T1,p=setTimeout(l,g)}).catch(e=>{this.waitingForPrack=!1,o(e)})})}sendProgressTrying(){try{const e=this.incomingInviteRequest.trying();return Promise.resolve(e)}catch(e){return Promise.reject(e)}}waitForArrivalOfPrack(){if(this.waitingForPrackPromise)throw new Error("Already waiting for PRACK");return this.waitingForPrackPromise=new Promise((e,t)=>{this.waitingForPrackResolve=e,this.waitingForPrackReject=t}),this.waitingForPrackPromise}prackArrived(){this.waitingForPrackResolve&&this.waitingForPrackResolve(),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0}prackNeverArrived(){this.waitingForPrackReject&&this.waitingForPrackReject(new u),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0}}},function(e,t,s){var i=s(61).default;e.exports=i},,,,,function(e,t,s){var i=s(15).default;function r(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e.exports=r=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},s=Object.prototype,n=s.hasOwnProperty,o=Object.defineProperty||function(e,t,s){e[t]=s.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",h=a.asyncIterator||"@@asyncIterator",d=a.toStringTag||"@@toStringTag";function l(e,t,s){return Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,s){return e[t]=s}}function u(e,t,s,i){var r=t&&t.prototype instanceof f?t:f,n=Object.create(r.prototype),a=new x(i||[]);return o(n,"_invoke",{value:I(e,s,a)}),n}function g(e,t,s){try{return{type:"normal",arg:e.call(t,s)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p={};function f(){}function m(){}function v(){}var w={};l(w,c,(function(){return this}));var b=Object.getPrototypeOf,y=b&&b(b(k([])));y&&y!==s&&n.call(y,c)&&(w=y);var T=v.prototype=f.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){var s;o(this,"_invoke",{value:function(r,o){function a(){return new t((function(s,a){!function s(r,o,a,c){var h=g(e[r],e,o);if("throw"!==h.type){var d=h.arg,l=d.value;return l&&"object"==i(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){s("next",e,a,c)}),(function(e){s("throw",e,a,c)})):t.resolve(l).then((function(e){d.value=e,a(d)}),(function(e){return s("throw",e,a,c)}))}c(h.arg)}(r,o,s,a)}))}return s=s?s.then(a,a):a()}})}function I(e,t,s){var i="suspendedStart";return function(r,n){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===r)throw n;return _()}for(s.method=r,s.arg=n;;){var o=s.delegate;if(o){var a=R(o,s);if(a){if(a===p)continue;return a}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if("suspendedStart"===i)throw i="completed",s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);i="executing";var c=g(e,t,s);if("normal"===c.type){if(i=s.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:s.done}}"throw"===c.type&&(i="completed",s.method="throw",s.arg=c.arg)}}}function R(e,t){var s=t.method,i=e.iterator[s];if(void 0===i)return t.delegate=null,"throw"===s&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==s&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+s+"' method")),p;var r=g(i,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,p;var n=r.arg;return n?n.done?(t[e.resultName]=n.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):n:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function $(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function k(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var s=-1,i=function t(){for(;++s<e.length;)if(n.call(e,s))return t.value=e[s],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:_}}function _(){return{value:void 0,done:!0}}return m.prototype=v,o(T,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:m,configurable:!0}),m.displayName=l(v,d,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,l(e,d,"GeneratorFunction")),e.prototype=Object.create(T),e},t.awrap=function(e){return{__await:e}},S(E.prototype),l(E.prototype,h,(function(){return this})),t.AsyncIterator=E,t.async=function(e,s,i,r,n){void 0===n&&(n=Promise);var o=new E(u(e,s,i,r),n);return t.isGeneratorFunction(s)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(T),l(T,d,"Generator"),l(T,c,(function(){return this})),l(T,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),s=[];for(var i in t)s.push(i);return s.reverse(),function e(){for(;s.length;){var i=s.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},t.values=k,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach($),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function s(s,i){return o.type="throw",o.arg=e,t.next=s,i&&(t.method="next",t.arg=void 0),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i],o=r.completion;if("root"===r.tryLoc)return s("end");if(r.tryLoc<=this.prev){var a=n.call(r,"catchLoc"),c=n.call(r,"finallyLoc");if(a&&c){if(this.prev<r.catchLoc)return s(r.catchLoc,!0);if(this.prev<r.finallyLoc)return s(r.finallyLoc)}else if(a){if(this.prev<r.catchLoc)return s(r.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return s(r.finallyLoc)}}}},abrupt:function(e,t){for(var s=this.tryEntries.length-1;s>=0;--s){var i=this.tryEntries[s];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,p):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var s=this.tryEntries[t];if(s.finallyLoc===e)return this.complete(s.completion,s.afterLoc),$(s),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var s=this.tryEntries[t];if(s.tryLoc===e){var i=s.completion;if("throw"===i.type){var r=i.arg;$(s)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,s){return this.delegate={iterator:k(e),resultName:t,nextLoc:s},"next"===this.method&&(this.arg=void 0),p}},t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";var i=this&&this.__awaiter||function(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.WebPhoneTransport=void 0;const r=s(31);class n extends r.Transport{constructor(e,t){super(e,t),this.onMessage=e=>{console.error(e)}}send(e){const t=Object.create(null,{send:{get:()=>super.send}});return i(this,void 0,void 0,(function*(){if(e.startsWith("INVITE"))try{return e=e.replace("actpass","active "),t.send.call(this,e)}catch(e){console.error(e)}else{if(!e.startsWith("SIP/2.0 200 OK"))return t.send.call(this,e);try{return t.send.call(this,e)}catch(e){console.error(e)}}}))}}t.WebPhoneTransport=n},function(e,t,s){var i=s(15).default;e.exports=function(e,t){if("object"!==i(e)||null===e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var r=s.call(e,t||"default");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function s(t,i){return e.exports=s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,s(t,i)}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){var i=s(39);e.exports=function(e){if(Array.isArray(e))return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){var i=s(39);e.exports=function(e,t){if(e){if("string"==typeof e)return i(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?i(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,s){"use strict";s.r(t);var i=s(5),r=s.n(i),n=s(2),o=s.n(n),a=s(41),c=s(34);function h(){this.a=[],this.b=0,this.residue=null}h.prototype.getLength=function(){return this.a.length-this.b},h.prototype.isEmpty=function(){return 0==this.a.length},h.prototype.enqueue=function(e){this.a.push(e)},h.prototype.dequeue=function(){if(0!=this.a.length){var e=this.a[this.b];return 2*++this.b>=this.a.length&&(this.a=this.a.slice(this.b),this.b=0),e}return null},h.prototype.peek=function(){return 0<this.a.length?this.a[this.b]:void 0},h.prototype.clear=function(){this.a=[],this.b=0};var d,l,u=h,g=s(7),p=s.n(g),f=s(8),m=s.n(f),v=function(){function e(){p()(this,e),this._highFrequencyLogs={}}return m()(e,[{key:"setInstance",value:function(e){this._instance=e}},{key:"getMessageFromErrorOrEvent",value:function(e,t){var s=e;return t instanceof ErrorEvent?(t.filename&&(s+=" File: ".concat(t.filename)),(t.lineno||t.colno)&&(s+=" Line: ".concat(t.lineno,":").concat(t.colno)),t.message&&(s+=" Message: ".concat(t.message)),t.stack&&(s+="\nStack: ".concat(t.stack))):t instanceof Error?(t.fileName&&(s+=" File: ".concat(t.fileName)),(t.lineNumber||t.columnNumber)&&(s+=" Line: ".concat(t.lineNumber,":").concat(t.columnNumber)),t.message&&(s+=" Message: ".concat(t.message)),t.stack&&(s+=" Stack: ".concat(t.stack)),t.name&&(s+=" Name: ".concat(t.name)),t.constraint&&(s+=" Constraint: ".concat(t.constraint))):t instanceof CloseEvent&&(t.code&&(s+=" Code: ".concat(t.code)),t.reason&&(s+=" Reason: ".concat(t.reason)),s+=" wasClean: ".concat(t.wasClean)),s}},{key:"error",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=this.getMessageFromErrorOrEvent(e,t),this._highFrequencyLogs[e]?this._highFrequencyLogs[e]+=1:this._highFrequencyLogs[e]=1;var s=w(this._highFrequencyLogs[e]);this._instance&&s&&this._instance.error(e)}},{key:"warn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=this.getMessageFromErrorOrEvent(e,t),this._instance&&this._instance.warn(e)}},{key:"log",value:function(e){this._instance&&this._instance.log(e)}}]),e}(),w=function(e){return 0==(e&e-1)},b=new v,y=s(15),T=s.n(y),S=function(){};S.prototype={threads:(l=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",function(){var e=r()(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(WebAssembly.validate(t)){e.next=2;break}return e.abrupt("return",!1);case 2:return e.prev=2,e.abrupt("return",((new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),!0));case 6:return e.prev=6,e.t0=e.catch(2),e.abrupt("return",!1);case 9:case"end":return e.stop()}}),e,null,[[2,6]])})));return function(t){return e.apply(this,arguments)}}()(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])));case 1:case"end":return e.stop()}}),e)}))),function(){return l.apply(this,arguments)}),simd:(d=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11])));case 1:case"end":return e.stop()}}),e)}))),function(){return d.apply(this,arguments)})};var E,I,R,C,$=new S,x=function(){function e(){p()(this,e)}return m()(e,[{key:"_drawWatermarkWithShadow",value:function(e){var t=e.ctx,s=e.textPos,i=e.opacity,r=e.name;t.fillStyle="rgba(0, 0, 0, ".concat(i,")"),t.fillText(r,s.x,s.y),t.fillStyle="rgba(255, 255, 255, ".concat(i,")"),t.fillText(r,s.x+1,s.y+1)}},{key:"_getTransformInfo",value:function(e){var t,s=e.canvas,i=e.position;if(1===i)t={x:s.width/2,y:0,rateRadio:0,maxWidth:s.width};else if(2===i)t={x:s.width/2,y:s.height,rateRadio:0,maxWidth:s.width};else if(4===i)t={x:0,y:s.height/2,rateRadio:Math.PI/2,maxWidth:s.height};else if(8===i)t={x:s.width,y:s.height/2,rateRadio:-Math.PI/2,maxWidth:s.height};else{var r=-21*Math.PI/180;t={x:s.width/2,y:s.height/2,rateRadio:r,maxWidth:Math.min(s.width/Math.cos(r),-s.height/Math.sin(r))}}return t.maxWidth>100&&(t.maxWidth-=50),t}},{key:"_calcTextPos",value:function(e){var t=e.position,s=e.ctx,i=e.name,r=e.textWidth,n=this._getPaddingWidth({ctx:s,position:t,name:i});return 1===t?{x:-r.width/2,y:n}:2===t||4===t||8===t?{x:-r.width/2,y:-n}:{x:-r.width/2,y:s.measureText(i[0]).width/2}}},{key:"_getPaddingWidth",value:function(e){var t=e.ctx,s=e.position,i=e.name;return[1,2,4,8].includes(s)?32:t.measureText(i[0]).width}},{key:"_setBaseLine",value:function(e){var t=e.ctx,s=e.position;t.textBaseline=1===s?"top":2===s||4===s||8===s?"bottom":"middle"}},{key:"Get_WaterMarkRGBA",value:function(e){var t=e.canvas,s=e.name,i=e.width,r=e.height,n=e.opacity,o=void 0===n?.15:n,a=e.position,c=e.convertToDataUrl;if(s&&i&&r){o=o||.15;i*=1,r*=1,t.width=i,t.height=r;var h,d=this._getTransformInfo({canvas:t,position:a}),l=t.getContext("2d");if(l.clearRect(0,0,t.width,t.height),l.translate(d.x,d.y),l.rotate(d.rateRadio),this._setBaseLine({ctx:l,position:a}),l.lineWidth=1,l.imageSmoothingEnabled=!0,1==s.length){var u=d.maxWidth/s.length;l.font=u+"px 'Segoe UI'",h=l.measureText(s)}else{var g=16;for(l.font=g+"px 'Segoe UI'",h=l.measureText(s);h.width<d.maxWidth-2*this._getPaddingWidth({ctx:l,position:a,name:s});)g+=1,l.font=g+"px 'Segoe UI'",h=l.measureText(s);if(h.width>d.maxWidth-2*this._getPaddingWidth({ctx:l,position:a,name:s}))if(g>16)g-=1,l.font=g+"px 'Segoe UI'",h=l.measureText(s);else{for(var p=s;s.length>5&&h.width>d.maxWidth-2*this._getPaddingWidth({ctx:l,position:a,name:s+"..."});)s=s.slice(0,s.length-1),h=l.measureText(s+"...");p!==s&&(s+="...")}}var f,m=this._calcTextPos({position:a,ctx:l,name:s,textWidth:h});if(this._drawWatermarkWithShadow({ctx:l,name:s,opacity:o,textPos:m}),c)f=t.toDataURL();else{var v=l.getImageData(0,0,l.canvas.width,l.canvas.height);f=new Uint8Array(v.data.buffer)}return l.rotate(-d.rateRadio),l.translate(-d.x,-d.y),f}}},{key:"Get_Repeated_WaterMarkRGBA",value:function(e){var t=e.canvas,s=e.name,i=e.width,r=e.height,n=e.opacity,o=void 0===n?.15:n,a=(e.position,e.convertToDataUrl);if(s&&i&&r){o=o||.15;i*=1,r*=1,t.width=i,t.height=r;var c=t.getContext("2d");c.clearRect(0,0,t.width,t.height),c.translate(i/2,r/2),c.rotate(-21*Math.PI/180),c.imageSmoothingEnabled=!0;c.font="".concat(32,"px 'Segoe UI'"),c.textBaseline="top";var h,d=c.measureText(s),l=.37*d.width,u=0,g=-r;do{var p=u%2==0?l-i:-i;do{c.fillStyle="rgba(0, 0, 0, ".concat(o,")"),c.fillText(s,p,g),c.fillStyle="rgba(255, 255, 255, ".concat(o,")"),c.fillText(s,p+1,g+1),p+=d.width+l}while(p<i);g+=32+l,u++}while(g<r);if(a)h=t.toDataURL();else{var f=c.getImageData(0,0,c.canvas.width,c.canvas.height);h=new Uint8Array(f.data.buffer)}return c.rotate(21*Math.PI/180),c.translate(-i/2,-r/2),h}}}]),e}(),k=(I={},R=navigator.userAgent.toLowerCase(),(E=R.match(/rv:([\d.]+)\) like gecko/))||(E=R.match(/msie ([\d\.]+)/))?I.ie=E[1]:(E=R.match(/edge\/([\d\.]+)/))?I.edge=E[1]:(E=R.match(/firefox\/([\d\.]+)/))?I.firefox=E[1]:(E=R.match(/(?:opera|opr).([\d\.]+)/))?I.opera=E[1]:(E=R.match(/chrome\/([\d\.]+)/))?I.chrome=E[1]:(E=R.match(/version\/([\d\.]+).*safari/))&&(I.safari=E[1]),C=I,function(){return C}),_=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:90,t=k();if(t.chrome){var s=parseInt(t.chrome);if(s>=e)return!0}return!1},D=function(e){var t=k();if(t.firefox&&parseInt(t.firefox)>=e)return!0;return!1};var A=new(function(){function e(){p()(this,e),this._isSupportMultiThread=!1,this._isSupportSIMD=!1,this.inProgressPromise={checkSupportMultiThread:null,checkSupportSIMD:null},this._isSupportWebtransport=!1,this._isSupportVirtualBackground=!1}var t,s;return m()(e,[{key:"checkIsSupportMultiThread",value:(s=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.getIsSupportMultiThread()){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,!this.inProgressPromise.checkSupportMultiThread){e.next=8;break}return e.next=6,this.inProgressPromise.checkSupportMultiThread;case 6:e.next=14;break;case 8:return this.inProgressPromise.checkSupportMultiThread=$.threads(),e.t0=this,e.next=12,this.inProgressPromise.checkSupportMultiThread;case 12:e.t1=e.sent,e.t0._setIsSupportMultiThread.call(e.t0,e.t1);case 14:e.next=19;break;case 16:e.prev=16,e.t2=e.catch(2),this._setIsSupportMultiThread(!1);case 19:case"end":return e.stop()}}),e,this,[[2,16]])}))),function(){return s.apply(this,arguments)})},{key:"_setIsSupportMultiThread",value:function(e){this._isSupportMultiThread=e}},{key:"getIsSupportMultiThread",value:function(){return this._isSupportMultiThread}},{key:"checkIsSupportSIMD",value:(t=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.getIsSupportSIMD()){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,!this.inProgressPromise.checkSupportSIMD){e.next=8;break}return e.next=6,this.inProgressPromise.checkSupportSIMD;case 6:e.next=14;break;case 8:return this.inProgressPromise.checkSupportSIMD=$.simd(),e.t0=this,e.next=12,this.inProgressPromise.checkSupportSIMD;case 12:e.t1=e.sent,e.t0._setIsSupportSIMD.call(e.t0,e.t1);case 14:e.next=19;break;case 16:e.prev=16,e.t2=e.catch(2),this._setIsSupportSIMD(!1);case 19:case"end":return e.stop()}}),e,this,[[2,16]])}))),function(){return t.apply(this,arguments)})},{key:"_setIsSupportSIMD",value:function(e){this._isSupportSIMD=e}},{key:"getIsSupportSIMD",value:function(){return this._isSupportSIMD}},{key:"getIsSupportWebtransport",value:function(){return _(97)&&"function"==typeof WebTransport&&this._isSupportWebtransport}},{key:"setIsSupportWebtransport",value:function(e){this._isSupportWebtransport=!!e}},{key:"getIsSupportVirtualBackground",value:function(){var e=_(91)||D(89);return navigator.hardwareConcurrency&&navigator.hardwareConcurrency>2&&e&&"function"==typeof OffscreenCanvas&&this._isSupportVirtualBackground}},{key:"setIsSupportVirtualBackground",value:function(e){this._isSupportVirtualBackground=!!e}},{key:"getIsRenderSelfVideoInEncodeWorker",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e&&!this.getIsSupportMultiThread()&&this.getIsSupportVirtualBackground()}}]),e}());function P(e,t,s){var i=e.match(t);return i&&i.length>=s&&parseInt(i[s],10)}function H(){var e=window.navigator,t={browser:null,version:null};if("undefined"==typeof window||!window.navigator)return t.browser="Not a browser.",t;if(e.mozGetUserMedia)t.browser="firefox",t.version=P(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia)t.browser="chrome",t.version=P(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=P(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!window.RTCPeerConnection||!e.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=P(e.userAgent,/AppleWebKit\/(\d+)\./,1)}return t}var q=H();function O(){var e=navigator.userAgent.match(/CrKey\/([\d.]+)/);if(e){var t=e[1].match(/[0-9]{0,2}[.][0-9]{0,2}/);return t?t[0]:-1}return-1}"function"==typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("webgl");var M,N,j,F,U,L,B,V,G,W,K,Y,Z,J,z,X,Q,ee={isFirefox:"firefox"===q.browser,isChrome:"chrome"===q.browser,isSafari:"safari"===q.browser};Q=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,A.checkIsSupportMultiThread();case 2:return e.abrupt("return",A.getIsSupportMultiThread()&&navigator.userAgent&&(-1==navigator.userAgent.indexOf("CrKey")||O()>=1.54));case 3:case"end":return e.stop()}}),e)}))),X=r()(o.a.mark((function e(){var t;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1==navigator.userAgent.indexOf("WOW64")){e.next=4;break}return e.abrupt("return",!0);case 4:if(!navigator.userAgentData||!navigator.userAgentData.getHighEntropyValues){e.next=11;break}return e.next=7,navigator.userAgentData.getHighEntropyValues(["wow64"]);case 7:return t=e.sent,e.abrupt("return",t.wow64);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e)}))),z=null,Y=new x,Z=document.createElement("canvas"),J={enableWaterMark:!1,waterMarkText:"",watermarkOpacity:0,watermarkRepeated:!1,watermarkPosition:void 0},j=document.createElement("canvas"),F=j.getContext("2d"),U=640,L=360,B=navigator.hardwareConcurrency&&navigator.hardwareConcurrency<4?10:24,V=1e3/("chrome"===q.browser?B:10),G=null,W=0,K=null,function(){var e=null,t=new(window.AudioContext||window.webkitAudioContext),s=null,i=null,r=null}();function te(){var e=this;this.promise=new Promise((function(t,s){e.reject=s,e.resolve=t}))}var se=s(29),ie=s.n(se),re=s(45),ne=s.n(re),oe=s(32),ae=s.n(oe),ce=s(33),he=s.n(ce),de="object"===("undefined"==typeof localStorage?"undefined":T()(localStorage))&&localStorage.__islogdebug,le=function(e,t){function s(){var e=[];return e.push.apply(e,arguments),e}!0===t&&(de=!0);var i=function(){var t;de&&(t=console).log.apply(t,[e].concat(he()(s(arguments))))};return["log","info","warn","error"].forEach((function(t){i[t]=function(){var i;de&&(i=console)[t].apply(i,[e].concat(he()(s(arguments))))}})),i.isEnable=function(){return de},i};le.isEnable=function(){return de};var ue=le;function ge(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,i=ae()(e);if(t){var r=ae()(this).constructor;s=Reflect.construct(i,arguments,r)}else s=i.apply(this,arguments);return ne()(this,s)}}var pe,fe=ue("sdk.init"),me=function(){function e(){var t=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";p()(this,e),this.name=s,this.handler=null,this.wasm=null,this.socket=null,this.defered=new te,this.initSuccessPromise=this.defered.promise,this.wasmDefered=new te,this.wasmSuccessPromise=this.wasmDefered.promise,this.handlerDefered=new te,this.handlerSuccessPromise=this.handlerDefered.promise,this.socketDefered=new te,this.socketSuccessPromise=this.socketDefered.promise,Promise.all([this.wasmSuccessPromise,this.handlerSuccessPromise,this.socketSuccessPromise]).then((function(e){var s=e.every((function(e){return!0===e}));t.defered.resolve(s),s||fe.error(t.name,{handler:t.handler,wasm:t.wasm,socket:t.socket})}))}return m()(e,[{key:"setHanderSuccess",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.handler=e,this.handlerDefered.resolve(e)}},{key:"setWasmSuccess",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.wasm=e,this.wasmDefered.resolve(e)}},{key:"setSocketSuccess",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.socket=e,this.socketDefered.resolve(e)}},{key:"checkInitSuccess",value:function(){var e=this.handler&&this.wasm&&this.socket;return e&&this.defered.resolve(!0),e}},{key:"isSocketInitSuccess",value:function(){return this.socket}},{key:"waitforInitSuccess",value:function(){return this.initSuccessPromise}}]),e}(),ve=function(e){ie()(s,e);var t=ge(s);function s(e){return p()(this,s),t.call(this,e)}return m()(s)}(me),we=function(e){ie()(s,e);var t=ge(s);function s(e){return p()(this,s),t.call(this,e)}return m()(s)}(me),be=function(e){ie()(s,e);var t=ge(s);function s(e){return p()(this,s),t.call(this,e)}return m()(s)}(me),ye=s(18),Te=s.n(ye),Se="0",Ee="1",Ie="2",Re="3",Ce="4",$e="5",xe=0,ke=0,_e=(pe={},Te()(pe,Ie,"audio.encode"),Te()(pe,Re,"audio.decode"),Te()(pe,Se,"video.encode"),Te()(pe,Ee,"video.decode"),Te()(pe,Ce,"share.encode"),Te()(pe,$e,"share.decode"),ue("sdk.variables"));function De(){}De.prototype.initDB=function(){var e,t={},s=this;t.init=function(i){if(this.db_name=i.db_name,this.db_version=i.db_version,this.db_store_name=i.db_store_name,indexedDB){try{e=indexedDB.open(this.db_name,this.db_version)}catch(e){return b.error("Error opening IndexedDB",e),void(s.indexDbObject=null)}e.onerror=function(e){s.indexDbObject=null},e.onupgradeneeded=function(e){this.db=e.target.result,this.db.createObjectStore(t.db_store_name)},e.onsuccess=function(e){t.db=e.target.result,s.openIndexFlag=!0,s.indexDbObject.select("delay")}}else s.indexDbObject=null},t.put=function(e,s){try{var i=t.db.transaction(t.db_store_name,"readwrite").objectStore(t.db_store_name).put(e,s);i.onsuccess=function(){},i.onerror=function(e){b.error("Set Delay failed!",e)}}catch(e){b.error("IndexDb put Failed!",e)}},t.delete=function(s){(e=t.db.transaction(t.db_store_name,"readwrite").objectStore(t.db_store_name).delete(s)).onsuccess=function(){_e("Delete the key:"+s)}},t.select=function(e){try{var i=t.db.transaction(t.db_store_name,"readwrite").objectStore(t.db_store_name);if(e)var r=i.get(e);else r=i.getAll();r.onsuccess=function(){s.audioDelay=r.result},r.onerror=function(){s.audioDelay=0}}catch(e){b.error("IndexDb Select Failed",e)}},t.clear=function(){t.db.transaction(t.db_store_name,"readwrite").objectStore(t.db_store_name).clear().onsuccess=function(){_e("Clear the IndexDb Successfully")}},t.close=function(){t.db&&t.db.close()},this.indexDbObject=t,this.indexDbObject.init({db_name:"AEC",db_version:1,db_store_name:"delay"})},De.prototype.Notify_APPUI_SAFE=function(){this._Notify_APPUI&&(_e("Notify_APPUI_SAFE",arguments),this._Notify_APPUI.apply(this,arguments))},De.prototype.Notify_APPUI=function(){this._Notify_APPUI&&(_e("Notify_APPUI",arguments),this._Notify_APPUI.apply(this,arguments))},De.prototype.queueMessageToRwg=function(e,t){this.rwgMessageList.push({jsEvent:e,message:t})},De.prototype.clearMessageToRwg=function(){var e=this;this.rwgConnectSuccess=!0,this.rwgMessageList.length>0&&(this.rwgAgent||this._Notify_APPUI)&&(this.rwgMessageList.forEach((function(t){var s=t.jsEvent,i=t.message;e.sendMessageToRwg(s,i,!1,!1)})),this.rwgMessageList=[])},De.prototype.destroyQueueMessageToRwg=function(){this.rwgConnectSuccess=!1,this.rwgMessageList=[]},De.prototype.sendMessageToRwg=function(e,t){var s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this.rwgConnectSuccess&&(this.rwgAgent||this._Notify_APPUI)||!s){this.rwgConnectSuccess&&i&&this.clearMessageToRwg();try{this.rwgAgent?this.rwgAgent.sendMessageToRwg(t):this.Notify_APPUI_SAFE(e,t)}catch(e){b.error("Error sending message to RWG",e)}}else this.queueMessageToRwg(e,t)},De.prototype.reinit=function(){this.SPECIAL_ID=0,this._Notify_APPUI=null,this.localAudioDecMGR=null,this.localVideoDecMGR=null,this.localAudioEncMGR=null,this.localVideoEncMGR=null,this.localSharingDecMGR=null,this.localMouseDecMGR=null,this.localSharingEncMGR=null,this.localAudioPara=null,this.localVideoPara=null,this.localSharingPara=null,this.Audio_WebSocket_Ip_Address=null,this.Audio_Web_Transport_Ip_Address=null,this.Video_WebSocket_Ip_Address=null,this.Video_Web_Transport_Ip_Address=null,this.Sharing_WebSocket_Ip_Address=null,this.mediaSDKHandle=null,this.audio_pcm_queue=new u,this.int16Array=null,this.isInitialFailed=!1,this.isAudioEncodeWASMOK=!1,this.isAudioDecodeWASMOK=!1,this.isVideoEncodeWASMOK=!1,this.isVideoDecodeWASMOK=!1,this.isSharingDecodeWASMOK=!1,this.isSharingEncodeWASMOK=!1,this.audioEncWorkerPath="",this.audioDecWorkerPath="",this.videoDecWorkerPath="",this.videoEncWorkerPath="",this.sharingDecWorkerPath="",this.sharingEncWorkerPath="",this.isAudioEncodePostStart=!1,this.isAudioDecodePostStart=!1,this.isVideoDecodePostStart=!1,this.isVideoEncodePostStart=!1,this.isSharingDecodePostStart=!1,this.isSharingEncodePostStart=!1,this.isAudioEncodeThreadStart=!1,this.isAudioDecodeThreadStart=!1,this.isVideoDecodeThreadStart=!1,this.isSharingDecodeThreadStart=!1,this.isVideoEncodeThreadStart=!1,this.isSharingEncodeThreadStart=!1,this.isAudioPlayWork=!1,this.isVideoPlayWork=!1,this.isSharingPlayWork=!1,this.shareBufferSampleNumb=30,this.audioWasmInfo=null,this.audioWasm=null,this.initialSuccessNumb=0,this.TotalWaitEvent=0,this.audioPostInterval=null,this.sharedBuffer=null,this.decoderinworklet=null,this.decoderinworkletOP=null,this.chromeWideAEC=null,this.shareSystemAudio=!1,this.indexDbObject=null,this.audioDelay=0,this.openIndexFlag=!1,this.audioBufferSize=ee.isFirefox?30:15,this.monitorEncodeVideo=null,this.monitorDecodeVideo=null,this.monitorEncodeSharing=null,this.monitorDecodeSharing=null,this.monitorEncodeAudio=null,this.monitorDecodeAudio=null,this.monitorVideoCapture=null,this.monitorVideoReadyCaptureWidth=0,this.monitorVideoReadyCaptureHeight=0,this.monitorIntervalHandle=null,this.monitorVideoUserID=null,this.monitorSharingUserID=null,this.monitorSharingEncodeAPPInfo=null,this.monitorVideoDecodeAPPInfo=null,this.monitorVideoEncodeAPPInfo=null,this.monitorCid=null,this.e2eencrypt=!1,this.AudioNode=null,this.SharingAudioNode=null,this.CurrentSSRC=0,this.CurrentSSRCTime=0,this.audioPlayTime=0,this.videoDecResponseText=null,this.videoEncResponseText=null,this.sharingDecodeResponse=null,this.sharingEncodeResponse=null,this.sharingDecInitInstance=new ve($e),this.sharingEncInitInstance=new ve(Ce),this.videoDecInitInstance=new we(Ee),this.videoInitInstance=new we(Se),this.audioDecInitInstance=new be(Re),this.audioEncodeInitInstance=new be(Ie),this.audioDecodeResponse=null,this.audioEncodeResponse=null,this.ivObj={},this.userNodeList=[],this.rwgAgent=null,this.ComputerAudioStatus=xe,this.DesktopAudioStatus=ke,this.initDB(),this.resourceManager=null,this.vbarraybuffer=null,this.vbbin=null,this.vbjson=null,this.tfjsurl=null,this.afnbin=null,this.afnjson=null,this.basebin=null,this.basejson=null,this.interpretationMessage=new u,this.workletWasmInitSuccess=!1,this.videoEncodeInitSuccess=null,this.vbPreloadSuccess=null,this.enableAduioBridge=!1,this.audioMode=-1,this.isPreviewMode={audioEncode:!1,audioDecode:!1,videoEncode:!1,videoDecode:!1},this.rwgConnectSuccess=!1,this.rwgMessageList=[],this.localSsrc=0};var Ae=new De,Pe=0;function He(e,t,s,i,r,n){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:18e4;this.reconnectTimes=10,this.keepalive=0,this.intervalTime=o,this.state=Pe,this.isReconnect=!1,this.websipclientagent=new a.WebSipClientAgent(e,t,s,i,r,n,this.reconnectTimes,this)}He.prototype.mute=function(){this.websipclientagent&&this.websipclientagent.mute()},He.prototype.unmute=function(){this.websipclientagent&&this.websipclientagent.unmute()},He.prototype.connect=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.websipclientagent){e.next=9;break}return e.prev=1,e.next=4,this.websipclientagent.connect();case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),Ae.Notify_APPUI&&Ae.Notify_APPUI(-28);case 9:case"end":return e.stop()}}),e,this,[[1,6]])}))),He.prototype.call=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.websipclientagent){e.next=6;break}return e.next=3,this.websipclientagent.call();case 3:e.sent&&Ae.Notify_APPUI(2,null),this.setPeerConnectionDelegate();case 6:case"end":return e.stop()}}),e,this)}))),He.prototype.disconnect=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.websipclientagent){e.next=3;break}return e.next=3,this.websipclientagent.disconnect();case 3:case"end":return e.stop()}}),e,this)}))),He.prototype.hangup=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.websipclientagent){e.next=3;break}return e.next=3,this.websipclientagent.hangup();case 3:case"end":return e.stop()}}),e,this)}))),He.prototype.onCallHangup=function(){this.isReconnect=!0,this.keepalive&&(clearInterval(this.keepalive),this.keepalive=0)},He.prototype.onCallAnswered=function(){var e=this;Ae.Notify_APPUI&&Ae.Notify_APPUI(22),this.keepalive||(this.keepalive=setInterval((function(){e.sendOption()}),this.intervalTime))},He.prototype.onServerDisconnect=function(){Ae.Notify_APPUI&&Ae.Notify_APPUI(-26),this.keepalive&&(clearInterval(this.keepalive),this.keepalive=0)},He.prototype.onFailedReconnect=function(){Ae.Notify_APPUI&&Ae.Notify_APPUI(-25)},He.prototype.onServerConnect=function(){this.isReconnect&&(this.websipclientagent.failover(),this.websipclientagent.call())},He.prototype.clear=r()(o.a.mark((function e(){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.hangup();case 2:return e.next=4,this.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),He.prototype.sendOption=function(){var e=this.websipclientagent.instance.userAgent.userAgentCore,t=c.a.makeURI("sip:wcl.sip@zoom.us"),s=c.a.makeURI("sip:wcl.server@zoom.us"),i=s,r=e.makeOutgoingRequestMessage("OPTIONS",i,t,s,{});e.request(r)},He.prototype.onRejectInvite=function(e){var t;Ae.Notify_APPUI&&(e&&e.message&&(t=e.message.statusCode),Ae.Notify_APPUI(-30,t))},He.prototype.setPeerConnectionDelegate=function(){this.websipclientagent.instance&&this.websipclientagent.instance&&this.websipclientagent.instance.session._sessionDescriptionHandler&&(this.websipclientagent.instance.session._sessionDescriptionHandler._peerConnectionDelegate={onconnectionstatechange:function(e){e.target&&e.target.connectionState},onstatsended:function(e){},onsignalingstatechange:function(e){}})};t.default=He},function(e,t,s){"use strict";s.r(t);var i,r=s(7),n=s.n(r),o=s(8),a=s.n(o),c=s(34),h=s(9),d=s(23),l=s(10),u=s(28),g=s(16),p=s(65);!function(e){e.Initial="Initial",e.Registered="Registered",e.Unregistered="Unregistered",e.Terminated="Terminated"}(i||(i={}));class f{constructor(e,t={}){this.disposed=!1,this._contacts=[],this._retryAfter=void 0,this._state=i.Initial,this._waiting=!1,this._stateEventEmitter=new g.a,this._waitingEventEmitter=new g.a,this.userAgent=e;const s=e.configuration.uri.clone();if(s.user=void 0,this.options=Object.assign(Object.assign(Object.assign({},f.defaultOptions()),{registrar:s}),f.stripUndefinedProperties(t)),this.options.extraContactHeaderParams=(this.options.extraContactHeaderParams||[]).slice(),this.options.extraHeaders=(this.options.extraHeaders||[]).slice(),!this.options.registrar)throw new Error("Registrar undefined.");if(this.options.registrar=this.options.registrar.clone(),this.options.regId&&!this.options.instanceId?this.options.instanceId=f.newUUID():!this.options.regId&&this.options.instanceId&&(this.options.regId=1),this.options.instanceId&&-1===d.a.parse(this.options.instanceId,"uuid"))throw new Error("Invalid instanceId.");if(this.options.regId&&this.options.regId<0)throw new Error("Invalid regId.");const r=this.options.registrar,n=this.options.params&&this.options.params.fromUri||e.userAgentCore.configuration.aor,o=this.options.params&&this.options.params.toUri||e.configuration.uri,a=this.options.params||{},c=(t.extraHeaders||[]).slice();if(this.request=e.userAgentCore.makeOutgoingRequestMessage(l.a.REGISTER,r,n,o,a,c,void 0),this.expires=this.options.expires||f.defaultExpires,this.expires<0)throw new Error("Invalid expires.");if(this.refreshFrequency=this.options.refreshFrequency||f.defaultRefreshFrequency,this.refreshFrequency<50||this.refreshFrequency>99)throw new Error("Invalid refresh frequency. The value represents a percentage of the expiration time and should be between 50 and 99.");this.logger=e.getLogger("sip.Registerer"),this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(e=>{const t=this.options[e];switch(e){case"registrar":this.logger.log("· "+e+": "+t);break;default:this.logger.log("· "+e+": "+JSON.stringify(t))}})),this.id=this.request.callId+this.request.from.parameters.tag,this.userAgent._registerers[this.id]=this}static defaultOptions(){return{expires:f.defaultExpires,extraContactHeaderParams:[],extraHeaders:[],logConfiguration:!0,instanceId:"",params:{},regId:0,registrar:new u.a("sip","anonymous","anonymous.invalid"),refreshFrequency:f.defaultRefreshFrequency}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.floor(16*Math.random());return("x"===e?t:t%4+8).toString(16)})}static stripUndefinedProperties(e){return Object.keys(e).reduce((t,s)=>(void 0!==e[s]&&(t[s]=e[s]),t),{})}get contacts(){return this._contacts.slice()}get retryAfter(){return this._retryAfter}get state(){return this._state}get stateChange(){return this._stateEventEmitter}dispose(){return this.disposed?Promise.resolve():(this.disposed=!0,this.logger.log(`Registerer ${this.id} in state ${this.state} is being disposed`),delete this.userAgent._registerers[this.id],new Promise(e=>{const t=()=>{if(!this.waiting&&this._state===i.Registered)return this.stateChange.addListener(()=>{this.terminated(),e()},{once:!0}),void this.unregister();this.terminated(),e()};this.waiting?this.waitingChange.addListener(()=>{t()},{once:!0}):t()}))}register(e={}){if(this.state===i.Terminated)throw this.stateError(),new Error("Registerer terminated. Unable to register.");if(this.disposed)throw this.stateError(),new Error("Registerer disposed. Unable to register.");if(this.waiting){this.waitingWarning();const e=new p.a("REGISTER request already in progress, waiting for final response");return Promise.reject(e)}e.requestOptions&&(this.options=Object.assign(Object.assign({},this.options),e.requestOptions));const t=(this.options.extraHeaders||[]).slice();t.push("Contact: "+this.generateContactHeader(this.expires)),t.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.request.extraHeaders=t,this.waitingToggle(!0);const s=this.userAgent.userAgentCore.register(this.request,{onAccept:t=>{let s;t.message.hasHeader("expires")&&(s=Number(t.message.getHeader("expires"))),this._contacts=t.message.getHeaders("contact");let i,r=this._contacts.length;if(!r)return this.logger.error("No Contact header in response to REGISTER, dropping response."),void this.unregistered();for(;r--;){if(i=t.message.parseHeader("contact",r),!i)throw new Error("Contact undefined");if(this.userAgent.contact.pubGruu&&Object(u.b)(i.uri,this.userAgent.contact.pubGruu)){s=Number(i.getParam("expires"));break}if(""===this.userAgent.configuration.contactName){if(i.uri.user===this.userAgent.contact.uri.user){s=Number(i.getParam("expires"));break}}else if(Object(u.b)(i.uri,this.userAgent.contact.uri)){s=Number(i.getParam("expires"));break}i=void 0}if(void 0===i)return this.logger.error("No Contact header pointing to us, dropping response"),this.unregistered(),void this.waitingToggle(!1);if(void 0===s)return this.logger.error("Contact pointing to us is missing expires parameter, dropping response"),this.unregistered(),void this.waitingToggle(!1);if(i.hasParam("temp-gruu")){const e=i.getParam("temp-gruu");e&&(this.userAgent.contact.tempGruu=d.a.URIParse(e.replace(/"/g,"")))}if(i.hasParam("pub-gruu")){const e=i.getParam("pub-gruu");e&&(this.userAgent.contact.pubGruu=d.a.URIParse(e.replace(/"/g,"")))}this.registered(s),e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t),this.waitingToggle(!1)},onProgress:t=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(t)},onRedirect:t=>{this.logger.error("Redirect received. Not supported."),this.unregistered(),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(t),this.waitingToggle(!1)},onReject:t=>{if(423===t.message.statusCode)return t.message.hasHeader("min-expires")?(this.expires=Number(t.message.getHeader("min-expires")),this.waitingToggle(!1),void this.register()):(this.logger.error("423 response received for REGISTER without Min-Expires, dropping response"),this.unregistered(),void this.waitingToggle(!1));this.logger.warn("Failed to register, status code "+t.message.statusCode);let s=NaN;if(500===t.message.statusCode||503===t.message.statusCode){const e=t.message.getHeader("retry-after");e&&(s=Number.parseInt(e,void 0))}this._retryAfter=isNaN(s)?void 0:s,this.unregistered(),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t),this._retryAfter=void 0,this.waitingToggle(!1)},onTrying:t=>{e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(t)}});return Promise.resolve(s)}unregister(e={}){if(this.state===i.Terminated)throw this.stateError(),new Error("Registerer terminated. Unable to register.");if(this.disposed&&this.state!==i.Registered)throw this.stateError(),new Error("Registerer disposed. Unable to register.");if(this.waiting){this.waitingWarning();const e=new p.a("REGISTER request already in progress, waiting for final response");return Promise.reject(e)}this._state===i.Registered||e.all||this.logger.warn("Not currently registered, but sending an unregister anyway.");const t=(e.requestOptions&&e.requestOptions.extraHeaders||[]).slice();this.request.extraHeaders=t,e.all?(t.push("Contact: *"),t.push("Expires: 0")):t.push("Contact: "+this.generateContactHeader(0)),this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),this.waitingToggle(!0);const s=this.userAgent.userAgentCore.register(this.request,{onAccept:t=>{this._contacts=t.message.getHeaders("contact"),this.unregistered(),e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(t),this.waitingToggle(!1)},onProgress:t=>{e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(t)},onRedirect:t=>{this.logger.error("Unregister redirected. Not currently supported."),this.unregistered(),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(t),this.waitingToggle(!1)},onReject:t=>{this.logger.error("Unregister rejected with status code "+t.message.statusCode),this.unregistered(),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(t),this.waitingToggle(!1)},onTrying:t=>{e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(t)}});return Promise.resolve(s)}clearTimers(){void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),void 0!==this.registrationExpiredTimer&&(clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=void 0)}generateContactHeader(e){let t=this.userAgent.contact.toString();return this.options.regId&&this.options.instanceId&&(t+=";reg-id="+this.options.regId,t+=';+sip.instance="<urn:uuid:'+this.options.instanceId+'>"'),this.options.extraContactHeaderParams&&this.options.extraContactHeaderParams.forEach(e=>{t+=";"+e}),t+=";expires="+e,t}registered(e){this.clearTimers(),this.registrationTimer=setTimeout(()=>{this.registrationTimer=void 0,this.register()},this.refreshFrequency/100*e*1e3),this.registrationExpiredTimer=setTimeout(()=>{this.logger.warn("Registration expired"),this.unregistered()},1e3*e),this._state!==i.Registered&&this.stateTransition(i.Registered)}unregistered(){this.clearTimers(),this._state!==i.Unregistered&&this.stateTransition(i.Unregistered)}terminated(){this.clearTimers(),this._state!==i.Terminated&&this.stateTransition(i.Terminated)}stateTransition(e){const t=()=>{throw new Error(`Invalid state transition from ${this._state} to ${e}`)};switch(this._state){case i.Initial:e!==i.Registered&&e!==i.Unregistered&&e!==i.Terminated&&t();break;case i.Registered:e!==i.Unregistered&&e!==i.Terminated&&t();break;case i.Unregistered:e!==i.Registered&&e!==i.Terminated&&t();break;case i.Terminated:t();break;default:throw new Error("Unrecognized state.")}this._state=e,this.logger.log("Registration transitioned to state "+this._state),this._stateEventEmitter.emit(this._state),e===i.Terminated&&this.dispose()}get waiting(){return this._waiting}get waitingChange(){return this._waitingEventEmitter}waitingToggle(e){if(this._waiting===e)throw new Error(`Invalid waiting transition from ${this._waiting} to ${e}`);this._waiting=e,this.logger.log("Waiting toggled to "+this._waiting),this._waitingEventEmitter.emit(this._waiting)}waitingWarning(){let e="An attempt was made to send a REGISTER request while a prior one was still in progress.";e+=" RFC 3261 requires UAs MUST NOT send a new registration until they have received a final response",e+=" from the registrar for the previous one or the previous REGISTER request has timed out.",e+=" Note that if the transport disconnects, you still must wait for the prior request to time out before",e+=" sending a new REGISTER request or alternatively dispose of the current Registerer and create a new Registerer.",this.logger.warn("An attempt was made to send a REGISTER request while a prior one was still in progress. RFC 3261 requires UAs MUST NOT send a new registration until they have received a final response from the registrar for the previous one or the previous REGISTER request has timed out. Note that if the transport disconnects, you still must wait for the prior request to time out before sending a new REGISTER request or alternatively dispose of the current Registerer and create a new Registerer.")}stateError(){let e=`An attempt was made to send a REGISTER request when the Registerer ${this.state===i.Terminated?"is in 'Terminated' state":"has been disposed"}.`;e+=" The Registerer transitions to 'Terminated' when Registerer.dispose() is called.",e+=" Perhaps you called UserAgent.stop() which dipsoses of all Registerers?",this.logger.error(e)}}f.defaultExpires=600,f.defaultRefreshFrequency=99;var m=s(43),v=s(46);class w{constructor(e,t,s,i="text/plain",r={}){this.logger=e.getLogger("sip.Messager"),r.params=r.params||{};let n=e.userAgentCore.configuration.aor;if(r.params.fromUri&&(n="string"==typeof r.params.fromUri?d.a.URIParse(r.params.fromUri):r.params.fromUri),!n)throw new TypeError("Invalid from URI: "+r.params.fromUri);let o=t;if(r.params.toUri&&(o="string"==typeof r.params.toUri?d.a.URIParse(r.params.toUri):r.params.toUri),!o)throw new TypeError("Invalid to URI: "+r.params.toUri);const a=r.params?Object.assign({},r.params):{},c=(r.extraHeaders||[]).slice(),h={contentDisposition:"render",contentType:i,content:s};this.request=e.userAgentCore.makeOutgoingRequestMessage(l.a.MESSAGE,t,n,o,a,c,h),this.userAgent=e}message(e={}){return this.userAgent.userAgentCore.request(this.request,e.requestDelegate),Promise.resolve()}}var b=s(0),y=s(42),T=s(40);s.d(t,"SimpleUser",(function(){return S}));var S=function(){function e(t){var s=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n()(this,e),this.attemptingReconnection=!1,this.connectRequested=!1,this.held=!1,this.muted=!1,this.registerer=void 0,this.registerRequested=!1,this.session=void 0,this.delegate=i.delegate,this.options=Object.assign({},i);var r=Object.assign({},i.userAgentOptions);if(r.transportConstructor||(r.transportConstructor=T.a),r.transportOptions||(r.transportOptions={server:t}),!r.uri&&i.aor){var o=c.a.makeURI(i.aor);if(!o)throw new Error("Failed to create valid URI from ".concat(i.aor));r.uri=o}this.userAgent=new c.a(r),this.userAgent.delegate={onConnect:function(){s.logger.log("[".concat(s.id,"] Connected")),s.delegate&&s.delegate.onServerConnect&&s.delegate.onServerConnect(),s.registerer&&s.registerRequested&&(s.logger.log("[".concat(s.id,"] Registering...")),s.registerer.register().catch((function(e){s.logger.error("[".concat(s.id,"] Error occurred registering after connection with server was obtained.")),s.logger.error(e.toString())})))},onDisconnect:function(e){s.logger.log("[".concat(s.id,"] Disconnected")),s.delegate&&s.delegate.onServerDisconnect&&s.delegate.onServerDisconnect(e),s.session&&(s.logger.log("[".concat(s.id,"] Hanging up...")),s.hangup().catch((function(e){s.logger.error("[".concat(s.id,"] Error occurred hanging up call after connection with server was lost.")),s.logger.error(e.toString())}))),s.registerer&&(s.logger.log("[".concat(s.id,"] Unregistering...")),s.registerer.unregister().catch((function(e){s.logger.error("[".concat(s.id,"] Error occurred unregistering after connection with server was lost.")),s.logger.error(e.toString())}))),e&&s.attemptReconnection()},onInvite:function(e){if(s.logger.log("[".concat(s.id,"] Received INVITE")),s.session)return s.logger.warn("[".concat(s.id,"] Session already in progress, rejecting INVITE...")),void e.reject().then((function(){s.logger.log("[".concat(s.id,"] Rejected INVITE"))})).catch((function(e){s.logger.error("[".concat(s.id,"] Failed to reject INVITE")),s.logger.error(e.toString())}));var t={sessionDescriptionHandlerOptions:{constraints:s.constraints}};s.initSession(e,t),s.delegate&&s.delegate.onCallReceived?s.delegate.onCallReceived():(s.logger.warn("[".concat(s.id,"] No handler available, rejecting INVITE...")),e.reject().then((function(){s.logger.log("[".concat(s.id,"] Rejected INVITE"))})).catch((function(e){s.logger.error("[".concat(s.id,"] Failed to reject INVITE")),s.logger.error(e.toString())})))},onMessage:function(e){e.accept().then((function(){s.delegate&&s.delegate.onMessageReceived&&s.delegate.onMessageReceived(e.request.body)}))}},this.logger=this.userAgent.getLogger("sip.SimpleUser"),window.addEventListener("online",(function(){s.logger.log("[".concat(s.id,"] Online")),s.attemptReconnection()}))}return a()(e,[{key:"id",get:function(){return this.options.userAgentOptions&&this.options.userAgentOptions.displayName||"Anonymous"}},{key:"localMediaStream",get:function(){var e,t=null===(e=this.session)||void 0===e?void 0:e.sessionDescriptionHandler;if(t){if(!(t instanceof y.a))throw new Error("Session description handler not instance of web SessionDescriptionHandler");return t.localMediaStream}}},{key:"remoteMediaStream",get:function(){var e,t=null===(e=this.session)||void 0===e?void 0:e.sessionDescriptionHandler;if(t){if(!(t instanceof y.a))throw new Error("Session description handler not instance of web SessionDescriptionHandler");return t.remoteMediaStream}}},{key:"localAudioTrack",get:function(){var e;return null===(e=this.localMediaStream)||void 0===e?void 0:e.getTracks().find((function(e){return"audio"===e.kind}))}},{key:"localVideoTrack",get:function(){var e;return null===(e=this.localMediaStream)||void 0===e?void 0:e.getTracks().find((function(e){return"video"===e.kind}))}},{key:"remoteAudioTrack",get:function(){var e;return null===(e=this.remoteMediaStream)||void 0===e?void 0:e.getTracks().find((function(e){return"audio"===e.kind}))}},{key:"remoteVideoTrack",get:function(){var e;return null===(e=this.remoteMediaStream)||void 0===e?void 0:e.getTracks().find((function(e){return"video"===e.kind}))}},{key:"connect",value:function(){return this.logger.log("[".concat(this.id,"] Connecting UserAgent...")),this.connectRequested=!0,this.userAgent.state!==h.a.Started?this.userAgent.start():this.userAgent.reconnect()}},{key:"disconnect",value:function(){return this.logger.log("[".concat(this.id,"] Disconnecting UserAgent...")),this.connectRequested=!1,this.userAgent.stop()}},{key:"isConnected",value:function(){return this.userAgent.isConnected()}},{key:"register",value:function(e,t){var s=this;return this.logger.log("[".concat(this.id,"] Registering UserAgent...")),this.registerRequested=!0,this.registerer||(this.registerer=new f(this.userAgent,e),this.registerer.stateChange.addListener((function(e){switch(e){case i.Initial:break;case i.Registered:s.delegate&&s.delegate.onRegistered&&s.delegate.onRegistered();break;case i.Unregistered:s.delegate&&s.delegate.onUnregistered&&s.delegate.onUnregistered();break;case i.Terminated:s.registerer=void 0;break;default:throw new Error("Unknown registerer state.")}}))),this.registerer.register(t).then((function(){}))}},{key:"unregister",value:function(e){return this.logger.log("[".concat(this.id,"] Unregistering UserAgent...")),this.registerRequested=!1,this.registerer?this.registerer.unregister(e).then((function(){})):Promise.resolve()}},{key:"call",value:function(e,t,s){if(this.logger.log("[".concat(this.id,"] Beginning Session...")),this.session)return Promise.reject(new Error("Session already exists."));var i=c.a.makeURI(e);if(!i)return Promise.reject(new Error('Failed to create a valid URI from "'.concat(e,'"')));t||(t={}),t.sessionDescriptionHandlerOptions||(t.sessionDescriptionHandlerOptions={}),t.sessionDescriptionHandlerOptions.constraints||(t.sessionDescriptionHandlerOptions.constraints=this.constraints);var r=new m.a(this.userAgent,i,t);return this.sendInvite(r,t,s).then((function(){return!0}))}},{key:"hangup",value:function(){return this.logger.log("[".concat(this.id,"] Hangup...")),this.terminate()}},{key:"answer",value:function(e){return this.logger.log("[".concat(this.id,"] Accepting Invitation...")),this.session?this.session instanceof v.a?(e||(e={}),e.sessionDescriptionHandlerOptions||(e.sessionDescriptionHandlerOptions={}),e.sessionDescriptionHandlerOptions.constraints||(e.sessionDescriptionHandlerOptions.constraints=this.constraints),this.session.accept(e)):Promise.reject(new Error("Session not instance of Invitation.")):Promise.reject(new Error("Session does not exist."))}},{key:"decline",value:function(){return this.logger.log("[".concat(this.id,"] rejecting Invitation...")),this.session?this.session instanceof v.a?this.session.reject():Promise.reject(new Error("Session not instance of Invitation.")):Promise.reject(new Error("Session does not exist."))}},{key:"hold",value:function(){return this.logger.log("[".concat(this.id,"] holding session...")),this.setHold(!0)}},{key:"unhold",value:function(){return this.logger.log("[".concat(this.id,"] unholding session...")),this.setHold(!1)}},{key:"isHeld",value:function(){return this.held}},{key:"mute",value:function(){this.logger.log("[".concat(this.id,"] disabling media tracks...")),this.setMute(!0)}},{key:"unmute",value:function(){this.logger.log("[".concat(this.id,"] enabling media tracks...")),this.setMute(!1)}},{key:"isMuted",value:function(){return this.muted}},{key:"sendDTMF",value:function(e){if(this.logger.log("[".concat(this.id,"] sending DTMF...")),!/^[0-9A-D#*,]$/.exec(e))return Promise.reject(new Error("Invalid DTMF tone."));if(!this.session)return Promise.reject(new Error("Session does not exist."));this.logger.log("[".concat(this.id,"] Sending DTMF tone: ").concat(e));var t={body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal="+e+"\r\nDuration=2000"}};return this.session.info({requestOptions:t}).then((function(){}))}},{key:"message",value:function(e,t){this.logger.log("[".concat(this.id,"] sending message..."));var s=c.a.makeURI(e);return s?new w(this.userAgent,s,t).message():Promise.reject(new Error('Failed to create a valid URI from "'.concat(e,'"')))}},{key:"constraints",get:function(){var e,t={audio:!0,video:!1};return(null===(e=this.options.media)||void 0===e?void 0:e.constraints)&&(t=Object.assign({},this.options.media.constraints)),t}},{key:"attemptReconnection",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,s=this.options.reconnectionAttempts||3,i=this.options.reconnectionDelay||4;if(this.connectRequested){if(this.attemptingReconnection&&this.logger.log("[".concat(this.id,"] Reconnection attempt already in progress")),t>s)return this.options&&this.options.onFailedReconnect&&this.options.onFailedReconnect(),void this.logger.log("[".concat(this.id,"] Reconnection maximum attempts reached"));1===t?this.logger.log("[".concat(this.id,"] Reconnection attempt ").concat(t," of ").concat(s," - trying")):this.logger.log("[".concat(this.id,"] Reconnection attempt ").concat(t," of ").concat(s," - trying in ").concat(i," seconds")),this.attemptingReconnection=!0,setTimeout((function(){if(!e.connectRequested)return e.logger.log("[".concat(e.id,"] Reconnection attempt ").concat(t," of ").concat(s," - aborted")),void(e.attemptingReconnection=!1);e.userAgent.reconnect().then((function(){e.logger.log("[".concat(e.id,"] Reconnection attempt ").concat(t," of ").concat(s," - succeeded")),e.attemptingReconnection=!1})).catch((function(i){e.logger.log("[".concat(e.id,"] Reconnection attempt ").concat(t," of ").concat(s," - failed")),e.logger.error(i.message),e.attemptingReconnection=!1,e.attemptReconnection(++t)}))}),1===t?0:1e3*i)}else this.logger.log("[".concat(this.id,"] Reconnection not currently desired"))}},{key:"cleanupMedia",value:function(){this.options.media&&(this.options.media.local&&this.options.media.local.video&&(this.options.media.local.video.srcObject=null,this.options.media.local.video.pause()),this.options.media.remote&&(this.options.media.remote.audio&&(this.options.media.remote.audio.srcObject=null,this.options.media.remote.audio.pause()),this.options.media.remote.video&&(this.options.media.remote.video.srcObject=null,this.options.media.remote.video.pause())))}},{key:"enableReceiverTracks",value:function(e){if(!this.session)throw new Error("Session does not exist.");var t=this.session.sessionDescriptionHandler;if(!(t instanceof y.a))throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");var s=t.peerConnection;if(!s)throw new Error("Peer connection closed.");s.getReceivers().forEach((function(t){t.track&&(t.track.enabled=e)}))}},{key:"enableSenderTracks",value:function(e){if(!this.session)throw new Error("Session does not exist.");var t=this.session.sessionDescriptionHandler;if(!(t instanceof y.a))throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");var s=t.peerConnection;if(!s)throw new Error("Peer connection closed.");s.getSenders().forEach((function(t){t.track&&(t.track.enabled=e)}))}},{key:"initSession",value:function(e,t){var s=this;this.session=e,this.delegate&&this.delegate.onCallCreated&&this.delegate.onCallCreated(),this.session.stateChange.addListener((function(t){if(s.session===e)switch(s.logger.log("[".concat(s.id,"] session state changed to ").concat(t)),t){case b.a.Initial:case b.a.Establishing:break;case b.a.Established:s.setupLocalMedia(),s.setupRemoteMedia(),s.delegate&&s.delegate.onCallAnswered&&s.delegate.onCallAnswered();break;case b.a.Terminating:case b.a.Terminated:s.session=void 0,s.cleanupMedia(),s.delegate&&s.delegate.onCallHangup&&s.delegate.onCallHangup();break;default:throw new Error("Unknown session state.")}})),this.session.delegate={onInfo:function(e){var t;if(void 0!==(null===(t=s.delegate)||void 0===t?void 0:t.onCallDTMFReceived)){var i=e.request.getHeader("content-type");if(i&&/^application\/dtmf-relay/i.exec(i)){var r=e.request.body.split("\r\n",2);if(2===r.length){var n,o=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/;if(o.test(r[0])&&(n=r[0].replace(o,"$2")),n){var a,c=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;c.test(r[1])&&(a=parseInt(r[1].replace(c,"$2"),10)),a?e.accept().then((function(){if(s.delegate&&s.delegate.onCallDTMFReceived){if(!n||!a)throw new Error("Tone or duration undefined.");s.delegate.onCallDTMFReceived(n,a)}})).catch((function(e){s.logger.error(e.message)})):e.reject()}else e.reject()}else e.reject()}else e.reject()}else e.reject()},onRefer:function(e){e.accept().then((function(){return s.sendInvite(e.makeInviter(t),t)})).catch((function(e){s.logger.error(e.message)}))}}}},{key:"sendInvite",value:function(e,t,s){var i=this;return this.initSession(e,t),e.invite(s).then((function(){i.logger.log("[".concat(i.id,"] sent INVITE"))}))}},{key:"setHold",value:function(e){var t=this;if(!this.session)return Promise.reject(new Error("Session does not exist."));var s=this.session;if(this.held===e)return Promise.resolve();if(!(this.session.sessionDescriptionHandler instanceof y.a))throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");var i={requestDelegate:{onAccept:function(){t.held=e,t.enableReceiverTracks(!t.held),t.enableSenderTracks(!t.held&&!t.muted),t.delegate&&t.delegate.onCallHold&&t.delegate.onCallHold(t.held)},onReject:function(){t.logger.warn("[".concat(t.id,"] re-invite request was rejected")),t.enableReceiverTracks(!t.held),t.enableSenderTracks(!t.held&&!t.muted),t.delegate&&t.delegate.onCallHold&&t.delegate.onCallHold(t.held)}}},r=s.sessionDescriptionHandlerOptionsReInvite;return r.hold=e,s.sessionDescriptionHandlerOptionsReInvite=r,this.session.invite(i).then((function(){t.enableReceiverTracks(!e),t.enableSenderTracks(!e&&!t.muted)})).catch((function(e){throw e instanceof p.a&&t.logger.error("[".concat(t.id,"] A hold request is already in progress.")),e}))}},{key:"setMute",value:function(e){this.session?this.session.state===b.a.Established?(this.muted=e,this.enableSenderTracks(!this.held&&!this.muted)):this.logger.warn("[".concat(this.id,"] An established session is required to enable/disable media tracks")):this.logger.warn("[".concat(this.id,"] A session is required to enabled/disable media tracks"))}},{key:"setupLocalMedia",value:function(){var e,t,s=this;if(!this.session)throw new Error("Session does not exist.");var i=null===(t=null===(e=this.options.media)||void 0===e?void 0:e.local)||void 0===t?void 0:t.video;if(i){var r=this.localMediaStream;if(!r)throw new Error("Local media stream undefiend.");i.srcObject=r,i.volume=0,i.play().catch((function(e){s.logger.error("[".concat(s.id,"] Failed to play local media")),s.logger.error(e.message)}))}}},{key:"setupRemoteMedia",value:function(){var e,t,s,i,r=this;if(!this.session)throw new Error("Session does not exist.");var n=(null===(t=null===(e=this.options.media)||void 0===e?void 0:e.remote)||void 0===t?void 0:t.video)||(null===(i=null===(s=this.options.media)||void 0===s?void 0:s.remote)||void 0===i?void 0:i.audio);if(n){var o=this.remoteMediaStream;if(!o)throw new Error("Remote media stream undefiend.");n.autoplay=!0,n.srcObject=o,n.play().catch((function(e){r.logger.error("[".concat(r.id,"] Failed to play remote media")),r.logger.error(e.message)})),o.onaddtrack=function(){r.logger.log("[".concat(r.id,"] Remote media onaddtrack")),n.load(),n.play().catch((function(e){r.logger.error("[".concat(r.id,"] Failed to play remote media")),r.logger.error(e.message)}))}}}},{key:"terminate",value:function(){var e=this;if(this.logger.log("[".concat(this.id,"] Terminating...")),!this.session)return Promise.reject(new Error("Session does not exist."));switch(this.session.state){case b.a.Initial:if(this.session instanceof m.a)return this.session.cancel().then((function(){e.logger.log("[".concat(e.id,"] Inviter never sent INVITE (canceled)"))}));if(this.session instanceof v.a)return this.session.reject().then((function(){e.logger.log("[".concat(e.id,"] Invitation rejected (sent 480)"))}));throw new Error("Unknown session type.");case b.a.Establishing:if(this.session instanceof m.a)return this.session.cancel().then((function(){e.logger.log("[".concat(e.id,"] Inviter canceled (sent CANCEL)"))}));if(this.session instanceof v.a)return this.session.reject().then((function(){e.logger.log("[".concat(e.id,"] Invitation rejected (sent 480)"))}));throw new Error("Unknown session type.");case b.a.Established:return this.session.bye().then((function(){e.logger.log("[".concat(e.id,"] Session ended (sent BYE)"))}));case b.a.Terminating:case b.a.Terminated:break;default:throw new Error("Unknown state")}return this.logger.log("[".concat(this.id,"] Terminating in state ").concat(this.session.state,", no action taken")),Promise.resolve()}}]),e}()},,,function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s(19);class r extends i.a{constructor(e){super(e||"Request pending.")}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return a})),s.d(t,"c",(function(){return c})),s.d(t,"b",(function(){return h}));var i=s(25),r=s(20),n=s(44);function o(e){return"application/sdp"===e?"session":"render"}function a(e){const t="string"==typeof e?e:e.body,s="string"==typeof e?"application/sdp":e.contentType;return{contentDisposition:o(s),contentType:s,content:t}}function c(e){return!(!e||"string"!=typeof e.content||"string"!=typeof e.contentType||void 0!==e.contentDisposition)||"string"==typeof e.contentDisposition}function h(e){let t,s,a;if(e instanceof i.a&&e.body){const i=e.parseHeader("Content-Disposition");t=i?i.type:void 0,s=e.parseHeader("Content-Type"),a=e.body}if(e instanceof r.a&&e.body){const i=e.parseHeader("Content-Disposition");t=i?i.type:void 0,s=e.parseHeader("Content-Type"),a=e.body}if(e instanceof n.a&&e.body)if(t=e.getHeader("Content-Disposition"),s=e.getHeader("Content-Type"),"string"==typeof e.body){if(!s)throw new Error("Header content type header does not equal body content type.");a=e.body}else{if(s&&s!==e.body.contentType)throw new Error("Header content type header does not equal body content type.");s=e.body.contentType,a=e.body.body}if(c(e)&&(t=e.contentDisposition,s=e.contentType,a=e.content),a){if(s&&!t&&(t=o(s)),!t)throw new Error("Content disposition undefined.");if(!s)throw new Error("Content type undefined.");return{contentDisposition:t,contentType:s,content:a}}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s(19);class r extends i.a{constructor(e){super(e||"Unsupported content type.")}}},function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var i=s(19);class r extends i.a{constructor(e){super(e||"Transaction state error.")}}}])}));
|