ahs-cti 0.0.8 → 0.0.9

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