call-control-sdk 5.4.1 → 5.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import { SxProps } from '@mui/material';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
2
 
4
3
  /**
@@ -35,32 +34,6 @@ declare const useEndCall: () => {
35
34
  data: null;
36
35
  };
37
36
 
38
- interface CallData {
39
- mobileNumber?: string;
40
- callReferenceId?: string;
41
- convoxId?: string;
42
- type?: string;
43
- status?: string;
44
- agent_id?: string;
45
- phone_number?: string;
46
- event_time?: string;
47
- convox_id?: string;
48
- process_id?: string;
49
- process_name?: string;
50
- }
51
- interface CallControlPanelProps {
52
- onDataChange?: (data: any) => void;
53
- }
54
- type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
55
- interface SDKConfig {
56
- showEndCallButton?: boolean;
57
- showTransferButton?: boolean;
58
- showConferenceButton?: boolean;
59
- disabled?: SxProps;
60
- enabled?: SxProps;
61
- outlined?: SxProps;
62
- }
63
-
64
37
  interface StartCallPayload {
65
38
  mobileNumber: string;
66
39
  }
@@ -80,6 +53,24 @@ declare const useClickToCall: () => {
80
53
  data: null;
81
54
  };
82
55
 
56
+ interface CallData {
57
+ mobileNumber?: string;
58
+ callReferenceId?: string;
59
+ convoxId?: string;
60
+ type?: string;
61
+ status?: string;
62
+ agent_id?: string;
63
+ phone_number?: string;
64
+ event_time?: string;
65
+ convox_id?: string;
66
+ process_id?: string;
67
+ process_name?: string;
68
+ }
69
+ interface CallControlPanelProps {
70
+ onDataChange?: (data: any) => void;
71
+ }
72
+ type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
73
+
83
74
  declare function CallControlPanel({ onDataChange }: CallControlPanelProps): react_jsx_runtime.JSX.Element;
84
75
 
85
76
  /**
@@ -91,8 +82,7 @@ type intiSDKParams = {
91
82
  apiKey: string;
92
83
  tenantId: string;
93
84
  agentId: string;
94
- sdkConfig?: SDKConfig;
95
85
  };
96
- declare function initSDK({ apiKey, tenantId, agentId, sdkConfig, }: intiSDKParams): void;
86
+ declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
97
87
 
98
88
  export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useClickToCall, useEndCall, useLogout };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { SxProps } from '@mui/material';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
2
 
4
3
  /**
@@ -35,32 +34,6 @@ declare const useEndCall: () => {
35
34
  data: null;
36
35
  };
37
36
 
38
- interface CallData {
39
- mobileNumber?: string;
40
- callReferenceId?: string;
41
- convoxId?: string;
42
- type?: string;
43
- status?: string;
44
- agent_id?: string;
45
- phone_number?: string;
46
- event_time?: string;
47
- convox_id?: string;
48
- process_id?: string;
49
- process_name?: string;
50
- }
51
- interface CallControlPanelProps {
52
- onDataChange?: (data: any) => void;
53
- }
54
- type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
55
- interface SDKConfig {
56
- showEndCallButton?: boolean;
57
- showTransferButton?: boolean;
58
- showConferenceButton?: boolean;
59
- disabled?: SxProps;
60
- enabled?: SxProps;
61
- outlined?: SxProps;
62
- }
63
-
64
37
  interface StartCallPayload {
65
38
  mobileNumber: string;
66
39
  }
@@ -80,6 +53,24 @@ declare const useClickToCall: () => {
80
53
  data: null;
81
54
  };
82
55
 
56
+ interface CallData {
57
+ mobileNumber?: string;
58
+ callReferenceId?: string;
59
+ convoxId?: string;
60
+ type?: string;
61
+ status?: string;
62
+ agent_id?: string;
63
+ phone_number?: string;
64
+ event_time?: string;
65
+ convox_id?: string;
66
+ process_id?: string;
67
+ process_name?: string;
68
+ }
69
+ interface CallControlPanelProps {
70
+ onDataChange?: (data: any) => void;
71
+ }
72
+ type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
73
+
83
74
  declare function CallControlPanel({ onDataChange }: CallControlPanelProps): react_jsx_runtime.JSX.Element;
84
75
 
85
76
  /**
@@ -91,8 +82,7 @@ type intiSDKParams = {
91
82
  apiKey: string;
92
83
  tenantId: string;
93
84
  agentId: string;
94
- sdkConfig?: SDKConfig;
95
85
  };
96
- declare function initSDK({ apiKey, tenantId, agentId, sdkConfig, }: intiSDKParams): void;
86
+ declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
97
87
 
98
88
  export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useClickToCall, useEndCall, useLogout };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Vo=Object.create;var De=Object.defineProperty,Qo=Object.defineProperties,Zo=Object.getOwnPropertyDescriptor,es=Object.getOwnPropertyDescriptors,ts=Object.getOwnPropertyNames,_o=Object.getOwnPropertySymbols,os=Object.getPrototypeOf,wo=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable;var Ge=(t,o,e)=>o in t?De(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,c=(t,o)=>{for(var e in o||(o={}))wo.call(o,e)&&Ge(t,e,o[e]);if(_o)for(var e of _o(o))ss.call(o,e)&&Ge(t,e,o[e]);return t},Z=(t,o)=>Qo(t,es(o));var ns=(t,o)=>{for(var e in o)De(t,e,{get:o[e],enumerable:!0})},Ro=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of ts(o))!wo.call(t,l)&&l!==e&&De(t,l,{get:()=>o[l],enumerable:!(a=Zo(o,l))||a.enumerable});return t};var as=(t,o,e)=>(e=t!=null?Vo(os(t)):{},Ro(o||!t||!t.__esModule?De(e,"default",{value:t,enumerable:!0}):e,t)),is=t=>Ro(De({},"__esModule",{value:!0}),t);var ae=(t,o,e)=>Ge(t,typeof o!="symbol"?o+"":o,e);var ms={};ns(ms,{CallControlPanel:()=>Go,initSDK:()=>fs,useClickToCall:()=>Oo,useEndCall:()=>Po,useLogout:()=>Ao});module.exports=is(ms);var Ye=class{constructor(){ae(this,"config",null);ae(this,"ticketId",null);ae(this,"baseUrl","");ae(this,"eventQueue",[]);ae(this,"isOnline",!0);ae(this,"retryQueue",[]);ae(this,"flushTimer",null)}async init(o){this.config=c({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},o),this.baseUrl=o.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let e=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),e}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 o=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(!o.ok)throw new Error(`Failed to initialize: ${o.status} ${o.statusText}`);let e=await o.json();return this.ticketId=e.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(o){throw console.error("EventTracker initialization failed:",o),o}}async logEvent(o,e){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",o);return}let a={eventType:o,eventData:e,timestamp:Date.now()};if(this.eventQueue.push(a),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(a)}catch(l){console.warn("Failed to send event, will retry later:",l)}}async sendEvent(o){if(!(!this.config||!this.ticketId))try{let e=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:o.eventType,eventData:o.eventData})});if(!e.ok)throw new Error(`Failed to log event: ${e.status} ${e.statusText}`);let a=this.eventQueue.findIndex(l=>l.timestamp===o.timestamp);a>-1&&this.eventQueue.splice(a,1)}catch(e){console.error("Event logging failed:",e),this.retryQueue.push(()=>this.sendEvent(o))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let o=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(!o.ok)throw new Error(`Failed to close ticket: ${o.status} ${o.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(o){throw console.error("Ticket close failed:",o),o}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let o=[...this.eventQueue];for(let a of o)await this.sendEvent(a);let e=[...this.retryQueue];this.retryQueue=[];for(let a of e)try{await a()}catch(l){console.error("Retry failed:",l)}}async makeRequest(o,e){var p;let a=`${this.baseUrl}${o}`,l=((p=this.config)==null?void 0:p.retryAttempts)||3;for(let g=1;g<=l;g++)try{return await fetch(a,e)}catch(C){if(g===l)throw C;let S=Math.min(1e3*Math.pow(2,g-1),1e4);await new Promise(f=>setTimeout(f,S))}throw new Error("Max retries exceeded")}setupAutoTracking(){var a;if(typeof window=="undefined"||!((a=this.config)!=null&&a.autoTrack))return;let o=this.config.autoTrack===!0?{}:this.config.autoTrack;if(o.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(l=>console.warn("Failed to track page visit:",l)),o.clicks!==!1&&document.addEventListener("click",l=>{var g;let p=l.target;(p.tagName==="BUTTON"||p.tagName==="A"||p.onclick||p.getAttribute("role")==="button"||p instanceof HTMLButtonElement&&p.type==="button")&&this.logEvent("click",{element:p.tagName,text:(g=p.textContent)==null?void 0:g.trim().substring(0,100),href:p.getAttribute("href"),id:p.id,className:p.className,role:p.getAttribute("role"),position:{x:l.clientX,y:l.clientY},timestamp:new Date().toISOString()}).catch(C=>console.warn("Failed to track click:",C))}),o.forms!==!1&&document.addEventListener("submit",l=>{let p=l.target,g=new FormData(p),C={};g.forEach((S,f)=>{C[f]=S.toString()}),this.logEvent("formSubmission",{formId:p.id,action:p.action,method:p.method,fields:Object.keys(C),fieldCount:Object.keys(C).length,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track form submission:",S))}),o.inputs!==!1){let l;document.addEventListener("input",p=>{let g=p.target;(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT")&&(clearTimeout(l),l=setTimeout(()=>{var C;this.logEvent("fieldChange",{element:g.tagName,type:g.getAttribute("type"),name:g.getAttribute("name"),id:g.id,valueLength:((C=g.value)==null?void 0:C.length)||0,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track field change:",S))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let l=Date.now()-e;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:l,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),o.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),o.errors!==!1&&(window.addEventListener("error",l=>{this.logEvent("jsError",{message:l.message,filename:l.filename,lineno:l.lineno,colno:l.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",l=>{var p;this.logEvent("unhandledRejection",{reason:(p=l.reason)==null?void 0:p.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let l=window.performance.navigation,p=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:p.navigationStart,loadTime:p.loadEventEnd-p.navigationStart,domReady:p.domContentLoadedEventEnd-p.navigationStart,renderTime:p.loadEventEnd-p.domContentLoadedEventEnd,navigationType:l.type,redirectCount:l.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 e;this.flushTimer&&clearInterval(this.flushTimer);let o=((e=this.config)==null?void 0:e.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},o)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},je=new Ye;typeof window!="undefined"&&(window.EventTracker=je);var Xe=class{constructor(){ae(this,"state");ae(this,"listeners",[]);ae(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,sdkConfig:{showEndCallButton:!0,showTransferButton:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},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 o=localStorage.getItem(this.STORAGE_KEY);if(o){let e=JSON.parse(o);this.state=Z(c({},this.state),{apiKey:e.apiKey||"",agentId:e.agentId||"",process:e.process||null,isInitialized:e.isInitialized||!1,sdkConfig:e.sdkConfig||{showEndCallButton:!0,showTransferButton:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},isHolding:e.isHolding||!1,isMuted:e.isMuted||!1,status:e.status||"idle",callStartTime:e.callStartTime||null,controlPanelPosition:e.controlPanelPosition||{x:10,y:10},iframePosition:e.iframePosition||{x:10,y:80},callData:e.callData||{mobileNumber:"",callReferenceId:"",agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:e.conferenceLine&&Array.isArray(e.conferenceLine)&&e.conferenceLine.length>0?e.conferenceLine:this.state.conferenceLine})}}catch(o){console.warn("Failed to load SDK state from localStorage:",o)}}saveToStorage(){try{let o={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,sdkConfig:this.state.sdkConfig,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(o))}catch(o){console.warn("Failed to save SDK state to localStorage:",o)}}notifyListeners(){this.listeners.forEach(o=>o())}initialize(o,e,a){if(!o||typeof o!="string"||o.trim().length===0)throw new Error("API key not available");this.state.apiKey=o,this.state.agentId=e,this.state.sdkConfig=c({showEndCallButton:!0,showTransferButton:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},a),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return c({},this.state)}subscribe(o){return this.listeners.push(o),()=>{let e=this.listeners.indexOf(o);e>-1&&this.listeners.splice(e,1)}}setHolding(o){this.state.isHolding=o,this.saveToStorage(),this.notifyListeners()}setMuted(o){this.state.isMuted=o,this.saveToStorage(),this.notifyListeners()}setStatus(o){this.state.status=o,this.saveToStorage(),this.notifyListeners()}setProcess(o){this.state.process=o,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(o){this.state.controlPanelPosition=o,this.saveToStorage(),this.notifyListeners()}setIframePosition(o){this.state.iframePosition=o,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(o){this.state.callData=c(c({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){var a;(!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 e=(a=this.state.conferenceLine)==null?void 0:a.map(l=>l.line===o.line?o:l);this.state.conferenceLine=e,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(o){console.warn("Failed to clear localStorage:",o)}}debugStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",o),o&&console.log("Parsed localStorage data:",JSON.parse(o)),console.log("Current state:",this.state)}catch(o){console.error("Error debugging storage:",o)}}getConferenceLines(){return this.state.conferenceLine||[]}},L=new Xe;var fe=require("react");var ze="10.10.102.42",H=`http://${ze}:8095`,ls=`ws://${ze}:8095`,W={v1:"/api/v1"},O={LOGIN:`${H}${W.v1}/cti/login?provider=convox`,READY_AGENT:`${H}${W.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${H}${W.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${H}${W.v1}/cti/calls?provider=convox`,HOLD_CALL:`${H}${W.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${H}${W.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${H}${W.v1}/cti/unmute-call?provider=convox`,END_CALL:`${H}${W.v1}/cti/calls/end?provider=convox`,LOGOUT:`${H}${W.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${H}${W.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${H}${W.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${H}${W.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${H}${W.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${H}${W.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${H}${W.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${H}${W.v1}/cti/users`,PROCESS_LIST:`${H}${W.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${H}${W.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${H}${W.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${H}${W.v1}/users/get_sentiment_analysis`},ko={WS:`${ls}${W.v1}/cti/ws`};var No=as(require("axios"));var rs="12345",Je=No.default.create({baseURL:H,headers:{"Content-Type":"application/json",Authorization:rs},timeout:1e4});Je.interceptors.request.use(t=>{let o="12345";return o&&t.headers&&(t.headers.Authorization=`Bearer ${o}`),t},t=>Promise.reject(t instanceof Error?t:new Error(String(t))));Je.interceptors.response.use(t=>t,async t=>{var e;let o=t.config;return((e=t.response)==null?void 0:e.status)===401&&!o._retry&&(o._retry=!0),Promise.reject(t instanceof Error?t:new Error(String(t)))});var oe=Je;var cs=()=>{let[t,o]=(0,fe.useState)(!1),[e,a]=(0,fe.useState)(!1),[l,p]=(0,fe.useState)(!1),[g,C]=(0,fe.useState)(null),[S,f]=(0,fe.useState)(null);return{logout:(0,fe.useCallback)(async()=>{var y;let m=JSON.parse((y=localStorage.getItem("call-control-sdk-state"))!=null?y:"");o(!0);let r={action:"LOGOUTUSER",userId:m.agentId||""};return oe.post(O.LOGOUT,r).then(h=>(L.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(h==null?void 0:h.data),a(!0),h==null?void 0:h.data)).catch(h=>{var E;return p(!0),C(h),(E=h==null?void 0:h.response)==null?void 0:E.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:S}},Ao=cs;var me=require("react");var Po=()=>{let[t,o]=(0,me.useState)(!1),[e,a]=(0,me.useState)(!1),[l,p]=(0,me.useState)(!1),[g,C]=(0,me.useState)(null),[S,f]=(0,me.useState)(null);return{handleEndCall:(0,me.useCallback)(async m=>{var h,E,M,U,A,w,B,te,$,R,x,q,se,ne,_;let r=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");o(!0);let y={action:"ENDCALL",userId:r==null?void 0:r.agentId,processid:(U=(M=(E=r==null?void 0:r.process)==null?void 0:E.process_id)==null?void 0:M.toString())!=null?U:"",process_name:(w=(A=r==null?void 0:r.process)==null?void 0:A.process_name)!=null?w:"",callreferenceid:(te=(B=r==null?void 0:r.callData)==null?void 0:B.convox_id)!=null?te:"",mobile_number:(R=($=r==null?void 0:r.callData)==null?void 0:$.phone_number)!=null?R:"",disposition:(x=m==null?void 0:m.disposition)!=null?x:"RES",set_followUp:(q=m==null?void 0:m.followUp)!=null?q:"N",callback_date:(se=m==null?void 0:m.callbackDate)!=null?se:"",callback_hrs:(ne=m==null?void 0:m.callbackHrs)!=null?ne:"",callback_mins:(_=m==null?void 0:m.callbackMins)!=null?_:"",endcall_type:"CLOSE"};return oe.post(O.END_CALL,y).then(v=>(L.endCall(),f(v==null?void 0:v.data),a(!0),v==null?void 0:v.data)).catch(v=>{var P;return p(!0),C(v),(P=v==null?void 0:v.response)==null?void 0:P.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:S}};var xe=require("react");var Oo=()=>{let[t,o]=(0,xe.useState)(!1),[e,a]=(0,xe.useState)(!1),[l,p]=(0,xe.useState)(!1),[g,C]=(0,xe.useState)(null),[S,f]=(0,xe.useState)(null);return{handleStartCall:(0,xe.useCallback)(async m=>{var y,h,E,M,U,A,w,B,te;let r=JSON.parse((y=localStorage.getItem("call-control-sdk-state"))!=null?y:"");if(o(!0),((h=r==null?void 0:r.callData)==null?void 0:h.status)==="IDLE"){let $={action:"CALL",userId:r==null?void 0:r.agentId,phone_number:m==null?void 0:m.mobileNumber};return oe.post(O.CLICK_TO_CALL,$).then(R=>(f(R==null?void 0:R.data),a(!0),R==null?void 0:R.data)).catch(R=>{var x;return p(!0),C(R),(x=R==null?void 0:R.response)==null?void 0:x.data}).finally(()=>{o(!1)})}else if(((E=r==null?void 0:r.callData)==null?void 0:E.status)==="ONCALL"){let $=(U=(M=r==null?void 0:r.conferenceLine)==null?void 0:M.filter(x=>x.line!==1))==null?void 0:U.find(x=>x.status==="IDLE"&&!(x!=null&&x.isCallStart)),R={action:"EXTERNAL_CONFERENCE",operation:`CALL${$.line}`,line_used:String($.line),thirdparty_no:m==null?void 0:m.mobileNumber,userid:(w=(A=r.callData)==null?void 0:A.agent_id)!=null?w:"",process:(te=(B=r.callData)==null?void 0:B.process_name)!=null?te:""};return oe.post(O.CONFERENCE_CALL,R).then(x=>(f(x==null?void 0:x.data),a(!0),L.setConferenceLine(Z(c({},$),{isCallStart:!0,status:"ONCALL",phone:m==null?void 0:m.mobileNumber})),x==null?void 0:x.data)).catch(x=>{var q;return p(!0),C(x),(q=x==null?void 0:x.response)==null?void 0:q.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:S}};var D=require("@mui/icons-material"),u=require("@mui/material"),K=require("react");var ie=require("react");function Ve(t,o){let[e,a]=(0,ie.useState)(t),[l,p]=(0,ie.useState)(!1),g=(0,ie.useRef)(),C=(0,ie.useRef)({x:0,y:0}),S=(0,ie.useRef)({x:0,y:0}),f=(0,ie.useCallback)(y=>{let h=g.current;if(!h)return;let E=h.getBoundingClientRect(),M=window.innerWidth,U=window.innerHeight,A={x:Math.max(0,Math.min(y.x,M-E.width)),y:Math.max(0,Math.min(y.y,U-E.height))};a(A),o==null||o(A)},[o]),b=(0,ie.useCallback)((y,h)=>{p(!0),C.current={x:y,y:h},S.current=e;let E=(w,B)=>{let te=w-C.current.x,$=B-C.current.y;f({x:S.current.x+te,y:S.current.y+$})},M=w=>{w.preventDefault(),E(w.clientX,w.clientY)},U=w=>{w.preventDefault();let B=w.touches[0];B&&E(B.clientX,B.clientY)},A=()=>{p(!1),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",A),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",A)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",A),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",A)},[e,f]),m=(0,ie.useCallback)(y=>{y.preventDefault(),b(y.clientX,y.clientY)},[b]),r=(0,ie.useCallback)(y=>{y.preventDefault();let h=y.touches[0];h&&b(h.clientX,h.clientY)},[b]);return{position:e,isDragging:l,dragRef:g,handleMouseDown:m,handleTouchStart:r}}var qe=require("react");function ye(){let[t,o]=(0,qe.useState)(L.getState());return(0,qe.useEffect)(()=>L.subscribe(()=>{o(L.getState())}),[]),t}var We=require("react");var Ce=require("react"),Fe=require("@mui/material"),Ie=require("react/jsx-runtime"),Uo=(0,Ce.createContext)(void 0),_e=()=>{let t=(0,Ce.useContext)(Uo);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},Mo=({children:t})=>{let[o,e]=(0,Ce.useState)(!1),[a,l]=(0,Ce.useState)(""),[p,g]=(0,Ce.useState)("info"),C=(S,f="info")=>{l(S),g(f),e(!0)};return(0,Ie.jsxs)(Uo.Provider,{value:{showToast:C},children:[t,(0,Ie.jsx)(Fe.Snackbar,{open:o,color:p,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,Ie.jsx)(Fe.Alert,{variant:"filled",severity:p,onClose:()=>e(!1),sx:{width:"100%"},children:a})})]})};var ds={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},ps=(t,o)=>{if(o.type==="isLoading")return Z(c({},t),{isLoading:o.payload});if(o.type==="isSuccess")return Z(c({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return Z(c({},t),{isError:!0,error:o.payload});if(o.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var le=(t={})=>{let{onSuccess:o=null,onError:e=null}=t,{showToast:a}=_e(),[l,p]=(0,We.useReducer)(ps,ds);return[(0,We.useCallback)((C,S,f={})=>{p({type:"isLoading",payload:!0}),oe.post(C,S,f).then(b=>{var m,r;p({type:"isSuccess",payload:b.data}),o==null||o(b.data,S),console.log((m=b.data)==null?void 0:m.message,"res45"),a((r=b.data)==null?void 0:r.message,"success")}).catch(b=>{var r,y,h,E,M,U,A,w,B,te,$,R;let m={status:(y=(r=b.response)==null?void 0:r.status)!=null?y:500,message:((E=(h=b.response)==null?void 0:h.data)==null?void 0:E.detail)||((U=(M=b.response)==null?void 0:M.data)==null?void 0:U.message)||b.message||"An unknown error occurred",data:(w=(A=b.response)==null?void 0:A.data)!=null?w:null,statusText:(te=(B=b.response)==null?void 0:B.statusText)!=null?te:"",code:($=b==null?void 0:b.code)!=null?$:"",name:(R=b==null?void 0:b.name)!=null?R:""};a(m.message,"error"),p({type:"isError",payload:m}),e==null||e(m,S)}).finally(()=>{p({type:"isLoading",payload:!1})})},[o,e,a]),l]};var N=require("@mui/icons-material"),n=require("@mui/material"),re=require("react");var Bo=require("@mui/material");var us=({disabled:t,enabled:o,outlined:e})=>{let a=(0,Bo.useTheme)();return{disabled:c({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 ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},t),enabled:c({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${a.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},o),outlined:c({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:a.palette.grey[200],boxShadow:`0px 2px 1px ${a.palette.primary.light}`,border:`0px solid ${a.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${a.palette.primary.main}`,border:`0px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},e)}},Ke=us;var s=require("react/jsx-runtime"),gs=({each:t})=>{var R,x,q,se,ne;let o=ye(),{showToast:e}=_e(),{disabled:a,enabled:l,outlined:p}=Ke({disabled:((R=o.sdkConfig)==null?void 0:R.disabled)||{},enabled:((x=o.sdkConfig)==null?void 0:x.enabled)||{},outlined:((q=o.sdkConfig)==null?void 0:q.outlined)||{}}),g=(0,n.useTheme)(),[C,S]=(0,re.useState)(!1),[f,b]=(0,re.useState)(!1),[m,r]=(0,re.useState)(!1),[y,h]=(0,re.useState)(!1),[E,M]=(0,re.useState)(!1),U=(_,v)=>{L.setConferenceLine(c(c({},_),v))},A=(_,v)=>{var F,j,Y,X;let P=c(c({},_),v);S(!0);let G={action:"EXTERNAL_CONFERENCE",operation:`CALL${P.line}`,line_used:String(P.line),thirdparty_no:P.phone,userid:(j=(F=o.callData)==null?void 0:F.agent_id)!=null?j:"",process:(X=(Y=o.callData)==null?void 0:Y.process_name)!=null?X:""};oe.post(O.CONFERENCE_CALL,G).then(k=>{var I;e((I=k.data)==null?void 0:I.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(k=>{var z,J,ee,V;let I=((J=(z=k.response)==null?void 0:z.data)==null?void 0:J.detail)||((V=(ee=k.response)==null?void 0:ee.data)==null?void 0:V.message)||k.message||"An unknown error occurred";e(I,"error")}).finally(()=>{S(!1)})},w=(_,v)=>{var F,j,Y,X;let P=c(c({},_),v);b(!0);let G={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(P.line),thirdparty_no:P.phone,userid:(j=(F=o.callData)==null?void 0:F.agent_id)!=null?j:"",process:(X=(Y=o.callData)==null?void 0:Y.process_name)!=null?X:""};oe.post(O.CONFERENCE_CALL,G).then(k=>{var I;e((I=k.data)==null?void 0:I.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(k=>{var z,J,ee,V;let I=((J=(z=k.response)==null?void 0:z.data)==null?void 0:J.detail)||((V=(ee=k.response)==null?void 0:ee.data)==null?void 0:V.message)||k.message||"An unknown error occurred";e(I,"error")}).finally(()=>{b(!1)})},B=(_,v,P)=>{var j,Y,X,k;let G=c(c({},_),v);r(!0);let F={action:"EXTERNAL_CONFERENCE",operation:P,hold_channel_no:P==="HOLDUSER"?`hold${G.line}`:`unhold${G.line}`,userid:(Y=(j=o.callData)==null?void 0:j.agent_id)!=null?Y:"",process:(k=(X=o.callData)==null?void 0:X.process_name)!=null?k:""};oe.post(O.CONFERENCE_CALL_HOLD_OR_UN_HOLD,F).then(I=>{var z;e((z=I.data)==null?void 0:z.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(I=>{var J,ee,V,pe;let z=((ee=(J=I.response)==null?void 0:J.data)==null?void 0:ee.detail)||((pe=(V=I.response)==null?void 0:V.data)==null?void 0:pe.message)||I.message||"An unknown error occurred";e(z,"error")}).finally(()=>{r(!1)})},te=(_,v,P)=>{var j,Y,X,k;let G=c(c({},_),v);h(!0);let F={action:"EXTERNAL_CONFERENCE",operation:P,channel_no:P==="MUTEUSER"?`mute${G.line}`:`play${G.line}`,userid:(Y=(j=o.callData)==null?void 0:j.agent_id)!=null?Y:"",thirdparty_no:G.phone,process:(k=(X=o.callData)==null?void 0:X.process_name)!=null?k:""};oe.post(O.CONFERENCE_CALL_MUTE_OT_UN_MUTE,F).then(I=>{var z;e((z=I.data)==null?void 0:z.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(I=>{var J,ee,V,pe;let z=((ee=(J=I.response)==null?void 0:J.data)==null?void 0:ee.detail)||((pe=(V=I.response)==null?void 0:V.data)==null?void 0:pe.message)||I.message||"An unknown error occurred";e(z,"error")}).finally(()=>{h(!1)})},$=(_,v)=>{var F,j,Y,X;let P=c(c({},_),v);M(!0);let G={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(P.line-1),user_type:`THIRDPARTY${P.line-1}`,thirdparty_no:P.phone,userid:(j=(F=o.callData)==null?void 0:F.agent_id)!=null?j:"",process:(X=(Y=o.callData)==null?void 0:Y.process_name)!=null?X:""};oe.post(O.CONFERENCE_CALL_END,G).then(k=>{var I;e((I=k.data)==null?void 0:I.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(k=>{var z,J,ee,V;let I=((J=(z=k.response)==null?void 0:z.data)==null?void 0:J.detail)||((V=(ee=k.response)==null?void 0:ee.data)==null?void 0:V.message)||k.message||"An unknown error occurred";e(I,"error")}).finally(()=>{M(!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 ",(se=t==null?void 0:t.line)!=null?se:"",". "]})}),(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:(ne=t==null?void 0:t.status)!=null?ne:""})}),(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:(t==null?void 0:t.line)===1?"Internal":"External"})})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.TextField,{size:"small",placeholder:"Phone Number",value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1,onChange:_=>{U(t,{phone:_.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:t!=null&&t.isCallStart?"outlined":"contained",color:"success",sx:t!=null&&t.isCallStart?c({},a):Z(c({},l),{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:()=>{A(t,{isCallStart:!0,status:"ONCALL"})},disabled:(t==null?void 0:t.isCallStart)||C,children:C?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"success"}):(0,s.jsx)(N.Call,{sx:{color:t!=null&&t.isCallStart?"default":"#e7e7e7ff"}})})}),(0,s.jsx)(n.Tooltip,{title:"Merge Call",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isMergeCall?"contained":"outlined",sx:t!=null&&t.isMergeCall&&(t!=null&&t.isCallStart)?c({},a):t!=null&&t.isCallStart?c({},p):c({},a),onClick:()=>{w(t,{isMergeCall:!0,status:"ONCALL"})},disabled:!(t!=null&&t.isCallStart)||f,children:f?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:t!=null&&t.isMergeCall?"#e7e7e7ff":g.palette.primary.main}}):(0,s.jsx)(N.CallSplit,{})})}),(0,s.jsx)(n.Tooltip,{title:t.isHold?"Hold":"Un Hold",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isHold?"contained":"outlined",sx:t!=null&&t.isHold&&(t!=null&&t.isCallStart)?c({},a):t!=null&&t.isCallStart?c({},p):c({},a),onClick:()=>{t.isHold?B(t,{isHold:!1},"UNHOLDUSER"):B(t,{isHold:!0},"HOLDUSER")},disabled:!(t!=null&&t.isCallStart)||m,children:m?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):t.isHold?(0,s.jsx)(N.PlayArrow,{}):(0,s.jsx)(N.Pause,{})})}),(0,s.jsx)(n.Tooltip,{title:t.isMute?"Mute":"Un Mute",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isMute?"contained":"outlined",sx:t!=null&&t.isMute&&(t!=null&&t.isCallStart)?c({},a):t!=null&&t.isCallStart?c({},p):c({},a),onClick:()=>{t.isMute?te(t,{isMute:!1},"PLAYUSER"):te(t,{isMute:!0},"MUTEUSER")},disabled:!(t!=null&&t.isCallStart)||y,children:y?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):t.isMute?(0,s.jsx)(N.MicOff,{}):(0,s.jsx)(N.Mic,{})})}),(0,s.jsx)(n.Tooltip,{title:"End Call",children:(t==null?void 0:t.line)!==1?(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:t!=null&&t.isCallStart?Z(c({},l),{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}`}}):Z(c({},a),{minWidth:"60px !important"}),onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart)||E,children:E?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error"}):(0,s.jsx)(N.CallEnd,{})}):(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",sx:Z(c({},a),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart),children:(0,s.jsx)(n.Typography,{children:(0,s.jsx)(N.CallEnd,{sx:{visibility:"hidden"}})})})})]})})]},t.line)};function Ho({open:t,setOpen:o}){var S;let e=ye(),{showToast:a}=_e(),[l,p]=(0,re.useState)(!1),g=()=>{o(!1)},C=()=>{var b,m,r,y;p(!0);let f={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(m=(b=e.callData)==null?void 0:b.agent_id)!=null?m:"",process:(y=(r=e.callData)==null?void 0:r.process_name)!=null?y:""};oe.post(O.CONFERENCE_CALL_END_ALL,f).then(h=>{var E;a((E=h.data)==null?void 0:E.message,"success"),L.resetConferenceLines(),g()}).catch(h=>{var M,U,A,w;let E=((U=(M=h.response)==null?void 0:M.data)==null?void 0:U.detail)||((w=(A=h.response)==null?void 0:A.data)==null?void 0:w.message)||h.message||"An unknown error occurred";a(E,"error")}).finally(()=>{p(!1)})};return(0,re.useEffect)(()=>{var b,m,r,y;let f={line:1,status:(m=(b=e.callData)==null?void 0:b.status)!=null?m:"",type:"internal",phone:(y=(r=e.callData)==null?void 0:r.phone_number)!=null?y:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};L.setConferenceLine(f)},[]),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"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:[(S=e==null?void 0:e.agentId)!=null?S:""," conference"]}),(0,s.jsx)(n.IconButton,{onClick:g,children:(0,s.jsx)(N.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:e==null?void 0:e.conferenceLine.map(f=>(0,s.jsx)(gs,{each:f}))})]})})}),(0,s.jsx)(n.Box,{textAlign:"center",m:2,children:(0,s.jsxs)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:C,disabled:l,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[l?(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)(N.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function $o({open:t,setOpen:o}){var r,y,h,E,M,U,A,w,B,te,$,R;let[e]=le({onSuccess:x=>{console.log("res",x),o(!1)},onError:x=>{console.log("error",x)}}),a=ye(),[l,p]=(0,re.useState)("process"),[g,{data:C}]=le(),[S,{data:f}]=le(),b=()=>{o(!1)},m=(x,q)=>{var se,ne,_,v,P,G,F,j,Y,X,k,I,z,J,ee,V,pe,we,be,Re,ve,ke,Se,Ne,Ae,Pe,Ee,Oe,Ue,Me,Be,He,$e;if(console.log(x,"data34"),q==="PROCESS"){let he={mobile_number:(ne=(se=a.callData)==null?void 0:se.phone_number)!=null?ne:"",userid:(v=(_=a.callData)==null?void 0:_.agent_id)!=null?v:"",type:"PROCESS",transfer_to:(P=x==null?void 0:x.process_name)!=null?P:"",callreferenceid:(F=(G=a.callData)==null?void 0:G.convox_id)!=null?F:"",processid:String((Y=(j=a.callData)==null?void 0:j.process_id)!=null?Y:""),process_name:(k=(X=a.callData)==null?void 0:X.process_name)!=null?k:""};e(O.TRANSFER_CALL,he)}else if(q==="QUEUE"){let he={mobile_number:(z=(I=a.callData)==null?void 0:I.phone_number)!=null?z:"",userid:(ee=(J=a.callData)==null?void 0:J.agent_id)!=null?ee:"",type:"QUEUE",transfer_to:(V=x==null?void 0:x.queue_name)!=null?V:"",callreferenceid:(we=(pe=a.callData)==null?void 0:pe.convox_id)!=null?we:"",processid:String((Re=(be=a.callData)==null?void 0:be.process_id)!=null?Re:""),process_name:(ke=(ve=a.callData)==null?void 0:ve.process_name)!=null?ke:""};e(O.TRANSFER_CALL,he)}else if(q==="AGENT"){let he={mobile_number:(Ne=(Se=a.callData)==null?void 0:Se.phone_number)!=null?Ne:"",userid:(Pe=(Ae=a.callData)==null?void 0:Ae.agent_id)!=null?Pe:"",type:"AGENT",transfer_to:(Ee=x==null?void 0:x.user_id)!=null?Ee:"",callreferenceid:(Ue=(Oe=a.callData)==null?void 0:Oe.convox_id)!=null?Ue:"",processid:String((Be=(Me=a.callData)==null?void 0:Me.process_id)!=null?Be:""),process_name:($e=(He=a.callData)==null?void 0:He.process_name)!=null?$e:""};e(O.TRANSFER_CALL,he)}};return(0,re.useEffect)(()=>{g(O.AGENTS_LIST,{status:"IDLE",active:!0}),S(O.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(C,"idleAgentsList"),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"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:b,children:(0,s.jsx)(N.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:l==="process"?"contained":"outlined",onClick:()=>p("process"),children:"Process"}),(0,s.jsx)(n.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>p("queues"),children:"Queues"}),(0,s.jsx)(n.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>p("agents"),children:"Agents"})]}),l==="process"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(r=f==null?void 0:f.data)!=null&&r.process&&((h=(y=f==null?void 0:f.data)==null?void 0:y.process)==null?void 0:h.length)>0?(M=(E=f==null?void 0:f.data)==null?void 0:E.process)==null?void 0:M.map((x,q)=>(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)(N.SupportAgent,{sx:{marginRight:"4px"}}),x.process_name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"PROCESS")},children:(0,s.jsx)(N.Call,{})})]},q)):(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"})}),l==="queues"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(U=f==null?void 0:f.data)!=null&&U.queue&&((w=(A=f==null?void 0:f.data)==null?void 0:A.queue)==null?void 0:w.length)>0?(te=(B=f==null?void 0:f.data)==null?void 0:B.queue)==null?void 0:te.map((x,q)=>{var se,ne,_,v,P,G;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)(N.SupportAgent,{sx:{marginRight:"4px"}}),x.queue_name,(_=(ne=(se=f==null?void 0:f.data)==null?void 0:se.process)==null?void 0:ne.find(F=>F.process_id===x.process_id))!=null&&_.process_name?(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((G=(P=(v=f==null?void 0:f.data)==null?void 0:v.process)==null?void 0:P.find(F=>F.process_id===x.process_id))==null?void 0:G.process_name)+")"}):""]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"QUEUE")},children:(0,s.jsx)(N.Call,{})})]},q)}):(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"})}),l==="agents"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:C!=null&&C.data&&(($=C==null?void 0:C.data)==null?void 0:$.length)>0?(R=C==null?void 0:C.data)==null?void 0:R.map((x,q)=>(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)(N.SupportAgent,{sx:{marginRight:"4px"}}),x.name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"AGENT")},children:(0,s.jsx)(N.Call,{})})]},q)):(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 zo({open:t,setOpen:o,onSubmitDisposition:e}){var b,m;let[a,l]=(0,re.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),p=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],g=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],C=(r,y)=>{l(h=>Z(c({},h),{[r]:y}))},S=()=>{l({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{S(),o(!1)};return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"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:a.disposition,options:p,getOptionLabel:r=>r.label,onChange:(r,y)=>C("disposition",y),size:"small",renderInput:r=>(0,s.jsx)(n.TextField,Z(c({},r),{label:"Disposition",fullWidth:!0}))})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{options:g,getOptionLabel:r=>r.label,value:a.followUp,onChange:(r,y)=>C("followUp",y),size:"small",renderInput:r=>(0,s.jsx)(n.TextField,Z(c({},r),{label:"Follow Up",fullWidth:!0}))})}),((m=(b=a==null?void 0:a.followUp)==null?void 0:b.label)==null?void 0:m.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:a.callbackDate,onChange:r=>C("callbackDate",r.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:a.callbackHrs,onChange:r=>C("callbackHrs",r.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:a.callbackMins,onChange:r=>C("callbackMins",r.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:()=>e(a),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function qo({open:t,setOpen:o}){return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"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:()=>{o(!1)},children:(0,s.jsx)(N.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 d=require("react/jsx-runtime");function Fo({onDataChange:t}){var et,tt,ot,st,nt,at,it,lt,rt,ct,dt,pt,ut,gt,ft,mt,xt,Ct,ht,yt,bt,vt,St,Et,Tt,Lt,Dt,It,_t,wt,Rt,kt,Nt,At,Pt,Ot,Ut,Mt,Bt,Ht,$t,zt,qt,Ft,Wt,Kt,Gt,Yt,jt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,no,ao,io,lo,ro,co,po,uo,go,fo,mo,xo,Co,ho;let o=(0,u.useTheme)(),e=ye(),{disabled:a,enabled:l,outlined:p}=Ke({disabled:((et=e.sdkConfig)==null?void 0:et.disabled)||{},enabled:((tt=e.sdkConfig)==null?void 0:tt.enabled)||{},outlined:((ot=e.sdkConfig)==null?void 0:ot.outlined)||{}}),g=(0,K.useRef)(null),[C,S]=(0,K.useState)(null),[f,b]=(0,K.useState)(!0),[m,r]=(0,K.useState)(null),[y,h]=(0,K.useState)(null),[E,M]=(0,K.useState)(!1),[U,A]=(0,K.useState)(!1),[w,B]=(0,K.useState)(!1),[te,$]=(0,K.useState)(!1),[R,x]=(0,K.useState)(!1),[q,se]=(0,K.useState)(""),[ne,_]=(0,K.useState)(0),{position:v,isDragging:P,dragRef:G,handleMouseDown:F,handleTouchStart:j}=Ve(e.controlPanelPosition,i=>L.setControlPanelPosition(i)),{position:Y,isDragging:X,dragRef:k,handleMouseDown:I,handleTouchStart:z}=Ve(e.iframePosition,i=>L.setIframePosition(i)),[J,{data:ee}]=le({onSuccess:i=>{var T;console.log("res",i),i&&i.data&&((T=i==null?void 0:i.data)==null?void 0:T.length)>1?$(!0):(L.setProcess(i==null?void 0:i.data[0]),$(!1))},onError:()=>{$(!1)}}),[V,{isLoading:pe}]=le(),[we,{isLoading:be}]=le({onSuccess:()=>{L.setHolding(!e.isHolding)},onError:i=>{console.log("error",i)}}),[Re,{isLoading:ve}]=le({onSuccess:()=>{L.setMuted(!e.isMuted)},onError:i=>{console.log("error",i)}}),[ke,{isLoading:Se}]=le(),[Ne,{isLoading:Ae}]=le(),[Pe,{isLoading:Ee}]=le(),Oe=(0,K.useCallback)(i=>{let T=Math.floor(i/60),Q=i%60;return`${T.toString().padStart(2,"0")}:${Q.toString().padStart(2,"0")}`},[]),Ue=()=>{S(null)},Me=i=>{b(!0),h(i.currentTarget),L.setStatus("dial")},Be=()=>{e.status!=="on call"&&L.setStatus("idle"),h(null)},He=i=>{r(i.currentTarget)},$e=()=>{r(null)},he=()=>{let i={action:"READYAGENT",userId:e.agentId};ke(O.READY_AGENT,i)},Ze=i=>{r(null);let T={action:"AGENTBREAK",break_type:i,userId:e.agentId};Ne(O.UPDATE_AGENT_BREAK,T)},Yo=i=>{if(i.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(i)){let T={action:"CALL",phone_number:i,userId:e.agentId};V(O.CLICK_TO_CALL,T)}},jo=()=>{let i={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};we(O.HOLD_CALL,i)},Xo=()=>{let i={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};Re(O.MUTE_CALL,i)},Jo=i=>{var Q,ce,de,ue,ge,Te,Le,yo,bo,vo,So,Eo,To,Lo,Do,Io;console.log("data",i);let T={action:"ENDCALL",userId:e.agentId,processid:(de=(ce=(Q=e.process)==null?void 0:Q.process_id)==null?void 0:ce.toString())!=null?de:"",process_name:(ge=(ue=e.process)==null?void 0:ue.process_name)!=null?ge:"",callreferenceid:(Le=(Te=e.callData)==null?void 0:Te.convox_id)!=null?Le:"",mobile_number:(bo=(yo=e.callData)==null?void 0:yo.phone_number)!=null?bo:"",disposition:(So=(vo=i==null?void 0:i.disposition)==null?void 0:vo.value)!=null?So:"",set_followUp:(To=(Eo=i==null?void 0:i.followUp)==null?void 0:Eo.value)!=null?To:"",callback_date:(Lo=i==null?void 0:i.callbackDate)!=null?Lo:"",callback_hrs:(Do=i==null?void 0:i.callbackHrs)!=null?Do:"",callback_mins:(Io=i==null?void 0:i.callbackMins)!=null?Io:"",endcall_type:"CLOSE"};se(""),Pe(O.END_CALL,T),L.endCall(),B(!1)};return(0,K.useEffect)(()=>{let i;return e.callData.status&&e.callData.status==="ONCALL"?i=setInterval(()=>{let T=Math.floor((Date.now()-e.callStartTime)/1e3);_(T)},1e3):_(0),()=>{i&&clearInterval(i)}},[e.callData.status]),(0,K.useEffect)(()=>{t&&t(e.callData)},[e.callData,t]),(0,K.useEffect)(()=>{e.agentId?J(O.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),(0,K.useEffect)(()=>(e.agentId&&(g.current=new WebSocket(`${ko.WS}?agent_id=${e.agentId}`),g.current.onopen=()=>{console.log("WebSocket connection established")},g.current.onmessage=i=>{try{let T=JSON.parse(i.data);console.log("parsedJSON:",T),L.updateCallData(T),T.status==="ONCALL"&&L.startCall(),T.status==="WRAPUP"&&L.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()}),[e.agentId]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(u.Fade,{in:!0,timeout:300,children:(0,d.jsx)(u.Paper,{ref:G,elevation:P?4:1,sx:{position:"fixed",left:v.x,top:v.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:99999,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:(0,d.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,d.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,d.jsxs)(u.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:F,onTouchStart:j,children:[(0,d.jsx)(D.DragIndicator,{})," "]}),(0,d.jsx)(u.Box,{sx:{marginRight:"10px"},children:(0,d.jsx)(u.Tooltip,{title:"Dial",children:(0,d.jsx)(u.IconButton,{size:"small",onClick:i=>{var T,Q,ce,de,ue,ge,Te,Le;((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())!=="ONCALL"&&((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())!=="BREAK"&&((ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())!=="RINGING"&&((Le=(Te=e.callData)==null?void 0:Te.status)==null?void 0:Le.toUpperCase())!=="WRAPUP"&&Me(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,d.jsx)(D.WifiCalling3,{sx:{color:((nt=(st=e.callData)==null?void 0:st.status)==null?void 0:nt.toUpperCase())==="ONCALL"||((it=(at=e.callData)==null?void 0:at.status)==null?void 0:it.toUpperCase())==="BREAK"||((rt=(lt=e.callData)==null?void 0:lt.status)==null?void 0:rt.toUpperCase())==="RINGING"||((dt=(ct=e.callData)==null?void 0:ct.status)==null?void 0:dt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,d.jsx)(u.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Oe(ne)}),Ae||Se?(0,d.jsx)(u.Box,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,d.jsx)(u.CircularProgress,{size:"20px"})}):(0,d.jsx)(u.Typography,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(gt=(ut=(pt=e.callData)==null?void 0:pt.status)==null?void 0:ut.toUpperCase())!=null?gt:"N/A"}),(0,d.jsx)(u.Box,{onClick:He,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:(0,d.jsx)(D.ArrowDropDown,{})})]}),(0,d.jsxs)(u.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,d.jsx)(u.Tooltip,{title:"Agent Ready",children:(0,d.jsx)(u.Button,{variant:((mt=(ft=e.callData)==null?void 0:ft.status)==null?void 0:mt.toUpperCase())==="BREAK"||((Ct=(xt=e.callData)==null?void 0:xt.status)==null?void 0:Ct.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var T,Q,ce,de;(((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="BREAK"||((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())==="MISSED")&&(i.stopPropagation(),he())},classes:{root:((yt=(ht=e.callData)==null?void 0:ht.status)==null?void 0:yt.toUpperCase())==="BREAK"||((vt=(bt=e.callData)==null?void 0:bt.status)==null?void 0:vt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:c({},((Et=(St=e.callData)==null?void 0:St.status)==null?void 0:Et.toUpperCase())==="BREAK"||((Lt=(Tt=e.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())==="MISSED"?p:l),disabled:Se,children:(0,d.jsx)(D.SupportAgent,{})})}),(0,d.jsx)(u.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,d.jsx)(u.Button,{variant:e.isHolding&&((It=(Dt=e.callData)==null?void 0:Dt.status)==null?void 0:It.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),jo()},sx:e.isHolding&&((wt=(_t=e.callData)==null?void 0:_t.status)==null?void 0:wt.toUpperCase())==="ONCALL"?c({},l):((kt=(Rt=e.callData)==null?void 0:Rt.status)==null?void 0:kt.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((At=(Nt=e.callData)==null?void 0:Nt.status)==null?void 0:At.toUpperCase())!=="ONCALL"&&!e.isHolding||be,children:be?(0,d.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?(0,d.jsx)(D.PlayArrow,{}):(0,d.jsx)(D.Pause,{})})}),(0,d.jsx)(u.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,d.jsx)(u.Button,{variant:e.isMuted&&((Ot=(Pt=e.callData)==null?void 0:Pt.status)==null?void 0:Ot.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),Xo()},sx:e.isMuted&&((Mt=(Ut=e.callData)==null?void 0:Ut.status)==null?void 0:Mt.toUpperCase())==="ONCALL"?c({},l):((Ht=(Bt=e.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((zt=($t=e.callData)==null?void 0:$t.status)==null?void 0:zt.toUpperCase())!=="ONCALL"&&!e.isMuted||ve,children:ve?(0,d.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?(0,d.jsx)(D.MicOff,{}):(0,d.jsx)(D.Mic,{})})}),((qt=e.sdkConfig)==null?void 0:qt.showTransferButton)&&(0,d.jsx)(u.Tooltip,{title:"Transfer Call",children:(0,d.jsx)(u.Button,{variant:U?"contained":"outlined",onClick:i=>{var T,Q;((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),A(!0))},sx:U?c({},l):((Wt=(Ft=e.callData)==null?void 0:Ft.status)==null?void 0:Wt.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((Gt=(Kt=e.callData)==null?void 0:Kt.status)==null?void 0:Gt.toUpperCase())!=="ONCALL",children:(0,d.jsx)(D.TransferWithinAStation,{})})}),((Yt=e.sdkConfig)==null?void 0:Yt.showConferenceButton)&&(0,d.jsx)(u.Tooltip,{title:"Conference Call",children:(0,d.jsx)(u.Button,{variant:E?"contained":"outlined",onClick:i=>{var T,Q;((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),M(!0))},sx:E?c({},l):((Xt=(jt=e.callData)==null?void 0:jt.status)==null?void 0:Xt.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((Vt=(Jt=e.callData)==null?void 0:Jt.status)==null?void 0:Vt.toUpperCase())!=="ONCALL",children:(0,d.jsx)(D.Group,{})})}),((Qt=e.sdkConfig)==null?void 0:Qt.showEndCallButton)&&(0,d.jsx)(u.Tooltip,{title:"End Call",children:(0,d.jsx)(u.Button,{variant:((eo=(Zt=e.callData)==null?void 0:Zt.status)==null?void 0:eo.toUpperCase())==="ONCALL"||((oo=(to=e.callData)==null?void 0:to.status)==null?void 0:oo.toUpperCase())==="RINGING"||((no=(so=e.callData)==null?void 0:so.status)==null?void 0:no.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var T,Q,ce,de,ue,ge;(((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="ONCALL"||((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())==="RINGING"||((ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())==="WRAPUP")&&(i.stopPropagation(),B(!0))},sx:((io=(ao=e.callData)==null?void 0:ao.status)==null?void 0:io.toUpperCase())==="ONCALL"||((ro=(lo=e.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())==="RINGING"||((po=(co=e.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())==="WRAPUP"?Z(c({},l),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${o.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${o.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${o.palette.primary.light}`}}):Z(c({},a),{minWidth:"60px !important"}),disabled:((go=(uo=e.callData)==null?void 0:uo.status)==null?void 0:go.toUpperCase())!=="ONCALL"&&((mo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())!=="RINGING"&&((Co=(xo=e.callData)==null?void 0:xo.status)==null?void 0:Co.toUpperCase())!=="WRAPUP"||Ee,children:Ee?(0,d.jsx)(u.CircularProgress,{size:"20px",color:"error"}):(0,d.jsx)(D.CallEnd,{})})})]})]})})}),(0,d.jsx)(u.Fade,{in:!0,timeout:300,children:(0,d.jsxs)(u.Paper,{ref:k,elevation:X?4:1,sx:{position:"fixed",left:Y.x,top:Y.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:99999,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:f?"visible":"hidden",userSelect:"none"},children:[(0,d.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:I,onTouchStart:z,children:[(0,d.jsx)(D.DragIndicator,{sx:{transform:"rotate(90deg)"}})," ",(0,d.jsx)(u.IconButton,{onClick:()=>b(!1),children:(0,d.jsx)(D.Close,{})})]}),(0,d.jsx)("iframe",{src:`https://${ze}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(ho=e.process)==null?void 0:ho.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})]})}),(0,d.jsx)(u.Menu,{anchorEl:y,open:!!y,onClose:Be,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(u.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(u.TextField,{size:"small",value:q,placeholder:"Enter Mobile No.",onChange:i=>{se(i.target.value)}}),(0,d.jsx)(u.IconButton,{color:"info",onClick:()=>{Yo(q)},children:pe?(0,d.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,d.jsx)(D.Phone,{color:"success"})})]})}),(0,d.jsxs)(u.Menu,{anchorEl:m,open:!!m,onClose:$e,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,d.jsx)(u.MenuItem,{onClick:()=>Ze("Lunch"),children:"- Lunch"}),(0,d.jsx)(u.MenuItem,{onClick:()=>Ze("Tea"),children:"- Tea"})]}),(0,d.jsx)(u.Menu,{anchorEl:C,open:!!C,onClose:Ue,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(u.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(u.Chip,{icon:(0,d.jsx)(D.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,d.jsx)(u.Chip,{icon:(0,d.jsx)(D.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,d.jsx)(u.Chip,{icon:(0,d.jsx)(D.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!E&&(0,d.jsx)(Ho,{open:E,setOpen:M}),!!U&&(0,d.jsx)($o,{open:U,setOpen:A}),!!w&&(0,d.jsx)(zo,{open:w,setOpen:B,onSubmitDisposition:Jo}),!!R&&(0,d.jsx)(qo,{open:R,setOpen:x})]})}var Ko=require("react/jsx-runtime"),Wo=({children:t})=>(0,Ko.jsx)(Mo,{children:t});var Qe=require("react/jsx-runtime");function Go({onDataChange:t}){return(0,Qe.jsx)(Wo,{children:(0,Qe.jsx)(Fo,{onDataChange:t})})}function fs({apiKey:t,tenantId:o,agentId:e,sdkConfig:a}){L.initialize(t,e,a),je.init({apiKey:t,tenantId:o,agentId:e,baseUrl:H}).then(l=>{console.log(l?"SDK initialized successfully":"SDK initialization failed")})}0&&(module.exports={CallControlPanel,initSDK,useClickToCall,useEndCall,useLogout});
1
+ "use strict";var Wo=Object.create;var Ee=Object.defineProperty,Go=Object.defineProperties,Ko=Object.getOwnPropertyDescriptor,jo=Object.getOwnPropertyDescriptors,Yo=Object.getOwnPropertyNames,vo=Object.getOwnPropertySymbols,Xo=Object.getPrototypeOf,So=Object.prototype.hasOwnProperty,Jo=Object.prototype.propertyIsEnumerable;var Ge=(e,t,a)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,d=(e,t)=>{for(var a in t||(t={}))So.call(t,a)&&Ge(e,a,t[a]);if(vo)for(var a of vo(t))Jo.call(t,a)&&Ge(e,a,t[a]);return e},Z=(e,t)=>Go(e,jo(t));var Vo=(e,t)=>{for(var a in t)Ee(e,a,{get:t[a],enumerable:!0})},Eo=(e,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Yo(t))!So.call(e,r)&&r!==a&&Ee(e,r,{get:()=>t[r],enumerable:!(l=Ko(t,r))||l.enumerable});return e};var Qo=(e,t,a)=>(a=e!=null?Wo(Xo(e)):{},Eo(t||!e||!e.__esModule?Ee(a,"default",{value:e,enumerable:!0}):a,e)),Zo=e=>Eo(Ee({},"__esModule",{value:!0}),e);var oe=(e,t,a)=>Ge(e,typeof t!="symbol"?t+"":t,a);var rs={};Vo(rs,{CallControlPanel:()=>Ho,initSDK:()=>ls,useClickToCall:()=>Ro,useEndCall:()=>Io,useLogout:()=>Do});module.exports=Zo(rs);var Ke=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=d({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(r){console.warn("Failed to send event, will retry later:",r)}}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(r=>r.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(r){console.error("Retry failed:",r)}}async makeRequest(t,a){var o;let l=`${this.baseUrl}${t}`,r=((o=this.config)==null?void 0:o.retryAttempts)||3;for(let g=1;g<=r;g++)try{return await fetch(l,a)}catch(y){if(g===r)throw y;let S=Math.min(1e3*Math.pow(2,g-1),1e4);await new Promise(f=>setTimeout(f,S))}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(r=>console.warn("Failed to track page visit:",r)),t.clicks!==!1&&document.addEventListener("click",r=>{var g;let o=r.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:r.clientX,y:r.clientY},timestamp:new Date().toISOString()}).catch(y=>console.warn("Failed to track click:",y))}),t.forms!==!1&&document.addEventListener("submit",r=>{let o=r.target,g=new FormData(o),y={};g.forEach((S,f)=>{y[f]=S.toString()}),this.logEvent("formSubmission",{formId:o.id,action:o.action,method:o.method,fields:Object.keys(y),fieldCount:Object.keys(y).length,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track form submission:",S))}),t.inputs!==!1){let r;document.addEventListener("input",o=>{let g=o.target;(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT")&&(clearTimeout(r),r=setTimeout(()=>{var y;this.logEvent("fieldChange",{element:g.tagName,type:g.getAttribute("type"),name:g.getAttribute("name"),id:g.id,valueLength:((y=g.value)==null?void 0:y.length)||0,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track field change:",S))},1e3))})}let a=Date.now();window.addEventListener("beforeunload",()=>{let r=Date.now()-a;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:r,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",r=>{this.logEvent("jsError",{message:r.message,filename:r.filename,lineno:r.lineno,colno:r.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",r=>{var o;this.logEvent("unhandledRejection",{reason:(o=r.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 r=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:r.type,redirectCount:r.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)}},je=new Ke;typeof window!="undefined"&&(window.EventTracker=je);var Ye=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=Z(d({},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 d({},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=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 a=(l=this.state.conferenceLine)==null?void 0:l.map(r=>r.line===t.line?t:r);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||[]}},D=new Ye;var de=require("react");var q="http://172.29.16.1:8095",es="ws://172.29.16.1:8095",j={v1:"/api/v1"},M={LOGIN:`${q}${j.v1}/cti/login?provider=convox`,READY_AGENT:`${q}${j.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${q}${j.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${q}${j.v1}/cti/calls?provider=convox`,HOLD_CALL:`${q}${j.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${q}${j.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${q}${j.v1}/cti/unmute-call?provider=convox`,END_CALL:`${q}${j.v1}/cti/calls/end?provider=convox`,LOGOUT:`${q}${j.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${q}${j.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${q}${j.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${q}${j.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${q}${j.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${q}${j.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${q}${j.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${q}${j.v1}/cti/users`,PROCESS_LIST:`${q}${j.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${q}${j.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${q}${j.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${q}${j.v1}/users/get_sentiment_analysis`},To={WS:`${es}${j.v1}/cti/ws`};var Lo=Qo(require("axios"));var ts="12345",Xe=Lo.default.create({baseURL:q,headers:{"Content-Type":"application/json",Authorization:ts},timeout:1e4});Xe.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))));Xe.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=Xe;var os=()=>{let[e,t]=(0,de.useState)(!1),[a,l]=(0,de.useState)(!1),[r,o]=(0,de.useState)(!1),[g,y]=(0,de.useState)(null),[S,f]=(0,de.useState)(null);return{logout:(0,de.useCallback)(async()=>{var h;let m=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");t(!0);let c={action:"LOGOUTUSER",userId:m.agentId||""};return te.post(M.LOGOUT,c).then(C=>(D.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(C==null?void 0:C.data),l(!0),C==null?void 0:C.data)).catch(C=>{var E;return o(!0),y(C),(E=C==null?void 0:C.response)==null?void 0:E.data}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:a,isError:r,error:g,data:S}},Do=os;var ue=require("react");var Io=()=>{let[e,t]=(0,ue.useState)(!1),[a,l]=(0,ue.useState)(!1),[r,o]=(0,ue.useState)(!1),[g,y]=(0,ue.useState)(null),[S,f]=(0,ue.useState)(null);return{handleEndCall:(0,ue.useCallback)(async m=>{var C,E,B,U,P,_,$,ee,F,w,x,v,k,O,z;let c=JSON.parse((C=localStorage.getItem("call-control-sdk-state"))!=null?C:"");t(!0);let h={action:"ENDCALL",userId:c==null?void 0:c.agentId,processid:(U=(B=(E=c==null?void 0:c.process)==null?void 0:E.process_id)==null?void 0:B.toString())!=null?U:"",process_name:(_=(P=c==null?void 0:c.process)==null?void 0:P.process_name)!=null?_:"",callreferenceid:(ee=($=c==null?void 0:c.callData)==null?void 0:$.convox_id)!=null?ee:"",mobile_number:(w=(F=c==null?void 0:c.callData)==null?void 0:F.phone_number)!=null?w:"",disposition:(x=m==null?void 0:m.disposition)!=null?x:"RES",set_followUp:(v=m==null?void 0:m.followUp)!=null?v:"N",callback_date:(k=m==null?void 0:m.callbackDate)!=null?k:"",callback_hrs:(O=m==null?void 0:m.callbackHrs)!=null?O:"",callback_mins:(z=m==null?void 0:m.callbackMins)!=null?z:"",endcall_type:"CLOSE"};return te.post(M.END_CALL,h).then(T=>(D.endCall(),f(T==null?void 0:T.data),l(!0),T==null?void 0:T.data)).catch(T=>{var H;return o(!0),y(T),(H=T==null?void 0:T.response)==null?void 0:H.data}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:a,isError:r,error:g,data:S}};var ge=require("react");var Ro=()=>{let[e,t]=(0,ge.useState)(!1),[a,l]=(0,ge.useState)(!1),[r,o]=(0,ge.useState)(!1),[g,y]=(0,ge.useState)(null),[S,f]=(0,ge.useState)(null);return{handleStartCall:(0,ge.useCallback)(async m=>{var h,C,E,B,U,P,_,$,ee;let c=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");if(t(!0),((C=c==null?void 0:c.callData)==null?void 0:C.status)==="IDLE"){let F={action:"CALL",userId:c==null?void 0:c.agentId,phone_number:m==null?void 0:m.mobileNumber};return te.post(M.CLICK_TO_CALL,F).then(w=>(f(w==null?void 0:w.data),l(!0),w==null?void 0:w.data)).catch(w=>{var x;return o(!0),y(w),(x=w==null?void 0:w.response)==null?void 0:x.data}).finally(()=>{t(!1)})}else if(((E=c==null?void 0:c.callData)==null?void 0:E.status)==="ONCALL"){let F=(U=(B=c==null?void 0:c.conferenceLine)==null?void 0:B.filter(x=>x.line!==1))==null?void 0:U.find(x=>x.status==="IDLE"&&!(x!=null&&x.isCallStart)),w={action:"EXTERNAL_CONFERENCE",operation:`CALL${F.line}`,line_used:String(F.line),thirdparty_no:m==null?void 0:m.mobileNumber,userid:(_=(P=c.callData)==null?void 0:P.agent_id)!=null?_:"",process:(ee=($=c.callData)==null?void 0:$.process_name)!=null?ee:""};return te.post(M.CONFERENCE_CALL,w).then(x=>(f(x==null?void 0:x.data),l(!0),D.setConferenceLine(Z(d({},F),{isCallStart:!0,status:"ONCALL",phone:m==null?void 0:m.mobileNumber})),x==null?void 0:x.data)).catch(x=>{var v;return o(!0),y(x),(v=x==null?void 0:x.response)==null?void 0:v.data}).finally(()=>{t(!1)})}else alert("Agent is not ready")},[]),isLoading:e,isSuccess:a,isError:r,error:g,data:S}};var I=require("@mui/icons-material"),u=require("@mui/material"),Y=require("react");var se=require("react");function Je(e,t){let[a,l]=(0,se.useState)(e),[r,o]=(0,se.useState)(!1),g=(0,se.useRef)(),y=(0,se.useRef)({x:0,y:0}),S=(0,se.useRef)({x:0,y:0}),f=(0,se.useCallback)(h=>{let C=g.current;if(!C)return;let E=C.getBoundingClientRect(),B=window.innerWidth,U=window.innerHeight,P={x:Math.max(0,Math.min(h.x,B-E.width)),y:Math.max(0,Math.min(h.y,U-E.height))};l(P),t==null||t(P)},[t]),b=(0,se.useCallback)((h,C)=>{o(!0),y.current={x:h,y:C},S.current=a;let E=(_,$)=>{let ee=_-y.current.x,F=$-y.current.y;f({x:S.current.x+ee,y:S.current.y+F})},B=_=>{_.preventDefault(),E(_.clientX,_.clientY)},U=_=>{_.preventDefault();let $=_.touches[0];$&&E($.clientX,$.clientY)},P=()=>{o(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",P),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",P)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",P),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",P)},[a,f]),m=(0,se.useCallback)(h=>{h.preventDefault(),b(h.clientX,h.clientY)},[b]),c=(0,se.useCallback)(h=>{h.preventDefault();let C=h.touches[0];C&&b(C.clientX,C.clientY)},[b]);return{position:a,isDragging:r,dragRef:g,handleMouseDown:m,handleTouchStart:c}}var $e=require("react");function xe(){let[e,t]=(0,$e.useState)(D.getState());return(0,$e.useEffect)(()=>D.subscribe(()=>{t(D.getState())}),[]),e}var qe=require("react");var fe=require("react"),ze=require("@mui/material"),Te=require("react/jsx-runtime"),_o=(0,fe.createContext)(void 0),Le=()=>{let e=(0,fe.useContext)(_o);if(!e)throw new Error("useToast must be used inside ToastProvider");return e},wo=({children:e})=>{let[t,a]=(0,fe.useState)(!1),[l,r]=(0,fe.useState)(""),[o,g]=(0,fe.useState)("info"),y=(S,f="info")=>{r(S),g(f),a(!0)};return(0,Te.jsxs)(_o.Provider,{value:{showToast:y},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 ss={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},as=(e,t)=>{if(t.type==="isLoading")return Z(d({},e),{isLoading:t.payload});if(t.type==="isSuccess")return Z(d({},e),{isSuccess:!0,data:t.payload});if(t.type==="isError")return Z(d({},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}=Le(),[r,o]=(0,qe.useReducer)(as,ss);return[(0,qe.useCallback)((y,S,f={})=>{o({type:"isLoading",payload:!0}),te.post(y,S,f).then(b=>{var m,c;o({type:"isSuccess",payload:b.data}),t==null||t(b.data,S),console.log((m=b.data)==null?void 0:m.message,"res45"),l((c=b.data)==null?void 0:c.message,"success")}).catch(b=>{var c,h,C,E,B,U,P,_,$,ee,F,w;let m={status:(h=(c=b.response)==null?void 0:c.status)!=null?h:500,message:((E=(C=b.response)==null?void 0:C.data)==null?void 0:E.detail)||((U=(B=b.response)==null?void 0:B.data)==null?void 0:U.message)||b.message||"An unknown error occurred",data:(_=(P=b.response)==null?void 0:P.data)!=null?_:null,statusText:(ee=($=b.response)==null?void 0:$.statusText)!=null?ee:"",code:(F=b==null?void 0:b.code)!=null?F:"",name:(w=b==null?void 0:b.name)!=null?w:""};l(m.message,"error"),o({type:"isError",payload:m}),a==null||a(m,S)}).finally(()=>{o({type:"isLoading",payload:!1})})},[t,a,l]),r]};var A=require("@mui/icons-material"),n=require("@mui/material"),ne=require("react");var ko=require("@mui/material"),ns=()=>{let e=(0,ko.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}`}}}},Fe=ns;var s=require("react/jsx-runtime"),is=({each:e})=>{var w,x;let t=xe(),{showToast:a}=Le(),{disabled:l,enabled:r,outlined:o}=Fe(),g=(0,n.useTheme)(),[y,S]=(0,ne.useState)(!1),[f,b]=(0,ne.useState)(!1),[m,c]=(0,ne.useState)(!1),[h,C]=(0,ne.useState)(!1),[E,B]=(0,ne.useState)(!1),U=(v,k)=>{D.setConferenceLine(d(d({},v),k))},P=(v,k)=>{var T,H,K,W;let O=d(d({},v),k);S(!0);let z={action:"EXTERNAL_CONFERENCE",operation:`CALL${O.line}`,line_used:String(O.line),thirdparty_no:O.phone,userid:(H=(T=t.callData)==null?void 0:T.agent_id)!=null?H:"",process:(W=(K=t.callData)==null?void 0:K.process_name)!=null?W:""};te.post(M.CONFERENCE_CALL,z).then(N=>{var R;a((R=N.data)==null?void 0:R.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(N=>{var G,X,J,V;let R=((X=(G=N.response)==null?void 0:G.data)==null?void 0:X.detail)||((V=(J=N.response)==null?void 0:J.data)==null?void 0:V.message)||N.message||"An unknown error occurred";a(R,"error")}).finally(()=>{S(!1)})},_=(v,k)=>{var T,H,K,W;let O=d(d({},v),k);b(!0);let z={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(O.line),thirdparty_no:O.phone,userid:(H=(T=t.callData)==null?void 0:T.agent_id)!=null?H:"",process:(W=(K=t.callData)==null?void 0:K.process_name)!=null?W:""};te.post(M.CONFERENCE_CALL,z).then(N=>{var R;a((R=N.data)==null?void 0:R.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(N=>{var G,X,J,V;let R=((X=(G=N.response)==null?void 0:G.data)==null?void 0:X.detail)||((V=(J=N.response)==null?void 0:J.data)==null?void 0:V.message)||N.message||"An unknown error occurred";a(R,"error")}).finally(()=>{b(!1)})},$=(v,k,O)=>{var H,K,W,N;let z=d(d({},v),k);c(!0);let T={action:"EXTERNAL_CONFERENCE",operation:O,hold_channel_no:O==="HOLDUSER"?`hold${z.line}`:`unhold${z.line}`,userid:(K=(H=t.callData)==null?void 0:H.agent_id)!=null?K:"",process:(N=(W=t.callData)==null?void 0:W.process_name)!=null?N:""};te.post(M.CONFERENCE_CALL_HOLD_OR_UN_HOLD,T).then(R=>{var G;a((G=R.data)==null?void 0:G.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(R=>{var X,J,V,re;let G=((J=(X=R.response)==null?void 0:X.data)==null?void 0:J.detail)||((re=(V=R.response)==null?void 0:V.data)==null?void 0:re.message)||R.message||"An unknown error occurred";a(G,"error")}).finally(()=>{c(!1)})},ee=(v,k,O)=>{var H,K,W,N;let z=d(d({},v),k);C(!0);let T={action:"EXTERNAL_CONFERENCE",operation:O,channel_no:O==="MUTEUSER"?`mute${z.line}`:`play${z.line}`,userid:(K=(H=t.callData)==null?void 0:H.agent_id)!=null?K:"",thirdparty_no:z.phone,process:(N=(W=t.callData)==null?void 0:W.process_name)!=null?N:""};te.post(M.CONFERENCE_CALL_MUTE_OT_UN_MUTE,T).then(R=>{var G;a((G=R.data)==null?void 0:G.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(R=>{var X,J,V,re;let G=((J=(X=R.response)==null?void 0:X.data)==null?void 0:J.detail)||((re=(V=R.response)==null?void 0:V.data)==null?void 0:re.message)||R.message||"An unknown error occurred";a(G,"error")}).finally(()=>{C(!1)})},F=(v,k)=>{var T,H,K,W;let O=d(d({},v),k);B(!0);let z={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(O.line-1),user_type:`THIRDPARTY${O.line-1}`,thirdparty_no:O.phone,userid:(H=(T=t.callData)==null?void 0:T.agent_id)!=null?H:"",process:(W=(K=t.callData)==null?void 0:K.process_name)!=null?W:""};te.post(M.CONFERENCE_CALL_END,z).then(N=>{var R;a((R=N.data)==null?void 0:R.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(N=>{var G,X,J,V;let R=((X=(G=N.response)==null?void 0:G.data)==null?void 0:X.detail)||((V=(J=N.response)==null?void 0:J.data)==null?void 0:V.message)||N.message||"An unknown error occurred";a(R,"error")}).finally(()=>{B(!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 ",(w=e==null?void 0:e.line)!=null?w:"",". "]})}),(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:(x=e==null?void 0:e.status)!=null?x:""})}),(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=>{U(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?d({},l):Z(d({},r),{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)||y,children:y?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"success"}):(0,s.jsx)(A.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)?d({},l):e!=null&&e.isCallStart?d({},o):d({},l),onClick:()=>{_(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)(A.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)?d({},l):e!=null&&e.isCallStart?d({},o):d({},l),onClick:()=>{e.isHold?$(e,{isHold:!1},"UNHOLDUSER"):$(e,{isHold:!0},"HOLDUSER")},disabled:!(e!=null&&e.isCallStart)||m,children:m?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):e.isHold?(0,s.jsx)(A.PlayArrow,{}):(0,s.jsx)(A.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)?d({},l):e!=null&&e.isCallStart?d({},o):d({},l),onClick:()=>{e.isMute?ee(e,{isMute:!1},"PLAYUSER"):ee(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)(A.MicOff,{}):(0,s.jsx)(A.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?Z(d({},r),{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}`}}):Z(d({},l),{minWidth:"60px !important"}),onClick:()=>{F(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart)||E,children:E?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error"}):(0,s.jsx)(A.CallEnd,{})}):(0,s.jsx)(n.Button,{variant:e!=null&&e.isCallStart?"contained":"outlined",sx:Z(d({},l),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{F(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)(A.CallEnd,{sx:{visibility:"hidden"}})})})})]})})]},e.line)};function No({open:e,setOpen:t}){var S;let a=xe(),{showToast:l}=Le(),[r,o]=(0,ne.useState)(!1),g=()=>{t(!1)},y=()=>{var b,m,c,h;o(!0);let f={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(m=(b=a.callData)==null?void 0:b.agent_id)!=null?m:"",process:(h=(c=a.callData)==null?void 0:c.process_name)!=null?h:""};te.post(M.CONFERENCE_CALL_END_ALL,f).then(C=>{var E;l((E=C.data)==null?void 0:E.message,"success"),D.resetConferenceLines(),g()}).catch(C=>{var B,U,P,_;let E=((U=(B=C.response)==null?void 0:B.data)==null?void 0:U.detail)||((_=(P=C.response)==null?void 0:P.data)==null?void 0:_.message)||C.message||"An unknown error occurred";l(E,"error")}).finally(()=>{o(!1)})};return(0,ne.useEffect)(()=>{var b,m,c,h;let f={line:1,status:(m=(b=a.callData)==null?void 0:b.status)!=null?m:"",type:"internal",phone:(h=(c=a.callData)==null?void 0:c.phone_number)!=null?h:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};D.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:[(S=a==null?void 0:a.agentId)!=null?S:""," conference"]}),(0,s.jsx)(n.IconButton,{onClick:g,children:(0,s.jsx)(A.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)(is,{each:f}))})]})})}),(0,s.jsx)(n.Box,{textAlign:"center",m:2,children:(0,s.jsxs)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:y,disabled:r,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[r?(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)(A.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function Ao({open:e,setOpen:t}){var c,h,C,E,B,U,P,_,$,ee,F,w;let[a]=ae({onSuccess:x=>{console.log("res",x),t(!1)},onError:x=>{console.log("error",x)}}),l=xe(),[r,o]=(0,ne.useState)("process"),[g,{data:y}]=ae(),[S,{data:f}]=ae(),b=()=>{t(!1)},m=(x,v)=>{var k,O,z,T,H,K,W,N,R,G,X,J,V,re,We,De,Ie,Re,ye,_e,Ce,we,he,ke,Ne,Ae,be,Pe,Oe,Me,Ue,Be,He;if(console.log(x,"data34"),v==="PROCESS"){let me={mobile_number:(O=(k=l.callData)==null?void 0:k.phone_number)!=null?O:"",userid:(T=(z=l.callData)==null?void 0:z.agent_id)!=null?T:"",type:"PROCESS",transfer_to:(H=x==null?void 0:x.process_name)!=null?H:"",callreferenceid:(W=(K=l.callData)==null?void 0:K.convox_id)!=null?W:"",processid:String((R=(N=l.callData)==null?void 0:N.process_id)!=null?R:""),process_name:(X=(G=l.callData)==null?void 0:G.process_name)!=null?X:""};a(M.TRANSFER_CALL,me)}else if(v==="QUEUE"){let me={mobile_number:(V=(J=l.callData)==null?void 0:J.phone_number)!=null?V:"",userid:(We=(re=l.callData)==null?void 0:re.agent_id)!=null?We:"",type:"QUEUE",transfer_to:(De=x==null?void 0:x.queue_name)!=null?De:"",callreferenceid:(Re=(Ie=l.callData)==null?void 0:Ie.convox_id)!=null?Re:"",processid:String((_e=(ye=l.callData)==null?void 0:ye.process_id)!=null?_e:""),process_name:(we=(Ce=l.callData)==null?void 0:Ce.process_name)!=null?we:""};a(M.TRANSFER_CALL,me)}else if(v==="AGENT"){let me={mobile_number:(ke=(he=l.callData)==null?void 0:he.phone_number)!=null?ke:"",userid:(Ae=(Ne=l.callData)==null?void 0:Ne.agent_id)!=null?Ae:"",type:"AGENT",transfer_to:(be=x==null?void 0:x.user_id)!=null?be:"",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(M.TRANSFER_CALL,me)}};return(0,ne.useEffect)(()=>{g(M.AGENTS_LIST,{status:"IDLE",active:!0}),S(M.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(y,"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:b,children:(0,s.jsx)(A.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:r==="process"?"contained":"outlined",onClick:()=>o("process"),children:"Process"}),(0,s.jsx)(n.Button,{variant:r==="queues"?"contained":"outlined",onClick:()=>o("queues"),children:"Queues"}),(0,s.jsx)(n.Button,{variant:r==="agents"?"contained":"outlined",onClick:()=>o("agents"),children:"Agents"})]}),r==="process"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(c=f==null?void 0:f.data)!=null&&c.process&&((C=(h=f==null?void 0:f.data)==null?void 0:h.process)==null?void 0:C.length)>0?(B=(E=f==null?void 0:f.data)==null?void 0:E.process)==null?void 0:B.map((x,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)(A.SupportAgent,{sx:{marginRight:"4px"}}),x.process_name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"PROCESS")},children:(0,s.jsx)(A.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"})}),r==="queues"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(U=f==null?void 0:f.data)!=null&&U.queue&&((_=(P=f==null?void 0:f.data)==null?void 0:P.queue)==null?void 0:_.length)>0?(ee=($=f==null?void 0:f.data)==null?void 0:$.queue)==null?void 0:ee.map((x,v)=>{var k,O,z,T,H,K;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)(A.SupportAgent,{sx:{marginRight:"4px"}}),x.queue_name,(z=(O=(k=f==null?void 0:f.data)==null?void 0:k.process)==null?void 0:O.find(W=>W.process_id===x.process_id))!=null&&z.process_name?(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((K=(H=(T=f==null?void 0:f.data)==null?void 0:T.process)==null?void 0:H.find(W=>W.process_id===x.process_id))==null?void 0:K.process_name)+")"}):""]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"QUEUE")},children:(0,s.jsx)(A.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"})}),r==="agents"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:y!=null&&y.data&&((F=y==null?void 0:y.data)==null?void 0:F.length)>0?(w=y==null?void 0:y.data)==null?void 0:w.map((x,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)(A.SupportAgent,{sx:{marginRight:"4px"}}),x.name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"AGENT")},children:(0,s.jsx)(A.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 Po({open:e,setOpen:t,onSubmitDisposition:a}){var b,m;let[l,r]=(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"}],y=(c,h)=>{r(C=>Z(d({},C),{[c]:h}))},S=()=>{r({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{S(),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:c=>c.label,onChange:(c,h)=>y("disposition",h),size:"small",renderInput:c=>(0,s.jsx)(n.TextField,Z(d({},c),{label:"Disposition",fullWidth:!0}))})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{options:g,getOptionLabel:c=>c.label,value:l.followUp,onChange:(c,h)=>y("followUp",h),size:"small",renderInput:c=>(0,s.jsx)(n.TextField,Z(d({},c),{label:"Follow Up",fullWidth:!0}))})}),((m=(b=l==null?void 0:l.followUp)==null?void 0:b.label)==null?void 0:m.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:c=>y("callbackDate",c.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:c=>y("callbackHrs",c.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:c=>y("callbackMins",c.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 Oo({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)(A.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 p=require("react/jsx-runtime");function Mo({onDataChange:e}){var Ze,et,tt,ot,st,at,nt,it,lt,rt,ct,pt,dt,ut,gt,ft,mt,xt,yt,Ct,ht,bt,vt,St,Et,Tt,Lt,Dt,It,Rt,_t,wt,kt,Nt,At,Pt,Ot,Mt,Ut,Bt,Ht,$t,zt,qt,Ft,Wt,Gt,Kt,jt,Yt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,ao,no,io,lo,ro,co,po;let t=(0,u.useTheme)(),{disabled:a,enabled:l,outlined:r}=Fe(),o=xe(),g=(0,Y.useRef)(null),[y,S]=(0,Y.useState)(null),[f,b]=(0,Y.useState)(!0),[m,c]=(0,Y.useState)(null),[h,C]=(0,Y.useState)(null),[E,B]=(0,Y.useState)(!1),[U,P]=(0,Y.useState)(!1),[_,$]=(0,Y.useState)(!1),[ee,F]=(0,Y.useState)(!1),[w,x]=(0,Y.useState)(!1),[v,k]=(0,Y.useState)(""),[O,z]=(0,Y.useState)(0),{position:T,isDragging:H,dragRef:K,handleMouseDown:W,handleTouchStart:N}=Je(o.controlPanelPosition,i=>D.setControlPanelPosition(i)),{position:R,isDragging:G,dragRef:X,handleMouseDown:J,handleTouchStart:V}=Je(o.iframePosition,i=>D.setIframePosition(i)),[re,{data:We}]=ae({onSuccess:i=>{var L;console.log("res",i),i&&i.data&&((L=i==null?void 0:i.data)==null?void 0:L.length)>1?F(!0):(D.setProcess(i==null?void 0:i.data[0]),F(!1))},onError:()=>{F(!1)}}),[De,{isLoading:Ie}]=ae(),[Re,{isLoading:ye}]=ae({onSuccess:()=>{D.setHolding(!o.isHolding)},onError:i=>{console.log("error",i)}}),[_e,{isLoading:Ce}]=ae({onSuccess:()=>{D.setMuted(!o.isMuted)},onError:i=>{console.log("error",i)}}),[we,{isLoading:he}]=ae(),[ke,{isLoading:Ne}]=ae(),[Ae,{isLoading:be}]=ae(),Pe=(0,Y.useCallback)(i=>{let L=Math.floor(i/60),Q=i%60;return`${L.toString().padStart(2,"0")}:${Q.toString().padStart(2,"0")}`},[]),Oe=()=>{S(null)},Me=i=>{b(!0),C(i.currentTarget),D.setStatus("dial")},Ue=()=>{o.status!=="on call"&&D.setStatus("idle"),C(null)},Be=i=>{c(i.currentTarget)},He=()=>{c(null)},me=()=>{let i={action:"READYAGENT",userId:o.agentId};we(M.READY_AGENT,i)},Qe=i=>{c(null);let L={action:"AGENTBREAK",break_type:i,userId:o.agentId};ke(M.UPDATE_AGENT_BREAK,L)},$o=i=>{if(i.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(i)){let L={action:"CALL",phone_number:i,userId:o.agentId};De(M.CLICK_TO_CALL,L)}},zo=()=>{let i={action:o.isHolding?"UNHOLD":"HOLD",userId:o.agentId};Re(M.HOLD_CALL,i)},qo=()=>{let i={action:o.isMuted?"UNMUTE":"MUTE",userId:o.agentId};_e(M.MUTE_CALL,i)},Fo=i=>{var Q,ie,le,ce,pe,ve,Se,uo,go,fo,mo,xo,yo,Co,ho,bo;console.log("data",i);let L={action:"ENDCALL",userId:o.agentId,processid:(le=(ie=(Q=o.process)==null?void 0:Q.process_id)==null?void 0:ie.toString())!=null?le:"",process_name:(pe=(ce=o.process)==null?void 0:ce.process_name)!=null?pe:"",callreferenceid:(Se=(ve=o.callData)==null?void 0:ve.convox_id)!=null?Se:"",mobile_number:(go=(uo=o.callData)==null?void 0:uo.phone_number)!=null?go:"",disposition:(mo=(fo=i==null?void 0:i.disposition)==null?void 0:fo.value)!=null?mo:"",set_followUp:(yo=(xo=i==null?void 0:i.followUp)==null?void 0:xo.value)!=null?yo:"",callback_date:(Co=i==null?void 0:i.callbackDate)!=null?Co:"",callback_hrs:(ho=i==null?void 0:i.callbackHrs)!=null?ho:"",callback_mins:(bo=i==null?void 0:i.callbackMins)!=null?bo:"",endcall_type:"CLOSE"};k(""),Ae(M.END_CALL,L),D.endCall(),$(!1)};return(0,Y.useEffect)(()=>{let i;return o.callData.status&&o.callData.status==="ONCALL"?i=setInterval(()=>{let L=Math.floor((Date.now()-o.callStartTime)/1e3);z(L)},1e3):z(0),()=>{i&&clearInterval(i)}},[o.callData.status]),(0,Y.useEffect)(()=>{e&&e(o.callData)},[o.callData,e]),(0,Y.useEffect)(()=>{o.agentId?re(M.PROCESS_LIST,{userId:o.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[o.agentId]),(0,Y.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 L=JSON.parse(i.data);console.log("parsedJSON:",L),D.updateCallData(L),L.status==="ONCALL"&&D.startCall(),L.status==="WRAPUP"&&D.endCall()}catch(L){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]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.Fade,{in:!0,timeout:300,children:(0,p.jsx)(u.Paper,{ref:K,elevation:H?4:1,sx:{position:"fixed",left:T.x,top:T.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,p.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,p.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,p.jsxs)(u.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:W,onTouchStart:N,children:[(0,p.jsx)(I.DragIndicator,{})," "]}),(0,p.jsx)(u.Box,{sx:{marginRight:"10px"},children:(0,p.jsx)(u.Tooltip,{title:"Dial",children:(0,p.jsx)(u.IconButton,{size:"small",onClick:i=>{var L,Q,ie,le,ce,pe,ve,Se;((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.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"&&((Se=(ve=o.callData)==null?void 0:ve.status)==null?void 0:Se.toUpperCase())!=="WRAPUP"&&Me(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,p.jsx)(I.WifiCalling3,{sx:{color:((et=(Ze=o.callData)==null?void 0:Ze.status)==null?void 0:et.toUpperCase())==="ONCALL"||((ot=(tt=o.callData)==null?void 0:tt.status)==null?void 0:ot.toUpperCase())==="BREAK"||((at=(st=o.callData)==null?void 0:st.status)==null?void 0:at.toUpperCase())==="RINGING"||((it=(nt=o.callData)==null?void 0:nt.status)==null?void 0:it.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,p.jsx)(u.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Pe(O)}),Ne||he?(0,p.jsx)(u.Box,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,p.jsx)(u.CircularProgress,{size:"20px"})}):(0,p.jsx)(u.Typography,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(ct=(rt=(lt=o.callData)==null?void 0:lt.status)==null?void 0:rt.toUpperCase())!=null?ct:"N/A"}),(0,p.jsx)(u.Box,{onClick:Be,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:(0,p.jsx)(I.ArrowDropDown,{})})]}),(0,p.jsxs)(u.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,p.jsx)(u.Tooltip,{title:"Agent Ready",children:(0,p.jsx)(u.Button,{variant:((dt=(pt=o.callData)==null?void 0:pt.status)==null?void 0:dt.toUpperCase())==="BREAK"||((gt=(ut=o.callData)==null?void 0:ut.status)==null?void 0:gt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var L,Q,ie,le;(((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())==="BREAK"||((le=(ie=o.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())==="MISSED")&&(i.stopPropagation(),me())},classes:{root:((mt=(ft=o.callData)==null?void 0:ft.status)==null?void 0:mt.toUpperCase())==="BREAK"||((yt=(xt=o.callData)==null?void 0:xt.status)==null?void 0:yt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:d({},((ht=(Ct=o.callData)==null?void 0:Ct.status)==null?void 0:ht.toUpperCase())==="BREAK"||((vt=(bt=o.callData)==null?void 0:bt.status)==null?void 0:vt.toUpperCase())==="MISSED"?r:l),disabled:he,children:(0,p.jsx)(I.SupportAgent,{})})}),(0,p.jsx)(u.Tooltip,{title:o.isHolding?"Resume":"Hold",children:(0,p.jsx)(u.Button,{variant:o.isHolding&&((Et=(St=o.callData)==null?void 0:St.status)==null?void 0:Et.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),zo()},sx:o.isHolding&&((Lt=(Tt=o.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())==="ONCALL"?d({},l):((It=(Dt=o.callData)==null?void 0:Dt.status)==null?void 0:It.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((_t=(Rt=o.callData)==null?void 0:Rt.status)==null?void 0:_t.toUpperCase())!=="ONCALL"&&!o.isHolding||ye,children:ye?(0,p.jsx)(u.CircularProgress,{size:"20px",sx:{color:t.palette.primary.main}}):o.isHolding?(0,p.jsx)(I.PlayArrow,{}):(0,p.jsx)(I.Pause,{})})}),(0,p.jsx)(u.Tooltip,{title:o.isMuted?"Unmute":"Mute",children:(0,p.jsx)(u.Button,{variant:o.isMuted&&((kt=(wt=o.callData)==null?void 0:wt.status)==null?void 0:kt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),qo()},sx:o.isMuted&&((At=(Nt=o.callData)==null?void 0:Nt.status)==null?void 0:At.toUpperCase())==="ONCALL"?d({},l):((Ot=(Pt=o.callData)==null?void 0:Pt.status)==null?void 0:Ot.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((Ut=(Mt=o.callData)==null?void 0:Mt.status)==null?void 0:Ut.toUpperCase())!=="ONCALL"&&!o.isMuted||Ce,children:Ce?(0,p.jsx)(u.CircularProgress,{size:"20px",sx:{color:t.palette.primary.main}}):o.isMuted?(0,p.jsx)(I.MicOff,{}):(0,p.jsx)(I.Mic,{})})}),(0,p.jsx)(u.Tooltip,{title:"Transfer Call",children:(0,p.jsx)(u.Button,{variant:U?"contained":"outlined",onClick:i=>{var L,Q;((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),P(!0))},sx:U?d({},l):((Ht=(Bt=o.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((zt=($t=o.callData)==null?void 0:$t.status)==null?void 0:zt.toUpperCase())!=="ONCALL",children:(0,p.jsx)(I.TransferWithinAStation,{})})}),(0,p.jsx)(u.Tooltip,{title:"Conference Call",children:(0,p.jsx)(u.Button,{variant:E?"contained":"outlined",onClick:i=>{var L,Q;((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),B(!0))},sx:E?d({},l):((Ft=(qt=o.callData)==null?void 0:qt.status)==null?void 0:Ft.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((Gt=(Wt=o.callData)==null?void 0:Wt.status)==null?void 0:Gt.toUpperCase())!=="ONCALL",children:(0,p.jsx)(I.Group,{})})}),(0,p.jsx)(u.Tooltip,{title:"End Call",children:(0,p.jsx)(u.Button,{variant:((jt=(Kt=o.callData)==null?void 0:Kt.status)==null?void 0:jt.toUpperCase())==="ONCALL"||((Xt=(Yt=o.callData)==null?void 0:Yt.status)==null?void 0:Xt.toUpperCase())==="RINGING"||((Vt=(Jt=o.callData)==null?void 0:Jt.status)==null?void 0:Vt.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var L,Q,ie,le,ce,pe;(((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.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(),$(!0))},sx:((Zt=(Qt=o.callData)==null?void 0:Qt.status)==null?void 0:Zt.toUpperCase())==="ONCALL"||((to=(eo=o.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())==="RINGING"||((so=(oo=o.callData)==null?void 0:oo.status)==null?void 0:so.toUpperCase())==="WRAPUP"?Z(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}`}}):Z(d({},a),{minWidth:"60px !important"}),disabled:((no=(ao=o.callData)==null?void 0:ao.status)==null?void 0:no.toUpperCase())!=="ONCALL"&&((lo=(io=o.callData)==null?void 0:io.status)==null?void 0:lo.toUpperCase())!=="RINGING"&&((co=(ro=o.callData)==null?void 0:ro.status)==null?void 0:co.toUpperCase())!=="WRAPUP"||be,children:be?(0,p.jsx)(u.CircularProgress,{size:"20px",color:"error"}):(0,p.jsx)(I.CallEnd,{})})})]})]})})}),(0,p.jsx)(u.Fade,{in:!0,timeout:300,children:(0,p.jsxs)(u.Paper,{ref:X,elevation:G?4:1,sx:{position:"fixed",left:R.x,top:R.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,p.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:J,onTouchStart:V,children:[(0,p.jsx)(I.DragIndicator,{sx:{transform:"rotate(90deg)"}})," ",(0,p.jsx)(u.IconButton,{onClick:()=>b(!1),children:(0,p.jsx)(I.Close,{})})]}),(0,p.jsx)("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${o.agentId}&process_id=${(po=o.process)==null?void 0:po.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),(0,p.jsx)(u.Menu,{anchorEl:h,open:!!h,onClose:Ue,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,p.jsxs)(u.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,p.jsx)(u.TextField,{size:"small",value:v,placeholder:"Enter Mobile No.",onChange:i=>{k(i.target.value)}}),(0,p.jsx)(u.IconButton,{color:"info",onClick:()=>{$o(v)},children:Ie?(0,p.jsx)(u.CircularProgress,{size:"20px",sx:{color:t.palette.success.main}}):(0,p.jsx)(I.Phone,{color:"success"})})]})}),(0,p.jsxs)(u.Menu,{anchorEl:m,open:!!m,onClose:He,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,p.jsx)(u.MenuItem,{onClick:()=>Qe("Lunch"),children:"- Lunch"}),(0,p.jsx)(u.MenuItem,{onClick:()=>Qe("Tea"),children:"- Tea"})]}),(0,p.jsx)(u.Menu,{anchorEl:y,open:!!y,onClose:Oe,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,p.jsxs)(u.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,p.jsx)(u.Chip,{icon:(0,p.jsx)(I.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,p.jsx)(u.Chip,{icon:(0,p.jsx)(I.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,p.jsx)(u.Chip,{icon:(0,p.jsx)(I.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!E&&(0,p.jsx)(No,{open:E,setOpen:B}),!!U&&(0,p.jsx)(Ao,{open:U,setOpen:P}),!!_&&(0,p.jsx)(Po,{open:_,setOpen:$,onSubmitDisposition:Fo}),!!w&&(0,p.jsx)(Oo,{open:w,setOpen:x})]})}var Bo=require("react/jsx-runtime"),Uo=({children:e})=>(0,Bo.jsx)(wo,{children:e});var Ve=require("react/jsx-runtime");function Ho({onDataChange:e}){return(0,Ve.jsx)(Uo,{children:(0,Ve.jsx)(Mo,{onDataChange:e})})}function ls({apiKey:e,tenantId:t,agentId:a}){D.initialize(e,a),je.init({apiKey:e,tenantId:t,agentId:a,baseUrl:q})}0&&(module.exports={CallControlPanel,initSDK,useClickToCall,useEndCall,useLogout});
2
2
  //# sourceMappingURL=index.js.map