call-control-sdk 5.0.9 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -17
- package/dist/index.d.mts +25 -16
- package/dist/index.d.ts +25 -16
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,22 +32,22 @@ npm install react react-dom axios @mui/material @mui/icons-material @emotion/rea
|
|
|
32
32
|
### 1. Initialize the SDK
|
|
33
33
|
|
|
34
34
|
```typescript
|
|
35
|
-
import { initSDK } from
|
|
35
|
+
import { initSDK } from "call-control-sdk";
|
|
36
36
|
|
|
37
37
|
// Initialize at the top level of your app
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
// Initialize the SDK.
|
|
40
|
+
try {
|
|
41
|
+
initSDK({
|
|
42
|
+
apiKey: "apiKey",
|
|
43
|
+
tenantId: "tenantId",
|
|
44
|
+
agentId: "agentId",
|
|
45
|
+
});
|
|
46
|
+
console.log("SDK initialized successfully");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error("SDK initialization failed:", error);
|
|
49
|
+
}
|
|
50
|
+
}, []);
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
### 2. Use the CallControlPanel
|
|
@@ -69,7 +69,8 @@ function App() {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
```
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
### 3. Use the useLogout Hook
|
|
73
74
|
|
|
74
75
|
```typescript
|
|
75
76
|
import React from 'react';
|
|
@@ -84,8 +85,63 @@ function App() {
|
|
|
84
85
|
);
|
|
85
86
|
}
|
|
86
87
|
```
|
|
88
|
+
|
|
87
89
|
- `useLogout` is used to logout the agent.
|
|
88
90
|
|
|
91
|
+
### 4. Use the useEndCall Hook
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import React from "react";
|
|
95
|
+
import { useEndCall } from "call-control-sdk";
|
|
96
|
+
|
|
97
|
+
export default function EndCallButton() {
|
|
98
|
+
const { handleEndCall, isLoading, isSuccess, isError, error, data } = useEndCall();
|
|
99
|
+
|
|
100
|
+
const onEndCall = () => {
|
|
101
|
+
handleEndCall({
|
|
102
|
+
disposition: "RES", // Call disposition
|
|
103
|
+
followUp: "N", // Y or N
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
{isLoading ? "Ending Call..." : "End Call"}
|
|
109
|
+
{isSuccess && "Call ended successfully"}
|
|
110
|
+
{isError && `Error: ${error?.message}`}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
useEndCall Hook for handling **end-call functionality** from your application.
|
|
116
|
+
It manages the API request, state (`loading`, `success`, `error`), and automatically resets the call
|
|
117
|
+
state when a call ends.
|
|
118
|
+
|
|
119
|
+
## ■ API
|
|
120
|
+
|
|
121
|
+
### `useEndCall()`
|
|
122
|
+
|
|
123
|
+
Returns an object with the following properties:
|
|
124
|
+
|
|
125
|
+
- `handleEndCall` -> `(data: EndCallPayload) => void` | Function to trigger the end call request.
|
|
126
|
+
Requires call disposition data.
|
|
127
|
+
- `isSuccess` -> `boolean` | `true` if the API request completed successfully. |
|
|
128
|
+
- `isError` -> `boolean` | `true` if an error occurred during the request. |
|
|
129
|
+
- `error` -> `any` | Error object returned from the failed request. |
|
|
130
|
+
- `data` -> `any` | Response data returned by the API on success. |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## ■ Payload Structure
|
|
135
|
+
|
|
136
|
+
The `handleEndCall` function accepts an object with the following fields:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
{
|
|
140
|
+
disposition?: string; // Call disposition (default: "RES")
|
|
141
|
+
followUp?: string; // Whether to set follow-up ("Y" or "N")
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
89
145
|
## API Reference
|
|
90
146
|
|
|
91
147
|
### `initSDK({apiKey: "apiKey",tenantId: "tenantId",agentId: "agentId",})`
|
|
@@ -93,18 +149,19 @@ function App() {
|
|
|
93
149
|
Initializes the SDK with an API key, tenantId, agentId, baseUrl. Must be called before using any components.
|
|
94
150
|
|
|
95
151
|
**Parameters:**
|
|
152
|
+
|
|
96
153
|
- `apiKey` (string): Your API key for SDK authentication
|
|
97
154
|
- `tenantId` (string): Your Tenant Id key for Events authentication
|
|
98
155
|
- `agentId` (string): Agent Id for access call controls
|
|
99
156
|
|
|
100
157
|
**Throws:** Error if API key is missing or invalid
|
|
101
158
|
|
|
102
|
-
|
|
103
159
|
### `CallControlPanel`
|
|
104
160
|
|
|
105
161
|
The main draggable control panel component.
|
|
106
162
|
|
|
107
163
|
**Props:**
|
|
164
|
+
|
|
108
165
|
- `onDataChange?` (function): Callback fired when call data changes
|
|
109
166
|
- Parameters: `{ mobileNumber: string, callReferenceId: string, agentLoginId: string }`
|
|
110
167
|
|
|
@@ -113,6 +170,7 @@ The main draggable control panel component.
|
|
|
113
170
|
Updates the call data that will be passed to the `onDataChange` callback.
|
|
114
171
|
|
|
115
172
|
**Parameters:**
|
|
173
|
+
|
|
116
174
|
- `data.mobileNumber?` (string): Mobile phone number
|
|
117
175
|
- `data.callReferenceId?` (string): Call reference ID
|
|
118
176
|
- `data.agentLoginId?` (string): Agent login ID
|
|
@@ -120,17 +178,21 @@ Updates the call data that will be passed to the `onDataChange` callback.
|
|
|
120
178
|
## Control Features
|
|
121
179
|
|
|
122
180
|
### Status Management
|
|
181
|
+
|
|
123
182
|
- **Idle**: Default state, no active call
|
|
124
183
|
- **Break**: Agent is on break
|
|
125
184
|
|
|
126
185
|
### Call Controls
|
|
186
|
+
|
|
127
187
|
- **Hold/Resume**: Toggle call hold state
|
|
128
188
|
- **Mute/Unmute**: Toggle microphone
|
|
129
189
|
- **End Call**: Terminate active call
|
|
130
190
|
- **More Menu**: Access status change options
|
|
131
191
|
|
|
132
192
|
### Persistent State
|
|
193
|
+
|
|
133
194
|
All control states are automatically persistent:
|
|
195
|
+
|
|
134
196
|
- Hold/mute states
|
|
135
197
|
- Agent status
|
|
136
198
|
- Panel position
|
|
@@ -145,4 +207,4 @@ All control states are automatically persistent:
|
|
|
145
207
|
|
|
146
208
|
## License
|
|
147
209
|
|
|
148
|
-
MIT © 2025
|
|
210
|
+
MIT © 2025
|
package/dist/index.d.mts
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
interface LogoutResponse {
|
|
4
|
-
success: boolean;
|
|
5
|
-
message?: string;
|
|
6
|
-
data?: any;
|
|
7
|
-
}
|
|
8
|
-
interface UseLogoutOptions {
|
|
9
|
-
onSuccess?: (response: LogoutResponse) => void;
|
|
10
|
-
onError?: (error: any) => void;
|
|
11
|
-
onComplete?: () => void;
|
|
12
|
-
}
|
|
13
3
|
/**
|
|
14
4
|
* Custom hook for handling agent logout functionality
|
|
15
5
|
* @param options - Optional callbacks for success, error, and completion
|
|
16
6
|
* @returns Object containing logout function and loading state
|
|
17
7
|
*/
|
|
18
|
-
declare const useLogout: (
|
|
8
|
+
declare const useLogout: () => {
|
|
19
9
|
logout: () => void;
|
|
20
10
|
isLoading: boolean;
|
|
21
11
|
isSuccess: boolean;
|
|
22
12
|
isError: boolean;
|
|
23
|
-
error:
|
|
24
|
-
data:
|
|
13
|
+
error: null;
|
|
14
|
+
data: null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Custom hook for handling end call functionality
|
|
19
|
+
* @param options - Optional callbacks for success, error, and completion
|
|
20
|
+
* @returns Object containing logout function and loading state
|
|
21
|
+
*/
|
|
22
|
+
declare const useEndCall: () => {
|
|
23
|
+
handleEndCall: (data: {
|
|
24
|
+
disposition?: string;
|
|
25
|
+
followUp?: string;
|
|
26
|
+
callbackDate?: string;
|
|
27
|
+
callbackHrs?: string;
|
|
28
|
+
callbackMins?: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
isSuccess: boolean;
|
|
32
|
+
isError: boolean;
|
|
33
|
+
error: null;
|
|
34
|
+
data: null;
|
|
25
35
|
};
|
|
26
36
|
|
|
27
37
|
interface CallData {
|
|
@@ -53,8 +63,7 @@ type intiSDKParams = {
|
|
|
53
63
|
apiKey: string;
|
|
54
64
|
tenantId: string;
|
|
55
65
|
agentId: string;
|
|
56
|
-
baseURL: string;
|
|
57
66
|
};
|
|
58
|
-
declare function initSDK({ apiKey, tenantId, agentId
|
|
67
|
+
declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
|
|
59
68
|
|
|
60
|
-
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useLogout };
|
|
69
|
+
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useEndCall, useLogout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
interface LogoutResponse {
|
|
4
|
-
success: boolean;
|
|
5
|
-
message?: string;
|
|
6
|
-
data?: any;
|
|
7
|
-
}
|
|
8
|
-
interface UseLogoutOptions {
|
|
9
|
-
onSuccess?: (response: LogoutResponse) => void;
|
|
10
|
-
onError?: (error: any) => void;
|
|
11
|
-
onComplete?: () => void;
|
|
12
|
-
}
|
|
13
3
|
/**
|
|
14
4
|
* Custom hook for handling agent logout functionality
|
|
15
5
|
* @param options - Optional callbacks for success, error, and completion
|
|
16
6
|
* @returns Object containing logout function and loading state
|
|
17
7
|
*/
|
|
18
|
-
declare const useLogout: (
|
|
8
|
+
declare const useLogout: () => {
|
|
19
9
|
logout: () => void;
|
|
20
10
|
isLoading: boolean;
|
|
21
11
|
isSuccess: boolean;
|
|
22
12
|
isError: boolean;
|
|
23
|
-
error:
|
|
24
|
-
data:
|
|
13
|
+
error: null;
|
|
14
|
+
data: null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Custom hook for handling end call functionality
|
|
19
|
+
* @param options - Optional callbacks for success, error, and completion
|
|
20
|
+
* @returns Object containing logout function and loading state
|
|
21
|
+
*/
|
|
22
|
+
declare const useEndCall: () => {
|
|
23
|
+
handleEndCall: (data: {
|
|
24
|
+
disposition?: string;
|
|
25
|
+
followUp?: string;
|
|
26
|
+
callbackDate?: string;
|
|
27
|
+
callbackHrs?: string;
|
|
28
|
+
callbackMins?: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
isSuccess: boolean;
|
|
32
|
+
isError: boolean;
|
|
33
|
+
error: null;
|
|
34
|
+
data: null;
|
|
25
35
|
};
|
|
26
36
|
|
|
27
37
|
interface CallData {
|
|
@@ -53,8 +63,7 @@ type intiSDKParams = {
|
|
|
53
63
|
apiKey: string;
|
|
54
64
|
tenantId: string;
|
|
55
65
|
agentId: string;
|
|
56
|
-
baseURL: string;
|
|
57
66
|
};
|
|
58
|
-
declare function initSDK({ apiKey, tenantId, agentId
|
|
67
|
+
declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
|
|
59
68
|
|
|
60
|
-
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useLogout };
|
|
69
|
+
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useEndCall, useLogout };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ko=Object.create;var ct=Object.defineProperty,Ao=Object.defineProperties,No=Object.getOwnPropertyDescriptor,Po=Object.getOwnPropertyDescriptors,Oo=Object.getOwnPropertyNames,go=Object.getOwnPropertySymbols,Uo=Object.getPrototypeOf,fo=Object.prototype.hasOwnProperty,Mo=Object.prototype.propertyIsEnumerable;var Bt=(r,t,n)=>t in r?ct(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,d=(r,t)=>{for(var n in t||(t={}))fo.call(t,n)&&Bt(r,n,t[n]);if(go)for(var n of go(t))Mo.call(t,n)&&Bt(r,n,t[n]);return r},$=(r,t)=>Ao(r,Po(t));var Bo=(r,t)=>{for(var n in t)ct(r,n,{get:t[n],enumerable:!0})},mo=(r,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of Oo(t))!fo.call(r,p)&&p!==n&&ct(r,p,{get:()=>t[p],enumerable:!(l=No(t,p))||l.enumerable});return r};var Ho=(r,t,n)=>(n=r!=null?ko(Uo(r)):{},mo(t||!r||!r.__esModule?ct(n,"default",{value:r,enumerable:!0}):n,r)),$o=r=>mo(ct({},"__esModule",{value:!0}),r);var q=(r,t,n)=>Bt(r,typeof t!="symbol"?t+"":t,n);var Yo={};Bo(Yo,{CallControlPanel:()=>Ro,initSDK:()=>jo,useLogout:()=>bo});module.exports=$o(Yo);var Ht=class{constructor(){q(this,"config",null);q(this,"ticketId",null);q(this,"baseUrl","");q(this,"eventQueue",[]);q(this,"isOnline",!0);q(this,"retryQueue",[]);q(this,"flushTimer",null)}async init(t){this.config=d({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},t),this.baseUrl=t.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let n=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),n}isInitialized(){return this.config!==null&&this.ticketId!==null}getConfig(){return this.config}getTicketId(){return this.ticketId}async createTicket(){if(!this.config)throw new Error("EventTracker not initialized");try{let t=await this.makeRequest("/api/v1/et/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({agentId:this.config.agentId,sessionId:this.config.sessionId})});if(!t.ok)throw new Error(`Failed to initialize: ${t.status} ${t.statusText}`);let n=await t.json();return this.ticketId=n.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(t){throw console.error("EventTracker initialization failed:",t),t}}async logEvent(t,n){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",t);return}let l={eventType:t,eventData:n,timestamp:Date.now()};if(this.eventQueue.push(l),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(l)}catch(p){console.warn("Failed to send event, will retry later:",p)}}async sendEvent(t){if(!(!this.config||!this.ticketId))try{let n=await this.makeRequest("/api/v1/et/event",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId,eventType:t.eventType,eventData:t.eventData})});if(!n.ok)throw new Error(`Failed to log event: ${n.status} ${n.statusText}`);let l=this.eventQueue.findIndex(p=>p.timestamp===t.timestamp);l>-1&&this.eventQueue.splice(l,1)}catch(n){console.error("Event logging failed:",n),this.retryQueue.push(()=>this.sendEvent(t))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let t=await this.makeRequest("/api/v1/et/close",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId})});if(!t.ok)throw new Error(`Failed to close ticket: ${t.status} ${t.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(t){throw console.error("Ticket close failed:",t),t}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let t=[...this.eventQueue];for(let l of t)await this.sendEvent(l);let n=[...this.retryQueue];this.retryQueue=[];for(let l of n)try{await l()}catch(p){console.error("Retry failed:",p)}}async makeRequest(t,n){var e;let l=`${this.baseUrl}${t}`,p=((e=this.config)==null?void 0:e.retryAttempts)||3;for(let f=1;f<=p;f++)try{return await fetch(l,n)}catch(h){if(f===p)throw h;let D=Math.min(1e3*Math.pow(2,f-1),1e4);await new Promise(C=>setTimeout(C,D))}throw new Error("Max retries exceeded")}setupAutoTracking(){var l;if(typeof window=="undefined"||!((l=this.config)!=null&&l.autoTrack))return;let t=this.config.autoTrack===!0?{}:this.config.autoTrack;if(t.pageVisits!==!1&&this.logEvent("pageVisit",{url:window.location.href,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}).catch(p=>console.warn("Failed to track page visit:",p)),t.clicks!==!1&&document.addEventListener("click",p=>{var f;let e=p.target;(e.tagName==="BUTTON"||e.tagName==="A"||e.onclick||e.getAttribute("role")==="button"||e instanceof HTMLButtonElement&&e.type==="button")&&this.logEvent("click",{element:e.tagName,text:(f=e.textContent)==null?void 0:f.trim().substring(0,100),href:e.getAttribute("href"),id:e.id,className:e.className,role:e.getAttribute("role"),position:{x:p.clientX,y:p.clientY},timestamp:new Date().toISOString()}).catch(h=>console.warn("Failed to track click:",h))}),t.forms!==!1&&document.addEventListener("submit",p=>{let e=p.target,f=new FormData(e),h={};f.forEach((D,C)=>{h[C]=D.toString()}),this.logEvent("formSubmission",{formId:e.id,action:e.action,method:e.method,fields:Object.keys(h),fieldCount:Object.keys(h).length,timestamp:new Date().toISOString()}).catch(D=>console.warn("Failed to track form submission:",D))}),t.inputs!==!1){let p;document.addEventListener("input",e=>{let f=e.target;(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.tagName==="SELECT")&&(clearTimeout(p),p=setTimeout(()=>{var h;this.logEvent("fieldChange",{element:f.tagName,type:f.getAttribute("type"),name:f.getAttribute("name"),id:f.id,valueLength:((h=f.value)==null?void 0:h.length)||0,timestamp:new Date().toISOString()}).catch(D=>console.warn("Failed to track field change:",D))},1e3))})}let n=Date.now();window.addEventListener("beforeunload",()=>{let p=Date.now()-n;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:p,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),t.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),t.errors!==!1&&(window.addEventListener("error",p=>{this.logEvent("jsError",{message:p.message,filename:p.filename,lineno:p.lineno,colno:p.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",p=>{var e;this.logEvent("unhandledRejection",{reason:(e=p.reason)==null?void 0:e.toString(),timestamp:new Date().toISOString()})})),t.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let p=window.performance.navigation,e=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:e.navigationStart,loadTime:e.loadEventEnd-e.navigationStart,domReady:e.domContentLoadedEventEnd-e.navigationStart,renderTime:e.loadEventEnd-e.domContentLoadedEventEnd,navigationType:p.type,redirectCount:p.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(this.isOnline=navigator.onLine,window.addEventListener("online",()=>{this.isOnline=!0,console.log("EventTracker: Back online, flushing queued events"),this.flush()}),window.addEventListener("offline",()=>{this.isOnline=!1,console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){var n;this.flushTimer&&clearInterval(this.flushTimer);let t=((n=this.config)==null?void 0:n.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},t)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},$t=new Ht;typeof window!="undefined"&&(window.EventTracker=$t);var zt=class{constructor(){q(this,"state");q(this,"listeners",[]);q(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{url:"",apiKey:null,process:null,agentId:"",isInitialized:!1,isHolding:!1,isMuted:!1,status:"idle",callStartTime:null,controlPanelPosition:{x:10,y:10},iframePosition:{x:10,y:80},callData:{agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:[{line:1,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:2,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:3,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:4,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:5,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1}]}}loadFromStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);if(t){let n=JSON.parse(t);this.state=$(d({},this.state),{apiKey:n.apiKey||"",agentId:n.agentId||"",process:n.process||null,isInitialized:n.isInitialized||!1,isHolding:n.isHolding||!1,isMuted:n.isMuted||!1,status:n.status||"idle",url:n.url||"",callStartTime:n.callStartTime||null,controlPanelPosition:n.controlPanelPosition||{x:10,y:10},iframePosition:n.iframePosition||{x:10,y:80},callData:n.callData||{mobileNumber:"",callReferenceId:"",agentLoginId:""},conferenceLine:n.conferenceLine&&Array.isArray(n.conferenceLine)&&n.conferenceLine.length>0?n.conferenceLine:this.state.conferenceLine})}}catch(t){console.warn("Failed to load SDK state from localStorage:",t)}}saveToStorage(){try{let t={url:this.state.url,apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,isHolding:this.state.isHolding,isMuted:this.state.isMuted,status:this.state.status,callStartTime:this.state.callStartTime,controlPanelPosition:this.state.controlPanelPosition,iframePosition:this.state.iframePosition,callData:this.state.callData,conferenceLine:this.state.conferenceLine};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(t))}catch(t){console.warn("Failed to save SDK state to localStorage:",t)}}notifyListeners(){this.listeners.forEach(t=>t())}initialize(t,n,l){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("API key not available");this.state.apiKey=t,this.state.agentId=n,this.state.isInitialized=!0,this.state.url=l,this.saveToStorage(),this.notifyListeners()}getState(){return d({},this.state)}subscribe(t){return this.listeners.push(t),()=>{let n=this.listeners.indexOf(t);n>-1&&this.listeners.splice(n,1)}}setHolding(t){this.state.isHolding=t,this.saveToStorage(),this.notifyListeners()}setMuted(t){this.state.isMuted=t,this.saveToStorage(),this.notifyListeners()}setStatus(t){this.state.status=t,this.saveToStorage(),this.notifyListeners()}setProcess(t){this.state.process=t,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(t){this.state.controlPanelPosition=t,this.saveToStorage(),this.notifyListeners()}setIframePosition(t){this.state.iframePosition=t,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}updateCallData(t){this.state.callData=d(d({},this.state.callData),t),this.saveToStorage(),this.notifyListeners()}setConferenceLine(t){var l;(!this.state.conferenceLine||!Array.isArray(this.state.conferenceLine))&&(console.warn("Conference line data corrupted, resetting to initial state"),this.state.conferenceLine=this.getInitialState().conferenceLine);let n=(l=this.state.conferenceLine)==null?void 0:l.map(p=>p.line===t.line?t:p);this.state.conferenceLine=n,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(t){console.warn("Failed to clear localStorage:",t)}}debugStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",t),t&&console.log("Parsed localStorage data:",JSON.parse(t)),console.log("Current state:",this.state)}catch(t){console.error("Error debugging storage:",t)}}getConferenceLines(){return this.state.conferenceLine||[]}getUrl(){return this.state.url||""}},T=new zt;var Co=require("react");var Ot=require("react");var yo=Ho(require("axios"));var xo=T.getUrl(),P=`http://${xo}`,zo=`ws://${xo}`,U={v1:"/api/v1"},k={LOGIN:`${P}${U.v1}/cti/login?provider=convox`,READY_AGENT:`${P}${U.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${P}${U.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${P}${U.v1}/cti/calls?provider=convox`,HOLD_CALL:`${P}${U.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${P}${U.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${P}${U.v1}/cti/unmute-call?provider=convox`,END_CALL:`${P}${U.v1}/cti/calls/end?provider=convox`,LOGOUT:`${P}${U.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${P}${U.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${P}${U.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${P}${U.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${P}${U.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${P}${U.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${P}${U.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${P}${U.v1}/cti/users`,PROCESS_LIST:`${P}${U.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${P}${U.v1}/cti/transfer-to-details?provider=convox`},ho={WS:`${zo}${U.v1}/cti/ws`};var Wo="12345",Wt=yo.default.create({baseURL:P,headers:{"Content-Type":"application/json",Authorization:Wo},timeout:1e4});Wt.interceptors.request.use(r=>{let t="12345";return t&&r.headers&&(r.headers.Authorization=`Bearer ${t}`),r},r=>Promise.reject(r instanceof Error?r:new Error(String(r))));Wt.interceptors.response.use(r=>r,async r=>{var n;let t=r.config;return((n=r.response)==null?void 0:n.status)===401&&!t._retry&&(t._retry=!0),Promise.reject(r instanceof Error?r:new Error(String(r)))});var Y=Wt;var Pt=require("@mui/material"),vo=require("react"),qt=require("react/jsx-runtime");function pt(){let[r,t]=(0,vo.useState)(!1),n=(p,e)=>{e!=="clickaway"&&t(!1)};return{showToast:(p,e)=>(t(!0),(0,qt.jsx)(Pt.Snackbar,{anchorOrigin:{vertical:"top",horizontal:"right"},open:r,onClose:n,children:(0,qt.jsx)(Pt.Alert,{onClose:n,severity:e,variant:"filled",sx:{width:"100%"},children:p})}))}}var qo={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},Fo=(r,t)=>{if(t.type==="isLoading")return $(d({},r),{isLoading:t.payload});if(t.type==="isSuccess")return $(d({},r),{isSuccess:!0,data:t.payload});if(t.type==="isError")return $(d({},r),{isError:!0,error:t.payload});if(t.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var W=(r={})=>{let{onSuccess:t=null,onError:n=null}=r,{showToast:l}=pt(),[p,e]=(0,Ot.useReducer)(Fo,qo);return[(0,Ot.useCallback)((h,D,C={})=>{e({type:"isLoading",payload:!0}),Y.post(h,D,C).then(w=>{e({type:"isSuccess",payload:w.data}),t==null||t(w.data,D)}).catch(w=>{var L,I,A,H,B,o,m,x,y,S,g,E;let M={status:(I=(L=w.response)==null?void 0:L.status)!=null?I:500,message:((H=(A=w.response)==null?void 0:A.data)==null?void 0:H.detail)||((o=(B=w.response)==null?void 0:B.data)==null?void 0:o.message)||w.message||"An unknown error occurred",data:(x=(m=w.response)==null?void 0:m.data)!=null?x:null,statusText:(S=(y=w.response)==null?void 0:y.statusText)!=null?S:"",code:(g=w==null?void 0:w.code)!=null?g:"",name:(E=w==null?void 0:w.name)!=null?E:""};l(M.message,"error"),e({type:"isError",payload:M}),n==null||n(M,D)}).finally(()=>{e({type:"isLoading",payload:!1})})},[t,n,l]),p]};var Ut=require("react");function ot(){let[r,t]=(0,Ut.useState)(T.getState());return(0,Ut.useEffect)(()=>T.subscribe(()=>{t(T.getState())}),[]),r}var Go=(r={})=>{let{onSuccess:t,onError:n,onComplete:l}=r,p=ot(),[e,f]=W({onSuccess:D=>{t==null||t(D),l==null||l(),T.clearStorageAndReset(),localStorage.clear()},onError:D=>{n==null||n(D),l==null||l()}});return{logout:(0,Co.useCallback)(()=>{let D={action:"LOGOUTUSER",userId:p.agentId||""};e(k.LOGOUT,D)},[e]),isLoading:f.isLoading,isSuccess:f.isSuccess,isError:f.isError,error:f.error,data:f.data}},bo=Go;var v=require("@mui/icons-material"),u=require("@mui/material"),N=require("react");var F=require("react");function Ft(r,t){let[n,l]=(0,F.useState)(r),[p,e]=(0,F.useState)(!1),f=(0,F.useRef)(),h=(0,F.useRef)({x:0,y:0}),D=(0,F.useRef)({x:0,y:0}),C=(0,F.useCallback)(I=>{let A=f.current;if(!A)return;let H=A.getBoundingClientRect(),B=window.innerWidth,o=window.innerHeight,m={x:Math.max(0,Math.min(I.x,B-H.width)),y:Math.max(0,Math.min(I.y,o-H.height))};l(m),t==null||t(m)},[t]),w=(0,F.useCallback)((I,A)=>{e(!0),h.current={x:I,y:A},D.current=n;let H=(x,y)=>{let S=x-h.current.x,g=y-h.current.y;C({x:D.current.x+S,y:D.current.y+g})},B=x=>{x.preventDefault(),H(x.clientX,x.clientY)},o=x=>{x.preventDefault();let y=x.touches[0];y&&H(y.clientX,y.clientY)},m=()=>{e(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",m)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",m),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",m)},[n,C]),M=(0,F.useCallback)(I=>{I.preventDefault(),w(I.clientX,I.clientY)},[w]),L=(0,F.useCallback)(I=>{I.preventDefault();let A=I.touches[0];A&&w(A.clientX,A.clientY)},[w]);return{position:n,isDragging:p,dragRef:f,handleMouseDown:M,handleTouchStart:L}}var R=require("@mui/icons-material"),s=require("@mui/material"),at=require("react");var So=require("@mui/material"),Ko=()=>{let r=(0,So.useTheme)();return{disabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",border:"1px solid rgb(206, 204, 204)",height:"40px","&:hover":{boxShadow:" 0px 2px 2px rgba(0, 0, 0, 0.79)",border:`1px solid ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.palette.primary.light}`}},enabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${r.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.palette.primary.light}`}},outlined:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:r.palette.grey[200],boxShadow:`0px 2px 1px ${r.palette.primary.light}`,border:`0px solid ${r.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${r.palette.primary.main}`,border:`0px solid ${r.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${r.palette.primary.light}`}}}},Mt=Ko;var a=require("react/jsx-runtime");function Eo({open:r,setOpen:t}){var H,B;let n=ot(),{disabled:l,enabled:p,outlined:e}=Mt(),f=(0,s.useTheme)(),h=()=>{t(!1)},D=(o,m)=>{T.setConferenceLine(d(d({},o),m))},C=(o,m)=>{var S,g,E,_;let x=d(d({},o),m),y={action:"EXTERNAL_CONFERENCE",operation:`CALL${x.line}`,line_used:String(x.line),thirdparty_no:x.phone,userid:(g=(S=n.callData)==null?void 0:S.agent_id)!=null?g:"",process:(_=(E=n.callData)==null?void 0:E.process_name)!=null?_:""};Y.post(k.CONFERENCE_CALL,y).then(()=>{T.setConferenceLine(d(d({},o),m))})},w=(o,m)=>{var S,g,E,_;let x=d(d({},o),m),y={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(x.line),thirdparty_no:x.phone,userid:(g=(S=n.callData)==null?void 0:S.agent_id)!=null?g:"",process:(_=(E=n.callData)==null?void 0:E.process_name)!=null?_:""};Y.post(k.CONFERENCE_CALL,y).then(()=>{T.setConferenceLine(d(d({},o),m))})},M=(o,m,x)=>{var g,E,_,z;let y=d(d({},o),m),S={action:"EXTERNAL_CONFERENCE",operation:x,hold_channel_no:x==="HOLDUSER"?`hold${y.line}`:`unhold${y.line}`,userid:(E=(g=n.callData)==null?void 0:g.agent_id)!=null?E:"",process:(z=(_=n.callData)==null?void 0:_.process_name)!=null?z:""};Y.post(k.CONFERENCE_CALL_HOLD_OR_UN_HOLD,S).then(()=>{T.setConferenceLine(d(d({},o),m))})},L=(o,m,x)=>{var g,E,_,z;let y=d(d({},o),m),S={action:"EXTERNAL_CONFERENCE",operation:x,channel_no:x==="MUTEUSER"?`mute${y.line}`:`play${y.line}`,userid:(E=(g=n.callData)==null?void 0:g.agent_id)!=null?E:"",thirdparty_no:y.phone,process:(z=(_=n.callData)==null?void 0:_.process_name)!=null?z:""};Y.post(k.CONFERENCE_CALL_MUTE_OT_UN_MUTE,S).then(()=>{T.setConferenceLine(d(d({},o),m))})},I=(o,m)=>{var S,g,E,_;let x=d(d({},o),m),y={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(x.line-1),user_type:`THIRDPARTY${x.line-1}`,thirdparty_no:x.phone,userid:(g=(S=n.callData)==null?void 0:S.agent_id)!=null?g:"",process:(_=(E=n.callData)==null?void 0:E.process_name)!=null?_:""};Y.post(k.CONFERENCE_CALL_END,y).then(()=>{T.setConferenceLine(d(d({},o),m))})},A=()=>{var m,x,y,S;let o={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(x=(m=n.callData)==null?void 0:m.agent_id)!=null?x:"",process:(S=(y=n.callData)==null?void 0:y.process_name)!=null?S:""};Y.post(k.CONFERENCE_CALL_END_ALL,o).then(()=>{T.resetConferenceLines(),h()})};return(0,at.useEffect)(()=>{var m,x,y,S;let o={line:1,status:(x=(m=n.callData)==null?void 0:m.status)!=null?x:"",type:"internal",phone:(S=(y=n.callData)==null?void 0:y.phone_number)!=null?S:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};T.setConferenceLine(o)},[]),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(s.Dialog,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,a.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,a.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[(0,a.jsxs)(s.Typography,{variant:"body1",children:[(H=n==null?void 0:n.agentId)!=null?H:""," conference"]}),(0,a.jsx)(s.IconButton,{onClick:h,children:(0,a.jsx)(R.Close,{})})]}),(0,a.jsx)(s.Box,{sx:{boxShadow:"0px 1px 2px #e7e5e5ff",padding:"2px 6px",margin:"0px 10px",borderRadius:"20px"},children:(B=n==null?void 0:n.conferenceLine)==null?void 0:B.map((o,m)=>{var x,y;return(0,a.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[(0,a.jsx)(s.Box,{sx:{color:"white",bgcolor:"warning.main",fontWeight:"bold",fontSize:14,minWidth:70,textAlign:"center",border:"2px solid primary.main",borderRadius:"10px 50px 50px 10px"},children:(0,a.jsx)(s.Typography,{children:(x=o==null?void 0:o.line)!=null?x:""})}),(0,a.jsx)(s.Typography,{variant:"body2",sx:{px:1,border:"2px solid gray",borderRadius:"10px",textAlign:"center",width:"80px",maxWidth:"100px"},children:(y=o==null?void 0:o.status)!=null?y:""}),(0,a.jsx)(s.Button,{sx:{textTransform:"capitalize"},size:"small",children:(0,a.jsx)(s.Typography,{variant:"body2",children:(o==null?void 0:o.line)===1?"Internal":"External"})}),(0,a.jsx)(s.TextField,{size:"small",placeholder:"Phone Number",value:(o==null?void 0:o.phone)||"",disabled:(o==null?void 0:o.line)===1,onChange:S=>{D(o,{phone:S.target.value})}}),(0,a.jsx)(s.Tooltip,{title:"Call",children:(0,a.jsx)(s.Button,{variant:o!=null&&o.isCallStart?"outlined":"contained",color:"success",sx:o!=null&&o.isCallStart?d({},l):$(d({},p),{border:`0px solid ${f.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${f.palette.success.light}`,border:`0px solid ${f.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${f.palette.primary.light}`}}),onClick:()=>{C(o,{isCallStart:!0,status:"ONCALL"})},disabled:o==null?void 0:o.isCallStart,children:(0,a.jsx)(R.Call,{sx:{color:o!=null&&o.isCallStart?"default":"#fff"}})})}),(0,a.jsx)(s.Tooltip,{title:"Merge Call",children:(0,a.jsx)(s.Button,{variant:o!=null&&o.isMergeCall?"contained":"outlined",sx:o!=null&&o.isMergeCall&&(o!=null&&o.isCallStart)?d({},l):o!=null&&o.isCallStart?d({},e):d({},l),onClick:()=>{w(o,{isMergeCall:!0,status:"ONCALL"})},disabled:!(o!=null&&o.isCallStart),children:(0,a.jsx)(R.CallSplit,{})})}),(0,a.jsx)(s.Tooltip,{title:o.isHold?"Hold":"Un Hold",children:(0,a.jsx)(s.Button,{variant:o!=null&&o.isHold?"contained":"outlined",sx:o!=null&&o.isHold&&(o!=null&&o.isCallStart)?d({},l):o!=null&&o.isCallStart?d({},e):d({},l),onClick:()=>{o.isHold?M(o,{isHold:!1},"UNHOLDUSER"):M(o,{isHold:!0},"HOLDUSER")},disabled:!(o!=null&&o.isCallStart),children:o.isHold?(0,a.jsx)(R.PlayArrow,{}):(0,a.jsx)(R.Pause,{})})}),(0,a.jsx)(s.Tooltip,{title:o.isMute?"Mute":"Un Mute",children:(0,a.jsx)(s.Button,{variant:o!=null&&o.isMute?"contained":"outlined",sx:o!=null&&o.isMute&&(o!=null&&o.isCallStart)?d({},l):o!=null&&o.isCallStart?d({},e):d({},l),onClick:()=>{o.isMute?L(o,{isMute:!1},"PLAYUSER"):L(o,{isMute:!0},"MUTEUSER")},disabled:!(o!=null&&o.isCallStart),children:o.isMute?(0,a.jsx)(R.MicOff,{}):(0,a.jsx)(R.Mic,{})})}),(0,a.jsx)(s.Tooltip,{title:"End Call",children:(o==null?void 0:o.line)!==1?(0,a.jsx)(s.Button,{variant:o!=null&&o.isCallStart?"contained":"outlined",color:"error",sx:o!=null&&o.isCallStart?$(d({},p),{minWidth:"60px !important",border:`0px solid ${f.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${f.palette.error.light}`,border:`0px solid ${f.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${f.palette.primary.light}`}}):$(d({},l),{minWidth:"60px !important"}),onClick:()=>{I(o,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE"})},disabled:!(o!=null&&o.isCallStart),children:(0,a.jsx)(R.CallEnd,{})}):(0,a.jsx)(s.Button,{variant:o!=null&&o.isCallStart?"contained":"outlined",sx:$(d({},l),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{I(o,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE"})},disabled:!(o!=null&&o.isCallStart),children:(0,a.jsx)(s.Typography,{children:(0,a.jsx)(R.CallEnd,{sx:{visibility:"hidden"}})})})})]},m)})}),(0,a.jsx)(s.Box,{textAlign:"center",m:2,children:(0,a.jsxs)(s.Button,{variant:"outlined",color:"error",size:"large",onClick:A,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[(0,a.jsx)(s.IconButton,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:(0,a.jsx)(R.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function To({open:r,setOpen:t}){var L,I,A,H,B,o,m,x,y,S;let[n]=W({onSuccess:g=>{console.log("res",g),t(!1)},onError:g=>{console.log("error",g)}}),l=ot(),[p,e]=(0,at.useState)("process"),[f,{data:h}]=W(),[D,{data:C}]=W(),w=()=>{t(!1)},M=(g,E)=>{var _,z,X,J,tt,Q,j,dt,ut,gt,ft,st,mt,xt,ht,yt,vt,nt,Ct,bt,St,Et,Tt,Lt,Dt,It,Rt,wt,_t,kt,At,it,Nt;if(console.log(g,"data34"),E==="PROCESS"){let et={mobile_number:(z=(_=l.callData)==null?void 0:_.phone_number)!=null?z:"",userid:(J=(X=l.callData)==null?void 0:X.agent_id)!=null?J:"",type:"PROCESS",transfer_to:(tt=g==null?void 0:g.process_name)!=null?tt:"",callreferenceid:(j=(Q=l.callData)==null?void 0:Q.convox_id)!=null?j:"",processid:String((ut=(dt=l.callData)==null?void 0:dt.process_id)!=null?ut:""),process_name:(ft=(gt=l.callData)==null?void 0:gt.process_name)!=null?ft:""};n(k.TRANSFER_CALL,et)}else if(E==="QUEUE"){let et={mobile_number:(mt=(st=l.callData)==null?void 0:st.phone_number)!=null?mt:"",userid:(ht=(xt=l.callData)==null?void 0:xt.agent_id)!=null?ht:"",type:"QUEUE",transfer_to:(yt=g==null?void 0:g.queue_name)!=null?yt:"",callreferenceid:(nt=(vt=l.callData)==null?void 0:vt.convox_id)!=null?nt:"",processid:String((bt=(Ct=l.callData)==null?void 0:Ct.process_id)!=null?bt:""),process_name:(Et=(St=l.callData)==null?void 0:St.process_name)!=null?Et:""};n(k.TRANSFER_CALL,et)}else if(E==="AGENT"){let et={mobile_number:(Lt=(Tt=l.callData)==null?void 0:Tt.phone_number)!=null?Lt:"",userid:(It=(Dt=l.callData)==null?void 0:Dt.agent_id)!=null?It:"",type:"AGENT",transfer_to:(Rt=g==null?void 0:g.user_id)!=null?Rt:"",callreferenceid:(_t=(wt=l.callData)==null?void 0:wt.convox_id)!=null?_t:"",processid:String((At=(kt=l.callData)==null?void 0:kt.process_id)!=null?At:""),process_name:(Nt=(it=l.callData)==null?void 0:it.process_name)!=null?Nt:""};n(k.TRANSFER_CALL,et)}};return(0,at.useEffect)(()=>{f(k.AGENTS_LIST,{status:"IDLE",active:!0}),D(k.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(s.Dialog,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,a.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,a.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,a.jsx)(s.Typography,{variant:"body1",children:" Call Transfer"}),(0,a.jsx)(s.IconButton,{onClick:w,children:(0,a.jsx)(R.Close,{})})]}),(0,a.jsxs)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[(0,a.jsxs)(s.Box,{sx:{display:"flex",gap:1},children:[(0,a.jsx)(s.Button,{variant:p==="process"?"contained":"outlined",onClick:()=>e("process"),children:"Process"}),(0,a.jsx)(s.Button,{variant:p==="queues"?"contained":"outlined",onClick:()=>e("queues"),children:"Queues"}),(0,a.jsx)(s.Button,{variant:p==="agents"?"contained":"outlined",onClick:()=>e("agents"),children:"Agents"})]}),p==="process"&&(0,a.jsx)(s.Box,{sx:{display:"flex",gap:1},children:((I=(L=C==null?void 0:C.data)==null?void 0:L.process)==null?void 0:I.length)>0?(H=(A=C==null?void 0:C.data)==null?void 0:A.process)==null?void 0:H.map((g,E)=>(0,a.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,a.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,a.jsx)(R.SupportAgent,{sx:{marginRight:"4px"}}),g.process_name]}),(0,a.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{M(g,"PROCESS")},children:(0,a.jsx)(R.Call,{})})]},E)):(0,a.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Process Found"})}),p==="queues"&&(0,a.jsx)(s.Box,{sx:{display:"flex",gap:1},children:((o=(B=C==null?void 0:C.data)==null?void 0:B.queue)==null?void 0:o.length)>0?(x=(m=C==null?void 0:C.data)==null?void 0:m.queue)==null?void 0:x.map((g,E)=>{var _,z,X,J,tt,Q;return(0,a.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,a.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,a.jsx)(R.SupportAgent,{sx:{marginRight:"4px"}}),g.queue_name,(X=(z=(_=C==null?void 0:C.data)==null?void 0:_.process)==null?void 0:z.find(j=>j.process_id===g.process_id))!=null&&X.process_name?(0,a.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((Q=(tt=(J=C==null?void 0:C.data)==null?void 0:J.process)==null?void 0:tt.find(j=>j.process_id===g.process_id))==null?void 0:Q.process_name)+")"}):""]}),(0,a.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{M(g,"QUEUE")},children:(0,a.jsx)(R.Call,{})})]},E)}):(0,a.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Queues Found"})}),p==="agents"&&(0,a.jsx)(s.Box,{sx:{display:"flex",gap:1},children:((y=h==null?void 0:h.data)==null?void 0:y.length)>0?(S=h==null?void 0:h.data)==null?void 0:S.map((g,E)=>(0,a.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,a.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,a.jsx)(R.SupportAgent,{sx:{marginRight:"4px"}}),g.name]}),(0,a.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{M(g,"AGENT")},children:(0,a.jsx)(R.Call,{})})]},E)):(0,a.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Agents Found"})})]})]})})})}function Lo({open:r,setOpen:t,onSubmitDisposition:n}){var w,M;let[l,p]=(0,at.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),e=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],f=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],h=(L,I)=>{p(A=>$(d({},A),{[L]:I}))},D=()=>{p({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},C=()=>{D(),t(!1)};return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(s.Dialog,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:(0,a.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,a.jsx)(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:(0,a.jsxs)(s.Typography,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),(0,a.jsx)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:(0,a.jsxs)(s.Grid,{container:!0,spacing:2,children:[(0,a.jsx)(s.Grid,{size:6,children:(0,a.jsx)(s.Autocomplete,{value:l.disposition,options:e,getOptionLabel:L=>L.label,onChange:(L,I)=>h("disposition",I),size:"small",renderInput:L=>(0,a.jsx)(s.TextField,$(d({},L),{label:"Disposition",fullWidth:!0}))})}),(0,a.jsx)(s.Grid,{size:6,children:(0,a.jsx)(s.Autocomplete,{options:f,getOptionLabel:L=>L.label,value:l.followUp,onChange:(L,I)=>h("followUp",I),size:"small",renderInput:L=>(0,a.jsx)(s.TextField,$(d({},L),{label:"Follow Up",fullWidth:!0}))})}),((M=(w=l==null?void 0:l.followUp)==null?void 0:w.label)==null?void 0:M.toLowerCase())==="yes"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.Grid,{size:6,children:(0,a.jsx)(s.TextField,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:l.callbackDate,onChange:L=>h("callbackDate",L.target.value),fullWidth:!0})}),(0,a.jsx)(s.Grid,{size:6,children:(0,a.jsx)(s.TextField,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:l.callbackHrs,onChange:L=>h("callbackHrs",L.target.value),fullWidth:!0})}),(0,a.jsx)(s.Grid,{size:6,children:(0,a.jsx)(s.TextField,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:l.callbackMins,onChange:L=>h("callbackMins",L.target.value),fullWidth:!0})})]})]})}),(0,a.jsxs)(s.Box,{textAlign:"right",m:2,children:[(0,a.jsx)(s.Button,{variant:"outlined",color:"error",size:"large",onClick:C,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,a.jsx)(s.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>n(l),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function Do({open:r,setOpen:t,processList:n=[],handleSelectedProcessor:l}){return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(s.Dialog,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:(0,a.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,a.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,a.jsx)(s.Typography,{variant:"body1",children:" Process List"}),(0,a.jsx)(s.IconButton,{onClick:()=>{t(!1)},children:(0,a.jsx)(R.Close,{})})]}),(0,a.jsx)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:(n==null?void 0:n.length)>0?n==null?void 0:n.map((e,f)=>(0,a.jsx)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{l(e)},children:(0,a.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,a.jsx)(R.SupportAgent,{sx:{marginRight:"4px"}}),e.process_name]})},f)):null})]})})})}function Io({open:r,setOpen:t}){return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(s.Dialog,{open:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,a.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,a.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,a.jsx)(s.Typography,{variant:"body1",children:" Call History"}),(0,a.jsx)(s.IconButton,{onClick:()=>{t(!1)},children:(0,a.jsx)(R.Close,{})})]}),(0,a.jsx)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}var c=require("react/jsx-runtime");function Ro({onDataChange:r}){var Gt,Kt,jt,Yt,Xt,Jt,Qt,Vt,Zt,te,ee,oe,ne,ae,se,ie,re,le,ce,pe,de,ue,ge,fe,me,xe,he,ye,ve,Ce,be,Se,Ee,Te,Le,De,Ie,Re,we,_e,ke,Ae,Ne,Pe,Oe,Ue,Me,Be,He,$e,ze,We,qe,Fe,Ge,Ke,je,Ye,Xe,Je,Qe,Ve,Ze,to,eo,oo;let t=(0,u.useTheme)(),{disabled:n,enabled:l,outlined:p}=Mt(),e=ot(),{showToast:f}=pt(),h=(0,N.useRef)(null),[D,C]=(0,N.useState)(null),[w,M]=(0,N.useState)(!0),[L,I]=(0,N.useState)(null),[A,H]=(0,N.useState)(null),[B,o]=(0,N.useState)(!1),[m,x]=(0,N.useState)(!1),[y,S]=(0,N.useState)(!1),[g,E]=(0,N.useState)(!1),[_,z]=(0,N.useState)(!1),[X,J]=(0,N.useState)(""),[tt,Q]=(0,N.useState)(0),{position:j,isDragging:dt,dragRef:ut,handleMouseDown:gt,handleTouchStart:ft}=Ft(e.controlPanelPosition,i=>T.setControlPanelPosition(i)),{position:st,isDragging:mt,dragRef:xt,handleMouseDown:ht,handleTouchStart:yt}=Ft(e.iframePosition,i=>T.setIframePosition(i)),[vt,{data:nt}]=W({onSuccess:i=>{var b;console.log("res",i),i&&i.data&&((b=i==null?void 0:i.data)==null?void 0:b.length)>1?E(!0):(T.setProcess(i==null?void 0:i.data[0]),E(!1))},onError:()=>{E(!1)}}),[Ct]=W(),[bt]=W({onSuccess:()=>{T.setHolding(!e.isHolding)},onError:i=>{console.log("error",i)}}),[St]=W({onSuccess:()=>{T.setMuted(!e.isMuted)},onError:i=>{console.log("error",i)}}),[Et]=W(),[Tt]=W(),[Lt]=W(),Dt=(0,N.useCallback)(i=>{let b=Math.floor(i/60),O=i%60;return`${b.toString().padStart(2,"0")}:${O.toString().padStart(2,"0")}`},[]),It=()=>{C(null)},Rt=i=>{M(!0),H(i.currentTarget),T.setStatus("dial")},wt=()=>{e.status!=="on call"&&T.setStatus("idle"),H(null)},_t=i=>{I(i.currentTarget)},kt=()=>{I(null)},At=()=>{let i={action:"READYAGENT",userId:e.agentId};Et(k.READY_AGENT,i)},it=i=>{I(null);let b={action:"AGENTBREAK",break_type:i,userId:e.agentId};Tt(k.UPDATE_AGENT_BREAK,b)},Nt=i=>{if(i.length!==10)f("Invalid phone number","error"),alert("Invalid phone number");else if(!/^\d+$/.test(i))f("Invalid phone number","error");else{let b={action:"CALL",phone_number:i,userId:e.agentId};Ct(k.CLICK_TO_CALL,b)}},et=()=>{let i={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};bt(k.HOLD_CALL,i)},wo=()=>{let i={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};St(k.MUTE_CALL,i)},_o=i=>{var O,G,K,V,Z,rt,lt,no,ao,so,io,ro,lo,co,po,uo;console.log("data",i);let b={action:"ENDCALL",userId:e.agentId,processid:(K=(G=(O=e.process)==null?void 0:O.process_id)==null?void 0:G.toString())!=null?K:"",process_name:(Z=(V=e.process)==null?void 0:V.process_name)!=null?Z:"",callreferenceid:(lt=(rt=e.callData)==null?void 0:rt.convox_id)!=null?lt:"",mobile_number:(ao=(no=e.callData)==null?void 0:no.phone_number)!=null?ao:"",disposition:(io=(so=i==null?void 0:i.disposition)==null?void 0:so.value)!=null?io:"",set_followUp:(lo=(ro=i==null?void 0:i.followUp)==null?void 0:ro.value)!=null?lo:"",callback_date:(co=i==null?void 0:i.callbackDate)!=null?co:"",callback_hrs:(po=i==null?void 0:i.callbackHrs)!=null?po:"",callback_mins:(uo=i==null?void 0:i.callbackMins)!=null?uo:"",endcall_type:"CLOSE"};J(""),Lt(k.END_CALL,b),T.endCall(),S(!1)};return(0,N.useEffect)(()=>{let i;return e.callData.status&&e.callData.status==="ONCALL"?i=setInterval(()=>{let b=Math.floor((Date.now()-e.callStartTime)/1e3);Q(b)},1e3):Q(0),()=>{i&&clearInterval(i)}},[e.callData.status]),(0,N.useEffect)(()=>{r&&r(e.callData)},[e.callData,r]),(0,N.useEffect)(()=>{e.agentId?vt(k.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),(0,N.useEffect)(()=>(e.agentId&&(h.current=new WebSocket(`${ho.WS}?agent_id=${e.agentId}`),h.current.onopen=()=>{console.log("WebSocket connection established")},h.current.onmessage=i=>{try{let b=JSON.parse(i.data);console.log("parsedJSON:",b),T.updateCallData(b),b.status==="ONCALL"&&T.startCall(),b.status==="WRAPUP"&&T.endCall()}catch(b){console.log("Raw message:",i.data)}},h.current.onclose=()=>{console.log("WebSocket connection closed")},h.current.onerror=i=>{console.error("WebSocket error:",i)}),()=>{var i;(i=h.current)==null||i.close()}),[e.agentId]),!e.isInitialized||!e.process?(0,c.jsx)(u.Box,{children:!!g&&(0,c.jsx)(Do,{processList:nt==null?void 0:nt.processes,open:g,setOpen:E,handleSelectedProcessor:i=>{T.setProcess(i)}})}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(u.Fade,{in:!0,timeout:300,children:(0,c.jsx)(u.Paper,{ref:ut,elevation:dt?4:1,sx:{position:"fixed",left:j.x,top:j.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:9999999999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),userSelect:"none"},children:(0,c.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,c.jsxs)(u.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,c.jsxs)(u.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:gt,onTouchStart:ft,children:[(0,c.jsx)(v.DragIndicator,{})," "]}),(0,c.jsx)(u.Box,{sx:{marginRight:"10px"},children:(0,c.jsx)(u.Tooltip,{title:"Dial",children:(0,c.jsx)(u.IconButton,{size:"small",onClick:i=>{var b,O,G,K,V,Z,rt,lt;((O=(b=e.callData)==null?void 0:b.status)==null?void 0:O.toUpperCase())!=="ONCALL"&&((K=(G=e.callData)==null?void 0:G.status)==null?void 0:K.toUpperCase())!=="BREAK"&&((Z=(V=e.callData)==null?void 0:V.status)==null?void 0:Z.toUpperCase())!=="RINGING"&&((lt=(rt=e.callData)==null?void 0:rt.status)==null?void 0:lt.toUpperCase())!=="WRAPUP"&&Rt(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,c.jsx)(v.WifiCalling3,{sx:{color:((Kt=(Gt=e.callData)==null?void 0:Gt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"||((Yt=(jt=e.callData)==null?void 0:jt.status)==null?void 0:Yt.toUpperCase())==="BREAK"||((Jt=(Xt=e.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())==="RINGING"||((Vt=(Qt=e.callData)==null?void 0:Qt.status)==null?void 0:Vt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,c.jsx)(u.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Dt(tt)}),(0,c.jsx)(u.Typography,{variant:"body2",sx:{fontWeight:"bold"},children:(ee=(te=(Zt=e.callData)==null?void 0:Zt.status)==null?void 0:te.toUpperCase())!=null?ee:"N/A"}),(0,c.jsxs)(u.Button,{size:"small",variant:"text",onClick:_t,disabled:!!e.callStartTime,children:[(0,c.jsx)(v.ArrowDropDown,{})," "]})]}),(0,c.jsxs)(u.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,c.jsx)(u.Tooltip,{title:"Agent Ready",children:(0,c.jsx)(u.Button,{variant:((ne=(oe=e.callData)==null?void 0:oe.status)==null?void 0:ne.toUpperCase())==="BREAK"||((se=(ae=e.callData)==null?void 0:ae.status)==null?void 0:se.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var b,O,G,K;(((O=(b=e.callData)==null?void 0:b.status)==null?void 0:O.toUpperCase())==="BREAK"||((K=(G=e.callData)==null?void 0:G.status)==null?void 0:K.toUpperCase())==="MISSED")&&(i.stopPropagation(),At())},classes:{root:((re=(ie=e.callData)==null?void 0:ie.status)==null?void 0:re.toUpperCase())==="BREAK"||((ce=(le=e.callData)==null?void 0:le.status)==null?void 0:ce.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:d({},((de=(pe=e.callData)==null?void 0:pe.status)==null?void 0:de.toUpperCase())==="BREAK"||((ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())==="MISSED"?p:l),children:(0,c.jsx)(v.SupportAgent,{})})}),(0,c.jsx)(u.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,c.jsx)(u.Button,{variant:e.isHolding&&((me=(fe=e.callData)==null?void 0:fe.status)==null?void 0:me.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),et()},sx:e.isHolding&&((he=(xe=e.callData)==null?void 0:xe.status)==null?void 0:he.toUpperCase())==="ONCALL"?d({},l):((ve=(ye=e.callData)==null?void 0:ye.status)==null?void 0:ve.toUpperCase())==="ONCALL"?d({},p):d({},n),disabled:((be=(Ce=e.callData)==null?void 0:Ce.status)==null?void 0:be.toUpperCase())!=="ONCALL"&&!e.isHolding,children:e.isHolding?(0,c.jsx)(v.PlayArrow,{}):(0,c.jsx)(v.Pause,{})})}),(0,c.jsx)(u.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,c.jsx)(u.Button,{variant:e.isMuted&&((Ee=(Se=e.callData)==null?void 0:Se.status)==null?void 0:Ee.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),wo()},sx:e.isMuted&&((Le=(Te=e.callData)==null?void 0:Te.status)==null?void 0:Le.toUpperCase())==="ONCALL"?d({},l):((Ie=(De=e.callData)==null?void 0:De.status)==null?void 0:Ie.toUpperCase())==="ONCALL"?d({},p):d({},n),disabled:((we=(Re=e.callData)==null?void 0:Re.status)==null?void 0:we.toUpperCase())!=="ONCALL"&&!e.isMuted,children:e.isMuted?(0,c.jsx)(v.MicOff,{}):(0,c.jsx)(v.Mic,{})})}),(0,c.jsx)(u.Tooltip,{title:"Transfer Call",children:(0,c.jsx)(u.Button,{variant:m?"contained":"outlined",onClick:i=>{var b,O;((O=(b=e.callData)==null?void 0:b.status)==null?void 0:O.toUpperCase())==="ONCALL"&&(i.stopPropagation(),x(!0))},sx:m?d({},l):((ke=(_e=e.callData)==null?void 0:_e.status)==null?void 0:ke.toUpperCase())==="ONCALL"?d({},p):d({},n),disabled:((Ne=(Ae=e.callData)==null?void 0:Ae.status)==null?void 0:Ne.toUpperCase())!=="ONCALL",children:(0,c.jsx)(v.TransferWithinAStation,{})})}),(0,c.jsx)(u.Tooltip,{title:"Conference Call",children:(0,c.jsx)(u.Button,{variant:B?"contained":"outlined",onClick:i=>{var b,O;((O=(b=e.callData)==null?void 0:b.status)==null?void 0:O.toUpperCase())==="ONCALL"&&(i.stopPropagation(),o(!0))},sx:B?d({},l):((Oe=(Pe=e.callData)==null?void 0:Pe.status)==null?void 0:Oe.toUpperCase())==="ONCALL"?d({},p):d({},n),disabled:((Me=(Ue=e.callData)==null?void 0:Ue.status)==null?void 0:Me.toUpperCase())!=="ONCALL",children:(0,c.jsx)(v.Group,{})})}),(0,c.jsx)(u.Tooltip,{title:"Call History",children:(0,c.jsx)(u.Button,{variant:_?"contained":"outlined",onClick:i=>{i.stopPropagation(),z(!0)},sx:_?d({},l):d({},p),children:(0,c.jsx)(v.History,{})})}),(0,c.jsx)(u.Tooltip,{title:"End Call",children:(0,c.jsx)(u.Button,{variant:((He=(Be=e.callData)==null?void 0:Be.status)==null?void 0:He.toUpperCase())==="ONCALL"||((ze=($e=e.callData)==null?void 0:$e.status)==null?void 0:ze.toUpperCase())==="RINGING"||((qe=(We=e.callData)==null?void 0:We.status)==null?void 0:qe.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var b,O,G,K,V,Z;(((O=(b=e.callData)==null?void 0:b.status)==null?void 0:O.toUpperCase())==="ONCALL"||((K=(G=e.callData)==null?void 0:G.status)==null?void 0:K.toUpperCase())==="RINGING"||((Z=(V=e.callData)==null?void 0:V.status)==null?void 0:Z.toUpperCase())==="WRAPUP")&&(i.stopPropagation(),S(!0))},sx:((Ge=(Fe=e.callData)==null?void 0:Fe.status)==null?void 0:Ge.toUpperCase())==="ONCALL"||((je=(Ke=e.callData)==null?void 0:Ke.status)==null?void 0:je.toUpperCase())==="RINGING"||((Xe=(Ye=e.callData)==null?void 0:Ye.status)==null?void 0:Xe.toUpperCase())==="WRAPUP"?$(d({},l),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${t.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${t.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${t.palette.primary.light}`}}):$(d({},n),{minWidth:"60px !important"}),disabled:((Qe=(Je=e.callData)==null?void 0:Je.status)==null?void 0:Qe.toUpperCase())!=="ONCALL"&&((Ze=(Ve=e.callData)==null?void 0:Ve.status)==null?void 0:Ze.toUpperCase())!=="RINGING"&&((eo=(to=e.callData)==null?void 0:to.status)==null?void 0:eo.toUpperCase())!=="WRAPUP",children:(0,c.jsx)(v.CallEnd,{})})})]})]})})}),(0,c.jsx)(u.Fade,{in:!0,timeout:300,children:(0,c.jsxs)(u.Paper,{ref:xt,elevation:mt?4:1,sx:{position:"fixed",left:st.x,top:st.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:9999999999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),visibility:w?"visible":"hidden",userSelect:"none"},children:[(0,c.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:ht,onTouchStart:yt,children:[(0,c.jsx)(v.DragIndicator,{sx:{transform:"rotate(90deg)"}})," ",(0,c.jsx)(u.IconButton,{onClick:()=>M(!1),children:(0,c.jsx)(v.Close,{})})]}),(0,c.jsx)("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(oo=e.process)==null?void 0:oo.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),(0,c.jsx)(u.Menu,{anchorEl:A,open:!!A,onClose:wt,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,c.jsxs)(u.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,c.jsx)(u.TextField,{size:"small",value:X,placeholder:"Enter Mobile No.",onChange:i=>{J(i.target.value)}}),(0,c.jsx)(u.IconButton,{color:"info",onClick:()=>{Nt(X)},children:(0,c.jsx)(v.Phone,{color:"success"})})]})}),(0,c.jsxs)(u.Menu,{anchorEl:L,open:!!L,onClose:kt,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,c.jsx)(u.MenuItem,{onClick:()=>it("Lunch"),children:"- Lunch"}),(0,c.jsx)(u.MenuItem,{onClick:()=>it("Tea"),children:"- Tea"})]}),(0,c.jsx)(u.Menu,{anchorEl:D,open:!!D,onClose:It,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,c.jsxs)(u.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,c.jsx)(u.Chip,{icon:(0,c.jsx)(v.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,c.jsx)(u.Chip,{icon:(0,c.jsx)(v.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,c.jsx)(u.Chip,{icon:(0,c.jsx)(v.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!B&&(0,c.jsx)(Eo,{open:B,setOpen:o}),!!m&&(0,c.jsx)(To,{open:m,setOpen:x}),!!y&&(0,c.jsx)(Lo,{open:y,setOpen:S,onSubmitDisposition:_o}),!!_&&(0,c.jsx)(Io,{open:_,setOpen:z})]})}function jo({apiKey:r,tenantId:t,agentId:n,baseURL:l}){T.initialize(r,n,l),$t.init({apiKey:r,tenantId:t,agentId:n,baseUrl:l})}0&&(module.exports={CallControlPanel,initSDK,useLogout});
|
|
1
|
+
"use strict";var Wo=Object.create;var Se=Object.defineProperty,Fo=Object.defineProperties,Go=Object.getOwnPropertyDescriptor,Ko=Object.getOwnPropertyDescriptors,jo=Object.getOwnPropertyNames,bo=Object.getOwnPropertySymbols,Yo=Object.getPrototypeOf,vo=Object.prototype.hasOwnProperty,Xo=Object.prototype.propertyIsEnumerable;var Fe=(e,t,a)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,p=(e,t)=>{for(var a in t||(t={}))vo.call(t,a)&&Fe(e,a,t[a]);if(bo)for(var a of bo(t))Xo.call(t,a)&&Fe(e,a,t[a]);return e},Q=(e,t)=>Fo(e,Ko(t));var Jo=(e,t)=>{for(var a in t)Se(e,a,{get:t[a],enumerable:!0})},So=(e,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of jo(t))!vo.call(e,c)&&c!==a&&Se(e,c,{get:()=>t[c],enumerable:!(l=Go(t,c))||l.enumerable});return e};var Vo=(e,t,a)=>(a=e!=null?Wo(Yo(e)):{},So(t||!e||!e.__esModule?Se(a,"default",{value:e,enumerable:!0}):a,e)),Qo=e=>So(Se({},"__esModule",{value:!0}),e);var oe=(e,t,a)=>Fe(e,typeof t!="symbol"?t+"":t,a);var ls={};Jo(ls,{CallControlPanel:()=>Bo,initSDK:()=>is,useEndCall:()=>Do,useLogout:()=>Lo});module.exports=Qo(ls);var Ge=class{constructor(){oe(this,"config",null);oe(this,"ticketId",null);oe(this,"baseUrl","");oe(this,"eventQueue",[]);oe(this,"isOnline",!0);oe(this,"retryQueue",[]);oe(this,"flushTimer",null)}async init(t){this.config=p({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},t),this.baseUrl=t.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let a=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),a}isInitialized(){return this.config!==null&&this.ticketId!==null}getConfig(){return this.config}getTicketId(){return this.ticketId}async createTicket(){if(!this.config)throw new Error("EventTracker not initialized");try{let t=await this.makeRequest("/api/v1/et/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({agentId:this.config.agentId,sessionId:this.config.sessionId})});if(!t.ok)throw new Error(`Failed to initialize: ${t.status} ${t.statusText}`);let a=await t.json();return this.ticketId=a.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(t){throw console.error("EventTracker initialization failed:",t),t}}async logEvent(t,a){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",t);return}let l={eventType:t,eventData:a,timestamp:Date.now()};if(this.eventQueue.push(l),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(l)}catch(c){console.warn("Failed to send event, will retry later:",c)}}async sendEvent(t){if(!(!this.config||!this.ticketId))try{let a=await this.makeRequest("/api/v1/et/event",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId,eventType:t.eventType,eventData:t.eventData})});if(!a.ok)throw new Error(`Failed to log event: ${a.status} ${a.statusText}`);let l=this.eventQueue.findIndex(c=>c.timestamp===t.timestamp);l>-1&&this.eventQueue.splice(l,1)}catch(a){console.error("Event logging failed:",a),this.retryQueue.push(()=>this.sendEvent(t))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let t=await this.makeRequest("/api/v1/et/close",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId})});if(!t.ok)throw new Error(`Failed to close ticket: ${t.status} ${t.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(t){throw console.error("Ticket close failed:",t),t}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let t=[...this.eventQueue];for(let l of t)await this.sendEvent(l);let a=[...this.retryQueue];this.retryQueue=[];for(let l of a)try{await l()}catch(c){console.error("Retry failed:",c)}}async makeRequest(t,a){var o;let l=`${this.baseUrl}${t}`,c=((o=this.config)==null?void 0:o.retryAttempts)||3;for(let g=1;g<=c;g++)try{return await fetch(l,a)}catch(m){if(g===c)throw m;let b=Math.min(1e3*Math.pow(2,g-1),1e4);await new Promise(f=>setTimeout(f,b))}throw new Error("Max retries exceeded")}setupAutoTracking(){var l;if(typeof window=="undefined"||!((l=this.config)!=null&&l.autoTrack))return;let t=this.config.autoTrack===!0?{}:this.config.autoTrack;if(t.pageVisits!==!1&&this.logEvent("pageVisit",{url:window.location.href,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}).catch(c=>console.warn("Failed to track page visit:",c)),t.clicks!==!1&&document.addEventListener("click",c=>{var g;let o=c.target;(o.tagName==="BUTTON"||o.tagName==="A"||o.onclick||o.getAttribute("role")==="button"||o instanceof HTMLButtonElement&&o.type==="button")&&this.logEvent("click",{element:o.tagName,text:(g=o.textContent)==null?void 0:g.trim().substring(0,100),href:o.getAttribute("href"),id:o.id,className:o.className,role:o.getAttribute("role"),position:{x:c.clientX,y:c.clientY},timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track click:",m))}),t.forms!==!1&&document.addEventListener("submit",c=>{let o=c.target,g=new FormData(o),m={};g.forEach((b,f)=>{m[f]=b.toString()}),this.logEvent("formSubmission",{formId:o.id,action:o.action,method:o.method,fields:Object.keys(m),fieldCount:Object.keys(m).length,timestamp:new Date().toISOString()}).catch(b=>console.warn("Failed to track form submission:",b))}),t.inputs!==!1){let c;document.addEventListener("input",o=>{let g=o.target;(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT")&&(clearTimeout(c),c=setTimeout(()=>{var m;this.logEvent("fieldChange",{element:g.tagName,type:g.getAttribute("type"),name:g.getAttribute("name"),id:g.id,valueLength:((m=g.value)==null?void 0:m.length)||0,timestamp:new Date().toISOString()}).catch(b=>console.warn("Failed to track field change:",b))},1e3))})}let a=Date.now();window.addEventListener("beforeunload",()=>{let c=Date.now()-a;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:c,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),t.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),t.errors!==!1&&(window.addEventListener("error",c=>{this.logEvent("jsError",{message:c.message,filename:c.filename,lineno:c.lineno,colno:c.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",c=>{var o;this.logEvent("unhandledRejection",{reason:(o=c.reason)==null?void 0:o.toString(),timestamp:new Date().toISOString()})})),t.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let c=window.performance.navigation,o=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:o.navigationStart,loadTime:o.loadEventEnd-o.navigationStart,domReady:o.domContentLoadedEventEnd-o.navigationStart,renderTime:o.loadEventEnd-o.domContentLoadedEventEnd,navigationType:c.type,redirectCount:c.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(this.isOnline=navigator.onLine,window.addEventListener("online",()=>{this.isOnline=!0,console.log("EventTracker: Back online, flushing queued events"),this.flush()}),window.addEventListener("offline",()=>{this.isOnline=!1,console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){var a;this.flushTimer&&clearInterval(this.flushTimer);let t=((a=this.config)==null?void 0:a.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},t)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},Ke=new Ge;typeof window!="undefined"&&(window.EventTracker=Ke);var je=class{constructor(){oe(this,"state");oe(this,"listeners",[]);oe(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,isHolding:!1,isMuted:!1,status:"idle",callStartTime:null,controlPanelPosition:{x:10,y:10},iframePosition:{x:10,y:80},callData:{agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:[{line:1,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:2,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:3,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:4,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:5,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1}]}}loadFromStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);if(t){let a=JSON.parse(t);this.state=Q(p({},this.state),{apiKey:a.apiKey||"",agentId:a.agentId||"",process:a.process||null,isInitialized:a.isInitialized||!1,isHolding:a.isHolding||!1,isMuted:a.isMuted||!1,status:a.status||"idle",callStartTime:a.callStartTime||null,controlPanelPosition:a.controlPanelPosition||{x:10,y:10},iframePosition:a.iframePosition||{x:10,y:80},callData:a.callData||{mobileNumber:"",callReferenceId:"",agentLoginId:""},conferenceLine:a.conferenceLine&&Array.isArray(a.conferenceLine)&&a.conferenceLine.length>0?a.conferenceLine:this.state.conferenceLine})}}catch(t){console.warn("Failed to load SDK state from localStorage:",t)}}saveToStorage(){try{let t={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,isHolding:this.state.isHolding,isMuted:this.state.isMuted,status:this.state.status,callStartTime:this.state.callStartTime,controlPanelPosition:this.state.controlPanelPosition,iframePosition:this.state.iframePosition,callData:this.state.callData,conferenceLine:this.state.conferenceLine};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(t))}catch(t){console.warn("Failed to save SDK state to localStorage:",t)}}notifyListeners(){this.listeners.forEach(t=>t())}initialize(t,a){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("API key not available");this.state.apiKey=t,this.state.agentId=a,this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return p({},this.state)}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1)}}setHolding(t){this.state.isHolding=t,this.saveToStorage(),this.notifyListeners()}setMuted(t){this.state.isMuted=t,this.saveToStorage(),this.notifyListeners()}setStatus(t){this.state.status=t,this.saveToStorage(),this.notifyListeners()}setProcess(t){this.state.process=t,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(t){this.state.controlPanelPosition=t,this.saveToStorage(),this.notifyListeners()}setIframePosition(t){this.state.iframePosition=t,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}updateCallData(t){this.state.callData=p(p({},this.state.callData),t),this.saveToStorage(),this.notifyListeners()}setConferenceLine(t){var l;(!this.state.conferenceLine||!Array.isArray(this.state.conferenceLine))&&(console.warn("Conference line data corrupted, resetting to initial state"),this.state.conferenceLine=this.getInitialState().conferenceLine);let a=(l=this.state.conferenceLine)==null?void 0:l.map(c=>c.line===t.line?t:c);this.state.conferenceLine=a,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(t){console.warn("Failed to clear localStorage:",t)}}debugStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",t),t&&console.log("Parsed localStorage data:",JSON.parse(t)),console.log("Current state:",this.state)}catch(t){console.error("Error debugging storage:",t)}}getConferenceLines(){return this.state.conferenceLine||[]}},E=new je;var de=require("react");var M="http://192.168.101.177:8095",Zo="ws://192.168.101.177:8095",G={v1:"/api/v1"},U={LOGIN:`${M}${G.v1}/cti/login?provider=convox`,READY_AGENT:`${M}${G.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${M}${G.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${M}${G.v1}/cti/calls?provider=convox`,HOLD_CALL:`${M}${G.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${M}${G.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${M}${G.v1}/cti/unmute-call?provider=convox`,END_CALL:`${M}${G.v1}/cti/calls/end?provider=convox`,LOGOUT:`${M}${G.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${M}${G.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${M}${G.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${M}${G.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${M}${G.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${M}${G.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${M}${G.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${M}${G.v1}/cti/users`,PROCESS_LIST:`${M}${G.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${M}${G.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${M}${G.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${M}${G.v1}/users/get_sentiment_analysis`},To={WS:`${Zo}${G.v1}/cti/ws`};var Eo=Vo(require("axios"));var es="12345",Ye=Eo.default.create({baseURL:M,headers:{"Content-Type":"application/json",Authorization:es},timeout:1e4});Ye.interceptors.request.use(e=>{let t="12345";return t&&e.headers&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e instanceof Error?e:new Error(String(e))));Ye.interceptors.response.use(e=>e,async e=>{var a;let t=e.config;return((a=e.response)==null?void 0:a.status)===401&&!t._retry&&(t._retry=!0),Promise.reject(e instanceof Error?e:new Error(String(e)))});var te=Ye;var ts=()=>{let[e,t]=(0,de.useState)(!1),[a,l]=(0,de.useState)(!1),[c,o]=(0,de.useState)(!1),[g,m]=(0,de.useState)(null),[b,f]=(0,de.useState)(null);return{logout:(0,de.useCallback)(()=>{var h;let x=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");t(!0);let u={action:"LOGOUTUSER",userId:x.agentId||""};te.post(U.LOGOUT,u).then(C=>{E.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(C==null?void 0:C.data),l(!0)}).catch(C=>{o(!0),m(C)}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:a,isError:c,error:g,data:b}},Lo=ts;var ue=require("react");var Do=()=>{let[e,t]=(0,ue.useState)(!1),[a,l]=(0,ue.useState)(!1),[c,o]=(0,ue.useState)(!1),[g,m]=(0,ue.useState)(null),[b,f]=(0,ue.useState)(null);return{handleEndCall:(0,ue.useCallback)(x=>{var C,w,z,B,P,N,F,Z,V,ee,S,v,R,k,O;let u=JSON.parse((C=localStorage.getItem("call-control-sdk-state"))!=null?C:"");t(!0);let h={action:"ENDCALL",userId:u==null?void 0:u.agentId,processid:(B=(z=(w=u==null?void 0:u.process)==null?void 0:w.process_id)==null?void 0:z.toString())!=null?B:"",process_name:(N=(P=u==null?void 0:u.process)==null?void 0:P.process_name)!=null?N:"",callreferenceid:(Z=(F=u==null?void 0:u.callData)==null?void 0:F.convox_id)!=null?Z:"",mobile_number:(ee=(V=u==null?void 0:u.callData)==null?void 0:V.phone_number)!=null?ee:"",disposition:(S=x==null?void 0:x.disposition)!=null?S:"RES",set_followUp:(v=x==null?void 0:x.followUp)!=null?v:"N",callback_date:(R=x==null?void 0:x.callbackDate)!=null?R:"",callback_hrs:(k=x==null?void 0:x.callbackHrs)!=null?k:"",callback_mins:(O=x==null?void 0:x.callbackMins)!=null?O:"",endcall_type:"CLOSE"};te.post(U.END_CALL,h).then(A=>{E.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),E.endCall(),f(A==null?void 0:A.data),l(!0)}).catch(A=>{o(!0),m(A)}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:a,isError:c,error:g,data:b}};var L=require("@mui/icons-material"),d=require("@mui/material"),K=require("react");var se=require("react");function Xe(e,t){let[a,l]=(0,se.useState)(e),[c,o]=(0,se.useState)(!1),g=(0,se.useRef)(),m=(0,se.useRef)({x:0,y:0}),b=(0,se.useRef)({x:0,y:0}),f=(0,se.useCallback)(h=>{let C=g.current;if(!C)return;let w=C.getBoundingClientRect(),z=window.innerWidth,B=window.innerHeight,P={x:Math.max(0,Math.min(h.x,z-w.width)),y:Math.max(0,Math.min(h.y,B-w.height))};l(P),t==null||t(P)},[t]),y=(0,se.useCallback)((h,C)=>{o(!0),m.current={x:h,y:C},b.current=a;let w=(N,F)=>{let Z=N-m.current.x,V=F-m.current.y;f({x:b.current.x+Z,y:b.current.y+V})},z=N=>{N.preventDefault(),w(N.clientX,N.clientY)},B=N=>{N.preventDefault();let F=N.touches[0];F&&w(F.clientX,F.clientY)},P=()=>{o(!1),document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",P),document.removeEventListener("touchmove",B),document.removeEventListener("touchend",P)};document.addEventListener("mousemove",z),document.addEventListener("mouseup",P),document.addEventListener("touchmove",B,{passive:!1}),document.addEventListener("touchend",P)},[a,f]),x=(0,se.useCallback)(h=>{h.preventDefault(),y(h.clientX,h.clientY)},[y]),u=(0,se.useCallback)(h=>{h.preventDefault();let C=h.touches[0];C&&y(C.clientX,C.clientY)},[y]);return{position:a,isDragging:c,dragRef:g,handleMouseDown:x,handleTouchStart:u}}var $e=require("react");function me(){let[e,t]=(0,$e.useState)(E.getState());return(0,$e.useEffect)(()=>E.subscribe(()=>{t(E.getState())}),[]),e}var qe=require("react");var ge=require("react"),ze=require("@mui/material"),Te=require("react/jsx-runtime"),Io=(0,ge.createContext)(void 0),Ee=()=>{let e=(0,ge.useContext)(Io);if(!e)throw new Error("useToast must be used inside ToastProvider");return e},Ro=({children:e})=>{let[t,a]=(0,ge.useState)(!1),[l,c]=(0,ge.useState)(""),[o,g]=(0,ge.useState)("info"),m=(b,f="info")=>{c(b),g(f),a(!0)};return(0,Te.jsxs)(Io.Provider,{value:{showToast:m},children:[e,(0,Te.jsx)(ze.Snackbar,{open:t,color:o,autoHideDuration:3e3,onClose:()=>a(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,Te.jsx)(ze.Alert,{variant:"filled",severity:o,onClose:()=>a(!1),sx:{width:"100%"},children:l})})]})};var os={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},ss=(e,t)=>{if(t.type==="isLoading")return Q(p({},e),{isLoading:t.payload});if(t.type==="isSuccess")return Q(p({},e),{isSuccess:!0,data:t.payload});if(t.type==="isError")return Q(p({},e),{isError:!0,error:t.payload});if(t.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var ae=(e={})=>{let{onSuccess:t=null,onError:a=null}=e,{showToast:l}=Ee(),[c,o]=(0,qe.useReducer)(ss,os);return[(0,qe.useCallback)((m,b,f={})=>{o({type:"isLoading",payload:!0}),te.post(m,b,f).then(y=>{var x,u;o({type:"isSuccess",payload:y.data}),t==null||t(y.data,b),console.log((x=y.data)==null?void 0:x.message,"res45"),l((u=y.data)==null?void 0:u.message,"success")}).catch(y=>{var u,h,C,w,z,B,P,N,F,Z,V,ee;let x={status:(h=(u=y.response)==null?void 0:u.status)!=null?h:500,message:((w=(C=y.response)==null?void 0:C.data)==null?void 0:w.detail)||((B=(z=y.response)==null?void 0:z.data)==null?void 0:B.message)||y.message||"An unknown error occurred",data:(N=(P=y.response)==null?void 0:P.data)!=null?N:null,statusText:(Z=(F=y.response)==null?void 0:F.statusText)!=null?Z:"",code:(V=y==null?void 0:y.code)!=null?V:"",name:(ee=y==null?void 0:y.name)!=null?ee:""};l(x.message,"error"),o({type:"isError",payload:x}),a==null||a(x,b)}).finally(()=>{o({type:"isLoading",payload:!1})})},[t,a,l]),c]};var I=require("@mui/icons-material"),n=require("@mui/material"),ne=require("react");var _o=require("@mui/material"),as=()=>{let e=(0,_o.useTheme)();return{disabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",border:"1px solid rgb(206, 204, 204)",height:"40px","&:hover":{boxShadow:" 0px 2px 2px rgba(0, 0, 0, 0.79)",border:`1px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},enabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},outlined:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:e.palette.grey[200],boxShadow:`0px 2px 1px ${e.palette.primary.light}`,border:`0px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${e.palette.primary.main}`,border:`0px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}}}},We=as;var s=require("react/jsx-runtime"),ns=({each:e})=>{var ee,S;let t=me(),{showToast:a}=Ee(),{disabled:l,enabled:c,outlined:o}=We(),g=(0,n.useTheme)(),[m,b]=(0,ne.useState)(!1),[f,y]=(0,ne.useState)(!1),[x,u]=(0,ne.useState)(!1),[h,C]=(0,ne.useState)(!1),[w,z]=(0,ne.useState)(!1),B=(v,R)=>{E.setConferenceLine(p(p({},v),R))},P=(v,R)=>{var A,q,W,H;let k=p(p({},v),R);b(!0);let O={action:"EXTERNAL_CONFERENCE",operation:`CALL${k.line}`,line_used:String(k.line),thirdparty_no:k.phone,userid:(q=(A=t.callData)==null?void 0:A.agent_id)!=null?q:"",process:(H=(W=t.callData)==null?void 0:W.process_name)!=null?H:""};te.post(U.CONFERENCE_CALL,O).then(_=>{var D;a((D=_.data)==null?void 0:D.message,"success"),E.setConferenceLine(p(p({},v),R))}).catch(_=>{var $,j,Y,X;let D=((j=($=_.response)==null?void 0:$.data)==null?void 0:j.detail)||((X=(Y=_.response)==null?void 0:Y.data)==null?void 0:X.message)||_.message||"An unknown error occurred";a(D,"error")}).finally(()=>{b(!1)})},N=(v,R)=>{var A,q,W,H;let k=p(p({},v),R);y(!0);let O={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(k.line),thirdparty_no:k.phone,userid:(q=(A=t.callData)==null?void 0:A.agent_id)!=null?q:"",process:(H=(W=t.callData)==null?void 0:W.process_name)!=null?H:""};te.post(U.CONFERENCE_CALL,O).then(_=>{var D;a((D=_.data)==null?void 0:D.message,"success"),E.setConferenceLine(p(p({},v),R))}).catch(_=>{var $,j,Y,X;let D=((j=($=_.response)==null?void 0:$.data)==null?void 0:j.detail)||((X=(Y=_.response)==null?void 0:Y.data)==null?void 0:X.message)||_.message||"An unknown error occurred";a(D,"error")}).finally(()=>{y(!1)})},F=(v,R,k)=>{var q,W,H,_;let O=p(p({},v),R);u(!0);let A={action:"EXTERNAL_CONFERENCE",operation:k,hold_channel_no:k==="HOLDUSER"?`hold${O.line}`:`unhold${O.line}`,userid:(W=(q=t.callData)==null?void 0:q.agent_id)!=null?W:"",process:(_=(H=t.callData)==null?void 0:H.process_name)!=null?_:""};te.post(U.CONFERENCE_CALL_HOLD_OR_UN_HOLD,A).then(D=>{var $;a(($=D.data)==null?void 0:$.message,"success"),E.setConferenceLine(p(p({},v),R))}).catch(D=>{var j,Y,X,re;let $=((Y=(j=D.response)==null?void 0:j.data)==null?void 0:Y.detail)||((re=(X=D.response)==null?void 0:X.data)==null?void 0:re.message)||D.message||"An unknown error occurred";a($,"error")}).finally(()=>{u(!1)})},Z=(v,R,k)=>{var q,W,H,_;let O=p(p({},v),R);C(!0);let A={action:"EXTERNAL_CONFERENCE",operation:k,channel_no:k==="MUTEUSER"?`mute${O.line}`:`play${O.line}`,userid:(W=(q=t.callData)==null?void 0:q.agent_id)!=null?W:"",thirdparty_no:O.phone,process:(_=(H=t.callData)==null?void 0:H.process_name)!=null?_:""};te.post(U.CONFERENCE_CALL_MUTE_OT_UN_MUTE,A).then(D=>{var $;a(($=D.data)==null?void 0:$.message,"success"),E.setConferenceLine(p(p({},v),R))}).catch(D=>{var j,Y,X,re;let $=((Y=(j=D.response)==null?void 0:j.data)==null?void 0:Y.detail)||((re=(X=D.response)==null?void 0:X.data)==null?void 0:re.message)||D.message||"An unknown error occurred";a($,"error")}).finally(()=>{C(!1)})},V=(v,R)=>{var A,q,W,H;let k=p(p({},v),R);z(!0);let O={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(k.line-1),user_type:`THIRDPARTY${k.line-1}`,thirdparty_no:k.phone,userid:(q=(A=t.callData)==null?void 0:A.agent_id)!=null?q:"",process:(H=(W=t.callData)==null?void 0:W.process_name)!=null?H:""};te.post(U.CONFERENCE_CALL_END,O).then(_=>{var D;a((D=_.data)==null?void 0:D.message,"success"),E.setConferenceLine(p(p({},v),R))}).catch(_=>{var $,j,Y,X;let D=((j=($=_.response)==null?void 0:$.data)==null?void 0:j.detail)||((X=(Y=_.response)==null?void 0:Y.data)==null?void 0:X.message)||_.message||"An unknown error occurred";a(D,"error")}).finally(()=>{z(!1)})};return(0,s.jsxs)(n.TableRow,{sx:{border:"2px solid #fff"},children:[(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsxs)(n.Typography,{children:["Line ",(ee=e==null?void 0:e.line)!=null?ee:"",". "]})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.Typography,{variant:"body2",sx:{px:1,borderRadius:"10px",width:"80px",maxWidth:"100px"},children:(S=e==null?void 0:e.status)!=null?S:""})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.Button,{sx:{textTransform:"capitalize"},size:"small",children:(0,s.jsx)(n.Typography,{variant:"body2",children:(e==null?void 0:e.line)===1?"Internal":"External"})})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.TextField,{size:"small",placeholder:"Phone Number",value:(e==null?void 0:e.phone)||"",disabled:(e==null?void 0:e.line)===1,onChange:v=>{B(e,{phone:v.target.value})}})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsxs)(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[(0,s.jsx)(n.Tooltip,{title:"Call",children:(0,s.jsx)(n.Button,{variant:e!=null&&e.isCallStart?"outlined":"contained",color:"success",sx:e!=null&&e.isCallStart?p({},l):Q(p({},c),{border:`0px solid ${g.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${g.palette.success.light}`,border:`0px solid ${g.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${g.palette.primary.light}`}}),onClick:()=>{P(e,{isCallStart:!0,status:"ONCALL"})},disabled:(e==null?void 0:e.isCallStart)||m,children:m?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"success"}):(0,s.jsx)(I.Call,{sx:{color:e!=null&&e.isCallStart?"default":"#e7e7e7ff"}})})}),(0,s.jsx)(n.Tooltip,{title:"Merge Call",children:(0,s.jsx)(n.Button,{variant:e!=null&&e.isMergeCall?"contained":"outlined",sx:e!=null&&e.isMergeCall&&(e!=null&&e.isCallStart)?p({},l):e!=null&&e.isCallStart?p({},o):p({},l),onClick:()=>{N(e,{isMergeCall:!0,status:"ONCALL"})},disabled:!(e!=null&&e.isCallStart)||f,children:f?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:e!=null&&e.isMergeCall?"#e7e7e7ff":g.palette.primary.main}}):(0,s.jsx)(I.CallSplit,{})})}),(0,s.jsx)(n.Tooltip,{title:e.isHold?"Hold":"Un Hold",children:(0,s.jsx)(n.Button,{variant:e!=null&&e.isHold?"contained":"outlined",sx:e!=null&&e.isHold&&(e!=null&&e.isCallStart)?p({},l):e!=null&&e.isCallStart?p({},o):p({},l),onClick:()=>{e.isHold?F(e,{isHold:!1},"UNHOLDUSER"):F(e,{isHold:!0},"HOLDUSER")},disabled:!(e!=null&&e.isCallStart)||x,children:x?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):e.isHold?(0,s.jsx)(I.PlayArrow,{}):(0,s.jsx)(I.Pause,{})})}),(0,s.jsx)(n.Tooltip,{title:e.isMute?"Mute":"Un Mute",children:(0,s.jsx)(n.Button,{variant:e!=null&&e.isMute?"contained":"outlined",sx:e!=null&&e.isMute&&(e!=null&&e.isCallStart)?p({},l):e!=null&&e.isCallStart?p({},o):p({},l),onClick:()=>{e.isMute?Z(e,{isMute:!1},"PLAYUSER"):Z(e,{isMute:!0},"MUTEUSER")},disabled:!(e!=null&&e.isCallStart)||h,children:h?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):e.isMute?(0,s.jsx)(I.MicOff,{}):(0,s.jsx)(I.Mic,{})})}),(0,s.jsx)(n.Tooltip,{title:"End Call",children:(e==null?void 0:e.line)!==1?(0,s.jsx)(n.Button,{variant:e!=null&&e.isCallStart?"contained":"outlined",color:"error",sx:e!=null&&e.isCallStart?Q(p({},c),{minWidth:"60px !important",border:`0px solid ${g.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${g.palette.error.light}`,border:`0px solid ${g.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${g.palette.primary.light}`}}):Q(p({},l),{minWidth:"60px !important"}),onClick:()=>{V(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart)||w,children:w?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error"}):(0,s.jsx)(I.CallEnd,{})}):(0,s.jsx)(n.Button,{variant:e!=null&&e.isCallStart?"contained":"outlined",sx:Q(p({},l),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{V(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart),children:(0,s.jsx)(n.Typography,{children:(0,s.jsx)(I.CallEnd,{sx:{visibility:"hidden"}})})})})]})})]},e.line)};function wo({open:e,setOpen:t}){var b;let a=me(),{showToast:l}=Ee(),[c,o]=(0,ne.useState)(!1),g=()=>{t(!1)},m=()=>{var y,x,u,h;o(!0);let f={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(x=(y=a.callData)==null?void 0:y.agent_id)!=null?x:"",process:(h=(u=a.callData)==null?void 0:u.process_name)!=null?h:""};te.post(U.CONFERENCE_CALL_END_ALL,f).then(C=>{var w;l((w=C.data)==null?void 0:w.message,"success"),E.resetConferenceLines(),g()}).catch(C=>{var z,B,P,N;let w=((B=(z=C.response)==null?void 0:z.data)==null?void 0:B.detail)||((N=(P=C.response)==null?void 0:P.data)==null?void 0:N.message)||C.message||"An unknown error occurred";l(w,"error")}).finally(()=>{o(!1)})};return(0,ne.useEffect)(()=>{var y,x,u,h;let f={line:1,status:(x=(y=a.callData)==null?void 0:y.status)!=null?x:"",type:"internal",phone:(h=(u=a.callData)==null?void 0:u.phone_number)!=null?h:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};E.setConferenceLine(f)},[]),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[(0,s.jsxs)(n.Typography,{variant:"body1",children:[(b=a==null?void 0:a.agentId)!=null?b:""," conference"]}),(0,s.jsx)(n.IconButton,{onClick:g,children:(0,s.jsx)(I.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:(0,s.jsx)(n.TableContainer,{component:n.Paper,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:(0,s.jsxs)(n.Table,{sx:{border:"4px solid #ffffff !important"},children:[(0,s.jsx)(n.TableHead,{children:(0,s.jsxs)(n.TableRow,{sx:{border:"2px solid #f3f3f3ff !important"},children:[(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Line"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Status"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Call Type"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Mobile Number"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Call Actions"})]})}),(0,s.jsx)(n.TableBody,{children:a==null?void 0:a.conferenceLine.map(f=>(0,s.jsx)(ns,{each:f}))})]})})}),(0,s.jsx)(n.Box,{textAlign:"center",m:2,children:(0,s.jsxs)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:m,disabled:c,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[c?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error",sx:{marginRight:"8px"}}):(0,s.jsx)(n.IconButton,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:(0,s.jsx)(I.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function ko({open:e,setOpen:t}){var u,h,C,w,z,B,P,N,F,Z,V,ee;let[a]=ae({onSuccess:S=>{console.log("res",S),t(!1)},onError:S=>{console.log("error",S)}}),l=me(),[c,o]=(0,ne.useState)("process"),[g,{data:m}]=ae(),[b,{data:f}]=ae(),y=()=>{t(!1)},x=(S,v)=>{var R,k,O,A,q,W,H,_,D,$,j,Y,X,re,Le,De,Ie,Re,xe,_e,ye,we,he,ke,Ae,Ne,Ce,Pe,Oe,Me,Ue,Be,He;if(console.log(S,"data34"),v==="PROCESS"){let fe={mobile_number:(k=(R=l.callData)==null?void 0:R.phone_number)!=null?k:"",userid:(A=(O=l.callData)==null?void 0:O.agent_id)!=null?A:"",type:"PROCESS",transfer_to:(q=S==null?void 0:S.process_name)!=null?q:"",callreferenceid:(H=(W=l.callData)==null?void 0:W.convox_id)!=null?H:"",processid:String((D=(_=l.callData)==null?void 0:_.process_id)!=null?D:""),process_name:(j=($=l.callData)==null?void 0:$.process_name)!=null?j:""};a(U.TRANSFER_CALL,fe)}else if(v==="QUEUE"){let fe={mobile_number:(X=(Y=l.callData)==null?void 0:Y.phone_number)!=null?X:"",userid:(Le=(re=l.callData)==null?void 0:re.agent_id)!=null?Le:"",type:"QUEUE",transfer_to:(De=S==null?void 0:S.queue_name)!=null?De:"",callreferenceid:(Re=(Ie=l.callData)==null?void 0:Ie.convox_id)!=null?Re:"",processid:String((_e=(xe=l.callData)==null?void 0:xe.process_id)!=null?_e:""),process_name:(we=(ye=l.callData)==null?void 0:ye.process_name)!=null?we:""};a(U.TRANSFER_CALL,fe)}else if(v==="AGENT"){let fe={mobile_number:(ke=(he=l.callData)==null?void 0:he.phone_number)!=null?ke:"",userid:(Ne=(Ae=l.callData)==null?void 0:Ae.agent_id)!=null?Ne:"",type:"AGENT",transfer_to:(Ce=S==null?void 0:S.user_id)!=null?Ce:"",callreferenceid:(Oe=(Pe=l.callData)==null?void 0:Pe.convox_id)!=null?Oe:"",processid:String((Ue=(Me=l.callData)==null?void 0:Me.process_id)!=null?Ue:""),process_name:(He=(Be=l.callData)==null?void 0:Be.process_name)!=null?He:""};a(U.TRANSFER_CALL,fe)}};return(0,ne.useEffect)(()=>{g(U.AGENTS_LIST,{status:"IDLE",active:!0}),b(U.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(m,"idleAgentsList"),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Call Transfer"}),(0,s.jsx)(n.IconButton,{onClick:y,children:(0,s.jsx)(I.Close,{})})]}),(0,s.jsxs)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",gap:1},children:[(0,s.jsx)(n.Button,{variant:c==="process"?"contained":"outlined",onClick:()=>o("process"),children:"Process"}),(0,s.jsx)(n.Button,{variant:c==="queues"?"contained":"outlined",onClick:()=>o("queues"),children:"Queues"}),(0,s.jsx)(n.Button,{variant:c==="agents"?"contained":"outlined",onClick:()=>o("agents"),children:"Agents"})]}),c==="process"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(u=f==null?void 0:f.data)!=null&&u.process&&((C=(h=f==null?void 0:f.data)==null?void 0:h.process)==null?void 0:C.length)>0?(z=(w=f==null?void 0:f.data)==null?void 0:w.process)==null?void 0:z.map((S,v)=>(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(I.SupportAgent,{sx:{marginRight:"4px"}}),S.process_name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{x(S,"PROCESS")},children:(0,s.jsx)(I.Call,{})})]},v)):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Process Found"})}),c==="queues"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(B=f==null?void 0:f.data)!=null&&B.queue&&((N=(P=f==null?void 0:f.data)==null?void 0:P.queue)==null?void 0:N.length)>0?(Z=(F=f==null?void 0:f.data)==null?void 0:F.queue)==null?void 0:Z.map((S,v)=>{var R,k,O,A,q,W;return(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(I.SupportAgent,{sx:{marginRight:"4px"}}),S.queue_name,(O=(k=(R=f==null?void 0:f.data)==null?void 0:R.process)==null?void 0:k.find(H=>H.process_id===S.process_id))!=null&&O.process_name?(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((W=(q=(A=f==null?void 0:f.data)==null?void 0:A.process)==null?void 0:q.find(H=>H.process_id===S.process_id))==null?void 0:W.process_name)+")"}):""]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{x(S,"QUEUE")},children:(0,s.jsx)(I.Call,{})})]},v)}):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Queues Found"})}),c==="agents"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:m!=null&&m.data&&((V=m==null?void 0:m.data)==null?void 0:V.length)>0?(ee=m==null?void 0:m.data)==null?void 0:ee.map((S,v)=>(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(I.SupportAgent,{sx:{marginRight:"4px"}}),S.name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{x(S,"AGENT")},children:(0,s.jsx)(I.Call,{})})]},v)):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Agents Found"})})]})]})})})}function Ao({open:e,setOpen:t,onSubmitDisposition:a}){var y,x;let[l,c]=(0,ne.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),o=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],g=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],m=(u,h)=>{c(C=>Q(p({},C),{[u]:h}))},b=()=>{c({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{b(),t(!1)};return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsx)(n.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:(0,s.jsxs)(n.Typography,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:(0,s.jsxs)(n.Grid,{container:!0,spacing:2,children:[(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{value:l.disposition,options:o,getOptionLabel:u=>u.label,onChange:(u,h)=>m("disposition",h),size:"small",renderInput:u=>(0,s.jsx)(n.TextField,Q(p({},u),{label:"Disposition",fullWidth:!0}))})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{options:g,getOptionLabel:u=>u.label,value:l.followUp,onChange:(u,h)=>m("followUp",h),size:"small",renderInput:u=>(0,s.jsx)(n.TextField,Q(p({},u),{label:"Follow Up",fullWidth:!0}))})}),((x=(y=l==null?void 0:l.followUp)==null?void 0:y.label)==null?void 0:x.toLowerCase())==="yes"&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.TextField,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:l.callbackDate,onChange:u=>m("callbackDate",u.target.value),fullWidth:!0})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.TextField,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:l.callbackHrs,onChange:u=>m("callbackHrs",u.target.value),fullWidth:!0})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.TextField,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:l.callbackMins,onChange:u=>m("callbackMins",u.target.value),fullWidth:!0})})]})]})}),(0,s.jsxs)(n.Box,{textAlign:"right",m:2,children:[(0,s.jsx)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:f,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,s.jsx)(n.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>a(l),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function No({open:e,setOpen:t,processList:a=null,handleSelectedProcessor:l}){var o,g;return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Process List"}),(0,s.jsx)(n.IconButton,{onClick:()=>{t(!1)},children:(0,s.jsx)(I.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:((o=a==null?void 0:a.processes)==null?void 0:o.length)>0?(g=a==null?void 0:a.processes)==null?void 0:g.map((m,b)=>(0,s.jsx)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{l(m)},children:(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(I.SupportAgent,{sx:{marginRight:"4px"}}),m.process_name]})},b)):null})]})})})}function Po({open:e,setOpen:t}){return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Call History"}),(0,s.jsx)(n.IconButton,{onClick:()=>{t(!1)},children:(0,s.jsx)(I.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}var r=require("react/jsx-runtime");function Oo({onDataChange:e}){var Qe,Ze,et,tt,ot,st,at,nt,it,lt,rt,ct,pt,dt,ut,gt,ft,mt,xt,yt,ht,Ct,bt,vt,St,Tt,Et,Lt,Dt,It,Rt,_t,wt,kt,At,Nt,Pt,Ot,Mt,Ut,Bt,Ht,$t,zt,qt,Wt,Ft,Gt,Kt,jt,Yt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,ao,no,io,lo,ro,co;let t=(0,d.useTheme)(),{disabled:a,enabled:l,outlined:c}=We(),o=me(),g=(0,K.useRef)(null),[m,b]=(0,K.useState)(null),[f,y]=(0,K.useState)(!0),[x,u]=(0,K.useState)(null),[h,C]=(0,K.useState)(null),[w,z]=(0,K.useState)(!1),[B,P]=(0,K.useState)(!1),[N,F]=(0,K.useState)(!1),[Z,V]=(0,K.useState)(!1),[ee,S]=(0,K.useState)(!1),[v,R]=(0,K.useState)(""),[k,O]=(0,K.useState)(0),{position:A,isDragging:q,dragRef:W,handleMouseDown:H,handleTouchStart:_}=Xe(o.controlPanelPosition,i=>E.setControlPanelPosition(i)),{position:D,isDragging:$,dragRef:j,handleMouseDown:Y,handleTouchStart:X}=Xe(o.iframePosition,i=>E.setIframePosition(i)),[re,{data:Le}]=ae({onSuccess:i=>{var T;console.log("res",i),i&&i.data&&((T=i==null?void 0:i.data)==null?void 0:T.length)>1?V(!0):(E.setProcess(i==null?void 0:i.data[0]),V(!1))},onError:()=>{V(!1)}}),[De,{isLoading:Ie}]=ae(),[Re,{isLoading:xe}]=ae({onSuccess:()=>{E.setHolding(!o.isHolding)},onError:i=>{console.log("error",i)}}),[_e,{isLoading:ye}]=ae({onSuccess:()=>{E.setMuted(!o.isMuted)},onError:i=>{console.log("error",i)}}),[we,{isLoading:he}]=ae(),[ke,{isLoading:Ae}]=ae(),[Ne,{isLoading:Ce}]=ae(),Pe=(0,K.useCallback)(i=>{let T=Math.floor(i/60),J=i%60;return`${T.toString().padStart(2,"0")}:${J.toString().padStart(2,"0")}`},[]),Oe=()=>{b(null)},Me=i=>{y(!0),C(i.currentTarget),E.setStatus("dial")},Ue=()=>{o.status!=="on call"&&E.setStatus("idle"),C(null)},Be=i=>{u(i.currentTarget)},He=()=>{u(null)},fe=()=>{let i={action:"READYAGENT",userId:o.agentId};we(U.READY_AGENT,i)},Ve=i=>{u(null);let T={action:"AGENTBREAK",break_type:i,userId:o.agentId};ke(U.UPDATE_AGENT_BREAK,T)},Ho=i=>{if(i.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(i)){let T={action:"CALL",phone_number:i,userId:o.agentId};De(U.CLICK_TO_CALL,T)}},$o=()=>{let i={action:o.isHolding?"UNHOLD":"HOLD",userId:o.agentId};Re(U.HOLD_CALL,i)},zo=()=>{let i={action:o.isMuted?"UNMUTE":"MUTE",userId:o.agentId};_e(U.MUTE_CALL,i)},qo=i=>{var J,ie,le,ce,pe,be,ve,po,uo,go,fo,mo,xo,yo,ho,Co;console.log("data",i);let T={action:"ENDCALL",userId:o.agentId,processid:(le=(ie=(J=o.process)==null?void 0:J.process_id)==null?void 0:ie.toString())!=null?le:"",process_name:(pe=(ce=o.process)==null?void 0:ce.process_name)!=null?pe:"",callreferenceid:(ve=(be=o.callData)==null?void 0:be.convox_id)!=null?ve:"",mobile_number:(uo=(po=o.callData)==null?void 0:po.phone_number)!=null?uo:"",disposition:(fo=(go=i==null?void 0:i.disposition)==null?void 0:go.value)!=null?fo:"",set_followUp:(xo=(mo=i==null?void 0:i.followUp)==null?void 0:mo.value)!=null?xo:"",callback_date:(yo=i==null?void 0:i.callbackDate)!=null?yo:"",callback_hrs:(ho=i==null?void 0:i.callbackHrs)!=null?ho:"",callback_mins:(Co=i==null?void 0:i.callbackMins)!=null?Co:"",endcall_type:"CLOSE"};R(""),Ne(U.END_CALL,T),E.endCall(),F(!1)};return(0,K.useEffect)(()=>{let i;return o.callData.status&&o.callData.status==="ONCALL"?i=setInterval(()=>{let T=Math.floor((Date.now()-o.callStartTime)/1e3);O(T)},1e3):O(0),()=>{i&&clearInterval(i)}},[o.callData.status]),(0,K.useEffect)(()=>{e&&e(o.callData)},[o.callData,e]),(0,K.useEffect)(()=>{o.agentId?re(U.PROCESS_LIST,{userId:o.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[o.agentId]),(0,K.useEffect)(()=>(o.agentId&&(g.current=new WebSocket(`${To.WS}?agent_id=${o.agentId}`),g.current.onopen=()=>{console.log("WebSocket connection established")},g.current.onmessage=i=>{try{let T=JSON.parse(i.data);console.log("parsedJSON:",T),E.updateCallData(T),T.status==="ONCALL"&&E.startCall(),T.status==="WRAPUP"&&E.endCall()}catch(T){console.log("Raw message:",i.data)}},g.current.onclose=()=>{console.log("WebSocket connection closed")},g.current.onerror=i=>{console.error("WebSocket error:",i)}),()=>{var i;(i=g.current)==null||i.close()}),[o.agentId]),!o.isInitialized||!o.process?(0,r.jsx)(d.Box,{children:!!Z&&(0,r.jsx)(No,{processList:Le,open:Z,setOpen:V,handleSelectedProcessor:i=>{E.setProcess(i)}})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.Fade,{in:!0,timeout:300,children:(0,r.jsx)(d.Paper,{ref:W,elevation:q?4:1,sx:{position:"fixed",left:A.x,top:A.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),userSelect:"none"},children:(0,r.jsxs)(d.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(d.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(d.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:H,onTouchStart:_,children:[(0,r.jsx)(L.DragIndicator,{})," "]}),(0,r.jsx)(d.Box,{sx:{marginRight:"10px"},children:(0,r.jsx)(d.Tooltip,{title:"Dial",children:(0,r.jsx)(d.IconButton,{size:"small",onClick:i=>{var T,J,ie,le,ce,pe,be,ve;((J=(T=o.callData)==null?void 0:T.status)==null?void 0:J.toUpperCase())!=="ONCALL"&&((le=(ie=o.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())!=="BREAK"&&((pe=(ce=o.callData)==null?void 0:ce.status)==null?void 0:pe.toUpperCase())!=="RINGING"&&((ve=(be=o.callData)==null?void 0:be.status)==null?void 0:ve.toUpperCase())!=="WRAPUP"&&Me(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,r.jsx)(L.WifiCalling3,{sx:{color:((Ze=(Qe=o.callData)==null?void 0:Qe.status)==null?void 0:Ze.toUpperCase())==="ONCALL"||((tt=(et=o.callData)==null?void 0:et.status)==null?void 0:tt.toUpperCase())==="BREAK"||((st=(ot=o.callData)==null?void 0:ot.status)==null?void 0:st.toUpperCase())==="RINGING"||((nt=(at=o.callData)==null?void 0:at.status)==null?void 0:nt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,r.jsx)(d.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Pe(k)}),Ae||he?(0,r.jsx)(d.Box,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)(d.CircularProgress,{size:"20px"})}):(0,r.jsx)(d.Typography,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(rt=(lt=(it=o.callData)==null?void 0:it.status)==null?void 0:lt.toUpperCase())!=null?rt:"N/A"}),(0,r.jsx)(d.Box,{onClick:Be,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:(0,r.jsx)(L.ArrowDropDown,{})})]}),(0,r.jsxs)(d.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,r.jsx)(d.Tooltip,{title:"Agent Ready",children:(0,r.jsx)(d.Button,{variant:((pt=(ct=o.callData)==null?void 0:ct.status)==null?void 0:pt.toUpperCase())==="BREAK"||((ut=(dt=o.callData)==null?void 0:dt.status)==null?void 0:ut.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var T,J,ie,le;(((J=(T=o.callData)==null?void 0:T.status)==null?void 0:J.toUpperCase())==="BREAK"||((le=(ie=o.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())==="MISSED")&&(i.stopPropagation(),fe())},classes:{root:((ft=(gt=o.callData)==null?void 0:gt.status)==null?void 0:ft.toUpperCase())==="BREAK"||((xt=(mt=o.callData)==null?void 0:mt.status)==null?void 0:xt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:p({},((ht=(yt=o.callData)==null?void 0:yt.status)==null?void 0:ht.toUpperCase())==="BREAK"||((bt=(Ct=o.callData)==null?void 0:Ct.status)==null?void 0:bt.toUpperCase())==="MISSED"?c:l),disabled:he,children:(0,r.jsx)(L.SupportAgent,{})})}),(0,r.jsx)(d.Tooltip,{title:o.isHolding?"Resume":"Hold",children:(0,r.jsx)(d.Button,{variant:o.isHolding&&((St=(vt=o.callData)==null?void 0:vt.status)==null?void 0:St.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),$o()},sx:o.isHolding&&((Et=(Tt=o.callData)==null?void 0:Tt.status)==null?void 0:Et.toUpperCase())==="ONCALL"?p({},l):((Dt=(Lt=o.callData)==null?void 0:Lt.status)==null?void 0:Dt.toUpperCase())==="ONCALL"?p({},c):p({},a),disabled:((Rt=(It=o.callData)==null?void 0:It.status)==null?void 0:Rt.toUpperCase())!=="ONCALL"&&!o.isHolding||xe,children:xe?(0,r.jsx)(d.CircularProgress,{size:"20px",sx:{color:t.palette.primary.main}}):o.isHolding?(0,r.jsx)(L.PlayArrow,{}):(0,r.jsx)(L.Pause,{})})}),(0,r.jsx)(d.Tooltip,{title:o.isMuted?"Unmute":"Mute",children:(0,r.jsx)(d.Button,{variant:o.isMuted&&((wt=(_t=o.callData)==null?void 0:_t.status)==null?void 0:wt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),zo()},sx:o.isMuted&&((At=(kt=o.callData)==null?void 0:kt.status)==null?void 0:At.toUpperCase())==="ONCALL"?p({},l):((Pt=(Nt=o.callData)==null?void 0:Nt.status)==null?void 0:Pt.toUpperCase())==="ONCALL"?p({},c):p({},a),disabled:((Mt=(Ot=o.callData)==null?void 0:Ot.status)==null?void 0:Mt.toUpperCase())!=="ONCALL"&&!o.isMuted||ye,children:ye?(0,r.jsx)(d.CircularProgress,{size:"20px",sx:{color:t.palette.primary.main}}):o.isMuted?(0,r.jsx)(L.MicOff,{}):(0,r.jsx)(L.Mic,{})})}),(0,r.jsx)(d.Tooltip,{title:"Transfer Call",children:(0,r.jsx)(d.Button,{variant:B?"contained":"outlined",onClick:i=>{var T,J;((J=(T=o.callData)==null?void 0:T.status)==null?void 0:J.toUpperCase())==="ONCALL"&&(i.stopPropagation(),P(!0))},sx:B?p({},l):((Bt=(Ut=o.callData)==null?void 0:Ut.status)==null?void 0:Bt.toUpperCase())==="ONCALL"?p({},c):p({},a),disabled:(($t=(Ht=o.callData)==null?void 0:Ht.status)==null?void 0:$t.toUpperCase())!=="ONCALL",children:(0,r.jsx)(L.TransferWithinAStation,{})})}),(0,r.jsx)(d.Tooltip,{title:"Conference Call",children:(0,r.jsx)(d.Button,{variant:w?"contained":"outlined",onClick:i=>{var T,J;((J=(T=o.callData)==null?void 0:T.status)==null?void 0:J.toUpperCase())==="ONCALL"&&(i.stopPropagation(),z(!0))},sx:w?p({},l):((qt=(zt=o.callData)==null?void 0:zt.status)==null?void 0:qt.toUpperCase())==="ONCALL"?p({},c):p({},a),disabled:((Ft=(Wt=o.callData)==null?void 0:Wt.status)==null?void 0:Ft.toUpperCase())!=="ONCALL",children:(0,r.jsx)(L.Group,{})})}),(0,r.jsx)(d.Tooltip,{title:"End Call",children:(0,r.jsx)(d.Button,{variant:((Kt=(Gt=o.callData)==null?void 0:Gt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"||((Yt=(jt=o.callData)==null?void 0:jt.status)==null?void 0:Yt.toUpperCase())==="RINGING"||((Jt=(Xt=o.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var T,J,ie,le,ce,pe;(((J=(T=o.callData)==null?void 0:T.status)==null?void 0:J.toUpperCase())==="ONCALL"||((le=(ie=o.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())==="RINGING"||((pe=(ce=o.callData)==null?void 0:ce.status)==null?void 0:pe.toUpperCase())==="WRAPUP")&&(i.stopPropagation(),F(!0))},sx:((Qt=(Vt=o.callData)==null?void 0:Vt.status)==null?void 0:Qt.toUpperCase())==="ONCALL"||((eo=(Zt=o.callData)==null?void 0:Zt.status)==null?void 0:eo.toUpperCase())==="RINGING"||((oo=(to=o.callData)==null?void 0:to.status)==null?void 0:oo.toUpperCase())==="WRAPUP"?Q(p({},l),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${t.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${t.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${t.palette.primary.light}`}}):Q(p({},a),{minWidth:"60px !important"}),disabled:((ao=(so=o.callData)==null?void 0:so.status)==null?void 0:ao.toUpperCase())!=="ONCALL"&&((io=(no=o.callData)==null?void 0:no.status)==null?void 0:io.toUpperCase())!=="RINGING"&&((ro=(lo=o.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())!=="WRAPUP"||Ce,children:Ce?(0,r.jsx)(d.CircularProgress,{size:"20px",color:"error"}):(0,r.jsx)(L.CallEnd,{})})})]})]})})}),(0,r.jsx)(d.Fade,{in:!0,timeout:300,children:(0,r.jsxs)(d.Paper,{ref:j,elevation:$?4:1,sx:{position:"fixed",left:D.x,top:D.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),visibility:f?"visible":"hidden",userSelect:"none"},children:[(0,r.jsxs)(d.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:Y,onTouchStart:X,children:[(0,r.jsx)(L.DragIndicator,{sx:{transform:"rotate(90deg)"}})," ",(0,r.jsx)(d.IconButton,{onClick:()=>y(!1),children:(0,r.jsx)(L.Close,{})})]}),(0,r.jsx)("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${o.agentId}&process_id=${(co=o.process)==null?void 0:co.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),(0,r.jsx)(d.Menu,{anchorEl:h,open:!!h,onClose:Ue,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,r.jsxs)(d.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,r.jsx)(d.TextField,{size:"small",value:v,placeholder:"Enter Mobile No.",onChange:i=>{R(i.target.value)}}),(0,r.jsx)(d.IconButton,{color:"info",onClick:()=>{Ho(v)},children:Ie?(0,r.jsx)(d.CircularProgress,{size:"20px",sx:{color:t.palette.success.main}}):(0,r.jsx)(L.Phone,{color:"success"})})]})}),(0,r.jsxs)(d.Menu,{anchorEl:x,open:!!x,onClose:He,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,r.jsx)(d.MenuItem,{onClick:()=>Ve("Lunch"),children:"- Lunch"}),(0,r.jsx)(d.MenuItem,{onClick:()=>Ve("Tea"),children:"- Tea"})]}),(0,r.jsx)(d.Menu,{anchorEl:m,open:!!m,onClose:Oe,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,r.jsxs)(d.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,r.jsx)(d.Chip,{icon:(0,r.jsx)(L.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,r.jsx)(d.Chip,{icon:(0,r.jsx)(L.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,r.jsx)(d.Chip,{icon:(0,r.jsx)(L.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!w&&(0,r.jsx)(wo,{open:w,setOpen:z}),!!B&&(0,r.jsx)(ko,{open:B,setOpen:P}),!!N&&(0,r.jsx)(Ao,{open:N,setOpen:F,onSubmitDisposition:qo}),!!ee&&(0,r.jsx)(Po,{open:ee,setOpen:S})]})}var Uo=require("react/jsx-runtime"),Mo=({children:e})=>(0,Uo.jsx)(Ro,{children:e});var Je=require("react/jsx-runtime");function Bo({onDataChange:e}){return(0,Je.jsx)(Mo,{children:(0,Je.jsx)(Oo,{onDataChange:e})})}function is({apiKey:e,tenantId:t,agentId:a}){E.initialize(e,a),Ke.init({apiKey:e,tenantId:t,agentId:a,baseUrl:M})}0&&(module.exports={CallControlPanel,initSDK,useEndCall,useLogout});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|