ahs-cti 0.0.2-beta.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/dist/index.js ADDED
@@ -0,0 +1,4569 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
47
+
48
+ // call-control-sdk/index.ts
49
+ var index_exports = {};
50
+ __export(index_exports, {
51
+ CallControlPanel: () => CallControlPanel,
52
+ getSDKVersion: () => getSDKVersion,
53
+ initSDK: () => initSDK,
54
+ isSDKInitialized: () => isSDKInitialized,
55
+ useClickToCall: () => useClickToCall,
56
+ useEndCall: () => useEndCall,
57
+ useGetAuthorizationToken: () => useGetAuthorizationToken,
58
+ useGetCallerData: () => useGetCallerData,
59
+ useLogout: () => useLogout
60
+ });
61
+ module.exports = __toCommonJS(index_exports);
62
+
63
+ // call-control-sdk/lib/hooks/eventsTracker.ts
64
+ var EventTrackerSDK = class {
65
+ constructor() {
66
+ __publicField(this, "config", null);
67
+ __publicField(this, "ticketId", null);
68
+ __publicField(this, "baseUrl", "");
69
+ __publicField(this, "flushTimer", null);
70
+ }
71
+ async init(config) {
72
+ this.config = __spreadValues({
73
+ retryAttempts: 3,
74
+ queueSize: 100,
75
+ flushInterval: 5e3
76
+ }, config);
77
+ this.baseUrl = config.baseUrl || (typeof window !== "undefined" ? window.location.origin : "");
78
+ const ticket = await this.createTicket();
79
+ this.startPeriodicFlush();
80
+ return ticket;
81
+ }
82
+ isInitialized() {
83
+ return this.config !== null && this.ticketId !== null;
84
+ }
85
+ getConfig() {
86
+ return this.config;
87
+ }
88
+ getTicketId() {
89
+ return this.ticketId;
90
+ }
91
+ async createTicket() {
92
+ if (!this.config) {
93
+ throw new Error("EventTracker not initialized");
94
+ }
95
+ try {
96
+ const response = await this.makeRequest("/api/v1/auth/login", {
97
+ method: "POST",
98
+ headers: {
99
+ "Content-Type": "application/json"
100
+ },
101
+ body: JSON.stringify({
102
+ userId: this.config.agentId,
103
+ // sessionId: this.config.sessionId,
104
+ password: this.config.password
105
+ })
106
+ });
107
+ const data = await response.json();
108
+ this.ticketId = data.ticketId;
109
+ return data;
110
+ } catch (error) {
111
+ throw error;
112
+ }
113
+ }
114
+ async makeRequest(url, options) {
115
+ var _a2;
116
+ const fullUrl = `${this.baseUrl}${url}`;
117
+ const maxRetries = ((_a2 = this.config) == null ? void 0 : _a2.retryAttempts) || 3;
118
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
119
+ try {
120
+ const response = await fetch(fullUrl, options);
121
+ return response;
122
+ } catch (error) {
123
+ if (attempt === maxRetries) {
124
+ throw error;
125
+ }
126
+ const delay = Math.min(1e3 * Math.pow(2, attempt - 1), 1e4);
127
+ await new Promise((resolve) => setTimeout(resolve, delay));
128
+ }
129
+ }
130
+ throw new Error("Max retries exceeded");
131
+ }
132
+ startPeriodicFlush() {
133
+ if (this.flushTimer) {
134
+ clearInterval(this.flushTimer);
135
+ }
136
+ }
137
+ };
138
+ var eventTracker = new EventTrackerSDK();
139
+ if (typeof window !== "undefined") {
140
+ window.EventTracker = eventTracker;
141
+ }
142
+
143
+ // call-control-sdk/lib/hooks/sdk-state.ts
144
+ var import_vault = require("@react-solutions/vault");
145
+
146
+ // call-control-sdk/lib/services/endPoint.ts
147
+ var BASE_URL = "";
148
+ var VERSION = {
149
+ v1: "/api/v1"
150
+ };
151
+ var END_POINT = {
152
+ LOGIN: `${BASE_URL}${VERSION.v1}/cti/login?provider=convox`,
153
+ READY_AGENT: `${BASE_URL}${VERSION.v1}/cti/ready-agent?provider=convox`,
154
+ UPDATE_AGENT_BREAK: `${BASE_URL}${VERSION.v1}/cti/update-agent-status?provider=convox`,
155
+ CLICK_TO_CALL: `${BASE_URL}${VERSION.v1}/cti/calls?provider=convox`,
156
+ HOLD_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/hold?provider=convox`,
157
+ MUTE_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/mute?provider=convox`,
158
+ UNMUTE_CALL: `${BASE_URL}${VERSION.v1}/cti/unmute-call?provider=convox`,
159
+ END_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/end?provider=convox`,
160
+ LOGOUT: `${BASE_URL}${VERSION.v1}/cti/logout?provider=convox`,
161
+ CONFERENCE_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/conference?provider=convox`,
162
+ CONFERENCE_CALL_HOLD_OR_UN_HOLD: `${BASE_URL}${VERSION.v1}/cti/calls/conference/hold?provider=convox`,
163
+ CONFERENCE_CALL_MUTE_OT_UN_MUTE: `${BASE_URL}${VERSION.v1}/cti/calls/conference/mute?provider=convox`,
164
+ CONFERENCE_CALL_END: `${BASE_URL}${VERSION.v1}/cti/calls/conference/hangup?provider=convox`,
165
+ CONFERENCE_CALL_END_ALL: `${BASE_URL}${VERSION.v1}/cti/calls/conference/hangup/all?provider=convox`,
166
+ CONFERENCE_CALL_TRANSFER: `${BASE_URL}${VERSION.v1}/cti/calls/conference/transfer?provider=convox`,
167
+ TRANSFER_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/transfer?provider=convox`,
168
+ AGENTS_LIST: `${BASE_URL}${VERSION.v1}/cti/users`,
169
+ PROCESS_LIST: `${BASE_URL}${VERSION.v1}/cti/processes-list`,
170
+ BREAKS_LIST: `${BASE_URL}${VERSION.v1}/cti/breaks`,
171
+ TRANSFER_TO_DETAILS: `${BASE_URL}${VERSION.v1}/cti/transfer-to-details?provider=convox`,
172
+ SEND_NOTIFICATIONS: `${BASE_URL}${VERSION.v1}/cti/notifications/send`,
173
+ CALL_HISTORY: `${BASE_URL}${VERSION.v1}/dashboard/call-history`,
174
+ SENTIMENTAL_ANALYSIS: `${BASE_URL}${VERSION.v1}/users/get_sentiment_analysis`,
175
+ DISPOSITIONS: `${BASE_URL}${VERSION.v1}/cti/calls/dispositions`,
176
+ HOSPITALS_SERVICES: `${BASE_URL}${VERSION.v1}/cti/hospital/services`,
177
+ BLIEND_TRANSFER: `${BASE_URL}${VERSION.v1}/cti/calls/blind_transfer?provider=convox`
178
+ };
179
+ var STORAGE_KEY = "call-control-sdk-state";
180
+
181
+ // call-control-sdk/lib/hooks/sdk-state.ts
182
+ var SDKStateManager = class {
183
+ constructor() {
184
+ __publicField(this, "state");
185
+ __publicField(this, "listeners", []);
186
+ __publicField(this, "STORAGE_KEY", STORAGE_KEY);
187
+ __publicField(this, "apiKey");
188
+ __publicField(this, "tenantId");
189
+ this.state = this.getInitialState();
190
+ this.loadFromStorage();
191
+ }
192
+ getInitialState() {
193
+ var _a2, _b;
194
+ return {
195
+ authorization: void 0,
196
+ process: null,
197
+ agentId: "",
198
+ openConferenceDialog: false,
199
+ openCallTransferDialog: false,
200
+ isInitialized: false,
201
+ sdkConfig: {
202
+ disableEndCallButton: false,
203
+ disabledDialButton: false,
204
+ disabledMoreOptionsButton: false,
205
+ enableSmsServices: false,
206
+ enableQueueName: false,
207
+ disableCallTransferButton: false,
208
+ isDraggable: true,
209
+ disableSoftPhone: false,
210
+ disableConferenceButton: false,
211
+ disabled: {},
212
+ enabled: {},
213
+ outlined: {}
214
+ },
215
+ urlConfig: {
216
+ baseURL: "",
217
+ iframeURL: "",
218
+ iframeAPIURL: "",
219
+ webSocketURL: "",
220
+ password: ""
221
+ },
222
+ callStartTime: null,
223
+ controlPanelPosition: { x: 10, y: 10 },
224
+ iframePosition: { x: ((_a2 = window.screen) == null ? void 0 : _a2.availWidth) - 460, y: ((_b = window.screen) == null ? void 0 : _b.height) - 580 },
225
+ callData: {
226
+ agent_id: "",
227
+ queue_name: "",
228
+ hold: 0,
229
+ mute: 0,
230
+ status: "",
231
+ type: "",
232
+ event_time: "",
233
+ phone_number: ""
234
+ },
235
+ conferenceLine: [
236
+ {
237
+ line: 1,
238
+ status: "IDLE",
239
+ type: "",
240
+ phone: "",
241
+ isMute: false,
242
+ isHold: false,
243
+ isCallStart: false,
244
+ isMergeCall: false
245
+ },
246
+ {
247
+ line: 2,
248
+ status: "IDLE",
249
+ type: "",
250
+ phone: "",
251
+ isMute: false,
252
+ isHold: false,
253
+ isCallStart: false,
254
+ isMergeCall: false
255
+ },
256
+ {
257
+ line: 3,
258
+ status: "IDLE",
259
+ type: "",
260
+ phone: "",
261
+ isMute: false,
262
+ isHold: false,
263
+ isCallStart: false,
264
+ isMergeCall: false
265
+ },
266
+ {
267
+ line: 4,
268
+ status: "IDLE",
269
+ type: "",
270
+ phone: "",
271
+ isMute: false,
272
+ isHold: false,
273
+ isCallStart: false,
274
+ isMergeCall: false
275
+ },
276
+ {
277
+ line: 5,
278
+ status: "IDLE",
279
+ type: "",
280
+ phone: "",
281
+ isMute: false,
282
+ isHold: false,
283
+ isCallStart: false,
284
+ isMergeCall: false
285
+ }
286
+ ],
287
+ hold: 0,
288
+ mute: 0,
289
+ agentStatus: ""
290
+ };
291
+ }
292
+ loadFromStorage() {
293
+ var _a2, _b;
294
+ try {
295
+ const stored = (0, import_vault.getItem)(this.STORAGE_KEY);
296
+ if (stored) {
297
+ const parsedState = stored;
298
+ this.state = __spreadProps(__spreadValues({}, this.state), {
299
+ agentId: parsedState.agentId || "",
300
+ authorization: parsedState.authorization || void 0,
301
+ process: parsedState.process || null,
302
+ openConferenceDialog: (parsedState == null ? void 0 : parsedState.openConferenceDialog) || false,
303
+ openCallTransferDialog: (parsedState == null ? void 0 : parsedState.openCallTransferDialog) || false,
304
+ isInitialized: parsedState.isInitialized || false,
305
+ sdkConfig: parsedState.sdkConfig || {
306
+ disableEndCallButton: false,
307
+ disabledMoreOptionsButton: false,
308
+ enableSmsServices: false,
309
+ enableQueueName: false,
310
+ disabledDialButton: false,
311
+ disableCallTransferButton: false,
312
+ isDraggable: true,
313
+ disableSoftPhone: false,
314
+ disableConferenceButton: false,
315
+ disabled: {},
316
+ enabled: {},
317
+ outlined: {}
318
+ },
319
+ urlConfig: parsedState.urlConfig || {
320
+ baseURL: "",
321
+ iframeURL: "",
322
+ iframeAPIURL: "",
323
+ webSocketURL: "",
324
+ password: ""
325
+ },
326
+ callStartTime: parsedState.callStartTime || null,
327
+ controlPanelPosition: parsedState.controlPanelPosition || {
328
+ x: 10,
329
+ y: 10
330
+ },
331
+ iframePosition: parsedState.iframePosition || {
332
+ x: ((_a2 = window.screen) == null ? void 0 : _a2.availWidth) - 460,
333
+ y: ((_b = window.screen) == null ? void 0 : _b.height) - 580
334
+ },
335
+ callData: parsedState.callData || {
336
+ mobileNumber: "",
337
+ callReferenceId: "",
338
+ agent_id: "",
339
+ status: "",
340
+ type: "",
341
+ event_time: "",
342
+ phone_number: ""
343
+ },
344
+ conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine,
345
+ agentStatus: parsedState.agentStatus
346
+ });
347
+ }
348
+ } catch (error) {
349
+ console.warn("Failed to load SDK state:", error);
350
+ }
351
+ }
352
+ saveToStorage() {
353
+ try {
354
+ const persistentState = {
355
+ agentId: this.state.agentId,
356
+ authorization: this.state.authorization,
357
+ process: this.state.process,
358
+ isInitialized: this.state.isInitialized,
359
+ openConferenceDialog: this.state.openConferenceDialog,
360
+ openCallTransferDialog: this.state.openCallTransferDialog,
361
+ sdkConfig: this.state.sdkConfig,
362
+ urlConfig: this.state.urlConfig,
363
+ callStartTime: this.state.callStartTime,
364
+ controlPanelPosition: this.state.controlPanelPosition,
365
+ iframePosition: this.state.iframePosition,
366
+ callData: this.state.callData,
367
+ conferenceLine: this.state.conferenceLine,
368
+ agentStatus: this.state.agentStatus
369
+ };
370
+ (0, import_vault.setItem)(this.STORAGE_KEY, persistentState);
371
+ } catch (error) {
372
+ console.warn("Failed to save SDK state:", error);
373
+ }
374
+ }
375
+ notifyListeners() {
376
+ this.listeners.forEach((listener) => listener());
377
+ }
378
+ validateCredentials(apiKey, tenantId) {
379
+ if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
380
+ throw new Error("API key not available");
381
+ }
382
+ if (!tenantId || typeof tenantId !== "string" || tenantId.trim().length === 0) {
383
+ throw new Error("Tenant ID not available");
384
+ }
385
+ this.apiKey = apiKey.trim();
386
+ this.tenantId = tenantId.trim();
387
+ }
388
+ initialize(apiKey, tenantId, agentId, sdkConfig, initResult, urlConfig) {
389
+ this.validateCredentials(apiKey, tenantId);
390
+ if (!agentId || typeof agentId !== "string" || agentId.trim().length === 0) {
391
+ throw new Error("Agent ID not available");
392
+ } else {
393
+ this.state.agentId = agentId;
394
+ this.state.openConferenceDialog = false;
395
+ this.state.openCallTransferDialog = false;
396
+ this.state.authorization = initResult;
397
+ this.state.sdkConfig = __spreadValues({
398
+ disableEndCallButton: false,
399
+ disabledDialButton: false,
400
+ enableSmsServices: false,
401
+ disabledMoreOptionsButton: false,
402
+ enableQueueName: false,
403
+ disableCallTransferButton: false,
404
+ isDraggable: true,
405
+ disableSoftPhone: false,
406
+ disableConferenceButton: false,
407
+ disabled: {},
408
+ enabled: {},
409
+ outlined: {}
410
+ }, sdkConfig);
411
+ this.state.urlConfig = {
412
+ baseURL: (urlConfig == null ? void 0 : urlConfig.baseURL) || "",
413
+ iframeURL: (urlConfig == null ? void 0 : urlConfig.iframeURL) || "",
414
+ iframeAPIURL: (urlConfig == null ? void 0 : urlConfig.iframeAPIURL) || "",
415
+ webSocketURL: (urlConfig == null ? void 0 : urlConfig.webSocketURL) || "",
416
+ password: (urlConfig == null ? void 0 : urlConfig.password) || ""
417
+ };
418
+ this.state.isInitialized = true;
419
+ this.saveToStorage();
420
+ this.notifyListeners();
421
+ }
422
+ }
423
+ getState() {
424
+ return __spreadValues({}, this.state);
425
+ }
426
+ getCredentials() {
427
+ return { apiKey: this.apiKey, tenantId: this.tenantId };
428
+ }
429
+ getSdkAuthToken() {
430
+ var _a2;
431
+ return (_a2 = this.state.authorization) == null ? void 0 : _a2.accessToken;
432
+ }
433
+ subscribe(listener) {
434
+ this.listeners.push(listener);
435
+ return () => {
436
+ const index = this.listeners.indexOf(listener);
437
+ if (index > -1) {
438
+ this.listeners.splice(index, 1);
439
+ }
440
+ };
441
+ }
442
+ // public setHolding(isHolding: boolean): void {
443
+ // this.state.isHolding = isHolding;
444
+ // this.saveToStorage();
445
+ // this.notifyListeners();
446
+ // }
447
+ // public setMuted(isMuted: boolean): void {
448
+ // this.state.isMuted = isMuted;
449
+ // this.saveToStorage();
450
+ // this.notifyListeners();
451
+ // }
452
+ setProcess(process) {
453
+ this.state.process = process;
454
+ this.saveToStorage();
455
+ this.notifyListeners();
456
+ }
457
+ setControlPanelPosition(position) {
458
+ this.state.controlPanelPosition = position;
459
+ this.saveToStorage();
460
+ this.notifyListeners();
461
+ }
462
+ setIframePosition(position) {
463
+ this.state.iframePosition = position;
464
+ this.saveToStorage();
465
+ this.notifyListeners();
466
+ }
467
+ startCall() {
468
+ this.state.callStartTime = Date.now();
469
+ this.saveToStorage();
470
+ this.notifyListeners();
471
+ }
472
+ endCall() {
473
+ this.state.callStartTime = null;
474
+ this.saveToStorage();
475
+ this.notifyListeners();
476
+ }
477
+ setInitCheck() {
478
+ this.state.isInitialized = false;
479
+ this.saveToStorage();
480
+ this.notifyListeners();
481
+ }
482
+ setOpenConferenceDialog(open) {
483
+ this.state.openConferenceDialog = open;
484
+ this.saveToStorage();
485
+ this.notifyListeners();
486
+ }
487
+ setOpenCallTransferDialog(open) {
488
+ this.state.openCallTransferDialog = open;
489
+ this.saveToStorage();
490
+ this.notifyListeners();
491
+ }
492
+ setAgentStatus(status) {
493
+ this.state.agentStatus = status;
494
+ this.saveToStorage();
495
+ this.notifyListeners();
496
+ }
497
+ updateCallData(data) {
498
+ this.state.callData = __spreadValues(__spreadValues({}, this.state.callData), data);
499
+ this.saveToStorage();
500
+ this.notifyListeners();
501
+ }
502
+ updateConferenceData(data) {
503
+ this.state.conferenceLine = [...data];
504
+ this.saveToStorage();
505
+ this.notifyListeners();
506
+ }
507
+ setConferenceLine(line) {
508
+ var _a2;
509
+ if (!this.state.conferenceLine || !Array.isArray(this.state.conferenceLine)) {
510
+ this.state.conferenceLine = this.getInitialState().conferenceLine;
511
+ }
512
+ const conferenceLineData = (_a2 = this.state.conferenceLine) == null ? void 0 : _a2.map((each) => {
513
+ if (each.line === line.line) {
514
+ return line;
515
+ }
516
+ return each;
517
+ });
518
+ this.state.conferenceLine = conferenceLineData;
519
+ this.saveToStorage();
520
+ this.notifyListeners();
521
+ }
522
+ resetConferenceLines() {
523
+ this.state.conferenceLine = [
524
+ {
525
+ line: 1,
526
+ status: "IDLE",
527
+ type: "",
528
+ phone: "",
529
+ isMute: false,
530
+ isHold: false,
531
+ isCallStart: false,
532
+ isMergeCall: false
533
+ },
534
+ {
535
+ line: 2,
536
+ status: "IDLE",
537
+ type: "",
538
+ phone: "",
539
+ isMute: false,
540
+ isHold: false,
541
+ isCallStart: false,
542
+ isMergeCall: false
543
+ },
544
+ {
545
+ line: 3,
546
+ status: "IDLE",
547
+ type: "",
548
+ phone: "",
549
+ isMute: false,
550
+ isHold: false,
551
+ isCallStart: false,
552
+ isMergeCall: false
553
+ },
554
+ {
555
+ line: 4,
556
+ status: "IDLE",
557
+ type: "",
558
+ phone: "",
559
+ isMute: false,
560
+ isHold: false,
561
+ isCallStart: false,
562
+ isMergeCall: false
563
+ },
564
+ {
565
+ line: 5,
566
+ status: "IDLE",
567
+ type: "",
568
+ phone: "",
569
+ isMute: false,
570
+ isHold: false,
571
+ isCallStart: false,
572
+ isMergeCall: false
573
+ }
574
+ ];
575
+ this.saveToStorage();
576
+ this.notifyListeners();
577
+ }
578
+ clearStorageAndReset() {
579
+ try {
580
+ (0, import_vault.removeItem)(this.STORAGE_KEY);
581
+ this.state = this.getInitialState();
582
+ this.notifyListeners();
583
+ } catch (error) {
584
+ console.warn("Failed to clear:", error);
585
+ }
586
+ }
587
+ getConferenceLines() {
588
+ return this.state.conferenceLine || [];
589
+ }
590
+ };
591
+ var sdkStateManager = new SDKStateManager();
592
+
593
+ // call-control-sdk/lib/hooks/useLogout.ts
594
+ var import_react = require("react");
595
+
596
+ // call-control-sdk/lib/services/axios.ts
597
+ var import_axios = __toESM(require("axios"));
598
+ var _a;
599
+ var DEFAULT_TOKEN = (_a = sdkStateManager.getSdkAuthToken()) != null ? _a : "";
600
+ var REQUEST_TIMEOUT = 6e4;
601
+ function getAuthToken() {
602
+ var _a2;
603
+ return (_a2 = sdkStateManager.getSdkAuthToken()) != null ? _a2 : "";
604
+ }
605
+ function createAxiosInstance() {
606
+ var _a2, _b, _c, _d, _e, _f;
607
+ const instance = import_axios.default.create({
608
+ baseURL: (_b = (_a2 = sdkStateManager.getState()) == null ? void 0 : _a2.urlConfig) == null ? void 0 : _b.baseURL,
609
+ headers: {
610
+ "Content-Type": "application/json",
611
+ Accept: "application/json",
612
+ "x-tenant-id": (_d = (_c = sdkStateManager.getCredentials()) == null ? void 0 : _c.tenantId) != null ? _d : "",
613
+ "x-api-key": (_f = (_e = sdkStateManager.getCredentials()) == null ? void 0 : _e.apiKey) != null ? _f : "",
614
+ Authorization: `${DEFAULT_TOKEN}`
615
+ },
616
+ timeout: REQUEST_TIMEOUT,
617
+ withCredentials: false
618
+ });
619
+ instance.interceptors.request.use(
620
+ (config) => {
621
+ const token = getAuthToken();
622
+ if (token && config.headers) {
623
+ config.headers.Authorization = `${token}`;
624
+ }
625
+ config.metadata = { startTime: (/* @__PURE__ */ new Date()).getTime() };
626
+ return config;
627
+ },
628
+ (error) => {
629
+ console.error("Request interceptor error:", error);
630
+ return Promise.reject(error);
631
+ }
632
+ );
633
+ instance.interceptors.response.use(
634
+ (response) => {
635
+ return response;
636
+ },
637
+ async (error) => {
638
+ var _a3;
639
+ const originalRequest = error.config;
640
+ if (((_a3 = error.response) == null ? void 0 : _a3.status) === 401 && !originalRequest._retry) {
641
+ sdkStateManager.setInitCheck();
642
+ console.warn("Unauthorized request, attempting retry...");
643
+ }
644
+ if (!error.response) {
645
+ console.error("Network error:", error.message);
646
+ error.message = "Network error: Please check your internet connection";
647
+ }
648
+ if (error.response && error.response.status >= 500) {
649
+ console.error("Server error:", error.response.status, error.response.data);
650
+ error.message = "Server error: Please try again later";
651
+ }
652
+ return Promise.reject(error);
653
+ }
654
+ );
655
+ return instance;
656
+ }
657
+ var axiosInstance = createAxiosInstance();
658
+ var axios_default = axiosInstance;
659
+
660
+ // call-control-sdk/lib/hooks/useLogout.ts
661
+ var import_vault2 = require("@react-solutions/vault");
662
+
663
+ // call-control-sdk/lib/services/usbLight.ts
664
+ var USB_LIGHT_BASE_URL = `http://localhost:5000`;
665
+ var USB_LIGHT_ON = (color) => {
666
+ return `${USB_LIGHT_BASE_URL}/light/${color}/on`;
667
+ };
668
+ var USB_LIGHT_FLASH = (color, number) => {
669
+ return `${USB_LIGHT_BASE_URL}/light/${color}/flash${number}`;
670
+ };
671
+ var USB_LIGHT_ALL_OFF = () => {
672
+ return `${USB_LIGHT_BASE_URL}/all/off`;
673
+ };
674
+ var USB_LIGHT_REQUEST = (url, init) => {
675
+ return fetch(url, init);
676
+ };
677
+
678
+ // call-control-sdk/lib/hooks/useLogout.ts
679
+ var useLogout = () => {
680
+ const [loading, setLoading] = (0, import_react.useState)(false);
681
+ const [success, setSuccess] = (0, import_react.useState)(false);
682
+ const [isError, setIsError] = (0, import_react.useState)(false);
683
+ const [error, setError] = (0, import_react.useState)(null);
684
+ const [data, setData] = (0, import_react.useState)(null);
685
+ const handleLogout = (0, import_react.useCallback)(async () => {
686
+ USB_LIGHT_REQUEST(USB_LIGHT_ALL_OFF());
687
+ const state = (0, import_vault2.getItem)(STORAGE_KEY);
688
+ setLoading(true);
689
+ const payload = {
690
+ action: "LOGOUTUSER",
691
+ userId: state.agentId || ""
692
+ };
693
+ return axios_default.post(END_POINT.LOGOUT, payload).then((res) => {
694
+ sdkStateManager.clearStorageAndReset();
695
+ (0, import_vault2.removeItem)(STORAGE_KEY);
696
+ setData(res == null ? void 0 : res.data);
697
+ setSuccess(true);
698
+ return res == null ? void 0 : res.data;
699
+ }).catch((err) => {
700
+ var _a2, _b, _c, _d;
701
+ setIsError(true);
702
+ setError(err);
703
+ if ((_c = (_b = (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.data) == null ? void 0 : _c.clearAgentData) {
704
+ sdkStateManager.clearStorageAndReset();
705
+ (0, import_vault2.removeItem)(STORAGE_KEY);
706
+ }
707
+ return (_d = err == null ? void 0 : err.response) == null ? void 0 : _d.data;
708
+ }).finally(() => {
709
+ setLoading(false);
710
+ });
711
+ }, []);
712
+ return {
713
+ logout: handleLogout,
714
+ isLoading: loading,
715
+ isSuccess: success,
716
+ isError,
717
+ error,
718
+ data
719
+ };
720
+ };
721
+
722
+ // call-control-sdk/lib/hooks/useEndCall.ts
723
+ var import_react2 = require("react");
724
+ var import_vault3 = require("@react-solutions/vault");
725
+ var useEndCall = () => {
726
+ const [loading, setLoading] = (0, import_react2.useState)(false);
727
+ const [success, setSuccess] = (0, import_react2.useState)(false);
728
+ const [isError, setIsError] = (0, import_react2.useState)(false);
729
+ const [error, setError] = (0, import_react2.useState)(null);
730
+ const [data, setData] = (0, import_react2.useState)(null);
731
+ const handleEndCall = (0, import_react2.useCallback)(
732
+ async (data2) => {
733
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
734
+ const state = (0, import_vault3.getItem)(STORAGE_KEY);
735
+ setLoading(true);
736
+ const payload = {
737
+ action: "ENDCALL",
738
+ userId: state == null ? void 0 : state.agentId,
739
+ processid: (_c = (_b = (_a2 = state == null ? void 0 : state.process) == null ? void 0 : _a2.process_id) == null ? void 0 : _b.toString()) != null ? _c : "",
740
+ process_name: (_e = (_d = state == null ? void 0 : state.process) == null ? void 0 : _d.process_name) != null ? _e : "",
741
+ callreferenceid: (_g = (_f = state == null ? void 0 : state.callData) == null ? void 0 : _f.convox_id) != null ? _g : "",
742
+ mobile_number: (_i = (_h = state == null ? void 0 : state.callData) == null ? void 0 : _h.phone_number) != null ? _i : "",
743
+ disposition: (_j = data2 == null ? void 0 : data2.disposition) != null ? _j : "RES",
744
+ set_followUp: (_k = data2 == null ? void 0 : data2.followUp) != null ? _k : "N",
745
+ callback_date: (_l = data2 == null ? void 0 : data2.callbackDate) != null ? _l : "",
746
+ callback_hrs: (_m = data2 == null ? void 0 : data2.callbackHrs) != null ? _m : "",
747
+ callback_mins: (_n = data2 == null ? void 0 : data2.callbackMins) != null ? _n : "",
748
+ endcall_type: "CLOSE",
749
+ patient_enquiry: (_o = data2 == null ? void 0 : data2.patientLog) != null ? _o : null
750
+ };
751
+ return axios_default.post(END_POINT.END_CALL, payload, {
752
+ params: {
753
+ isBreak: (_p = data2 == null ? void 0 : data2.isBreak) != null ? _p : false
754
+ }
755
+ }).then((res) => {
756
+ sdkStateManager.resetConferenceLines();
757
+ sdkStateManager.endCall();
758
+ setData(res == null ? void 0 : res.data);
759
+ setSuccess(true);
760
+ return res == null ? void 0 : res.data;
761
+ }).catch((err) => {
762
+ var _a3;
763
+ setIsError(true);
764
+ setError(err);
765
+ return (_a3 = err == null ? void 0 : err.response) == null ? void 0 : _a3.data;
766
+ }).finally(() => {
767
+ setLoading(false);
768
+ });
769
+ },
770
+ []
771
+ );
772
+ return {
773
+ handleEndCall,
774
+ isLoading: loading,
775
+ isSuccess: success,
776
+ isError,
777
+ error,
778
+ data
779
+ };
780
+ };
781
+
782
+ // call-control-sdk/lib/hooks/useClickToCall.ts
783
+ var import_react3 = require("react");
784
+ var import_vault4 = require("@react-solutions/vault");
785
+ var useClickToCall = () => {
786
+ const [loading, setLoading] = (0, import_react3.useState)(false);
787
+ const [success, setSuccess] = (0, import_react3.useState)(false);
788
+ const [isError, setIsError] = (0, import_react3.useState)(false);
789
+ const [error, setError] = (0, import_react3.useState)(null);
790
+ const [data, setData] = (0, import_react3.useState)(null);
791
+ const handleStartCall = (0, import_react3.useCallback)(async (data2) => {
792
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
793
+ const state = (0, import_vault4.getItem)(STORAGE_KEY);
794
+ setLoading(true);
795
+ if (((_a2 = state == null ? void 0 : state.callData) == null ? void 0 : _a2.status) === "IDLE") {
796
+ const payload = {
797
+ action: "CALL",
798
+ userId: state == null ? void 0 : state.agentId,
799
+ phone_number: data2 == null ? void 0 : data2.mobileNumber
800
+ };
801
+ return axios_default.post(END_POINT.CLICK_TO_CALL, payload).then((res) => {
802
+ sdkStateManager.resetConferenceLines();
803
+ setData(res == null ? void 0 : res.data);
804
+ setSuccess(true);
805
+ return res == null ? void 0 : res.data;
806
+ }).catch((err) => {
807
+ var _a3;
808
+ setIsError(true);
809
+ setError(err);
810
+ return (_a3 = err == null ? void 0 : err.response) == null ? void 0 : _a3.data;
811
+ }).finally(() => {
812
+ setLoading(false);
813
+ });
814
+ } else if (((_b = state == null ? void 0 : state.callData) == null ? void 0 : _b.status) === "ONCALL") {
815
+ const line_used = (_d = (_c = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _c.filter((each) => each.line !== 1)) == null ? void 0 : _d.find((each) => each.status === "IDLE" && !(each == null ? void 0 : each.isCallStart));
816
+ const payload = {
817
+ action: "EXTERNAL_CONFERENCE",
818
+ operation: `CALL${line_used.line}`,
819
+ line_used: String(line_used.line),
820
+ thirdparty_no: data2 == null ? void 0 : data2.mobileNumber,
821
+ userid: (_f = (_e = state.callData) == null ? void 0 : _e.agent_id) != null ? _f : "",
822
+ process: (_h = (_g = state.callData) == null ? void 0 : _g.process_name) != null ? _h : ""
823
+ };
824
+ return axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
825
+ setData(res == null ? void 0 : res.data);
826
+ setSuccess(true);
827
+ sdkStateManager.setOpenConferenceDialog(true);
828
+ return res == null ? void 0 : res.data;
829
+ }).catch((err) => {
830
+ var _a3;
831
+ setIsError(true);
832
+ setError(err);
833
+ return (_a3 = err == null ? void 0 : err.response) == null ? void 0 : _a3.data;
834
+ }).finally(() => {
835
+ setLoading(false);
836
+ });
837
+ } else {
838
+ alert("Agent is not ready");
839
+ }
840
+ }, []);
841
+ return {
842
+ handleStartCall,
843
+ isLoading: loading,
844
+ isSuccess: success,
845
+ isError,
846
+ error,
847
+ data
848
+ };
849
+ };
850
+
851
+ // call-control-sdk/lib/hooks/useGetCallerData.ts
852
+ var import_react4 = require("react");
853
+ var useGetCallerData = () => {
854
+ const { process_id, process_name, status, phone_number, agent_id, convox_id } = sdkStateManager.getState().callData;
855
+ const initialCallData = {
856
+ phone_number,
857
+ status,
858
+ callReferenceId: convox_id,
859
+ agent_id,
860
+ process_id,
861
+ process_name
862
+ };
863
+ const [callData, setCallData] = (0, import_react4.useState)(initialCallData);
864
+ (0, import_react4.useEffect)(() => {
865
+ const unsubscribe = sdkStateManager.subscribe(() => {
866
+ const { process_id: process_id2, process_name: process_name2, status: status2, phone_number: phone_number2, agent_id: agent_id2, convox_id: convox_id2 } = sdkStateManager.getState().callData;
867
+ const currentCallData = {
868
+ phone_number: phone_number2,
869
+ status: status2,
870
+ callReferenceId: convox_id2,
871
+ agent_id: agent_id2,
872
+ process_id: process_id2,
873
+ process_name: process_name2
874
+ };
875
+ setCallData(currentCallData);
876
+ });
877
+ return unsubscribe;
878
+ }, []);
879
+ return callData;
880
+ };
881
+
882
+ // call-control-sdk/lib/hooks/useGetAuthorizationToken.ts
883
+ var import_react5 = require("react");
884
+ var useGetAuthorizationToken = () => {
885
+ const [token, setToken] = (0, import_react5.useState)(sdkStateManager.getSdkAuthToken());
886
+ (0, import_react5.useEffect)(() => {
887
+ const unsubscribe = sdkStateManager.subscribe(() => {
888
+ setToken(sdkStateManager.getSdkAuthToken());
889
+ });
890
+ return unsubscribe;
891
+ }, []);
892
+ return token;
893
+ };
894
+
895
+ // call-control-sdk/lib/components/callControlPanel.tsx
896
+ var import_react13 = require("react");
897
+
898
+ // call-control-sdk/lib/components/callControls.tsx
899
+ var import_icons_material2 = require("@mui/icons-material");
900
+ var import_material4 = require("@mui/material");
901
+ var import_react11 = require("react");
902
+
903
+ // call-control-sdk/lib/components/dialog.tsx
904
+ var import_icons_material = require("@mui/icons-material");
905
+ var import_material3 = require("@mui/material");
906
+ var import_react9 = require("react");
907
+
908
+ // call-control-sdk/lib/hooks/useSDKState.ts
909
+ var import_react6 = require("react");
910
+ function useSDKState() {
911
+ const [state, setState] = (0, import_react6.useState)(sdkStateManager.getState());
912
+ (0, import_react6.useEffect)(() => {
913
+ const unsubscribe = sdkStateManager.subscribe(() => {
914
+ setState(sdkStateManager.getState());
915
+ });
916
+ return unsubscribe;
917
+ }, []);
918
+ return state;
919
+ }
920
+
921
+ // call-control-sdk/lib/services/request.ts
922
+ var import_react8 = require("react");
923
+
924
+ // call-control-sdk/lib/services/toastMessage.tsx
925
+ var import_react7 = require("react");
926
+ var import_material = require("@mui/material");
927
+ var import_jsx_runtime = require("react/jsx-runtime");
928
+ var ToastContext = (0, import_react7.createContext)(void 0);
929
+ var useToast = () => {
930
+ const ctx = (0, import_react7.useContext)(ToastContext);
931
+ if (!ctx) throw new Error("useToast must be used inside ToastProvider");
932
+ return ctx;
933
+ };
934
+ var ToastProvider = ({ children }) => {
935
+ const [open, setOpen] = (0, import_react7.useState)(false);
936
+ const [message, setMessage] = (0, import_react7.useState)("");
937
+ const [severity, setSeverity] = (0, import_react7.useState)("info");
938
+ const showToast = (msg, sev = "info") => {
939
+ setMessage(msg);
940
+ setSeverity(sev);
941
+ setOpen(true);
942
+ };
943
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ToastContext.Provider, { value: { showToast }, children: [
944
+ children,
945
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
946
+ import_material.Snackbar,
947
+ {
948
+ open,
949
+ color: severity,
950
+ autoHideDuration: 3e3,
951
+ onClose: () => setOpen(false),
952
+ anchorOrigin: { vertical: "top", horizontal: "right" },
953
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
954
+ import_material.Alert,
955
+ {
956
+ variant: "filled",
957
+ severity,
958
+ onClose: () => setOpen(false),
959
+ sx: { width: "100%" },
960
+ children: message
961
+ }
962
+ )
963
+ }
964
+ )
965
+ ] });
966
+ };
967
+
968
+ // call-control-sdk/lib/services/request.ts
969
+ var initialState = {
970
+ isLoading: false,
971
+ isSuccess: false,
972
+ isError: false,
973
+ error: null,
974
+ data: null
975
+ };
976
+ var reducer = (state, action) => {
977
+ if (action.type === "isLoading") {
978
+ return __spreadProps(__spreadValues({}, state), {
979
+ isLoading: action.payload
980
+ });
981
+ } else if (action.type === "isSuccess") {
982
+ return __spreadProps(__spreadValues({}, state), {
983
+ isSuccess: true,
984
+ data: action.payload
985
+ });
986
+ } else if (action.type === "isError") {
987
+ return __spreadProps(__spreadValues({}, state), {
988
+ isError: true,
989
+ error: action.payload
990
+ });
991
+ } else if (action.type === "reset") {
992
+ return {
993
+ isLoading: false,
994
+ isSuccess: false,
995
+ isError: false,
996
+ error: null,
997
+ data: null
998
+ };
999
+ }
1000
+ throw Error("Unknown action.");
1001
+ };
1002
+ var useGetRequest = (props = {}) => {
1003
+ const { onSuccess = null, onError = null } = props;
1004
+ const { showToast } = useToast();
1005
+ const [state, dispatch] = (0, import_react8.useReducer)(reducer, initialState);
1006
+ const getRequest = (0, import_react8.useCallback)(
1007
+ (url, config = {}) => {
1008
+ dispatch({
1009
+ type: "isLoading",
1010
+ payload: true
1011
+ });
1012
+ axios_default.get(url, config).then((res) => {
1013
+ var _a2, _b;
1014
+ if ((_a2 = res.data) == null ? void 0 : _a2.success) {
1015
+ dispatch({
1016
+ type: "isSuccess",
1017
+ payload: res.data
1018
+ });
1019
+ onSuccess == null ? void 0 : onSuccess(res.data, config);
1020
+ } else {
1021
+ dispatch({
1022
+ type: "isError",
1023
+ payload: res.data
1024
+ });
1025
+ showToast((_b = res.data) == null ? void 0 : _b.message, "error");
1026
+ onError == null ? void 0 : onError(res.data, config);
1027
+ }
1028
+ }).catch((err) => {
1029
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1030
+ const error = {
1031
+ status: (_b = (_a2 = err.response) == null ? void 0 : _a2.status) != null ? _b : 500,
1032
+ message: ((_d = (_c = err.response) == null ? void 0 : _c.data) == null ? void 0 : _d.detail) || ((_f = (_e = err.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) || err.message || "An unknown error occurred",
1033
+ data: (_h = (_g = err.response) == null ? void 0 : _g.data) != null ? _h : null,
1034
+ statusText: (_j = (_i = err.response) == null ? void 0 : _i.statusText) != null ? _j : "",
1035
+ code: (_k = err == null ? void 0 : err.code) != null ? _k : "",
1036
+ name: (_l = err == null ? void 0 : err.name) != null ? _l : ""
1037
+ };
1038
+ showToast(error.message, "error");
1039
+ dispatch({
1040
+ type: "isError",
1041
+ payload: error
1042
+ });
1043
+ onError == null ? void 0 : onError(error, config);
1044
+ }).finally(() => {
1045
+ dispatch({
1046
+ type: "isLoading",
1047
+ payload: false
1048
+ });
1049
+ });
1050
+ },
1051
+ [onSuccess, onError, showToast]
1052
+ );
1053
+ return [getRequest, state];
1054
+ };
1055
+ var usePostRequest = (props = {}) => {
1056
+ const { onSuccess = null, onError = null, disabledSuccessToast = false } = props;
1057
+ const { showToast } = useToast();
1058
+ const [state, dispatch] = (0, import_react8.useReducer)(reducer, initialState);
1059
+ const postRequest = (0, import_react8.useCallback)(
1060
+ async (url, payload, config = {}) => {
1061
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1062
+ dispatch({
1063
+ type: "isLoading",
1064
+ payload: true
1065
+ });
1066
+ try {
1067
+ try {
1068
+ const res = await axios_default.post(url, payload, config);
1069
+ dispatch({
1070
+ type: "isSuccess",
1071
+ payload: res.data
1072
+ });
1073
+ onSuccess == null ? void 0 : onSuccess(res.data, payload);
1074
+ if (!disabledSuccessToast) {
1075
+ showToast((_a2 = res.data) == null ? void 0 : _a2.message, "success");
1076
+ }
1077
+ } catch (err) {
1078
+ const error = {
1079
+ status: (_c = (_b = err.response) == null ? void 0 : _b.status) != null ? _c : 500,
1080
+ message: ((_e = (_d = err.response) == null ? void 0 : _d.data) == null ? void 0 : _e.detail) || ((_g = (_f = err.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) || err.message || "An unknown error occurred",
1081
+ data: (_i = (_h = err.response) == null ? void 0 : _h.data) != null ? _i : null,
1082
+ statusText: (_k = (_j = err.response) == null ? void 0 : _j.statusText) != null ? _k : "",
1083
+ code: (_l = err == null ? void 0 : err.code) != null ? _l : "",
1084
+ name: (_m = err == null ? void 0 : err.name) != null ? _m : ""
1085
+ };
1086
+ showToast(error.message, "error");
1087
+ dispatch({
1088
+ type: "isError",
1089
+ payload: error
1090
+ });
1091
+ onError == null ? void 0 : onError(error, payload);
1092
+ }
1093
+ } finally {
1094
+ dispatch({
1095
+ type: "isLoading",
1096
+ payload: false
1097
+ });
1098
+ }
1099
+ },
1100
+ [onSuccess, onError, showToast]
1101
+ );
1102
+ return [postRequest, state];
1103
+ };
1104
+
1105
+ // call-control-sdk/lib/components/styles.ts
1106
+ var import_material2 = require("@mui/material");
1107
+ var useStyles = ({
1108
+ disabled,
1109
+ enabled,
1110
+ outlined
1111
+ }) => {
1112
+ const theme = (0, import_material2.useTheme)();
1113
+ return {
1114
+ disabled: __spreadValues({
1115
+ padding: "0px",
1116
+ margin: "0px",
1117
+ minWidth: "40px !important",
1118
+ borderRadius: "16px",
1119
+ border: `1px solid rgb(206, 204, 204)`,
1120
+ height: "40px",
1121
+ "&:hover": {
1122
+ boxShadow: " 0px 2px 2px rgba(0, 0, 0, 0.79)",
1123
+ border: `1px solid ${theme.palette.primary.main}`
1124
+ },
1125
+ "&:active": {
1126
+ bgcolor: "primary.main",
1127
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1128
+ }
1129
+ }, disabled),
1130
+ enabled: __spreadValues({
1131
+ padding: "0px",
1132
+ margin: "0px",
1133
+ minWidth: "40px !important",
1134
+ borderRadius: "16px",
1135
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
1136
+ border: `1px solid ${theme.palette.primary.main}`,
1137
+ height: "40px",
1138
+ "&:hover": {
1139
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
1140
+ border: `1px solid ${theme.palette.primary.main}`
1141
+ },
1142
+ "&:active": {
1143
+ bgcolor: "primary.main",
1144
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1145
+ }
1146
+ }, enabled),
1147
+ outlined: __spreadValues({
1148
+ padding: "0px",
1149
+ margin: "0px",
1150
+ minWidth: "40px !important",
1151
+ borderRadius: "16px",
1152
+ backgroundColor: theme.palette.grey[200],
1153
+ boxShadow: `0px 2px 1px ${theme.palette.primary.light}`,
1154
+ border: `0px solid ${theme.palette.primary.main}`,
1155
+ height: "40px",
1156
+ "&:hover": {
1157
+ boxShadow: `0px 2px 1px ${theme.palette.primary.main}`,
1158
+ border: `0px solid ${theme.palette.primary.main}`
1159
+ },
1160
+ "&:active": {
1161
+ bgcolor: "primary.main",
1162
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1163
+ }
1164
+ }, outlined)
1165
+ };
1166
+ };
1167
+ var styles_default = useStyles;
1168
+
1169
+ // call-control-sdk/lib/components/dialog.tsx
1170
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1171
+ var ConferenceTableRow = ({ each, isLineDialing }) => {
1172
+ var _a2, _b, _c, _d, _e, _f;
1173
+ const state = useSDKState();
1174
+ const theme = (0, import_material3.useTheme)();
1175
+ const { showToast } = useToast();
1176
+ const { disabled, enabled, outlined } = styles_default({
1177
+ disabled: ((_a2 = state.sdkConfig) == null ? void 0 : _a2.disabled) || {},
1178
+ enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
1179
+ outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
1180
+ });
1181
+ const [conferenceCallStart, setConferenceCallStart] = (0, import_react9.useState)(false);
1182
+ const [conferenceCallMerge, setConferenceCallMerge] = (0, import_react9.useState)(false);
1183
+ const [conferenceCallHoldOrUnHold, setConferenceCallHoldOrUnHold] = (0, import_react9.useState)(false);
1184
+ const [conferenceCallEnd, setConferenceCallEnd] = (0, import_react9.useState)(false);
1185
+ const onConferenceLineUpdate = (line, data) => {
1186
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1187
+ };
1188
+ const onConferenceCallStart = (line, data) => {
1189
+ var _a3, _b2, _c2, _d2;
1190
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1191
+ setConferenceCallStart(true);
1192
+ const payload = {
1193
+ action: "EXTERNAL_CONFERENCE",
1194
+ operation: `CALL${line_used.line}`,
1195
+ line_used: String(line_used.line),
1196
+ thirdparty_no: line_used.phone,
1197
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1198
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1199
+ };
1200
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
1201
+ var _a4;
1202
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1203
+ }).catch((err) => {
1204
+ var _a4, _b3, _c3, _d3;
1205
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1206
+ showToast(message, "error");
1207
+ }).finally(() => {
1208
+ setConferenceCallStart(false);
1209
+ });
1210
+ };
1211
+ const onMergeConferenceCall = (line, data) => {
1212
+ var _a3, _b2, _c2, _d2;
1213
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1214
+ setConferenceCallMerge(true);
1215
+ const payload = {
1216
+ action: "EXTERNAL_CONFERENCE",
1217
+ operation: `CONFERENCE`,
1218
+ line_used: String(line_used.line),
1219
+ thirdparty_no: line_used.phone,
1220
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1221
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1222
+ };
1223
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
1224
+ var _a4, _b3, _c3;
1225
+ if (((_a4 = state.callData) == null ? void 0 : _a4.hold) === 1) {
1226
+ handleHoldToggle();
1227
+ }
1228
+ if (((_b3 = state.callData) == null ? void 0 : _b3.mute) === 1) {
1229
+ handleMuteToggle();
1230
+ }
1231
+ showToast((_c3 = res.data) == null ? void 0 : _c3.message, "success");
1232
+ }).catch((err) => {
1233
+ var _a4, _b3, _c3, _d3;
1234
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1235
+ showToast(message, "error");
1236
+ }).finally(() => {
1237
+ setConferenceCallMerge(false);
1238
+ });
1239
+ };
1240
+ const onHoldOrUnHoldConferenceCall = (line, data, type) => {
1241
+ var _a3, _b2, _c2, _d2;
1242
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1243
+ setConferenceCallHoldOrUnHold(true);
1244
+ const payload = {
1245
+ action: "EXTERNAL_CONFERENCE",
1246
+ operation: type,
1247
+ hold_channel_no: type === "HOLDUSER" ? `hold${line_used.line}` : `unhold${line_used.line}`,
1248
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1249
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1250
+ };
1251
+ axios_default.post(END_POINT.CONFERENCE_CALL_HOLD_OR_UN_HOLD, payload).then((res) => {
1252
+ var _a4;
1253
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1254
+ }).catch((err) => {
1255
+ var _a4, _b3, _c3, _d3;
1256
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1257
+ showToast(message, "error");
1258
+ }).finally(() => {
1259
+ setConferenceCallHoldOrUnHold(false);
1260
+ });
1261
+ };
1262
+ const onEndConferenceCall = (line, data) => {
1263
+ var _a3, _b2, _c2, _d2;
1264
+ const line_used = __spreadValues(__spreadValues({}, line), data);
1265
+ setConferenceCallEnd(true);
1266
+ const payload = {
1267
+ action: "EXTERNAL_CONFERENCE",
1268
+ operation: "HANGUP_CHANNEL",
1269
+ line_used: String(line_used.line),
1270
+ user_type: `THIRDPARTY${line_used.line - 1}`,
1271
+ thirdparty_no: line_used.phone,
1272
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1273
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1274
+ };
1275
+ axios_default.post(END_POINT.CONFERENCE_CALL_END, payload).then((res) => {
1276
+ var _a4;
1277
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1278
+ }).catch((err) => {
1279
+ var _a4, _b3, _c3, _d3;
1280
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1281
+ showToast(message, "error");
1282
+ }).finally(() => {
1283
+ setConferenceCallEnd(false);
1284
+ });
1285
+ };
1286
+ const [holdOrUnHold] = usePostRequest();
1287
+ const [muteOrUnMute] = usePostRequest();
1288
+ const handleHoldToggle = () => {
1289
+ var _a3;
1290
+ const payload = {
1291
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" /* UNHOLD */ : "HOLD" /* HOLD */,
1292
+ userId: state.agentId
1293
+ };
1294
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
1295
+ };
1296
+ const handleMuteToggle = () => {
1297
+ var _a3;
1298
+ const payload = {
1299
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" /* UNMUTE */ : "MUTE" /* MUTE */,
1300
+ userId: state.agentId
1301
+ };
1302
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
1303
+ };
1304
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1305
+ import_material3.TableRow,
1306
+ {
1307
+ sx: {
1308
+ border: "2px solid #fff"
1309
+ },
1310
+ children: [
1311
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1312
+ import_material3.TableCell,
1313
+ {
1314
+ sx: {
1315
+ padding: "6px",
1316
+ flex: 1,
1317
+ width: "100px"
1318
+ },
1319
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Typography, { children: [
1320
+ "Line ",
1321
+ (_d = each == null ? void 0 : each.line) != null ? _d : "",
1322
+ ". "
1323
+ ] })
1324
+ }
1325
+ ),
1326
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1327
+ import_material3.TableCell,
1328
+ {
1329
+ sx: {
1330
+ padding: "6px",
1331
+ width: "150px"
1332
+ },
1333
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1334
+ import_material3.Typography,
1335
+ {
1336
+ variant: "body2",
1337
+ sx: {
1338
+ px: 1,
1339
+ borderRadius: "10px",
1340
+ width: "150px"
1341
+ },
1342
+ children: (_e = each == null ? void 0 : each.status) != null ? _e : ""
1343
+ }
1344
+ )
1345
+ }
1346
+ ),
1347
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1348
+ import_material3.TableCell,
1349
+ {
1350
+ sx: {
1351
+ padding: "6px",
1352
+ flex: 1
1353
+ },
1354
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1355
+ import_material3.TextField,
1356
+ {
1357
+ size: "small",
1358
+ placeholder: "Phone Number",
1359
+ fullWidth: true,
1360
+ value: (each == null ? void 0 : each.phone) || "",
1361
+ disabled: (each == null ? void 0 : each.line) === 1 || [
1362
+ "ONCALL" /* ONCALL */,
1363
+ "DISCONNECTED" /* DISCONNECTED */,
1364
+ "CONFERENCE" /* CONFERENCE */,
1365
+ "HOLD" /* HOLD */,
1366
+ "MUTE" /* MUTE */,
1367
+ "DIALING" /* DIALING */,
1368
+ "RINGING" /* RINGING */
1369
+ ].includes((_f = each == null ? void 0 : each.status) != null ? _f : "") || isLineDialing,
1370
+ onChange: (e) => {
1371
+ onConferenceLineUpdate(each, { phone: e.target.value });
1372
+ }
1373
+ }
1374
+ )
1375
+ }
1376
+ ),
1377
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1378
+ import_material3.TableCell,
1379
+ {
1380
+ sx: {
1381
+ padding: "6px",
1382
+ flex: 1
1383
+ },
1384
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1385
+ import_material3.Box,
1386
+ {
1387
+ sx: {
1388
+ width: "100%",
1389
+ display: "flex",
1390
+ alignItems: "center",
1391
+ justifyContent: "flex-start",
1392
+ gap: "10px"
1393
+ },
1394
+ children: [
1395
+ (each == null ? void 0 : each.line) === 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ ? "Hold" : "Resume", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1396
+ import_material3.Button,
1397
+ {
1398
+ variant: (each == null ? void 0 : each.status) === "HOLD" /* HOLD */ ? "contained" : "outlined",
1399
+ sx: (each == null ? void 0 : each.status) === "CONFERENCE" /* CONFERENCE */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1400
+ onClick: () => {
1401
+ if (each.status === "HOLD" /* HOLD */) {
1402
+ onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
1403
+ } else {
1404
+ onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
1405
+ }
1406
+ },
1407
+ disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" /* CONFERENCE */ && (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ || conferenceCallHoldOrUnHold,
1408
+ children: each.status === "HOLD" /* HOLD */ ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1409
+ import_material3.Box,
1410
+ {
1411
+ sx: {
1412
+ display: "flex",
1413
+ alignItems: "center",
1414
+ justifyContent: "center",
1415
+ gap: "5px",
1416
+ width: "98px"
1417
+ },
1418
+ children: [
1419
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1420
+ import_material3.Typography,
1421
+ {
1422
+ variant: "body2",
1423
+ sx: {
1424
+ fontSize: "12px",
1425
+ color: each.status === "HOLD" /* HOLD */ ? "#fff" : "initial"
1426
+ },
1427
+ children: "Unhold"
1428
+ }
1429
+ ),
1430
+ conferenceCallHoldOrUnHold ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1431
+ import_material3.CircularProgress,
1432
+ {
1433
+ size: "16px",
1434
+ sx: {
1435
+ color: theme.palette.primary.main
1436
+ }
1437
+ }
1438
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.PlayArrow, {})
1439
+ ]
1440
+ }
1441
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1442
+ import_material3.Box,
1443
+ {
1444
+ sx: {
1445
+ display: "flex",
1446
+ alignItems: "center",
1447
+ justifyContent: "center",
1448
+ gap: "5px",
1449
+ width: "98px"
1450
+ },
1451
+ children: [
1452
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1453
+ import_material3.Typography,
1454
+ {
1455
+ variant: "body2",
1456
+ sx: {
1457
+ color: each.status === "HOLD" /* HOLD */ ? "#fff" : "#000",
1458
+ fontSize: "12px"
1459
+ },
1460
+ children: "Hold"
1461
+ }
1462
+ ),
1463
+ conferenceCallHoldOrUnHold ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1464
+ import_material3.CircularProgress,
1465
+ {
1466
+ size: "16px",
1467
+ sx: {
1468
+ color: theme.palette.primary.main
1469
+ }
1470
+ }
1471
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Pause, {})
1472
+ ]
1473
+ }
1474
+ )
1475
+ }
1476
+ ) }),
1477
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1478
+ import_material3.Button,
1479
+ {
1480
+ variant: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ ? "outlined" : "contained",
1481
+ color: "success",
1482
+ sx: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ ? __spreadValues({}, disabled) : __spreadProps(__spreadValues({}, enabled), {
1483
+ border: `0px solid ${theme.palette.success.light}`,
1484
+ "&:hover": {
1485
+ bgcolor: "success.light",
1486
+ boxShadow: `0px 2px 1px ${theme.palette.success.light}`,
1487
+ border: `0px solid ${theme.palette.success.light}`
1488
+ },
1489
+ "&:active": {
1490
+ bgcolor: "success.light",
1491
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1492
+ }
1493
+ }),
1494
+ onClick: () => {
1495
+ onConferenceCallStart(each, {});
1496
+ },
1497
+ disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ || isLineDialing,
1498
+ children: conferenceCallStart ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1499
+ import_material3.CircularProgress,
1500
+ {
1501
+ size: "20px",
1502
+ color: "success"
1503
+ }
1504
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1505
+ import_icons_material.Call,
1506
+ {
1507
+ sx: {
1508
+ color: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ ? "default" : "#f3f2f2"
1509
+ }
1510
+ }
1511
+ )
1512
+ }
1513
+ ) }),
1514
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Merge Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1515
+ import_material3.Button,
1516
+ {
1517
+ variant: (each == null ? void 0 : each.status) === "ONCALL" /* ONCALL */ ? "contained" : "outlined",
1518
+ sx: (each == null ? void 0 : each.status) === "ONCALL" /* ONCALL */ ? __spreadValues({}, enabled) : __spreadValues({}, disabled),
1519
+ onClick: () => {
1520
+ onMergeConferenceCall(each, {
1521
+ isMergeCall: true
1522
+ });
1523
+ },
1524
+ disabled: (each == null ? void 0 : each.status) !== "ONCALL" /* ONCALL */,
1525
+ children: conferenceCallMerge ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.CircularProgress, { size: "20px" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallSplit, {})
1526
+ }
1527
+ ) }),
1528
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ ? "Hold" : "Resume", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1529
+ import_material3.Button,
1530
+ {
1531
+ variant: (each == null ? void 0 : each.status) === "HOLD" /* HOLD */ ? "contained" : "outlined",
1532
+ sx: (each == null ? void 0 : each.status) === "CONFERENCE" /* CONFERENCE */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1533
+ onClick: () => {
1534
+ if (each.status === "HOLD" /* HOLD */) {
1535
+ onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
1536
+ } else {
1537
+ onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
1538
+ }
1539
+ },
1540
+ disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" /* CONFERENCE */ && (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ || conferenceCallHoldOrUnHold,
1541
+ children: conferenceCallHoldOrUnHold ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1542
+ import_material3.CircularProgress,
1543
+ {
1544
+ size: "20px",
1545
+ sx: {
1546
+ color: theme.palette.primary.main
1547
+ }
1548
+ }
1549
+ ) : each.status === "HOLD" /* HOLD */ ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Pause, {})
1550
+ }
1551
+ ) }),
1552
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1553
+ import_material3.Button,
1554
+ {
1555
+ variant: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ && (each == null ? void 0 : each.status) !== "DISCONNECTED" /* DISCONNECTED */ ? "contained" : "outlined",
1556
+ color: "error",
1557
+ sx: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ && (each == null ? void 0 : each.status) !== "DISCONNECTED" /* DISCONNECTED */ ? __spreadProps(__spreadValues({}, enabled), {
1558
+ border: `0px solid ${theme.palette.error.light}`,
1559
+ "&:hover": {
1560
+ bgcolor: "error.light",
1561
+ boxShadow: `0px 2px 1px ${theme.palette.error.light}`,
1562
+ border: `0px solid ${theme.palette.error.light}`
1563
+ },
1564
+ "&:active": {
1565
+ bgcolor: "error.light",
1566
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1567
+ }
1568
+ }) : __spreadValues({}, disabled),
1569
+ onClick: () => {
1570
+ onEndConferenceCall(each, {
1571
+ isCallStart: false,
1572
+ isMergeCall: false,
1573
+ isMute: false,
1574
+ isHold: false
1575
+ });
1576
+ },
1577
+ disabled: (each == null ? void 0 : each.status) === "IDLE" /* IDLE */ || (each == null ? void 0 : each.status) === "DISCONNECTED" /* DISCONNECTED */ || conferenceCallEnd,
1578
+ children: conferenceCallEnd ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1579
+ import_material3.CircularProgress,
1580
+ {
1581
+ size: "20px",
1582
+ color: "error"
1583
+ }
1584
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallEnd, {})
1585
+ }
1586
+ ) })
1587
+ ]
1588
+ }
1589
+ )
1590
+ }
1591
+ )
1592
+ ]
1593
+ },
1594
+ each.line
1595
+ );
1596
+ };
1597
+ function ConferenceDialog() {
1598
+ var _a2, _b, _c, _d, _e, _f, _g;
1599
+ const state = useSDKState();
1600
+ const { showToast } = useToast();
1601
+ const [conferenceCallEndAll, setConferenceCallEndAll] = (0, import_react9.useState)(false);
1602
+ const handleClose = () => {
1603
+ sdkStateManager.setOpenConferenceDialog(false);
1604
+ };
1605
+ const onEndAllConferenceCalls = () => {
1606
+ var _a3, _b2, _c2, _d2;
1607
+ setConferenceCallEndAll(true);
1608
+ const payload = {
1609
+ action: "EXTERNAL_CONFERENCE",
1610
+ operation: "ENDCONFERENCE",
1611
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1612
+ process: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1613
+ };
1614
+ axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then((res) => {
1615
+ var _a4;
1616
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1617
+ sdkStateManager.resetConferenceLines();
1618
+ handleClose();
1619
+ }).catch((err) => {
1620
+ var _a4, _b3, _c3, _d3;
1621
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1622
+ showToast(message, "error");
1623
+ }).finally(() => {
1624
+ setConferenceCallEndAll(false);
1625
+ });
1626
+ };
1627
+ const handleTransferConferenceCall = () => {
1628
+ var _a3, _b2, _c2, _d2;
1629
+ const payload = {
1630
+ action: "TRANSFERAPI",
1631
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1632
+ process_name: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.process_name) != null ? _d2 : ""
1633
+ };
1634
+ axios_default.post(END_POINT.CONFERENCE_CALL_TRANSFER, payload).then((res) => {
1635
+ var _a4;
1636
+ showToast((_a4 = res.data) == null ? void 0 : _a4.message, "success");
1637
+ sdkStateManager.resetConferenceLines();
1638
+ handleClose();
1639
+ }).catch((err) => {
1640
+ var _a4, _b3, _c3, _d3;
1641
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1642
+ showToast(message, "error");
1643
+ });
1644
+ };
1645
+ const isLineDialing = (_a2 = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _a2.some((item) => (item == null ? void 0 : item.status) === "DIALING" /* DIALING */);
1646
+ const conferenceLineCount = (_d = (_c = (_b = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _b.filter((item) => (item == null ? void 0 : item.status) === "CONFERENCE" /* CONFERENCE */)) == null ? void 0 : _c.length) != null ? _d : 0;
1647
+ const isHold = (_e = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _e.some((item) => (item == null ? void 0 : item.status) === "HOLD" /* HOLD */);
1648
+ const isOnCall = (_f = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _f.some((item) => (item == null ? void 0 : item.status) === "ONCALL" /* ONCALL */);
1649
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1650
+ import_material3.Dialog,
1651
+ {
1652
+ open: state.openConferenceDialog,
1653
+ "aria-labelledby": "alert-dialog-title",
1654
+ "aria-describedby": "alert-dialog-description",
1655
+ maxWidth: "md",
1656
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
1657
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1658
+ import_material3.Box,
1659
+ {
1660
+ sx: {
1661
+ display: "flex",
1662
+ justifyContent: "space-between",
1663
+ alignItems: "center",
1664
+ padding: "0px 16px",
1665
+ paddingBottom: "6px",
1666
+ boxShadow: "1px 1px 2px #e7e5e5ff",
1667
+ margin: "10px 0px"
1668
+ },
1669
+ children: [
1670
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1671
+ import_material3.Typography,
1672
+ {
1673
+ variant: "body1",
1674
+ color: "primary.main",
1675
+ sx: { textTransform: "uppercase", fontWeight: "bold", fontSize: "14px" },
1676
+ children: [
1677
+ (_g = state == null ? void 0 : state.agentId) != null ? _g : "",
1678
+ " conference"
1679
+ ]
1680
+ }
1681
+ ),
1682
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Box, { children: [
1683
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1684
+ import_material3.Button,
1685
+ {
1686
+ color: "primary",
1687
+ variant: "outlined",
1688
+ onClick: handleTransferConferenceCall,
1689
+ disabled: conferenceLineCount <= 1 || isHold || isLineDialing || isOnCall,
1690
+ startIcon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.TransferWithinAStation, {}),
1691
+ children: "Exit Conference"
1692
+ }
1693
+ ),
1694
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1695
+ import_material3.IconButton,
1696
+ {
1697
+ onClick: handleClose,
1698
+ color: "primary",
1699
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, { sx: { color: "primary.main" } })
1700
+ }
1701
+ )
1702
+ ] })
1703
+ ]
1704
+ }
1705
+ ),
1706
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1707
+ import_material3.Box,
1708
+ {
1709
+ sx: {
1710
+ boxShadow: "1px 1px 2px #e7e5e5ff",
1711
+ margin: "0px 15px",
1712
+ borderRadius: "20px"
1713
+ },
1714
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1715
+ import_material3.TableContainer,
1716
+ {
1717
+ component: import_material3.Paper,
1718
+ sx: {
1719
+ outline: "0px solid gray !important",
1720
+ boxShadow: "1px 1px 6px #e7e5e5ff"
1721
+ },
1722
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1723
+ import_material3.Table,
1724
+ {
1725
+ sx: {
1726
+ border: "4px solid #ffffff !important"
1727
+ },
1728
+ children: [
1729
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1730
+ import_material3.TableRow,
1731
+ {
1732
+ sx: {
1733
+ border: "2px solid #f3f3f3ff !important"
1734
+ },
1735
+ children: [
1736
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1737
+ import_material3.TableCell,
1738
+ {
1739
+ sx: {
1740
+ padding: "6px"
1741
+ },
1742
+ children: "Line"
1743
+ }
1744
+ ),
1745
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1746
+ import_material3.TableCell,
1747
+ {
1748
+ sx: {
1749
+ padding: "6px"
1750
+ },
1751
+ children: "Status"
1752
+ }
1753
+ ),
1754
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1755
+ import_material3.TableCell,
1756
+ {
1757
+ sx: {
1758
+ padding: "6px"
1759
+ },
1760
+ children: "Mobile Number"
1761
+ }
1762
+ ),
1763
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1764
+ import_material3.TableCell,
1765
+ {
1766
+ sx: {
1767
+ padding: "6px"
1768
+ },
1769
+ children: "Call Actions"
1770
+ }
1771
+ )
1772
+ ]
1773
+ }
1774
+ ) }),
1775
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1776
+ ConferenceTableRow,
1777
+ {
1778
+ each,
1779
+ isLineDialing
1780
+ }
1781
+ )) })
1782
+ ]
1783
+ }
1784
+ )
1785
+ }
1786
+ )
1787
+ }
1788
+ ),
1789
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1790
+ import_material3.Box,
1791
+ {
1792
+ textAlign: "center",
1793
+ m: 2,
1794
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1795
+ import_material3.Button,
1796
+ {
1797
+ variant: "outlined",
1798
+ color: "error",
1799
+ size: "large",
1800
+ onClick: onEndAllConferenceCalls,
1801
+ disabled: conferenceCallEndAll || conferenceLineCount <= 0,
1802
+ sx: { px: 2, borderRadius: "20px", textTransform: "capitalize" },
1803
+ children: [
1804
+ conferenceCallEndAll ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1805
+ import_material3.CircularProgress,
1806
+ {
1807
+ size: "20px",
1808
+ color: "error",
1809
+ sx: {
1810
+ marginRight: "8px"
1811
+ }
1812
+ }
1813
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1814
+ import_material3.IconButton,
1815
+ {
1816
+ sx: {
1817
+ bgcolor: "error.main",
1818
+ "&:hover": { bgcolor: "error.dark" },
1819
+ marginRight: "8px",
1820
+ width: "28px",
1821
+ height: "28px",
1822
+ fontSize: "12px",
1823
+ fontWeight: "600",
1824
+ lineHeight: "16px",
1825
+ letterSpacing: "0.02em",
1826
+ textTransform: "capitalize",
1827
+ color: "white",
1828
+ display: "flex",
1829
+ alignItems: "center",
1830
+ justifyContent: "center",
1831
+ borderRadius: "50%"
1832
+ },
1833
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1834
+ import_icons_material.PhoneDisabled,
1835
+ {
1836
+ sx: {
1837
+ color: "white",
1838
+ fontSize: "16px",
1839
+ fontWeight: "600"
1840
+ }
1841
+ }
1842
+ )
1843
+ }
1844
+ ),
1845
+ "End Conference"
1846
+ ]
1847
+ }
1848
+ )
1849
+ }
1850
+ )
1851
+ ] })
1852
+ }
1853
+ ) });
1854
+ }
1855
+ function CallTransferDialog({ open }) {
1856
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1857
+ const state = useSDKState();
1858
+ const [mobileNumber, setMobileNumber] = (0, import_react9.useState)("");
1859
+ const [transferCall] = usePostRequest({
1860
+ onSuccess: () => {
1861
+ sdkStateManager.setOpenCallTransferDialog(false);
1862
+ }
1863
+ });
1864
+ const [blindTransferCall] = usePostRequest({
1865
+ onSuccess: () => {
1866
+ sdkStateManager.setOpenCallTransferDialog(false);
1867
+ }
1868
+ });
1869
+ const [currentselecteTab, setCurrentselecteTab] = (0, import_react9.useState)("process");
1870
+ const [getIdelAgentsList, { data: idleAgentsList, isLoading: isIdleAgentsListLoading }] = usePostRequest({
1871
+ disabledSuccessToast: true
1872
+ });
1873
+ const [
1874
+ getHospitalsServicesList,
1875
+ { data: hospitalsServicesList, isLoading: isHospitalsServicesListLoading }
1876
+ ] = useGetRequest({
1877
+ disabledSuccessToast: true
1878
+ });
1879
+ const [
1880
+ getProcessAndQueuesList,
1881
+ { data: processAndQueuesList, isLoading: isProcessAndQueuesListLoading }
1882
+ ] = usePostRequest({
1883
+ disabledSuccessToast: true
1884
+ });
1885
+ const handleClose = () => {
1886
+ sdkStateManager.setOpenCallTransferDialog(false);
1887
+ };
1888
+ const handleTransferCall = (data, type) => {
1889
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
1890
+ if (type === "PROCESS") {
1891
+ const payload = {
1892
+ mobile_number: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.phone_number) != null ? _b2 : "",
1893
+ userid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.agent_id) != null ? _d2 : "",
1894
+ type: "PROCESS",
1895
+ transfer_to: (_e2 = data == null ? void 0 : data.process_name) != null ? _e2 : "",
1896
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
1897
+ processid: String((_i2 = (_h2 = state.callData) == null ? void 0 : _h2.process_id) != null ? _i2 : ""),
1898
+ process_name: (_k2 = (_j2 = state.callData) == null ? void 0 : _j2.process_name) != null ? _k2 : ""
1899
+ };
1900
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1901
+ } else if (type === "QUEUE") {
1902
+ const payload = {
1903
+ mobile_number: (_m2 = (_l2 = state.callData) == null ? void 0 : _l2.phone_number) != null ? _m2 : "",
1904
+ userid: (_o2 = (_n2 = state.callData) == null ? void 0 : _n2.agent_id) != null ? _o2 : "",
1905
+ type: "QUEUE",
1906
+ transfer_to: (_p2 = data == null ? void 0 : data.queue_name) != null ? _p2 : "",
1907
+ callreferenceid: (_r2 = (_q2 = state.callData) == null ? void 0 : _q2.convox_id) != null ? _r2 : "",
1908
+ processid: String((_t2 = (_s2 = state.callData) == null ? void 0 : _s2.process_id) != null ? _t2 : ""),
1909
+ process_name: (_v = (_u2 = state.callData) == null ? void 0 : _u2.process_name) != null ? _v : ""
1910
+ };
1911
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1912
+ } else if (type === "AGENT") {
1913
+ const payload = {
1914
+ mobile_number: (_x = (_w = state.callData) == null ? void 0 : _w.phone_number) != null ? _x : "",
1915
+ userid: (_z = (_y = state.callData) == null ? void 0 : _y.agent_id) != null ? _z : "",
1916
+ type: "AGENT",
1917
+ transfer_to: (_A = data == null ? void 0 : data.user_id) != null ? _A : "",
1918
+ callreferenceid: (_C = (_B = state.callData) == null ? void 0 : _B.convox_id) != null ? _C : "",
1919
+ processid: String((_E = (_D = state.callData) == null ? void 0 : _D.process_id) != null ? _E : ""),
1920
+ process_name: (_G = (_F = state.callData) == null ? void 0 : _F.process_name) != null ? _G : ""
1921
+ };
1922
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1923
+ } else if (type === "OTHER") {
1924
+ const payload = {
1925
+ action: "BLIND_TRANSFER",
1926
+ userid: (_I = (_H = state.callData) == null ? void 0 : _H.agent_id) != null ? _I : "",
1927
+ callreferenceid: (_K = (_J = state.callData) == null ? void 0 : _J.convox_id) != null ? _K : "",
1928
+ blind_transfer_no: (_L = data == null ? void 0 : data.mobile_number) != null ? _L : ""
1929
+ };
1930
+ blindTransferCall(END_POINT.BLIEND_TRANSFER, payload);
1931
+ }
1932
+ };
1933
+ (0, import_react9.useEffect)(() => {
1934
+ getIdelAgentsList(END_POINT.AGENTS_LIST, {
1935
+ status: "IDLE",
1936
+ active: true
1937
+ });
1938
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
1939
+ status: "ACTIVE",
1940
+ active: true
1941
+ });
1942
+ getHospitalsServicesList(END_POINT.HOSPITALS_SERVICES);
1943
+ }, []);
1944
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1945
+ import_material3.Dialog,
1946
+ {
1947
+ open,
1948
+ "aria-labelledby": "alert-dialog-title",
1949
+ "aria-describedby": "alert-dialog-description",
1950
+ fullWidth: true,
1951
+ maxWidth: "sm",
1952
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
1953
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1954
+ import_material3.Box,
1955
+ {
1956
+ sx: {
1957
+ display: "flex",
1958
+ justifyContent: "space-between",
1959
+ alignItems: "center",
1960
+ padding: "4px 16px",
1961
+ boxShadow: "0px 1px 2px #f5f5f5ff"
1962
+ },
1963
+ children: [
1964
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Call Transfer" }),
1965
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
1966
+ ]
1967
+ }
1968
+ ),
1969
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1970
+ import_material3.Box,
1971
+ {
1972
+ sx: {
1973
+ margin: "10px",
1974
+ borderRadius: "10px"
1975
+ },
1976
+ children: [
1977
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Box, { sx: { display: "flex", gap: 1, margin: "10px" }, children: [
1978
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1979
+ import_material3.Button,
1980
+ {
1981
+ variant: currentselecteTab === "process" ? "contained" : "outlined",
1982
+ onClick: () => {
1983
+ setCurrentselecteTab("process");
1984
+ },
1985
+ children: "Process"
1986
+ }
1987
+ ),
1988
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1989
+ import_material3.Button,
1990
+ {
1991
+ variant: currentselecteTab === "queues" ? "contained" : "outlined",
1992
+ onClick: () => {
1993
+ setCurrentselecteTab("queues");
1994
+ },
1995
+ children: "Queues"
1996
+ }
1997
+ ),
1998
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1999
+ import_material3.Button,
2000
+ {
2001
+ variant: currentselecteTab === "agents" ? "contained" : "outlined",
2002
+ onClick: () => {
2003
+ setCurrentselecteTab("agents");
2004
+ getIdelAgentsList(END_POINT.AGENTS_LIST, {
2005
+ status: "IDLE",
2006
+ active: true
2007
+ });
2008
+ },
2009
+ children: "Agents"
2010
+ }
2011
+ ),
2012
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2013
+ import_material3.Button,
2014
+ {
2015
+ variant: currentselecteTab === "others" ? "contained" : "outlined",
2016
+ onClick: () => {
2017
+ setCurrentselecteTab("others");
2018
+ },
2019
+ children: "Others"
2020
+ }
2021
+ )
2022
+ ] }),
2023
+ (isProcessAndQueuesListLoading || isIdleAgentsListLoading || isHospitalsServicesListLoading) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2024
+ import_material3.Box,
2025
+ {
2026
+ sx: {
2027
+ display: "flex",
2028
+ justifyContent: "center",
2029
+ alignItems: "center",
2030
+ height: "80px"
2031
+ },
2032
+ children: [
2033
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.CircularProgress, {}),
2034
+ " "
2035
+ ]
2036
+ }
2037
+ ),
2038
+ !isProcessAndQueuesListLoading && !isIdleAgentsListLoading && !isHospitalsServicesListLoading && currentselecteTab === "process" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2039
+ import_material3.Box,
2040
+ {
2041
+ sx: {
2042
+ display: "grid",
2043
+ gridTemplateColumns: ((_a2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a2.process) && ((_c = (_b = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _b.process) == null ? void 0 : _c.length) > 0 ? "repeat(2, 1fr)" : "repeat(1, 1fr)",
2044
+ gap: 1,
2045
+ padding: "10px",
2046
+ flexWrap: "wrap",
2047
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2048
+ borderRadius: "10px"
2049
+ },
2050
+ children: ((_d = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _d.process) && ((_f = (_e = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _e.process) == null ? void 0 : _f.length) > 0 ? (_h = (_g = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _g.process) == null ? void 0 : _h.map((process, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2051
+ import_material3.Box,
2052
+ {
2053
+ sx: {
2054
+ p: 1,
2055
+ display: "flex",
2056
+ alignItems: "center",
2057
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2058
+ padding: "6px",
2059
+ borderRadius: "10px",
2060
+ "&:hover": { bgcolor: "action.selected" }
2061
+ },
2062
+ children: [
2063
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2064
+ import_material3.Typography,
2065
+ {
2066
+ variant: "body1",
2067
+ sx: {
2068
+ mx: 1,
2069
+ width: "200px",
2070
+ maxWidth: "250px",
2071
+ display: "flex",
2072
+ alignItems: "center"
2073
+ },
2074
+ children: [
2075
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.MemoryOutlined, { sx: { marginRight: "4px" } }),
2076
+ process.process_name
2077
+ ]
2078
+ }
2079
+ ),
2080
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2081
+ import_material3.IconButton,
2082
+ {
2083
+ color: "success",
2084
+ sx: {
2085
+ bgcolor: "action.hover",
2086
+ "&:hover": { bgcolor: "action.selected" }
2087
+ },
2088
+ onClick: () => {
2089
+ handleTransferCall(process, "PROCESS");
2090
+ },
2091
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2092
+ }
2093
+ )
2094
+ ]
2095
+ },
2096
+ index
2097
+ )) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2098
+ import_material3.Box,
2099
+ {
2100
+ sx: {
2101
+ display: "flex",
2102
+ alignItems: "center",
2103
+ justifyContent: "center",
2104
+ flexDirection: "column"
2105
+ },
2106
+ p: 2,
2107
+ children: [
2108
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Upcoming, { color: "primary" }),
2109
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2110
+ import_material3.Typography,
2111
+ {
2112
+ variant: "body1",
2113
+ sx: {
2114
+ fontSize: "16px",
2115
+ letterSpacing: "0.02em",
2116
+ textTransform: "capitalize",
2117
+ display: "flex",
2118
+ alignItems: "center",
2119
+ justifyContent: "center",
2120
+ width: "100%",
2121
+ margin: "10px 0px",
2122
+ color: "primary.main",
2123
+ height: "20px"
2124
+ },
2125
+ children: "No Process Found"
2126
+ }
2127
+ )
2128
+ ]
2129
+ }
2130
+ )
2131
+ }
2132
+ ),
2133
+ !isProcessAndQueuesListLoading && !isIdleAgentsListLoading && !isHospitalsServicesListLoading && currentselecteTab === "queues" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2134
+ import_material3.Box,
2135
+ {
2136
+ sx: {
2137
+ display: "grid",
2138
+ gridTemplateColumns: ((_i = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _i.queue) && ((_k = (_j = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _j.queue) == null ? void 0 : _k.length) > 0 ? "repeat(2, 1fr)" : "repeat(1, 1fr)",
2139
+ gap: 1,
2140
+ padding: "10px",
2141
+ flexWrap: "wrap",
2142
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2143
+ borderRadius: "10px"
2144
+ },
2145
+ children: ((_l = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _l.queue) && ((_n = (_m = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _m.queue) == null ? void 0 : _n.length) > 0 ? (_p = (_o = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _o.queue) == null ? void 0 : _p.map((queue, index) => {
2146
+ var _a3, _b2, _c2, _d2, _e2, _f2;
2147
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2148
+ import_material3.Box,
2149
+ {
2150
+ sx: {
2151
+ p: 1,
2152
+ display: "flex",
2153
+ alignItems: "center",
2154
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2155
+ padding: "6px",
2156
+ borderRadius: "10px",
2157
+ "&:hover": { bgcolor: "action.selected" }
2158
+ },
2159
+ children: [
2160
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2161
+ import_material3.Typography,
2162
+ {
2163
+ variant: "body1",
2164
+ sx: {
2165
+ mx: 1,
2166
+ width: "200px",
2167
+ maxWidth: "250px",
2168
+ display: "flex",
2169
+ alignItems: "center"
2170
+ },
2171
+ children: [
2172
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Airlines, { sx: { marginRight: "4px" } }),
2173
+ queue.queue_name,
2174
+ ((_c2 = (_b2 = (_a3 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a3.process) == null ? void 0 : _b2.find(
2175
+ (process) => process.process_id === queue.process_id
2176
+ )) == null ? void 0 : _c2.process_name) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2177
+ import_material3.Typography,
2178
+ {
2179
+ variant: "body1",
2180
+ sx: {
2181
+ fontSize: "12px",
2182
+ fontWeight: "600",
2183
+ letterSpacing: "0.02em",
2184
+ textTransform: "capitalize",
2185
+ color: "gray"
2186
+ },
2187
+ children: "(" + ((_f2 = (_e2 = (_d2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _d2.process) == null ? void 0 : _e2.find(
2188
+ (process) => process.process_id === queue.process_id
2189
+ )) == null ? void 0 : _f2.process_name) + ")"
2190
+ }
2191
+ ) : ""
2192
+ ]
2193
+ }
2194
+ ),
2195
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2196
+ import_material3.IconButton,
2197
+ {
2198
+ color: "success",
2199
+ sx: {
2200
+ bgcolor: "action.hover",
2201
+ "&:hover": { bgcolor: "action.selected" }
2202
+ },
2203
+ onClick: () => {
2204
+ handleTransferCall(queue, "QUEUE");
2205
+ },
2206
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2207
+ }
2208
+ )
2209
+ ]
2210
+ },
2211
+ index
2212
+ );
2213
+ }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2214
+ import_material3.Box,
2215
+ {
2216
+ sx: {
2217
+ display: "flex",
2218
+ alignItems: "center",
2219
+ justifyContent: "center",
2220
+ flexDirection: "column"
2221
+ },
2222
+ p: 2,
2223
+ children: [
2224
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Upcoming, { color: "primary" }),
2225
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2226
+ import_material3.Typography,
2227
+ {
2228
+ variant: "body1",
2229
+ sx: {
2230
+ fontSize: "16px",
2231
+ letterSpacing: "0.02em",
2232
+ textTransform: "capitalize",
2233
+ display: "flex",
2234
+ alignItems: "center",
2235
+ justifyContent: "center",
2236
+ width: "100%",
2237
+ margin: "10px 0px",
2238
+ color: "primary.main",
2239
+ height: "20px"
2240
+ },
2241
+ children: "No Queues Found"
2242
+ }
2243
+ )
2244
+ ]
2245
+ }
2246
+ )
2247
+ }
2248
+ ),
2249
+ !isProcessAndQueuesListLoading && !isIdleAgentsListLoading && !isHospitalsServicesListLoading && currentselecteTab === "agents" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2250
+ import_material3.Box,
2251
+ {
2252
+ sx: {
2253
+ display: "grid",
2254
+ gridTemplateColumns: (idleAgentsList == null ? void 0 : idleAgentsList.data) && ((_q = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _q.length) > 0 ? "repeat(2, 1fr)" : "repeat(1, 1fr)",
2255
+ gap: 1,
2256
+ padding: "10px",
2257
+ flexWrap: "wrap",
2258
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2259
+ borderRadius: "10px"
2260
+ },
2261
+ children: (idleAgentsList == null ? void 0 : idleAgentsList.data) && ((_r = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _r.length) > 0 ? (_s = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _s.map((agent, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2262
+ import_material3.Box,
2263
+ {
2264
+ sx: {
2265
+ p: 1,
2266
+ display: "flex",
2267
+ alignItems: "center",
2268
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2269
+ padding: "6px",
2270
+ borderRadius: "10px",
2271
+ "&:hover": { bgcolor: "action.selected" }
2272
+ },
2273
+ children: [
2274
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2275
+ import_material3.Typography,
2276
+ {
2277
+ variant: "body1",
2278
+ sx: {
2279
+ mx: 1,
2280
+ width: "200px",
2281
+ maxWidth: "250px",
2282
+ display: "flex",
2283
+ alignItems: "center"
2284
+ },
2285
+ children: [
2286
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2287
+ agent.name
2288
+ ]
2289
+ }
2290
+ ),
2291
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2292
+ import_material3.IconButton,
2293
+ {
2294
+ color: "success",
2295
+ sx: {
2296
+ bgcolor: "action.hover",
2297
+ "&:hover": { bgcolor: "action.selected" }
2298
+ },
2299
+ onClick: () => {
2300
+ handleTransferCall(agent, "AGENT");
2301
+ },
2302
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2303
+ }
2304
+ )
2305
+ ]
2306
+ },
2307
+ index
2308
+ )) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2309
+ import_material3.Box,
2310
+ {
2311
+ sx: {
2312
+ display: "flex",
2313
+ alignItems: "center",
2314
+ justifyContent: "center",
2315
+ flexDirection: "column"
2316
+ },
2317
+ p: 2,
2318
+ children: [
2319
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Upcoming, { color: "primary" }),
2320
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2321
+ import_material3.Typography,
2322
+ {
2323
+ variant: "body1",
2324
+ sx: {
2325
+ fontSize: "16px",
2326
+ letterSpacing: "0.02em",
2327
+ textTransform: "capitalize",
2328
+ display: "flex",
2329
+ alignItems: "center",
2330
+ justifyContent: "center",
2331
+ width: "100%",
2332
+ margin: "10px 0px",
2333
+ color: "primary.main",
2334
+ height: "20px"
2335
+ },
2336
+ children: "No Agents Found"
2337
+ }
2338
+ )
2339
+ ]
2340
+ }
2341
+ )
2342
+ }
2343
+ ),
2344
+ !isProcessAndQueuesListLoading && !isIdleAgentsListLoading && !isHospitalsServicesListLoading && currentselecteTab === "others" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2345
+ import_material3.Box,
2346
+ {
2347
+ sx: {
2348
+ display: "grid",
2349
+ gridTemplateColumns: "repeat(2, 1fr)",
2350
+ gap: 1,
2351
+ padding: "10px",
2352
+ flexWrap: "wrap",
2353
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2354
+ borderRadius: "10px"
2355
+ },
2356
+ children: [
2357
+ (hospitalsServicesList == null ? void 0 : hospitalsServicesList.data) && ((_t = hospitalsServicesList == null ? void 0 : hospitalsServicesList.data) == null ? void 0 : _t.length) > 0 && ((_u = hospitalsServicesList == null ? void 0 : hospitalsServicesList.data) == null ? void 0 : _u.map((service, index) => {
2358
+ var _a3, _b2, _c2;
2359
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2360
+ import_material3.Box,
2361
+ {
2362
+ sx: {
2363
+ p: 1,
2364
+ display: "flex",
2365
+ alignItems: "center",
2366
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2367
+ padding: "6px",
2368
+ borderRadius: "10px",
2369
+ "&:hover": { bgcolor: "action.selected" }
2370
+ },
2371
+ children: [
2372
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2373
+ import_material3.Typography,
2374
+ {
2375
+ variant: "body1",
2376
+ sx: {
2377
+ mx: 1,
2378
+ width: "200px",
2379
+ maxWidth: "250px",
2380
+ display: "flex",
2381
+ alignItems: "center"
2382
+ },
2383
+ children: [
2384
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Roofing, { sx: { marginRight: "4px" } }),
2385
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: `${(_a3 = service == null ? void 0 : service.description) != null ? _a3 : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Box, { sx: { color: "text.secondary" }, children: [
2386
+ service.name,
2387
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2388
+ import_material3.Box,
2389
+ {
2390
+ sx: {
2391
+ fontSize: "9px",
2392
+ fontWeight: "600",
2393
+ letterSpacing: "0.02em",
2394
+ textTransform: "capitalize",
2395
+ color: "gray",
2396
+ textOverflow: "ellipsis",
2397
+ whiteSpace: "nowrap",
2398
+ overflow: "hidden",
2399
+ maxWidth: "160px"
2400
+ },
2401
+ children: (_b2 = service == null ? void 0 : service.description) != null ? _b2 : ""
2402
+ }
2403
+ )
2404
+ ] }) })
2405
+ ]
2406
+ }
2407
+ ),
2408
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (_c2 = service == null ? void 0 : service.phone_number) != null ? _c2 : "", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2409
+ import_material3.IconButton,
2410
+ {
2411
+ color: "success",
2412
+ sx: {
2413
+ bgcolor: "action.hover",
2414
+ "&:hover": { bgcolor: "action.selected" }
2415
+ },
2416
+ onClick: () => {
2417
+ var _a4;
2418
+ handleTransferCall(
2419
+ {
2420
+ mobile_number: (_a4 = service == null ? void 0 : service.phone_number) != null ? _a4 : ""
2421
+ },
2422
+ "OTHER"
2423
+ );
2424
+ },
2425
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2426
+ }
2427
+ ) })
2428
+ ]
2429
+ },
2430
+ index
2431
+ );
2432
+ })),
2433
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2434
+ import_material3.Box,
2435
+ {
2436
+ sx: {
2437
+ p: 1,
2438
+ display: "flex",
2439
+ alignItems: "center",
2440
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2441
+ padding: "6px",
2442
+ borderRadius: "10px"
2443
+ },
2444
+ children: [
2445
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2446
+ import_material3.Typography,
2447
+ {
2448
+ variant: "body1",
2449
+ sx: {
2450
+ mx: 1,
2451
+ width: "200px",
2452
+ maxWidth: "250px",
2453
+ display: "flex",
2454
+ alignItems: "center"
2455
+ },
2456
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2457
+ import_material3.TextField,
2458
+ {
2459
+ size: "small",
2460
+ name: "others",
2461
+ label: "Mobile number",
2462
+ variant: "outlined",
2463
+ type: "tel",
2464
+ value: mobileNumber,
2465
+ onChange: (e) => {
2466
+ const v = e.target.value;
2467
+ if (/^\d*$/.test(v)) {
2468
+ setMobileNumber(v);
2469
+ }
2470
+ },
2471
+ slotProps: {
2472
+ htmlInput: {
2473
+ inputMode: "numeric",
2474
+ maxLength: 11
2475
+ }
2476
+ },
2477
+ placeholder: "Enter mobile number",
2478
+ autoComplete: "off"
2479
+ }
2480
+ )
2481
+ }
2482
+ ),
2483
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2484
+ import_material3.Tooltip,
2485
+ {
2486
+ title: mobileNumber ? `Call To - ${mobileNumber}` : "Enter mobile number",
2487
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2488
+ import_material3.IconButton,
2489
+ {
2490
+ color: "success",
2491
+ sx: {
2492
+ bgcolor: "action.hover",
2493
+ "&:hover": { bgcolor: "action.selected" }
2494
+ },
2495
+ onClick: () => {
2496
+ handleTransferCall(
2497
+ {
2498
+ mobile_number: mobileNumber != null ? mobileNumber : ""
2499
+ },
2500
+ "OTHER"
2501
+ );
2502
+ },
2503
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Call, {})
2504
+ }
2505
+ )
2506
+ }
2507
+ )
2508
+ ]
2509
+ }
2510
+ )
2511
+ ]
2512
+ }
2513
+ )
2514
+ ]
2515
+ }
2516
+ )
2517
+ ] })
2518
+ }
2519
+ ) });
2520
+ }
2521
+ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2522
+ var _a2, _b, _c, _d, _e;
2523
+ const [getDispositions, data] = useGetRequest();
2524
+ const [formData, setFormData] = (0, import_react9.useState)({
2525
+ disposition: { label: "Resolved", value: "RES" },
2526
+ followUp: { label: "No", value: "N" },
2527
+ callbackDate: "",
2528
+ callbackHrs: "",
2529
+ callbackMins: "",
2530
+ selected_break: false
2531
+ });
2532
+ const followUpOptions = [
2533
+ { label: "Yes", value: "Y" },
2534
+ { label: "No", value: "N" }
2535
+ ];
2536
+ const handleChange = (field, value) => {
2537
+ setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [field]: value }));
2538
+ };
2539
+ const handleReset = () => {
2540
+ setFormData({
2541
+ disposition: { label: "Resolved", value: "RES" },
2542
+ followUp: { label: "No", value: "N" },
2543
+ callbackDate: "",
2544
+ callbackHrs: "",
2545
+ callbackMins: "",
2546
+ selected_break: false
2547
+ });
2548
+ };
2549
+ const handleClose = () => {
2550
+ handleReset();
2551
+ setOpen(false);
2552
+ };
2553
+ (0, import_react9.useEffect)(() => {
2554
+ getDispositions(END_POINT.DISPOSITIONS);
2555
+ }, []);
2556
+ const dispositionsOptions = (0, import_react9.useMemo)(() => {
2557
+ var _a3, _b2;
2558
+ return ((_b2 = (_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.data) == null ? void 0 : _b2.map((item) => ({
2559
+ label: item.name,
2560
+ value: item.code
2561
+ }))) || [];
2562
+ }, [(_a2 = data == null ? void 0 : data.data) == null ? void 0 : _a2.data]);
2563
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2564
+ import_material3.Dialog,
2565
+ {
2566
+ open,
2567
+ "aria-labelledby": "alert-dialog-title",
2568
+ "aria-describedby": "alert-dialog-description",
2569
+ fullWidth: true,
2570
+ maxWidth: "xs",
2571
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2572
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2573
+ import_material3.Box,
2574
+ {
2575
+ sx: {
2576
+ display: "flex",
2577
+ justifyContent: "center",
2578
+ alignItems: "center",
2579
+ padding: "4px 16px",
2580
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2581
+ },
2582
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2583
+ import_material3.Typography,
2584
+ {
2585
+ variant: "body1",
2586
+ m: 1,
2587
+ children: [
2588
+ " ",
2589
+ "Call Disposition"
2590
+ ]
2591
+ }
2592
+ )
2593
+ }
2594
+ ),
2595
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2596
+ import_material3.Box,
2597
+ {
2598
+ sx: {
2599
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2600
+ padding: "10px",
2601
+ margin: "10px",
2602
+ borderRadius: "10px"
2603
+ },
2604
+ children: [
2605
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2606
+ import_material3.Box,
2607
+ {
2608
+ display: "flex",
2609
+ gap: 2,
2610
+ children: [
2611
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2612
+ import_material3.Autocomplete,
2613
+ {
2614
+ value: formData.disposition,
2615
+ options: dispositionsOptions,
2616
+ getOptionLabel: (opt) => opt.label,
2617
+ onChange: (_, val) => handleChange("disposition", val),
2618
+ size: "small",
2619
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2620
+ import_material3.TextField,
2621
+ __spreadProps(__spreadValues({}, params), {
2622
+ label: "Disposition",
2623
+ fullWidth: true
2624
+ })
2625
+ ),
2626
+ sx: { flex: 1 }
2627
+ }
2628
+ ),
2629
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2630
+ import_material3.Autocomplete,
2631
+ {
2632
+ options: followUpOptions,
2633
+ getOptionLabel: (opt) => opt.label,
2634
+ value: formData.followUp,
2635
+ onChange: (_, val) => handleChange("followUp", val),
2636
+ size: "small",
2637
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2638
+ import_material3.TextField,
2639
+ __spreadProps(__spreadValues({}, params), {
2640
+ label: "Follow Up",
2641
+ fullWidth: true
2642
+ })
2643
+ ),
2644
+ sx: { flex: 1 }
2645
+ }
2646
+ )
2647
+ ]
2648
+ }
2649
+ ),
2650
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2651
+ import_material3.Box,
2652
+ {
2653
+ display: "flex",
2654
+ gap: 2,
2655
+ mt: 2,
2656
+ children: [
2657
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2658
+ import_material3.Box,
2659
+ {
2660
+ sx: {
2661
+ flex: "1",
2662
+ border: "1px solid #bdbdbd",
2663
+ borderRadius: "5px"
2664
+ },
2665
+ children: [
2666
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2667
+ import_material3.Checkbox,
2668
+ {
2669
+ name: "selected_break",
2670
+ sx: {
2671
+ padding: "6px"
2672
+ },
2673
+ checked: formData.selected_break,
2674
+ onChange: (event) => {
2675
+ handleChange("selected_break", event.target.checked);
2676
+ },
2677
+ slotProps: {
2678
+ input: { "aria-label": "controlled" }
2679
+ }
2680
+ }
2681
+ ),
2682
+ " ",
2683
+ "Mark as break"
2684
+ ]
2685
+ }
2686
+ ),
2687
+ ((_c = (_b = formData == null ? void 0 : formData.followUp) == null ? void 0 : _b.label) == null ? void 0 : _c.toLowerCase()) === "yes" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2688
+ import_material3.TextField,
2689
+ {
2690
+ size: "small",
2691
+ label: "Callback Date",
2692
+ type: "date",
2693
+ slotProps: {
2694
+ inputLabel: { shrink: true }
2695
+ },
2696
+ value: formData.callbackDate,
2697
+ onChange: (e) => handleChange("callbackDate", e.target.value),
2698
+ fullWidth: true,
2699
+ sx: { flex: 1 }
2700
+ }
2701
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { flex: 1 } })
2702
+ ]
2703
+ }
2704
+ ),
2705
+ ((_e = (_d = formData == null ? void 0 : formData.followUp) == null ? void 0 : _d.label) == null ? void 0 : _e.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2706
+ import_material3.Box,
2707
+ {
2708
+ display: "flex",
2709
+ gap: 2,
2710
+ mt: 2,
2711
+ children: [
2712
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2713
+ import_material3.TextField,
2714
+ {
2715
+ size: "small",
2716
+ label: "Hours (0-23)",
2717
+ type: "text",
2718
+ value: formData.callbackHrs,
2719
+ onChange: (e) => handleChange("callbackHrs", e.target.value),
2720
+ fullWidth: true,
2721
+ sx: { flex: 1 }
2722
+ }
2723
+ ),
2724
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2725
+ import_material3.TextField,
2726
+ {
2727
+ size: "small",
2728
+ label: "Minutes (0-59)",
2729
+ type: "text",
2730
+ value: formData.callbackMins,
2731
+ onChange: (e) => handleChange("callbackMins", e.target.value),
2732
+ fullWidth: true,
2733
+ sx: { flex: 1 }
2734
+ }
2735
+ )
2736
+ ]
2737
+ }
2738
+ )
2739
+ ]
2740
+ }
2741
+ ),
2742
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2743
+ import_material3.Box,
2744
+ {
2745
+ textAlign: "right",
2746
+ m: 2,
2747
+ children: [
2748
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2749
+ import_material3.Button,
2750
+ {
2751
+ variant: "outlined",
2752
+ color: "error",
2753
+ size: "large",
2754
+ onClick: handleClose,
2755
+ sx: {
2756
+ px: 2,
2757
+ mx: 1,
2758
+ borderRadius: "10px",
2759
+ textTransform: "capitalize"
2760
+ },
2761
+ children: "cancel"
2762
+ }
2763
+ ),
2764
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2765
+ import_material3.Button,
2766
+ {
2767
+ variant: "contained",
2768
+ color: "primary",
2769
+ size: "large",
2770
+ onClick: () => onSubmitDisposition(formData),
2771
+ sx: { px: 2, borderRadius: "10px", textTransform: "capitalize" },
2772
+ children: "Submit"
2773
+ }
2774
+ )
2775
+ ]
2776
+ }
2777
+ )
2778
+ ] })
2779
+ }
2780
+ ) });
2781
+ }
2782
+ function ProcessorListDialog({
2783
+ open,
2784
+ setOpen,
2785
+ processList = null,
2786
+ handleSelectedProcessor
2787
+ }) {
2788
+ const handleClose = () => {
2789
+ setOpen(false);
2790
+ };
2791
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2792
+ import_material3.Dialog,
2793
+ {
2794
+ open,
2795
+ "aria-labelledby": "alert-dialog-title",
2796
+ "aria-describedby": "alert-dialog-description",
2797
+ maxWidth: "xs",
2798
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2799
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2800
+ import_material3.Box,
2801
+ {
2802
+ sx: {
2803
+ display: "flex",
2804
+ justifyContent: "space-between",
2805
+ alignItems: "center",
2806
+ padding: "4px 16px",
2807
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2808
+ },
2809
+ children: [
2810
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Process List" }),
2811
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2812
+ ]
2813
+ }
2814
+ ),
2815
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2816
+ import_material3.Box,
2817
+ {
2818
+ sx: {
2819
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2820
+ padding: "6px 10px",
2821
+ margin: "10px",
2822
+ borderRadius: "10px"
2823
+ },
2824
+ children: processList.length > 0 ? processList == null ? void 0 : processList.map((process, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2825
+ import_material3.Box,
2826
+ {
2827
+ sx: {
2828
+ p: 1,
2829
+ display: "flex",
2830
+ alignItems: "center",
2831
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2832
+ padding: "6px",
2833
+ margin: "10px 0px",
2834
+ borderRadius: "10px",
2835
+ cursor: "pointer",
2836
+ "&:hover": { bgcolor: "action.selected" }
2837
+ },
2838
+ onClick: () => {
2839
+ handleSelectedProcessor(process);
2840
+ },
2841
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2842
+ import_material3.Typography,
2843
+ {
2844
+ variant: "body1",
2845
+ sx: {
2846
+ mx: 1,
2847
+ width: "200px",
2848
+ maxWidth: "250px",
2849
+ display: "flex",
2850
+ alignItems: "center"
2851
+ },
2852
+ children: [
2853
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.SupportAgent, { sx: { marginRight: "4px" } }),
2854
+ process.process_name
2855
+ ]
2856
+ }
2857
+ )
2858
+ },
2859
+ index
2860
+ )) : null
2861
+ }
2862
+ )
2863
+ ] })
2864
+ }
2865
+ ) });
2866
+ }
2867
+ function CallHistoryDialog({ open, setOpen }) {
2868
+ const handleClose = () => {
2869
+ setOpen(false);
2870
+ };
2871
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2872
+ import_material3.Dialog,
2873
+ {
2874
+ open,
2875
+ "aria-labelledby": "alert-dialog-title",
2876
+ "aria-describedby": "alert-dialog-description",
2877
+ fullWidth: true,
2878
+ maxWidth: "md",
2879
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Paper, { sx: { borderRadius: 2 }, children: [
2880
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2881
+ import_material3.Box,
2882
+ {
2883
+ sx: {
2884
+ display: "flex",
2885
+ justifyContent: "space-between",
2886
+ alignItems: "center",
2887
+ padding: "4px 16px",
2888
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2889
+ },
2890
+ children: [
2891
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Typography, { variant: "body1", children: " Call History" }),
2892
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
2893
+ ]
2894
+ }
2895
+ ),
2896
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2897
+ import_material3.Box,
2898
+ {
2899
+ sx: {
2900
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2901
+ margin: "10px",
2902
+ borderRadius: "10px",
2903
+ textAlign: "center",
2904
+ fontSize: "16px",
2905
+ fontWeight: "bold"
2906
+ },
2907
+ p: 6,
2908
+ children: "Coming Soon..."
2909
+ }
2910
+ )
2911
+ ] })
2912
+ }
2913
+ ) });
2914
+ }
2915
+
2916
+ // call-control-sdk/lib/hooks/useDraggable.ts
2917
+ var import_react10 = require("react");
2918
+ function useDraggable(initialPosition, onPositionChange) {
2919
+ const [position, setPosition] = (0, import_react10.useState)(initialPosition);
2920
+ const [isDragging, setIsDragging] = (0, import_react10.useState)(false);
2921
+ const dragRef = (0, import_react10.useRef)();
2922
+ const dragStart = (0, import_react10.useRef)({ x: 0, y: 0 });
2923
+ const elementStart = (0, import_react10.useRef)({ x: 0, y: 0 });
2924
+ const updatePosition = (0, import_react10.useCallback)(
2925
+ (newPosition) => {
2926
+ const element = dragRef.current;
2927
+ if (!element) return;
2928
+ const rect = element.getBoundingClientRect();
2929
+ const viewportWidth = window.innerWidth;
2930
+ const viewportHeight = window.innerHeight;
2931
+ const constrainedPosition = {
2932
+ x: Math.max(0, Math.min(newPosition.x, viewportWidth - rect.width)),
2933
+ y: Math.max(0, Math.min(newPosition.y, viewportHeight - rect.height))
2934
+ };
2935
+ setPosition(constrainedPosition);
2936
+ onPositionChange == null ? void 0 : onPositionChange(constrainedPosition);
2937
+ },
2938
+ [onPositionChange]
2939
+ );
2940
+ const handleStart = (0, import_react10.useCallback)(
2941
+ (clientX, clientY) => {
2942
+ setIsDragging(true);
2943
+ dragStart.current = { x: clientX, y: clientY };
2944
+ elementStart.current = position;
2945
+ const handleMove = (moveClientX, moveClientY) => {
2946
+ const deltaX = moveClientX - dragStart.current.x;
2947
+ const deltaY = moveClientY - dragStart.current.y;
2948
+ updatePosition({
2949
+ x: elementStart.current.x + deltaX,
2950
+ y: elementStart.current.y + deltaY
2951
+ });
2952
+ };
2953
+ const handleMouseMove = (e) => {
2954
+ e.preventDefault();
2955
+ handleMove(e.clientX, e.clientY);
2956
+ };
2957
+ const handleTouchMove = (e) => {
2958
+ e.preventDefault();
2959
+ const touch = e.touches[0];
2960
+ if (touch) {
2961
+ handleMove(touch.clientX, touch.clientY);
2962
+ }
2963
+ };
2964
+ const handleEnd = () => {
2965
+ setIsDragging(false);
2966
+ document.removeEventListener("mousemove", handleMouseMove);
2967
+ document.removeEventListener("mouseup", handleEnd);
2968
+ document.removeEventListener("touchmove", handleTouchMove);
2969
+ document.removeEventListener("touchend", handleEnd);
2970
+ };
2971
+ document.addEventListener("mousemove", handleMouseMove);
2972
+ document.addEventListener("mouseup", handleEnd);
2973
+ document.addEventListener("touchmove", handleTouchMove, {
2974
+ passive: false
2975
+ });
2976
+ document.addEventListener("touchend", handleEnd);
2977
+ },
2978
+ [position, updatePosition]
2979
+ );
2980
+ const handleMouseDown = (0, import_react10.useCallback)(
2981
+ (e) => {
2982
+ e.preventDefault();
2983
+ handleStart(e.clientX, e.clientY);
2984
+ },
2985
+ [handleStart]
2986
+ );
2987
+ const handleTouchStart = (0, import_react10.useCallback)(
2988
+ (e) => {
2989
+ e.preventDefault();
2990
+ const touch = e.touches[0];
2991
+ if (touch) {
2992
+ handleStart(touch.clientX, touch.clientY);
2993
+ }
2994
+ },
2995
+ [handleStart]
2996
+ );
2997
+ return {
2998
+ position,
2999
+ isDragging,
3000
+ dragRef,
3001
+ handleMouseDown,
3002
+ handleTouchStart
3003
+ };
3004
+ }
3005
+
3006
+ // call-control-sdk/lib/services/micController.ts
3007
+ function createMicController(constraints = { audio: true }) {
3008
+ let stream = null;
3009
+ let muted = false;
3010
+ async function start() {
3011
+ if (stream) return;
3012
+ stream = await navigator.mediaDevices.getUserMedia(constraints);
3013
+ stream.getAudioTracks().forEach((track) => track.enabled = true);
3014
+ muted = false;
3015
+ }
3016
+ function setEnabled(enabled) {
3017
+ if (!stream) return;
3018
+ stream.getAudioTracks().forEach((track) => track.enabled = enabled);
3019
+ muted = !enabled;
3020
+ }
3021
+ function mute() {
3022
+ setEnabled(false);
3023
+ }
3024
+ function unmute() {
3025
+ setEnabled(true);
3026
+ }
3027
+ function toggleMute() {
3028
+ if (muted) {
3029
+ unmute();
3030
+ } else {
3031
+ mute();
3032
+ }
3033
+ }
3034
+ function stop() {
3035
+ if (!stream) return;
3036
+ stream.getTracks().forEach((t) => t.stop());
3037
+ stream = null;
3038
+ muted = false;
3039
+ }
3040
+ function isMuted() {
3041
+ return muted;
3042
+ }
3043
+ function getStream() {
3044
+ return stream;
3045
+ }
3046
+ return {
3047
+ start,
3048
+ stop,
3049
+ mute,
3050
+ unmute,
3051
+ toggleMute,
3052
+ isMuted,
3053
+ getStream
3054
+ };
3055
+ }
3056
+
3057
+ // call-control-sdk/lib/utils/audioLoader.ts
3058
+ var import_incoming = __toESM(require("./incoming-4WP3FJI4.mp3"));
3059
+ var audioBlobUrl = null;
3060
+ var audioBuffer = null;
3061
+ async function loadAudioAsBlob() {
3062
+ if (audioBlobUrl) {
3063
+ return audioBlobUrl;
3064
+ }
3065
+ if (import_incoming.default.startsWith("data:") || import_incoming.default.startsWith("http://") || import_incoming.default.startsWith("https://") || import_incoming.default.startsWith("blob:")) {
3066
+ return import_incoming.default;
3067
+ }
3068
+ try {
3069
+ const response = await fetch(import_incoming.default);
3070
+ if (!response.ok) {
3071
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
3072
+ }
3073
+ const blob = await response.blob();
3074
+ if (blob.size === 0) {
3075
+ throw new Error("Empty blob");
3076
+ }
3077
+ audioBlobUrl = URL.createObjectURL(blob);
3078
+ return audioBlobUrl;
3079
+ } catch (error) {
3080
+ console.error("Could not create blob URL, using direct URL:", error);
3081
+ return import_incoming.default;
3082
+ }
3083
+ }
3084
+ async function createAudioElement() {
3085
+ const audio = new Audio();
3086
+ audio.loop = true;
3087
+ audio.volume = 0.7;
3088
+ audio.preload = "auto";
3089
+ let audioUrl = "";
3090
+ try {
3091
+ audioUrl = await loadAudioAsBlob();
3092
+ } catch (error) {
3093
+ console.warn("Failed to load audio as blob, trying direct URL:", error);
3094
+ audioUrl = import_incoming.default;
3095
+ }
3096
+ const tryLoadAudio = async (url) => {
3097
+ return new Promise((resolve) => {
3098
+ const checkCanPlay = () => {
3099
+ const canPlay = audio.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;
3100
+ if (canPlay) {
3101
+ resolve(true);
3102
+ return;
3103
+ }
3104
+ if (audio.error) {
3105
+ resolve(false);
3106
+ return;
3107
+ }
3108
+ setTimeout(checkCanPlay, 100);
3109
+ };
3110
+ audio.addEventListener("canplay", () => resolve(true), { once: true });
3111
+ audio.addEventListener("error", () => resolve(false), { once: true });
3112
+ audio.src = url;
3113
+ audio.load();
3114
+ setTimeout(() => resolve(false), 2e3);
3115
+ });
3116
+ };
3117
+ let loaded = await tryLoadAudio(audioUrl);
3118
+ if (!loaded && audioUrl !== import_incoming.default) {
3119
+ loaded = await tryLoadAudio(import_incoming.default);
3120
+ if (loaded) {
3121
+ audioUrl = import_incoming.default;
3122
+ }
3123
+ }
3124
+ return audio;
3125
+ }
3126
+ function cleanupAudioResources() {
3127
+ if (audioBlobUrl) {
3128
+ URL.revokeObjectURL(audioBlobUrl);
3129
+ audioBlobUrl = null;
3130
+ }
3131
+ audioBuffer = null;
3132
+ }
3133
+
3134
+ // call-control-sdk/lib/components/callControls.tsx
3135
+ var import_vault5 = require("@react-solutions/vault");
3136
+ var import_jsx_runtime3 = require("react/jsx-runtime");
3137
+ var getCombineConfrenceData = (localState, apiData) => {
3138
+ const localConfrenceData = localState == null ? void 0 : localState.conferenceLine;
3139
+ const apiConferenceData = apiData == null ? void 0 : apiData.conferencestatus;
3140
+ const updatedConferenceData = localConfrenceData.map((item) => {
3141
+ var _a2, _b, _c, _d, _e;
3142
+ if ((item == null ? void 0 : item.line) === 1) {
3143
+ const statusKey = `line_${item.line}_status`;
3144
+ return __spreadProps(__spreadValues({}, item), {
3145
+ line: 1,
3146
+ status: (_b = apiConferenceData[statusKey]) != null ? _b : (_a2 = localState == null ? void 0 : localState.callData) == null ? void 0 : _a2.status,
3147
+ phone: (_d = (_c = localState == null ? void 0 : localState.callData) == null ? void 0 : _c.phone_number) != null ? _d : ""
3148
+ });
3149
+ } else {
3150
+ const statusKey = `line_${item.line}_status`;
3151
+ const phoneKey = `line_${item.line}_phonenumber`;
3152
+ return __spreadProps(__spreadValues({}, item), {
3153
+ status: (_e = apiConferenceData[statusKey]) != null ? _e : item.status,
3154
+ phone: apiConferenceData[phoneKey] === null || apiConferenceData[phoneKey] === "0" ? item.phone : apiConferenceData[phoneKey]
3155
+ });
3156
+ }
3157
+ });
3158
+ return updatedConferenceData;
3159
+ };
3160
+ var formatDuration = (seconds) => {
3161
+ const mins = Math.floor(seconds / 60);
3162
+ const secs = seconds % 60;
3163
+ return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
3164
+ };
3165
+ function CallControls({ onDataChange }) {
3166
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za;
3167
+ const theme = (0, import_material4.useTheme)();
3168
+ const state = useSDKState();
3169
+ const { showToast } = useToast();
3170
+ const { disabled, enabled, outlined } = styles_default({
3171
+ disabled: ((_a2 = state.sdkConfig) == null ? void 0 : _a2.disabled) || {},
3172
+ enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
3173
+ outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
3174
+ });
3175
+ const micRef = (0, import_react11.useRef)(null);
3176
+ const webSocketRef = (0, import_react11.useRef)(null);
3177
+ const audioRef = (0, import_react11.useRef)(null);
3178
+ const reconnectTimeoutRef = (0, import_react11.useRef)(null);
3179
+ const pingIntervalRef = (0, import_react11.useRef)(null);
3180
+ const reconnectAttemptsRef = (0, import_react11.useRef)(0);
3181
+ const hasFlashedRef = (0, import_react11.useRef)(false);
3182
+ const lastEventTimeRef = (0, import_react11.useRef)(null);
3183
+ const maxReconnectAttempts = 60;
3184
+ const baseReconnectDelay = 2e3;
3185
+ const maxReconnectDelay = 3e4;
3186
+ const [anchorEl, setAnchorEl] = (0, import_react11.useState)(null);
3187
+ const [statusAnchorEl, setStatusAnchorEl] = (0, import_react11.useState)(null);
3188
+ const [dialerAnchorEl, setDialerAnchorEl] = (0, import_react11.useState)(null);
3189
+ const [ambulanceAnchorEl, setAmbulanceAnchorEl] = (0, import_react11.useState)(null);
3190
+ const [moreOptionsAnchorEl, setMoreOptionsAnchorEl] = (0, import_react11.useState)(null);
3191
+ const [showIframe, setShowIframe] = (0, import_react11.useState)(true);
3192
+ const [openCallDisposition, setOpenCallDisposition] = (0, import_react11.useState)(false);
3193
+ const [openProcessorDialog, setOpenProcessorDialog] = (0, import_react11.useState)(false);
3194
+ const [openCallHistoryDialog, setOpenCallHistoryDialog] = (0, import_react11.useState)(false);
3195
+ const [processList, setProcessList] = (0, import_react11.useState)(null);
3196
+ const [breaksList, setBreaksList] = (0, import_react11.useState)(null);
3197
+ const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
3198
+ const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
3199
+ const [callWrapuptime, setCallWrapuptime] = (0, import_react11.useState)(null);
3200
+ const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
3201
+ state.controlPanelPosition,
3202
+ (newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
3203
+ );
3204
+ const {
3205
+ position: iframePosition,
3206
+ isDragging: iframeIsDragging,
3207
+ dragRef: iframeDragRef,
3208
+ handleMouseDown: iframeHandleMouseDown,
3209
+ handleTouchStart: iframeHandleTouchStart
3210
+ } = useDraggable(
3211
+ state.iframePosition,
3212
+ (newPosition) => sdkStateManager.setIframePosition(newPosition)
3213
+ );
3214
+ const [clickToCall, { isLoading: clickToCallLoading }] = usePostRequest({
3215
+ onSuccess: () => {
3216
+ setPhoneNumber("");
3217
+ setDialerAnchorEl(null);
3218
+ }
3219
+ });
3220
+ const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest();
3221
+ const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest();
3222
+ const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest({
3223
+ onSuccess: () => {
3224
+ sdkStateManager.setAgentStatus("");
3225
+ }
3226
+ });
3227
+ const [updateAgentStatus, { isLoading }] = usePostRequest();
3228
+ const [sendNotification] = usePostRequest();
3229
+ const [endCall, { isLoading: endCallLoading }] = usePostRequest({
3230
+ onSuccess: () => {
3231
+ sdkStateManager.endCall();
3232
+ setOpenCallDisposition(false);
3233
+ sdkStateManager.resetConferenceLines();
3234
+ }
3235
+ });
3236
+ const handleCloseQueueCounts = () => {
3237
+ setAnchorEl(null);
3238
+ };
3239
+ const handleOpenDialer = (event) => {
3240
+ setShowIframe(true);
3241
+ setDialerAnchorEl(event.currentTarget);
3242
+ };
3243
+ const handleOpenAbulanceServices = (event) => {
3244
+ setAmbulanceAnchorEl(event.currentTarget);
3245
+ };
3246
+ const handleOpenMoreOptions = (event) => {
3247
+ setMoreOptionsAnchorEl(event.currentTarget);
3248
+ };
3249
+ const handleCloseDialer = () => {
3250
+ setDialerAnchorEl(null);
3251
+ };
3252
+ const handleCloseAmbulance = () => {
3253
+ setAmbulanceAnchorEl(null);
3254
+ };
3255
+ const handleCloseMoreOptions = () => {
3256
+ setMoreOptionsAnchorEl(null);
3257
+ };
3258
+ const handleOpenAgentStatus = (event) => {
3259
+ setStatusAnchorEl(event.currentTarget);
3260
+ };
3261
+ const handleCloseAgentStatus = () => {
3262
+ setStatusAnchorEl(null);
3263
+ };
3264
+ const handleAgentReady = () => {
3265
+ const payload = {
3266
+ action: "READYAGENT",
3267
+ userId: state.agentId
3268
+ };
3269
+ readyAgentStatus(END_POINT.READY_AGENT, payload);
3270
+ };
3271
+ const handleUpdateAgentStatus = (status) => {
3272
+ setStatusAnchorEl(null);
3273
+ const payload = {
3274
+ action: "AGENTBREAK",
3275
+ break_type: status,
3276
+ userId: state.agentId
3277
+ };
3278
+ updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload).then(() => {
3279
+ sdkStateManager.setAgentStatus(status);
3280
+ });
3281
+ };
3282
+ const handleStartCall = (number) => {
3283
+ if (number.length !== 10) {
3284
+ showToast("Invalid phone number", "error");
3285
+ } else if (!/^\d+$/.test(number)) {
3286
+ showToast("Invalid phone number", "error");
3287
+ } else {
3288
+ const payload = {
3289
+ action: "CALL",
3290
+ phone_number: number,
3291
+ userId: state.agentId
3292
+ };
3293
+ clickToCall(END_POINT.CLICK_TO_CALL, payload);
3294
+ }
3295
+ };
3296
+ const handleHoldToggle = () => {
3297
+ var _a3;
3298
+ const payload = {
3299
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" /* UNHOLD */ : "HOLD" /* HOLD */,
3300
+ userId: state.agentId
3301
+ };
3302
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
3303
+ };
3304
+ const handleMuteToggle = () => {
3305
+ var _a3;
3306
+ const payload = {
3307
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" /* UNMUTE */ : "MUTE" /* MUTE */,
3308
+ userId: state.agentId
3309
+ };
3310
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
3311
+ };
3312
+ const handleEndCall = (data) => {
3313
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2;
3314
+ const payload = {
3315
+ action: "ENDCALL",
3316
+ userId: state.agentId,
3317
+ processid: (_c2 = (_b2 = (_a3 = state.process) == null ? void 0 : _a3.process_id) == null ? void 0 : _b2.toString()) != null ? _c2 : "",
3318
+ process_name: (_e2 = (_d2 = state.process) == null ? void 0 : _d2.process_name) != null ? _e2 : "",
3319
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
3320
+ mobile_number: (_i2 = (_h2 = state.callData) == null ? void 0 : _h2.phone_number) != null ? _i2 : "",
3321
+ disposition: (_k2 = (_j2 = data == null ? void 0 : data.disposition) == null ? void 0 : _j2.value) != null ? _k2 : "",
3322
+ set_followUp: (_m2 = (_l2 = data == null ? void 0 : data.followUp) == null ? void 0 : _l2.value) != null ? _m2 : "",
3323
+ callback_date: (_n2 = data == null ? void 0 : data.callbackDate) != null ? _n2 : "",
3324
+ callback_hrs: (_o2 = data == null ? void 0 : data.callbackHrs) != null ? _o2 : "",
3325
+ callback_mins: (_p2 = data == null ? void 0 : data.callbackMins) != null ? _p2 : "",
3326
+ endcall_type: "CLOSE"
3327
+ };
3328
+ setPhoneNumber("");
3329
+ endCall(END_POINT.END_CALL, payload, {
3330
+ params: {
3331
+ isBreak: (_q2 = data == null ? void 0 : data.selected_break) != null ? _q2 : false
3332
+ }
3333
+ });
3334
+ };
3335
+ (0, import_react11.useEffect)(() => {
3336
+ const handleBeforeUnload = (e) => {
3337
+ e.preventDefault();
3338
+ };
3339
+ window.addEventListener("beforeunload", handleBeforeUnload);
3340
+ return () => {
3341
+ window.removeEventListener("beforeunload", handleBeforeUnload);
3342
+ };
3343
+ }, []);
3344
+ (0, import_react11.useEffect)(() => {
3345
+ const mic = createMicController();
3346
+ micRef.current = mic;
3347
+ mic.start().catch((err) => {
3348
+ console.error("Failed to start mic:", err);
3349
+ });
3350
+ const handleKeyDown = (event) => {
3351
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3352
+ const fullState = (0, import_vault5.getItem)(STORAGE_KEY);
3353
+ const key = (_a3 = event.key) == null ? void 0 : _a3.toLowerCase();
3354
+ if (!event.altKey || ((_b2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _b2.status) !== "ONCALL" /* ONCALL */) {
3355
+ return;
3356
+ }
3357
+ if (key === "m" && String((_c2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _c2.mute) === "0") {
3358
+ event.preventDefault();
3359
+ (_d2 = micRef.current) == null ? void 0 : _d2.mute();
3360
+ const payload = {
3361
+ action: "MUTE" /* MUTE */,
3362
+ userId: fullState.agentId
3363
+ };
3364
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
3365
+ }
3366
+ if (key === "u" && String((_e2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _e2.mute) === "1") {
3367
+ event.preventDefault();
3368
+ const payload = {
3369
+ action: "UNMUTE" /* UNMUTE */,
3370
+ userId: fullState.agentId
3371
+ };
3372
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
3373
+ (_f2 = micRef.current) == null ? void 0 : _f2.unmute();
3374
+ }
3375
+ if (key === "h" && String((_g2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _g2.hold) === "0") {
3376
+ event.preventDefault();
3377
+ const payload = {
3378
+ action: "HOLD" /* HOLD */,
3379
+ userId: fullState.agentId
3380
+ };
3381
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
3382
+ }
3383
+ if (key === "r" && String((_h2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _h2.hold) === "1") {
3384
+ event.preventDefault();
3385
+ const payload = {
3386
+ action: "UNHOLD" /* UNHOLD */,
3387
+ userId: fullState.agentId
3388
+ };
3389
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
3390
+ }
3391
+ };
3392
+ window.addEventListener("keydown", handleKeyDown);
3393
+ return () => {
3394
+ window.removeEventListener("keydown", handleKeyDown);
3395
+ };
3396
+ }, []);
3397
+ (0, import_react11.useEffect)(() => {
3398
+ let interval;
3399
+ let wrapUpinterval;
3400
+ if (state.callData.status && state.callData.status === "ONCALL" /* ONCALL */) {
3401
+ interval = setInterval(() => {
3402
+ const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
3403
+ setCallDuration(elapsed);
3404
+ }, 1e3);
3405
+ } else {
3406
+ setCallDuration(0);
3407
+ }
3408
+ if (state.callData.status && state.callData.status === "WRAPUP" /* WRAPUP */ && callWrapuptime !== null) {
3409
+ wrapUpinterval = setInterval(() => {
3410
+ setCallWrapuptime((prevTime) => {
3411
+ if (prevTime === null || prevTime <= 1) {
3412
+ clearInterval(wrapUpinterval);
3413
+ handleEndCall({
3414
+ disposition: { label: "Resolved", value: "AUTO_WRAPUP" },
3415
+ followUp: { label: "No", value: "N" },
3416
+ callbackDate: "",
3417
+ callbackHrs: "",
3418
+ callbackMins: "",
3419
+ selected_break: false
3420
+ });
3421
+ return null;
3422
+ }
3423
+ return prevTime - 1;
3424
+ });
3425
+ }, 1e3);
3426
+ }
3427
+ return () => {
3428
+ if (interval) clearInterval(interval);
3429
+ if (wrapUpinterval) clearInterval(wrapUpinterval);
3430
+ };
3431
+ }, [state.callData.status]);
3432
+ (0, import_react11.useEffect)(() => {
3433
+ createAudioElement().then((audio) => {
3434
+ audioRef.current = audio;
3435
+ }).catch((error) => {
3436
+ console.error("Failed to load audio element:", error);
3437
+ });
3438
+ return () => {
3439
+ if (audioRef.current) {
3440
+ audioRef.current.pause();
3441
+ audioRef.current.currentTime = 0;
3442
+ audioRef.current.src = "";
3443
+ audioRef.current = null;
3444
+ }
3445
+ cleanupAudioResources();
3446
+ };
3447
+ }, []);
3448
+ (0, import_react11.useEffect)(() => {
3449
+ if (onDataChange && state.callData) {
3450
+ const { process_id, process_name, status, phone_number, agent_id, convox_id } = state.callData;
3451
+ const callData = {
3452
+ phone_number,
3453
+ status,
3454
+ callReferenceId: convox_id,
3455
+ agent_id,
3456
+ process_id,
3457
+ process_name
3458
+ };
3459
+ onDataChange(callData);
3460
+ }
3461
+ }, [state.callData, onDataChange]);
3462
+ (0, import_react11.useEffect)(() => {
3463
+ if (state.agentId) {
3464
+ axios_default.post(END_POINT.PROCESS_LIST, {
3465
+ userId: state.agentId,
3466
+ action: "GETAGENTPROCESSLIST",
3467
+ refno: "1234221233"
3468
+ }).then((res) => {
3469
+ const data = {
3470
+ "process_id": 101,
3471
+ "process_name": "ConVoxProcess"
3472
+ };
3473
+ sdkStateManager.setProcess(data);
3474
+ }).catch((err) => {
3475
+ showToast(err.response.data.message, "error");
3476
+ });
3477
+ axios_default.get(END_POINT.BREAKS_LIST).then((res) => {
3478
+ var _a3, _b2, _c2;
3479
+ if (res && ((_a3 = res.data) == null ? void 0 : _a3.data) && ((_c2 = (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.data) == null ? void 0 : _c2.length)) {
3480
+ setBreaksList(res.data.data);
3481
+ }
3482
+ }).catch((err) => {
3483
+ showToast(err.response.data.message, "error");
3484
+ });
3485
+ }
3486
+ }, [state.agentId]);
3487
+ const connectWebSocket = () => {
3488
+ var _a3, _b2;
3489
+ if (!state.agentId) {
3490
+ return;
3491
+ }
3492
+ if (reconnectTimeoutRef.current) {
3493
+ clearTimeout(reconnectTimeoutRef.current);
3494
+ reconnectTimeoutRef.current = null;
3495
+ }
3496
+ try {
3497
+ webSocketRef.current = new WebSocket(`${(_a3 = state.urlConfig) == null ? void 0 : _a3.webSocketURL}?agent_id=${state.agentId}&accessToken=${(_b2 = state.authorization) == null ? void 0 : _b2.accessToken}`);
3498
+ webSocketRef.current.onopen = () => {
3499
+ console.log("\u{1F310} WebSocket connection established");
3500
+ reconnectAttemptsRef.current = 0;
3501
+ if (pingIntervalRef.current) {
3502
+ clearInterval(pingIntervalRef.current);
3503
+ }
3504
+ pingIntervalRef.current = setInterval(() => {
3505
+ if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) {
3506
+ try {
3507
+ webSocketRef.current.send(JSON.stringify({ type: "ping" }));
3508
+ } catch (error) {
3509
+ console.error("Failed to send ping:", error);
3510
+ }
3511
+ }
3512
+ }, 3e4);
3513
+ };
3514
+ webSocketRef.current.onmessage = (event) => {
3515
+ var _a4, _b3, _c2, _d2, _e2;
3516
+ try {
3517
+ const data = JSON.parse(event.data);
3518
+ if (data.type === "pong") {
3519
+ return;
3520
+ }
3521
+ const sdkState = (0, import_vault5.getItem)(STORAGE_KEY);
3522
+ const confrence = getCombineConfrenceData(sdkState, data);
3523
+ const callData = {
3524
+ agent_id: data == null ? void 0 : data.agent_id,
3525
+ status: data == null ? void 0 : data.status,
3526
+ type: data == null ? void 0 : data.type,
3527
+ event_time: data == null ? void 0 : data.event_time,
3528
+ phone_number: data == null ? void 0 : data.phone_number,
3529
+ convox_id: data == null ? void 0 : data.convox_id,
3530
+ process_id: data == null ? void 0 : data.process_id,
3531
+ process_name: data == null ? void 0 : data.process_name,
3532
+ hold: data == null ? void 0 : data.hold,
3533
+ mute: data == null ? void 0 : data.mute,
3534
+ mode: data == null ? void 0 : data.mode,
3535
+ queue_name: data == null ? void 0 : data.queue_name
3536
+ };
3537
+ sdkStateManager.updateCallData(callData);
3538
+ sdkStateManager.updateConferenceData([...confrence]);
3539
+ if (["RINGING" /* RINGING */, "DIALING" /* DIALING */].includes(data.status)) {
3540
+ setShowIframe(true);
3541
+ setCallWrapuptime((_b3 = (_a4 = sdkState == null ? void 0 : sdkState.sdkConfig) == null ? void 0 : _a4.auto_wrapup_time) != null ? _b3 : null);
3542
+ sdkStateManager.updateConferenceData([
3543
+ {
3544
+ line: 1,
3545
+ status: "IDLE",
3546
+ type: "",
3547
+ phone: "",
3548
+ isMute: false,
3549
+ isHold: false,
3550
+ isCallStart: false,
3551
+ isMergeCall: false
3552
+ },
3553
+ {
3554
+ line: 2,
3555
+ status: "IDLE",
3556
+ type: "",
3557
+ phone: "",
3558
+ isMute: false,
3559
+ isHold: false,
3560
+ isCallStart: false,
3561
+ isMergeCall: false
3562
+ },
3563
+ {
3564
+ line: 3,
3565
+ status: "IDLE",
3566
+ type: "",
3567
+ phone: "",
3568
+ isMute: false,
3569
+ isHold: false,
3570
+ isCallStart: false,
3571
+ isMergeCall: false
3572
+ },
3573
+ {
3574
+ line: 4,
3575
+ status: "IDLE",
3576
+ type: "",
3577
+ phone: "",
3578
+ isMute: false,
3579
+ isHold: false,
3580
+ isCallStart: false,
3581
+ isMergeCall: false
3582
+ },
3583
+ {
3584
+ line: 5,
3585
+ status: "IDLE",
3586
+ type: "",
3587
+ phone: "",
3588
+ isMute: false,
3589
+ isHold: false,
3590
+ isCallStart: false,
3591
+ isMergeCall: false
3592
+ }
3593
+ ]);
3594
+ if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current && ((_c2 = state == null ? void 0 : state.sdkConfig) == null ? void 0 : _c2.enableRingtone)) {
3595
+ audioRef.current.play().catch((error) => {
3596
+ console.error("Failed to play ringtone:", error);
3597
+ });
3598
+ }
3599
+ } else {
3600
+ if (audioRef.current) {
3601
+ audioRef.current.pause();
3602
+ audioRef.current.currentTime = 0;
3603
+ }
3604
+ }
3605
+ if (data.status === "IDLE" /* IDLE */) {
3606
+ USB_LIGHT_REQUEST(USB_LIGHT_ON("green"));
3607
+ } else if ((data == null ? void 0 : data.mute) !== 1 && (data == null ? void 0 : data.hold) !== 1 && data.status === "ONCALL" /* ONCALL */) {
3608
+ USB_LIGHT_REQUEST(USB_LIGHT_ON("red"));
3609
+ sdkStateManager.startCall();
3610
+ if (!showIframe) {
3611
+ setShowIframe(true);
3612
+ }
3613
+ } else if (((data == null ? void 0 : data.mute) === 1 || (data == null ? void 0 : data.hold) === 1) && data.status === "ONCALL" /* ONCALL */) {
3614
+ USB_LIGHT_REQUEST(USB_LIGHT_FLASH("red", 1));
3615
+ } else if (data.status === "BREAK" /* BREAK */) {
3616
+ const breakTime = (_d2 = sdkState == null ? void 0 : sdkState.sdkConfig) == null ? void 0 : _d2.break_time;
3617
+ const eventTime = (_e2 = data == null ? void 0 : data.event_time) != null ? _e2 : null;
3618
+ if (eventTime !== lastEventTimeRef.current) {
3619
+ hasFlashedRef.current = false;
3620
+ lastEventTimeRef.current = eventTime;
3621
+ }
3622
+ let isOverLimit = false;
3623
+ if (breakTime && eventTime) {
3624
+ const differenceInMinutes = ((/* @__PURE__ */ new Date()).getTime() - new Date(eventTime).getTime()) / 6e4;
3625
+ if (Number(differenceInMinutes.toFixed(0)) >= Number(breakTime)) {
3626
+ isOverLimit = true;
3627
+ }
3628
+ }
3629
+ if (isOverLimit) {
3630
+ if (!hasFlashedRef.current) {
3631
+ USB_LIGHT_REQUEST(USB_LIGHT_FLASH("yellow", 1));
3632
+ hasFlashedRef.current = true;
3633
+ }
3634
+ } else {
3635
+ USB_LIGHT_REQUEST(USB_LIGHT_ON("yellow"));
3636
+ }
3637
+ } else if (data.status === "WRAPUP" /* WRAPUP */) {
3638
+ USB_LIGHT_REQUEST(USB_LIGHT_FLASH("green", 1));
3639
+ sdkStateManager.endCall();
3640
+ }
3641
+ } catch (e) {
3642
+ console.error("\u{1F4E8} Raw message:", event.data);
3643
+ }
3644
+ };
3645
+ webSocketRef.current.onclose = (event) => {
3646
+ if (pingIntervalRef.current) {
3647
+ clearInterval(pingIntervalRef.current);
3648
+ pingIntervalRef.current = null;
3649
+ }
3650
+ if (event.code !== 1e3 && reconnectAttemptsRef.current < maxReconnectAttempts) {
3651
+ reconnectAttemptsRef.current += 1;
3652
+ const delay = Math.min(
3653
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3654
+ maxReconnectDelay
3655
+ );
3656
+ console.warn(
3657
+ `\u{1F504} Attempting to reconnect WebSocket (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts}) in ${delay}ms`
3658
+ );
3659
+ reconnectTimeoutRef.current = setTimeout(() => {
3660
+ connectWebSocket();
3661
+ }, delay);
3662
+ } else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
3663
+ showToast("WebSocket connection failed. Please refresh the page.", "error");
3664
+ }
3665
+ };
3666
+ webSocketRef.current.onerror = (error) => {
3667
+ console.error("\u274C WebSocket error:", error);
3668
+ };
3669
+ } catch (error) {
3670
+ if (reconnectAttemptsRef.current < maxReconnectAttempts) {
3671
+ reconnectAttemptsRef.current += 1;
3672
+ const delay = Math.min(
3673
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3674
+ maxReconnectDelay
3675
+ );
3676
+ reconnectTimeoutRef.current = setTimeout(() => {
3677
+ connectWebSocket();
3678
+ }, delay);
3679
+ }
3680
+ }
3681
+ };
3682
+ (0, import_react11.useEffect)(() => {
3683
+ if (state.agentId) {
3684
+ connectWebSocket();
3685
+ }
3686
+ return () => {
3687
+ if (reconnectTimeoutRef.current) {
3688
+ clearTimeout(reconnectTimeoutRef.current);
3689
+ reconnectTimeoutRef.current = null;
3690
+ }
3691
+ if (pingIntervalRef.current) {
3692
+ clearInterval(pingIntervalRef.current);
3693
+ pingIntervalRef.current = null;
3694
+ }
3695
+ if (webSocketRef.current) {
3696
+ webSocketRef.current.close(1e3, "Component unmounting");
3697
+ webSocketRef.current = null;
3698
+ }
3699
+ reconnectAttemptsRef.current = 0;
3700
+ };
3701
+ }, [state.agentId]);
3702
+ const handleSendSMS = (data) => {
3703
+ var _a3;
3704
+ sendNotification(END_POINT.SEND_NOTIFICATIONS, {
3705
+ phone_number: (_a3 = data == null ? void 0 : data.phone_number) != null ? _a3 : "",
3706
+ type: "ambulance"
3707
+ });
3708
+ };
3709
+ if (!state.isInitialized || !state.process) {
3710
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: Boolean(openProcessorDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3711
+ ProcessorListDialog,
3712
+ {
3713
+ processList,
3714
+ open: openProcessorDialog,
3715
+ setOpen: setOpenProcessorDialog,
3716
+ handleSelectedProcessor: (data) => {
3717
+ sdkStateManager.setProcess(data);
3718
+ }
3719
+ }
3720
+ ) });
3721
+ }
3722
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3723
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3724
+ import_material4.Fade,
3725
+ {
3726
+ in: true,
3727
+ timeout: 300,
3728
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3729
+ import_material4.Paper,
3730
+ {
3731
+ ref: ((_d = state.sdkConfig) == null ? void 0 : _d.isDraggable) ? dragRef : null,
3732
+ elevation: isDragging ? 4 : ((_e = state.sdkConfig) == null ? void 0 : _e.isDraggable) ? 1 : 0,
3733
+ sx: {
3734
+ position: ((_f = state.sdkConfig) == null ? void 0 : _f.isDraggable) ? "fixed" : "relative",
3735
+ left: ((_g = state.sdkConfig) == null ? void 0 : _g.isDraggable) ? position.x : "auto",
3736
+ top: ((_h = state.sdkConfig) == null ? void 0 : _h.isDraggable) ? position.y : "auto",
3737
+ display: "inline-block",
3738
+ width: "auto",
3739
+ flexShrink: 0,
3740
+ whiteSpace: "nowrap",
3741
+ p: 0.5,
3742
+ borderRadius: 3,
3743
+ bgcolor: "background.paper",
3744
+ zIndex: ((_i = state.sdkConfig) == null ? void 0 : _i.isDraggable) ? Number.MAX_SAFE_INTEGER : 0,
3745
+ transition: theme.transitions.create(["box-shadow", "transform"], {
3746
+ duration: theme.transitions.duration.short
3747
+ }),
3748
+ userSelect: "none"
3749
+ },
3750
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3751
+ import_material4.Box,
3752
+ {
3753
+ sx: {
3754
+ display: "flex",
3755
+ alignItems: "center"
3756
+ },
3757
+ children: [
3758
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3759
+ import_material4.Box,
3760
+ {
3761
+ sx: {
3762
+ display: "flex",
3763
+ alignItems: "center",
3764
+ gap: 1,
3765
+ margin: "0px 10px"
3766
+ },
3767
+ children: [
3768
+ ((_j = state.sdkConfig) == null ? void 0 : _j.isDraggable) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3769
+ import_material4.IconButton,
3770
+ {
3771
+ component: "div",
3772
+ size: "small",
3773
+ sx: {
3774
+ cursor: "all-scroll"
3775
+ },
3776
+ onMouseDown: handleMouseDown,
3777
+ onTouchStart: handleTouchStart,
3778
+ children: [
3779
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.DragIndicator, {}),
3780
+ " "
3781
+ ]
3782
+ }
3783
+ ),
3784
+ ((_k = state.sdkConfig) == null ? void 0 : _k.enableQueueName) && ((_l = state == null ? void 0 : state.callData) == null ? void 0 : _l.queue_name) && ((_m = state == null ? void 0 : state.callData) == null ? void 0 : _m.mode) !== "manual" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Chip, { label: (_n = state == null ? void 0 : state.callData) == null ? void 0 : _n.queue_name }),
3785
+ !((_o = state.sdkConfig) == null ? void 0 : _o.disabledDialButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Dial", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3786
+ import_material4.IconButton,
3787
+ {
3788
+ size: "small",
3789
+ onClick: (e) => {
3790
+ var _a3, _b2;
3791
+ if (![
3792
+ "BREAK" /* BREAK */,
3793
+ "ONCALL" /* ONCALL */,
3794
+ "RINGING" /* RINGING */,
3795
+ "WRAPUP" /* WRAPUP */
3796
+ ].includes((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase())) {
3797
+ handleOpenDialer(e);
3798
+ }
3799
+ },
3800
+ disabled: [
3801
+ "BREAK" /* BREAK */,
3802
+ "ONCALL" /* ONCALL */,
3803
+ "RINGING" /* RINGING */,
3804
+ "WRAPUP" /* WRAPUP */
3805
+ ].includes(state.callData.status.toUpperCase()),
3806
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3807
+ import_icons_material2.WifiCalling3,
3808
+ {
3809
+ sx: {
3810
+ color: [
3811
+ "BREAK" /* BREAK */,
3812
+ "ONCALL" /* ONCALL */,
3813
+ "RINGING" /* RINGING */,
3814
+ "WRAPUP" /* WRAPUP */
3815
+ ].includes(state.callData.status.toUpperCase()) ? "action.selected" : "success.main"
3816
+ }
3817
+ }
3818
+ )
3819
+ }
3820
+ ) }),
3821
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { onClick: () => setShowIframe(true), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3822
+ import_material4.Typography,
3823
+ {
3824
+ sx: {
3825
+ color: "success.main",
3826
+ width: "40px",
3827
+ marginRight: "10px",
3828
+ fontSize: "18px",
3829
+ fontWeight: "600",
3830
+ cursor: "pointer"
3831
+ },
3832
+ children: state.callData.status === "WRAPUP" /* WRAPUP */ && callWrapuptime !== null ? formatDuration(callWrapuptime) : formatDuration(callDuration)
3833
+ }
3834
+ ) }),
3835
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3836
+ import_material4.Chip,
3837
+ {
3838
+ sx: {
3839
+ padding: "18px 0px"
3840
+ },
3841
+ label: isLoading || agentReadyLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3842
+ import_material4.Box,
3843
+ {
3844
+ sx: {
3845
+ fontWeight: "bold",
3846
+ width: "60px",
3847
+ display: "flex",
3848
+ alignItems: "center",
3849
+ justifyContent: "center"
3850
+ },
3851
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.CircularProgress, { size: "20px" })
3852
+ }
3853
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3854
+ import_material4.Typography,
3855
+ {
3856
+ variant: "body2",
3857
+ sx: {
3858
+ fontWeight: "bold",
3859
+ width: "60px",
3860
+ textAlign: "center"
3861
+ },
3862
+ children: (_r = (_q = (_p = state.callData) == null ? void 0 : _p.status) == null ? void 0 : _q.toUpperCase()) != null ? _r : "N/A"
3863
+ }
3864
+ ),
3865
+ onClick: handleOpenAgentStatus,
3866
+ deleteIcon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.KeyboardArrowDown, { color: "primary" }),
3867
+ onDelete: handleOpenAgentStatus
3868
+ }
3869
+ )
3870
+ ]
3871
+ }
3872
+ ),
3873
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3874
+ import_material4.Box,
3875
+ {
3876
+ sx: {
3877
+ display: "flex",
3878
+ gap: 1,
3879
+ justifyContent: "center",
3880
+ alignItems: "center"
3881
+ },
3882
+ children: [
3883
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Agent Ready", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3884
+ import_material4.Button,
3885
+ {
3886
+ variant: ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3887
+ (_t = (_s = state.callData) == null ? void 0 : _s.status) == null ? void 0 : _t.toUpperCase()
3888
+ ) ? "outlined" : "contained",
3889
+ onClick: (e) => {
3890
+ var _a3, _b2;
3891
+ if (["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3892
+ (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()
3893
+ )) {
3894
+ e.stopPropagation();
3895
+ handleAgentReady();
3896
+ }
3897
+ },
3898
+ classes: {
3899
+ root: ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3900
+ (_v = (_u = state.callData) == null ? void 0 : _u.status) == null ? void 0 : _v.toUpperCase()
3901
+ ) ? "outlined" : "enabled"
3902
+ },
3903
+ sx: __spreadValues({}, ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3904
+ (_x = (_w = state.callData) == null ? void 0 : _w.status) == null ? void 0 : _x.toUpperCase()
3905
+ ) ? outlined : enabled),
3906
+ disabled: agentReadyLoading,
3907
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.SupportAgent, {})
3908
+ }
3909
+ ) }),
3910
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_y = state.callData) == null ? void 0 : _y.hold) === 1 ? "Resume" : "Hold", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3911
+ import_material4.Button,
3912
+ {
3913
+ variant: ((_z = state.callData) == null ? void 0 : _z.hold) === 1 && ((_B = (_A = state.callData) == null ? void 0 : _A.status) == null ? void 0 : _B.toUpperCase()) === "ONCALL" /* ONCALL */ ? "contained" : "outlined",
3914
+ onClick: (e) => {
3915
+ e.stopPropagation();
3916
+ handleHoldToggle();
3917
+ },
3918
+ sx: ((_C = state.callData) == null ? void 0 : _C.hold) === 1 && ((_E = (_D = state.callData) == null ? void 0 : _D.status) == null ? void 0 : _E.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues({}, enabled) : ((_G = (_F = state.callData) == null ? void 0 : _F.status) == null ? void 0 : _G.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3919
+ disabled: ((_I = (_H = state.callData) == null ? void 0 : _H.status) == null ? void 0 : _I.toUpperCase()) !== "ONCALL" /* ONCALL */ && ((_J = state.callData) == null ? void 0 : _J.hold) !== 1 || holdOrUnHoldLoading,
3920
+ children: holdOrUnHoldLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3921
+ import_material4.CircularProgress,
3922
+ {
3923
+ size: "20px",
3924
+ sx: {
3925
+ color: theme.palette.primary.main
3926
+ }
3927
+ }
3928
+ ) : ((_K = state.callData) == null ? void 0 : _K.hold) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pause, {})
3929
+ }
3930
+ ) }),
3931
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_L = state.callData) == null ? void 0 : _L.mute) === 1 ? "Unmute" : "Mute", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3932
+ import_material4.Button,
3933
+ {
3934
+ variant: ((_M = state.callData) == null ? void 0 : _M.mute) === 1 && ((_O = (_N = state.callData) == null ? void 0 : _N.status) == null ? void 0 : _O.toUpperCase()) === "ONCALL" /* ONCALL */ ? "contained" : "outlined",
3935
+ onClick: (e) => {
3936
+ e.stopPropagation();
3937
+ handleMuteToggle();
3938
+ },
3939
+ sx: ((_P = state.callData) == null ? void 0 : _P.hold) === 1 ? __spreadValues({}, disabled) : ((_Q = state.callData) == null ? void 0 : _Q.mute) === 1 && ((_S = (_R = state.callData) == null ? void 0 : _R.status) == null ? void 0 : _S.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues({}, enabled) : ((_U = (_T = state.callData) == null ? void 0 : _T.status) == null ? void 0 : _U.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3940
+ disabled: ((_W = (_V = state.callData) == null ? void 0 : _V.status) == null ? void 0 : _W.toUpperCase()) !== "ONCALL" /* ONCALL */ && ((_X = state.callData) == null ? void 0 : _X.mute) !== 1 || muteOrUnMuteLoading || ((_Y = state.callData) == null ? void 0 : _Y.hold) === 1,
3941
+ children: muteOrUnMuteLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3942
+ import_material4.CircularProgress,
3943
+ {
3944
+ size: "20px",
3945
+ sx: {
3946
+ color: theme.palette.primary.main
3947
+ }
3948
+ }
3949
+ ) : ((_Z = state.callData) == null ? void 0 : _Z.mute) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.MicOff, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Mic, {})
3950
+ }
3951
+ ) }),
3952
+ !((__ = state.sdkConfig) == null ? void 0 : __.disableCallTransferButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Transfer Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3953
+ import_material4.Button,
3954
+ {
3955
+ variant: state.openCallTransferDialog ? "contained" : "outlined",
3956
+ onClick: (e) => {
3957
+ var _a3, _b2;
3958
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */) {
3959
+ e.stopPropagation();
3960
+ sdkStateManager.setOpenCallTransferDialog(true);
3961
+ }
3962
+ },
3963
+ sx: state.openCallTransferDialog ? __spreadValues({}, enabled) : ((_aa = (_$ = state.callData) == null ? void 0 : _$.status) == null ? void 0 : _aa.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3964
+ disabled: ((_ca = (_ba = state.callData) == null ? void 0 : _ba.status) == null ? void 0 : _ca.toUpperCase()) !== "ONCALL" /* ONCALL */,
3965
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.TransferWithinAStation, {})
3966
+ }
3967
+ ) }),
3968
+ !((_da = state.sdkConfig) == null ? void 0 : _da.disableConferenceButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Conference Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3969
+ import_material4.Button,
3970
+ {
3971
+ variant: state.openConferenceDialog ? "contained" : "outlined",
3972
+ onClick: (e) => {
3973
+ var _a3, _b2;
3974
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */) {
3975
+ e.stopPropagation();
3976
+ sdkStateManager.setOpenConferenceDialog(true);
3977
+ }
3978
+ },
3979
+ sx: state.openConferenceDialog ? __spreadValues({}, enabled) : ((_fa = (_ea = state.callData) == null ? void 0 : _ea.status) == null ? void 0 : _fa.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3980
+ disabled: ((_ha = (_ga = state.callData) == null ? void 0 : _ga.status) == null ? void 0 : _ha.toUpperCase()) !== "ONCALL" /* ONCALL */,
3981
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Group, {})
3982
+ }
3983
+ ) }),
3984
+ ((_ia = state.sdkConfig) == null ? void 0 : _ia.enableSmsServices) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Send SMS", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3985
+ import_material4.Button,
3986
+ {
3987
+ variant: Boolean(ambulanceAnchorEl) ? "contained" : "outlined",
3988
+ onClick: (e) => {
3989
+ var _a3, _b2;
3990
+ if (["ONCALL" /* ONCALL */, "WRAPUP" /* WRAPUP */].includes(
3991
+ (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()
3992
+ )) {
3993
+ e.stopPropagation();
3994
+ handleOpenAbulanceServices(e);
3995
+ }
3996
+ },
3997
+ sx: Boolean(ambulanceAnchorEl) ? __spreadValues({}, enabled) : ["ONCALL" /* ONCALL */, "WRAPUP" /* WRAPUP */].includes(
3998
+ (_ka = (_ja = state.callData) == null ? void 0 : _ja.status) == null ? void 0 : _ka.toUpperCase()
3999
+ ) ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
4000
+ disabled: !["ONCALL" /* ONCALL */, "WRAPUP" /* WRAPUP */].includes(
4001
+ (_ma = (_la = state.callData) == null ? void 0 : _la.status) == null ? void 0 : _ma.toUpperCase()
4002
+ ),
4003
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.SmsSharp, {})
4004
+ }
4005
+ ) }),
4006
+ !((_na = state.sdkConfig) == null ? void 0 : _na.disableEndCallButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4007
+ import_material4.Button,
4008
+ {
4009
+ variant: [
4010
+ "ONCALL" /* ONCALL */,
4011
+ "RINGING" /* RINGING */,
4012
+ "DIALING" /* DIALING */,
4013
+ "WRAPUP" /* WRAPUP */
4014
+ ].includes((_pa = (_oa = state.callData) == null ? void 0 : _oa.status) == null ? void 0 : _pa.toUpperCase()) ? "contained" : "outlined",
4015
+ onClick: (e) => {
4016
+ var _a3, _b2;
4017
+ if ([
4018
+ "ONCALL" /* ONCALL */,
4019
+ "RINGING" /* RINGING */,
4020
+ "DIALING" /* DIALING */,
4021
+ "WRAPUP" /* WRAPUP */
4022
+ ].includes((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase())) {
4023
+ e.stopPropagation();
4024
+ setOpenCallDisposition(true);
4025
+ }
4026
+ },
4027
+ sx: [
4028
+ "ONCALL" /* ONCALL */,
4029
+ "RINGING" /* RINGING */,
4030
+ "DIALING" /* DIALING */,
4031
+ "WRAPUP" /* WRAPUP */
4032
+ ].includes((_ra = (_qa = state.callData) == null ? void 0 : _qa.status) == null ? void 0 : _ra.toUpperCase()) ? __spreadProps(__spreadValues({}, enabled), {
4033
+ borderRight: "1px",
4034
+ backgroundColor: "error.main",
4035
+ minWidth: "60px !important",
4036
+ boxShadow: " 0px 2px 1px #5f3f3f",
4037
+ border: `1px solid ${theme.palette.error.light}`,
4038
+ height: "40px",
4039
+ "&:hover": {
4040
+ bgcolor: "error.light",
4041
+ boxShadow: " 0px 2px 1px #5f3f3f",
4042
+ border: `0px solid ${theme.palette.error.light}`
4043
+ },
4044
+ "&:active": {
4045
+ bgcolor: "error.light",
4046
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
4047
+ }
4048
+ }) : __spreadProps(__spreadValues({}, disabled), {
4049
+ minWidth: "60px !important"
4050
+ }),
4051
+ disabled: ![
4052
+ "ONCALL" /* ONCALL */,
4053
+ "RINGING" /* RINGING */,
4054
+ "DIALING" /* DIALING */,
4055
+ "WRAPUP" /* WRAPUP */
4056
+ ].includes((_ta = (_sa = state.callData) == null ? void 0 : _sa.status) == null ? void 0 : _ta.toUpperCase()) || endCallLoading,
4057
+ children: endCallLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4058
+ import_material4.CircularProgress,
4059
+ {
4060
+ size: "20px",
4061
+ color: "error"
4062
+ }
4063
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.CallEnd, {})
4064
+ }
4065
+ ) }),
4066
+ !((_ua = state.sdkConfig) == null ? void 0 : _ua.disabledMoreOptionsButton) && processList && (processList == null ? void 0 : processList.length) > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Switch Process", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4067
+ import_material4.Button,
4068
+ {
4069
+ variant: Boolean(moreOptionsAnchorEl) ? "contained" : "outlined",
4070
+ onClick: (e) => {
4071
+ var _a3, _b2;
4072
+ if (["BREAK" /* BREAK */, "IDLE" /* IDLE */].includes(
4073
+ (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()
4074
+ )) {
4075
+ e.stopPropagation();
4076
+ handleOpenMoreOptions(e);
4077
+ }
4078
+ },
4079
+ sx: Boolean(moreOptionsAnchorEl) ? __spreadValues({}, enabled) : __spreadValues({}, outlined),
4080
+ disabled: !["BREAK" /* BREAK */, "IDLE" /* IDLE */].includes(
4081
+ (_wa = (_va = state.callData) == null ? void 0 : _va.status) == null ? void 0 : _wa.toUpperCase()
4082
+ ),
4083
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.MoreVert, {})
4084
+ }
4085
+ ) })
4086
+ ]
4087
+ }
4088
+ )
4089
+ ]
4090
+ }
4091
+ )
4092
+ }
4093
+ )
4094
+ }
4095
+ ) }),
4096
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4097
+ import_material4.Fade,
4098
+ {
4099
+ in: true,
4100
+ timeout: 300,
4101
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4102
+ import_material4.Paper,
4103
+ {
4104
+ ref: iframeDragRef,
4105
+ elevation: iframeIsDragging ? 4 : 1,
4106
+ sx: {
4107
+ position: "absolute",
4108
+ left: iframePosition.x,
4109
+ top: iframePosition.y,
4110
+ borderRadius: 2,
4111
+ bgcolor: "background.paper",
4112
+ zIndex: Number.MAX_SAFE_INTEGER,
4113
+ transition: theme.transitions.create(["box-shadow", "transform"], {
4114
+ duration: theme.transitions.duration.short
4115
+ }),
4116
+ visibility: showIframe && !((_xa = state.sdkConfig) == null ? void 0 : _xa.disableSoftPhone) ? "visible" : "hidden",
4117
+ userSelect: "none"
4118
+ },
4119
+ children: [
4120
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4121
+ import_material4.Box,
4122
+ {
4123
+ sx: {
4124
+ display: "flex",
4125
+ alignItems: "center",
4126
+ justifyContent: "space-between",
4127
+ cursor: "all-scroll",
4128
+ padding: "0px 10px"
4129
+ },
4130
+ onMouseDown: iframeHandleMouseDown,
4131
+ onTouchStart: iframeHandleTouchStart,
4132
+ children: [
4133
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4134
+ import_icons_material2.DragIndicator,
4135
+ {
4136
+ sx: {
4137
+ transform: "rotate(90deg)",
4138
+ color: "#7b7b7b"
4139
+ }
4140
+ }
4141
+ ),
4142
+ " ",
4143
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.IconButton, { onClick: () => setShowIframe(false), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Close, {}) })
4144
+ ]
4145
+ }
4146
+ ),
4147
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4148
+ "iframe",
4149
+ {
4150
+ src: `${(_ya = state.urlConfig) == null ? void 0 : _ya.iframeURL}/static/phone/cti_index.html?user_id=${state.agentId}&api_url=${(_za = state.urlConfig) == null ? void 0 : _za.iframeAPIURL}`,
4151
+ height: 380,
4152
+ width: 420,
4153
+ allow: "camera; microphone; autoplay",
4154
+ style: {
4155
+ border: "none"
4156
+ }
4157
+ }
4158
+ ) })
4159
+ ]
4160
+ }
4161
+ )
4162
+ }
4163
+ ),
4164
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4165
+ import_material4.Menu,
4166
+ {
4167
+ anchorEl: dialerAnchorEl,
4168
+ open: Boolean(dialerAnchorEl),
4169
+ onClose: handleCloseDialer,
4170
+ onClick: (e) => e.stopPropagation(),
4171
+ sx: {
4172
+ zIndex: 99999
4173
+ },
4174
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4175
+ import_material4.Box,
4176
+ {
4177
+ sx: {
4178
+ all: "unset",
4179
+ padding: "10px",
4180
+ "&hover": {
4181
+ backgroundColor: "white"
4182
+ }
4183
+ },
4184
+ children: [
4185
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4186
+ import_material4.TextField,
4187
+ {
4188
+ size: "small",
4189
+ value: phoneNumber,
4190
+ placeholder: "Enter Mobile No.",
4191
+ onChange: (e) => {
4192
+ const value = e.target.value;
4193
+ setPhoneNumber(value);
4194
+ },
4195
+ onKeyDown: (e) => {
4196
+ if (e.key === "Enter") {
4197
+ handleStartCall(phoneNumber);
4198
+ }
4199
+ }
4200
+ }
4201
+ ),
4202
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4203
+ import_material4.IconButton,
4204
+ {
4205
+ color: "info",
4206
+ onClick: () => {
4207
+ handleStartCall(phoneNumber);
4208
+ },
4209
+ children: clickToCallLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4210
+ import_material4.CircularProgress,
4211
+ {
4212
+ size: "20px",
4213
+ sx: {
4214
+ color: theme.palette.success.main
4215
+ }
4216
+ }
4217
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Phone, { color: "success" })
4218
+ }
4219
+ )
4220
+ ]
4221
+ }
4222
+ )
4223
+ }
4224
+ ),
4225
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4226
+ import_material4.Menu,
4227
+ {
4228
+ anchorEl: ambulanceAnchorEl,
4229
+ open: Boolean(ambulanceAnchorEl),
4230
+ onClose: handleCloseAmbulance,
4231
+ onClick: (e) => e.stopPropagation(),
4232
+ sx: {
4233
+ zIndex: 99999
4234
+ },
4235
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4236
+ import_material4.Box,
4237
+ {
4238
+ sx: {
4239
+ all: "unset",
4240
+ padding: " 0px 20px",
4241
+ "&hover": {
4242
+ backgroundColor: "white"
4243
+ },
4244
+ display: "flex",
4245
+ alignItems: "center"
4246
+ },
4247
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Ambulance Service", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4248
+ import_material4.Button,
4249
+ {
4250
+ color: "primary",
4251
+ variant: "outlined",
4252
+ onClick: () => {
4253
+ handleSendSMS(state.callData);
4254
+ },
4255
+ children: [
4256
+ "Ambulance",
4257
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4258
+ import_material4.Box,
4259
+ {
4260
+ sx: {
4261
+ display: "flex",
4262
+ alignItems: "center",
4263
+ backgroundColor: "green",
4264
+ color: "#fff",
4265
+ marginLeft: "14px",
4266
+ padding: "2px 6px",
4267
+ borderRadius: "10px"
4268
+ },
4269
+ children: [
4270
+ "Send",
4271
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4272
+ import_icons_material2.SendRounded,
4273
+ {
4274
+ sx: {
4275
+ marginLeft: "8px",
4276
+ width: "18px",
4277
+ transform: "rotate(-16deg)"
4278
+ }
4279
+ }
4280
+ )
4281
+ ]
4282
+ }
4283
+ )
4284
+ ]
4285
+ }
4286
+ ) })
4287
+ }
4288
+ )
4289
+ }
4290
+ ),
4291
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4292
+ import_material4.Menu,
4293
+ {
4294
+ anchorEl: moreOptionsAnchorEl,
4295
+ open: Boolean(moreOptionsAnchorEl),
4296
+ onClose: handleCloseMoreOptions,
4297
+ onClick: (e) => e.stopPropagation(),
4298
+ sx: {
4299
+ zIndex: 99999
4300
+ },
4301
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4302
+ import_material4.Box,
4303
+ {
4304
+ sx: {
4305
+ all: "unset",
4306
+ padding: " 0px 20px",
4307
+ "&hover": {
4308
+ backgroundColor: "white"
4309
+ },
4310
+ display: "flex",
4311
+ alignItems: "center",
4312
+ flexDirection: "column",
4313
+ gap: 1
4314
+ },
4315
+ children: processList == null ? void 0 : processList.map((item) => {
4316
+ var _a3, _b2, _c2;
4317
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4318
+ import_material4.Box,
4319
+ {
4320
+ sx: {
4321
+ width: "100%"
4322
+ },
4323
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: (_a3 = item == null ? void 0 : item.process_name) != null ? _a3 : "", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4324
+ import_material4.Button,
4325
+ {
4326
+ color: "primary",
4327
+ variant: ((_b2 = state == null ? void 0 : state.process) == null ? void 0 : _b2.process_id) === (item == null ? void 0 : item.process_id) ? "contained" : "outlined",
4328
+ onClick: () => {
4329
+ sdkStateManager.setProcess(item);
4330
+ },
4331
+ sx: {
4332
+ width: "100%"
4333
+ },
4334
+ children: (_c2 = item == null ? void 0 : item.process_name) != null ? _c2 : ""
4335
+ }
4336
+ ) })
4337
+ },
4338
+ item == null ? void 0 : item.process_id
4339
+ );
4340
+ })
4341
+ }
4342
+ )
4343
+ }
4344
+ ),
4345
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4346
+ import_material4.Menu,
4347
+ {
4348
+ anchorEl: statusAnchorEl,
4349
+ open: Boolean(statusAnchorEl),
4350
+ onClose: handleCloseAgentStatus,
4351
+ onClick: (e) => e.stopPropagation(),
4352
+ sx: {
4353
+ zIndex: 99999
4354
+ },
4355
+ children: !breaksList || (breaksList == null ? void 0 : breaksList.length) === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" }) : breaksList == null ? void 0 : breaksList.map((item) => {
4356
+ var _a3, _b2, _c2;
4357
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4358
+ import_material4.MenuItem,
4359
+ {
4360
+ sx: {
4361
+ // hilight background of selected
4362
+ backgroundColor: ((_a3 = state == null ? void 0 : state.callData) == null ? void 0 : _a3.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "primary.main" : "transparent",
4363
+ color: ((_b2 = state == null ? void 0 : state.callData) == null ? void 0 : _b2.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "white" : "primary.main",
4364
+ ":hover": {
4365
+ backgroundColor: ((_c2 = state == null ? void 0 : state.callData) == null ? void 0 : _c2.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "primary.dark" : "selected.hover"
4366
+ // color:
4367
+ // state?.callData?.status === "BREAK" && state?.agentStatus === item?.type ?
4368
+ // "primary.main"
4369
+ // : "primary.main",
4370
+ }
4371
+ },
4372
+ onClick: () => handleUpdateAgentStatus(item == null ? void 0 : item.type),
4373
+ children: [
4374
+ "- ",
4375
+ item == null ? void 0 : item.type
4376
+ ]
4377
+ },
4378
+ item == null ? void 0 : item.type
4379
+ );
4380
+ })
4381
+ }
4382
+ ),
4383
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4384
+ import_material4.Menu,
4385
+ {
4386
+ anchorEl,
4387
+ open: Boolean(anchorEl),
4388
+ onClose: handleCloseQueueCounts,
4389
+ onClick: (e) => e.stopPropagation(),
4390
+ sx: {
4391
+ zIndex: 99999
4392
+ },
4393
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4394
+ import_material4.Box,
4395
+ {
4396
+ sx: {
4397
+ display: "flex",
4398
+ justifyContent: "flex-start",
4399
+ flexDirection: "column",
4400
+ padding: "0px 10px",
4401
+ "&hover": {
4402
+ backgroundColor: "white"
4403
+ }
4404
+ },
4405
+ children: [
4406
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4407
+ import_material4.Chip,
4408
+ {
4409
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Layers, { color: "secondary" }),
4410
+ variant: "outlined",
4411
+ label: "Waiting - 25",
4412
+ sx: {
4413
+ margin: "4px 2px"
4414
+ }
4415
+ }
4416
+ ),
4417
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4418
+ import_material4.Chip,
4419
+ {
4420
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pending, { color: "info" }),
4421
+ label: "Pending - 99+",
4422
+ variant: "outlined",
4423
+ sx: {
4424
+ margin: "4px 2px"
4425
+ }
4426
+ }
4427
+ ),
4428
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4429
+ import_material4.Chip,
4430
+ {
4431
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Upcoming, { color: "success" }),
4432
+ variant: "outlined",
4433
+ label: "Upcoming - 66",
4434
+ sx: {
4435
+ margin: "4px 2px"
4436
+ }
4437
+ }
4438
+ )
4439
+ ]
4440
+ }
4441
+ )
4442
+ }
4443
+ ),
4444
+ Boolean(state.openConferenceDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConferenceDialog, {}),
4445
+ Boolean(state.openCallTransferDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CallTransferDialog, { open: state.openCallTransferDialog }),
4446
+ Boolean(openCallDisposition) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4447
+ EndCallDispositionDialog,
4448
+ {
4449
+ open: openCallDisposition,
4450
+ setOpen: setOpenCallDisposition,
4451
+ onSubmitDisposition: handleEndCall
4452
+ }
4453
+ ),
4454
+ Boolean(openCallHistoryDialog) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4455
+ CallHistoryDialog,
4456
+ {
4457
+ open: openCallHistoryDialog,
4458
+ setOpen: setOpenCallHistoryDialog
4459
+ }
4460
+ )
4461
+ ] });
4462
+ }
4463
+
4464
+ // call-control-sdk/lib/components/SDKProvider.tsx
4465
+ var import_react12 = require("react");
4466
+ var import_jsx_runtime4 = require("react/jsx-runtime");
4467
+ var SDKProvider = (0, import_react12.memo)(({ children }) => {
4468
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ToastProvider, { children });
4469
+ });
4470
+ SDKProvider.displayName = "SDKProvider";
4471
+
4472
+ // call-control-sdk/lib/components/callControlPanel.tsx
4473
+ var import_jsx_runtime5 = require("react/jsx-runtime");
4474
+ var CallControlPanel = (0, import_react13.memo)(({ onDataChange }) => {
4475
+ const handleDataChange = (0, import_react13.useCallback)(
4476
+ (data) => {
4477
+ try {
4478
+ if (onDataChange && typeof onDataChange === "function") {
4479
+ onDataChange(data);
4480
+ }
4481
+ } catch (error) {
4482
+ console.error("Error in CallControlPanel data change handler:", error);
4483
+ }
4484
+ },
4485
+ [onDataChange]
4486
+ );
4487
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SDKProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CallControls, { onDataChange: handleDataChange }) });
4488
+ });
4489
+ CallControlPanel.displayName = "CallControlPanel";
4490
+
4491
+ // call-control-sdk/index.ts
4492
+ async function initSDK({
4493
+ apiKey,
4494
+ tenantId,
4495
+ agentId,
4496
+ sdkConfig,
4497
+ urlConfig
4498
+ }) {
4499
+ if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
4500
+ throw new Error(
4501
+ "SDK initialization failed: API key is required and must be a non-empty string"
4502
+ );
4503
+ }
4504
+ if (!tenantId || typeof tenantId !== "string" || tenantId.trim().length === 0) {
4505
+ throw new Error(
4506
+ "SDK initialization failed: Tenant ID is required and must be a non-empty string"
4507
+ );
4508
+ }
4509
+ if (!agentId || typeof agentId !== "string" || agentId.trim().length === 0) {
4510
+ throw new Error(
4511
+ "SDK initialization failed: Agent ID is required and must be a non-empty string"
4512
+ );
4513
+ }
4514
+ try {
4515
+ const initResult = await eventTracker.init({
4516
+ apiKey: apiKey.trim(),
4517
+ tenantId: tenantId.trim(),
4518
+ agentId: agentId.trim(),
4519
+ password: urlConfig == null ? void 0 : urlConfig.password,
4520
+ baseUrl: urlConfig == null ? void 0 : urlConfig.baseURL
4521
+ });
4522
+ const res = {
4523
+ accessToken: initResult == null ? void 0 : initResult.accessToken,
4524
+ expiration: initResult == null ? void 0 : initResult.expiration,
4525
+ ticketId: initResult == null ? void 0 : initResult.ticketId
4526
+ };
4527
+ if (initResult) {
4528
+ console.info("SDK initialized successfully");
4529
+ sdkStateManager.initialize(
4530
+ apiKey.trim(),
4531
+ tenantId.trim(),
4532
+ agentId.trim(),
4533
+ __spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig),
4534
+ res
4535
+ );
4536
+ } else {
4537
+ sdkStateManager.setInitCheck();
4538
+ throw new Error(
4539
+ "SDK initialization failed: Unable to establish connection with the CTI system"
4540
+ );
4541
+ }
4542
+ } catch (error) {
4543
+ sdkStateManager.setInitCheck();
4544
+ if (error instanceof Error) {
4545
+ throw error;
4546
+ } else {
4547
+ throw new Error(`SDK initialization failed: ${String(error)}`);
4548
+ }
4549
+ }
4550
+ }
4551
+ function getSDKVersion() {
4552
+ return "6.x.x";
4553
+ }
4554
+ function isSDKInitialized() {
4555
+ return sdkStateManager.getState().isInitialized;
4556
+ }
4557
+ // Annotate the CommonJS export names for ESM import in node:
4558
+ 0 && (module.exports = {
4559
+ CallControlPanel,
4560
+ getSDKVersion,
4561
+ initSDK,
4562
+ isSDKInitialized,
4563
+ useClickToCall,
4564
+ useEndCall,
4565
+ useGetAuthorizationToken,
4566
+ useGetCallerData,
4567
+ useLogout
4568
+ });
4569
+ //# sourceMappingURL=index.js.map