ue-softphone-sdk-beta 3.0.21 → 3.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/types/index.d.ts +1 -4
- package/dist/lib/ue-soft-phone.min.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/ue-softphone-sdk.js +1 -1
- package/package.json +1 -1
- package/sdkdemo/ue-load.min.js +3 -3
- package/sdkdemo/ue.lib.css +1 -1
- package/sdkdemo/ue.min.js +6 -6
- package/sdkdemo/webphone_ez.html +63 -47
- package/src/index.ts +78 -21
|
@@ -155,10 +155,6 @@ export default class ueSoftphone {
|
|
|
155
155
|
constructor(options?: InitOptions);
|
|
156
156
|
private init;
|
|
157
157
|
private login;
|
|
158
|
-
/**
|
|
159
|
-
* 座席互踢后调用退出登录方法
|
|
160
|
-
*/
|
|
161
|
-
static exitLogOut(): void;
|
|
162
158
|
static createEventHandle(callbacks?: any): void;
|
|
163
159
|
private getWebrtcInfo;
|
|
164
160
|
private initAttachEvent;
|
|
@@ -168,6 +164,7 @@ export default class ueSoftphone {
|
|
|
168
164
|
private initAgentQueue;
|
|
169
165
|
private initQueue;
|
|
170
166
|
static createQueueMonitorEventHandle(callbacks?: any): void;
|
|
167
|
+
static createopenNlsTransEventHandle(callbacks?: any): void;
|
|
171
168
|
listenCallQueueEvent: (callbacks: any) => void;
|
|
172
169
|
listenTranslationEvent: (callbacks: any) => void;
|
|
173
170
|
static useDefaultDependencies(deps: any): {
|
|
@@ -19,4 +19,4 @@ const t$1=Object.create(null);t$1.open="0",t$1.close="1",t$1.ping="2",t$1.pong="
|
|
|
19
19
|
* @since jsrsasign 2.1
|
|
20
20
|
* @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
|
|
21
21
|
*/
|
|
22
|
-
var KJUR={};void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var n=t.substr(1).length;n%2==1?n+=1:t.match(/^[0-7]/)||(n+=2);for(var r="",i=0;i<n;i++)r+="f";t=new BigInteger(r,16).xor(e).add(BigInteger.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return hextopem(e,t)},this.newObject=function(e){var t=KJUR.asn1,n=t.DERBoolean,r=t.DERInteger,i=t.DERBitString,s=t.DEROctetString,o=t.DERNull,a=t.DERObjectIdentifier,c=t.DEREnumerated,u=t.DERUTF8String,h=t.DERNumericString,l=t.DERPrintableString,d=t.DERTeletexString,p=t.DERIA5String,g=t.DERUTCTime,f=t.DERGeneralizedTime,m=t.DERSequence,v=t.DERSet,y=t.DERTaggedObject,b=t.ASN1Util.newObject,S=Object.keys(e);if(1!=S.length)throw"key of param shall be only one.";var T=S[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+T+":"))throw"undefined key: "+T;if("bool"==T)return new n(e[T]);if("int"==T)return new r(e[T]);if("bitstr"==T)return new i(e[T]);if("octstr"==T)return new s(e[T]);if("null"==T)return new o(e[T]);if("oid"==T)return new a(e[T]);if("enum"==T)return new c(e[T]);if("utf8str"==T)return new u(e[T]);if("numstr"==T)return new h(e[T]);if("prnstr"==T)return new l(e[T]);if("telstr"==T)return new d(e[T]);if("ia5str"==T)return new p(e[T]);if("utctime"==T)return new g(e[T]);if("gentime"==T)return new f(e[T]);if("seq"==T){for(var w=e[T],R=[],E=0;E<w.length;E++){var I=b(w[E]);R.push(I)}return new m({array:R})}if("set"==T){for(w=e[T],R=[],E=0;E<w.length;E++){I=b(w[E]);R.push(I)}return new v({array:R})}if("tag"==T){var _=e[T];if("[object Array]"===Object.prototype.toString.call(_)&&3==_.length){var A=b(_[2]);return new y({tag:_[0],explicit:_[1],obj:A})}var C={};if(void 0!==_.explicit&&(C.explicit=_.explicit),void 0!==_.tag&&(C.tag=_.tag),void 0===_.obj)throw"obj shall be specified for 'tag'.";return C.obj=b(_.obj),new y(C)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},KJUR.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",n=parseInt(e.substr(0,2),16),r=(t=Math.floor(n/40)+"."+n%40,""),i=2;i<e.length;i+=2){var s=("00000000"+parseInt(e.substr(i,2),16).toString(2)).slice(-8);if(r+=s.substr(1,7),"0"==s.substr(0,1))t=t+"."+new BigInteger(r,2).toString(10),r=""}return t},KJUR.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},n=function(e){var n="",r=new BigInteger(e,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";r=s+r;for(o=0;o<r.length-1;o+=7){var a=r.substr(o,7);o!=r.length-7&&(a="1"+a),n+=t(parseInt(a,2))}return n};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var r="",i=e.split("."),s=40*parseInt(i[0])+parseInt(i[1]);r+=t(s),i.splice(0,2);for(var o=0;o<i.length;o++)r+=n(i[o]);return r},KJUR.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n=0,v="+this.hV;var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var n=t.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+n).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(e){KJUR.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(this.s)},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(e){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){return utc=e.getTime()+6e4*e.getTimezoneOffset(),new Date(utc)},this.formatDate=function(e,t,n){var r=this.zeroPadding,i=this.localDateToUTC(e),s=String(i.getFullYear());"utc"==t&&(s=s.substr(2,2));var o=s+r(String(i.getMonth()+1),2)+r(String(i.getDate()),2)+r(String(i.getHours()),2)+r(String(i.getMinutes()),2)+r(String(i.getSeconds()),2);if(!0===n){var a=i.getMilliseconds();if(0!=a){var c=r(String(a),3);o=o+"."+(c=c.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(e)},this.setByDateValue=function(e,t,n,r,i,s){var o=new Date(Date.UTC(e,t-1,n,r,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(e){KJUR.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(e){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new BigInteger(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=KJUR.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var n="0"+e;this.hTLV=null,this.isModified=!0,this.hV=n+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var n=0;n<=t;n++)e+="0";var r="";for(n=0;n<e.length-1;n+=8){var i=e.substr(n,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),r+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+t+r},this.setByBooleanArray=function(e){for(var t="",n=0;n<e.length;n++)1==e[n]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},YAHOO.lang.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=KJUR.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}KJUR.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},YAHOO.lang.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},YAHOO.lang.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},n=function(e){var n="",r=new BigInteger(e,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";r=s+r;for(o=0;o<r.length-1;o+=7){var a=r.substr(o,7);o!=r.length-7&&(a="1"+a),n+=t(parseInt(a,2))}return n};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var r="",i=e.split("."),s=40*parseInt(i[0])+parseInt(i[1]);r+=t(s),i.splice(0,2);for(var o=0;o<i.length;o++)r+=n(i[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(e){var t=KJUR.asn1.x509.OID.name2oid(e);if(""===t)throw"DERObjectIdentifier oidName undefined: "+e;this.setValueOidString(t)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e):void 0!==e.oid?this.setValueOidString(e.oid):void 0!==e.hex?this.setValueHex(e.hex):void 0!==e.name&&this.setValueName(e.name))},YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DEREnumerated=function(e){KJUR.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new BigInteger(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},YAHOO.lang.extend(KJUR.asn1.DEREnumerated,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(e){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},YAHOO.lang.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(e){KJUR.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},YAHOO.lang.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(e){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},YAHOO.lang.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(e){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},YAHOO.lang.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(e){KJUR.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},YAHOO.lang.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(e){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},YAHOO.lang.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(e){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(e){KJUR.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},YAHOO.lang.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(e){KJUR.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var n=this.asn1Array[t];e.push(n.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},YAHOO.lang.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(e){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,n){this.hT=t,this.isExplicit=e,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.tag&&(this.hT=e.tag),void 0!==e.explicit&&(this.isExplicit=e.explicit),void 0!==e.obj&&(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},YAHOO.lang.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object);var __extends=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),JSEncryptRSAKey=function(e){function t(n){var r=e.call(this)||this;return n&&("string"==typeof n?r.parseKey(n):(t.hasPrivateKeyProperty(n)||t.hasPublicKeyProperty(n))&&r.parsePropertiesFrom(n)),r}return __extends(t,e),t.prototype.parseKey=function(e){try{var t=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?Hex.decode(e):Base64.unarmor(e),i=ASN1.decode(r);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){t=i.sub[1].getHexStringValue(),this.n=parseBigInt(t,16),n=i.sub[2].getHexStringValue(),this.e=parseInt(n,16);var s=i.sub[3].getHexStringValue();this.d=parseBigInt(s,16);var o=i.sub[4].getHexStringValue();this.p=parseBigInt(o,16);var a=i.sub[5].getHexStringValue();this.q=parseBigInt(a,16);var c=i.sub[6].getHexStringValue();this.dmp1=parseBigInt(c,16);var u=i.sub[7].getHexStringValue();this.dmq1=parseBigInt(u,16);var h=i.sub[8].getHexStringValue();this.coeff=parseBigInt(h,16)}else{if(2!==i.sub.length)return!1;if(i.sub[0].sub){var l=i.sub[1].sub[0];t=l.sub[0].getHexStringValue(),this.n=parseBigInt(t,16),n=l.sub[1].getHexStringValue(),this.e=parseInt(n,16)}else t=i.sub[0].getHexStringValue(),this.n=parseBigInt(t,16),n=i.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(e){return!1}},t.prototype.getPrivateBaseKey=function(){var e={array:[new KJUR.asn1.DERInteger({int:0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({int:this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]};return new KJUR.asn1.DERSequence(e).getEncodedHex()},t.prototype.getPrivateBaseKeyB64=function(){return hex2b64(this.getPrivateBaseKey())},t.prototype.getPublicBaseKey=function(){var e=new KJUR.asn1.DERSequence({array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]}),t=new KJUR.asn1.DERSequence({array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({int:this.e})]}),n=new KJUR.asn1.DERBitString({hex:"00"+t.getEncodedHex()});return new KJUR.asn1.DERSequence({array:[e,n]}).getEncodedHex()},t.prototype.getPublicBaseKeyB64=function(){return hex2b64(this.getPublicBaseKey())},t.wordwrap=function(e,t){if(!e)return e;var n="(.{1,"+(t=t||64)+"})( +|$\n?)|(.{1,"+t+"})";return e.match(RegExp(n,"g")).join("\n")},t.prototype.getPrivateKey=function(){var e="-----BEGIN RSA PRIVATE KEY-----\n";return e+=t.wordwrap(this.getPrivateBaseKeyB64())+"\n",e+="-----END RSA PRIVATE KEY-----"},t.prototype.getPublicKey=function(){var e="-----BEGIN PUBLIC KEY-----\n";return e+=t.wordwrap(this.getPublicBaseKeyB64())+"\n",e+="-----END PUBLIC KEY-----"},t.hasPublicKeyProperty=function(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")},t.hasPrivateKeyProperty=function(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t}(RSAKey),_a,version=void 0!==browser$1?null===(_a=browser$1.env)||void 0===_a?void 0:_a.npm_package_version:void 0,JSEncrypt=function(){function e(e){void 0===e&&(e={}),e=e||{},this.default_key_size=e.default_key_size?parseInt(e.default_key_size,10):1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}return e.prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new JSEncryptRSAKey(e)},e.prototype.setPrivateKey=function(e){this.setKey(e)},e.prototype.setPublicKey=function(e){this.setKey(e)},e.prototype.decrypt=function(e){try{return this.getKey().decrypt(b64tohex(e))}catch(e){return!1}},e.prototype.encrypt=function(e){try{return hex2b64(this.getKey().encrypt(e))}catch(e){return!1}},e.prototype.sign=function(e,t,n){try{return hex2b64(this.getKey().sign(e,t,n))}catch(e){return!1}},e.prototype.verify=function(e,t,n){try{return this.getKey().verify(e,b64tohex(t),n)}catch(e){return!1}},e.prototype.getKey=function(e){if(!this.key){if(this.key=new JSEncryptRSAKey,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},e.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},e.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},e.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},e.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},e.version=version,e}(),networkMonitoringConfig={requestState:!1,delay:0},ueSoftphone=function(){function e(e){void 0===e&&(e={});var n=this;this.getWebrtcInfo=function(e,n){t.request(e+"/call/api/sip/webrtc/config/query",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(e){e.success&&e.data?(t.agentextras=e.data,t.initWebrtcEvent(e.data)):n.error(__assign$1({},e))},error:function(e){n.error({error:e})}})},this.initAttachEvent=function(e,r,i,s,o){n.attachEventCallbacks&&t.request(e+"/platform/action/refreshWsToken",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(e){if(e&&e.data){var a="";i.forEach((function(e){"KF"===e.id&&(a=e.url)})),n.attachEventCallbacks.serve=a,n.attachEventCallbacks.SocketOptions={query:{accountId:s.accountId,agentNumber:s.agentNumber,agentId:s._id,token:e.data.wsToken,wsExtra:JSON.stringify({loginType:r,channelType:"SDK",ability:["call"]}),timestamp:e.data.timestamp,clientType:1,pushHangupStatistics:t.initOptions.pushHangupStatistics||!1,pushCallinRingStatistics:t.initOptions.pushCallinRingStatistics||!1},reconnectionDelay:3e3,"force new connection":!0,transports:["websocket"],timeout:5e3},n.attachEventCallbacks.suc=o,t.createEventHandle(n.attachEventCallbacks)}},error:function(e){i.error({error:e})}})},this.attachNetworkCallbacks={message:t.noop,error:t.noop,success:t.noop},this.initnNetworkMonitoring=function(e,r){var i="";e.forEach((function(e){if("MONITOR"===e.id){var t=document.location.protocol;"file:"===t&&(t="https:"),i=t+"//"+e.url}})),n.attachNetworkCallbacks.success(),n.attachNetworkCallbacks.message({delay:100}),setInterval((function(){var e=(new Date).getTime();networkMonitoringConfig.requestState=!0,t.request(i+"/ready",{method:"GET",success:function(t){if(t.success){var r=(new Date).getTime();networkMonitoringConfig.delay=(r-e)/2,n.attachNetworkCallbacks.message({delay:networkMonitoringConfig.delay})}else n.attachNetworkCallbacks.error(),networkMonitoringConfig.delay=500,networkMonitoringConfig.requestState=!1},error:function(e){n.attachNetworkCallbacks.error(),networkMonitoringConfig.delay=500,networkMonitoringConfig.requestState=!1}})}),1e4)},this.listenCallNetork=function(e){e&&(n.attachNetworkCallbacks.message=e.message&&"function"==typeof e.message?e.message:t.noop,n.attachNetworkCallbacks.success=e.success&&"function"==typeof e.success?e.success:t.noop,n.attachNetworkCallbacks.error=e.error&&"function"==typeof e.error?e.error:t.noop)},this.initAgentQueue=function(e,r,i,s,o){(n.attachMonitorEventCallbacks||n.attachNlsTranslationEventCallbacks)&&t.request(e+"/platform/action/refreshWsToken",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(e){if(e&&e.data){var a="";i.forEach((function(e){"MONITOR"===e.id&&(a=e.url)})),n.attachMonitorEventCallbacks&&t.UserConfig.isOpenCallQueue&&(n.attachMonitorEventCallbacks.serve=a,n.attachMonitorEventCallbacks.SocketOptions={query:{accountId:s.accountId,agentNumber:s.agentNumber,agentId:s._id,token:e.data.wsToken,wsExtra:JSON.stringify({loginType:r,channelType:"SDK",ability:["call"]}),timestamp:e.data.timestamp,clientType:3},reconnectionDelay:3e3,"force new connection":!0,transports:["websocket"],timeout:5e3},n.attachMonitorEventCallbacks.suc=o,t.createQueueMonitorEventHandle(n.attachMonitorEventCallbacks)),n.attachNlsTranslationEventCallbacks&&t.UserConfig.openNlsTranslation&&(n.attachNlsTranslationEventCallbacks.serve=a,n.attachNlsTranslationEventCallbacks.SocketOptions={query:{accountId:s.accountId,agentNumber:s.agentNumber,agentId:s._id,token:e.data.wsToken,wsExtra:JSON.stringify({loginType:r,channelType:"SDK",ability:["call"]}),timestamp:e.data.timestamp,clientType:3},reconnectionDelay:3e3,"force new connection":!0,transports:["websocket"],timeout:5e3},n.attachNlsTranslationEventCallbacks.suc=o,t.createQueueMonitorEventHandle(n.attachNlsTranslationEventCallbacks))}},error:function(e){console.log("失败",e),i.error({error:e})}})},this.initQueue=function(e){t.request(e+"/call/monitor/agent/queue/query",{verb:"POST",body:{accountId:t.agentInfo.accountId,agentId:t.agentInfo._id},success:function(e){e&&e.data?n.attachMonitorEventCallbacks.message(e):n.attachMonitorEventCallbacks.error(e)},error:function(e){n.attachMonitorEventCallbacks.error(e)}})},this.listenCallQueueEvent=function(e){n.attachMonitorEventCallbacks=e},this.listenTranslationEvent=function(e){n.attachNlsTranslationEventCallbacks=e},this.openMediaAudio=function(e,t){var n=navigator,r=n.mediaDevices,i=n.getUserMedia,s=n.webkitGetUserMedia,o=n.mozGetUserMedia,a=n.msGetUserMedia,c=(i||s||o||a).bind(navigator);return r?navigator.mediaDevices.getUserMedia({audio:!0}).catch((function(n){var r=n.message.includes(DENIED);return t?(r&&alert(AUDIO_FORBIDDEN.forbiddenAudioMsg),e&&!r&&alert(e),r?AUDIO_FORBIDDEN:NOT_OPEN_AUDIO):r?AUDIO_FORBIDDEN:NOT_OPEN_AUDIO})):new Promise((function(n,r){c?c({audio:!0},(function(e){n(!0)}),(function(n){t&&e&&alert(e),r(NOT_OPEN_AUDIO)})):r(NOT_OPEN_AUDIO)}))},this.listenCallEvent=function(e){n.attachEventCallbacks=e},this._callApi=function(){var e,r,i=n;return{callout:function(n){return __awaiter$1(this,void 0,void 0,(function(){var s,o,a,c,u,h;return __generator$1(this,(function(l){switch(l.label){case 0:if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null===t.loginToken||void 0===t.loginToken)return n.fail({success:!1,message:"initialization not complete!"}),[2];if(null===t.agentInfo||void 0===t.agentInfo)return n.fail({success:!1,message:"initialization not complete!"}),[2];if(null===n.customerNumber||void 0===n.customerNumber)return n.fail({success:!1,message:"Parameter customerNumber is required!"}),[2];if("WEBRTC"!==t.initOptions.loginType)return[3,4];l.label=1;case 1:return l.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:!0})];case 2:return l.sent(),[3,4];case 3:return l.sent(),n.fail({success:!1,message:"无麦克风权限!"}),[2];case 4:if(s=t.initOptions.server||t.callApiUrl,o={customerNumber:n.customerNumber,agentNumber:t.agentInfo.agentNumber,accountId:t.agentInfo.accountId,agentId:t.agentInfo._id,loginType:n.loginType||t.agentInfo.loginType||t.initOptions.loginType},n.agentTimeout&&(o.agentTimeout=n.agentTimeout),n.customerTimeout&&(o.customerTimeout=n.customerTimeout),n.agentDisNumber&&(o.agentDisNumber=n.agentDisNumber),n.customerDisNumber&&(o.customerDisNumber=n.customerDisNumber),n.extras&&(o.extras=n.extras),n.numberGroupId&&(o.numberGroupId=n.numberGroupId),n.numberGroupName&&(o.numberGroupName=n.numberGroupName),a=t.initOptions,c=!0,"WEBRTC"!==a.loginType)return[3,8];l.label=5;case 5:return l.trys.push([5,7,,8]),[4,i.openMediaAudio("请打开麦克风权限!",c)];case 6:return u=l.sent()||{},[3,8];case 7:return h=l.sent(),console.log(h),[3,8];case 8:return t.request(s+"/call/api/call/call/out",{verb:"POST",body:o,loginToken:t.loginToken,sessionId:t.agentInfo._id,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success(__assign$1(__assign$1({success:!0,message:"callout success"},u),e.data)):n.fail(__assign$1({success:!1,message:e.message,code:e.code},u))}}),[2]}}))}))},hangup:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/hangup",{verb:"POST",body:{},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"hangup success",data:e}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},holdOrUnHold:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type){var i=t.initOptions.server||t.callApiUrl,s={type:n.type};t.request(i+"/call/api/call/hold",{verb:"POST",body:s,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"holdOrUnHold success"}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},muteOrUnMute:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type){var i=t.initOptions.server||t.callApiUrl,s={type:n.type,direction:n.direction||"all"};t.request(i+"/call/api/call/mute",{verb:"POST",body:s,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"muteOrUnMute success"}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},transfer:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type)if(null!==n.number&&void 0!==n.number){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/transfer",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"transfer success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter number is required!"});else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},consult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.mode&&void 0!==n.mode)if(null!==n.number&&void 0!==n.number){n.agentNumber=t.agentInfo.agentNumber;var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"consult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter number is required!"});else n.fail({success:!1,message:"Parameter mode is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},cancelconsult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/cancel",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"cancelconsult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},endConsult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/stop",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"endConsult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},callbackConsult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/resume",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"resumeConsult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},consultTransfer:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/transfer",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"consultTransfer success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},threeWayCall:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/threeway",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"threeWayCall success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},evaluate:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/evaluate",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"evaluate success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},meeting:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.number&&void 0!==n.number){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/meeting",{verb:"POST",body:{meetingType:"phone",number:n.number},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"meeting success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter number is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})}}},this._agentApi=function(){var e=n;return{switchLoginType:function(n){return __awaiter$1(this,void 0,void 0,(function(){var r,i,s,o,a,c,u=this;return __generator$1(this,(function(h){switch(h.label){case 0:if(r=null,n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null===n.loginType||void 0===n.loginType)return n.fail({success:!1,message:"Parameter loginType is required!"}),[2];if(null===t.agentInfo||void 0===t.agentInfo)return n.fail({success:!1,message:"initialization not complete!"}),[2];if(null!==n.loginNumber&&void 0!==n.loginNumber&&(r=n.loginNumber),"PSTN"===n.loginType&&!(r=r||t.agentInfo.mobile))return alert("请给座席绑定手机号,或者传入号码参数!"),n.fail({success:!1,message:"Please bind your mobile number"}),[2];if("SIP"===n.loginType&&(r=r||t.agentInfo.sipNumber),"WEBRTC"===n.loginType&&(r=t.agentInfo.webrtcSipNumber),i=t.initOptions.server||t.callApiUrl,s={loginType:n.loginType,loginNumber:r},t.initOptions,a=!0,"WEBRTC"!==n.loginType)return[3,4];h.label=1;case 1:return h.trys.push([1,3,,4]),[4,e.openMediaAudio("请打开麦克风权限!",a)];case 2:return o=h.sent()||{},[3,4];case 3:return c=h.sent(),console.log(c),[3,4];case 4:return t.request(i+"/call/api/agent/v1/login-type/change",{verb:"POST",body:s,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(r){return __awaiter$1(u,void 0,void 0,(function(){return __generator$1(this,(function(s){switch(s.label){case 0:return r.success?(n.success(__assign$1({success:!0,message:"updateLoginType success"},o)),t.agentInfo.loginType=n.loginType,t.initOptions.loginType=n.loginType,"WEBRTC"!==n.loginType?[3,1]:(e._webPhoneApi().connect(),[3,4])):[3,5];case 1:return"PSTN"!==n.loginType?[3,3]:[4,t.request(i+"/platform/action/updateCallConfig",{verb:"POST",body:{agentCallConfig:{},mobile:n.loginNumber},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId})];case 2:return s.sent(),e._webPhoneApi().disconnect(),[3,4];case 3:e._webPhoneApi().disconnect(),s.label=4;case 4:return[3,6];case 5:n.fail(__assign$1({success:!1,message:r.message,code:r.code},o)),s.label=6;case 6:return[2]}}))}))}}),[2]}}))}))},findPhoneBarList:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl;t.request(n+"/call/api/phone/bar/all",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(t){if(t.success){var n=[];t.data.forEach((function(e){var t={name:e.name,number:e.number};n.push(t)})),e.success({success:!0,data:n})}else e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"})},switchPhoneBar:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==e.stateNumber&&void 0!==e.stateNumber)if(null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl,r={stateNumber:e.stateNumber,accountId:t.agentInfo.accountId,agentNumber:t.agentInfo.agentNumber};t.request(n+"/call/api/agent/status/switch",{verb:"POST",body:r,loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(t){t.success?e.success({success:!0}):e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"});else e.fail({success:!1,message:"Parameter stateNumber is required!"})},logout:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){null!==e.toAnswerOffline&&void 0!==e.toAnswerOffline||(e.toAnswerOffline="1");var n=t.initOptions.server||t.callApiUrl,r={toAnswerOffline:e.toAnswerOffline};t.request(n+"/call/api/sdk/agent/logout",{verb:"POST",body:r,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(n){n.success?e&&(t.Socketinstance.disconnect(),"WEBRTC"===t.agentInfo.loginType&&t.webPhone.disconnect(),e.success({success:!0})):e&&e.fail({success:!1,message:n.message,code:n.code})}})}else e.fail({success:!1,message:"initialization not complete!"})},findIdleAgentsForQueue:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl;t.request(n+"/call/api/queue/acountFreeAgent/find",{verb:"POST",body:{},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(t){t.success?e&&e.success({success:!0,dataList:t.data||[]}):e&&e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"})},getAvailableSipNumberList:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl;t.request(n+"/call/api/sip/avaliable/query",{verb:"POST",body:{},loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(t){if(t.success&&t.data){var n=[];t.data.forEach((function(e){var t={number:e.id,numberName:e.number};n.push(t)})),e.success({success:!0,data:n})}else e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"})}}},this._webPhoneApi=function(){return{accept:function(){t.webPhone.accept()},connect:function(){t.webPhone&&this.isConnected()||t.initWebrtcEvent(t.agentextras)},disconnect:function(){t.webPhone&&this.isConnected()&&t.webPhone.disconnect()},isConnected:function(){return t.webPhone.isConnected()},sendDTMF:function(e){t.webPhone.sendDTMF(e)}}},e.error="function"==typeof e.error?e.error:t.noop,e.success="function"==typeof e.success?e.success:t.noop,null!==e.agentNumber&&void 0!==e.agentNumber?(null!==e.loginType&&void 0!==e.loginType||(e.loginType="PSTN"),null!==e.pushHangupStatistics&&void 0!==e.pushHangupStatistics||(e.pushHangupStatistics=!1),null!==e.pushCallinRingStatistics&&void 0!==e.pushCallinRingStatistics||(e.pushCallinRingStatistics=!1),this.init(e)):e.error({message:"Invalid agentNumber"})}var t;return e.noop=function(){},e.prototype.init=function(e){if(void 0===e&&(e={}),t.trace=t.noop,t.debug=t.noop,t.log=t.noop,t.warn=t.noop,t.error=t.noop,!0===e.debug||"all"===e.debug)t.trace=console.trace.bind(console),t.debug=console.debug.bind(console),t.log=console.log.bind(console),t.warn=console.warn.bind(console),t.error=console.error.bind(console);else if(Array.isArray(e.debug))for(var n in e.debug){var r=e.debug[n];switch(r){case"trace":t.trace=console.trace.bind(console);break;case"debug":t.debug=console.debug.bind(console);break;case"log":t.log=console.log.bind(console);break;case"warn":t.warn=console.warn.bind(console);break;case"error":t.error=console.error.bind(console);break;default:console.error("Unknown debugging option '"+r+"' (supported: 'trace', 'debug', 'log', warn', 'error')")}}t.log("Initializing library");var i=t.useDefaultDependencies({WebSocket:ueWebsocket});t.newWebSocket=i.newWebSocket,t.request=i.request,this.login(e)},e.prototype.login=function(e){return __awaiter$1(this,void 0,void 0,(function(){var n,r,i,s,o,a,c,u,h,l,d=this;return __generator$1(this,(function(p){switch(p.label){case 0:if(console.log(e,"options"),t.UserConfig=e,n=e.server||t.callApiUrl,r=e.agentNumber+"@"+e.accountId,i=e.loginType,s=e.isOpenNetwork||!1,o=e.isOpenCallQueue||!1,a=e.openNlsTranslation||!1,c={loginName:r,loginType:i,loginChannel:"SDK",password:""},u=!0,"WEBRTC"!==i)return[3,4];p.label=1;case 1:return p.trys.push([1,3,,4]),[4,this.openMediaAudio("请打开麦克风权限!",u)];case 2:return h=p.sent()||{},[3,4];case 3:return l=p.sent(),console.log(l),console.log("授权失败================================"),[3,4];case 4:return e.password&&(c.password=e.password),t.request(n+"/platform/public/loginPre",{verb:"GET",success:function(r){if(r&&r.success&&r.data){var u=decodeURIComponent(gBase64.decode(r.data.pk)),l=new JSEncrypt;l.setPublicKey(u);var p=md5(c.password),g=l.encrypt(p);c.password=g,t.request(n+"/platform/public/login",{verb:"POST",body:c,success:function(r){r.success?t.request(n+"/platform/action/loginInfo",{verb:"GET",loginToken:r.data.loginToken,sessionId:r.data.sessionId,success:function(r){r.success?(r.data.agent&&(t.agentInfo=r.data.agent,t.loginToken=r.data.loginToken,t.initOptions=__assign$1(__assign$1({},e),{audioInfo:h})),d.initAttachEvent(n,i,r.data.pushServer,r.data.agent,e.success),s&&d.initnNetworkMonitoring(r.data.pushServer,""),(o||a)&&d.initAgentQueue(n,i,r.data.pushServer,r.data.agent,e.success),o&&d.initQueue(n),"WEBRTC"===i&&d.getWebrtcInfo(n,e)):e.error(__assign$1(__assign$1({},r),h))},error:function(t){e.error(__assign$1({error:t},h))}}):e.error(__assign$1(__assign$1({},r),h))},error:function(t){e.error(__assign$1({error:t},h))}})}else e.error(__assign$1(__assign$1({},r),h))},error:function(t){e.error(__assign$1({error:t},h))}}),[2]}}))}))},e.exitLogOut=function(){var e=t.UserConfig.server||t.callApiUrl;t.request(e+"/platform/action/webLogout",{verb:"POST",success:function(e){console.log(e,"互踢后退出登录成功")},error:function(e){console.log(e,"互踢后退出登录失败")}})},e.createEventHandle=function(e){var n=this;void 0===e&&(e={}),e.success="function"==typeof e.success?e.success:t.noop,e.error="function"==typeof e.error?e.error:t.noop,e.message="function"==typeof e.message?e.message:t.noop,e.event="function"==typeof e.event?e.event:t.noop,e.server=null===e.serve||void 0===e.serve?"ws://152.136.72.209:3201/phoneBarGateway":e.serve,null!==e.SocketOptions&&void 0!==e.SocketOptions||(e.SocketOptions={},t.error({message:"login response error!"})),this.Socketinstance=t.newWebSocket(e.server,e.SocketOptions),this.Socketinstance.on("connect",(function(){e.success("connect event serve success!"),e.suc()})),this.Socketinstance.on("error",(function(t,n){e.error({type:"socketError",error:t}),n&&"function"==typeof n&&n("error")})),this.Socketinstance.on("message",(function(n,r){e.message({subtype:n.subType,data:n.data}),"WEBRTC"===t.initOptions.loginType&&(n.data&&n.data.callType&&"callin"===n.data.callType&&n.data.eventType&&"ring"===n.data.eventType?(t.AudioTask||(t.AudioTask=new AudioTask("https://softphone.useasy.cn/ring.wav")),t.AudioTask.ringAudioPlay()):t.AudioTask&&t.AudioTask.ringAudioPause()),r&&"function"==typeof r&&r("success")})),this.Socketinstance.on("event",(function(r){if("KICK_OFF"===r.subType&&!0===r.data.kickoff){n.Socketinstance.disconnect(),t.loginToken=null;try{t.webPhone.disconnect(),console.log(r,"互踢")}catch(e){}e.event({message:"坐席账户在其他地方登录",data:r})}}))},e.createQueueMonitorEventHandle=function(e){var n=this;void 0===e&&(e={}),e.success="function"==typeof e.success?e.success:t.noop,e.error="function"==typeof e.error?e.error:t.noop,e.message="function"==typeof e.message?e.message:t.noop,e.server=null===e.serve||void 0===e.serve?"ue-dev1.useasy.cn":e.serve,null!==e.SocketOptions&&void 0!==e.SocketOptions||(e.SocketOptions={},t.error({message:"login response error!"})),this.MonitorSocketinstance=t.newWebSocket(e.server,e.SocketOptions),this.MonitorSocketinstance.on("connect",(function(){e.success("connect event serve success!"),e.suc(),t.log("监控connect========")})),this.MonitorSocketinstance.on("error",(function(t,n){e.error({type:"socketError",error:t}),n&&"function"==typeof n&&n("error")})),this.MonitorSocketinstance.on("message",(function(t,n){e.message({subtype:t.subType,data:t.data})})),this.MonitorSocketinstance.on("event",(function(r,i){if("KICK_OFF"===r.subType&&!0===r.data.kickoff){n.MonitorSocketinstance.disconnect();try{t.webPhone.disconnect(),console.log(r,"呼叫队列互踢")}catch(e){}e.message({message:"坐席账户在其他地方登录",data:r})}e.message(r)})),this.MonitorSocketinstance.on("translation",(function(t,n){console.log("呼叫队列消息更新???translation",t),e.message(t)}))},e.useDefaultDependencies=function(e){var n=e&&e.fetch||fetch,r=e&&e.Promise||Promise,i=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,t){return new i(e,t)},request:function(e,i){var s={method:i.verb,cache:"no-cache",headers:{"Content-Type":"application/json",loginToken:i.loginToken||"",sessionId:i.sessionId||"",clienttype:0}};i.encryptionFields&&(s.headers["ue-encryption-algorithm"]=i.encryptionAlgorithm||"aes",s.headers["ue-encryption-fields"]=i.encryptionFields),void 0!==i.withCredentials&&(s.credentials=!0===i.withCredentials?"include":i.withCredentials?i.withCredentials:"omit"),void 0!==i.body&&(s.body=JSON.stringify(i.body));var o=n(e,s).catch((function(e){return r.reject({message:"Probably a network error, is the gateway down?",error:e})}));if(void 0!==i.timeout){var a=new r((function(e,t){var n=window.setTimeout((function(){return clearTimeout(n),i.error({message:"Request timed out",timeout:i.timeout}),t({message:"Request timed out",timeout:i.timeout})}),i.timeout)}));o=r.race([o,a])}return o.then((function(e){return e.ok?typeof i.success==typeof t.noop?e.json().then((function(e){i.success(e)})).catch((function(t){return i.error({message:"Failed to parse response body",error:t,response:e}),r.reject({message:"Failed to parse response body",error:t,response:e})})):void 0:(i.error({message:"API call failed",response:e}),r.reject({message:"API call failed",response:e}))})).catch((function(e){typeof i.error==typeof t.noop&&i.error(e.message||"<< internal error >>",e)})),o}}},Object.defineProperty(e.prototype,"agent",{get:function(){return this._agentApi()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"webrtc",{get:function(){return this._webPhoneApi()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"call",{get:function(){return this._callApi()},enumerable:!1,configurable:!0}),t=e,e.callApiUrl="https://app.useasy.cn/api",e.Socketinstance=null,e.AudioTask=null,e.MonitorSocketinstance=null,e.UserConfig=null,e.initWebrtcEvent=function(e){return __awaiter$1(void 0,void 0,void 0,(function(){return __generator$1(t,(function(n){switch(n.label){case 0:return t.webPhone=new UeWebrtc({server:e.wssUrl,sip:e.sip,secret:e.password}),[4,this.webPhone.connect()];case 1:return n.sent(),this.webPhone.register(),[2]}}))}))},e}(),ueWebsocket=function(){function e(e,t){delete t.path,delete t.hostname,delete t.port,this.ws=_t.connect("wss://".concat(e),t)}return e.prototype.on=function(e,t){console.log(e,"type---\x3ecallback",t),"connect"===e&&this.ws.on(e,t),"error"===e&&(this.ws.on("connect_error",t),this.ws.on("error",t),this.ws.on("disconnect",t),this.ws.on("reconnect_failed",t)),"message"===e&&this.ws.on("call",t),"event"===e&&this.ws.on("event",t),"monitor"===e&&this.ws.on("monitor",t),"translation"===e&&this.ws.on("translation",t)},e.prototype.emit=function(e,t,n){this.ws.emit(e,t,n)},e.prototype.disconnect=function(){this.ws.disconnect()},e}(),AudioTask=function(){function e(e){this.ringAudio=new Audio(e),this.ringAudio.loop=!0,this.ringAudioRunning=!1}return e.prototype.ringAudioPlay=function(){return __awaiter$1(this,void 0,void 0,(function(){return __generator$1(this,(function(e){switch(e.label){case 0:return this.ringAudioRunning?[2]:[3,1];case 1:return[4,this.ringAudio.play()];case 2:e.sent(),this.ringAudioRunning=!0,e.label=3;case 3:return[2]}}))}))},e.prototype.ringAudioPause=function(){return __awaiter$1(this,void 0,void 0,(function(){return __generator$1(this,(function(e){switch(e.label){case 0:return this.ringAudio.paused?[3,2]:[4,this.ringAudio.pause()];case 1:e.sent(),this.ringAudioRunning=!1,e.label=2;case 2:return[2]}}))}))},e}();return ueSoftphone}();
|
|
22
|
+
var KJUR={};void 0!==KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var n=t.substr(1).length;n%2==1?n+=1:t.match(/^[0-7]/)||(n+=2);for(var r="",i=0;i<n;i++)r+="f";t=new BigInteger(r,16).xor(e).add(BigInteger.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return hextopem(e,t)},this.newObject=function(e){var t=KJUR.asn1,n=t.DERBoolean,r=t.DERInteger,i=t.DERBitString,s=t.DEROctetString,o=t.DERNull,a=t.DERObjectIdentifier,c=t.DEREnumerated,u=t.DERUTF8String,h=t.DERNumericString,l=t.DERPrintableString,d=t.DERTeletexString,p=t.DERIA5String,g=t.DERUTCTime,f=t.DERGeneralizedTime,m=t.DERSequence,v=t.DERSet,y=t.DERTaggedObject,b=t.ASN1Util.newObject,S=Object.keys(e);if(1!=S.length)throw"key of param shall be only one.";var T=S[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+T+":"))throw"undefined key: "+T;if("bool"==T)return new n(e[T]);if("int"==T)return new r(e[T]);if("bitstr"==T)return new i(e[T]);if("octstr"==T)return new s(e[T]);if("null"==T)return new o(e[T]);if("oid"==T)return new a(e[T]);if("enum"==T)return new c(e[T]);if("utf8str"==T)return new u(e[T]);if("numstr"==T)return new h(e[T]);if("prnstr"==T)return new l(e[T]);if("telstr"==T)return new d(e[T]);if("ia5str"==T)return new p(e[T]);if("utctime"==T)return new g(e[T]);if("gentime"==T)return new f(e[T]);if("seq"==T){for(var w=e[T],R=[],E=0;E<w.length;E++){var I=b(w[E]);R.push(I)}return new m({array:R})}if("set"==T){for(w=e[T],R=[],E=0;E<w.length;E++){I=b(w[E]);R.push(I)}return new v({array:R})}if("tag"==T){var _=e[T];if("[object Array]"===Object.prototype.toString.call(_)&&3==_.length){var A=b(_[2]);return new y({tag:_[0],explicit:_[1],obj:A})}var C={};if(void 0!==_.explicit&&(C.explicit=_.explicit),void 0!==_.tag&&(C.tag=_.tag),void 0===_.obj)throw"obj shall be specified for 'tag'.";return C.obj=b(_.obj),new y(C)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},KJUR.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",n=parseInt(e.substr(0,2),16),r=(t=Math.floor(n/40)+"."+n%40,""),i=2;i<e.length;i+=2){var s=("00000000"+parseInt(e.substr(i,2),16).toString(2)).slice(-8);if(r+=s.substr(1,7),"0"==s.substr(0,1))t=t+"."+new BigInteger(r,2).toString(10),r=""}return t},KJUR.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},n=function(e){var n="",r=new BigInteger(e,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";r=s+r;for(o=0;o<r.length-1;o+=7){var a=r.substr(o,7);o!=r.length-7&&(a="1"+a),n+=t(parseInt(a,2))}return n};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var r="",i=e.split("."),s=40*parseInt(i[0])+parseInt(i[1]);r+=t(s),i.splice(0,2);for(var o=0;o<i.length;o++)r+=n(i[o]);return r},KJUR.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n=0,v="+this.hV;var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var n=t.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+n).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(e){KJUR.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(this.s)},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(e){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){return utc=e.getTime()+6e4*e.getTimezoneOffset(),new Date(utc)},this.formatDate=function(e,t,n){var r=this.zeroPadding,i=this.localDateToUTC(e),s=String(i.getFullYear());"utc"==t&&(s=s.substr(2,2));var o=s+r(String(i.getMonth()+1),2)+r(String(i.getDate()),2)+r(String(i.getHours()),2)+r(String(i.getMinutes()),2)+r(String(i.getSeconds()),2);if(!0===n){var a=i.getMilliseconds();if(0!=a){var c=r(String(a),3);o=o+"."+(c=c.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=stohex(e)},this.setByDateValue=function(e,t,n,r,i,s){var o=new Date(Date.UTC(e,t-1,n,r,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(e){KJUR.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(e){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new BigInteger(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=KJUR.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var n="0"+e;this.hTLV=null,this.isModified=!0,this.hV=n+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var n=0;n<=t;n++)e+="0";var r="";for(n=0;n<e.length-1;n+=8){var i=e.substr(n,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),r+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+t+r},this.setByBooleanArray=function(e){for(var t="",n=0;n<e.length;n++)1==e[n]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},YAHOO.lang.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=KJUR.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}KJUR.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},YAHOO.lang.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},YAHOO.lang.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},n=function(e){var n="",r=new BigInteger(e,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";r=s+r;for(o=0;o<r.length-1;o+=7){var a=r.substr(o,7);o!=r.length-7&&(a="1"+a),n+=t(parseInt(a,2))}return n};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var r="",i=e.split("."),s=40*parseInt(i[0])+parseInt(i[1]);r+=t(s),i.splice(0,2);for(var o=0;o<i.length;o++)r+=n(i[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(e){var t=KJUR.asn1.x509.OID.name2oid(e);if(""===t)throw"DERObjectIdentifier oidName undefined: "+e;this.setValueOidString(t)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e):void 0!==e.oid?this.setValueOidString(e.oid):void 0!==e.hex?this.setValueHex(e.hex):void 0!==e.name&&this.setValueName(e.name))},YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DEREnumerated=function(e){KJUR.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new BigInteger(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},YAHOO.lang.extend(KJUR.asn1.DEREnumerated,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(e){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},YAHOO.lang.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(e){KJUR.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},YAHOO.lang.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(e){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},YAHOO.lang.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(e){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},YAHOO.lang.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(e){KJUR.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},YAHOO.lang.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(e){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},YAHOO.lang.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(e){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(e){KJUR.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},YAHOO.lang.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(e){KJUR.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var n=this.asn1Array[t];e.push(n.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},YAHOO.lang.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(e){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,n){this.hT=t,this.isExplicit=e,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.tag&&(this.hT=e.tag),void 0!==e.explicit&&(this.isExplicit=e.explicit),void 0!==e.obj&&(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},YAHOO.lang.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object);var __extends=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),JSEncryptRSAKey=function(e){function t(n){var r=e.call(this)||this;return n&&("string"==typeof n?r.parseKey(n):(t.hasPrivateKeyProperty(n)||t.hasPublicKeyProperty(n))&&r.parsePropertiesFrom(n)),r}return __extends(t,e),t.prototype.parseKey=function(e){try{var t=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?Hex.decode(e):Base64.unarmor(e),i=ASN1.decode(r);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){t=i.sub[1].getHexStringValue(),this.n=parseBigInt(t,16),n=i.sub[2].getHexStringValue(),this.e=parseInt(n,16);var s=i.sub[3].getHexStringValue();this.d=parseBigInt(s,16);var o=i.sub[4].getHexStringValue();this.p=parseBigInt(o,16);var a=i.sub[5].getHexStringValue();this.q=parseBigInt(a,16);var c=i.sub[6].getHexStringValue();this.dmp1=parseBigInt(c,16);var u=i.sub[7].getHexStringValue();this.dmq1=parseBigInt(u,16);var h=i.sub[8].getHexStringValue();this.coeff=parseBigInt(h,16)}else{if(2!==i.sub.length)return!1;if(i.sub[0].sub){var l=i.sub[1].sub[0];t=l.sub[0].getHexStringValue(),this.n=parseBigInt(t,16),n=l.sub[1].getHexStringValue(),this.e=parseInt(n,16)}else t=i.sub[0].getHexStringValue(),this.n=parseBigInt(t,16),n=i.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(e){return!1}},t.prototype.getPrivateBaseKey=function(){var e={array:[new KJUR.asn1.DERInteger({int:0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({int:this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]};return new KJUR.asn1.DERSequence(e).getEncodedHex()},t.prototype.getPrivateBaseKeyB64=function(){return hex2b64(this.getPrivateBaseKey())},t.prototype.getPublicBaseKey=function(){var e=new KJUR.asn1.DERSequence({array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]}),t=new KJUR.asn1.DERSequence({array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({int:this.e})]}),n=new KJUR.asn1.DERBitString({hex:"00"+t.getEncodedHex()});return new KJUR.asn1.DERSequence({array:[e,n]}).getEncodedHex()},t.prototype.getPublicBaseKeyB64=function(){return hex2b64(this.getPublicBaseKey())},t.wordwrap=function(e,t){if(!e)return e;var n="(.{1,"+(t=t||64)+"})( +|$\n?)|(.{1,"+t+"})";return e.match(RegExp(n,"g")).join("\n")},t.prototype.getPrivateKey=function(){var e="-----BEGIN RSA PRIVATE KEY-----\n";return e+=t.wordwrap(this.getPrivateBaseKeyB64())+"\n",e+="-----END RSA PRIVATE KEY-----"},t.prototype.getPublicKey=function(){var e="-----BEGIN PUBLIC KEY-----\n";return e+=t.wordwrap(this.getPublicBaseKeyB64())+"\n",e+="-----END PUBLIC KEY-----"},t.hasPublicKeyProperty=function(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")},t.hasPrivateKeyProperty=function(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t}(RSAKey),_a,version=void 0!==browser$1?null===(_a=browser$1.env)||void 0===_a?void 0:_a.npm_package_version:void 0,JSEncrypt=function(){function e(e){void 0===e&&(e={}),e=e||{},this.default_key_size=e.default_key_size?parseInt(e.default_key_size,10):1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}return e.prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new JSEncryptRSAKey(e)},e.prototype.setPrivateKey=function(e){this.setKey(e)},e.prototype.setPublicKey=function(e){this.setKey(e)},e.prototype.decrypt=function(e){try{return this.getKey().decrypt(b64tohex(e))}catch(e){return!1}},e.prototype.encrypt=function(e){try{return hex2b64(this.getKey().encrypt(e))}catch(e){return!1}},e.prototype.sign=function(e,t,n){try{return hex2b64(this.getKey().sign(e,t,n))}catch(e){return!1}},e.prototype.verify=function(e,t,n){try{return this.getKey().verify(e,b64tohex(t),n)}catch(e){return!1}},e.prototype.getKey=function(e){if(!this.key){if(this.key=new JSEncryptRSAKey,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},e.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},e.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},e.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},e.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},e.version=version,e}(),networkMonitoringConfig={requestState:!1,delay:0},ueSoftphone=function(){function e(e){void 0===e&&(e={});var n=this;this.getWebrtcInfo=function(e,n){t.request(e+"/call/api/sip/webrtc/config/query",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(e){e.success&&e.data?(t.agentextras=e.data,t.initWebrtcEvent(e.data)):n.error(__assign$1({},e))},error:function(e){n.error({error:e})}})},this.initAttachEvent=function(e,r,i,s,o){n.attachEventCallbacks&&t.request(e+"/platform/action/refreshWsToken",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(e){if(e&&e.data){var a="";i.forEach((function(e){"KF"===e.id&&(a=e.url)})),n.attachEventCallbacks.serve=a,n.attachEventCallbacks.SocketOptions={query:{accountId:s.accountId,agentNumber:s.agentNumber,agentId:s._id,token:e.data.wsToken,wsExtra:JSON.stringify({loginType:r,channelType:"SDK",ability:["call"]}),timestamp:e.data.timestamp,clientType:1,pushHangupStatistics:t.initOptions.pushHangupStatistics||!1,pushCallinRingStatistics:t.initOptions.pushCallinRingStatistics||!1},reconnectionDelay:3e3,"force new connection":!0,transports:["websocket"],timeout:5e3},n.attachEventCallbacks.suc=o,t.createEventHandle(n.attachEventCallbacks)}},error:function(e){i.error({error:e})}})},this.attachNetworkCallbacks={message:t.noop,error:t.noop,success:t.noop},this.initnNetworkMonitoring=function(e,r){var i="";e.forEach((function(e){if("MONITOR"===e.id){var t=document.location.protocol;"file:"===t&&(t="https:"),i=t+"//"+e.url}})),n.attachNetworkCallbacks.success(),n.attachNetworkCallbacks.message({delay:100}),setInterval((function(){var e=(new Date).getTime();networkMonitoringConfig.requestState=!0,t.request(i+"/ready",{method:"GET",success:function(t){if(t.success){var r=(new Date).getTime();networkMonitoringConfig.delay=(r-e)/2,n.attachNetworkCallbacks.message({delay:networkMonitoringConfig.delay})}else n.attachNetworkCallbacks.error(),networkMonitoringConfig.delay=500,networkMonitoringConfig.requestState=!1},error:function(e){n.attachNetworkCallbacks.error(),networkMonitoringConfig.delay=500,networkMonitoringConfig.requestState=!1}})}),1e4)},this.listenCallNetork=function(e){e&&(n.attachNetworkCallbacks.message=e.message&&"function"==typeof e.message?e.message:t.noop,n.attachNetworkCallbacks.success=e.success&&"function"==typeof e.success?e.success:t.noop,n.attachNetworkCallbacks.error=e.error&&"function"==typeof e.error?e.error:t.noop)},this.initAgentQueue=function(e,r,i,s,o){(n.attachMonitorEventCallbacks||n.attachNlsTranslationEventCallbacks)&&t.request(e+"/platform/action/refreshWsToken",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(e){if(e&&e.data){var a="";i.forEach((function(e){"MONITOR"===e.id&&(a=e.url)})),n.attachMonitorEventCallbacks&&t.UserConfig.isOpenCallQueue&&(n.attachMonitorEventCallbacks.serve=a,n.attachMonitorEventCallbacks.SocketOptions={query:{accountId:s.accountId,agentNumber:s.agentNumber,agentId:s._id,token:e.data.wsToken,wsExtra:JSON.stringify({loginType:r,channelType:"SDK",ability:["call"]}),timestamp:e.data.timestamp,clientType:3},reconnectionDelay:3e3,"force new connection":!0,transports:["websocket"],timeout:5e3},n.attachMonitorEventCallbacks.suc=o,t.createQueueMonitorEventHandle(n.attachMonitorEventCallbacks)),n.attachNlsTranslationEventCallbacks&&t.UserConfig.openNlsTranslation&&(n.attachNlsTranslationEventCallbacks.serve=a,n.attachNlsTranslationEventCallbacks.SocketOptions={query:{accountId:s.accountId,agentNumber:s.agentNumber,agentId:s._id,token:e.data.wsToken,wsExtra:JSON.stringify({loginType:r,channelType:"SDK",ability:["call"]}),timestamp:e.data.timestamp,clientType:3},reconnectionDelay:3e3,"force new connection":!0,transports:["websocket"],timeout:5e3},n.attachNlsTranslationEventCallbacks.suc=o,t.createopenNlsTransEventHandle(n.attachNlsTranslationEventCallbacks))}},error:function(e){console.log("失败",e),i.error({error:e})}})},this.initQueue=function(e){t.request(e+"/call/monitor/agent/queue/query",{verb:"POST",body:{accountId:t.agentInfo.accountId,agentId:t.agentInfo._id},success:function(e){e&&e.data?n.attachMonitorEventCallbacks.message(e):n.attachMonitorEventCallbacks.error(e)},error:function(e){n.attachMonitorEventCallbacks.error(e)}})},this.listenCallQueueEvent=function(e){n.attachMonitorEventCallbacks=e},this.listenTranslationEvent=function(e){n.attachNlsTranslationEventCallbacks=e},this.openMediaAudio=function(e,t){var n=navigator,r=n.mediaDevices,i=n.getUserMedia,s=n.webkitGetUserMedia,o=n.mozGetUserMedia,a=n.msGetUserMedia,c=(i||s||o||a).bind(navigator);return r?navigator.mediaDevices.getUserMedia({audio:!0}).catch((function(n){var r=n.message.includes(DENIED);return t?(r&&alert(AUDIO_FORBIDDEN.forbiddenAudioMsg),e&&!r&&alert(e),r?AUDIO_FORBIDDEN:NOT_OPEN_AUDIO):r?AUDIO_FORBIDDEN:NOT_OPEN_AUDIO})):new Promise((function(n,r){c?c({audio:!0},(function(e){n(!0)}),(function(n){t&&e&&alert(e),r(NOT_OPEN_AUDIO)})):r(NOT_OPEN_AUDIO)}))},this.listenCallEvent=function(e){n.attachEventCallbacks=e},this._callApi=function(){var e,r,i=n;return{callout:function(n){return __awaiter$1(this,void 0,void 0,(function(){var s,o,a,c,u,h;return __generator$1(this,(function(l){switch(l.label){case 0:if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null===t.loginToken||void 0===t.loginToken)return n.fail({success:!1,message:"initialization not complete!"}),[2];if("KICK_OFF"===t.loginToken)return n.fail({success:!1,message:"您的座席账号正在别处登录,当前页面电话条已退出。"}),[2];if(null===t.agentInfo||void 0===t.agentInfo)return n.fail({success:!1,message:"initialization not complete!"}),[2];if(null===n.customerNumber||void 0===n.customerNumber)return n.fail({success:!1,message:"Parameter customerNumber is required!"}),[2];if("WEBRTC"!==t.initOptions.loginType)return[3,4];l.label=1;case 1:return l.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:!0})];case 2:return l.sent(),[3,4];case 3:return l.sent(),n.fail({success:!1,message:"无麦克风权限!"}),[2];case 4:if(s=t.initOptions.server||t.callApiUrl,o={customerNumber:n.customerNumber,agentNumber:t.agentInfo.agentNumber,accountId:t.agentInfo.accountId,agentId:t.agentInfo._id,loginType:n.loginType||t.agentInfo.loginType||t.initOptions.loginType},n.agentTimeout&&(o.agentTimeout=n.agentTimeout),n.customerTimeout&&(o.customerTimeout=n.customerTimeout),n.agentDisNumber&&(o.agentDisNumber=n.agentDisNumber),n.customerDisNumber&&(o.customerDisNumber=n.customerDisNumber),n.extras&&(o.extras=n.extras),n.numberGroupId&&(o.numberGroupId=n.numberGroupId),n.numberGroupName&&(o.numberGroupName=n.numberGroupName),a=t.initOptions,c=!0,"WEBRTC"!==a.loginType)return[3,8];l.label=5;case 5:return l.trys.push([5,7,,8]),[4,i.openMediaAudio("请打开麦克风权限!",c)];case 6:return u=l.sent()||{},[3,8];case 7:return h=l.sent(),console.log(h),[3,8];case 8:return t.request(s+"/call/api/call/call/out",{verb:"POST",body:o,loginToken:t.loginToken,sessionId:t.agentInfo._id,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success(__assign$1(__assign$1({success:!0,message:"callout success"},u),e.data)):n.fail(__assign$1({success:!1,message:e.message,code:e.code},u))}}),[2]}}))}))},hangup:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/hangup",{verb:"POST",body:{},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"hangup success",data:e}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},holdOrUnHold:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type){var i=t.initOptions.server||t.callApiUrl,s={type:n.type};t.request(i+"/call/api/call/hold",{verb:"POST",body:s,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"holdOrUnHold success"}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},muteOrUnMute:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type){var i=t.initOptions.server||t.callApiUrl,s={type:n.type,direction:n.direction||"all"};t.request(i+"/call/api/call/mute",{verb:"POST",body:s,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"muteOrUnMute success"}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},transfer:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type)if(null!==n.number&&void 0!==n.number){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/transfer",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"transfer success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter number is required!"});else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},consult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.mode&&void 0!==n.mode)if(null!==n.number&&void 0!==n.number){n.agentNumber=t.agentInfo.agentNumber;var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"consult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter number is required!"});else n.fail({success:!1,message:"Parameter mode is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},cancelconsult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/cancel",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"cancelconsult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},endConsult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/stop",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"endConsult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},callbackConsult:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/resume",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"resumeConsult success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},consultTransfer:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/consult/transfer",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"consultTransfer success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},threeWayCall:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/threeway",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"threeWayCall success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},evaluate:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.type&&void 0!==n.type){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/evaluate",{verb:"POST",body:n,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"evaluate success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter type is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})},meeting:function(n){if(n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null!==t.loginToken&&void 0!==t.loginToken)if(null!==t.agentInfo&&void 0!==t.agentInfo)if(null!==n.number&&void 0!==n.number){var i=t.initOptions.server||t.callApiUrl;t.request(i+"/call/api/call/meeting",{verb:"POST",body:{meetingType:"phone",number:n.number},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,encryptionAlgorithm:e,encryptionFields:r,success:function(e){e.success?n.success({success:!0,message:"meeting success",data:e.data.response.data}):n.fail({success:!1,message:e.message,code:e.code})}})}else n.fail({success:!1,message:"Parameter number is required!"});else n.fail({success:!1,message:"initialization not complete!"});else n.fail({success:!1,message:"initialization not complete!"})}}},this._agentApi=function(){var e=n;return{switchLoginType:function(n){return __awaiter$1(this,void 0,void 0,(function(){var r,i,s,o,a,c,u=this;return __generator$1(this,(function(h){switch(h.label){case 0:if(r=null,n.success=n&&"function"==typeof n.success?n.success:t.noop,n.fail=n&&"function"==typeof n.fail?n.fail:t.noop,null===n.loginType||void 0===n.loginType)return n.fail({success:!1,message:"Parameter loginType is required!"}),[2];if(null===t.agentInfo||void 0===t.agentInfo)return n.fail({success:!1,message:"initialization not complete!"}),[2];if(null!==n.loginNumber&&void 0!==n.loginNumber&&(r=n.loginNumber),"PSTN"===n.loginType&&!(r=r||t.agentInfo.mobile))return alert("请给座席绑定手机号,或者传入号码参数!"),n.fail({success:!1,message:"Please bind your mobile number"}),[2];if("SIP"===n.loginType&&(r=r||t.agentInfo.sipNumber),"WEBRTC"===n.loginType&&(r=t.agentInfo.webrtcSipNumber),i=t.initOptions.server||t.callApiUrl,s={loginType:n.loginType,loginNumber:r},t.initOptions,a=!0,"WEBRTC"!==n.loginType)return[3,4];h.label=1;case 1:return h.trys.push([1,3,,4]),[4,e.openMediaAudio("请打开麦克风权限!",a)];case 2:return o=h.sent()||{},[3,4];case 3:return c=h.sent(),console.log(c),[3,4];case 4:return t.request(i+"/call/api/agent/v1/login-type/change",{verb:"POST",body:s,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(r){return __awaiter$1(u,void 0,void 0,(function(){return __generator$1(this,(function(s){switch(s.label){case 0:return r.success?(n.success(__assign$1({success:!0,message:"updateLoginType success"},o)),t.agentInfo.loginType=n.loginType,t.initOptions.loginType=n.loginType,"WEBRTC"!==n.loginType?[3,1]:(e._webPhoneApi().connect(),[3,4])):[3,5];case 1:return"PSTN"!==n.loginType?[3,3]:[4,t.request(i+"/platform/action/updateCallConfig",{verb:"POST",body:{agentCallConfig:{},mobile:n.loginNumber},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId})];case 2:return s.sent(),e._webPhoneApi().disconnect(),[3,4];case 3:e._webPhoneApi().disconnect(),s.label=4;case 4:return[3,6];case 5:n.fail(__assign$1({success:!1,message:r.message,code:r.code},o)),s.label=6;case 6:return[2]}}))}))}}),[2]}}))}))},findPhoneBarList:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl;t.request(n+"/call/api/phone/bar/all",{verb:"GET",loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(t){if(t.success){var n=[];t.data.forEach((function(e){var t={name:e.name,number:e.number};n.push(t)})),e.success({success:!0,data:n})}else e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"})},switchPhoneBar:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==e.stateNumber&&void 0!==e.stateNumber)if(null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl,r={stateNumber:e.stateNumber,accountId:t.agentInfo.accountId,agentNumber:t.agentInfo.agentNumber};t.request(n+"/call/api/agent/status/switch",{verb:"POST",body:r,loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(t){t.success?e.success({success:!0}):e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"});else e.fail({success:!1,message:"Parameter stateNumber is required!"})},logout:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){null!==e.toAnswerOffline&&void 0!==e.toAnswerOffline||(e.toAnswerOffline="1");var n=t.initOptions.server||t.callApiUrl,r={toAnswerOffline:e.toAnswerOffline};t.request(n+"/call/api/sdk/agent/logout",{verb:"POST",body:r,loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(n){n.success?e&&(t.Socketinstance.disconnect(),"WEBRTC"===t.agentInfo.loginType&&t.webPhone.disconnect(),e.success({success:!0})):e&&e.fail({success:!1,message:n.message,code:n.code})}})}else e.fail({success:!1,message:"initialization not complete!"})},findIdleAgentsForQueue:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl;t.request(n+"/call/api/queue/acountFreeAgent/find",{verb:"POST",body:{},loginToken:t.loginToken,sessionId:t.agentInfo._id,accountId:t.agentInfo.accountId,success:function(t){t.success?e&&e.success({success:!0,dataList:t.data||[]}):e&&e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"})},getAvailableSipNumberList:function(e){if(e.success=e&&"function"==typeof e.success?e.success:t.noop,e.fail=e&&"function"==typeof e.fail?e.fail:t.noop,null!==t.agentInfo&&void 0!==t.agentInfo){var n=t.initOptions.server||t.callApiUrl;t.request(n+"/call/api/sip/avaliable/query",{verb:"POST",body:{},loginToken:t.loginToken,sessionId:t.agentInfo._id,success:function(t){if(t.success&&t.data){var n=[];t.data.forEach((function(e){var t={number:e.id,numberName:e.number};n.push(t)})),e.success({success:!0,data:n})}else e.fail({success:!1,message:t.message,code:t.code})}})}else e.fail({success:!1,message:"initialization not complete!"})}}},this._webPhoneApi=function(){return{accept:function(){t.webPhone.accept()},connect:function(){t.webPhone&&this.isConnected()||t.initWebrtcEvent(t.agentextras)},disconnect:function(){t.webPhone&&this.isConnected()&&t.webPhone.disconnect()},isConnected:function(){return t.webPhone.isConnected()},sendDTMF:function(e){t.webPhone.sendDTMF(e)}}},e.error="function"==typeof e.error?e.error:t.noop,e.success="function"==typeof e.success?e.success:t.noop,null!==e.agentNumber&&void 0!==e.agentNumber?(null!==e.loginType&&void 0!==e.loginType||(e.loginType="PSTN"),null!==e.pushHangupStatistics&&void 0!==e.pushHangupStatistics||(e.pushHangupStatistics=!1),null!==e.pushCallinRingStatistics&&void 0!==e.pushCallinRingStatistics||(e.pushCallinRingStatistics=!1),this.init(e)):e.error({message:"Invalid agentNumber"})}var t;return e.noop=function(){},e.prototype.init=function(e){if(void 0===e&&(e={}),t.trace=t.noop,t.debug=t.noop,t.log=t.noop,t.warn=t.noop,t.error=t.noop,!0===e.debug||"all"===e.debug)t.trace=console.trace.bind(console),t.debug=console.debug.bind(console),t.log=console.log.bind(console),t.warn=console.warn.bind(console),t.error=console.error.bind(console);else if(Array.isArray(e.debug))for(var n in e.debug){var r=e.debug[n];switch(r){case"trace":t.trace=console.trace.bind(console);break;case"debug":t.debug=console.debug.bind(console);break;case"log":t.log=console.log.bind(console);break;case"warn":t.warn=console.warn.bind(console);break;case"error":t.error=console.error.bind(console);break;default:console.error("Unknown debugging option '"+r+"' (supported: 'trace', 'debug', 'log', warn', 'error')")}}t.log("Initializing library");var i=t.useDefaultDependencies({WebSocket:ueWebsocket});t.newWebSocket=i.newWebSocket,t.request=i.request,this.login(e)},e.prototype.login=function(e){return __awaiter$1(this,void 0,void 0,(function(){var n,r,i,s,o,a,c,u,h,l,d=this;return __generator$1(this,(function(p){switch(p.label){case 0:if(console.log(e,"options"),t.UserConfig=e,n=e.server||t.callApiUrl,r=e.agentNumber+"@"+e.accountId,i=e.loginType,s=e.isOpenNetwork||!1,o=e.isOpenCallQueue||!1,a=e.openNlsTranslation||!1,c={loginName:r,loginType:i,loginChannel:"SDK",password:""},u=!0,"WEBRTC"!==i)return[3,4];p.label=1;case 1:return p.trys.push([1,3,,4]),[4,this.openMediaAudio("请打开麦克风权限!",u)];case 2:return h=p.sent()||{},[3,4];case 3:return l=p.sent(),console.log(l),console.log("授权失败================================"),[3,4];case 4:return e.password&&(c.password=e.password),t.request(n+"/platform/public/loginPre",{verb:"GET",success:function(r){if(r&&r.success&&r.data){var u=decodeURIComponent(gBase64.decode(r.data.pk)),l=new JSEncrypt;l.setPublicKey(u);var p=md5(c.password),g=l.encrypt(p);c.password=g,t.request(n+"/platform/public/login",{verb:"POST",body:c,success:function(r){r.success?t.request(n+"/platform/action/loginInfo",{verb:"GET",loginToken:r.data.loginToken,sessionId:r.data.sessionId,success:function(r){r.success?(r.data.agent&&(t.agentInfo=r.data.agent,t.loginToken=r.data.loginToken,t.initOptions=__assign$1(__assign$1({},e),{audioInfo:h})),d.initAttachEvent(n,i,r.data.pushServer,r.data.agent,e.success),s&&d.initnNetworkMonitoring(r.data.pushServer,""),(o||a)&&d.initAgentQueue(n,i,r.data.pushServer,r.data.agent,e.success),o&&d.initQueue(n),"WEBRTC"===i&&d.getWebrtcInfo(n,e)):e.error(__assign$1(__assign$1({},r),h))},error:function(t){e.error(__assign$1({error:t},h))}}):e.error(__assign$1(__assign$1({},r),h))},error:function(t){e.error(__assign$1({error:t},h))}})}else e.error(__assign$1(__assign$1({},r),h))},error:function(t){e.error(__assign$1({error:t},h))}}),[2]}}))}))},e.createEventHandle=function(e){var n=this;void 0===e&&(e={}),e.success="function"==typeof e.success?e.success:t.noop,e.error="function"==typeof e.error?e.error:t.noop,e.message="function"==typeof e.message?e.message:t.noop,e.event="function"==typeof e.event?e.event:t.noop,e.server=null===e.serve||void 0===e.serve?"ws://152.136.72.209:3201/phoneBarGateway":e.serve,null!==e.SocketOptions&&void 0!==e.SocketOptions||(e.SocketOptions={},t.error({message:"login response error!"})),this.Socketinstance=t.newWebSocket(e.server,e.SocketOptions),this.Socketinstance.on("connect",(function(){e.success("connect event serve success!"),e.suc()})),this.Socketinstance.on("error",(function(t,n){e.error({type:"socketError",error:t}),n&&"function"==typeof n&&n("error")})),this.Socketinstance.on("message",(function(n,r){e.message({subtype:n.subType,data:n.data}),"WEBRTC"===t.initOptions.loginType&&(n.data&&n.data.callType&&"callin"===n.data.callType&&n.data.eventType&&"ring"===n.data.eventType?(t.AudioTask||(t.AudioTask=new AudioTask("https://softphone.useasy.cn/ring.wav")),t.AudioTask.ringAudioPlay()):t.AudioTask&&t.AudioTask.ringAudioPause()),r&&"function"==typeof r&&r("success")})),this.Socketinstance.on("event",(function(r){if("KICK_OFF"===r.subType&&!0===r.data.kickoff){n.Socketinstance.disconnect(),t.loginToken="KICK_OFF";try{t.webPhone.disconnect(),console.log(r,"互踢")}catch(e){}e.event({message:"坐席账户在其他地方登录",data:r})}}))},e.createQueueMonitorEventHandle=function(e){var n=this;void 0===e&&(e={}),e.success="function"==typeof e.success?e.success:t.noop,e.error="function"==typeof e.error?e.error:t.noop,e.message="function"==typeof e.message?e.message:t.noop,e.server=null===e.serve||void 0===e.serve?"ue-dev1.useasy.cn":e.serve,null!==e.SocketOptions&&void 0!==e.SocketOptions||(e.SocketOptions={},t.error({message:"login response error!"})),null===this.MonitorSocketinstance&&(this.MonitorSocketinstance=t.newWebSocket(e.server,e.SocketOptions)),this.MonitorSocketinstance.on("connect",(function(){e.success("connect event serve success!"),e.suc(),t.log("监控connect========")})),this.MonitorSocketinstance.on("error",(function(t,n){e.error({type:"socketError",error:t}),n&&"function"==typeof n&&n("error")})),this.MonitorSocketinstance.on("event",(function(r,i){if("KICK_OFF"===r.subType&&!0===r.data.kickoff){n.MonitorSocketinstance.disconnect();try{t.webPhone.disconnect()}catch(e){}e.message({message:"坐席账户在其他地方登录",data:r})}e.message(r)})),this.MonitorSocketinstance.on("call",(function(n,r){"queue"==n.subType&&t.UserConfig.isOpenCallQueue&&e.message({subtype:n.subType,data:n.data})}))},e.createopenNlsTransEventHandle=function(e){var n=this;void 0===e&&(e={}),e.success="function"==typeof e.success?e.success:t.noop,e.error="function"==typeof e.error?e.error:t.noop,e.message="function"==typeof e.message?e.message:t.noop,e.server=null===e.serve||void 0===e.serve?"ue-dev1.useasy.cn":e.serve,null!==e.SocketOptions&&void 0!==e.SocketOptions||(e.SocketOptions={},t.error({message:"login response error!"})),null===this.MonitorSocketinstance&&(this.MonitorSocketinstance=t.newWebSocket(e.server,e.SocketOptions)),this.MonitorSocketinstance.on("connect",(function(){e.success("转译connect event serve success!"),e.suc(),t.log("转译监控connect========")})),this.MonitorSocketinstance.on("error",(function(t,n){e.error({type:"socketError",error:t}),n&&"function"==typeof n&&n("error")})),this.MonitorSocketinstance.on("event",(function(r,i){if("KICK_OFF"===r.subType&&!0===r.data.kickoff){n.MonitorSocketinstance.disconnect();try{t.webPhone.disconnect()}catch(e){}e.message({message:"坐席账户在其他地方登录",data:r})}e.message(r)})),this.MonitorSocketinstance.on("call",(function(n,r){"translation"==n.subType&&t.UserConfig.openNlsTranslation&&e.message({subtype:n.subType,data:n.data})}))},e.useDefaultDependencies=function(e){var n=e&&e.fetch||fetch,r=e&&e.Promise||Promise,i=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,t){return new i(e,t)},request:function(e,i){var s={method:i.verb,cache:"no-cache",headers:{"Content-Type":"application/json",loginToken:i.loginToken||"",sessionId:i.sessionId||"",clienttype:0}};i.encryptionFields&&(s.headers["ue-encryption-algorithm"]=i.encryptionAlgorithm||"aes",s.headers["ue-encryption-fields"]=i.encryptionFields),void 0!==i.withCredentials&&(s.credentials=!0===i.withCredentials?"include":i.withCredentials?i.withCredentials:"omit"),void 0!==i.body&&(s.body=JSON.stringify(i.body));var o=n(e,s).catch((function(e){return r.reject({message:"Probably a network error, is the gateway down?",error:e})}));if(void 0!==i.timeout){var a=new r((function(e,t){var n=window.setTimeout((function(){return clearTimeout(n),i.error({message:"Request timed out",timeout:i.timeout}),t({message:"Request timed out",timeout:i.timeout})}),i.timeout)}));o=r.race([o,a])}return o.then((function(e){return e.ok?typeof i.success==typeof t.noop?e.json().then((function(e){i.success(e)})).catch((function(t){return i.error({message:"Failed to parse response body",error:t,response:e}),r.reject({message:"Failed to parse response body",error:t,response:e})})):void 0:(i.error({message:"API call failed",response:e}),r.reject({message:"API call failed",response:e}))})).catch((function(e){typeof i.error==typeof t.noop&&i.error(e.message||"<< internal error >>",e)})),o}}},Object.defineProperty(e.prototype,"agent",{get:function(){return this._agentApi()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"webrtc",{get:function(){return this._webPhoneApi()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"call",{get:function(){return this._callApi()},enumerable:!1,configurable:!0}),t=e,e.callApiUrl="https://app.useasy.cn/api",e.Socketinstance=null,e.AudioTask=null,e.MonitorSocketinstance=null,e.UserConfig=null,e.initWebrtcEvent=function(e){return __awaiter$1(void 0,void 0,void 0,(function(){return __generator$1(t,(function(n){switch(n.label){case 0:return t.webPhone=new UeWebrtc({server:e.wssUrl,sip:e.sip,secret:e.password}),[4,this.webPhone.connect()];case 1:return n.sent(),this.webPhone.register(),[2]}}))}))},e}(),ueWebsocket=function(){function e(e,t){delete t.path,delete t.hostname,delete t.port,this.ws=_t.connect("wss://".concat(e),t)}return e.prototype.on=function(e,t){"connect"===e&&this.ws.on(e,t),"error"===e&&(this.ws.on("connect_error",t),this.ws.on("error",t),this.ws.on("disconnect",t),this.ws.on("reconnect_failed",t)),"message"===e&&this.ws.on("call",t),"event"===e&&this.ws.on("event",t),"call"===e&&this.ws.on("call",t)},e.prototype.emit=function(e,t,n){this.ws.emit(e,t,n)},e.prototype.disconnect=function(){this.ws.disconnect()},e}(),AudioTask=function(){function e(e){this.ringAudio=new Audio(e),this.ringAudio.loop=!0,this.ringAudioRunning=!1}return e.prototype.ringAudioPlay=function(){return __awaiter$1(this,void 0,void 0,(function(){return __generator$1(this,(function(e){switch(e.label){case 0:return this.ringAudioRunning?[2]:[3,1];case 1:return[4,this.ringAudio.play()];case 2:e.sent(),this.ringAudioRunning=!0,e.label=3;case 3:return[2]}}))}))},e.prototype.ringAudioPause=function(){return __awaiter$1(this,void 0,void 0,(function(){return __generator$1(this,(function(e){switch(e.label){case 0:return this.ringAudio.paused?[3,2]:[4,this.ringAudio.pause()];case 1:e.sent(),this.ringAudioRunning=!1,e.label=2;case 2:return[2]}}))}))},e}();return ueSoftphone}();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ interface meetingParams {
|
|
|
129
129
|
success?: Function;
|
|
130
130
|
fail?: Function;
|
|
131
131
|
}
|
|
132
|
-
export default class
|
|
132
|
+
export default class ueSoftphone {
|
|
133
133
|
static ueTimer: any;
|
|
134
134
|
static loginToken: String | undefined;
|
|
135
135
|
static agentInfo: any;
|
|
@@ -164,6 +164,7 @@ export default class ueSoftphoneBeta {
|
|
|
164
164
|
private initAgentQueue;
|
|
165
165
|
private initQueue;
|
|
166
166
|
static createQueueMonitorEventHandle(callbacks?: any): void;
|
|
167
|
+
static createopenNlsTransEventHandle(callbacks?: any): void;
|
|
167
168
|
listenCallQueueEvent: (callbacks: any) => void;
|
|
168
169
|
listenTranslationEvent: (callbacks: any) => void;
|
|
169
170
|
static useDefaultDependencies(deps: any): {
|