@94ai/softphone 4.0.1 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import e from"@babel/runtime-corejs3/helpers/esm/classCallCheck";import t from"@babel/runtime-corejs3/helpers/esm/createClass";import{UserAgent as n,SessionState as i,Registerer as r}from"sip.js";export{Inviter,Registerer,SessionState,URI,UserAgent}from"sip.js";export{SimpleUser}from"sip.js/lib/platform/web/index.js";import s from"on-change";export{default as onChange}from"on-change";import o from"@babel/runtime-corejs3/helpers/esm/typeof";import a from"@babel/runtime-corejs3/regenerator";import c from"@babel/runtime-corejs3/core-js/json/stringify";import u from"@babel/runtime-corejs3/core-js/object/define-property";import f from"@babel/runtime-corejs3/core-js/date/now";import l from"@babel/runtime-corejs3/core-js/instance/for-each";import h from"@babel/runtime-corejs3/core-js/set-timeout";import d from"@babel/runtime-corejs3/core-js/set-interval";import p from"@babel/runtime-corejs3/core-js/promise";import v from"@babel/runtime-corejs3/core-js/object/assign";import m from"@babel/runtime-corejs3/core-js/instance/concat";import g from"@babel/runtime-corejs3/core-js/instance/map";import w from"@babel/runtime-corejs3/core-js/instance/index-of";import k from"@babel/runtime-corejs3/core-js/instance/filter";import b from"@babel/runtime-corejs3/core-js/weak-map";import x from"@babel/runtime-corejs3/core-js/weak-set";import y from"@babel/runtime-corejs3/core-js/object/keys";import S from"@babel/runtime-corejs3/core-js/instance/pad-start";import A from"@babel/runtime-corejs3/core-js/instance/slice";import I from"crypto-js";import T from"@fingerprintjs/fingerprintjs";function j(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function C(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function O(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var E,D;"function"==typeof SuppressedError&&SuppressedError;var R,N,q,P,H=m(E="sip:".concat("","@")).call(E,""),M=m(D="".concat("","://")).call(D,""),U={authorizationPassword:"",authorizationUsername:"",viaHost:"",uri:n.makeURI(H),logLevel:"error",transportOptions:{server:M},contactName:""},z={connectStatus:!1,registerStatus:!1,invitatingStatus:!1,incomingStatus:!1,answerStatus:!1,reconnectStatus:!1};function L(e){return document.getElementById(e)}function X(e){if(e&&e.getTracks)try{var t=e.getTracks();l(t).call(t,(function(e){try{e.stop()}catch(e){}}))}catch(e){}}function G(e){return navigator.mediaDevices.getUserMedia(e).then((function(e){return e?(X(e),!0):p.reject(new Error("EmptyStreamError"))})).catch((function(e){return(!e||"NotAllowedError"!==e.name)&&p.reject(e)}))}function F(){try{var e;if(-1===w(e=navigator.userAgent).call(e,"Firefox"))return G({video:!1,audio:!0}).catch((function(){return!0}))}catch(e){console.log(e)}}function _(e){var t=L(e);t&&(t.currentTime=0,t.play())}function B(e){var t=L(e);t&&(t.currentTime=0,t.pause())}function Y(e){var t=L(e);t&&(t.srcObject=null,t.pause())}!function(e){e.NO="0",e.YES="1"}(R||(R={})),function(e){e.NO="0",e.YES="1"}(N||(N={})),function(e){e.MULTI_AI="1",e.MULTI_VOICE_NOTIFY="2",e.MULTI_PRETEST="3",e.LABOUR="4",e.AI="5",e.NEW_VOICE_NOTIFY="6"}(q||(q={})),function(e){e.DIRECT_ANSWER="1",e.LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY="2"}(P||(P={}));var V,J,W,Z,K,$,Q,ee,te,ne,ie,re,se,oe,ae,ce,ue,fe,le,he,de,pe,ve,me,ge,we,ke,be,xe,ye,Se,Ae,Ie,Te,je,Ce,Oe,Ee,De,Re,Ne,qe,Pe,He,Me,Ue,ze,Le,Xe,Ge,Fe,_e,Be,Ye,Ve,Je,We,Ze,Ke,$e,Qe,et,tt,nt,it,rt,st,ot,at,ct,ut,ft,lt,ht,dt,pt,vt,mt,gt,wt,kt,bt,xt,yt,St,At,It,Tt,jt,Ct,Ot,Et,Dt,Rt,Nt,qt,Pt,Ht,Mt,Ut,zt,Lt,Xt,Gt,Ft,_t,Bt,Yt,Vt,Jt,Wt,Zt,Kt,$t,Qt,en=function(e){var t,n,i;return S(t=e.getHours().toString()).call(t,2,"0")+":"+S(n=e.getMinutes().toString()).call(n,2,"0")+":"+S(i=e.getSeconds().toString()).call(i,2,"0")},tn=function(){return new Date(new Date((new Date).toLocaleDateString()).getTime())},nn=function(e){return new Date(e.setSeconds(e.getSeconds()+1))};function rn(e){var t=tn();e(en(t));var n=d((function(){var n=nn(t),i=en(n);e(i)}),1e3);return function(){clearInterval(n),n=null}}function sn(e,t,n){var i=window.XMLHttpRequest?new window.XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):void 0;i||t(new Error("Your Browser does not support ajax")),i.onreadystatechange=function(){if(4==i.readyState){var n=i.response||i.responseText;if(200==i.status){var r=i.getResponseHeader("Content-Type");-1!=w(r).call(r,"json")?e(JSON.parse(i.responseText)):-1!=w(r).call(r,"xml")?e(i.responseXML):e(i.responseText)}else t(n)}};var r=n.url,s=n.data,o=n.type,a=n.contentType,u=o||"POST",f=r,l=null;return s&&("GET"===u?f=f+"?"+function(e){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join("&")}(s):"POST"===u&&(l=c(s))),i.open(u,f,!0),{xhr:i,ajaxData:l,contentType:a}}var on,an,cn=function(){function r(){var t=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e(this,r),V.add(this),J.set(this,void 0),W.set(this,void 0),Z.set(this,void 0),K.set(this,void 0),$.set(this,void 0),Q.set(this,[]),ee.set(this,[]),te.set(this,{}),ne.set(this,void 0),ie.set(this,void 0),re.set(this,new MediaStream),se.set(this,JSON.parse(c(z))),oe.set(this,0),ae.set(this,void 0),ce.set(this,void 0),ue.set(this,void 0),u(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),fe.set(this,void 0),le.set(this,48e4),he.set(this,12e6),de.set(this,{}),pe.set(this,void 0),ve.set(this,void 0),me.set(this,void 0),ge.set(this,(function(e){})),we.set(this,(function(e){})),ke.set(this,(function(e){})),be.set(this,(function(e){})),xe.set(this,(function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,ae,"f")||!C(this,ce,"f")){t.next=9;break}if(!(f()-C(this,ce,"f")>e)){t.next=9;break}return t.next=4,C(this,Se,"f").call(this);case 4:n=t.sent,i=n.sign,r=n.timestamp,O(this,ae,null!=i?i:C(this,ae,"f"),"f"),O(this,ce,null!=r?r:C(this,ce,"f"),"f");case 9:case"end":return t.stop()}}),t,this)})))})),ye.set(this,(function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i,r,s,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,fe,"f")){t.next=19;break}if(!(f()-C(this,fe,"f")>e)){t.next=19;break}if(!C(this,ue,"f")){t.next=12;break}return t.next=5,C(this,Ae,"f").call(this);case 5:n=t.sent,i=n.token,r=n.tokenTimestamp,O(this,ue,null!=i?i:C(this,ue,"f"),"f"),O(this,fe,null!=r?r:f(),"f"),t.next=19;break;case 12:if(!this.token){t.next=19;break}return t.next=15,this.getGatewayAccessToken({corpId:C(this,Ve,"f"),sid:C(this,Ze,"f"),secret:C(this,Je,"f"),seatOnline:!1});case 15:s=t.sent,o=s.token,this.token=o,O(this,fe,f(),"f");case 19:case"end":return t.stop()}}),t,this)})))})),Se.set(this,(function(){})),Ae.set(this,(function(){})),Ie.set(this,(function(e){})),Te.set(this,(function(e){})),je.set(this,void 0),Ce.set(this,void 0),u(this,"networkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:"0.00Mb/s"}),u(this,"networkDelay",{enumerable:!0,configurable:!0,writable:!0,value:"0ms"}),u(this,"onLine",{enumerable:!0,configurable:!0,writable:!0,value:navigator.onLine}),u(this,"testspeeding",{enumerable:!0,configurable:!0,writable:!0,value:!1}),u(this,"goodNetworkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:function(){return 1e3*Number(t.networkSpeed.replace("Mb/s",""))>=30}}),u(this,"goodNetworkDelay",{enumerable:!0,configurable:!0,writable:!0,value:function(){return Number(t.networkDelay.replace("ms",""))<=500&&"0ms"!==t.networkDelay}}),u(this,"authorizedMicrophonePermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),u(this,"authorizedNotificationPermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Oe.set(this,100),Ee.set(this,3),De.set(this,8),Re.set(this,3),Ne.set(this,0),qe.set(this,!1),Pe.set(this,void 0),He.set(this,3),Me.set(this,3),Ue.set(this,0),ze.set(this,0),Le.set(this,0),Xe.set(this,!1),Ge.set(this,!1),Fe.set(this,!1),_e.set(this,void 0),Be.set(this,void 0),Ye.set(this,void 0),Ve.set(this,void 0),Je.set(this,void 0),We.set(this,void 0),Ze.set(this,void 0),Ke.set(this,void 0),$e.set(this,void 0),Qe.set(this,void 0),et.set(this,void 0),tt.set(this,(function(e){C(t,V,"m",Wt).call(t)})),nt.set(this,(function(){})),it.set(this,{}),rt.set(this,!1),st.set(this,!0),u(this,"ifAutoAnswer",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,it,"f").autoAnswer)===R.YES}}),u(this,"notNeedSendStarDtmf",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,it,"f").afterTransferLabour)===P.DIRECT_ANSWER}}),ot.set(this,(function(){if(C(t,st,"f")){var e;C(t,at,"f").call(t);var n=new(window.AudioContext||window.webkitAudioContext);O(t,ve,n.createScriptProcessor(2048,1,1),"f"),C(t,ve,"f").onaudioprocess=function(e){for(var n=e.inputBuffer.getChannelData(0),i=0,r=0;r<n.length;++r)i+=n[r]*n[r];O(t,oe,Number(Math.sqrt(i/n.length).toFixed(2)),"f"),C(t,ge,"f").call(t,C(t,oe,"f"))},O(t,me,new MediaStream,"f"),l(e=t.getSenders()).call(e,(function(e){e.track&&C(t,me,"f").addTrack(e.track)})),O(t,pe,n.createMediaStreamSource(C(t,me,"f")),"f"),C(t,pe,"f").connect(C(t,ve,"f")),C(t,ve,"f").connect(n.destination)}})),at.set(this,(function(){if(C(t,st,"f")){if(C(t,pe,"f"))try{C(t,pe,"f").disconnect()}catch(e){console.log(e)}if(C(t,ve,"f"))try{C(t,ve,"f").disconnect()}catch(e){console.log(e)}if(C(t,me,"f"))try{var e;l(e=C(t,me,"f").getTracks()).call(e,(function(e){e.stop()}))}catch(e){console.log(e)}}O(t,pe,void 0,"f"),O(t,ve,void 0,"f"),O(t,me,void 0,"f"),O(t,oe,0,"f"),C(t,ge,"f").call(t,C(t,oe,"f"))})),u(this,"disposeSoftphoneEnvRequirementCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){C(t,ct,"f").call(t),window.removeEventListener("offline",C(t,lt,"f")),window.removeEventListener("online",C(t,ft,"f")),window.removeEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)}}),ct.set(this,(function(){clearInterval(C(t,je,"f")),O(t,je,void 0,"f"),clearTimeout(C(t,Ce,"f")),O(t,Ce,void 0,"f"),t.testspeeding=!1})),u(this,"softphoneEnvCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){return j(t,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding||(C(this,ut,"f").call(this),this.oneRoundOfTesting());case 1:case"end":return e.stop()}}),e,this)})))}}),ut.set(this,(function(){window.addEventListener("offline",C(t,lt,"f")),window.addEventListener("online",C(t,ft,"f")),window.addEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)})),u(this,"oneRoundOfTesting",{enumerable:!0,configurable:!0,writable:!0,value:function(){return j(t,void 0,void 0,a.mark((function e(){var t=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding=!0,this.detectNavigatorPermissions(),this.onLine?(C(this,ht,"f").call(this,this),O(this,Ce,h((function(){t.testspeeding=!1,t.disposeSoftphoneEnvRequirementCheck()}),4e3),"f")):this.testspeeding=!1;case 3:case"end":return e.stop()}}),e,this)})))}}),ft.set(this,(function(){t.onLine=!0,t.oneRoundOfTesting()})),lt.set(this,(function(){t.onLine=!1,t.networkSpeed="0.00Mb/s",t.networkDelay="0ms",C(t,Te,"f").call(t,{networkSpeed:t.networkSpeed,networkDelay:t.networkDelay,authorizedMicrophonePermissions:t.authorizedMicrophonePermissions,authorizedNotificationPermissions:t.authorizedNotificationPermissions}),C(t,ct,"f").call(t)})),ht.set(this,(function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i,r=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e||this,clearInterval(C(n,je,"f")),O(n,je,void 0,"f"),i=function(){return j(r,void 0,void 0,a.mark((function e(){var t;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.onLine){e.next=15;break}return e.prev=1,e.next=4,C(n,dt,"f").call(n);case 4:t=e.sent,n.networkSpeed=t.networkSpeed,n.networkDelay=t.networkDelay,e.next=13;break;case 9:e.prev=9,e.t0=e.catch(1),n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 13:e.next=17;break;case 15:n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 17:C(this,Te,"f").call(this,{networkSpeed:this.networkSpeed,networkDelay:this.networkDelay,authorizedMicrophonePermissions:this.authorizedMicrophonePermissions,authorizedNotificationPermissions:this.authorizedNotificationPermissions}),C(this,Ce,"f")||(this.testspeeding=!1,this.disposeSoftphoneEnvRequirementCheck());case 19:case"end":return e.stop()}}),e,this,[[1,9]])})))},t.next=6,i();case 6:C(this,Ce,"f")&&O(n,je,d((function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i();case 2:case"end":return e.stop()}}),e)})))}),1e3),"f");case 7:case"end":return t.stop()}}),t,this)})))})),dt.set(this,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return j(t,void 0,void 0,a.mark((function t(){var r,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=[],s=0;s<i;s++)r.push(C(this,pt,"f").call(this,e+"?d="+f()+s,n));return t.abrupt("return",p.all(r).then((function(e){var t=0,n=0;return l(e).call(e,(function(e){t+=Number(e[0]),n+=Number(e[1])})),{networkDelay:(n/i).toFixed(2)+"ms",networkSpeed:(t/i).toFixed(2)+"Mb/s"}})));case 3:case"end":return t.stop()}}),t,this)})))})),pt.set(this,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png?d="+f(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491;return new p((function(n,i){var r=document.createElement("img");r.start=window.performance.now(),r.onload=function(){var e=window.performance.now()-r.start;n([(1e3*t/(1048576*e)).toFixed(2),e])},r.onerror=function(e){i(e)},r.src=e})).catch((function(e){throw e}))})),u(this,"openApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return new p((function(n,i){return j(t,void 0,void 0,a.mark((function t(){var r,s,o,c,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=sn(n,i,e),s=r.xhr,o=r.ajaxData,c=r.contentType,t.next=3,this.getOpenApiSign();case 3:return u=t.sent,f=u.timestamp,l=u.sign,s.setRequestHeader("appKey",C(this,Ve,"f")),s.setRequestHeader("timestamp",String(f)),s.setRequestHeader("sign",l),s.setRequestHeader("Content-type",c||"application/json"),t.next=12,C(this,ke,"f").call(this,s);case 12:s.send(o);case 13:case"end":return t.stop()}}),t,this)})))}))}}),u(this,"requestGateway",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.gatewayApiAjax(v(v({},e),{url:t.getGateway()+e.url}),n)}}),u(this,"gatewayApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new p((function(i,r){return j(t,void 0,void 0,a.mark((function t(){var s,o,c,u,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=sn(i,r,e),o=s.xhr,c=s.ajaxData,u=s.contentType,!n){t.next=8;break}return t.next=4,this.getGatewayToken();case 4:f=t.sent,o.setRequestHeader("x-token",f),o.setRequestHeader("seatsToken",f),o.setRequestHeader("x-authority-token",f);case 8:return o.setRequestHeader("x-app-code",3),o.setRequestHeader("content-type",u||"application/json"),t.next=12,C(this,be,"f").call(this,o);case 12:o.send(c);case 13:case"end":return t.stop()}}),t,this)})))}))}}),u(this,"requestOpenApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.openApiAjax(v(v({},e),{url:t.getOpenApi()+e.url}))}}),u(this,"getDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:function(){return j(t,void 0,void 0,a.mark((function e(){var t,n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,et,"f")){e.next=2;break}return e.abrupt("return",C(this,et,"f"));case 2:return e.next=4,T.load();case 4:return t=e.sent,e.next=7,t.get();case 7:return n=e.sent,O(this,et,n.visitorId,"f"),e.abrupt("return",C(this,et,"f"));case 10:case"end":return e.stop()}}),e,this)})))}}),xt.set(this,(function(){return j(t,void 0,void 0,a.mark((function e(){var t,i,r,s;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,V,"m",bt).call(this)||C(this,te,"f").authorizationUsername&&C(this,te,"f").uri&&C(this,te,"f").authorizationPassword&&C(this,te,"f").transportOptions.server){e.next=15;break}return e.next=3,this.getAgentInfo();case 3:if(200!=(t=e.sent).code){e.next=14;break}s=t.data,C(this,te,"f").authorizationUsername=s.agentExtension,C(this,te,"f").authorizationPassword=s.extensionPwd,C(this,te,"f").uri=n.makeURI(m(i="sip:".concat(s.agentExtension,"@")).call(i,s.wsRegisterAddress)),C(this,te,"f").transportOptions.server=m(r="".concat(s.wsProtocol,"://")).call(r,s.wsRegisterAddress),O(this,Ze,s.agentId,"f"),O(this,We,s.agentTag,"f"),e.next=15;break;case 14:throw new Error(t);case 15:case"end":return e.stop()}}),e,this)})))})),yt.set(this,(function(){return j(t,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(C(this,te,"f").viaHost){e.next=6;break}return e.t0="",e.next=4,this.getDeviceId();case 4:e.t1=e.sent,C(this,te,"f").viaHost=m(e.t0).call(e.t0,e.t1,".sip");case 6:case"end":return e.stop()}}),e,this)})))})),St.set(this,(function(e){var n,i,r,s,o,a,c,u,f,l,h,d,p,v,m,w,k,b;C(t,it,"f").popWindow=null===(s=e["X-Popwindow"])||void 0===s?void 0:s[0].raw,C(t,it,"f").afterTransferLabour=null===(o=e["X-Aftertransferlabour"])||void 0===o?void 0:o[0].raw,C(t,it,"f").callId=null===(a=e["X-94callid"])||void 0===a?void 0:a[0].raw,C(t,it,"f").cid=null===(c=e["X-Cid"])||void 0===c?void 0:c[0].raw,C(t,it,"f").numberId=null===(u=e["X-Numberid"])||void 0===u?void 0:u[0].raw,C(t,it,"f").taskId=null===(f=e["X-Taskid"])||void 0===f?void 0:f[0].raw,C(t,it,"f").voiceType=null===(l=e["X-Voicetype"])||void 0===l?void 0:l[0].raw,C(t,it,"f").processTime=null===(h=e["X-Processtime"])||void 0===h?void 0:h[0].raw,C(t,it,"f").userPhone=null===(d=e["X-Userphone"])||void 0===d?void 0:d[0].raw,C(t,it,"f").autoAnswer=null===(p=e["X-94autoanswer"])||void 0===p?void 0:p[0].raw,C(t,it,"f").nodeTitle=null===(v=e["X-Nodetitle"])||void 0===v?void 0:g(n=v[0].raw.split("-")).call(n,(function(e){return String.fromCharCode(e)})).join(""),C(t,it,"f").taskName=null===(m=e["X-Taskname"])||void 0===m?void 0:g(i=m[0].raw.split("-")).call(i,(function(e){return String.fromCharCode(e)})).join(""),C(t,it,"f").templateTitle=null===(w=e["X-Templatetitle"])||void 0===w?void 0:g(r=w[0].raw.split("-")).call(r,(function(e){return String.fromCharCode(e)})).join(""),C(t,it,"f").phoneNumber=(null===(k=e["X-Phonenumber"])||void 0===k?void 0:k[0].raw)||(null===(b=e.From)||void 0===b?void 0:b[0].parsed.uri.normal.user)})),Mt.set(this,(function(e){switch(e){case i.Initial:case i.Establishing:break;case i.Established:C(t,V,"m",Ht).call(t);break;case i.Terminating:case i.Terminated:var n=h((function(){clearTimeout(n),n=void 0,C(t,se,"f").incomingStatus=!1}),10);C(t,at,"f").call(t);break;default:throw new Error("Unknown session state.")}})),zt.set(this,(function(e,n,i){C(t,De,"f")&&(O(t,qe,!1,"f"),C(t,se,"f").reconnectStatus=!1,C(t,Ge,"f")&&(O(t,Ge,!1,"f"),C(t,Gt,"f").call(t,e,n,i)))})),Lt.set(this,(function(){return j(t,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,De,"f")){e.next=15;break}return O(this,qe,!0,"f"),O(this,Ge,!1,"f"),e.next=5,this.getUserAgent().transport.disconnect().catch((function(e){return console.error(e)}));case 5:return console.log("sip transport disconnect"),e.prev=6,e.next=9,C(this,V,"m",Ut).call(this);case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(6);case 13:C(this,Ft,"f").call(this),C(this,V,"m",Wt).call(this);case 15:case"end":return e.stop()}}),e,this,[[6,11]])})))})),Xt.set(this,(function(){if(C(t,De,"f")){var e=C(t,te,"f").uri.clone(),n=C(t,te,"f").uri.clone(),i=C(t,te,"f").uri.clone();i.user=void 0,C(t,Gt,"f").call(t,i,e,n)}})),Gt.set(this,(function(e,n,i){if(C(t,De,"f")){if(C(t,Ge,"f"))return;O(t,Ge,!0,"f"),O(t,Be,h((function(){C(t,V,"m",Vt).call(t);var r=t.getUserAgent().userAgentCore,s=r.makeOutgoingRequestMessage("OPTIONS",e,n,i,{});O(t,Pe,r.request(s,{onAccept:function(){console.log("sip ping ok"),O(t,Ne,0,"f"),O(t,Pe,void 0,"f"),C(t,zt,"f").call(t,e,n,i)},onReject:function(r){var s;if(O(t,Pe,void 0,"f"),408===r.message.statusCode||503===r.message.statusCode)if(console.log("sip ping error with code "+r.message.statusCode),C(t,Re,"f")>0&&C(t,Ne,"f")>=C(t,Re,"f"))console.log("sip maximum ping attempts reached"),C(t,Lt,"f").call(t);else{var o,a;if(C(t,Ne,"f")>0)console.log(m(a="sip ping retry ".concat(C(t,Ne,"f")," of ")).call(a,C(t,Re,"f")," fail"));O(t,Ne,(s=C(t,Ne,"f"),++s),"f"),console.log(m(o="sip ping retry ".concat(C(t,Ne,"f")," of ")).call(o,C(t,Re,"f"))),C(t,zt,"f").call(t,e,n,i)}else O(t,Ne,0,"f"),C(t,zt,"f").call(t,e,n,i)}}),"f")}),1e3*C(t,De,"f")),"f")}})),Ft.set(this,(function(){if(C(t,De,"f")){if(O(t,Ge,!1,"f"),O(t,qe,!1,"f"),C(t,Pe,"f")){try{C(t,Pe,"f").dispose()}catch(e){}O(t,Pe,void 0,"f")}C(t,Be,"f")&&C(t,V,"m",Vt).call(t)}})),Jt.set(this,(function(){if(C(t,He,"f")){if(C(t,Fe,"f"))return;O(t,Fe,!0,"f"),C(t,se,"f").reconnectStatus=!0,O(t,Ye,h((function(){return j(t,void 0,void 0,a.mark((function e(){var t=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,C(this,V,"m",Bt).call(this),0===C(this,Ue,"f")&&console.log("sip reconnect success then register start"),e.next=5,C(this,Z,"f").register({requestDelegate:{onAccept:function(e){console.log("sip reconnect success and register ok"),O(t,Ue,0,"f"),O(t,Fe,!1,"f"),C(t,se,"f").registerStatus=!0,C(t,se,"f").reconnectStatus=!1,C(t,Xt,"f").call(t)},onReject:function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log("sip reconnect success but register fail with code "+e.message.statusCode),O(this,Fe,!1,"f"),!(C(this,Me,"f")<=C(this,Ue,"f"))){t.next=10;break}return console.log("sip maximum register attempts reached"),O(this,Ue,0,"f"),t.next=7,this.getUserAgent().transport.disconnect().catch((function(e){return console.error(e)}));case 7:C(this,V,"m",Wt).call(this),t.next=13;break;case 10:O(this,Ue,(n=C(this,Ue,"f"),++n),"f"),console.log(m(i="sip reconnect success and register retry ".concat(C(this,Ue,"f")," of ")).call(i,C(this,Me,"f"))),C(this,Jt,"f").call(this);case 13:case"end":return t.stop()}}),t,this)})))}},requestOptions:{extraHeaders:C(this,J,"f")}});case 5:e.next=12;break;case 7:e.prev=7,e.t0=e.catch(0),console.log("sip reconnect then registerer register error",e.t0),O(this,Ue,0,"f"),O(this,Fe,!1,"f");case 12:case"end":return e.stop()}}),e,this,[[0,7]])})))}),1e3*C(t,He,"f")),"f")}})),"object"!==o(s))throw new Error("userAgentOption must be plain object");C(this,V,"m",wt).call(this,s),C(this,V,"m",gt).call(this,s),C(this,V,"m",kt).call(this,s),C(this,V,"m",It).call(this,s),C(this,V,"m",mt).call(this,s),C(this,V,"m",vt).call(this,s),O(this,te,C(this,V,"m",jt).call(this,s),"f")}return t(r,[{key:"volumeValue",get:function(){return C(this,oe,"f")}},{key:"businessAttribute",get:function(){return C(this,it,"f")}},{key:"getFastOutboundCall",value:function(){return C(this,it,"f").voiceType===q.LABOUR}},{key:"getSitOutboundCall",value:function(){return C(this,it,"f").voiceType===q.AI}},{key:"detectNavigatorPermissions",value:function(){var e,t=this;-1===w(e=navigator.userAgent).call(e,"Firefox")?navigator.permissions.query({name:"microphone"}).then((function(e){"granted"===e.state?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1})).catch((function(e){console.log("Got error :",e),t.authorizedMicrophonePermissions=!1})):navigator.mediaDevices.enumerateDevices().then((function(e){""!==k(e).call(e,(function(e){return"audioinput"===e.kind}))[0].label?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1})),navigator.permissions.query({name:"notifications"}).then((function(e){"granted"===e.state?t.authorizedNotificationPermissions=!0:t.authorizedNotificationPermissions=!1})).catch((function(e){console.log("Got error :",e),t.authorizedNotificationPermissions=!1}))}},{key:"getGateway",value:function(){return"1"===C(this,Qe,"f")?"https://gateway.sg.94ai.com":"https://gateway.94ai.com"}},{key:"getGatewayToken",value:function(){return j(this,void 0,void 0,a.mark((function e(){var t,n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,C(this,ye,"f").call(this,C(this,he,"f"));case 2:if(!C(this,ue,"f")){e.next=4;break}return e.abrupt("return",C(this,ue,"f"));case 4:if(this.token){e.next=13;break}return e.next=7,C(this,xt,"f").call(this);case 7:return e.next=9,this.getGatewayAccessToken({corpId:C(this,Ve,"f"),sid:C(this,Ze,"f"),secret:C(this,Je,"f"),seatOnline:!1});case 9:t=e.sent,n=t.token,this.token=n,O(this,fe,f(),"f");case 13:return e.abrupt("return",this.token);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getGatewayAccessToken",value:function(e){return this.requestGateway({url:"/authority/accessToken/openApi",data:e},!1)}},{key:"getCallNumberDetail",value:function(e){return this.requestGateway({url:"/task-aggre/callCenterNumber/get",data:e})}},{key:"getCallNumberChats",value:function(e){return this.requestGateway({url:"/dialogue-aggre/call-center-number/chat/list",data:e})}},{key:"getCallInfo",value:function(){return j(this,void 0,void 0,a.mark((function e(){var t,n,i=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=v({},C(this,it,"f")),n=function(){return j(i,void 0,void 0,a.mark((function e(){var n,i,r,s,o,c,u,f,l,h,d,p,v,w,k,b,x,y,S,A;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.numberId||!t.taskId){e.next=57;break}return n={},e.prev=2,e.next=5,this.getCallNumberDetail({id:t.numberId,taskId:t.taskId});case 5:if(200===(n=e.sent).code){e.next=11;break}return console.error(n.message),t.stop=!0,C(this,Ie,"f").call(this,new Error(n.message)),e.abrupt("return");case 11:e.next=20;break;case 13:return e.prev=13,e.t0=e.catch(2),s=m(i=m(r="当前会话callid:".concat(t.callId,",根据numberId:")).call(r,t.numberId,",taskId:")).call(i,t.taskId,":查询坐席接听状态异常"),console.error(s),t.stop=!0,C(this,Ie,"f").call(this,new Error(n.message)),e.abrupt("return");case 20:if(o=n.data,c=o.callType,u=o.newIntentTag,f=o.intentTag,l=o.number,h=o.numberMd5,d=o.sid,p=o.config,v=o.tag,10!==o.state){e.next=25;break}return console.log("当前会话callid:".concat(t.callId,"已结束")),t.stop=!0,e.abrupt("return");case 25:if(t.callType||(t.callType=c),t.intentTag=u||f,t.number||(t.number=l),t.numberMD5||(t.numberMD5=h),t.agentId||(t.agentId=d),t.tag||(t.tag=v),t.templateId||p&&"string"==typeof p&&(w=JSON.parse(p))&&w.templateId&&(t.templateId=w.templateId),!t.callId){e.next=54;break}return b={},e.prev=34,e.next=37,this.getCallNumberChats({callId:t.callId,taskId:t.taskId});case 37:if(200===(b=e.sent).code){e.next=43;break}return console.error(b.message),t.stop=!0,C(this,Ie,"f").call(this,new Error(b.message)),e.abrupt("return");case 43:e.next=52;break;case 45:return e.prev=45,e.t1=e.catch(34),y=m(x="当前会话根据callId:".concat(t.callId,",taskId:")).call(x,t.taskId,":查询会话对话记录异常"),console.error(y),t.stop=!0,C(this,Ie,"f").call(this,new Error(y)),e.abrupt("return");case 52:t.chats=g(k=b.data).call(k,(function(e){return e.matchinfo&&(e.matchinfo=JSON.parse(e.matchinfo)),e})),C(this,de,"f")[t.callId]=t;case 54:try{C(this,we,"f").call(this,C(this,de,"f")[t.callId])}catch(e){console.log(e)}e.next=60;break;case 57:t.stop=!0,t.taskId||(S="当前会话callid:".concat(t.callId,"的taskId不存在,无法查询通话记录"),console.error(S),C(this,Ie,"f").call(this,new Error(S))),t.numberId||(A="当前会话callid:".concat(t.callId,"的numberId不存在,无法查询通话记录"),console.error(A),C(this,Ie,"f").call(this,new Error(A)));case 60:case"end":return e.stop()}}),e,this,[[2,13],[34,45]])})))},e.prev=2;case 3:if(!t.stop){e.next=6;break}return e.abrupt("break",14);case 6:return e.next=8,n();case 8:if(!t.stop){e.next=10;break}return e.abrupt("break",14);case 10:return e.next=12,new p((function(e){var t=h((function(){return j(i,void 0,void 0,a.mark((function n(){return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:clearTimeout(t),t=void 0,e(!0);case 3:case"end":return n.stop()}}),n)})))}),3e3)}));case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),C(this,Ie,"f").call(this,e.t0);case 19:case"end":return e.stop()}}),e,this,[[2,16]])})))}},{key:"refreshCallChatInfo",value:function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(C(this,it,"f").numberId&&C(this,it,"f").callId&&C(this,it,"f").taskId&&C(this,rt,"f"))){e.next=3;break}return e.next=3,this.getCallInfo();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getOpenApi",value:function(){return C(this,Ke,"f")?function(e){if(!e)return!1;var t=/^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;return!!/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||("//"===A(e).call(e,0,2)?t.test(A(e).call(e,2,e.length)):"http://"===A(e).call(e,0,7)?t.test(A(e).call(e,7,e.length)):"https://"===A(e).call(e,0,8)?t.test(A(e).call(e,8,e.length)):t.test(e))}(C(this,Ke,"f"))?C(this,Ke,"f"):"1"===C(this,Qe,"f")?"1"===C(this,$e,"f")?"https://seatsg.94ai.com/sgopenapi":"https://seatsg.94ai.com/openapi":"1"===C(this,$e,"f")?"https://seat.94ai.com/sgopenapi":"https://seat.94ai.com/openapi":"https://seat.94ai.com/openapi"}},{key:"getAgentInfo",value:function(){return this.requestOpenApi({url:"/v1/agent/getAgent",data:{agentTag:C(this,We,"f"),agentId:C(this,Ze,"f")}})}},{key:"getOpenApiSign",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f(),i=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return j(this,void 0,void 0,a.mark((function s(){return a.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,C(this,xe,"f").call(this,C(this,le,"f"));case 2:return s.abrupt("return",{sign:null!==(e=C(this,ae,"f"))&&void 0!==e?e:I.enc.Base64.stringify(I.HmacSHA1(i||C(this,Ve,"f")+n,r||C(this,Je,"f"))),timestamp:null!==(t=C(this,ce,"f"))&&void 0!==t?t:n});case 3:case"end":return s.stop()}}),s,this)})))}},{key:"updateOpenApiAgentStatus",value:function(e){return this.requestOpenApi({url:"/v1/agent/updateAgentStatus",data:{agentTag:C(this,We,"f"),agentId:C(this,Ze,"f"),agentStatus:e}})}},{key:"importOpenApiAgentCustomer",value:function(e){return this.requestOpenApi({url:"/v1/task/importAgentCustomer",data:{agentTag:C(this,We,"f"),agentId:C(this,Ze,"f"),callType:1001,customers:[{number:e}]}})}},{key:"callNumber",value:function(e){return this.importOpenApiAgentCustomer(e)}},{key:"toggleNap",value:function(e){return e?this.updateOpenApiAgentStatus(3):this.updateOpenApiAgentStatus(1)}},{key:"refreshSign",value:function(e){O(this,ae,e,"f")}},{key:"prepareUserAgent",value:function(e,t){var n;return j(this,void 0,void 0,a.mark((function i(){var r,s,o,c,u,f,l,h,d,p,m;return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=(r=e||{}).refresh,o=r.registererOptions,c=r.registererRegisterOptions,u=r.extraHeaders,f=r.authorizationUsername,l=r.authorizationPassword,h=r.uri,d=r.contactName,p=r.transportOptions,i.next=3,this.dispose();case 3:return C(this,te,"f").uri=null!=h?h:C(this,te,"f").uri,C(this,te,"f").authorizationUsername=null!=f?f:C(this,te,"f").authorizationUsername,C(this,te,"f").authorizationPassword=null!=l?l:C(this,te,"f").authorizationPassword,C(this,te,"f").contactName=null!==(n=null!=d?d:f)&&void 0!==n?n:C(this,te,"f").contactName,p&&(C(this,te,"f").transportOptions=v(v({},C(this,te,"f").transportOptions),p)),i.prev=8,C(this,V,"m",wt).call(this,e),i.next=12,C(this,xt,"f").call(this);case 12:return i.next=14,C(this,yt,"f").call(this);case 14:return i.next=16,C(this,V,"m",$t).call(this,{refresh:s});case 16:return t&&C(this,V,"m",Kt).call(this,t),i.next=19,C(this,V,"m",Qt).call(this,{registererOptions:o,registererRegisterOptions:c,extraHeaders:u});case 19:return m=i.sent,i.abrupt("return",m);case 23:return i.prev=23,i.t0=i.catch(8),i.next=27,this.dispose();case 27:throw i.t0;case 28:case"end":return i.stop()}}),i,this,[[8,23]])})))}},{key:"dispose",value:function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,C(this,V,"m",Et).call(this),C(this,V,"m",qt).call(this),C(this,V,"m",Pt).call(this),C(this,V,"m",Nt).call(this),C(this,V,"m",Rt).call(this),C(this,V,"m",_t).call(this),e.next=9,C(this,V,"m",Ot).call(this);case 9:C(this,V,"m",Dt).call(this),C(this,at,"f").call(this),O(this,it,{},"f"),O(this,de,{},"f"),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(0),C(this,V,"m",Dt).call(this),console.log("sip dispose with error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[0,15]])})))}},{key:"ignoreInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return C(this,se,"f").incomingStatus=!1,t.next=3,this.getCurrentInvitation().reject(e);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"acceptInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,new p((function(t,i){j(n,void 0,void 0,a.mark((function n(){var r,s;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=null==e?void 0:e.onAck,s=null==e?void 0:e.onAckTimeout,null==e||delete e.onAck,null==e||delete e.onAckTimeout,n.next=7,this.getCurrentInvitation().accept(v({sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}},onAck:function(e){t(e),null==r||r()},onAckTimeout:function(){null==s||s(),i(new Error("接听响应超时"))}},e||{}));case 7:n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),i(n.t0);case 12:case"end":return n.stop()}}),n,this,[[0,9]])})))}));case 3:C(this,se,"f").incomingStatus&&(C(this,se,"f").incomingStatus=!1,C(this,se,"f").answerStatus=!0),t.next=10;break;case 6:throw t.prev=6,t.t0=t.catch(0),C(this,se,"f").incomingStatus=!1,t.t0;case 10:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"hangUpInvite",value:function(e){return j(this,void 0,void 0,a.mark((function t(){var n,r,s,o,c,u=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=e||{}).rejectOptions,s=n.byeOptions,o=n.extraHeaders,c=n.scoutResponse,t.abrupt("return",new p((function(e,t){return j(u,void 0,void 0,a.mark((function n(){var u,f,l,h,d,p,m,g,w;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,m=null===(u=(p=s||{}).requestDelegate)||void 0===u?void 0:u.onAccept,g=null===(f=p.requestDelegate)||void 0===f?void 0:f.onReject,null===(l=p.requestDelegate)||void 0===l||delete l.onAccept,null===(h=p.requestDelegate)||void 0===h||delete h.onReject,w=C(this,V,"m",Tt).call(this,{onAccept:function(t){console.log("sip bye success"),e(t),null==m||m(t)},onReject:function(e){null==g||g(e),t(new Error("sip bye fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,n.t0=null===(d=C(this,ne,"f"))||void 0===d?void 0:d.state,n.next=n.t0===i.Initial||n.t0===i.Establishing?11:n.t0===i.Established?15:n.t0===i.Terminating||n.t0===i.Terminated?19:21;break;case 11:return n.next=13,C(this,ne,"f").reject(v({extraHeaders:o},r||{}));case 13:return e(!0),n.abrupt("break",21);case 15:return n.next=17,C(this,ne,"f").bye(v({requestDelegate:w,requestOptions:{extraHeaders:o}},p));case 17:return c||e(!0),n.abrupt("break",21);case 19:return e(!0),n.abrupt("break",21);case 21:n.next=26;break;case 23:n.prev=23,n.t1=n.catch(0),t(n.t1);case 26:return n.prev=26,C(this,se,"f").incomingStatus=!1,C(this,se,"f").answerStatus=!1,n.finish(26);case 30:case"end":return n.stop()}}),n,this,[[0,23,26,30]])})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"sendStarDtmf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new p((function(t,i){return j(n,void 0,void 0,a.mark((function n(){var r,s,o,c;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,s=(r=e||{}).extraHeaders,o=r.requestDelegate,c=C(this,V,"m",Tt).call(this,{onAccept:function(e){console.log("sip send dtmf Signal=* success"),t(e)},onReject:function(e){i(new Error("sip send dtmf Signal=* fail with code "+e.message.statusCode))}},o),delete r.requestDelegate,n.next=7,this.getCurrentInvitation().info(v({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal=*\r\nDuration=100"},extraHeaders:s},requestDelegate:c},r));case 7:C(this,ot,"f").call(this),n.next=13;break;case 10:n.prev=10,n.t0=n.catch(0),i(n.t0);case 13:case"end":return n.stop()}}),n,this,[[0,10]])})))})));case 1:case"end":return t.stop()}}),t)})))}},{key:"sendCurrentInviter",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=(e||{}).extraHeaders,t.next=3,this.getCurrentInviter().invite(v({requestOptions:{extraHeaders:n}},e));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"muteRemoteAudio",value:function(){var e;l(e=C(this,$,"f").getReceivers()).call(e,(function(e){e.track.enabled=!1}))}},{key:"unMuteRemoteAudio",value:function(){var e;l(e=C(this,$,"f").getReceivers()).call(e,(function(e){e.track.enabled=!0}))}},{key:"muteLocalAudio",value:function(){var e;l(e=C(this,$,"f").getSenders()).call(e,(function(e){e.track.enabled=!1}))}},{key:"unMuteLocalAudio",value:function(){var e;l(e=C(this,$,"f").getSenders()).call(e,(function(e){e.track.enabled=!0}))}},{key:"getUserAgentStatue",value:function(){return C(this,se,"f")}},{key:"getUserAgent",value:function(){return C(this,W,"f")||O(this,W,new n(C(this,te,"f")),"f"),C(this,W,"f")}},{key:"getSessionDescriptionHandler",value:function(){return C(this,K,"f")}},{key:"getPeerConnection",value:function(){return C(this,$,"f")}},{key:"getSenders",value:function(){return C(this,ee,"f")}},{key:"getReceivers",value:function(){return C(this,Q,"f")}},{key:"getStream",value:function(){var e,t=this;return C(this,re,"f")||O(this,re,new MediaStream,"f"),l(e=C(this,Q,"f")).call(e,(function(e){e.track&&C(t,re,"f").addTrack(e.track)})),C(this,re,"f")}},{key:"getCurrentInviter",value:function(){if(!C(this,ie,"f"))throw new Error("No currentInviter, please call createCurrentInviter");return C(this,ie,"f")}},{key:"getCurrentInvitation",value:function(){return C(this,ne,"f")}}]),r}();J=new b,W=new b,Z=new b,K=new b,$=new b,Q=new b,ee=new b,te=new b,ne=new b,ie=new b,re=new b,se=new b,oe=new b,ae=new b,ce=new b,ue=new b,fe=new b,le=new b,he=new b,de=new b,pe=new b,ve=new b,me=new b,ge=new b,we=new b,ke=new b,be=new b,xe=new b,ye=new b,Se=new b,Ae=new b,Ie=new b,Te=new b,je=new b,Ce=new b,Oe=new b,Ee=new b,De=new b,Re=new b,Ne=new b,qe=new b,Pe=new b,He=new b,Me=new b,Ue=new b,ze=new b,Le=new b,Xe=new b,Ge=new b,Fe=new b,_e=new b,Be=new b,Ye=new b,Ve=new b,Je=new b,We=new b,Ze=new b,Ke=new b,$e=new b,Qe=new b,et=new b,tt=new b,nt=new b,it=new b,rt=new b,st=new b,ot=new b,at=new b,ct=new b,ut=new b,ft=new b,lt=new b,ht=new b,dt=new b,pt=new b,xt=new b,yt=new b,St=new b,Mt=new b,zt=new b,Lt=new b,Xt=new b,Gt=new b,Ft=new b,Jt=new b,V=new x,vt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O(this,ke,null!==(e=n.openXhrIntercept)&&void 0!==e?e:C(this,ke,"f"),"f"),O(this,be,null!==(t=n.gatewayXhrIntercept)&&void 0!==t?t:C(this,be,"f"),"f")},mt=function(){var e,t,n,i,r,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O(this,rt,null!==(e=o.enableChatInfoPush)&&void 0!==e?e:C(this,rt,"f"),"f"),O(this,st,null!==(t=o.enableVolumnTrack)&&void 0!==t?t:C(this,st,"f"),"f"),O(this,ge,null!==(n=o.refreshSpeekVolumn)&&void 0!==n?n:C(this,ge,"f"),"f"),O(this,Te,null!==(i=o.refreshRequirementCheck)&&void 0!==i?i:C(this,Te,"f"),"f"),O(this,we,null!==(r=o.refreshChat)&&void 0!==r?r:C(this,we,"f"),"f"),O(this,Ie,null!==(s=o.refreshChatErrorCallback)&&void 0!==s?s:C(this,Ie,"f"),"f")},gt=function(){var e,t,n,i,r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O(this,ue,null!==(e=s.token)&&void 0!==e?e:C(this,ue,"f"),"f"),O(this,fe,null!==(t=s.tokenTimestamp)&&void 0!==t?t:C(this,fe,"f"),"f"),O(this,he,null!==(n=s.tokenExpirationTime)&&void 0!==n?n:C(this,he,"f"),"f"),C(this,ue,"f")&&!C(this,fe,"f")&&O(this,fe,f(),"f"),O(this,ye,null!==(i=s.tokenCheck)&&void 0!==i?i:C(this,ye,"f"),"f"),O(this,Ae,null!==(r=s.tokenOverdued)&&void 0!==r?r:C(this,Ae,"f"),"f")},wt=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.agentId,s=i.agentTag,o=i.appKey,a=i.appSecret,c=i.openBaseUrl,u=i.sg,f=i.sgOpen,l=i.sign,h=i.timestamp;O(this,Ze,null!=r?r:C(this,Ze,"f"),"f"),O(this,We,null!=s?s:C(this,We,"f"),"f"),O(this,Ve,null!=o?o:C(this,Ve,"f"),"f"),O(this,Je,null!=a?a:C(this,Je,"f"),"f"),O(this,Ke,null!=c?c:C(this,Ke,"f"),"f"),O(this,Qe,null!=u?u:C(this,Qe,"f"),"f"),O(this,$e,null!=f?f:C(this,$e,"f"),"f"),O(this,ae,null!=l?l:C(this,ae,"f"),"f"),O(this,ce,null!=h?h:C(this,ce,"f"),"f"),O(this,le,null!==(e=i.signExpirationTime)&&void 0!==e?e:C(this,le,"f"),"f"),O(this,xe,null!==(t=i.signCheck)&&void 0!==t?t:C(this,xe,"f"),"f"),O(this,Se,null!==(n=i.signOverdued)&&void 0!==n?n:C(this,Se,"f"),"f")},kt=function(e){e.sipHeaders&&(O(this,J,e.sipHeaders,"f"),delete e.sipHeaders)},bt=function(){return!(!C(this,Ze,"f")&&!C(this,We,"f")||!(C(this,Ve,"f")&&C(this,Je,"f")||C(this,ae,"f")&&C(this,ce,"f")))},At=function(e){O(this,se,s(JSON.parse(c(z)),"function"==typeof e.refresh?e.refresh:C(this,nt,"f")),"f")},It=function(e){var t,n,i,r,s,o,a,c,u,f,l,h,d,p,v;O(this,Oe,null!==(i=null!==(t=e.reconnectionAttempts)&&void 0!==t?t:null===(n=null==e?void 0:e.transportOptions)||void 0===n?void 0:n.maxReconnectionAttempts)&&void 0!==i?i:C(this,Oe,"f"),"f"),O(this,Ee,null!==(a=null!==(s=null!==(r=e.reconnectionInterval)&&void 0!==r?r:e.reconnectionDelay)&&void 0!==s?s:null===(o=null==e?void 0:e.transportOptions)||void 0===o?void 0:o.reconnectionTimeout)&&void 0!==a?a:C(this,Ee,"f"),"f"),O(this,ze,null!==(u=null===(c=e.transportOptions)||void 0===c?void 0:c.keepAliveInterval)&&void 0!==u?u:C(this,ze,"f"),"f"),O(this,Le,null!==(l=null===(f=e.transportOptions)||void 0===f?void 0:f.keepAliveDebounce)&&void 0!==l?l:C(this,Le,"f"),"f"),O(this,He,null!==(h=e.registerInterval)&&void 0!==h?h:C(this,He,"f"),"f"),O(this,De,null!==(d=e.optionsPingInterval)&&void 0!==d?d:C(this,De,"f"),"f"),O(this,Re,null!==(p=e.optionsPingAttempts)&&void 0!==p?p:C(this,Re,"f"),"f"),O(this,Me,null!==(v=e.registerAttempts)&&void 0!==v?v:C(this,Me,"f"),"f")},Tt=function(e,t){var n,i=this;return t?(l(n=y(t)).call(n,(function(n){if(t[n]&&"function"==typeof t[n])if(e[n]){if("function"==typeof e[n]){var r=e[n];e[n]=function(e){return j(i,void 0,void 0,a.mark((function i(){return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,t[n](e);case 2:return i.next=4,r(e);case 4:case"end":return i.stop()}}),i)})))}}}else e[n]=t[n]})),e):e},jt=function(e){var t,n=this,i={delegate:{onConnect:function(){return j(n,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log("sip connected"),C(this,Xt,"f").call(this);case 2:case"end":return e.stop()}}),e,this)})))},onInvite:function(e){C(n,St,"f").call(n,e.incomingInviteRequest.message.headers),n.refreshCallChatInfo(),C(n,V,"m",Ct).call(n),O(n,ne,e,"f"),C(n,se,"f").incomingStatus=!0,e.stateChange.addListener(C(n,Mt,"f"))},onDisconnect:function(e){return j(n,void 0,void 0,a.mark((function t(){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("sip disconnected"),n=!1,C(this,De,"f")>0&&(n=C(this,qe,"f"),C(this,Ft,"f").call(this)),t.next=5,C(this,V,"m",Ut).call(this);case 5:(e||n)&&C(this,V,"m",Wt).call(this);case 6:case"end":return t.stop()}}),t,this)})))}}};e.delegate?l(t=y(e.delegate)).call(t,(function(t){var r=t;if(e.delegate[r]&&"function"==typeof e.delegate[r]){var s=e.delegate[r];e.delegate[r]=function(e){return j(n,void 0,void 0,a.mark((function t(){var n,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(o=(n=i.delegate)[r])||void 0===o||o.call(n,e),t.next=3,s(e);case 3:case"end":return t.stop()}}),t)})))}}})):e.delegate=i.delegate;return e.reconnectionAttempts=0,e.transportOptions=v(v({},e.transportOptions||{}),{keepAliveInterval:C(this,ze,"f"),keepAliveDebounce:C(this,Le,"f")}),void 0===e.sessionDescriptionHandlerFactoryOptions&&(e.sessionDescriptionHandlerFactoryOptions={iceGatheringTimeout:2e3,peerConnectionConfiguration:{iceServers:[]}}),v(v({},U),e)},Ct=function(){C(this,ne,"f")&&(C(this,ne,"f").dispose(),O(this,ne,void 0,"f"))},Ot=function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,W,"f")){e.next=4;break}return e.next=3,C(this,W,"f").stop();case 3:O(this,W,void 0,"f");case 4:case"end":return e.stop()}}),e,this)})))},Et=function(){var e;C(this,re,"f")&&(l(e=C(this,re,"f").getTracks()).call(e,(function(e){e.stop()})),O(this,re,void 0,"f"))},Dt=function(){var e,t=this;l(e=y(z)).call(e,(function(e){var n=e;C(t,se,"f")[n]=z[n]}))},Rt=function(){C(this,K,"f")&&(C(this,K,"f").close(),O(this,K,void 0,"f"))},Nt=function(){C(this,$,"f")&&(C(this,$,"f").close(),O(this,$,void 0,"f"))},qt=function(){O(this,ee,[],"f")},Pt=function(){O(this,Q,[],"f")},Ht=function(){var e=this.getCurrentInvitation().sessionDescriptionHandler;C(this,V,"m",Nt).call(this),C(this,V,"m",Rt).call(this),C(this,V,"m",qt).call(this),C(this,V,"m",Pt).call(this),O(this,K,e,"f"),O(this,$,e.peerConnection,"f"),O(this,ee,C(this,$,"f").getSenders(),"f"),O(this,Q,C(this,$,"f").getReceivers(),"f"),(this.getFastOutboundCall()||!this.getSitOutboundCall()&&this.notNeedSendStarDtmf())&&C(this,ot,"f").call(this)},Ut=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,Z,"f")){t.next=3;break}return console.log("sip due to disconnection, unregistered"),t.abrupt("return",new p((function(t,i){return j(n,void 0,void 0,a.mark((function n(){var r,s;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=e||{},s=C(this,V,"m",Tt).call(this,{onAccept:function(e){console.log("sip unregister successed"),t(e)},onReject:function(e){i(new Error("sip unregister fail with code "+e.message.statusCode))}},r.requestDelegate),delete e.requestDelegate,n.next=6,C(this,Z,"f").unregister(v({requestDelegate:s},e));case 6:n.next=11;break;case 8:n.prev=8,n.t0=n.catch(0),i(n.t0);case 11:case"end":return n.stop()}}),n,this,[[0,8]])})))})));case 3:case"end":return t.stop()}}),t,this)})))},_t=function(){C(this,V,"m",Bt).call(this),C(this,V,"m",Yt).call(this),C(this,V,"m",Vt).call(this),O(this,Fe,!1,"f"),O(this,Xe,!1,"f"),O(this,Ge,!1,"f")},Bt=function(){clearTimeout(C(this,Ye,"f")),O(this,Ye,void 0,"f")},Yt=function(){clearTimeout(C(this,_e,"f")),O(this,_e,void 0,"f")},Vt=function(){clearTimeout(C(this,Be,"f")),O(this,Be,void 0,"f")},Wt=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return j(this,void 0,void 0,a.mark((function n(){var i=this;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!C(this,Ee,"f")){n.next=12;break}if(C(this,se,"f").reconnectStatus=!0,!C(this,Xe,"f")){n.next=4;break}return n.abrupt("return");case 4:if(!(t>C(this,Oe,"f"))){n.next=9;break}return console.log("sip maximum reconnection attempts reached"),n.next=8,this.dispose();case 8:return n.abrupt("return");case 9:console.log("sip reconnection attempt..."),O(this,Xe,!0,"f"),O(this,_e,h((function(){C(i,V,"m",Yt).call(i),i.getUserAgent().reconnect().then((function(){return j(i,void 0,void 0,a.mark((function e(){var n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log(m(n="sip reconnection attempt ".concat(t," of ")).call(n,C(this,Oe,"f")," - succeeded")),O(this,Xe,!1,"f"),C(this,Jt,"f").call(this);case 3:case"end":return e.stop()}}),e,this)})))})).catch((function(n){var r;console.error(n),console.log(m(r="sip reconnection attempt ".concat(t," of ")).call(r,C(i,Oe,"f")," - failed")),O(i,Xe,!1,"f"),C(i,V,"m",e).call(i,++t)}))}),1===t?0:1e3*C(this,Ee,"f")),"f");case 12:case"end":return n.stop()}}),n,this)})))},Zt=function(e){var t,n=this;return l(t=y(e)).call(t,(function(t){var i=t;if("function"==typeof(null==e?void 0:e[i])){var r=e[i];e[i]=function(e){return j(n,void 0,void 0,a.mark((function t(){var n,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(s=(n=C(this,te,"f").delegate)[i])||void 0===s||s.call(n,e),t.next=3,r(e);case 3:case"end":return t.stop()}}),t,this)})))}}})),e},Kt=function(e){var t=this.getUserAgent();return t.delegate=C(this,V,"m",Zt).call(this,e),t},$t=function(e){return j(this,void 0,void 0,a.mark((function t(){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return C(this,V,"m",At).call(this,e),n=this.getUserAgent(),t.next=4,n.start();case 4:if(n.isConnected()){t.next=7;break}return t.next=7,n.reconnect();case 7:if(n.isConnected()){t.next=9;break}throw new Error("链接失败,请稍后再试");case 9:return C(this,se,"f").connectStatus=!0,t.abrupt("return",n);case 11:case"end":return t.stop()}}),t,this)})))},Qt=function(e){var t=this,n=e||{},i=n.registererOptions,s=n.registererRegisterOptions,o=n.extraHeaders;return new p((function(e,n){return j(t,void 0,void 0,a.mark((function t(){var c,u,f,l=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c=this.getUserAgent(),O(this,Z,new r(c,v({extraHeaders:o||C(this,J,"f")},i||{})),"f"),t.prev=2,u=s||{},f=C(this,V,"m",Tt).call(this,{onAccept:function(t){C(l,se,"f").registerStatus=!0,e(c)},onReject:function(e){n(new Error("sip register fail with code "+e.message.statusCode))}},u.requestDelegate),delete u.requestDelegate,t.next=8,C(this,Z,"f").register(v({requestDelegate:f,requestOptions:{extraHeaders:o||C(this,J,"f")}},u));case 8:t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),n(t.t0);case 13:case"end":return t.stop()}}),t,this,[[2,10]])})))}))};var un=function(){function n(){e(this,n)}return t(n,null,[{key:"getUserAgentManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,on,"f",an)||O(this,on,new cn(e),"f",an),C(this,on,"f",an)}},{key:"hasUserAgentManager",value:function(){return!!C(this,on,"f",an)}},{key:"newUserAgentManager",value:function(){return new cn(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dispose",value:function(){if(C(this,on,"f",an))try{C(this,on,"f",an).dispose()}catch(e){}finally{O(this,on,void 0,"f",an)}}}]),n}();on=un,an={value:void 0};export{un as UserAgentFactory,cn as UserAgentManager,nn as accumulateSec,rn as accumulationTimer,Y as cleanupMedia,G as getDevicePermission,L as getMedia,en as getTimes,tn as getZeorTime,B as pauseMedia,_ as playMedia,F as requestMicroPhonePermission,X as stopStreamTracks,U as userAgentDefault,z as userAgentStatus};
1
+ import e from"@babel/runtime-corejs3/helpers/esm/classCallCheck";import t from"@babel/runtime-corejs3/helpers/esm/createClass";import{UserAgent as n,SessionState as i,Registerer as r}from"sip.js";export{Inviter,Registerer,SessionState,URI,UserAgent}from"sip.js";export{SimpleUser}from"sip.js/lib/platform/web/index.js";import s from"on-change";export{default as onChange}from"on-change";import o from"@babel/runtime-corejs3/helpers/esm/typeof";import a from"@babel/runtime-corejs3/regenerator";import c from"@babel/runtime-corejs3/core-js/json/stringify";import u from"@babel/runtime-corejs3/core-js/object/define-property";import f from"@babel/runtime-corejs3/core-js/date/now";import l from"@babel/runtime-corejs3/core-js/instance/for-each";import h from"@babel/runtime-corejs3/core-js/set-timeout";import d from"@babel/runtime-corejs3/core-js/set-interval";import p from"@babel/runtime-corejs3/core-js/promise";import v from"@babel/runtime-corejs3/core-js/object/assign";import m from"@babel/runtime-corejs3/core-js/instance/concat";import g from"@babel/runtime-corejs3/core-js/instance/map";import w from"@babel/runtime-corejs3/core-js/instance/index-of";import k from"@babel/runtime-corejs3/core-js/instance/filter";import b from"@babel/runtime-corejs3/core-js/weak-map";import x from"@babel/runtime-corejs3/core-js/weak-set";import y from"@babel/runtime-corejs3/core-js/object/keys";import S from"@babel/runtime-corejs3/core-js/instance/pad-start";import A from"@babel/runtime-corejs3/core-js/instance/slice";import I from"crypto-js";import T from"@fingerprintjs/fingerprintjs";function j(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function C(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function O(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var D,E;"function"==typeof SuppressedError&&SuppressedError;var R,q,N,P,H=m(D="sip:".concat("","@")).call(D,""),M=m(E="".concat("","://")).call(E,""),U={authorizationPassword:"",authorizationUsername:"",viaHost:"",uri:n.makeURI(H),logLevel:"error",transportOptions:{server:M},contactName:""},z={connectStatus:!1,registerStatus:!1,invitatingStatus:!1,incomingStatus:!1,answerStatus:!1,reconnectStatus:!1};function L(e){return document.getElementById(e)}function X(e){if(e&&e.getTracks)try{var t=e.getTracks();l(t).call(t,(function(e){try{e.stop()}catch(e){}}))}catch(e){}}function G(e){return navigator.mediaDevices.getUserMedia(e).then((function(e){return e?(X(e),!0):p.reject(new Error("EmptyStreamError"))})).catch((function(e){return(!e||"NotAllowedError"!==e.name)&&p.reject(e)}))}function F(){try{var e;if(-1===w(e=navigator.userAgent).call(e,"Firefox"))return G({video:!1,audio:!0}).catch((function(){return!0}))}catch(e){console.log(e)}}function _(e){var t=L(e);t&&(t.currentTime=0,t.play())}function B(e){var t=L(e);t&&(t.currentTime=0,t.pause())}function Y(e){var t=L(e);t&&(t.srcObject=null,t.pause())}!function(e){e.NO="0",e.YES="1"}(R||(R={})),function(e){e.NO="0",e.YES="1"}(q||(q={})),function(e){e.MULTI_AI="1",e.MULTI_VOICE_NOTIFY="2",e.MULTI_PRETEST="3",e.LABOUR="4",e.AI="5",e.NEW_VOICE_NOTIFY="6"}(N||(N={})),function(e){e.DIRECT_ANSWER="1",e.LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY="2"}(P||(P={}));var V,J,W,Z,K,$,Q,ee,te,ne,ie,re,se,oe,ae,ce,ue,fe,le,he,de,pe,ve,me,ge,we,ke,be,xe,ye,Se,Ae,Ie,Te,je,Ce,Oe,De,Ee,Re,qe,Ne,Pe,He,Me,Ue,ze,Le,Xe,Ge,Fe,_e,Be,Ye,Ve,Je,We,Ze,Ke,$e,Qe,et,tt,nt,it,rt,st,ot,at,ct,ut,ft,lt,ht,dt,pt,vt,mt,gt,wt,kt,bt,xt,yt,St,At,It,Tt,jt,Ct,Ot,Dt,Et,Rt,qt,Nt,Pt,Ht,Mt,Ut,zt,Lt,Xt,Gt,Ft,_t,Bt,Yt,Vt,Jt,Wt,Zt,Kt,$t,Qt,en,tn,nn,rn,sn,on,an,cn,un=function(e){var t,n,i;return S(t=e.getHours().toString()).call(t,2,"0")+":"+S(n=e.getMinutes().toString()).call(n,2,"0")+":"+S(i=e.getSeconds().toString()).call(i,2,"0")},fn=function(){return new Date(new Date((new Date).toLocaleDateString()).getTime())},ln=function(e){return new Date(e.setSeconds(e.getSeconds()+1))};function hn(e){var t=fn();e(un(t));var n=d((function(){var n=ln(t),i=un(n);e(i)}),1e3);return function(){clearInterval(n),n=null}}function dn(e,t,n){var i=window.XMLHttpRequest?new window.XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):void 0;i||t(new Error("Your Browser does not support ajax")),i.onreadystatechange=function(){if(4==i.readyState){var n=i.response||i.responseText;if(200==i.status){var r=i.getResponseHeader("Content-Type");-1!=w(r).call(r,"json")?e(JSON.parse(i.responseText)):-1!=w(r).call(r,"xml")?e(i.responseXML):e(i.responseText)}else t(n)}};var r=n.url,s=n.data,o=n.type,a=n.contentType,u=o||"POST",f=r,l=null;return s&&("GET"===u?f=f+"?"+function(e){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join("&")}(s):"POST"===u&&(l=c(s))),i.open(u,f,!0),{xhr:i,ajaxData:l,contentType:a}}var pn,vn,mn=function(){function r(){var t=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e(this,r),V.add(this),J.set(this,void 0),W.set(this,void 0),Z.set(this,void 0),K.set(this,void 0),$.set(this,void 0),Q.set(this,[]),ee.set(this,[]),te.set(this,{}),ne.set(this,void 0),ie.set(this,void 0),re.set(this,new MediaStream),se.set(this,JSON.parse(c(z))),oe.set(this,0),ae.set(this,void 0),ce.set(this,void 0),ue.set(this,void 0),u(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),fe.set(this,void 0),le.set(this,48e4),he.set(this,12e6),de.set(this,{}),pe.set(this,void 0),ve.set(this,void 0),me.set(this,void 0),ge.set(this,(function(e){})),we.set(this,(function(e){})),ke.set(this,(function(e){})),be.set(this,(function(e){})),xe.set(this,(function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i,r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,ae,"f")||!C(this,ce,"f")){t.next=9;break}if(!(f()-C(this,ce,"f")>e)){t.next=9;break}return t.next=4,C(this,Se,"f").call(this);case 4:n=t.sent,i=n.sign,r=n.timestamp,O(this,ae,null!=i?i:C(this,ae,"f"),"f"),O(this,ce,null!=r?r:C(this,ce,"f"),"f");case 9:case"end":return t.stop()}}),t,this)})))})),ye.set(this,(function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i,r,s,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,fe,"f")){t.next=19;break}if(!(f()-C(this,fe,"f")>e)){t.next=19;break}if(!C(this,ue,"f")){t.next=12;break}return t.next=5,C(this,Ae,"f").call(this);case 5:n=t.sent,i=n.token,r=n.tokenTimestamp,O(this,ue,null!=i?i:C(this,ue,"f"),"f"),O(this,fe,null!=r?r:f(),"f"),t.next=19;break;case 12:if(!this.token){t.next=19;break}return t.next=15,this.getGatewayAccessToken({corpId:C(this,Ve,"f"),sid:C(this,Ze,"f"),secret:C(this,Je,"f"),seatOnline:!1});case 15:s=t.sent,o=s.token,this.token=o,O(this,fe,f(),"f");case 19:case"end":return t.stop()}}),t,this)})))})),Se.set(this,(function(){})),Ae.set(this,(function(){})),Ie.set(this,(function(e){})),Te.set(this,(function(e){})),je.set(this,void 0),Ce.set(this,void 0),u(this,"networkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:"0.00Mb/s"}),u(this,"networkDelay",{enumerable:!0,configurable:!0,writable:!0,value:"0ms"}),u(this,"onLine",{enumerable:!0,configurable:!0,writable:!0,value:navigator.onLine}),u(this,"testspeeding",{enumerable:!0,configurable:!0,writable:!0,value:!1}),u(this,"goodNetworkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:function(){return 1e3*Number(t.networkSpeed.replace("Mb/s",""))>=30}}),u(this,"goodNetworkDelay",{enumerable:!0,configurable:!0,writable:!0,value:function(){return Number(t.networkDelay.replace("ms",""))<=500&&"0ms"!==t.networkDelay}}),u(this,"authorizedMicrophonePermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),u(this,"authorizedNotificationPermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Oe.set(this,100),De.set(this,3),Ee.set(this,8),Re.set(this,3),qe.set(this,0),Ne.set(this,!1),Pe.set(this,void 0),He.set(this,3),Me.set(this,3),Ue.set(this,0),ze.set(this,0),Le.set(this,0),Xe.set(this,!1),Ge.set(this,!1),Fe.set(this,!1),_e.set(this,void 0),Be.set(this,void 0),Ye.set(this,void 0),Ve.set(this,void 0),Je.set(this,void 0),We.set(this,void 0),Ze.set(this,void 0),Ke.set(this,void 0),$e.set(this,void 0),Qe.set(this,void 0),et.set(this,void 0),tt.set(this,(function(e){C(t,V,"m",rn).call(t)})),nt.set(this,(function(){})),it.set(this,void 0),rt.set(this,void 0),st.set(this,!1),ot.set(this,4e3),at.set(this,4e3),ct.set(this,{}),ut.set(this,!1),ft.set(this,!0),u(this,"ifAutoAnswer",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,ct,"f").autoAnswer)===R.YES}}),u(this,"notNeedSendStarDtmf",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(C(t,ct,"f").afterTransferLabour)===P.DIRECT_ANSWER}}),lt.set(this,(function(){if(C(t,ft,"f")){var e;C(t,ht,"f").call(t);var n=new(window.AudioContext||window.webkitAudioContext);O(t,ve,n.createScriptProcessor(2048,1,1),"f"),C(t,ve,"f").onaudioprocess=function(e){for(var n=e.inputBuffer.getChannelData(0),i=0,r=0;r<n.length;++r)i+=n[r]*n[r];O(t,oe,Number(Math.sqrt(i/n.length).toFixed(2)),"f"),C(t,ge,"f").call(t,C(t,oe,"f"))},O(t,me,new MediaStream,"f"),l(e=t.getSenders()).call(e,(function(e){e.track&&C(t,me,"f").addTrack(e.track)})),O(t,pe,n.createMediaStreamSource(C(t,me,"f")),"f"),C(t,pe,"f").connect(C(t,ve,"f")),C(t,ve,"f").connect(n.destination)}})),ht.set(this,(function(){if(C(t,ft,"f")){if(C(t,pe,"f"))try{C(t,pe,"f").disconnect()}catch(e){console.log(e)}if(C(t,ve,"f"))try{C(t,ve,"f").disconnect()}catch(e){console.log(e)}if(C(t,me,"f"))try{var e;l(e=C(t,me,"f").getTracks()).call(e,(function(e){e.stop()}))}catch(e){console.log(e)}}O(t,pe,void 0,"f"),O(t,ve,void 0,"f"),O(t,me,void 0,"f"),O(t,oe,0,"f"),C(t,ge,"f").call(t,C(t,oe,"f"))})),u(this,"disposeSoftphoneEnvRequirementCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){C(t,dt,"f").call(t),window.removeEventListener("offline",C(t,mt,"f")),window.removeEventListener("online",C(t,vt,"f")),window.removeEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)}}),dt.set(this,(function(){clearInterval(C(t,je,"f")),O(t,je,void 0,"f"),clearTimeout(C(t,Ce,"f")),O(t,Ce,void 0,"f"),t.testspeeding=!1})),u(this,"softphoneEnvCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){return j(t,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding||(C(this,pt,"f").call(this),this.oneRoundOfTesting());case 1:case"end":return e.stop()}}),e,this)})))}}),pt.set(this,(function(){window.addEventListener("offline",C(t,mt,"f")),window.addEventListener("online",C(t,vt,"f")),window.addEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)})),u(this,"oneRoundOfTesting",{enumerable:!0,configurable:!0,writable:!0,value:function(){return j(t,void 0,void 0,a.mark((function e(){var t=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding=!0,this.detectNavigatorPermissions(),this.onLine?(C(this,gt,"f").call(this,this),O(this,Ce,h((function(){t.testspeeding=!1,t.disposeSoftphoneEnvRequirementCheck()}),4e3),"f")):this.testspeeding=!1;case 3:case"end":return e.stop()}}),e,this)})))}}),vt.set(this,(function(){t.onLine=!0,t.oneRoundOfTesting()})),mt.set(this,(function(){t.onLine=!1,t.networkSpeed="0.00Mb/s",t.networkDelay="0ms",C(t,Te,"f").call(t,{networkSpeed:t.networkSpeed,networkDelay:t.networkDelay,authorizedMicrophonePermissions:t.authorizedMicrophonePermissions,authorizedNotificationPermissions:t.authorizedNotificationPermissions}),C(t,dt,"f").call(t)})),gt.set(this,(function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i,r=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e||this,clearInterval(C(n,je,"f")),O(n,je,void 0,"f"),i=function(){return j(r,void 0,void 0,a.mark((function e(){var t;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.onLine){e.next=15;break}return e.prev=1,e.next=4,C(n,wt,"f").call(n);case 4:t=e.sent,n.networkSpeed=t.networkSpeed,n.networkDelay=t.networkDelay,e.next=13;break;case 9:e.prev=9,e.t0=e.catch(1),n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 13:e.next=17;break;case 15:n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 17:C(this,Te,"f").call(this,{networkSpeed:this.networkSpeed,networkDelay:this.networkDelay,authorizedMicrophonePermissions:this.authorizedMicrophonePermissions,authorizedNotificationPermissions:this.authorizedNotificationPermissions}),C(this,Ce,"f")||(this.testspeeding=!1,this.disposeSoftphoneEnvRequirementCheck());case 19:case"end":return e.stop()}}),e,this,[[1,9]])})))},t.next=6,i();case 6:C(this,Ce,"f")&&O(n,je,d((function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i();case 2:case"end":return e.stop()}}),e)})))}),1e3),"f");case 7:case"end":return t.stop()}}),t,this)})))})),wt.set(this,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return j(t,void 0,void 0,a.mark((function t(){var r,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=[],s=0;s<i;s++)r.push(C(this,kt,"f").call(this,e+"?d="+f()+s,n));return t.abrupt("return",p.all(r).then((function(e){var t=0,n=0;return l(e).call(e,(function(e){t+=Number(e[0]),n+=Number(e[1])})),{networkDelay:(n/i).toFixed(2)+"ms",networkSpeed:(t/i).toFixed(2)+"Mb/s"}})));case 3:case"end":return t.stop()}}),t,this)})))})),kt.set(this,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png?d="+f(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491;return new p((function(n,i){var r=document.createElement("img");r.start=window.performance.now(),r.onload=function(){var e=window.performance.now()-r.start;n([(1e3*t/(1048576*e)).toFixed(2),e])},r.onerror=function(e){i(e)},r.src=e})).catch((function(e){throw e}))})),u(this,"openApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return new p((function(n,i){return j(t,void 0,void 0,a.mark((function t(){var r,s,o,c,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=dn(n,i,e),s=r.xhr,o=r.ajaxData,c=r.contentType,t.next=3,this.getOpenApiSign();case 3:return u=t.sent,f=u.timestamp,l=u.sign,s.setRequestHeader("appKey",C(this,Ve,"f")),s.setRequestHeader("timestamp",String(f)),s.setRequestHeader("sign",l),s.setRequestHeader("Content-type",c||"application/json"),t.next=12,C(this,ke,"f").call(this,s);case 12:s.send(o);case 13:case"end":return t.stop()}}),t,this)})))}))}}),u(this,"requestGateway",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.gatewayApiAjax(v(v({},e),{url:t.getGateway()+e.url}),n)}}),u(this,"gatewayApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new p((function(i,r){return j(t,void 0,void 0,a.mark((function t(){var s,o,c,u,f;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=dn(i,r,e),o=s.xhr,c=s.ajaxData,u=s.contentType,!n){t.next=8;break}return t.next=4,this.getGatewayToken();case 4:f=t.sent,o.setRequestHeader("x-token",f),o.setRequestHeader("seatsToken",f),o.setRequestHeader("x-authority-token",f);case 8:return o.setRequestHeader("x-app-code",3),o.setRequestHeader("content-type",u||"application/json"),t.next=12,C(this,be,"f").call(this,o);case 12:o.send(c);case 13:case"end":return t.stop()}}),t,this)})))}))}}),u(this,"requestOpenApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.openApiAjax(v(v({},e),{url:t.getOpenApi()+e.url}))}}),u(this,"getDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:function(){return j(t,void 0,void 0,a.mark((function e(){var t,n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,et,"f")){e.next=2;break}return e.abrupt("return",C(this,et,"f"));case 2:return e.next=4,T.load();case 4:return t=e.sent,e.next=7,t.get();case 7:return n=e.sent,O(this,et,n.visitorId,"f"),e.abrupt("return",C(this,et,"f"));case 10:case"end":return e.stop()}}),e,this)})))}}),jt.set(this,(function(){return j(t,void 0,void 0,a.mark((function e(){var t,i,r,s;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,V,"m",Tt).call(this)||C(this,te,"f").authorizationUsername&&C(this,te,"f").uri&&C(this,te,"f").authorizationPassword&&C(this,te,"f").transportOptions.server){e.next=15;break}return e.next=3,this.getAgentInfo();case 3:if(200!=(t=e.sent).code){e.next=14;break}s=t.data,C(this,te,"f").authorizationUsername=s.agentExtension,C(this,te,"f").authorizationPassword=s.extensionPwd,C(this,te,"f").uri=n.makeURI(m(i="sip:".concat(s.agentExtension,"@")).call(i,s.wsRegisterAddress)),C(this,te,"f").transportOptions.server=m(r="".concat(s.wsProtocol,"://")).call(r,s.wsRegisterAddress),O(this,Ze,s.agentId,"f"),O(this,We,s.agentTag,"f"),e.next=15;break;case 14:throw new Error(t);case 15:case"end":return e.stop()}}),e,this)})))})),Ct.set(this,(function(){return j(t,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(C(this,te,"f").viaHost){e.next=6;break}return e.t0="",e.next=4,this.getDeviceId();case 4:e.t1=e.sent,C(this,te,"f").viaHost=m(e.t0).call(e.t0,e.t1,".sip");case 6:case"end":return e.stop()}}),e,this)})))})),Dt.set(this,(function(e){var n,i,r,s,o,a,c,u,f,l,h,d,p,v,m,w,k,b,x;C(t,ct,"f").popWindow=null===(s=e["X-Popwindow"])||void 0===s?void 0:s[0].raw,C(t,ct,"f").afterTransferLabour=null===(o=e["X-Aftertransferlabour"])||void 0===o?void 0:o[0].raw,C(t,ct,"f").callId=null===(a=e["X-94callid"])||void 0===a?void 0:a[0].raw,C(t,ct,"f").cid=null===(c=e["X-Cid"])||void 0===c?void 0:c[0].raw,C(t,ct,"f").numberId=null===(u=e["X-Numberid"])||void 0===u?void 0:u[0].raw,C(t,ct,"f").tag=null===(f=e["X-Tag"])||void 0===f?void 0:f[0].raw,C(t,ct,"f").taskId=null===(l=e["X-Taskid"])||void 0===l?void 0:l[0].raw,C(t,ct,"f").voiceType=null===(h=e["X-Voicetype"])||void 0===h?void 0:h[0].raw,C(t,ct,"f").processTime=null===(d=e["X-Processtime"])||void 0===d?void 0:d[0].raw,C(t,ct,"f").userPhone=null===(p=e["X-Userphone"])||void 0===p?void 0:p[0].raw,C(t,ct,"f").autoAnswer=null===(v=e["X-94autoanswer"])||void 0===v?void 0:v[0].raw,C(t,ct,"f").nodeTitle=null===(m=e["X-Nodetitle"])||void 0===m?void 0:g(n=m[0].raw.split("-")).call(n,(function(e){return String.fromCharCode(e)})).join(""),C(t,ct,"f").taskName=null===(w=e["X-Taskname"])||void 0===w?void 0:g(i=w[0].raw.split("-")).call(i,(function(e){return String.fromCharCode(e)})).join(""),C(t,ct,"f").templateTitle=null===(k=e["X-Templatetitle"])||void 0===k?void 0:g(r=k[0].raw.split("-")).call(r,(function(e){return String.fromCharCode(e)})).join(""),C(t,ct,"f").phoneNumber=(null===(b=e["X-Phonenumber"])||void 0===b?void 0:b[0].raw)||(null===(x=e.From)||void 0===x?void 0:x[0].parsed.uri.normal.user)})),_t.set(this,(function(e){switch(e){case i.Initial:case i.Establishing:break;case i.Established:C(t,V,"m",Ft).call(t);break;case i.Terminating:case i.Terminated:var n=h((function(){clearTimeout(n),n=void 0,C(t,se,"f").incomingStatus=!1}),10);C(t,ht,"f").call(t);break;default:throw new Error("Unknown session state.")}})),Yt.set(this,(function(e,n,i){C(t,Ee,"f")&&(O(t,Ne,!1,"f"),C(t,se,"f").reconnectStatus=!1,C(t,Ge,"f")&&(O(t,Ge,!1,"f"),C(t,Wt,"f").call(t,e,n,i)))})),Vt.set(this,(function(){return j(t,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,Ee,"f")){e.next=15;break}return O(this,Ne,!0,"f"),O(this,Ge,!1,"f"),e.next=5,this.getUserAgent().transport.disconnect().catch((function(e){return console.error(e)}));case 5:return console.log("sip transport disconnect"),e.prev=6,e.next=9,C(this,V,"m",Bt).call(this);case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(6);case 13:C(this,Zt,"f").call(this),C(this,V,"m",rn).call(this);case 15:case"end":return e.stop()}}),e,this,[[6,11]])})))})),Jt.set(this,(function(){if(C(t,Ee,"f")){var e=C(t,te,"f").uri.clone(),n=C(t,te,"f").uri.clone(),i=C(t,te,"f").uri.clone();i.user=void 0,C(t,Wt,"f").call(t,i,e,n)}})),Wt.set(this,(function(e,n,i){if(C(t,Ee,"f")){if(C(t,Ge,"f"))return;O(t,Ge,!0,"f"),O(t,Be,h((function(){C(t,V,"m",tn).call(t);var r=t.getUserAgent().userAgentCore,s=r.makeOutgoingRequestMessage("OPTIONS",e,n,i,{});O(t,Pe,r.request(s,{onAccept:function(){console.log("sip ping ok"),O(t,qe,0,"f"),O(t,Pe,void 0,"f"),C(t,Yt,"f").call(t,e,n,i)},onReject:function(r){var s;if(O(t,Pe,void 0,"f"),408===r.message.statusCode||503===r.message.statusCode)if(console.log("sip ping error with code "+r.message.statusCode),C(t,Re,"f")>0&&C(t,qe,"f")>=C(t,Re,"f"))console.log("sip maximum ping attempts reached"),C(t,Vt,"f").call(t);else{var o,a;if(C(t,qe,"f")>0)console.log(m(a="sip ping retry ".concat(C(t,qe,"f")," of ")).call(a,C(t,Re,"f")," fail"));O(t,qe,(s=C(t,qe,"f"),++s),"f"),console.log(m(o="sip ping retry ".concat(C(t,qe,"f")," of ")).call(o,C(t,Re,"f"))),C(t,Yt,"f").call(t,e,n,i)}else O(t,qe,0,"f"),C(t,Yt,"f").call(t,e,n,i)}}),"f")}),1e3*C(t,Ee,"f")),"f")}})),Zt.set(this,(function(){if(C(t,Ee,"f")){if(O(t,Ge,!1,"f"),O(t,Ne,!1,"f"),C(t,Pe,"f")){try{C(t,Pe,"f").dispose()}catch(e){}O(t,Pe,void 0,"f")}C(t,Be,"f")&&C(t,V,"m",tn).call(t)}})),nn.set(this,(function(){if(C(t,He,"f")){if(C(t,Fe,"f"))return;O(t,Fe,!0,"f"),C(t,se,"f").reconnectStatus=!0,O(t,Ye,h((function(){return j(t,void 0,void 0,a.mark((function e(){var t=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,C(this,V,"m",Qt).call(this),0===C(this,Ue,"f")&&console.log("sip reconnect success then register start"),e.next=5,C(this,Z,"f").register({requestDelegate:{onAccept:function(e){console.log("sip reconnect success and register ok"),O(t,Ue,0,"f"),O(t,Fe,!1,"f"),C(t,se,"f").registerStatus=!0,C(t,se,"f").reconnectStatus=!1,C(t,Jt,"f").call(t)},onReject:function(e){return j(t,void 0,void 0,a.mark((function t(){var n,i;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log("sip reconnect success but register fail with code "+e.message.statusCode),O(this,Fe,!1,"f"),!(C(this,Me,"f")<=C(this,Ue,"f"))){t.next=10;break}return console.log("sip maximum register attempts reached"),O(this,Ue,0,"f"),t.next=7,this.getUserAgent().transport.disconnect().catch((function(e){return console.error(e)}));case 7:C(this,V,"m",rn).call(this),t.next=13;break;case 10:O(this,Ue,(n=C(this,Ue,"f"),++n),"f"),console.log(m(i="sip reconnect success and register retry ".concat(C(this,Ue,"f")," of ")).call(i,C(this,Me,"f"))),C(this,nn,"f").call(this);case 13:case"end":return t.stop()}}),t,this)})))}},requestOptions:{extraHeaders:C(this,J,"f")}});case 5:e.next=12;break;case 7:e.prev=7,e.t0=e.catch(0),console.log("sip reconnect then registerer register error",e.t0),O(this,Ue,0,"f"),O(this,Fe,!1,"f");case 12:case"end":return e.stop()}}),e,this,[[0,7]])})))}),1e3*C(t,He,"f")),"f")}})),"object"!==o(s))throw new Error("userAgentOption must be plain object");C(this,V,"m",St).call(this,s),C(this,V,"m",At).call(this,s),C(this,V,"m",yt).call(this,s),C(this,V,"m",It).call(this,s),C(this,V,"m",Rt).call(this,s),C(this,V,"m",xt).call(this,s),C(this,V,"m",bt).call(this,s),O(this,te,C(this,V,"m",Nt).call(this,s),"f")}return t(r,[{key:"volumeValue",get:function(){return C(this,oe,"f")}},{key:"businessAttribute",get:function(){return C(this,ct,"f")}},{key:"getFastOutboundCall",value:function(){return C(this,ct,"f").voiceType===N.LABOUR}},{key:"getSitOutboundCall",value:function(){return C(this,ct,"f").voiceType===N.AI}},{key:"detectNavigatorPermissions",value:function(){var e,t=this;-1===w(e=navigator.userAgent).call(e,"Firefox")?navigator.permissions.query({name:"microphone"}).then((function(e){"granted"===e.state?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1})).catch((function(e){console.log("Got error :",e),t.authorizedMicrophonePermissions=!1})):navigator.mediaDevices.enumerateDevices().then((function(e){""!==k(e).call(e,(function(e){return"audioinput"===e.kind}))[0].label?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1})),navigator.permissions.query({name:"notifications"}).then((function(e){"granted"===e.state?t.authorizedNotificationPermissions=!0:t.authorizedNotificationPermissions=!1})).catch((function(e){console.log("Got error :",e),t.authorizedNotificationPermissions=!1}))}},{key:"getGateway",value:function(){return"1"===C(this,Qe,"f")?"https://gateway.sg.94ai.com":"https://gateway.94ai.com"}},{key:"getGatewayToken",value:function(){return j(this,void 0,void 0,a.mark((function e(){var t,n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,C(this,ye,"f").call(this,C(this,he,"f"));case 2:if(!C(this,ue,"f")){e.next=4;break}return e.abrupt("return",C(this,ue,"f"));case 4:if(this.token){e.next=13;break}return e.next=7,C(this,jt,"f").call(this);case 7:return e.next=9,this.getGatewayAccessToken({corpId:C(this,Ve,"f"),sid:C(this,Ze,"f"),secret:C(this,Je,"f"),seatOnline:!1});case 9:t=e.sent,n=t.token,this.token=n,O(this,fe,f(),"f");case 13:return e.abrupt("return",this.token);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getGatewayAccessToken",value:function(e){return this.requestGateway({url:"/authority/accessToken/openApi",data:e},!1)}},{key:"getCallNumberDetail",value:function(e){return this.requestGateway({url:"/task-aggre/callCenterNumber/get",data:e})}},{key:"getCallNumberChats",value:function(e){return this.requestGateway({url:"/dialogue-aggre/call-center-number/chat/list",data:e})}},{key:"getCallInfo",value:function(){return j(this,void 0,void 0,a.mark((function e(){var t,n,i=this;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=v({},C(this,ct,"f")),n=function(){return j(i,void 0,void 0,a.mark((function e(){var n,i,r,s,o,c,u,f,l,h,d,p,v,w,k,b,x,y,S,A;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.numberId||!t.taskId){e.next=57;break}return n={},e.prev=2,e.next=5,this.getCallNumberDetail({id:t.numberId,taskId:t.taskId});case 5:if(200===(n=e.sent).code){e.next=11;break}return console.error(n.message),t.stop=!0,C(this,Ie,"f").call(this,new Error(n.message)),e.abrupt("return");case 11:e.next=20;break;case 13:return e.prev=13,e.t0=e.catch(2),s=m(i=m(r="当前会话callid:".concat(t.callId,",根据numberId:")).call(r,t.numberId,",taskId:")).call(i,t.taskId,":查询坐席接听状态异常"),console.error(s),t.stop=!0,C(this,Ie,"f").call(this,new Error(n.message)),e.abrupt("return");case 20:if(o=n.data,c=o.callType,u=o.newIntentTag,f=o.intentTag,l=o.number,h=o.numberMd5,d=o.sid,p=o.config,v=o.tag,10!==o.state){e.next=25;break}return console.log("当前会话callid:".concat(t.callId,"已结束")),t.stop=!0,e.abrupt("return");case 25:if(t.callType||(t.callType=c),t.intentTag=u||f,t.number||(t.number=l),t.numberMD5||(t.numberMD5=h),t.agentId||(t.agentId=d),t.tag||(t.tag=v),t.templateId||p&&"string"==typeof p&&(w=JSON.parse(p))&&w.templateId&&(t.templateId=w.templateId),!t.callId){e.next=54;break}return b={},e.prev=34,e.next=37,this.getCallNumberChats({callId:t.callId,taskId:t.taskId});case 37:if(200===(b=e.sent).code){e.next=43;break}return console.error(b.message),t.stop=!0,C(this,Ie,"f").call(this,new Error(b.message)),e.abrupt("return");case 43:e.next=52;break;case 45:return e.prev=45,e.t1=e.catch(34),y=m(x="当前会话根据callId:".concat(t.callId,",taskId:")).call(x,t.taskId,":查询会话对话记录异常"),console.error(y),t.stop=!0,C(this,Ie,"f").call(this,new Error(y)),e.abrupt("return");case 52:t.chats=g(k=b.data).call(k,(function(e){return e.matchinfo&&(e.matchinfo=JSON.parse(e.matchinfo)),e})),C(this,de,"f")[t.callId]=t;case 54:try{C(this,we,"f").call(this,C(this,de,"f")[t.callId])}catch(e){console.log(e)}e.next=60;break;case 57:t.stop=!0,t.taskId||(S="当前会话callid:".concat(t.callId,"的taskId不存在,无法查询通话记录"),console.error(S),C(this,Ie,"f").call(this,new Error(S))),t.numberId||(A="当前会话callid:".concat(t.callId,"的numberId不存在,无法查询通话记录"),console.error(A),C(this,Ie,"f").call(this,new Error(A)));case 60:case"end":return e.stop()}}),e,this,[[2,13],[34,45]])})))},e.prev=2;case 3:if(!t.stop){e.next=6;break}return e.abrupt("break",14);case 6:return e.next=8,n();case 8:if(!t.stop){e.next=10;break}return e.abrupt("break",14);case 10:return e.next=12,new p((function(e){var t=h((function(){return j(i,void 0,void 0,a.mark((function n(){return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:clearTimeout(t),t=void 0,e(!0);case 3:case"end":return n.stop()}}),n)})))}),3e3)}));case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),C(this,Ie,"f").call(this,e.t0);case 19:case"end":return e.stop()}}),e,this,[[2,16]])})))}},{key:"refreshCallChatInfo",value:function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(C(this,ct,"f").numberId&&C(this,ct,"f").callId&&C(this,ct,"f").taskId&&C(this,ut,"f"))){e.next=3;break}return e.next=3,this.getCallInfo();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getOpenApi",value:function(){return C(this,Ke,"f")?function(e){if(!e)return!1;var t=/^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;return!!/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||("//"===A(e).call(e,0,2)?t.test(A(e).call(e,2,e.length)):"http://"===A(e).call(e,0,7)?t.test(A(e).call(e,7,e.length)):"https://"===A(e).call(e,0,8)?t.test(A(e).call(e,8,e.length)):t.test(e))}(C(this,Ke,"f"))?C(this,Ke,"f"):"1"===C(this,Qe,"f")?"1"===C(this,$e,"f")?"https://seatsg.94ai.com/sgopenapi":"https://seatsg.94ai.com/openapi":"1"===C(this,$e,"f")?"https://seat.94ai.com/sgopenapi":"https://seat.94ai.com/openapi":"https://seat.94ai.com/openapi"}},{key:"getAgentInfo",value:function(){return this.requestOpenApi({url:"/v1/agent/getAgent",data:{agentTag:C(this,We,"f"),agentId:C(this,Ze,"f")}})}},{key:"getOpenApiSign",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f(),i=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return j(this,void 0,void 0,a.mark((function s(){return a.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,C(this,xe,"f").call(this,C(this,le,"f"));case 2:return s.abrupt("return",{sign:null!==(e=C(this,ae,"f"))&&void 0!==e?e:I.enc.Base64.stringify(I.HmacSHA1(i||C(this,Ve,"f")+n,r||C(this,Je,"f"))),timestamp:null!==(t=C(this,ce,"f"))&&void 0!==t?t:n});case 3:case"end":return s.stop()}}),s,this)})))}},{key:"updateOpenApiAgentStatus",value:function(e){return this.requestOpenApi({url:"/v1/agent/updateAgentStatus",data:{agentTag:C(this,We,"f"),agentId:C(this,Ze,"f"),agentStatus:e}})}},{key:"importOpenApiAgentCustomer",value:function(e){return this.requestOpenApi({url:"/v1/task/importAgentCustomer",data:{agentTag:C(this,We,"f"),agentId:C(this,Ze,"f"),callType:1001,customers:[{number:e}]}})}},{key:"callNumber",value:function(e){return this.importOpenApiAgentCustomer(e)}},{key:"toggleNap",value:function(e){return e?this.updateOpenApiAgentStatus(3):this.updateOpenApiAgentStatus(1)}},{key:"refreshSign",value:function(e){O(this,ae,e,"f")}},{key:"prepareUserAgent",value:function(e,t){var n;return j(this,void 0,void 0,a.mark((function i(){var r,s,o,c,u,f,l,h,d,p,m;return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=(r=e||{}).refresh,o=r.registererOptions,c=r.registererRegisterOptions,u=r.extraHeaders,f=r.authorizationUsername,l=r.authorizationPassword,h=r.uri,d=r.contactName,p=r.transportOptions,i.next=3,this.dispose();case 3:return C(this,te,"f").uri=null!=h?h:C(this,te,"f").uri,C(this,te,"f").authorizationUsername=null!=f?f:C(this,te,"f").authorizationUsername,C(this,te,"f").authorizationPassword=null!=l?l:C(this,te,"f").authorizationPassword,C(this,te,"f").contactName=null!==(n=null!=d?d:f)&&void 0!==n?n:C(this,te,"f").contactName,p&&(C(this,te,"f").transportOptions=v(v({},C(this,te,"f").transportOptions),p)),i.prev=8,C(this,V,"m",At).call(this,e),i.next=12,C(this,jt,"f").call(this);case 12:return i.next=14,C(this,Ct,"f").call(this);case 14:return C(this,V,"m",Et).call(this,{refresh:s}),i.next=17,C(this,V,"m",an).call(this);case 17:return t&&C(this,V,"m",on).call(this,t),i.next=20,C(this,V,"m",cn).call(this,{registererOptions:o,registererRegisterOptions:c,extraHeaders:u},C(this,st,"f"));case 20:return m=i.sent,i.abrupt("return",m);case 24:return i.prev=24,i.t0=i.catch(8),i.next=28,this.dispose();case 28:throw i.t0;case 29:case"end":return i.stop()}}),i,this,[[8,24]])})))}},{key:"dispose",value:function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,C(this,V,"m",Ot).call(this),e.next=4,C(this,V,"m",Ht).call(this);case 4:e.next=10;break;case 6:e.prev=6,e.t0=e.catch(0),C(this,V,"m",Ut).call(this),console.log("sip dispose with error",e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,6]])})))}},{key:"ignoreInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return C(this,se,"f").incomingStatus=!1,t.next=3,this.getCurrentInvitation().reject(e);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"acceptInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,new p((function(t,i){j(n,void 0,void 0,a.mark((function n(){var r,s;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=null==e?void 0:e.onAck,s=null==e?void 0:e.onAckTimeout,null==e||delete e.onAck,null==e||delete e.onAckTimeout,n.next=7,this.getCurrentInvitation().accept(v({sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}},onAck:function(e){t(e),null==r||r()},onAckTimeout:function(){null==s||s(),i(new Error("接听响应超时"))}},e||{}));case 7:n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),i(n.t0);case 12:case"end":return n.stop()}}),n,this,[[0,9]])})))}));case 3:C(this,se,"f").incomingStatus&&(C(this,se,"f").incomingStatus=!1,C(this,se,"f").answerStatus=!0),t.next=10;break;case 6:throw t.prev=6,t.t0=t.catch(0),C(this,se,"f").incomingStatus=!1,t.t0;case 10:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"hangUpInvite",value:function(e){return j(this,void 0,void 0,a.mark((function t(){var n,r,s,o,c,u=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=e||{}).rejectOptions,s=n.byeOptions,o=n.extraHeaders,c=n.scoutResponse,t.abrupt("return",new p((function(e,t){return j(u,void 0,void 0,a.mark((function n(){var u,f,l,h,d,p,m,g,w;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,m=null===(u=(p=s||{}).requestDelegate)||void 0===u?void 0:u.onAccept,g=null===(f=p.requestDelegate)||void 0===f?void 0:f.onReject,null===(l=p.requestDelegate)||void 0===l||delete l.onAccept,null===(h=p.requestDelegate)||void 0===h||delete h.onReject,w=C(this,V,"m",qt).call(this,{onAccept:function(t){console.log("sip bye success"),e(t),null==m||m(t)},onReject:function(e){null==g||g(e),t(new Error("sip bye fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,n.t0=null===(d=C(this,ne,"f"))||void 0===d?void 0:d.state,n.next=n.t0===i.Initial||n.t0===i.Establishing?11:n.t0===i.Established?15:n.t0===i.Terminating||n.t0===i.Terminated?19:21;break;case 11:return n.next=13,C(this,ne,"f").reject(v({extraHeaders:o},r||{}));case 13:return e(!0),n.abrupt("break",21);case 15:return n.next=17,C(this,ne,"f").bye(v({requestDelegate:w,requestOptions:{extraHeaders:o}},p));case 17:return c||e(!0),n.abrupt("break",21);case 19:return e(!0),n.abrupt("break",21);case 21:n.next=26;break;case 23:n.prev=23,n.t1=n.catch(0),t(n.t1);case 26:return n.prev=26,C(this,se,"f").incomingStatus=!1,C(this,se,"f").answerStatus=!1,n.finish(26);case 30:case"end":return n.stop()}}),n,this,[[0,23,26,30]])})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"sendStarDtmf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new p((function(t,i){return j(n,void 0,void 0,a.mark((function n(){var r,s,o,c;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,s=(r=e||{}).extraHeaders,o=r.requestDelegate,c=C(this,V,"m",qt).call(this,{onAccept:function(e){console.log("sip send dtmf Signal=* success"),t(e)},onReject:function(e){i(new Error("sip send dtmf Signal=* fail with code "+e.message.statusCode))}},o),delete r.requestDelegate,n.next=7,this.getCurrentInvitation().info(v({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal=*\r\nDuration=100"},extraHeaders:s},requestDelegate:c},r));case 7:C(this,lt,"f").call(this),n.next=13;break;case 10:n.prev=10,n.t0=n.catch(0),i(n.t0);case 13:case"end":return n.stop()}}),n,this,[[0,10]])})))})));case 1:case"end":return t.stop()}}),t)})))}},{key:"sendCurrentInviter",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=(e||{}).extraHeaders,t.next=3,this.getCurrentInviter().invite(v({requestOptions:{extraHeaders:n}},e));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"muteRemoteAudio",value:function(){var e;l(e=C(this,$,"f").getReceivers()).call(e,(function(e){e.track.enabled=!1}))}},{key:"unMuteRemoteAudio",value:function(){var e;l(e=C(this,$,"f").getReceivers()).call(e,(function(e){e.track.enabled=!0}))}},{key:"muteLocalAudio",value:function(){var e;l(e=C(this,$,"f").getSenders()).call(e,(function(e){e.track.enabled=!1}))}},{key:"unMuteLocalAudio",value:function(){var e;l(e=C(this,$,"f").getSenders()).call(e,(function(e){e.track.enabled=!0}))}},{key:"getUserAgentStatue",value:function(){return C(this,se,"f")}},{key:"getUserAgent",value:function(){return C(this,W,"f")||O(this,W,new n(C(this,te,"f")),"f"),C(this,W,"f")}},{key:"getSessionDescriptionHandler",value:function(){return C(this,K,"f")}},{key:"getPeerConnection",value:function(){return C(this,$,"f")}},{key:"getSenders",value:function(){return C(this,ee,"f")}},{key:"getReceivers",value:function(){return C(this,Q,"f")}},{key:"getStream",value:function(){var e,t=this;return C(this,re,"f")||O(this,re,new MediaStream,"f"),l(e=C(this,Q,"f")).call(e,(function(e){e.track&&C(t,re,"f").addTrack(e.track)})),C(this,re,"f")}},{key:"getCurrentInviter",value:function(){if(!C(this,ie,"f"))throw new Error("No currentInviter, please call createCurrentInviter");return C(this,ie,"f")}},{key:"getCurrentInvitation",value:function(){return C(this,ne,"f")}}]),r}();J=new b,W=new b,Z=new b,K=new b,$=new b,Q=new b,ee=new b,te=new b,ne=new b,ie=new b,re=new b,se=new b,oe=new b,ae=new b,ce=new b,ue=new b,fe=new b,le=new b,he=new b,de=new b,pe=new b,ve=new b,me=new b,ge=new b,we=new b,ke=new b,be=new b,xe=new b,ye=new b,Se=new b,Ae=new b,Ie=new b,Te=new b,je=new b,Ce=new b,Oe=new b,De=new b,Ee=new b,Re=new b,qe=new b,Ne=new b,Pe=new b,He=new b,Me=new b,Ue=new b,ze=new b,Le=new b,Xe=new b,Ge=new b,Fe=new b,_e=new b,Be=new b,Ye=new b,Ve=new b,Je=new b,We=new b,Ze=new b,Ke=new b,$e=new b,Qe=new b,et=new b,tt=new b,nt=new b,it=new b,rt=new b,st=new b,ot=new b,at=new b,ct=new b,ut=new b,ft=new b,lt=new b,ht=new b,dt=new b,pt=new b,vt=new b,mt=new b,gt=new b,wt=new b,kt=new b,jt=new b,Ct=new b,Dt=new b,_t=new b,Yt=new b,Vt=new b,Jt=new b,Wt=new b,Zt=new b,nn=new b,V=new x,bt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O(this,ke,null!==(e=n.openXhrIntercept)&&void 0!==e?e:C(this,ke,"f"),"f"),O(this,be,null!==(t=n.gatewayXhrIntercept)&&void 0!==t?t:C(this,be,"f"),"f")},xt=function(){var e,t,n,i,r,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O(this,ut,null!==(e=o.enableChatInfoPush)&&void 0!==e?e:C(this,ut,"f"),"f"),O(this,ft,null!==(t=o.enableVolumnTrack)&&void 0!==t?t:C(this,ft,"f"),"f"),O(this,ge,null!==(n=o.refreshSpeekVolumn)&&void 0!==n?n:C(this,ge,"f"),"f"),O(this,Te,null!==(i=o.refreshRequirementCheck)&&void 0!==i?i:C(this,Te,"f"),"f"),O(this,we,null!==(r=o.refreshChat)&&void 0!==r?r:C(this,we,"f"),"f"),O(this,Ie,null!==(s=o.refreshChatErrorCallback)&&void 0!==s?s:C(this,Ie,"f"),"f")},yt=function(){var e,t,n,i,r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O(this,ue,null!==(e=s.token)&&void 0!==e?e:C(this,ue,"f"),"f"),O(this,fe,null!==(t=s.tokenTimestamp)&&void 0!==t?t:C(this,fe,"f"),"f"),O(this,he,null!==(n=s.tokenExpirationTime)&&void 0!==n?n:C(this,he,"f"),"f"),C(this,ue,"f")&&!C(this,fe,"f")&&O(this,fe,f(),"f"),O(this,ye,null!==(i=s.tokenCheck)&&void 0!==i?i:C(this,ye,"f"),"f"),O(this,Ae,null!==(r=s.tokenOverdued)&&void 0!==r?r:C(this,Ae,"f"),"f")},St=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O(this,st,null!==(e=i.clusterMode)&&void 0!==e?e:C(this,st,"f"),"f"),O(this,ot,null!==(t=i.reClusterRegisterTimeout)&&void 0!==t?t:C(this,ot,"f"),"f"),O(this,at,null!==(n=i.reClusterConnectTimeout)&&void 0!==n?n:C(this,at,"f"),"f")},At=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.agentId,s=i.agentTag,o=i.appKey,a=i.appSecret,c=i.openBaseUrl,u=i.sg,f=i.sgOpen,l=i.sign,h=i.timestamp;O(this,Ze,null!=r?r:C(this,Ze,"f"),"f"),O(this,We,null!=s?s:C(this,We,"f"),"f"),O(this,Ve,null!=o?o:C(this,Ve,"f"),"f"),O(this,Je,null!=a?a:C(this,Je,"f"),"f"),O(this,Ke,null!=c?c:C(this,Ke,"f"),"f"),O(this,Qe,null!=u?u:C(this,Qe,"f"),"f"),O(this,$e,null!=f?f:C(this,$e,"f"),"f"),O(this,ae,null!=l?l:C(this,ae,"f"),"f"),O(this,ce,null!=h?h:C(this,ce,"f"),"f"),O(this,le,null!==(e=i.signExpirationTime)&&void 0!==e?e:C(this,le,"f"),"f"),O(this,xe,null!==(t=i.signCheck)&&void 0!==t?t:C(this,xe,"f"),"f"),O(this,Se,null!==(n=i.signOverdued)&&void 0!==n?n:C(this,Se,"f"),"f")},It=function(e){e.sipHeaders&&(O(this,J,e.sipHeaders,"f"),delete e.sipHeaders)},Tt=function(){return!(!C(this,Ze,"f")&&!C(this,We,"f")||!(C(this,Ve,"f")&&C(this,Je,"f")||C(this,ae,"f")&&C(this,ce,"f")))},Ot=function(){C(this,V,"m",Mt).call(this),C(this,V,"m",Xt).call(this),C(this,V,"m",Gt).call(this),C(this,V,"m",Lt).call(this),C(this,V,"m",zt).call(this),C(this,V,"m",Kt).call(this),C(this,V,"m",$t).call(this),C(this,V,"m",Ut).call(this),C(this,ht,"f").call(this),O(this,ct,{},"f"),O(this,de,{},"f")},Et=function(e){O(this,se,s(JSON.parse(c(z)),"function"==typeof e.refresh?e.refresh:C(this,nt,"f")),"f")},Rt=function(e){var t,n,i,r,s,o,a,c,u,f,l,h,d,p,v;O(this,Oe,null!==(i=null!==(t=e.reconnectionAttempts)&&void 0!==t?t:null===(n=null==e?void 0:e.transportOptions)||void 0===n?void 0:n.maxReconnectionAttempts)&&void 0!==i?i:C(this,Oe,"f"),"f"),O(this,De,null!==(a=null!==(s=null!==(r=e.reconnectionInterval)&&void 0!==r?r:e.reconnectionDelay)&&void 0!==s?s:null===(o=null==e?void 0:e.transportOptions)||void 0===o?void 0:o.reconnectionTimeout)&&void 0!==a?a:C(this,De,"f"),"f"),O(this,ze,null!==(u=null===(c=e.transportOptions)||void 0===c?void 0:c.keepAliveInterval)&&void 0!==u?u:C(this,ze,"f"),"f"),O(this,Le,null!==(l=null===(f=e.transportOptions)||void 0===f?void 0:f.keepAliveDebounce)&&void 0!==l?l:C(this,Le,"f"),"f"),O(this,He,null!==(h=e.registerInterval)&&void 0!==h?h:C(this,He,"f"),"f"),O(this,Ee,null!==(d=e.optionsPingInterval)&&void 0!==d?d:C(this,Ee,"f"),"f"),O(this,Re,null!==(p=e.optionsPingAttempts)&&void 0!==p?p:C(this,Re,"f"),"f"),O(this,Me,null!==(v=e.registerAttempts)&&void 0!==v?v:C(this,Me,"f"),"f")},qt=function(e,t){var n,i=this;return t?(l(n=y(t)).call(n,(function(n){if(t[n]&&"function"==typeof t[n])if(e[n]){if("function"==typeof e[n]){var r=e[n];e[n]=function(e){return j(i,void 0,void 0,a.mark((function i(){return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,t[n](e);case 2:return i.next=4,r(e);case 4:case"end":return i.stop()}}),i)})))}}}else e[n]=t[n]})),e):e},Nt=function(e){var t,n=this,i={delegate:{onConnect:function(){return j(n,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log("sip connected"),C(this,Jt,"f").call(this);case 2:case"end":return e.stop()}}),e,this)})))},onInvite:function(e){C(n,Dt,"f").call(n,e.incomingInviteRequest.message.headers),n.refreshCallChatInfo(),C(n,V,"m",Pt).call(n),O(n,ne,e,"f"),C(n,se,"f").incomingStatus=!0,e.stateChange.addListener(C(n,_t,"f"))},onDisconnect:function(e){return j(n,void 0,void 0,a.mark((function t(){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("sip disconnected"),n=!1,C(this,Ee,"f")>0&&(n=C(this,Ne,"f"),C(this,Zt,"f").call(this)),t.prev=3,t.next=6,C(this,V,"m",Bt).call(this);case 6:t.next=10;break;case 8:t.prev=8,t.t0=t.catch(3);case 10:(e||n)&&C(this,V,"m",rn).call(this);case 11:case"end":return t.stop()}}),t,this,[[3,8]])})))}}};e.delegate?l(t=y(e.delegate)).call(t,(function(t){var r=t;if(e.delegate[r]&&"function"==typeof e.delegate[r]){var s=e.delegate[r];e.delegate[r]=function(e){return j(n,void 0,void 0,a.mark((function t(){var n,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(o=(n=i.delegate)[r])||void 0===o||o.call(n,e),t.next=3,s(e);case 3:case"end":return t.stop()}}),t)})))}}})):e.delegate=i.delegate;return e.reconnectionAttempts=0,e.transportOptions=v(v({},e.transportOptions||{}),{keepAliveInterval:C(this,ze,"f"),keepAliveDebounce:C(this,Le,"f")}),void 0===e.sessionDescriptionHandlerFactoryOptions&&(e.sessionDescriptionHandlerFactoryOptions={iceGatheringTimeout:2e3,peerConnectionConfiguration:{iceServers:[]}}),v(v({},U),e)},Pt=function(){C(this,ne,"f")&&(C(this,ne,"f").dispose(),O(this,ne,void 0,"f"))},Ht=function(){return j(this,void 0,void 0,a.mark((function e(){return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!C(this,W,"f")){e.next=4;break}return e.next=3,C(this,W,"f").stop();case 3:O(this,W,void 0,"f");case 4:case"end":return e.stop()}}),e,this)})))},Mt=function(){var e;C(this,re,"f")&&(l(e=C(this,re,"f").getTracks()).call(e,(function(e){e.stop()})),O(this,re,void 0,"f"))},Ut=function(){var e,t=this;l(e=y(z)).call(e,(function(e){var n=e;C(t,se,"f")[n]=z[n]}))},zt=function(){C(this,K,"f")&&(C(this,K,"f").close(),O(this,K,void 0,"f"))},Lt=function(){C(this,$,"f")&&(C(this,$,"f").close(),O(this,$,void 0,"f"))},Xt=function(){O(this,ee,[],"f")},Gt=function(){O(this,Q,[],"f")},Ft=function(){var e=this.getCurrentInvitation().sessionDescriptionHandler;C(this,V,"m",Lt).call(this),C(this,V,"m",zt).call(this),C(this,V,"m",Xt).call(this),C(this,V,"m",Gt).call(this),O(this,K,e,"f"),O(this,$,e.peerConnection,"f"),O(this,ee,C(this,$,"f").getSenders(),"f"),O(this,Q,C(this,$,"f").getReceivers(),"f"),(this.getFastOutboundCall()||!this.getSitOutboundCall()&&this.notNeedSendStarDtmf())&&C(this,lt,"f").call(this)},Bt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j(this,void 0,void 0,a.mark((function t(){var n=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!C(this,Z,"f")){t.next=3;break}return console.log("sip due to disconnection, unregistered"),t.abrupt("return",new p((function(t,i){return j(n,void 0,void 0,a.mark((function n(){var r,s;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=e||{},s=C(this,V,"m",qt).call(this,{onAccept:function(e){console.log("sip unregister successed"),t(e)},onReject:function(e){i(new Error("sip unregister fail with code "+e.message.statusCode))}},r.requestDelegate),delete e.requestDelegate,n.next=6,C(this,Z,"f").unregister(v({requestDelegate:s},e));case 6:n.next=11;break;case 8:n.prev=8,n.t0=n.catch(0),i(n.t0);case 11:case"end":return n.stop()}}),n,this,[[0,8]])})))})));case 3:case"end":return t.stop()}}),t,this)})))},Kt=function(){C(this,V,"m",Qt).call(this),C(this,V,"m",en).call(this),C(this,V,"m",tn).call(this),O(this,Fe,!1,"f"),O(this,Xe,!1,"f"),O(this,Ge,!1,"f")},$t=function(){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(clearTimeout(C(this,it,"f")),O(this,it,void 0,"f")),e&&(clearTimeout(C(this,rt,"f")),O(this,rt,void 0,"f"))},Qt=function(){clearTimeout(C(this,Ye,"f")),O(this,Ye,void 0,"f")},en=function(){clearTimeout(C(this,_e,"f")),O(this,_e,void 0,"f")},tn=function(){clearTimeout(C(this,Be,"f")),O(this,Be,void 0,"f")},rn=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return j(this,void 0,void 0,a.mark((function n(){var i=this;return a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!C(this,De,"f")){n.next=12;break}if(C(this,se,"f").reconnectStatus=!0,!C(this,Xe,"f")){n.next=4;break}return n.abrupt("return");case 4:if(!(t>C(this,Oe,"f"))){n.next=9;break}return console.log("sip maximum reconnection attempts reached"),n.next=8,this.dispose();case 8:return n.abrupt("return");case 9:console.log("sip reconnection attempt..."),O(this,Xe,!0,"f"),O(this,_e,h((function(){C(i,V,"m",en).call(i),i.getUserAgent().reconnect().then((function(){return j(i,void 0,void 0,a.mark((function e(){var n;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log(m(n="sip reconnection attempt ".concat(t," of ")).call(n,C(this,Oe,"f")," - succeeded")),O(this,Xe,!1,"f"),C(this,nn,"f").call(this);case 3:case"end":return e.stop()}}),e,this)})))})).catch((function(n){var r;console.error(n),console.log(m(r="sip reconnection attempt ".concat(t," of ")).call(r,C(i,Oe,"f")," - failed")),O(i,Xe,!1,"f"),C(i,V,"m",e).call(i,++t)}))}),1===t?0:1e3*C(this,De,"f")),"f");case 12:case"end":return n.stop()}}),n,this)})))},sn=function(e){var t,n=this;return l(t=y(e)).call(t,(function(t){var i=t;if("function"==typeof(null==e?void 0:e[i])){var r=e[i];e[i]=function(e){return j(n,void 0,void 0,a.mark((function t(){var n,s;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(s=(n=C(this,te,"f").delegate)[i])||void 0===s||s.call(n,e),t.next=3,r(e);case 3:case"end":return t.stop()}}),t,this)})))}}})),e},on=function(e){var t=this.getUserAgent();return t.delegate=C(this,V,"m",sn).call(this,e),t},an=function(){return j(this,void 0,void 0,a.mark((function e(){var t;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getUserAgent(),e.next=3,t.start();case 3:if(t.isConnected()){e.next=6;break}return e.next=6,t.reconnect();case 6:if(t.isConnected()){e.next=8;break}throw new Error("链接失败,请稍后再试");case 8:return C(this,se,"f").connectStatus=!0,e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)})))},cn=function e(t){var i=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=t||{},c=o.registererOptions,u=o.registererRegisterOptions,f=o.extraHeaders;return new p((function(t,o){return j(i,void 0,void 0,a.mark((function i(){var l,d,p,m,g=this;return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return l=this.getUserAgent(),O(this,Z,new r(l,v({extraHeaders:f||C(this,J,"f")},c||{})),"f"),p=u||{},m=C(this,V,"m",qt).call(this,{onAccept:function(e){d=e,C(g,V,"m",$t).call(g),C(g,se,"f").registerStatus=!0,t(l)},onReject:function(e){C(g,V,"m",$t).call(g),o(new Error("sip register fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,s&&O(this,it,h((function(){return j(g,void 0,void 0,a.mark((function i(){var s=this;return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(d){i.next=14;break}O(this,rt,h((function(){return j(s,void 0,void 0,a.mark((function i(){var r;return a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(C(this,V,"m",$t).call(this,!1,!0),d){i.next=22;break}i.prev=2;try{C(this,Z,"f").dispose()}catch(e){}return C(this,V,"m",Ot).call(this),C(this,Zt,"f").call(this),O(this,qe,0,"f"),O(this,Ue,0,"f"),i.next=10,C(this,W,"f").transport.dispose();case 10:return O(this,W,new n(C(this,te,"f")),"f"),i.next=13,C(this,V,"m",an).call(this);case 13:return i.next=15,C(this,V,"m",e).call(this,{registererOptions:c,registererRegisterOptions:u,extraHeaders:f});case 15:r=i.sent,t(r),i.next=22;break;case 19:i.prev=19,i.t0=i.catch(2),o(i.t0);case 22:case"end":return i.stop()}}),i,this,[[2,19]])})))}),C(this,at,"f")),"f");try{C(this,Z,"f").dispose()}catch(e){}return O(this,Z,new r(l,v({extraHeaders:f||C(this,J,"f")},c||{})),"f"),C(this,V,"m",$t).call(this,!0,!1),i.prev=5,i.next=8,C(this,Z,"f").register(v({requestDelegate:m,requestOptions:{extraHeaders:f||C(this,J,"f")}},p));case 8:i.next=14;break;case 10:i.prev=10,i.t0=i.catch(5),C(this,V,"m",$t).call(this),o(i.t0);case 14:case"end":return i.stop()}}),i,this,[[5,10]])})))}),C(this,ot,"f")),"f"),i.prev=6,i.next=9,C(this,Z,"f").register(v({requestDelegate:m,requestOptions:{extraHeaders:f||C(this,J,"f")}},p));case 9:i.next=15;break;case 11:i.prev=11,i.t0=i.catch(6),C(this,V,"m",$t).call(this),o(i.t0);case 15:case"end":return i.stop()}}),i,this,[[6,11]])})))}))};var gn=function(){function n(){e(this,n)}return t(n,null,[{key:"getUserAgentManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,pn,"f",vn)||O(this,pn,new mn(e),"f",vn),C(this,pn,"f",vn)}},{key:"hasUserAgentManager",value:function(){return!!C(this,pn,"f",vn)}},{key:"newUserAgentManager",value:function(){return new mn(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dispose",value:function(){if(C(this,pn,"f",vn))try{C(this,pn,"f",vn).dispose()}catch(e){}finally{O(this,pn,void 0,"f",vn)}}}]),n}();pn=gn,vn={value:void 0};export{gn as UserAgentFactory,mn as UserAgentManager,ln as accumulateSec,hn as accumulationTimer,Y as cleanupMedia,G as getDevicePermission,L as getMedia,un as getTimes,fn as getZeorTime,B as pauseMedia,_ as playMedia,F as requestMicroPhonePermission,X as stopStreamTracks,U as userAgentDefault,z as userAgentStatus};