@94ai/softphone 4.0.1

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/lib/index.d.ts ADDED
@@ -0,0 +1,531 @@
1
+ import { URI, UserAgent, Inviter } from 'sip.js';
2
+ export { Inviter, Registerer, SessionState, URI, UserAgent } from 'sip.js';
3
+ import { Invitation } from 'sip.js/lib/api/invitation';
4
+ export { Invitation } from 'sip.js/lib/api/invitation';
5
+ import { UserAgentDelegate } from 'sip.js/lib/api/user-agent-delegate';
6
+ export { UserAgentDelegate } from 'sip.js/lib/api/user-agent-delegate';
7
+ import { SessionDescriptionHandler } from 'sip.js/lib/api/session-description-handler';
8
+ export { SessionDescriptionHandler } from 'sip.js/lib/api/session-description-handler';
9
+ import { SessionByeOptions } from 'sip.js/lib/api/session-bye-options';
10
+ export { SessionByeOptions } from 'sip.js/lib/api/session-bye-options';
11
+ export { RegistererUnregisterOptions } from 'sip.js/lib/api/registerer-unregister-options';
12
+ import { RegistererRegisterOptions } from 'sip.js/lib/api/registerer-register-options';
13
+ export { RegistererRegisterOptions } from 'sip.js/lib/api/registerer-register-options';
14
+ import { InvitationAcceptOptions } from 'sip.js/lib/api/invitation-accept-options';
15
+ export { InvitationAcceptOptions } from 'sip.js/lib/api/invitation-accept-options';
16
+ import { InvitationRejectOptions } from 'sip.js/lib/api/invitation-reject-options';
17
+ export { InvitationRejectOptions } from 'sip.js/lib/api/invitation-reject-options';
18
+ import { RegistererOptions } from 'sip.js/lib/api/registerer-options';
19
+ export { RegistererOptions } from 'sip.js/lib/api/registerer-options';
20
+ export { OutgoingRequest } from 'sip.js/lib/core/messages/outgoing-request';
21
+ import { IncomingResponse } from 'sip.js/lib/core/messages/incoming-response';
22
+ export { IncomingResponse } from 'sip.js/lib/core/messages/incoming-response';
23
+ export { SimpleUser } from 'sip.js/lib/platform/web/index.js';
24
+ export { default as onChange } from 'on-change';
25
+ import { UserAgentOptions as UserAgentOptions$1 } from 'sip.js/lib/api/user-agent-options';
26
+ import { InviterInviteOptions } from 'sip.js/lib/api/inviter-invite-options';
27
+ import { SessionInfoOptions } from 'sip.js/lib/api/session-info-options';
28
+
29
+ type InviterInviteOptionsExtend = InviterInviteOptions & {
30
+ extraHeaders?: string[];
31
+ };
32
+ type SessionInfoOptionsExtend = SessionInfoOptions & {
33
+ extraHeaders?: string[];
34
+ };
35
+ type InvitationAcceptOptionsExtend = InvitationAcceptOptions & {
36
+ onAck?: Function;
37
+ onAckTimeout?: Function;
38
+ };
39
+ /**
40
+ * 挂断配置
41
+ */
42
+ type HandUpInviteOption = {
43
+ /** 当会话尚在建立中,配置挂断请求 */
44
+ rejectOptions?: InvitationRejectOptions;
45
+ /** 当会话已建立,配置挂断请求 */
46
+ byeOptions?: SessionByeOptions;
47
+ /** sip自定义头 */
48
+ extraHeaders?: string[];
49
+ /** 是否开启响应返回检测 */
50
+ scoutResponse?: boolean;
51
+ };
52
+ /**
53
+ * 注册配置
54
+ */
55
+ type RegisterOptions = {
56
+ /** sip自定义头 */
57
+ extraHeaders?: string[];
58
+ /** new Registerer Options */
59
+ registererOptions?: RegistererOptions;
60
+ /** Registerer Instance register Options */
61
+ registererRegisterOptions?: RegistererRegisterOptions;
62
+ };
63
+ /**
64
+ * 签入配置
65
+ */
66
+ type PrepareUserAgentOptions = {
67
+ /** sip服务地址,可以用于切换签入服务器 */
68
+ uri?: URI;
69
+ /** 分机号,可以用于切换签入服务器 */
70
+ authorizationUsername?: string;
71
+ /** 分机密码,可以用于切换签入服务器 */
72
+ authorizationPassword?: string;
73
+ /** transport层协议配置,可以用于切换签入服务器 */
74
+ transportOptions?: TransportOptions;
75
+ /** 一般设置同authorizationUsername,相当于MicroSIP的显示名称,可以用于切换签入服务器 */
76
+ contactName?: string;
77
+ /** sip自定义头 */
78
+ extraHeaders?: string[];
79
+ /** 当软电话状态变化时会实时刷新这个方法 */
80
+ refresh?: (path: UserAgentStatusKey, value: boolean) => void;
81
+ /** new Registerer Options */
82
+ registererOptions?: RegistererOptions;
83
+ /** Registerer Instance register Options */
84
+ registererRegisterOptions?: RegistererRegisterOptions;
85
+ agentId?: number;
86
+ agentTag?: string;
87
+ appKey?: string;
88
+ appSecret?: string;
89
+ openBaseUrl?: string;
90
+ sg?: '1' | '0';
91
+ sgOpen?: '1' | '0';
92
+ };
93
+ /**
94
+ * 软电话代理实例状态
95
+ */
96
+ type UserAgentStatus = {
97
+ /** 软电话是否已签入 */
98
+ connectStatus: boolean;
99
+ /** 软电话是否已注册 */
100
+ registerStatus: boolean;
101
+ /** 软电话是否正拨出 */
102
+ invitatingStatus: boolean;
103
+ /** 软电话是否正来电 */
104
+ incomingStatus: boolean;
105
+ /** 软电话是否正接听 */
106
+ answerStatus: boolean;
107
+ /**
108
+ * 软电话是否正在重连
109
+ * 网络断掉,服务器重启,宕机等引起服务不可达时软电话代理会尝试重新连接并签入
110
+ * 这个时候用户拨出等动作可以通过此状态做拦截,通知用户软电话服务器可能正重启或断网等导致服务不可用
111
+ * */
112
+ reconnectStatus: boolean;
113
+ };
114
+ type UserAgentDelegateKey = keyof UserAgentDelegate;
115
+ type UserAgentStatusKey = 'connectStatus' | 'registerStatus' | 'invitatingStatus' | 'incomingStatus' | 'answerStatus';
116
+ /**
117
+ * transport层配置
118
+ */
119
+ interface TransportOptions {
120
+ /** websocket协商地址, server和wsServers 必须二选一*/
121
+ server?: string;
122
+ /** 多个地址开启负载均衡模式 */
123
+ wsServers?: string | string[] | {
124
+ /** websocket协商地址 */
125
+ ws_uri: string;
126
+ /** 权重 */
127
+ weight: number;
128
+ }[];
129
+ /**
130
+ * websocke初始化连接等待超时时间
131
+ * @default 5
132
+ */
133
+ connectionTimeout?: number;
134
+ /**
135
+ * transport层客户端保活最大重连尝试次数
136
+ * @default 3
137
+ */
138
+ maxReconnectionAttempts?: number;
139
+ /**
140
+ * transport层客户端保活重连动作执行间隔时间,单位秒,同UserAgentOptionsSDK.reconnectionDelay
141
+ * @default 4
142
+ */
143
+ reconnectionTimeout?: number;
144
+ /**
145
+ * transport层The time (Number) in seconds to wait in between CLRF keepAlive sequences are sent.
146
+ * @default 0
147
+ */
148
+ keepAliveInterval?: number;
149
+ /**
150
+ * transport层The time (Number) in seconds to debounce sending CLRF keepAlive sequences by
151
+ * @default 10
152
+ */
153
+ keepAliveDebounce?: number;
154
+ /**
155
+ * transport层If true, messages sent and received by the transport are logged.
156
+ * @default false
157
+ */
158
+ traceSip?: boolean;
159
+ }
160
+ /**
161
+ * sip层配置
162
+ */
163
+ interface UserAgentOptionsSDK {
164
+ /**
165
+ * 通过openApi获取坐席账号分机密码
166
+ * @default ''
167
+ */
168
+ authorizationPassword: string;
169
+ /**
170
+ * 通过openApi获取坐席账号分机用户名
171
+ * @default ''
172
+ */
173
+ authorizationUsername: string;
174
+ /**
175
+ * 指纹,唯一标志,用来排查线路故障,默认随机指纹,可选
176
+ * @default createRandomToken(12) + ".invalid"
177
+ */
178
+ viaHost?: string;
179
+ /**
180
+ * sip服务地址,必填,需要服务可达的地址
181
+ * @default new URI("sip", "anonymous." + createRandomToken(6), "anonymous.invalid") })
182
+ */
183
+ uri: URI;
184
+ /**
185
+ * sip日志查看等级,一般情况下生产开error,开发用debugger
186
+ * @default 'log'
187
+ */
188
+ logLevel?: 'debug' | 'log' | 'warn' | 'error';
189
+ /**
190
+ * 一般设置同authorizationUsername,相当于MicroSIP的显示名称
191
+ * @default createRandomToken(8)
192
+ */
193
+ contactName?: string;
194
+ /**
195
+ * 签入来电后多长时间不执行接听会话自动结束会话,单位秒
196
+ * @default 60
197
+ */
198
+ noAnswerTimeout?: number;
199
+ /**
200
+ * sip层 - 重连尝试间隔,为了兼容sipjs,同reconnectionInterval
201
+ * @deprecated
202
+ * @default 100
203
+ */
204
+ reconnectionDelay?: number;
205
+ /**
206
+ * transport层协议配置
207
+ */
208
+ transportOptions: TransportOptions;
209
+ /**
210
+ * sip层 - 重连尝试间隔,单位秒
211
+ * @default 100
212
+ */
213
+ reconnectionInterval?: number;
214
+ /**
215
+ * sip层 - 重连失败最大尝试次数
216
+ * @default
217
+ */
218
+ reconnectionAttempts?: number;
219
+ /**
220
+ * sip层 - 重连成功后尝试重新注册检间隔,单位秒
221
+ * @default 3
222
+ */
223
+ registerInterval?: number;
224
+ /**
225
+ * sip层 - 重连成功最大尝试注册次数
226
+ * @default 3
227
+ */
228
+ registerAttempts?: number;
229
+ /**
230
+ * sip层 - ping动作间隔,单位秒
231
+ * @default 8
232
+ */
233
+ optionsPingInterval?: number;
234
+ /**
235
+ * sip层 - ping最大失败尝试次数后开始重连,防止网络抖动引起非必要重连
236
+ * @default 3
237
+ */
238
+ optionsPingAttempts?: number;
239
+ /**
240
+ * sip层 - 自定义通讯header
241
+ */
242
+ sipHeaders?: Array<string>;
243
+ appKey?: string;
244
+ appSecret?: string;
245
+ agentTag?: string;
246
+ agentId?: number;
247
+ openBaseUrl?: string;
248
+ sg?: '1' | '0';
249
+ sgOpen?: '1' | '0';
250
+ token: string;
251
+ tokenTimestamp: string | number;
252
+ tokenExpirationTime: number;
253
+ sign: string;
254
+ timestamp: string | number;
255
+ signExpirationTime: number;
256
+ signCheck?: Function;
257
+ tokenCheck?: Function;
258
+ signOverdued?: Function;
259
+ tokenOverdued?: Function;
260
+ openXhrIntercept?: Function;
261
+ gatewayXhrIntercept?: Function;
262
+ refreshChatErrorCallback?: Function;
263
+ refreshSpeekVolumn?: Function;
264
+ refreshRequirementCheck?: Function;
265
+ refreshChat?: Function;
266
+ enableChatInfoPush?: boolean;
267
+ enableVolumnTrack?: boolean;
268
+ }
269
+ type UserAgentOptions = UserAgentOptions$1 & UserAgentOptionsSDK;
270
+ type ajaxOption = {
271
+ type: 'GET' | 'POST';
272
+ url: string;
273
+ data: Record<string, any>;
274
+ contentType: string;
275
+ };
276
+
277
+ /**
278
+ * 代理实例类
279
+ */
280
+ declare class UserAgentManager {
281
+ #private;
282
+ token: string;
283
+ /**
284
+ * 坐席讲话音量
285
+ */
286
+ get volumeValue(): number;
287
+ networkSpeed: string;
288
+ networkDelay: string;
289
+ onLine: boolean;
290
+ testspeeding: boolean;
291
+ goodNetworkSpeed: () => boolean;
292
+ goodNetworkDelay: () => boolean;
293
+ authorizedMicrophonePermissions: boolean;
294
+ authorizedNotificationPermissions: boolean;
295
+ get businessAttribute(): Record<string, any>;
296
+ /**
297
+ * 每次来电是否自动接听
298
+ */
299
+ ifAutoAnswer: () => boolean;
300
+ /**
301
+ * 每次来电是否需要转人工
302
+ */
303
+ notNeedSendStarDtmf: () => boolean;
304
+ /**
305
+ * 是否快速外呼
306
+ */
307
+ getFastOutboundCall(): boolean;
308
+ getSitOutboundCall(): boolean;
309
+ constructor(userAgentOption?: Partial<UserAgentOptions>);
310
+ disposeSoftphoneEnvRequirementCheck: () => void;
311
+ /**
312
+ * 软电话环境检测
313
+ */
314
+ softphoneEnvCheck: () => Promise<void>;
315
+ oneRoundOfTesting: () => Promise<void>;
316
+ /**
317
+ * 检测麦克风权限
318
+ */
319
+ detectNavigatorPermissions(): void;
320
+ openApiAjax: (param: Partial<ajaxOption>) => Promise<any>;
321
+ getGateway(): "https://gateway.sg.94ai.com" | "https://gateway.94ai.com";
322
+ requestGateway: (param: Partial<ajaxOption>, needToken?: boolean) => Promise<any>;
323
+ gatewayApiAjax: (param: Partial<ajaxOption>, needToken?: boolean) => Promise<any>;
324
+ getGatewayToken(): Promise<string>;
325
+ getGatewayAccessToken(params: {
326
+ corpId: string;
327
+ secret: string;
328
+ sid: number;
329
+ seatOnline: boolean;
330
+ }): Promise<any>;
331
+ getCallNumberDetail(params: {
332
+ id: string;
333
+ taskId: string;
334
+ }): Promise<any>;
335
+ getCallNumberChats(params: {
336
+ callId: string;
337
+ taskId: string;
338
+ }): Promise<any>;
339
+ getCallInfo(): Promise<void>;
340
+ refreshCallChatInfo(): Promise<void>;
341
+ requestOpenApi: (param: Partial<ajaxOption>) => Promise<any>;
342
+ getOpenApi(): string;
343
+ getAgentInfo(): Promise<any>;
344
+ getOpenApiSign(timestamp?: number, appKey?: string, appSecret?: string): Promise<{
345
+ sign: string;
346
+ timestamp: string | number;
347
+ }>;
348
+ updateOpenApiAgentStatus(agentStatus: 1 | 2 | 3 | 4): Promise<any>;
349
+ importOpenApiAgentCustomer(number: string): Promise<any>;
350
+ /**
351
+ * 呼叫
352
+ */
353
+ callNumber(number: string): Promise<any>;
354
+ /**
355
+ * 小休
356
+ */
357
+ toggleNap(nap: boolean): Promise<any>;
358
+ getDeviceId: () => Promise<string>;
359
+ refreshSign(sign: string): void;
360
+ /**
361
+ * 签入
362
+ * @param config 配置
363
+ * @param { (path: keyof UserAgentStatusKey, value: boolean) => void } config.refresh 配置
364
+ * @param { import('sip.js/lib/api/registerer-options').RegistererOptions } config.registererOptions new Registerer Options
365
+ * @param { import('sip.js/lib/api/registerer-register-options').RegistererRegisterOptions } config.registererRegisterOptions Registerer Instance register Options
366
+ * @param { string[] } options.extraHeaders sip custom header
367
+ * @param { import('sip.js/lib/api/user-agent-delegate').UserAgentDelegate } event 事件
368
+ */
369
+ prepareUserAgent(config?: PrepareUserAgentOptions, event?: UserAgentDelegate): Promise<UserAgent>;
370
+ /**
371
+ * 签出
372
+ */
373
+ dispose(): Promise<void>;
374
+ /**
375
+ * 忽略
376
+ * @param { import('sip.js/lib/api/invitation-reject-options').InvitationRejectOptions } } options 配置
377
+ */
378
+ ignoreInvite(options?: InvitationRejectOptions): Promise<void>;
379
+ /**
380
+ * 接听
381
+ * @param { InvitationAcceptOptions } options 配置
382
+ */
383
+ acceptInvite(options?: InvitationAcceptOptionsExtend): Promise<void>;
384
+ /**
385
+ * 挂断
386
+ * @param options 配置
387
+ * @param { import('sip.js/lib/api/invitation-reject-options').InvitationRejectOptions } options.rejectOptions 当会话尚在建立中,配置挂断请求
388
+ * @param { import('sip.js/lib/api/session-bye-options').SessionByeOptions } options.byeOptions 当会话已建立,配置挂断请求
389
+ * @param { string[] } options.extraHeaders sip自定义头
390
+ */
391
+ hangUpInvite(options?: HandUpInviteOption): Promise<boolean | IncomingResponse>;
392
+ /**
393
+ * 按*转人工
394
+ * @param { import('sip.js/lib/api/session-info-options').SessionInfoOptions & {extraHeaders: string[]} } options 配置
395
+ */
396
+ sendStarDtmf(options?: SessionInfoOptionsExtend): Promise<IncomingResponse>;
397
+ /**
398
+ * 拨出
399
+ * @param { import('sip.js/lib/api/inviter-invite-options').InviterInviteOptions & {extraHeaders?: string[]} } options 配置
400
+ */
401
+ sendCurrentInviter(options?: InviterInviteOptionsExtend): Promise<void>;
402
+ /**
403
+ * 不接听远端声音
404
+ */
405
+ muteRemoteAudio(): void;
406
+ /**
407
+ * 接听远端声音
408
+ */
409
+ unMuteRemoteAudio(): void;
410
+ /**
411
+ * 不传输本地声音到远端
412
+ */
413
+ muteLocalAudio(): void;
414
+ /**
415
+ * 传输本地声音到远端
416
+ */
417
+ unMuteLocalAudio(): void;
418
+ /**
419
+ * 获取代理实例状态
420
+ */
421
+ getUserAgentStatue(): UserAgentStatus;
422
+ /**
423
+ * 获取代理实例
424
+ */
425
+ getUserAgent(): UserAgent;
426
+ /**
427
+ * 获取会话实例
428
+ */
429
+ getSessionDescriptionHandler(): SessionDescriptionHandler;
430
+ /**
431
+ * 获取peerConnection
432
+ */
433
+ getPeerConnection(): RTCPeerConnection;
434
+ /**
435
+ * 获取senders
436
+ */
437
+ getSenders(): [] | RTCRtpSender[];
438
+ /**
439
+ * 获取receivers
440
+ */
441
+ getReceivers(): [] | RTCRtpReceiver[];
442
+ /**
443
+ * 获取流对象
444
+ */
445
+ getStream(): MediaStream;
446
+ /**
447
+ * 拨出实例
448
+ */
449
+ getCurrentInviter(): Inviter;
450
+ /**
451
+ * 接听实例
452
+ */
453
+ getCurrentInvitation(): Invitation;
454
+ }
455
+
456
+ /**
457
+ * 默认连接配置
458
+ */
459
+ declare const userAgentDefault: Partial<UserAgentOptions$1>;
460
+ declare const userAgentStatus: UserAgentStatus;
461
+
462
+ /**
463
+ * 获取音频标签
464
+ * @param id Element id
465
+ */
466
+ declare function getMedia(id: string): HTMLAudioElement | undefined;
467
+ /**
468
+ * 释放 mediaStream
469
+ * @param stream
470
+ */
471
+ declare function stopStreamTracks(stream: any): void;
472
+ /**
473
+ * 获取设备权限
474
+ * @param constraints
475
+ */
476
+ declare function getDevicePermission(constraints: any): Promise<boolean>;
477
+ /**
478
+ * 请求设备权限
479
+ */
480
+ declare function requestMicroPhonePermission(): Promise<boolean>;
481
+ /**
482
+ * 来电振铃
483
+ * @param id Element id
484
+ */
485
+ declare function playMedia(id: string): void;
486
+ /**
487
+ * 关闭振铃
488
+ * @param id Element id
489
+ */
490
+ declare function pauseMedia(id: string): void;
491
+ /**
492
+ * 挂断通话
493
+ * @param id Element id
494
+ */
495
+ declare function cleanupMedia(id: string): void;
496
+ /**
497
+ * 获取时间字符串
498
+ * @param { Date }} time 需要转换的时间对象
499
+ * @return xx:xx:xx
500
+ */
501
+ declare const getTimes: (time: Date) => string;
502
+ /**
503
+ * 获取0点时间
504
+ * @return Date
505
+ */
506
+ declare const getZeorTime: () => Date;
507
+ /**
508
+ * 加1s时间
509
+ * @param { Date } date 需要操作的时间对象
510
+ * @return Date
511
+ */
512
+ declare const accumulateSec: (date: Date) => Date;
513
+ /**
514
+ * 计时器
515
+ * @param { Function } refresh 回调
516
+ * @return Function 销毁计时器
517
+ */
518
+ declare function accumulationTimer(refresh: Function): () => void;
519
+
520
+ /**
521
+ * 代理实例工厂
522
+ */
523
+ declare class UserAgentFactory {
524
+ #private;
525
+ static getUserAgentManager(options?: Partial<UserAgentOptions>): UserAgentManager;
526
+ static hasUserAgentManager(): boolean;
527
+ static newUserAgentManager(options?: Partial<UserAgentOptions>): UserAgentManager;
528
+ static dispose(): void;
529
+ }
530
+
531
+ export { HandUpInviteOption, InviterInviteOptionsExtend as InviterInviteOptions, PrepareUserAgentOptions, RegisterOptions, SessionInfoOptionsExtend as SessionInfoOptions, TransportOptions, UserAgentDelegateKey, UserAgentFactory, UserAgentManager, UserAgentOptions, UserAgentStatus, UserAgentStatusKey, accumulateSec, accumulationTimer, cleanupMedia, getDevicePermission, getMedia, getTimes, getZeorTime, pauseMedia, playMedia, requestMicroPhonePermission, stopStreamTracks, userAgentDefault, userAgentStatus };
@@ -0,0 +1 @@
1
+ "use strict";var e,t,n=require("@babel/runtime-corejs3/helpers/esm/classCallCheck"),i=require("@babel/runtime-corejs3/helpers/esm/createClass"),r=require("sip.js"),s=require("sip.js/lib/platform/web/index.js"),o=require("on-change"),a=require("@babel/runtime-corejs3/helpers/esm/typeof"),c=require("@babel/runtime-corejs3/regenerator"),u=require("@babel/runtime-corejs3/core-js/json/stringify"),l=require("@babel/runtime-corejs3/core-js/object/define-property"),f=require("@babel/runtime-corejs3/core-js/date/now"),h=require("@babel/runtime-corejs3/core-js/instance/for-each"),d=require("@babel/runtime-corejs3/core-js/set-timeout"),p=require("@babel/runtime-corejs3/core-js/set-interval"),v=require("@babel/runtime-corejs3/core-js/promise"),g=require("@babel/runtime-corejs3/core-js/object/assign"),m=require("@babel/runtime-corejs3/core-js/instance/concat"),w=require("@babel/runtime-corejs3/core-js/instance/map"),b=require("@babel/runtime-corejs3/core-js/instance/index-of"),k=require("@babel/runtime-corejs3/core-js/instance/filter"),x=require("@babel/runtime-corejs3/core-js/weak-map"),y=require("@babel/runtime-corejs3/core-js/weak-set"),S=require("@babel/runtime-corejs3/core-js/object/keys"),A=require("@babel/runtime-corejs3/core-js/instance/pad-start"),I=require("@babel/runtime-corejs3/core-js/instance/slice"),T=require("crypto-js"),j=require("@fingerprintjs/fingerprintjs");function C(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function O(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function q(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;var D,E,R,P,N=m(e="sip:".concat("","@")).call(e,""),M=m(t="".concat("","://")).call(t,""),U={authorizationPassword:"",authorizationUsername:"",viaHost:"",uri:r.UserAgent.makeURI(N),logLevel:"error",transportOptions:{server:M},contactName:""},H={connectStatus:!1,registerStatus:!1,invitatingStatus:!1,incomingStatus:!1,answerStatus:!1,reconnectStatus:!1};function z(e){return document.getElementById(e)}function L(e){if(e&&e.getTracks)try{var t=e.getTracks();h(t).call(t,(function(e){try{e.stop()}catch(e){}}))}catch(e){}}function X(e){return navigator.mediaDevices.getUserMedia(e).then((function(e){return e?(L(e),!0):v.reject(new Error("EmptyStreamError"))})).catch((function(e){return(!e||"NotAllowedError"!==e.name)&&v.reject(e)}))}!function(e){e.NO="0",e.YES="1"}(D||(D={})),function(e){e.NO="0",e.YES="1"}(E||(E={})),function(e){e.MULTI_AI="1",e.MULTI_VOICE_NOTIFY="2",e.MULTI_PRETEST="3",e.LABOUR="4",e.AI="5",e.NEW_VOICE_NOTIFY="6"}(R||(R={})),function(e){e.DIRECT_ANSWER="1",e.LISTEN_FIRST_AND_THEN_ANSWER_MANUALLY="2"}(P||(P={}));var F,G,_,B,Y,V,J,W,Z,K,$,Q,ee,te,ne,ie,re,se,oe,ae,ce,ue,le,fe,he,de,pe,ve,ge,me,we,be,ke,xe,ye,Se,Ae,Ie,Te,je,Ce,Oe,qe,De,Ee,Re,Pe,Ne,Me,Ue,He,ze,Le,Xe,Fe,Ge,_e,Be,Ye,Ve,Je,We,Ze,Ke,$e,Qe,et,tt,nt,it,rt,st,ot,at,ct,ut,lt,ft,ht,dt,pt,vt,gt,mt,wt,bt,kt,xt,yt,St,At,It,Tt,jt,Ct,Ot,qt,Dt,Et,Rt,Pt,Nt,Mt,Ut,Ht,zt,Lt,Xt,Ft,Gt,_t,Bt,Yt,Vt,Jt,Wt=function(e){var t,n,i;return A(t=e.getHours().toString()).call(t,2,"0")+":"+A(n=e.getMinutes().toString()).call(n,2,"0")+":"+A(i=e.getSeconds().toString()).call(i,2,"0")},Zt=function(){return new Date(new Date((new Date).toLocaleDateString()).getTime())},Kt=function(e){return new Date(e.setSeconds(e.getSeconds()+1))};function $t(e,t,n){var i=window.XMLHttpRequest?new window.XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):void 0;i||t(new Error("Your Browser does not support ajax")),i.onreadystatechange=function(){if(4==i.readyState){var n=i.response||i.responseText;if(200==i.status){var r=i.getResponseHeader("Content-Type");-1!=b(r).call(r,"json")?e(JSON.parse(i.responseText)):-1!=b(r).call(r,"xml")?e(i.responseXML):e(i.responseText)}else t(n)}};var r=n.url,s=n.data,o=n.type,a=n.contentType,c=o||"POST",l=r,f=null;return s&&("GET"===c?l=l+"?"+function(e){var t=[];for(var n in e)t.push(n+"="+e[n]);return t.join("&")}(s):"POST"===c&&(f=u(s))),i.open(c,l,!0),{xhr:i,ajaxData:f,contentType:a}}var Qt,en,tn=function(){function e(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(n(this,e),F.add(this),G.set(this,void 0),_.set(this,void 0),B.set(this,void 0),Y.set(this,void 0),V.set(this,void 0),J.set(this,[]),W.set(this,[]),Z.set(this,{}),K.set(this,void 0),$.set(this,void 0),Q.set(this,new MediaStream),ee.set(this,JSON.parse(u(H))),te.set(this,0),ne.set(this,void 0),ie.set(this,void 0),re.set(this,void 0),l(this,"token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),se.set(this,void 0),oe.set(this,48e4),ae.set(this,12e6),ce.set(this,{}),ue.set(this,void 0),le.set(this,void 0),fe.set(this,void 0),he.set(this,(function(e){})),de.set(this,(function(e){})),pe.set(this,(function(e){})),ve.set(this,(function(e){})),ge.set(this,(function(e){return C(t,void 0,void 0,c.mark((function t(){var n,i,r;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,ne,"f")||!O(this,ie,"f")){t.next=9;break}if(!(f()-O(this,ie,"f")>e)){t.next=9;break}return t.next=4,O(this,we,"f").call(this);case 4:n=t.sent,i=n.sign,r=n.timestamp,q(this,ne,null!=i?i:O(this,ne,"f"),"f"),q(this,ie,null!=r?r:O(this,ie,"f"),"f");case 9:case"end":return t.stop()}}),t,this)})))})),me.set(this,(function(e){return C(t,void 0,void 0,c.mark((function t(){var n,i,r,s,o;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,se,"f")){t.next=19;break}if(!(f()-O(this,se,"f")>e)){t.next=19;break}if(!O(this,re,"f")){t.next=12;break}return t.next=5,O(this,be,"f").call(this);case 5:n=t.sent,i=n.token,r=n.tokenTimestamp,q(this,re,null!=i?i:O(this,re,"f"),"f"),q(this,se,null!=r?r:f(),"f"),t.next=19;break;case 12:if(!this.token){t.next=19;break}return t.next=15,this.getGatewayAccessToken({corpId:O(this,Fe,"f"),sid:O(this,Be,"f"),secret:O(this,Ge,"f"),seatOnline:!1});case 15:s=t.sent,o=s.token,this.token=o,q(this,se,f(),"f");case 19:case"end":return t.stop()}}),t,this)})))})),we.set(this,(function(){})),be.set(this,(function(){})),ke.set(this,(function(e){})),xe.set(this,(function(e){})),ye.set(this,void 0),Se.set(this,void 0),l(this,"networkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:"0.00Mb/s"}),l(this,"networkDelay",{enumerable:!0,configurable:!0,writable:!0,value:"0ms"}),l(this,"onLine",{enumerable:!0,configurable:!0,writable:!0,value:navigator.onLine}),l(this,"testspeeding",{enumerable:!0,configurable:!0,writable:!0,value:!1}),l(this,"goodNetworkSpeed",{enumerable:!0,configurable:!0,writable:!0,value:function(){return 1e3*Number(t.networkSpeed.replace("Mb/s",""))>=30}}),l(this,"goodNetworkDelay",{enumerable:!0,configurable:!0,writable:!0,value:function(){return Number(t.networkDelay.replace("ms",""))<=500&&"0ms"!==t.networkDelay}}),l(this,"authorizedMicrophonePermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),l(this,"authorizedNotificationPermissions",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Ae.set(this,100),Ie.set(this,3),Te.set(this,8),je.set(this,3),Ce.set(this,0),Oe.set(this,!1),qe.set(this,void 0),De.set(this,3),Ee.set(this,3),Re.set(this,0),Pe.set(this,0),Ne.set(this,0),Me.set(this,!1),Ue.set(this,!1),He.set(this,!1),ze.set(this,void 0),Le.set(this,void 0),Xe.set(this,void 0),Fe.set(this,void 0),Ge.set(this,void 0),_e.set(this,void 0),Be.set(this,void 0),Ye.set(this,void 0),Ve.set(this,void 0),Je.set(this,void 0),We.set(this,void 0),Ze.set(this,(function(e){O(t,F,"m",_t).call(t)})),Ke.set(this,(function(){})),$e.set(this,{}),Qe.set(this,!1),et.set(this,!0),l(this,"ifAutoAnswer",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(O(t,$e,"f").autoAnswer)===D.YES}}),l(this,"notNeedSendStarDtmf",{enumerable:!0,configurable:!0,writable:!0,value:function(){return String(O(t,$e,"f").afterTransferLabour)===P.DIRECT_ANSWER}}),tt.set(this,(function(){if(O(t,et,"f")){var e;O(t,nt,"f").call(t);var n=new(window.AudioContext||window.webkitAudioContext);q(t,le,n.createScriptProcessor(2048,1,1),"f"),O(t,le,"f").onaudioprocess=function(e){for(var n=e.inputBuffer.getChannelData(0),i=0,r=0;r<n.length;++r)i+=n[r]*n[r];q(t,te,Number(Math.sqrt(i/n.length).toFixed(2)),"f"),O(t,he,"f").call(t,O(t,te,"f"))},q(t,fe,new MediaStream,"f"),h(e=t.getSenders()).call(e,(function(e){e.track&&O(t,fe,"f").addTrack(e.track)})),q(t,ue,n.createMediaStreamSource(O(t,fe,"f")),"f"),O(t,ue,"f").connect(O(t,le,"f")),O(t,le,"f").connect(n.destination)}})),nt.set(this,(function(){if(O(t,et,"f")){if(O(t,ue,"f"))try{O(t,ue,"f").disconnect()}catch(e){console.log(e)}if(O(t,le,"f"))try{O(t,le,"f").disconnect()}catch(e){console.log(e)}if(O(t,fe,"f"))try{var e;h(e=O(t,fe,"f").getTracks()).call(e,(function(e){e.stop()}))}catch(e){console.log(e)}}q(t,ue,void 0,"f"),q(t,le,void 0,"f"),q(t,fe,void 0,"f"),q(t,te,0,"f"),O(t,he,"f").call(t,O(t,te,"f"))})),l(this,"disposeSoftphoneEnvRequirementCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){O(t,it,"f").call(t),window.removeEventListener("offline",O(t,ot,"f")),window.removeEventListener("online",O(t,st,"f")),window.removeEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)}}),it.set(this,(function(){clearInterval(O(t,ye,"f")),q(t,ye,void 0,"f"),clearTimeout(O(t,Se,"f")),q(t,Se,void 0,"f"),t.testspeeding=!1})),l(this,"softphoneEnvCheck",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(t,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding||(O(this,rt,"f").call(this),this.oneRoundOfTesting());case 1:case"end":return e.stop()}}),e,this)})))}}),rt.set(this,(function(){window.addEventListener("offline",O(t,ot,"f")),window.addEventListener("online",O(t,st,"f")),window.addEventListener("unload",t.disposeSoftphoneEnvRequirementCheck)})),l(this,"oneRoundOfTesting",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(t,void 0,void 0,c.mark((function e(){var t=this;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.testspeeding=!0,this.detectNavigatorPermissions(),this.onLine?(O(this,at,"f").call(this,this),q(this,Se,d((function(){t.testspeeding=!1,t.disposeSoftphoneEnvRequirementCheck()}),4e3),"f")):this.testspeeding=!1;case 3:case"end":return e.stop()}}),e,this)})))}}),st.set(this,(function(){t.onLine=!0,t.oneRoundOfTesting()})),ot.set(this,(function(){t.onLine=!1,t.networkSpeed="0.00Mb/s",t.networkDelay="0ms",O(t,xe,"f").call(t,{networkSpeed:t.networkSpeed,networkDelay:t.networkDelay,authorizedMicrophonePermissions:t.authorizedMicrophonePermissions,authorizedNotificationPermissions:t.authorizedNotificationPermissions}),O(t,it,"f").call(t)})),at.set(this,(function(e){return C(t,void 0,void 0,c.mark((function t(){var n,i,r=this;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e||this,clearInterval(O(n,ye,"f")),q(n,ye,void 0,"f"),i=function(){return C(r,void 0,void 0,c.mark((function e(){var t;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.onLine){e.next=15;break}return e.prev=1,e.next=4,O(n,ct,"f").call(n);case 4:t=e.sent,n.networkSpeed=t.networkSpeed,n.networkDelay=t.networkDelay,e.next=13;break;case 9:e.prev=9,e.t0=e.catch(1),n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 13:e.next=17;break;case 15:n.networkSpeed="0.00Mb/s",n.networkDelay="0ms";case 17:O(this,xe,"f").call(this,{networkSpeed:this.networkSpeed,networkDelay:this.networkDelay,authorizedMicrophonePermissions:this.authorizedMicrophonePermissions,authorizedNotificationPermissions:this.authorizedNotificationPermissions}),O(this,Se,"f")||(this.testspeeding=!1,this.disposeSoftphoneEnvRequirementCheck());case 19:case"end":return e.stop()}}),e,this,[[1,9]])})))},t.next=6,i();case 6:O(this,Se,"f")&&q(n,ye,p((function(){return C(this,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i();case 2:case"end":return e.stop()}}),e)})))}),1e3),"f");case 7:case"end":return t.stop()}}),t,this)})))})),ct.set(this,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return C(t,void 0,void 0,c.mark((function t(){var r,s;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=[],s=0;s<i;s++)r.push(O(this,ut,"f").call(this,e+"?d="+f()+s,n));return t.abrupt("return",v.all(r).then((function(e){var t=0,n=0;return h(e).call(e,(function(e){t+=Number(e[0]),n+=Number(e[1])})),{networkDelay:(n/i).toFixed(2)+"ms",networkSpeed:(t/i).toFixed(2)+"Mb/s"}})));case 3:case"end":return t.stop()}}),t,this)})))})),ut.set(this,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://seat.94ai.com/favicon.png?d="+f(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:63491;return new v((function(n,i){var r=document.createElement("img");r.start=window.performance.now(),r.onload=function(){var e=window.performance.now()-r.start;n([(1e3*t/(1048576*e)).toFixed(2),e])},r.onerror=function(e){i(e)},r.src=e})).catch((function(e){throw e}))})),l(this,"openApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return new v((function(n,i){return C(t,void 0,void 0,c.mark((function t(){var r,s,o,a,u,l,f;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=$t(n,i,e),s=r.xhr,o=r.ajaxData,a=r.contentType,t.next=3,this.getOpenApiSign();case 3:return u=t.sent,l=u.timestamp,f=u.sign,s.setRequestHeader("appKey",O(this,Fe,"f")),s.setRequestHeader("timestamp",String(l)),s.setRequestHeader("sign",f),s.setRequestHeader("Content-type",a||"application/json"),t.next=12,O(this,pe,"f").call(this,s);case 12:s.send(o);case 13:case"end":return t.stop()}}),t,this)})))}))}}),l(this,"requestGateway",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.gatewayApiAjax(g(g({},e),{url:t.getGateway()+e.url}),n)}}),l(this,"gatewayApiAjax",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new v((function(i,r){return C(t,void 0,void 0,c.mark((function t(){var s,o,a,u,l;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=$t(i,r,e),o=s.xhr,a=s.ajaxData,u=s.contentType,!n){t.next=8;break}return t.next=4,this.getGatewayToken();case 4:l=t.sent,o.setRequestHeader("x-token",l),o.setRequestHeader("seatsToken",l),o.setRequestHeader("x-authority-token",l);case 8:return o.setRequestHeader("x-app-code",3),o.setRequestHeader("content-type",u||"application/json"),t.next=12,O(this,ve,"f").call(this,o);case 12:o.send(a);case 13:case"end":return t.stop()}}),t,this)})))}))}}),l(this,"requestOpenApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.openApiAjax(g(g({},e),{url:t.getOpenApi()+e.url}))}}),l(this,"getDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:function(){return C(t,void 0,void 0,c.mark((function e(){var t,n;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,We,"f")){e.next=2;break}return e.abrupt("return",O(this,We,"f"));case 2:return e.next=4,j.load();case 4:return t=e.sent,e.next=7,t.get();case 7:return n=e.sent,q(this,We,n.visitorId,"f"),e.abrupt("return",O(this,We,"f"));case 10:case"end":return e.stop()}}),e,this)})))}}),gt.set(this,(function(){return C(t,void 0,void 0,c.mark((function e(){var t,n,i,s;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,F,"m",vt).call(this)||O(this,Z,"f").authorizationUsername&&O(this,Z,"f").uri&&O(this,Z,"f").authorizationPassword&&O(this,Z,"f").transportOptions.server){e.next=15;break}return e.next=3,this.getAgentInfo();case 3:if(200!=(t=e.sent).code){e.next=14;break}s=t.data,O(this,Z,"f").authorizationUsername=s.agentExtension,O(this,Z,"f").authorizationPassword=s.extensionPwd,O(this,Z,"f").uri=r.UserAgent.makeURI(m(n="sip:".concat(s.agentExtension,"@")).call(n,s.wsRegisterAddress)),O(this,Z,"f").transportOptions.server=m(i="".concat(s.wsProtocol,"://")).call(i,s.wsRegisterAddress),q(this,Be,s.agentId,"f"),q(this,_e,s.agentTag,"f"),e.next=15;break;case 14:throw new Error(t);case 15:case"end":return e.stop()}}),e,this)})))})),mt.set(this,(function(){return C(t,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(O(this,Z,"f").viaHost){e.next=6;break}return e.t0="",e.next=4,this.getDeviceId();case 4:e.t1=e.sent,O(this,Z,"f").viaHost=m(e.t0).call(e.t0,e.t1,".sip");case 6:case"end":return e.stop()}}),e,this)})))})),wt.set(this,(function(e){var n,i,r,s,o,a,c,u,l,f,h,d,p,v,g,m,b,k;O(t,$e,"f").popWindow=null===(s=e["X-Popwindow"])||void 0===s?void 0:s[0].raw,O(t,$e,"f").afterTransferLabour=null===(o=e["X-Aftertransferlabour"])||void 0===o?void 0:o[0].raw,O(t,$e,"f").callId=null===(a=e["X-94callid"])||void 0===a?void 0:a[0].raw,O(t,$e,"f").cid=null===(c=e["X-Cid"])||void 0===c?void 0:c[0].raw,O(t,$e,"f").numberId=null===(u=e["X-Numberid"])||void 0===u?void 0:u[0].raw,O(t,$e,"f").taskId=null===(l=e["X-Taskid"])||void 0===l?void 0:l[0].raw,O(t,$e,"f").voiceType=null===(f=e["X-Voicetype"])||void 0===f?void 0:f[0].raw,O(t,$e,"f").processTime=null===(h=e["X-Processtime"])||void 0===h?void 0:h[0].raw,O(t,$e,"f").userPhone=null===(d=e["X-Userphone"])||void 0===d?void 0:d[0].raw,O(t,$e,"f").autoAnswer=null===(p=e["X-94autoanswer"])||void 0===p?void 0:p[0].raw,O(t,$e,"f").nodeTitle=null===(v=e["X-Nodetitle"])||void 0===v?void 0:w(n=v[0].raw.split("-")).call(n,(function(e){return String.fromCharCode(e)})).join(""),O(t,$e,"f").taskName=null===(g=e["X-Taskname"])||void 0===g?void 0:w(i=g[0].raw.split("-")).call(i,(function(e){return String.fromCharCode(e)})).join(""),O(t,$e,"f").templateTitle=null===(m=e["X-Templatetitle"])||void 0===m?void 0:w(r=m[0].raw.split("-")).call(r,(function(e){return String.fromCharCode(e)})).join(""),O(t,$e,"f").phoneNumber=(null===(b=e["X-Phonenumber"])||void 0===b?void 0:b[0].raw)||(null===(k=e.From)||void 0===k?void 0:k[0].parsed.uri.normal.user)})),Et.set(this,(function(e){switch(e){case r.SessionState.Initial:case r.SessionState.Establishing:break;case r.SessionState.Established:O(t,F,"m",Dt).call(t);break;case r.SessionState.Terminating:case r.SessionState.Terminated:var n=d((function(){clearTimeout(n),n=void 0,O(t,ee,"f").incomingStatus=!1}),10);O(t,nt,"f").call(t);break;default:throw new Error("Unknown session state.")}})),Pt.set(this,(function(e,n,i){O(t,Te,"f")&&(q(t,Oe,!1,"f"),O(t,ee,"f").reconnectStatus=!1,O(t,Ue,"f")&&(q(t,Ue,!1,"f"),O(t,Ut,"f").call(t,e,n,i)))})),Nt.set(this,(function(){return C(t,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,Te,"f")){e.next=15;break}return q(this,Oe,!0,"f"),q(this,Ue,!1,"f"),e.next=5,this.getUserAgent().transport.disconnect().catch((function(e){return console.error(e)}));case 5:return console.log("sip transport disconnect"),e.prev=6,e.next=9,O(this,F,"m",Rt).call(this);case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(6);case 13:O(this,Ht,"f").call(this),O(this,F,"m",_t).call(this);case 15:case"end":return e.stop()}}),e,this,[[6,11]])})))})),Mt.set(this,(function(){if(O(t,Te,"f")){var e=O(t,Z,"f").uri.clone(),n=O(t,Z,"f").uri.clone(),i=O(t,Z,"f").uri.clone();i.user=void 0,O(t,Ut,"f").call(t,i,e,n)}})),Ut.set(this,(function(e,n,i){if(O(t,Te,"f")){if(O(t,Ue,"f"))return;q(t,Ue,!0,"f"),q(t,Le,d((function(){O(t,F,"m",Ft).call(t);var r=t.getUserAgent().userAgentCore,s=r.makeOutgoingRequestMessage("OPTIONS",e,n,i,{});q(t,qe,r.request(s,{onAccept:function(){console.log("sip ping ok"),q(t,Ce,0,"f"),q(t,qe,void 0,"f"),O(t,Pt,"f").call(t,e,n,i)},onReject:function(r){var s;if(q(t,qe,void 0,"f"),408===r.message.statusCode||503===r.message.statusCode)if(console.log("sip ping error with code "+r.message.statusCode),O(t,je,"f")>0&&O(t,Ce,"f")>=O(t,je,"f"))console.log("sip maximum ping attempts reached"),O(t,Nt,"f").call(t);else{var o,a;if(O(t,Ce,"f")>0)console.log(m(a="sip ping retry ".concat(O(t,Ce,"f")," of ")).call(a,O(t,je,"f")," fail"));q(t,Ce,(s=O(t,Ce,"f"),++s),"f"),console.log(m(o="sip ping retry ".concat(O(t,Ce,"f")," of ")).call(o,O(t,je,"f"))),O(t,Pt,"f").call(t,e,n,i)}else q(t,Ce,0,"f"),O(t,Pt,"f").call(t,e,n,i)}}),"f")}),1e3*O(t,Te,"f")),"f")}})),Ht.set(this,(function(){if(O(t,Te,"f")){if(q(t,Ue,!1,"f"),q(t,Oe,!1,"f"),O(t,qe,"f")){try{O(t,qe,"f").dispose()}catch(e){}q(t,qe,void 0,"f")}O(t,Le,"f")&&O(t,F,"m",Ft).call(t)}})),Gt.set(this,(function(){if(O(t,De,"f")){if(O(t,He,"f"))return;q(t,He,!0,"f"),O(t,ee,"f").reconnectStatus=!0,q(t,Xe,d((function(){return C(t,void 0,void 0,c.mark((function e(){var t=this;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,O(this,F,"m",Lt).call(this),0===O(this,Re,"f")&&console.log("sip reconnect success then register start"),e.next=5,O(this,B,"f").register({requestDelegate:{onAccept:function(e){console.log("sip reconnect success and register ok"),q(t,Re,0,"f"),q(t,He,!1,"f"),O(t,ee,"f").registerStatus=!0,O(t,ee,"f").reconnectStatus=!1,O(t,Mt,"f").call(t)},onReject:function(e){return C(t,void 0,void 0,c.mark((function t(){var n,i;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.log("sip reconnect success but register fail with code "+e.message.statusCode),q(this,He,!1,"f"),!(O(this,Ee,"f")<=O(this,Re,"f"))){t.next=10;break}return console.log("sip maximum register attempts reached"),q(this,Re,0,"f"),t.next=7,this.getUserAgent().transport.disconnect().catch((function(e){return console.error(e)}));case 7:O(this,F,"m",_t).call(this),t.next=13;break;case 10:q(this,Re,(n=O(this,Re,"f"),++n),"f"),console.log(m(i="sip reconnect success and register retry ".concat(O(this,Re,"f")," of ")).call(i,O(this,Ee,"f"))),O(this,Gt,"f").call(this);case 13:case"end":return t.stop()}}),t,this)})))}},requestOptions:{extraHeaders:O(this,G,"f")}});case 5:e.next=12;break;case 7:e.prev=7,e.t0=e.catch(0),console.log("sip reconnect then registerer register error",e.t0),q(this,Re,0,"f"),q(this,He,!1,"f");case 12:case"end":return e.stop()}}),e,this,[[0,7]])})))}),1e3*O(t,De,"f")),"f")}})),"object"!==a(i))throw new Error("userAgentOption must be plain object");O(this,F,"m",dt).call(this,i),O(this,F,"m",ht).call(this,i),O(this,F,"m",pt).call(this,i),O(this,F,"m",kt).call(this,i),O(this,F,"m",ft).call(this,i),O(this,F,"m",lt).call(this,i),q(this,Z,O(this,F,"m",yt).call(this,i),"f")}return i(e,[{key:"volumeValue",get:function(){return O(this,te,"f")}},{key:"businessAttribute",get:function(){return O(this,$e,"f")}},{key:"getFastOutboundCall",value:function(){return O(this,$e,"f").voiceType===R.LABOUR}},{key:"getSitOutboundCall",value:function(){return O(this,$e,"f").voiceType===R.AI}},{key:"detectNavigatorPermissions",value:function(){var e,t=this;-1===b(e=navigator.userAgent).call(e,"Firefox")?navigator.permissions.query({name:"microphone"}).then((function(e){"granted"===e.state?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1})).catch((function(e){console.log("Got error :",e),t.authorizedMicrophonePermissions=!1})):navigator.mediaDevices.enumerateDevices().then((function(e){""!==k(e).call(e,(function(e){return"audioinput"===e.kind}))[0].label?t.authorizedMicrophonePermissions=!0:t.authorizedMicrophonePermissions=!1})),navigator.permissions.query({name:"notifications"}).then((function(e){"granted"===e.state?t.authorizedNotificationPermissions=!0:t.authorizedNotificationPermissions=!1})).catch((function(e){console.log("Got error :",e),t.authorizedNotificationPermissions=!1}))}},{key:"getGateway",value:function(){return"1"===O(this,Je,"f")?"https://gateway.sg.94ai.com":"https://gateway.94ai.com"}},{key:"getGatewayToken",value:function(){return C(this,void 0,void 0,c.mark((function e(){var t,n;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O(this,me,"f").call(this,O(this,ae,"f"));case 2:if(!O(this,re,"f")){e.next=4;break}return e.abrupt("return",O(this,re,"f"));case 4:if(this.token){e.next=13;break}return e.next=7,O(this,gt,"f").call(this);case 7:return e.next=9,this.getGatewayAccessToken({corpId:O(this,Fe,"f"),sid:O(this,Be,"f"),secret:O(this,Ge,"f"),seatOnline:!1});case 9:t=e.sent,n=t.token,this.token=n,q(this,se,f(),"f");case 13:return e.abrupt("return",this.token);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getGatewayAccessToken",value:function(e){return this.requestGateway({url:"/authority/accessToken/openApi",data:e},!1)}},{key:"getCallNumberDetail",value:function(e){return this.requestGateway({url:"/task-aggre/callCenterNumber/get",data:e})}},{key:"getCallNumberChats",value:function(e){return this.requestGateway({url:"/dialogue-aggre/call-center-number/chat/list",data:e})}},{key:"getCallInfo",value:function(){return C(this,void 0,void 0,c.mark((function e(){var t,n,i=this;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=g({},O(this,$e,"f")),n=function(){return C(i,void 0,void 0,c.mark((function e(){var n,i,r,s,o,a,u,l,f,h,d,p,v,g,b,k,x,y,S,A;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.numberId||!t.taskId){e.next=57;break}return n={},e.prev=2,e.next=5,this.getCallNumberDetail({id:t.numberId,taskId:t.taskId});case 5:if(200===(n=e.sent).code){e.next=11;break}return console.error(n.message),t.stop=!0,O(this,ke,"f").call(this,new Error(n.message)),e.abrupt("return");case 11:e.next=20;break;case 13:return e.prev=13,e.t0=e.catch(2),s=m(i=m(r="当前会话callid:".concat(t.callId,",根据numberId:")).call(r,t.numberId,",taskId:")).call(i,t.taskId,":查询坐席接听状态异常"),console.error(s),t.stop=!0,O(this,ke,"f").call(this,new Error(n.message)),e.abrupt("return");case 20:if(o=n.data,a=o.callType,u=o.newIntentTag,l=o.intentTag,f=o.number,h=o.numberMd5,d=o.sid,p=o.config,v=o.tag,10!==o.state){e.next=25;break}return console.log("当前会话callid:".concat(t.callId,"已结束")),t.stop=!0,e.abrupt("return");case 25:if(t.callType||(t.callType=a),t.intentTag=u||l,t.number||(t.number=f),t.numberMD5||(t.numberMD5=h),t.agentId||(t.agentId=d),t.tag||(t.tag=v),t.templateId||p&&"string"==typeof p&&(g=JSON.parse(p))&&g.templateId&&(t.templateId=g.templateId),!t.callId){e.next=54;break}return k={},e.prev=34,e.next=37,this.getCallNumberChats({callId:t.callId,taskId:t.taskId});case 37:if(200===(k=e.sent).code){e.next=43;break}return console.error(k.message),t.stop=!0,O(this,ke,"f").call(this,new Error(k.message)),e.abrupt("return");case 43:e.next=52;break;case 45:return e.prev=45,e.t1=e.catch(34),y=m(x="当前会话根据callId:".concat(t.callId,",taskId:")).call(x,t.taskId,":查询会话对话记录异常"),console.error(y),t.stop=!0,O(this,ke,"f").call(this,new Error(y)),e.abrupt("return");case 52:t.chats=w(b=k.data).call(b,(function(e){return e.matchinfo&&(e.matchinfo=JSON.parse(e.matchinfo)),e})),O(this,ce,"f")[t.callId]=t;case 54:try{O(this,de,"f").call(this,O(this,ce,"f")[t.callId])}catch(e){console.log(e)}e.next=60;break;case 57:t.stop=!0,t.taskId||(S="当前会话callid:".concat(t.callId,"的taskId不存在,无法查询通话记录"),console.error(S),O(this,ke,"f").call(this,new Error(S))),t.numberId||(A="当前会话callid:".concat(t.callId,"的numberId不存在,无法查询通话记录"),console.error(A),O(this,ke,"f").call(this,new Error(A)));case 60:case"end":return e.stop()}}),e,this,[[2,13],[34,45]])})))},e.prev=2;case 3:if(!t.stop){e.next=6;break}return e.abrupt("break",14);case 6:return e.next=8,n();case 8:if(!t.stop){e.next=10;break}return e.abrupt("break",14);case 10:return e.next=12,new v((function(e){var t=d((function(){return C(i,void 0,void 0,c.mark((function n(){return c.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:clearTimeout(t),t=void 0,e(!0);case 3:case"end":return n.stop()}}),n)})))}),3e3)}));case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),O(this,ke,"f").call(this,e.t0);case 19:case"end":return e.stop()}}),e,this,[[2,16]])})))}},{key:"refreshCallChatInfo",value:function(){return C(this,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(O(this,$e,"f").numberId&&O(this,$e,"f").callId&&O(this,$e,"f").taskId&&O(this,Qe,"f"))){e.next=3;break}return e.next=3,this.getCallInfo();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getOpenApi",value:function(){return O(this,Ye,"f")?function(e){if(!e)return!1;var t=/^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;return!!/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||("//"===I(e).call(e,0,2)?t.test(I(e).call(e,2,e.length)):"http://"===I(e).call(e,0,7)?t.test(I(e).call(e,7,e.length)):"https://"===I(e).call(e,0,8)?t.test(I(e).call(e,8,e.length)):t.test(e))}(O(this,Ye,"f"))?O(this,Ye,"f"):"1"===O(this,Je,"f")?"1"===O(this,Ve,"f")?"https://seatsg.94ai.com/sgopenapi":"https://seatsg.94ai.com/openapi":"1"===O(this,Ve,"f")?"https://seat.94ai.com/sgopenapi":"https://seat.94ai.com/openapi":"https://seat.94ai.com/openapi"}},{key:"getAgentInfo",value:function(){return this.requestOpenApi({url:"/v1/agent/getAgent",data:{agentTag:O(this,_e,"f"),agentId:O(this,Be,"f")}})}},{key:"getOpenApiSign",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f(),i=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;return C(this,void 0,void 0,c.mark((function s(){return c.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,O(this,ge,"f").call(this,O(this,oe,"f"));case 2:return s.abrupt("return",{sign:null!==(e=O(this,ne,"f"))&&void 0!==e?e:T.enc.Base64.stringify(T.HmacSHA1(i||O(this,Fe,"f")+n,r||O(this,Ge,"f"))),timestamp:null!==(t=O(this,ie,"f"))&&void 0!==t?t:n});case 3:case"end":return s.stop()}}),s,this)})))}},{key:"updateOpenApiAgentStatus",value:function(e){return this.requestOpenApi({url:"/v1/agent/updateAgentStatus",data:{agentTag:O(this,_e,"f"),agentId:O(this,Be,"f"),agentStatus:e}})}},{key:"importOpenApiAgentCustomer",value:function(e){return this.requestOpenApi({url:"/v1/task/importAgentCustomer",data:{agentTag:O(this,_e,"f"),agentId:O(this,Be,"f"),callType:1001,customers:[{number:e}]}})}},{key:"callNumber",value:function(e){return this.importOpenApiAgentCustomer(e)}},{key:"toggleNap",value:function(e){return e?this.updateOpenApiAgentStatus(3):this.updateOpenApiAgentStatus(1)}},{key:"refreshSign",value:function(e){q(this,ne,e,"f")}},{key:"prepareUserAgent",value:function(e,t){var n;return C(this,void 0,void 0,c.mark((function i(){var r,s,o,a,u,l,f,h,d,p,v;return c.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return s=(r=e||{}).refresh,o=r.registererOptions,a=r.registererRegisterOptions,u=r.extraHeaders,l=r.authorizationUsername,f=r.authorizationPassword,h=r.uri,d=r.contactName,p=r.transportOptions,i.next=3,this.dispose();case 3:return O(this,Z,"f").uri=null!=h?h:O(this,Z,"f").uri,O(this,Z,"f").authorizationUsername=null!=l?l:O(this,Z,"f").authorizationUsername,O(this,Z,"f").authorizationPassword=null!=f?f:O(this,Z,"f").authorizationPassword,O(this,Z,"f").contactName=null!==(n=null!=d?d:l)&&void 0!==n?n:O(this,Z,"f").contactName,p&&(O(this,Z,"f").transportOptions=g(g({},O(this,Z,"f").transportOptions),p)),i.prev=8,O(this,F,"m",dt).call(this,e),i.next=12,O(this,gt,"f").call(this);case 12:return i.next=14,O(this,mt,"f").call(this);case 14:return i.next=16,O(this,F,"m",Vt).call(this,{refresh:s});case 16:return t&&O(this,F,"m",Yt).call(this,t),i.next=19,O(this,F,"m",Jt).call(this,{registererOptions:o,registererRegisterOptions:a,extraHeaders:u});case 19:return v=i.sent,i.abrupt("return",v);case 23:return i.prev=23,i.t0=i.catch(8),i.next=27,this.dispose();case 27:throw i.t0;case 28:case"end":return i.stop()}}),i,this,[[8,23]])})))}},{key:"dispose",value:function(){return C(this,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,O(this,F,"m",It).call(this),O(this,F,"m",Ot).call(this),O(this,F,"m",qt).call(this),O(this,F,"m",Ct).call(this),O(this,F,"m",jt).call(this),O(this,F,"m",zt).call(this),e.next=9,O(this,F,"m",At).call(this);case 9:O(this,F,"m",Tt).call(this),O(this,nt,"f").call(this),q(this,$e,{},"f"),q(this,ce,{},"f"),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(0),O(this,F,"m",Tt).call(this),console.log("sip dispose with error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[0,15]])})))}},{key:"ignoreInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark((function t(){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return O(this,ee,"f").incomingStatus=!1,t.next=3,this.getCurrentInvitation().reject(e);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"acceptInvite",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark((function t(){var n=this;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,new v((function(t,i){C(n,void 0,void 0,c.mark((function n(){var r,s;return c.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=null==e?void 0:e.onAck,s=null==e?void 0:e.onAckTimeout,null==e||delete e.onAck,null==e||delete e.onAckTimeout,n.next=7,this.getCurrentInvitation().accept(g({sessionDescriptionHandlerOptions:{constraints:{audio:!0,video:!1}},onAck:function(e){t(e),null==r||r()},onAckTimeout:function(){null==s||s(),i(new Error("接听响应超时"))}},e||{}));case 7:n.next=12;break;case 9:n.prev=9,n.t0=n.catch(0),i(n.t0);case 12:case"end":return n.stop()}}),n,this,[[0,9]])})))}));case 3:O(this,ee,"f").incomingStatus&&(O(this,ee,"f").incomingStatus=!1,O(this,ee,"f").answerStatus=!0),t.next=10;break;case 6:throw t.prev=6,t.t0=t.catch(0),O(this,ee,"f").incomingStatus=!1,t.t0;case 10:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"hangUpInvite",value:function(e){return C(this,void 0,void 0,c.mark((function t(){var n,i,s,o,a,u=this;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=(n=e||{}).rejectOptions,s=n.byeOptions,o=n.extraHeaders,a=n.scoutResponse,t.abrupt("return",new v((function(e,t){return C(u,void 0,void 0,c.mark((function n(){var u,l,f,h,d,p,v,m,w;return c.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.prev=0,v=null===(u=(p=s||{}).requestDelegate)||void 0===u?void 0:u.onAccept,m=null===(l=p.requestDelegate)||void 0===l?void 0:l.onReject,null===(f=p.requestDelegate)||void 0===f||delete f.onAccept,null===(h=p.requestDelegate)||void 0===h||delete h.onReject,w=O(this,F,"m",xt).call(this,{onAccept:function(t){console.log("sip bye success"),e(t),null==v||v(t)},onReject:function(e){null==m||m(e),t(new Error("sip bye fail with code "+e.message.statusCode))}},p.requestDelegate),delete p.requestDelegate,n.t0=null===(d=O(this,K,"f"))||void 0===d?void 0:d.state,n.next=n.t0===r.SessionState.Initial||n.t0===r.SessionState.Establishing?11:n.t0===r.SessionState.Established?15:n.t0===r.SessionState.Terminating||n.t0===r.SessionState.Terminated?19:21;break;case 11:return n.next=13,O(this,K,"f").reject(g({extraHeaders:o},i||{}));case 13:return e(!0),n.abrupt("break",21);case 15:return n.next=17,O(this,K,"f").bye(g({requestDelegate:w,requestOptions:{extraHeaders:o}},p));case 17:return a||e(!0),n.abrupt("break",21);case 19:return e(!0),n.abrupt("break",21);case 21:n.next=26;break;case 23:n.prev=23,n.t1=n.catch(0),t(n.t1);case 26:return n.prev=26,O(this,ee,"f").incomingStatus=!1,O(this,ee,"f").answerStatus=!1,n.finish(26);case 30:case"end":return n.stop()}}),n,this,[[0,23,26,30]])})))})));case 2:case"end":return t.stop()}}),t)})))}},{key:"sendStarDtmf",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark((function t(){var n=this;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new v((function(t,i){return C(n,void 0,void 0,c.mark((function n(){var r,s,o,a;return c.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,s=(r=e||{}).extraHeaders,o=r.requestDelegate,a=O(this,F,"m",xt).call(this,{onAccept:function(e){console.log("sip send dtmf Signal=* success"),t(e)},onReject:function(e){i(new Error("sip send dtmf Signal=* fail with code "+e.message.statusCode))}},o),delete r.requestDelegate,n.next=7,this.getCurrentInvitation().info(g({requestOptions:{body:{contentDisposition:"render",contentType:"application/dtmf-relay",content:"Signal=*\r\nDuration=100"},extraHeaders:s},requestDelegate:a},r));case 7:O(this,tt,"f").call(this),n.next=13;break;case 10:n.prev=10,n.t0=n.catch(0),i(n.t0);case 13:case"end":return n.stop()}}),n,this,[[0,10]])})))})));case 1:case"end":return t.stop()}}),t)})))}},{key:"sendCurrentInviter",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark((function t(){var n;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=(e||{}).extraHeaders,t.next=3,this.getCurrentInviter().invite(g({requestOptions:{extraHeaders:n}},e));case 3:case"end":return t.stop()}}),t,this)})))}},{key:"muteRemoteAudio",value:function(){var e;h(e=O(this,V,"f").getReceivers()).call(e,(function(e){e.track.enabled=!1}))}},{key:"unMuteRemoteAudio",value:function(){var e;h(e=O(this,V,"f").getReceivers()).call(e,(function(e){e.track.enabled=!0}))}},{key:"muteLocalAudio",value:function(){var e;h(e=O(this,V,"f").getSenders()).call(e,(function(e){e.track.enabled=!1}))}},{key:"unMuteLocalAudio",value:function(){var e;h(e=O(this,V,"f").getSenders()).call(e,(function(e){e.track.enabled=!0}))}},{key:"getUserAgentStatue",value:function(){return O(this,ee,"f")}},{key:"getUserAgent",value:function(){return O(this,_,"f")||q(this,_,new r.UserAgent(O(this,Z,"f")),"f"),O(this,_,"f")}},{key:"getSessionDescriptionHandler",value:function(){return O(this,Y,"f")}},{key:"getPeerConnection",value:function(){return O(this,V,"f")}},{key:"getSenders",value:function(){return O(this,W,"f")}},{key:"getReceivers",value:function(){return O(this,J,"f")}},{key:"getStream",value:function(){var e,t=this;return O(this,Q,"f")||q(this,Q,new MediaStream,"f"),h(e=O(this,J,"f")).call(e,(function(e){e.track&&O(t,Q,"f").addTrack(e.track)})),O(this,Q,"f")}},{key:"getCurrentInviter",value:function(){if(!O(this,$,"f"))throw new Error("No currentInviter, please call createCurrentInviter");return O(this,$,"f")}},{key:"getCurrentInvitation",value:function(){return O(this,K,"f")}}]),e}();G=new x,_=new x,B=new x,Y=new x,V=new x,J=new x,W=new x,Z=new x,K=new x,$=new x,Q=new x,ee=new x,te=new x,ne=new x,ie=new x,re=new x,se=new x,oe=new x,ae=new x,ce=new x,ue=new x,le=new x,fe=new x,he=new x,de=new x,pe=new x,ve=new x,ge=new x,me=new x,we=new x,be=new x,ke=new x,xe=new x,ye=new x,Se=new x,Ae=new x,Ie=new x,Te=new x,je=new x,Ce=new x,Oe=new x,qe=new x,De=new x,Ee=new x,Re=new x,Pe=new x,Ne=new x,Me=new x,Ue=new x,He=new x,ze=new x,Le=new x,Xe=new x,Fe=new x,Ge=new x,_e=new x,Be=new x,Ye=new x,Ve=new x,Je=new x,We=new x,Ze=new x,Ke=new x,$e=new x,Qe=new x,et=new x,tt=new x,nt=new x,it=new x,rt=new x,st=new x,ot=new x,at=new x,ct=new x,ut=new x,gt=new x,mt=new x,wt=new x,Et=new x,Pt=new x,Nt=new x,Mt=new x,Ut=new x,Ht=new x,Gt=new x,F=new y,lt=function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,pe,null!==(e=n.openXhrIntercept)&&void 0!==e?e:O(this,pe,"f"),"f"),q(this,ve,null!==(t=n.gatewayXhrIntercept)&&void 0!==t?t:O(this,ve,"f"),"f")},ft=function(){var e,t,n,i,r,s,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,Qe,null!==(e=o.enableChatInfoPush)&&void 0!==e?e:O(this,Qe,"f"),"f"),q(this,et,null!==(t=o.enableVolumnTrack)&&void 0!==t?t:O(this,et,"f"),"f"),q(this,he,null!==(n=o.refreshSpeekVolumn)&&void 0!==n?n:O(this,he,"f"),"f"),q(this,xe,null!==(i=o.refreshRequirementCheck)&&void 0!==i?i:O(this,xe,"f"),"f"),q(this,de,null!==(r=o.refreshChat)&&void 0!==r?r:O(this,de,"f"),"f"),q(this,ke,null!==(s=o.refreshChatErrorCallback)&&void 0!==s?s:O(this,ke,"f"),"f")},ht=function(){var e,t,n,i,r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q(this,re,null!==(e=s.token)&&void 0!==e?e:O(this,re,"f"),"f"),q(this,se,null!==(t=s.tokenTimestamp)&&void 0!==t?t:O(this,se,"f"),"f"),q(this,ae,null!==(n=s.tokenExpirationTime)&&void 0!==n?n:O(this,ae,"f"),"f"),O(this,re,"f")&&!O(this,se,"f")&&q(this,se,f(),"f"),q(this,me,null!==(i=s.tokenCheck)&&void 0!==i?i:O(this,me,"f"),"f"),q(this,be,null!==(r=s.tokenOverdued)&&void 0!==r?r:O(this,be,"f"),"f")},dt=function(){var e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.agentId,s=i.agentTag,o=i.appKey,a=i.appSecret,c=i.openBaseUrl,u=i.sg,l=i.sgOpen,f=i.sign,h=i.timestamp;q(this,Be,null!=r?r:O(this,Be,"f"),"f"),q(this,_e,null!=s?s:O(this,_e,"f"),"f"),q(this,Fe,null!=o?o:O(this,Fe,"f"),"f"),q(this,Ge,null!=a?a:O(this,Ge,"f"),"f"),q(this,Ye,null!=c?c:O(this,Ye,"f"),"f"),q(this,Je,null!=u?u:O(this,Je,"f"),"f"),q(this,Ve,null!=l?l:O(this,Ve,"f"),"f"),q(this,ne,null!=f?f:O(this,ne,"f"),"f"),q(this,ie,null!=h?h:O(this,ie,"f"),"f"),q(this,oe,null!==(e=i.signExpirationTime)&&void 0!==e?e:O(this,oe,"f"),"f"),q(this,ge,null!==(t=i.signCheck)&&void 0!==t?t:O(this,ge,"f"),"f"),q(this,we,null!==(n=i.signOverdued)&&void 0!==n?n:O(this,we,"f"),"f")},pt=function(e){e.sipHeaders&&(q(this,G,e.sipHeaders,"f"),delete e.sipHeaders)},vt=function(){return!(!O(this,Be,"f")&&!O(this,_e,"f")||!(O(this,Fe,"f")&&O(this,Ge,"f")||O(this,ne,"f")&&O(this,ie,"f")))},bt=function(e){q(this,ee,o(JSON.parse(u(H)),"function"==typeof e.refresh?e.refresh:O(this,Ke,"f")),"f")},kt=function(e){var t,n,i,r,s,o,a,c,u,l,f,h,d,p,v;q(this,Ae,null!==(i=null!==(t=e.reconnectionAttempts)&&void 0!==t?t:null===(n=null==e?void 0:e.transportOptions)||void 0===n?void 0:n.maxReconnectionAttempts)&&void 0!==i?i:O(this,Ae,"f"),"f"),q(this,Ie,null!==(a=null!==(s=null!==(r=e.reconnectionInterval)&&void 0!==r?r:e.reconnectionDelay)&&void 0!==s?s:null===(o=null==e?void 0:e.transportOptions)||void 0===o?void 0:o.reconnectionTimeout)&&void 0!==a?a:O(this,Ie,"f"),"f"),q(this,Pe,null!==(u=null===(c=e.transportOptions)||void 0===c?void 0:c.keepAliveInterval)&&void 0!==u?u:O(this,Pe,"f"),"f"),q(this,Ne,null!==(f=null===(l=e.transportOptions)||void 0===l?void 0:l.keepAliveDebounce)&&void 0!==f?f:O(this,Ne,"f"),"f"),q(this,De,null!==(h=e.registerInterval)&&void 0!==h?h:O(this,De,"f"),"f"),q(this,Te,null!==(d=e.optionsPingInterval)&&void 0!==d?d:O(this,Te,"f"),"f"),q(this,je,null!==(p=e.optionsPingAttempts)&&void 0!==p?p:O(this,je,"f"),"f"),q(this,Ee,null!==(v=e.registerAttempts)&&void 0!==v?v:O(this,Ee,"f"),"f")},xt=function(e,t){var n,i=this;return t?(h(n=S(t)).call(n,(function(n){if(t[n]&&"function"==typeof t[n])if(e[n]){if("function"==typeof e[n]){var r=e[n];e[n]=function(e){return C(i,void 0,void 0,c.mark((function i(){return c.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,t[n](e);case 2:return i.next=4,r(e);case 4:case"end":return i.stop()}}),i)})))}}}else e[n]=t[n]})),e):e},yt=function(e){var t,n=this,i={delegate:{onConnect:function(){return C(n,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log("sip connected"),O(this,Mt,"f").call(this);case 2:case"end":return e.stop()}}),e,this)})))},onInvite:function(e){O(n,wt,"f").call(n,e.incomingInviteRequest.message.headers),n.refreshCallChatInfo(),O(n,F,"m",St).call(n),q(n,K,e,"f"),O(n,ee,"f").incomingStatus=!0,e.stateChange.addListener(O(n,Et,"f"))},onDisconnect:function(e){return C(n,void 0,void 0,c.mark((function t(){var n;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log("sip disconnected"),n=!1,O(this,Te,"f")>0&&(n=O(this,Oe,"f"),O(this,Ht,"f").call(this)),t.next=5,O(this,F,"m",Rt).call(this);case 5:(e||n)&&O(this,F,"m",_t).call(this);case 6:case"end":return t.stop()}}),t,this)})))}}};e.delegate?h(t=S(e.delegate)).call(t,(function(t){var r=t;if(e.delegate[r]&&"function"==typeof e.delegate[r]){var s=e.delegate[r];e.delegate[r]=function(e){return C(n,void 0,void 0,c.mark((function t(){var n,o;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(o=(n=i.delegate)[r])||void 0===o||o.call(n,e),t.next=3,s(e);case 3:case"end":return t.stop()}}),t)})))}}})):e.delegate=i.delegate;return e.reconnectionAttempts=0,e.transportOptions=g(g({},e.transportOptions||{}),{keepAliveInterval:O(this,Pe,"f"),keepAliveDebounce:O(this,Ne,"f")}),void 0===e.sessionDescriptionHandlerFactoryOptions&&(e.sessionDescriptionHandlerFactoryOptions={iceGatheringTimeout:2e3,peerConnectionConfiguration:{iceServers:[]}}),g(g({},U),e)},St=function(){O(this,K,"f")&&(O(this,K,"f").dispose(),q(this,K,void 0,"f"))},At=function(){return C(this,void 0,void 0,c.mark((function e(){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!O(this,_,"f")){e.next=4;break}return e.next=3,O(this,_,"f").stop();case 3:q(this,_,void 0,"f");case 4:case"end":return e.stop()}}),e,this)})))},It=function(){var e;O(this,Q,"f")&&(h(e=O(this,Q,"f").getTracks()).call(e,(function(e){e.stop()})),q(this,Q,void 0,"f"))},Tt=function(){var e,t=this;h(e=S(H)).call(e,(function(e){var n=e;O(t,ee,"f")[n]=H[n]}))},jt=function(){O(this,Y,"f")&&(O(this,Y,"f").close(),q(this,Y,void 0,"f"))},Ct=function(){O(this,V,"f")&&(O(this,V,"f").close(),q(this,V,void 0,"f"))},Ot=function(){q(this,W,[],"f")},qt=function(){q(this,J,[],"f")},Dt=function(){var e=this.getCurrentInvitation().sessionDescriptionHandler;O(this,F,"m",Ct).call(this),O(this,F,"m",jt).call(this),O(this,F,"m",Ot).call(this),O(this,F,"m",qt).call(this),q(this,Y,e,"f"),q(this,V,e.peerConnection,"f"),q(this,W,O(this,V,"f").getSenders(),"f"),q(this,J,O(this,V,"f").getReceivers(),"f"),(this.getFastOutboundCall()||!this.getSitOutboundCall()&&this.notNeedSendStarDtmf())&&O(this,tt,"f").call(this)},Rt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return C(this,void 0,void 0,c.mark((function t(){var n=this;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!O(this,B,"f")){t.next=3;break}return console.log("sip due to disconnection, unregistered"),t.abrupt("return",new v((function(t,i){return C(n,void 0,void 0,c.mark((function n(){var r,s;return c.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,r=e||{},s=O(this,F,"m",xt).call(this,{onAccept:function(e){console.log("sip unregister successed"),t(e)},onReject:function(e){i(new Error("sip unregister fail with code "+e.message.statusCode))}},r.requestDelegate),delete e.requestDelegate,n.next=6,O(this,B,"f").unregister(g({requestDelegate:s},e));case 6:n.next=11;break;case 8:n.prev=8,n.t0=n.catch(0),i(n.t0);case 11:case"end":return n.stop()}}),n,this,[[0,8]])})))})));case 3:case"end":return t.stop()}}),t,this)})))},zt=function(){O(this,F,"m",Lt).call(this),O(this,F,"m",Xt).call(this),O(this,F,"m",Ft).call(this),q(this,He,!1,"f"),q(this,Me,!1,"f"),q(this,Ue,!1,"f")},Lt=function(){clearTimeout(O(this,Xe,"f")),q(this,Xe,void 0,"f")},Xt=function(){clearTimeout(O(this,ze,"f")),q(this,ze,void 0,"f")},Ft=function(){clearTimeout(O(this,Le,"f")),q(this,Le,void 0,"f")},_t=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return C(this,void 0,void 0,c.mark((function n(){var i=this;return c.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!O(this,Ie,"f")){n.next=12;break}if(O(this,ee,"f").reconnectStatus=!0,!O(this,Me,"f")){n.next=4;break}return n.abrupt("return");case 4:if(!(t>O(this,Ae,"f"))){n.next=9;break}return console.log("sip maximum reconnection attempts reached"),n.next=8,this.dispose();case 8:return n.abrupt("return");case 9:console.log("sip reconnection attempt..."),q(this,Me,!0,"f"),q(this,ze,d((function(){O(i,F,"m",Xt).call(i),i.getUserAgent().reconnect().then((function(){return C(i,void 0,void 0,c.mark((function e(){var n;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:console.log(m(n="sip reconnection attempt ".concat(t," of ")).call(n,O(this,Ae,"f")," - succeeded")),q(this,Me,!1,"f"),O(this,Gt,"f").call(this);case 3:case"end":return e.stop()}}),e,this)})))})).catch((function(n){var r;console.error(n),console.log(m(r="sip reconnection attempt ".concat(t," of ")).call(r,O(i,Ae,"f")," - failed")),q(i,Me,!1,"f"),O(i,F,"m",e).call(i,++t)}))}),1===t?0:1e3*O(this,Ie,"f")),"f");case 12:case"end":return n.stop()}}),n,this)})))},Bt=function(e){var t,n=this;return h(t=S(e)).call(t,(function(t){var i=t;if("function"==typeof(null==e?void 0:e[i])){var r=e[i];e[i]=function(e){return C(n,void 0,void 0,c.mark((function t(){var n,s;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(s=(n=O(this,Z,"f").delegate)[i])||void 0===s||s.call(n,e),t.next=3,r(e);case 3:case"end":return t.stop()}}),t,this)})))}}})),e},Yt=function(e){var t=this.getUserAgent();return t.delegate=O(this,F,"m",Bt).call(this,e),t},Vt=function(e){return C(this,void 0,void 0,c.mark((function t(){var n;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return O(this,F,"m",bt).call(this,e),n=this.getUserAgent(),t.next=4,n.start();case 4:if(n.isConnected()){t.next=7;break}return t.next=7,n.reconnect();case 7:if(n.isConnected()){t.next=9;break}throw new Error("链接失败,请稍后再试");case 9:return O(this,ee,"f").connectStatus=!0,t.abrupt("return",n);case 11:case"end":return t.stop()}}),t,this)})))},Jt=function(e){var t=this,n=e||{},i=n.registererOptions,s=n.registererRegisterOptions,o=n.extraHeaders;return new v((function(e,n){return C(t,void 0,void 0,c.mark((function t(){var a,u,l,f=this;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=this.getUserAgent(),q(this,B,new r.Registerer(a,g({extraHeaders:o||O(this,G,"f")},i||{})),"f"),t.prev=2,u=s||{},l=O(this,F,"m",xt).call(this,{onAccept:function(t){O(f,ee,"f").registerStatus=!0,e(a)},onReject:function(e){n(new Error("sip register fail with code "+e.message.statusCode))}},u.requestDelegate),delete u.requestDelegate,t.next=8,O(this,B,"f").register(g({requestDelegate:l,requestOptions:{extraHeaders:o||O(this,G,"f")}},u));case 8:t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),n(t.t0);case 13:case"end":return t.stop()}}),t,this,[[2,10]])})))}))};var nn=function(){function e(){n(this,e)}return i(e,null,[{key:"getUserAgentManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O(this,Qt,"f",en)||q(this,Qt,new tn(e),"f",en),O(this,Qt,"f",en)}},{key:"hasUserAgentManager",value:function(){return!!O(this,Qt,"f",en)}},{key:"newUserAgentManager",value:function(){return new tn(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"dispose",value:function(){if(O(this,Qt,"f",en))try{O(this,Qt,"f",en).dispose()}catch(e){}finally{q(this,Qt,void 0,"f",en)}}}]),e}();Qt=nn,en={value:void 0},Object.defineProperty(exports,"Inviter",{enumerable:!0,get:function(){return r.Inviter}}),Object.defineProperty(exports,"Registerer",{enumerable:!0,get:function(){return r.Registerer}}),Object.defineProperty(exports,"SessionState",{enumerable:!0,get:function(){return r.SessionState}}),Object.defineProperty(exports,"URI",{enumerable:!0,get:function(){return r.URI}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return r.UserAgent}}),Object.defineProperty(exports,"SimpleUser",{enumerable:!0,get:function(){return s.SimpleUser}}),exports.onChange=o,exports.UserAgentFactory=nn,exports.UserAgentManager=tn,exports.accumulateSec=Kt,exports.accumulationTimer=function(e){var t=Zt();e(Wt(t));var n=p((function(){var n=Kt(t),i=Wt(n);e(i)}),1e3);return function(){clearInterval(n),n=null}},exports.cleanupMedia=function(e){var t=z(e);t&&(t.srcObject=null,t.pause())},exports.getDevicePermission=X,exports.getMedia=z,exports.getTimes=Wt,exports.getZeorTime=Zt,exports.pauseMedia=function(e){var t=z(e);t&&(t.currentTime=0,t.pause())},exports.playMedia=function(e){var t=z(e);t&&(t.currentTime=0,t.play())},exports.requestMicroPhonePermission=function(){try{var e;if(-1===b(e=navigator.userAgent).call(e,"Firefox"))return X({video:!1,audio:!0}).catch((function(){return!0}))}catch(e){console.log(e)}},exports.stopStreamTracks=L,exports.userAgentDefault=U,exports.userAgentStatus=H;