call-control-sdk 6.4.5-dev.7 → 6.4.5-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/incoming-4WP3FJI4.mp3 +0 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var yn=Object.create;var Re=Object.defineProperty,hn=Object.defineProperties,En=Object.getOwnPropertyDescriptor,Tn=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertyNames,Ko=Object.getOwnPropertySymbols,vn=Object.getPrototypeOf,Fo=Object.prototype.hasOwnProperty,Dn=Object.prototype.propertyIsEnumerable;var Ze=(t,o,e)=>o in t?Re(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,p=(t,o)=>{for(var e in o||(o={}))Fo.call(o,e)&&Ze(t,e,o[e]);if(Ko)for(var e of Ko(o))Dn.call(o,e)&&Ze(t,e,o[e]);return t},Y=(t,o)=>hn(t,Tn(o));var Ln=(t,o)=>{for(var e in o)Re(t,e,{get:o[e],enumerable:!0})},Wo=(t,o,e,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Sn(o))!Fo.call(t,i)&&i!==e&&Re(t,i,{get:()=>o[i],enumerable:!(l=En(o,i))||l.enumerable});return t};var In=(t,o,e)=>(e=t!=null?yn(vn(t)):{},Wo(o||!t||!t.__esModule?Re(e,"default",{value:t,enumerable:!0}):e,t)),_n=t=>Wo(Re({},"__esModule",{value:!0}),t);var ce=(t,o,e)=>Ze(t,typeof o!="symbol"?o+"":o,e);var Fn={};Ln(Fn,{CallControlPanel:()=>at,getSDKVersion:()=>qn,initSDK:()=>zn,isSDKInitialized:()=>Kn,useClickToCall:()=>Vo,useEndCall:()=>Jo,useGetAuthorizationToken:()=>Qo,useGetCallerData:()=>Zo,useLogout:()=>Xo});module.exports=_n(Fn);var Ke="uat-cti.aighospitals.com",$=`https://${Ke}:8095`,Rn=`wss://${Ke}:8095`,j={v1:"/api/v1"},R={LOGIN:`${$}${j.v1}/cti/login?provider=convox`,READY_AGENT:`${$}${j.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${$}${j.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${$}${j.v1}/cti/calls?provider=convox`,HOLD_CALL:`${$}${j.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${$}${j.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${$}${j.v1}/cti/unmute-call?provider=convox`,END_CALL:`${$}${j.v1}/cti/calls/end?provider=convox`,LOGOUT:`${$}${j.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${$}${j.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${$}${j.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${$}${j.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${$}${j.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${$}${j.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${$}${j.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${$}${j.v1}/cti/users`,PROCESS_LIST:`${$}${j.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${$}${j.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${$}${j.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${$}${j.v1}/users/get_sentiment_analysis`},Go={WS:`${Rn}${j.v1}/cti/ws`},xe="call-control-sdk-state";var Qe=class{constructor(){ce(this,"state");ce(this,"listeners",[]);ce(this,"STORAGE_KEY",xe);ce(this,"apiKey");ce(this,"tenantId");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{authorization:void 0,process:null,agentId:"",openConferenceDialog:!1,openCallTransferDialog:!1,isInitialized:!1,sdkConfig:{disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,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=Y(p({},this.state),{agentId:e.agentId||"",authorization:e.authorization||void 0,process:e.process||null,openConferenceDialog:(e==null?void 0:e.openConferenceDialog)||!1,openCallTransferDialog:(e==null?void 0:e.openCallTransferDialog)||!1,isInitialized:e.isInitialized||!1,sdkConfig:e.sdkConfig||{disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,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={agentId:this.state.agentId,authorization:this.state.authorization,process:this.state.process,isInitialized:this.state.isInitialized,openConferenceDialog:this.state.openConferenceDialog,openCallTransferDialog:this.state.openCallTransferDialog,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())}validateCredentials(o,e){if(!o||typeof o!="string"||o.trim().length===0)throw new Error("API key not available");if(!e||typeof e!="string"||e.trim().length===0)throw new Error("Tenant ID not available");this.apiKey=o.trim(),this.tenantId=e.trim()}initialize(o,e,l,i,a){if(this.validateCredentials(o,e),!l||typeof l!="string"||l.trim().length===0)throw new Error("Agent ID not available");this.state.agentId=l,this.state.openConferenceDialog=!1,this.state.openCallTransferDialog=!1,this.state.authorization=a,this.state.sdkConfig=p({disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,disabled:{},enabled:{},outlined:{}},i),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return p({},this.state)}getCredentials(){return{apiKey:this.apiKey,tenantId:this.tenantId}}getSdkAuthToken(){var o;return(o=this.state.authorization)==null?void 0:o.accessToken}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()}setInitCheck(){this.state.isInitialized=!1,this.saveToStorage(),this.notifyListeners()}setOpenConferenceDialog(o){this.state.openConferenceDialog=o,this.saveToStorage(),this.notifyListeners()}setOpenCallTransferDialog(o){this.state.openCallTransferDialog=o,this.saveToStorage(),this.notifyListeners()}updateCallData(o){this.state.callData=p(p({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}updateConferenceData(o){this.state.conferenceLine=[...o],this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){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 e=(l=this.state.conferenceLine)==null?void 0:l.map(i=>i.line===o.line?o:i);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||[]}},y=new Qe;var et=class{constructor(){ce(this,"config",null);ce(this,"ticketId",null);ce(this,"baseUrl","");ce(this,"eventQueue",[]);ce(this,"flushTimer",null)}async init(o){this.config=p({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 y.setInitCheck(),new Error(`Failed to initialize: ${o.status} ${o.statusText}`);let e=await o.json();return this.ticketId=e.ticketId,this.config.autoTrack&&this.setupAutoTracking(),e}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 l={eventType:o,eventData:e,timestamp:Date.now()};this.eventQueue.push(l),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift()}async makeRequest(o,e){var a;let l=`${this.baseUrl}${o}`,i=((a=this.config)==null?void 0:a.retryAttempts)||3;for(let u=1;u<=i;u++)try{return await fetch(l,e)}catch(d){if(u===i)throw d;let C=Math.min(1e3*Math.pow(2,u-1),1e4);await new Promise(f=>setTimeout(f,C))}throw new Error("Max retries exceeded")}setupAutoTracking(){var l;if(typeof window=="undefined"||!((l=this.config)!=null&&l.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(i=>console.warn("Failed to track page visit:",i)),o.clicks!==!1&&document.addEventListener("click",i=>{var u;let a=i.target;(a.tagName==="BUTTON"||a.tagName==="A"||a.onclick||a.getAttribute("role")==="button"||a instanceof HTMLButtonElement&&a.type==="button")&&this.logEvent("click",{element:a.tagName,text:(u=a.textContent)==null?void 0:u.trim().substring(0,100),href:a.getAttribute("href"),id:a.id,className:a.className,role:a.getAttribute("role"),position:{x:i.clientX,y:i.clientY},timestamp:new Date().toISOString()}).catch(d=>console.warn("Failed to track click:",d))}),o.forms!==!1&&document.addEventListener("submit",i=>{let a=i.target,u=new FormData(a),d={};u.forEach((C,f)=>{d[f]=C.toString()}),this.logEvent("formSubmission",{formId:a.id,action:a.action,method:a.method,fields:Object.keys(d),fieldCount:Object.keys(d).length,timestamp:new Date().toISOString()}).catch(C=>console.warn("Failed to track form submission:",C))}),o.inputs!==!1){let i;document.addEventListener("input",a=>{let u=a.target;(u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.tagName==="SELECT")&&(clearTimeout(i),i=setTimeout(()=>{var d;this.logEvent("fieldChange",{element:u.tagName,type:u.getAttribute("type"),name:u.getAttribute("name"),id:u.id,valueLength:((d=u.value)==null?void 0:d.length)||0,timestamp:new Date().toISOString()}).catch(C=>console.warn("Failed to track field change:",C))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let i=Date.now()-e;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:i,timestamp:new Date().toISOString()})}),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",i=>{this.logEvent("jsError",{message:i.message,filename:i.filename,lineno:i.lineno,colno:i.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",i=>{var a;this.logEvent("unhandledRejection",{reason:(a=i.reason)==null?void 0:a.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let i=window.performance.navigation,a=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:a.navigationStart,loadTime:a.loadEventEnd-a.navigationStart,domReady:a.domContentLoadedEventEnd-a.navigationStart,renderTime:a.loadEventEnd-a.domContentLoadedEventEnd,navigationType:i.type,redirectCount:i.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(window.addEventListener("online",()=>{console.log("EventTracker: Back online, flushing queued events")}),window.addEventListener("offline",()=>{console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){this.flushTimer&&clearInterval(this.flushTimer)}},tt=new et;typeof window!="undefined"&&(window.EventTracker=tt);var Ce=require("react");var jo=In(require("axios"));var Yo,kn=(Yo=y.getSdkAuthToken())!=null?Yo:"",wn=6e4;function Nn(){var t;return(t=y.getSdkAuthToken())!=null?t:""}function An(){var o,e,l,i;let t=jo.default.create({baseURL:$,headers:{"Content-Type":"application/json",Accept:"application/json","x-tenant-id":(e=(o=y.getCredentials())==null?void 0:o.tenantId)!=null?e:"","x-api-key":(i=(l=y.getCredentials())==null?void 0:l.apiKey)!=null?i:"",Authorization:`${kn}`},timeout:wn,withCredentials:!1});return t.interceptors.request.use(a=>{let u=Nn();return u&&a.headers&&(a.headers.Authorization=`${u}`),a.metadata={startTime:new Date().getTime()},a},a=>(console.error("Request interceptor error:",a),Promise.reject(a))),t.interceptors.response.use(a=>{var C;let u=new Date().getTime(),d=(C=a.config.metadata)==null?void 0:C.startTime;return d&&console.log(`Request to ${a.config.url} took ${u-d}ms`),a},async a=>{var d;let u=a.config;return((d=a.response)==null?void 0:d.status)===401&&!u._retry&&(y.setInitCheck(),console.warn("Unauthorized request, attempting retry...")),a.response||(console.error("Network error:",a.message),a.message="Network error: Please check your internet connection"),a.response&&a.response.status>=500&&(console.error("Server error:",a.response.status,a.response.data),a.message="Server error: Please try again later"),Promise.reject(a)}),t}var On=An(),ne=On;var Xo=()=>{let[t,o]=(0,Ce.useState)(!1),[e,l]=(0,Ce.useState)(!1),[i,a]=(0,Ce.useState)(!1),[u,d]=(0,Ce.useState)(null),[C,f]=(0,Ce.useState)(null);return{logout:(0,Ce.useCallback)(async()=>{var E;let g=JSON.parse((E=localStorage.getItem(xe))!=null?E:"");o(!0);let b={action:"LOGOUTUSER",userId:g.agentId||""};return ne.post(R.LOGOUT,b).then(m=>(y.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(m==null?void 0:m.data),l(!0),m==null?void 0:m.data)).catch(m=>{var S;return a(!0),d(m),(S=m==null?void 0:m.response)==null?void 0:S.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:C}};var be=require("react");var Jo=()=>{let[t,o]=(0,be.useState)(!1),[e,l]=(0,be.useState)(!1),[i,a]=(0,be.useState)(!1),[u,d]=(0,be.useState)(null),[C,f]=(0,be.useState)(null);return{handleEndCall:(0,be.useCallback)(async g=>{var m,S,w,U,N,M,q,Z,K,A,v,I,Q,ae,ie;let b=JSON.parse((m=localStorage.getItem(xe))!=null?m:"");o(!0);let E={action:"ENDCALL",userId:b==null?void 0:b.agentId,processid:(U=(w=(S=b==null?void 0:b.process)==null?void 0:S.process_id)==null?void 0:w.toString())!=null?U:"",process_name:(M=(N=b==null?void 0:b.process)==null?void 0:N.process_name)!=null?M:"",callreferenceid:(Z=(q=b==null?void 0:b.callData)==null?void 0:q.convox_id)!=null?Z:"",mobile_number:(A=(K=b==null?void 0:b.callData)==null?void 0:K.phone_number)!=null?A:"",disposition:(v=g==null?void 0:g.disposition)!=null?v:"RES",set_followUp:(I=g==null?void 0:g.followUp)!=null?I:"N",callback_date:(Q=g==null?void 0:g.callbackDate)!=null?Q:"",callback_hrs:(ae=g==null?void 0:g.callbackHrs)!=null?ae:"",callback_mins:(ie=g==null?void 0:g.callbackMins)!=null?ie:"",endcall_type:"CLOSE"};return ne.post(R.END_CALL,E).then(T=>(y.endCall(),f(T==null?void 0:T.data),l(!0),T==null?void 0:T.data)).catch(T=>{var P;return a(!0),d(T),(P=T==null?void 0:T.response)==null?void 0:P.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:C}};var ye=require("react");var Vo=()=>{let[t,o]=(0,ye.useState)(!1),[e,l]=(0,ye.useState)(!1),[i,a]=(0,ye.useState)(!1),[u,d]=(0,ye.useState)(null),[C,f]=(0,ye.useState)(null);return{handleStartCall:(0,ye.useCallback)(async g=>{var E,m,S,w,U,N,M,q,Z;let b=JSON.parse((E=localStorage.getItem(xe))!=null?E:"");if(o(!0),((m=b==null?void 0:b.callData)==null?void 0:m.status)==="IDLE"){let K={action:"CALL",userId:b==null?void 0:b.agentId,phone_number:g==null?void 0:g.mobileNumber};return ne.post(R.CLICK_TO_CALL,K).then(A=>(f(A==null?void 0:A.data),l(!0),A==null?void 0:A.data)).catch(A=>{var v;return a(!0),d(A),(v=A==null?void 0:A.response)==null?void 0:v.data}).finally(()=>{o(!1)})}else if(((S=b==null?void 0:b.callData)==null?void 0:S.status)==="ONCALL"){let K=(U=(w=b==null?void 0:b.conferenceLine)==null?void 0:w.filter(v=>v.line!==1))==null?void 0:U.find(v=>v.status==="IDLE"&&!(v!=null&&v.isCallStart)),A={action:"EXTERNAL_CONFERENCE",operation:`CALL${K.line}`,line_used:String(K.line),thirdparty_no:g==null?void 0:g.mobileNumber,userid:(M=(N=b.callData)==null?void 0:N.agent_id)!=null?M:"",process:(Z=(q=b.callData)==null?void 0:q.process_name)!=null?Z:""};return ne.post(R.CONFERENCE_CALL,A).then(v=>(f(v==null?void 0:v.data),l(!0),y.setConferenceLine(Y(p({},K),{isCallStart:!0,status:"ONCALL",phone:g==null?void 0:g.mobileNumber})),y.setOpenConferenceDialog(!0),v==null?void 0:v.data)).catch(v=>{var I;return a(!0),d(v),(I=v==null?void 0:v.response)==null?void 0:I.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:C}};var Fe=require("react");var Zo=()=>{let{process_id:t,process_name:o,status:e,phone_number:l,agent_id:i,convox_id:a}=y.getState().callData,u={phone_number:l,status:e,callReferenceId:a,agent_id:i,process_id:t,process_name:o},[d,C]=(0,Fe.useState)(u);return(0,Fe.useEffect)(()=>y.subscribe(()=>{let{process_id:D,process_name:g,status:b,phone_number:E,agent_id:m,convox_id:S}=y.getState().callData;C({phone_number:E,status:b,callReferenceId:S,agent_id:m,process_id:D,process_name:g})}),[]),d};var We=require("react");var Qo=()=>{let[t,o]=(0,We.useState)(y.getSdkAuthToken());return(0,We.useEffect)(()=>y.subscribe(()=>{o(y.getSdkAuthToken())}),[]),t};var Je=require("react");var L=require("@mui/icons-material"),x=require("@mui/material"),z=require("react");var pe=require("react");function ot(t,o){let[e,l]=(0,pe.useState)(t),[i,a]=(0,pe.useState)(!1),u=(0,pe.useRef)(),d=(0,pe.useRef)({x:0,y:0}),C=(0,pe.useRef)({x:0,y:0}),f=(0,pe.useCallback)(E=>{let m=u.current;if(!m)return;let S=m.getBoundingClientRect(),w=window.innerWidth,U=window.innerHeight,N={x:Math.max(0,Math.min(E.x,w-S.width)),y:Math.max(0,Math.min(E.y,U-S.height))};l(N),o==null||o(N)},[o]),D=(0,pe.useCallback)((E,m)=>{a(!0),d.current={x:E,y:m},C.current=e;let S=(M,q)=>{let Z=M-d.current.x,K=q-d.current.y;f({x:C.current.x+Z,y:C.current.y+K})},w=M=>{M.preventDefault(),S(M.clientX,M.clientY)},U=M=>{M.preventDefault();let q=M.touches[0];q&&S(q.clientX,q.clientY)},N=()=>{a(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",N)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",N),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",N)},[e,f]),g=(0,pe.useCallback)(E=>{E.preventDefault(),D(E.clientX,E.clientY)},[D]),b=(0,pe.useCallback)(E=>{E.preventDefault();let m=E.touches[0];m&&D(m.clientX,m.clientY)},[D]);return{position:e,isDragging:i,dragRef:u,handleMouseDown:g,handleTouchStart:b}}var Ge=require("react");function Te(){let[t,o]=(0,Ge.useState)(y.getState());return(0,Ge.useEffect)(()=>y.subscribe(()=>{o(y.getState())}),[]),t}var je=require("react");var he=require("react"),Ye=require("@mui/material"),ke=require("react/jsx-runtime"),en=(0,he.createContext)(void 0),Ee=()=>{let t=(0,he.useContext)(en);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},tn=({children:t})=>{let[o,e]=(0,he.useState)(!1),[l,i]=(0,he.useState)(""),[a,u]=(0,he.useState)("info"),d=(C,f="info")=>{i(C),u(f),e(!0)};return(0,ke.jsxs)(en.Provider,{value:{showToast:d},children:[t,(0,ke.jsx)(Ye.Snackbar,{open:o,color:a,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,ke.jsx)(Ye.Alert,{variant:"filled",severity:a,onClose:()=>e(!1),sx:{width:"100%"},children:l})})]})};var Pn={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},Un=(t,o)=>{if(o.type==="isLoading")return Y(p({},t),{isLoading:o.payload});if(o.type==="isSuccess")return Y(p({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return Y(p({},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 de=(t={})=>{let{onSuccess:o=null,onError:e=null,disabledSuccessToast:l=!1}=t,{showToast:i}=Ee(),[a,u]=(0,je.useReducer)(Un,Pn);return[(0,je.useCallback)((C,f,D={})=>{u({type:"isLoading",payload:!0}),ne.post(C,f,D).then(g=>{var b;u({type:"isSuccess",payload:g.data}),o==null||o(g.data,f),l||i((b=g.data)==null?void 0:b.message,"success")}).catch(g=>{var E,m,S,w,U,N,M,q,Z,K,A,v;let b={status:(m=(E=g.response)==null?void 0:E.status)!=null?m:500,message:((w=(S=g.response)==null?void 0:S.data)==null?void 0:w.detail)||((N=(U=g.response)==null?void 0:U.data)==null?void 0:N.message)||g.message||"An unknown error occurred",data:(q=(M=g.response)==null?void 0:M.data)!=null?q:null,statusText:(K=(Z=g.response)==null?void 0:Z.statusText)!=null?K:"",code:(A=g==null?void 0:g.code)!=null?A:"",name:(v=g==null?void 0:g.name)!=null?v:""};i(b.message,"error"),u({type:"isError",payload:b}),e==null||e(b,f)}).finally(()=>{u({type:"isLoading",payload:!1})})},[o,e,i]),a]};var k=require("@mui/icons-material"),s=require("@mui/material"),le=require("react");var on=require("@mui/material");var Mn=({disabled:t,enabled:o,outlined:e})=>{let l=(0,on.useTheme)();return{disabled:p({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 ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},t),enabled:p({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${l.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},o),outlined:p({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:l.palette.grey[200],boxShadow:`0px 2px 1px ${l.palette.primary.light}`,border:`0px solid ${l.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${l.palette.primary.main}`,border:`0px solid ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},e)}},Xe=Mn;var n=require("react/jsx-runtime"),Bn=({each:t,isMergeCall:o})=>{var v,I,Q,ae,ie;let e=Te(),{showToast:l}=Ee(),{disabled:i,enabled:a,outlined:u}=Xe({disabled:((v=e.sdkConfig)==null?void 0:v.disabled)||{},enabled:((I=e.sdkConfig)==null?void 0:I.enabled)||{},outlined:((Q=e.sdkConfig)==null?void 0:Q.outlined)||{}}),d=(0,s.useTheme)(),[C,f]=(0,le.useState)(!1),[D,g]=(0,le.useState)(!1),[b,E]=(0,le.useState)(!1),[m,S]=(0,le.useState)(!1),[w,U]=(0,le.useState)(!1),N=(T,P)=>{y.setConferenceLine(p(p({},T),P))},M=(T,P)=>{var G,X,J,ee;let B=p(p({},T),P);f(!0);let W={action:"EXTERNAL_CONFERENCE",operation:`CALL${B.line}`,line_used:String(B.line),thirdparty_no:B.phone,userid:(X=(G=e.callData)==null?void 0:G.agent_id)!=null?X:"",process:(ee=(J=e.callData)==null?void 0:J.process_name)!=null?ee:""};ne.post(R.CONFERENCE_CALL,W).then(O=>{var _;l((_=O.data)==null?void 0:_.message,"success"),y.setConferenceLine(p(p({},T),P))}).catch(O=>{var F,V,te,oe;let _=((V=(F=O.response)==null?void 0:F.data)==null?void 0:V.detail)||((oe=(te=O.response)==null?void 0:te.data)==null?void 0:oe.message)||O.message||"An unknown error occurred";l(_,"error")}).finally(()=>{f(!1)})},q=(T,P)=>{var G,X,J,ee;let B=p(p({},T),P);g(!0);let W={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(B.line),thirdparty_no:B.phone,userid:(X=(G=e.callData)==null?void 0:G.agent_id)!=null?X:"",process:(ee=(J=e.callData)==null?void 0:J.process_name)!=null?ee:""};ne.post(R.CONFERENCE_CALL,W).then(O=>{var _;l((_=O.data)==null?void 0:_.message,"success"),y.setConferenceLine(p(p({},T),P))}).catch(O=>{var F,V,te,oe;let _=((V=(F=O.response)==null?void 0:F.data)==null?void 0:V.detail)||((oe=(te=O.response)==null?void 0:te.data)==null?void 0:oe.message)||O.message||"An unknown error occurred";l(_,"error")}).finally(()=>{g(!1)})},Z=(T,P,B)=>{var X,J,ee,O;let W=p(p({},T),P);E(!0);let G={action:"EXTERNAL_CONFERENCE",operation:B,hold_channel_no:B==="HOLDUSER"?`hold${W.line}`:`unhold${W.line}`,userid:(J=(X=e.callData)==null?void 0:X.agent_id)!=null?J:"",process:(O=(ee=e.callData)==null?void 0:ee.process_name)!=null?O:""};ne.post(R.CONFERENCE_CALL_HOLD_OR_UN_HOLD,G).then(_=>{var F;l((F=_.data)==null?void 0:F.message,"success"),y.setConferenceLine(p(p({},T),P))}).catch(_=>{var V,te,oe,ue;let F=((te=(V=_.response)==null?void 0:V.data)==null?void 0:te.detail)||((ue=(oe=_.response)==null?void 0:oe.data)==null?void 0:ue.message)||_.message||"An unknown error occurred";l(F,"error")}).finally(()=>{E(!1)})},K=(T,P,B)=>{var X,J,ee,O;let W=p(p({},T),P);S(!0);let G={action:"EXTERNAL_CONFERENCE",operation:B,channel_no:B==="MUTEUSER"?`mute${W.line}`:`play${W.line}`,userid:(J=(X=e.callData)==null?void 0:X.agent_id)!=null?J:"",thirdparty_no:W.phone,process:(O=(ee=e.callData)==null?void 0:ee.process_name)!=null?O:""};ne.post(R.CONFERENCE_CALL_MUTE_OT_UN_MUTE,G).then(_=>{var F;l((F=_.data)==null?void 0:F.message,"success"),y.setConferenceLine(p(p({},T),P))}).catch(_=>{var V,te,oe,ue;let F=((te=(V=_.response)==null?void 0:V.data)==null?void 0:te.detail)||((ue=(oe=_.response)==null?void 0:oe.data)==null?void 0:ue.message)||_.message||"An unknown error occurred";l(F,"error")}).finally(()=>{S(!1)})},A=(T,P)=>{var G,X,J,ee;let B=p(p({},T),P);U(!0);let W={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(B.line),user_type:`THIRDPARTY${B.line-1}`,thirdparty_no:B.phone,userid:(X=(G=e.callData)==null?void 0:G.agent_id)!=null?X:"",process:(ee=(J=e.callData)==null?void 0:J.process_name)!=null?ee:""};ne.post(R.CONFERENCE_CALL_END,W).then(O=>{var _;l((_=O.data)==null?void 0:_.message,"success"),y.setConferenceLine(p(p({},T),P))}).catch(O=>{var F,V,te,oe;let _=((V=(F=O.response)==null?void 0:F.data)==null?void 0:V.detail)||((oe=(te=O.response)==null?void 0:te.data)==null?void 0:oe.message)||O.message||"An unknown error occurred";l(_,"error")}).finally(()=>{U(!1)})};return(0,n.jsxs)(s.TableRow,{sx:{border:"2px solid #fff"},children:[(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:(0,n.jsxs)(s.Typography,{children:["Line ",(ae=t==null?void 0:t.line)!=null?ae:"",". "]})}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(s.Typography,{variant:"body2",sx:{px:1,borderRadius:"10px"},children:(ie=t==null?void 0:t.status)!=null?ie:""})}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(s.Button,{sx:{textTransform:"capitalize"},size:"small",children:(0,n.jsx)(s.Typography,{variant:"body2",children:(t==null?void 0:t.line)===1?"Internal":"External"})})}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(s.TextField,{size:"small",placeholder:"Phone Number",fullWidth:!0,value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="CONFERENCE"||(t==null?void 0:t.status)==="HOLD"||(t==null?void 0:t.status)==="MUTE",onChange:T=>{N(t,{phone:T.target.value})}})}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:(0,n.jsxs)(s.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[t.line!==1&&(0,n.jsx)(s.Tooltip,{title:"Call",children:(0,n.jsx)(s.Button,{variant:(t==null?void 0:t.status)!=="IDLE"?"outlined":"contained",color:"success",sx:(t==null?void 0:t.status)!=="IDLE"?p({},i):Y(p({},a),{border:`0px solid ${d.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${d.palette.success.light}`,border:`0px solid ${d.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${d.palette.primary.light}`}}),onClick:()=>{M(t,{})},disabled:(t==null?void 0:t.status)!=="IDLE",children:C?(0,n.jsx)(s.CircularProgress,{size:"20px",color:"success"}):(0,n.jsx)(k.Call,{sx:{color:(t==null?void 0:t.status)!=="IDLE"?"default":"#f3f2f2"}})})}),t.line===1&&(0,n.jsx)(s.Tooltip,{title:"Merge Call",children:(0,n.jsxs)(s.Button,{variant:o?"contained":"outlined",sx:o?Y(p({},a),{padding:"0px 16px"}):Y(p({},i),{padding:"0px 16px"}),onClick:()=>{q(t,{isMergeCall:!0})},disabled:!o||D,children:[t!=null&&t.isMergeCall?"Merged":"Merge",D?(0,n.jsx)(s.CircularProgress,{size:"20px"}):(0,n.jsx)(k.CallSplit,{})]})}),(0,n.jsx)(s.Tooltip,{title:t.status!=="HOLD"?"Hold":"Un Hold",children:(0,n.jsx)(s.Button,{variant:t.status==="HOLD"?"contained":"outlined",sx:t.status==="DISCONNECTED"||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},i):(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},u):p({},i),onClick:()=>{t.status==="HOLD"?Z(t,{isHold:!1},"UNHOLDUSER"):Z(t,{isHold:!0},"HOLDUSER")},disabled:(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="IDLE"||b,children:b?(0,n.jsx)(s.CircularProgress,{size:"20px",sx:{color:d.palette.primary.main}}):t.status==="HOLD"?(0,n.jsx)(k.PlayArrow,{}):(0,n.jsx)(k.Pause,{})})}),(0,n.jsx)(s.Tooltip,{title:t.status!=="MUTE"?"Mute":"Un Mute",children:(0,n.jsx)(s.Button,{variant:t.status==="MUTE"?"contained":"outlined",sx:t.status==="DISCONNECTED"||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},i):(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},u):p({},i),onClick:()=>{t.status==="MUTE"?K(t,{isMute:!1},"PLAYUSER"):K(t,{isMute:!0},"MUTEUSER")},disabled:(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="HOLD"||m,children:m?(0,n.jsx)(s.CircularProgress,{size:"20px",sx:{color:d.palette.primary.main}}):t.status==="MUTE"?(0,n.jsx)(k.MicOff,{}):(0,n.jsx)(k.Mic,{})})}),(t==null?void 0:t.line)!==1?(0,n.jsx)(s.Tooltip,{title:"End Call",children:(0,n.jsx)(s.Button,{variant:(t==null?void 0:t.status)!=="IDLE"&&(t==null?void 0:t.status)!=="DISCONNECTED"?"contained":"outlined",color:"error",sx:(t==null?void 0:t.status)!=="IDLE"&&(t==null?void 0:t.status)!=="DISCONNECTED"?Y(p({},a),{border:`0px solid ${d.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${d.palette.error.light}`,border:`0px solid ${d.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${d.palette.primary.light}`}}):p({},i),onClick:()=>{A(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="DISCONNECTED"||w,children:w?(0,n.jsx)(s.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(k.CallEnd,{})})}):(0,n.jsx)(s.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:{display:"none"},onClick:()=>{A(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="DISCONNECTED"||w,children:w?(0,n.jsx)(s.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(k.CallEnd,{})})]})})]},t.line)};function nn(){var d;let t=Te(),{showToast:o}=Ee(),[e,l]=(0,le.useState)(!1),i=()=>{y.setOpenConferenceDialog(!1)},a=()=>{var f,D,g,b;l(!0);let C={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(D=(f=t.callData)==null?void 0:f.agent_id)!=null?D:"",process:(b=(g=t.callData)==null?void 0:g.process_name)!=null?b:""};ne.post(R.CONFERENCE_CALL_END_ALL,C).then(E=>{var m;o((m=E.data)==null?void 0:m.message,"success"),y.resetConferenceLines(),i()}).catch(E=>{var S,w,U,N;let m=((w=(S=E.response)==null?void 0:S.data)==null?void 0:w.detail)||((N=(U=E.response)==null?void 0:U.data)==null?void 0:N.message)||E.message||"An unknown error occurred";o(m,"error")}).finally(()=>{l(!1)})},u=(0,le.useMemo)(()=>{var C;return(C=t==null?void 0:t.conferenceLine)==null?void 0:C.some(f=>f.line!==1?f.status==="ONCALL":!1)},[t.conferenceLine]);return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:t.openConferenceDialog,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 16px"},children:[(0,n.jsxs)(s.Typography,{variant:"body1",children:[(d=t==null?void 0:t.agentId)!=null?d:""," conference"]}),(0,n.jsx)(s.IconButton,{onClick:i,children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(s.Box,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:(0,n.jsx)(s.TableContainer,{component:s.Paper,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:(0,n.jsxs)(s.Table,{sx:{border:"4px solid #ffffff !important"},children:[(0,n.jsx)(s.TableHead,{children:(0,n.jsxs)(s.TableRow,{sx:{border:"2px solid #f3f3f3ff !important"},children:[(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:"Line"}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:"Status"}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:"Call Type"}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:"Mobile Number"}),(0,n.jsx)(s.TableCell,{sx:{padding:"6px"},children:"Call Actions"})]})}),(0,n.jsx)(s.TableBody,{children:t==null?void 0:t.conferenceLine.map(C=>(0,n.jsx)(Bn,{each:C,isMergeCall:u}))})]})})}),(0,n.jsx)(s.Box,{textAlign:"center",m:2,children:(0,n.jsxs)(s.Button,{variant:"outlined",color:"error",size:"large",onClick:a,disabled:e,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[e?(0,n.jsx)(s.CircularProgress,{size:"20px",color:"error",sx:{marginRight:"8px"}}):(0,n.jsx)(s.IconButton,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:(0,n.jsx)(k.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function sn({open:t}){var E,m,S,w,U,N,M,q,Z,K,A,v;let o=Te(),[e]=de({onSuccess:()=>{y.setOpenCallTransferDialog(!1)}}),[l,i]=(0,le.useState)("process"),[a,{data:u,isLoading:d}]=de({disabledSuccessToast:!0}),[C,{data:f,isLoading:D}]=de({disabledSuccessToast:!0}),g=()=>{y.setOpenCallTransferDialog(!1)},b=(I,Q)=>{var ae,ie,T,P,B,W,G,X,J,ee,O,_,F,V,te,oe,ue,we,Ne,Ae,Oe,Se,Pe,ve,Ue,De,Me,Be,He,Le,$e,ze,qe;if(Q==="PROCESS"){let me={mobile_number:(ie=(ae=o.callData)==null?void 0:ae.phone_number)!=null?ie:"",userid:(P=(T=o.callData)==null?void 0:T.agent_id)!=null?P:"",type:"PROCESS",transfer_to:(B=I==null?void 0:I.process_name)!=null?B:"",callreferenceid:(G=(W=o.callData)==null?void 0:W.convox_id)!=null?G:"",processid:String((J=(X=o.callData)==null?void 0:X.process_id)!=null?J:""),process_name:(O=(ee=o.callData)==null?void 0:ee.process_name)!=null?O:""};e(R.TRANSFER_CALL,me)}else if(Q==="QUEUE"){let me={mobile_number:(F=(_=o.callData)==null?void 0:_.phone_number)!=null?F:"",userid:(te=(V=o.callData)==null?void 0:V.agent_id)!=null?te:"",type:"QUEUE",transfer_to:(oe=I==null?void 0:I.queue_name)!=null?oe:"",callreferenceid:(we=(ue=o.callData)==null?void 0:ue.convox_id)!=null?we:"",processid:String((Ae=(Ne=o.callData)==null?void 0:Ne.process_id)!=null?Ae:""),process_name:(Se=(Oe=o.callData)==null?void 0:Oe.process_name)!=null?Se:""};e(R.TRANSFER_CALL,me)}else if(Q==="AGENT"){let me={mobile_number:(ve=(Pe=o.callData)==null?void 0:Pe.phone_number)!=null?ve:"",userid:(De=(Ue=o.callData)==null?void 0:Ue.agent_id)!=null?De:"",type:"AGENT",transfer_to:(Me=I==null?void 0:I.user_id)!=null?Me:"",callreferenceid:(He=(Be=o.callData)==null?void 0:Be.convox_id)!=null?He:"",processid:String(($e=(Le=o.callData)==null?void 0:Le.process_id)!=null?$e:""),process_name:(qe=(ze=o.callData)==null?void 0:ze.process_name)!=null?qe:""};e(R.TRANSFER_CALL,me)}};return(0,le.useEffect)(()=>{a(R.AGENTS_LIST,{status:"IDLE",active:!0}),C(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(s.Typography,{variant:"body1",children:" Call Transfer"}),(0,n.jsx)(s.IconButton,{onClick:g,children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsxs)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[(0,n.jsxs)(s.Box,{sx:{display:"flex",gap:1},children:[(0,n.jsx)(s.Button,{variant:l==="process"?"contained":"outlined",onClick:()=>{i("process"),C(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Process"}),(0,n.jsx)(s.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>{i("queues"),C(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Queues"}),(0,n.jsx)(s.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>{i("agents"),a(R.AGENTS_LIST,{status:"IDLE",active:!0})},children:"Agents"})]}),(D||d)&&(0,n.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"80px"},children:[(0,n.jsx)(s.CircularProgress,{})," "]}),!D&&!d&&l==="process"&&(0,n.jsx)(s.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(E=f==null?void 0:f.data)!=null&&E.process&&((S=(m=f==null?void 0:f.data)==null?void 0:m.process)==null?void 0:S.length)>0?(U=(w=f==null?void 0:f.data)==null?void 0:w.process)==null?void 0:U.map((I,Q)=>(0,n.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,n.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),I.process_name]}),(0,n.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{b(I,"PROCESS")},children:(0,n.jsx)(k.Call,{})})]},Q)):(0,n.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"16px",letterSpacing:"0.02em",textTransform:"capitalize",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",margin:"10px 0px",color:"gray",height:"60px"},children:"No Process Found"})}),!D&&!d&&l==="queues"&&(0,n.jsx)(s.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(N=f==null?void 0:f.data)!=null&&N.queue&&((q=(M=f==null?void 0:f.data)==null?void 0:M.queue)==null?void 0:q.length)>0?(K=(Z=f==null?void 0:f.data)==null?void 0:Z.queue)==null?void 0:K.map((I,Q)=>{var ae,ie,T,P,B,W;return(0,n.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,n.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),I.queue_name,(T=(ie=(ae=f==null?void 0:f.data)==null?void 0:ae.process)==null?void 0:ie.find(G=>G.process_id===I.process_id))!=null&&T.process_name?(0,n.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((W=(B=(P=f==null?void 0:f.data)==null?void 0:P.process)==null?void 0:B.find(G=>G.process_id===I.process_id))==null?void 0:W.process_name)+")"}):""]}),(0,n.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{b(I,"QUEUE")},children:(0,n.jsx)(k.Call,{})})]},Q)}):(0,n.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"16px",letterSpacing:"0.02em",textTransform:"capitalize",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",margin:"10px 0px",color:"gray",height:"60px"},children:"No Queues Found"})}),!D&&!d&&l==="agents"&&(0,n.jsx)(s.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:u!=null&&u.data&&((A=u==null?void 0:u.data)==null?void 0:A.length)>0?(v=u==null?void 0:u.data)==null?void 0:v.map((I,Q)=>(0,n.jsxs)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,n.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),I.name]}),(0,n.jsx)(s.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{b(I,"AGENT")},children:(0,n.jsx)(k.Call,{})})]},Q)):(0,n.jsx)(s.Typography,{variant:"body1",sx:{fontSize:"16px",letterSpacing:"0.02em",textTransform:"capitalize",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",margin:"10px 0px",color:"gray",height:"60px"},children:"No Agents Found"})})]})]})})})}function an({open:t,setOpen:o,onSubmitDisposition:e}){var D,g,b,E;let[l,i]=(0,le.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),a=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],u=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],d=(m,S)=>{i(w=>Y(p({},w),{[m]:S}))},C=()=>{i({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{C(),o(!1)};return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:(0,n.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,n.jsx)(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:(0,n.jsxs)(s.Typography,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),(0,n.jsxs)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:[(0,n.jsxs)(s.Box,{display:"flex",gap:2,children:[(0,n.jsx)(s.Autocomplete,{value:l.disposition,options:a,getOptionLabel:m=>m.label,onChange:(m,S)=>d("disposition",S),size:"small",renderInput:m=>(0,n.jsx)(s.TextField,Y(p({},m),{label:"Disposition",fullWidth:!0})),sx:{flex:1}}),(0,n.jsx)(s.Autocomplete,{options:u,getOptionLabel:m=>m.label,value:l.followUp,onChange:(m,S)=>d("followUp",S),size:"small",renderInput:m=>(0,n.jsx)(s.TextField,Y(p({},m),{label:"Follow Up",fullWidth:!0})),sx:{flex:1}})]}),((g=(D=l==null?void 0:l.followUp)==null?void 0:D.label)==null?void 0:g.toLowerCase())==="yes"&&(0,n.jsxs)(s.Box,{display:"flex",gap:2,mt:2,children:[(0,n.jsx)(s.TextField,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:l.callbackDate,onChange:m=>d("callbackDate",m.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(s.TextField,{size:"small",label:"Hours (0-23)",type:"text",value:l.callbackHrs,onChange:m=>d("callbackHrs",m.target.value),fullWidth:!0,sx:{flex:1}})]}),((E=(b=l==null?void 0:l.followUp)==null?void 0:b.label)==null?void 0:E.toLowerCase())==="yes"&&(0,n.jsxs)(s.Box,{display:"flex",gap:2,mt:2,children:[(0,n.jsx)(s.TextField,{size:"small",label:"Minutes (0-59)",type:"text",value:l.callbackMins,onChange:m=>d("callbackMins",m.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(s.Box,{sx:{flex:1}})]})]}),(0,n.jsxs)(s.Box,{textAlign:"right",m:2,children:[(0,n.jsx)(s.Button,{variant:"outlined",color:"error",size:"large",onClick:f,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,n.jsx)(s.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>e(l),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function rn({open:t,setOpen:o,processList:e=null,handleSelectedProcessor:l}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:(0,n.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(s.Typography,{variant:"body1",children:" Process List"}),(0,n.jsx)(s.IconButton,{onClick:()=>{o(!1)},children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:e.length>0?e==null?void 0:e.map((a,u)=>(0,n.jsx)(s.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{l(a)},children:(0,n.jsxs)(s.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),a.process_name]})},u)):null})]})})})}function ln({open:t,setOpen:o}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(s.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(s.Typography,{variant:"body1",children:" Call History"}),(0,n.jsx)(s.IconButton,{onClick:()=>{o(!1)},children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(s.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}var c=require("react/jsx-runtime"),Hn=(t,o,e)=>t.map(i=>{var a,u,d;if((i==null?void 0:i.line)===1){let C=`line_${i.line}_status`;return Y(p({},i),{line:1,status:(a=o[C])!=null?a:e==null?void 0:e.status,phone:(u=e==null?void 0:e.phone_number)!=null?u:""})}else{let C=`line_${i.line}_status`,f=`line_${i.line}_phonenumber`;return Y(p({},i),{status:(d=o[C])!=null?d:"IDLE",phone:o[f]!=="0"?o[f]:""})}}),$n=t=>{let o=Math.floor(t/60),e=t%60;return`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`};function cn({onDataChange:t}){var it,rt,lt,ct,pt,dt,ut,gt,ft,mt,xt,Ct,bt,yt,ht,Et,Tt,St,vt,Dt,Lt,It,_t,Rt,kt,wt,Nt,At,Ot,Pt,Ut,Mt,Bt,Ht,$t,zt,qt,Kt,Ft,Wt,Gt,Yt,jt,Xt,Jt,Vt,Zt,Qt,eo,to,oo,no,so,ao,io,ro,lo,co,po,uo,go,fo,mo,xo,Co,bo,yo,ho,Eo,To,So,vo,Do,Lo,Io,_o,Ro,ko,wo,No,Ao;let o=(0,x.useTheme)(),e=Te(),{showToast:l}=Ee(),{disabled:i,enabled:a,outlined:u}=Xe({disabled:((it=e.sdkConfig)==null?void 0:it.disabled)||{},enabled:((rt=e.sdkConfig)==null?void 0:rt.enabled)||{},outlined:((lt=e.sdkConfig)==null?void 0:lt.outlined)||{}}),d=(0,z.useRef)(null),C=(0,z.useRef)(null),f=(0,z.useRef)(null),D=(0,z.useRef)(null),g=(0,z.useRef)(0),b=60,E=1e3,m=3e4,[S,w]=(0,z.useState)(null),[U,N]=(0,z.useState)(!0),[M,q]=(0,z.useState)(null),[Z,K]=(0,z.useState)(null),[A,v]=(0,z.useState)(!1),[I,Q]=(0,z.useState)(!1),[ae,ie]=(0,z.useState)(!1),[T,P]=(0,z.useState)(null),[B,W]=(0,z.useState)(""),[G,X]=(0,z.useState)(0),{position:J,isDragging:ee,dragRef:O,handleMouseDown:_,handleTouchStart:F}=ot(e.controlPanelPosition,r=>y.setControlPanelPosition(r)),{position:V,isDragging:te,dragRef:oe,handleMouseDown:ue,handleTouchStart:we}=ot(e.iframePosition,r=>y.setIframePosition(r)),[Ne,{isLoading:Ae}]=de({onSuccess:()=>{W(""),K(null)}}),[Oe,{isLoading:Se}]=de({onSuccess:()=>{y.setHolding(!e.isHolding)},onError:r=>{console.log("\u274C Hold operation error:",r)}}),[Pe,{isLoading:ve}]=de({onSuccess:()=>{y.setMuted(!e.isMuted)},onError:r=>{console.log("\u274C Mute operation error:",r)}}),[Ue,{isLoading:De}]=de(),[Me,{isLoading:Be}]=de(),[He,{isLoading:Le}]=de(),$e=()=>{w(null)},ze=r=>{N(!0),K(r.currentTarget),y.setStatus("dial")},qe=()=>{e.status!=="on call"&&y.setStatus("idle"),K(null)},me=r=>{q(r.currentTarget)},un=()=>{q(null)},gn=()=>{let r={action:"READYAGENT",userId:e.agentId};Ue(R.READY_AGENT,r)},fn=r=>{q(null);let h={action:"AGENTBREAK",break_type:r,userId:e.agentId};Me(R.UPDATE_AGENT_BREAK,h)},mn=r=>{if(r.length!==10)l("Invalid phone number","error");else if(!/^\d+$/.test(r))l("Invalid phone number","error");else{let h={action:"CALL",phone_number:r,userId:e.agentId};Ne(R.CLICK_TO_CALL,h)}},xn=()=>{let r={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};Oe(R.HOLD_CALL,r)},Cn=()=>{let r={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};Pe(R.MUTE_CALL,r)},bn=r=>{var H,se,re,ge,fe,Ie,_e,Oo,Po,Uo,Mo,Bo,Ho,$o,zo,qo;let h={action:"ENDCALL",userId:e.agentId,processid:(re=(se=(H=e.process)==null?void 0:H.process_id)==null?void 0:se.toString())!=null?re:"",process_name:(fe=(ge=e.process)==null?void 0:ge.process_name)!=null?fe:"",callreferenceid:(_e=(Ie=e.callData)==null?void 0:Ie.convox_id)!=null?_e:"",mobile_number:(Po=(Oo=e.callData)==null?void 0:Oo.phone_number)!=null?Po:"",disposition:(Mo=(Uo=r==null?void 0:r.disposition)==null?void 0:Uo.value)!=null?Mo:"",set_followUp:(Ho=(Bo=r==null?void 0:r.followUp)==null?void 0:Bo.value)!=null?Ho:"",callback_date:($o=r==null?void 0:r.callbackDate)!=null?$o:"",callback_hrs:(zo=r==null?void 0:r.callbackHrs)!=null?zo:"",callback_mins:(qo=r==null?void 0:r.callbackMins)!=null?qo:"",endcall_type:"CLOSE"};W(""),He(R.END_CALL,h),y.endCall(),v(!1)};(0,z.useEffect)(()=>{let r=h=>{h.preventDefault()};return window.addEventListener("beforeunload",r),()=>{window.removeEventListener("beforeunload",r)}},[]),(0,z.useEffect)(()=>{let r;return e.callData.status&&e.callData.status==="ONCALL"?r=setInterval(()=>{let h=Math.floor((Date.now()-e.callStartTime)/1e3);X(h)},1e3):X(0),()=>{r&&clearInterval(r)}},[e.callData.status]),(0,z.useEffect)(()=>(C.current=new Audio("../ringtones/incoming.mp3"),C.current.loop=!0,C.current.volume=.7,()=>{C.current&&(C.current.pause(),C.current.currentTime=0,C.current=null)}),[]),(0,z.useEffect)(()=>{if(t&&e.callData){let{process_id:r,process_name:h,status:H,phone_number:se,agent_id:re,convox_id:ge}=e.callData;t({phone_number:se,status:H,callReferenceId:ge,agent_id:re,process_id:r,process_name:h})}},[e.callData,t]),(0,z.useEffect)(()=>{e.agentId?ne.post(R.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}).then(r=>{var h,H;r&&r.data&&((h=r==null?void 0:r.data)==null?void 0:h.length)>1?(P(r.data.data),Q(!0)):(y.setProcess((H=r==null?void 0:r.data)==null?void 0:H.data[0]),Q(!1))}).catch(r=>{l(r.response.data.message,"error")}):console.log("No agentId available, skipping API call")},[e.agentId]);let Ve=()=>{if(!e.agentId){console.log("No agentId available, cannot connect WebSocket");return}f.current&&(clearTimeout(f.current),f.current=null);try{d.current=new WebSocket(`${Go.WS}?agent_id=${e.agentId}`),d.current.onopen=()=>{console.log("\u{1F310} WebSocket connection established"),g.current=0,D.current&&clearInterval(D.current),D.current=setInterval(()=>{if(d.current&&d.current.readyState===WebSocket.OPEN)try{d.current.send(JSON.stringify({type:"ping"})),console.log("\u{1F4E1} WebSocket ping sent")}catch(r){console.error("Failed to send ping:",r)}},3e4)},d.current.onmessage=r=>{try{let h=JSON.parse(r.data);if(h.type==="pong"){console.log("\u{1F4E1} WebSocket pong received");return}let H=Hn(e==null?void 0:e.conferenceLine,h==null?void 0:h.conferencestatus,h);y.updateCallData(h),y.updateConferenceData([...H]),(h.status==="RINGING"||h.status==="DIALING")&&C.current&&C.current.play().catch(se=>{console.error("Failed to play ringtone:",se)}),h.status==="ONCALL"&&(C.current&&(C.current.pause(),C.current.currentTime=0),y.startCall(),U||N(!0)),h.status==="WRAPUP"&&(C.current&&(C.current.pause(),C.current.currentTime=0),y.endCall())}catch(h){console.log("\u{1F4E8} Raw message:",r.data)}},d.current.onclose=r=>{if(console.log("\u{1F50C} WebSocket connection closed",r.code,r.reason),D.current&&(clearInterval(D.current),D.current=null),r.code!==1e3&&g.current<b){g.current+=1;let h=Math.min(E*Math.pow(2,g.current-1),m);console.log(`\u{1F504} Attempting to reconnect WebSocket (attempt ${g.current}/${b}) in ${h}ms`),f.current=setTimeout(()=>{Ve()},h)}else g.current>=b&&(console.error("\u274C Maximum reconnection attempts reached. Please refresh the page."),l("WebSocket connection failed. Please refresh the page.","error"))},d.current.onerror=r=>{console.error("\u274C WebSocket error:",r)}}catch(r){if(console.error("\u274C Failed to create WebSocket:",r),g.current<b){g.current+=1;let h=Math.min(E*Math.pow(2,g.current-1),m);f.current=setTimeout(()=>{Ve()},h)}}};return(0,z.useEffect)(()=>(e.agentId&&Ve(),()=>{f.current&&(clearTimeout(f.current),f.current=null),D.current&&(clearInterval(D.current),D.current=null),d.current&&(d.current.close(1e3,"Component unmounting"),d.current=null),g.current=0}),[e.agentId]),!e.isInitialized||!e.process?(0,c.jsx)(x.Box,{children:!!I&&(0,c.jsx)(rn,{processList:T,open:I,setOpen:Q,handleSelectedProcessor:r=>{y.setProcess(r)}})}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(x.Box,{children:(0,c.jsx)(x.Fade,{in:!0,timeout:300,children:(0,c.jsx)(x.Paper,{ref:(ct=e.sdkConfig)!=null&&ct.isDraggable?O:null,elevation:ee?4:(pt=e.sdkConfig)!=null&&pt.isDraggable?1:0,sx:{position:(dt=e.sdkConfig)!=null&&dt.isDraggable?"fixed":"relative",left:(ut=e.sdkConfig)!=null&&ut.isDraggable?J.x:"auto",top:(gt=e.sdkConfig)!=null&>.isDraggable?J.y:"auto",display:"inline-block",width:"auto",flexShrink:0,whiteSpace:"nowrap",p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:(ft=e.sdkConfig)!=null&&ft.isDraggable?Number.MAX_SAFE_INTEGER:0,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:(0,c.jsxs)(x.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,c.jsxs)(x.Box,{sx:{display:"flex",alignItems:"center",gap:1,margin:"0px 10px"},children:[((mt=e.sdkConfig)==null?void 0:mt.isDraggable)&&(0,c.jsxs)(x.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:_,onTouchStart:F,children:[(0,c.jsx)(L.DragIndicator,{})," "]}),(0,c.jsx)(x.Box,{children:!((xt=e.sdkConfig)!=null&&xt.disabledDialButton)&&(0,c.jsx)(x.Tooltip,{title:"Dial",children:(0,c.jsx)(x.IconButton,{size:"small",onClick:r=>{var h,H,se,re,ge,fe,Ie,_e;((H=(h=e.callData)==null?void 0:h.status)==null?void 0:H.toUpperCase())!=="ONCALL"&&((re=(se=e.callData)==null?void 0:se.status)==null?void 0:re.toUpperCase())!=="BREAK"&&((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())!=="RINGING"&&((_e=(Ie=e.callData)==null?void 0:Ie.status)==null?void 0:_e.toUpperCase())!=="WRAPUP"&&ze(r)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,c.jsx)(L.WifiCalling3,{sx:{color:((bt=(Ct=e.callData)==null?void 0:Ct.status)==null?void 0:bt.toUpperCase())==="ONCALL"||((ht=(yt=e.callData)==null?void 0:yt.status)==null?void 0:ht.toUpperCase())==="BREAK"||((Tt=(Et=e.callData)==null?void 0:Et.status)==null?void 0:Tt.toUpperCase())==="RINGING"||((vt=(St=e.callData)==null?void 0:St.status)==null?void 0:vt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,c.jsx)(x.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px",fontSize:"18px",fontWeight:"600"},children:$n(G)}),(0,c.jsx)(x.Chip,{sx:{padding:"18px 0px"},label:Be||De?(0,c.jsx)(x.Box,{sx:{fontWeight:"bold",width:"60px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,c.jsx)(x.CircularProgress,{size:"20px"})}):(0,c.jsx)(x.Typography,{variant:"body2",sx:{fontWeight:"bold",width:"60px",textAlign:"center"},children:(It=(Lt=(Dt=e.callData)==null?void 0:Dt.status)==null?void 0:Lt.toUpperCase())!=null?It:"N/A"}),onClick:me,deleteIcon:(0,c.jsx)(L.KeyboardArrowDown,{color:"primary"}),onDelete:me})]}),(0,c.jsxs)(x.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,c.jsx)(x.Tooltip,{title:"Agent Ready",children:(0,c.jsx)(x.Button,{variant:((Rt=(_t=e.callData)==null?void 0:_t.status)==null?void 0:Rt.toUpperCase())==="BREAK"||((wt=(kt=e.callData)==null?void 0:kt.status)==null?void 0:wt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:r=>{var h,H,se,re;(((H=(h=e.callData)==null?void 0:h.status)==null?void 0:H.toUpperCase())==="BREAK"||((re=(se=e.callData)==null?void 0:se.status)==null?void 0:re.toUpperCase())==="MISSED")&&(r.stopPropagation(),gn())},classes:{root:((At=(Nt=e.callData)==null?void 0:Nt.status)==null?void 0:At.toUpperCase())==="BREAK"||((Pt=(Ot=e.callData)==null?void 0:Ot.status)==null?void 0:Pt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:p({},((Mt=(Ut=e.callData)==null?void 0:Ut.status)==null?void 0:Mt.toUpperCase())==="BREAK"||((Ht=(Bt=e.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="MISSED"?u:a),disabled:De,children:(0,c.jsx)(L.SupportAgent,{})})}),(0,c.jsx)(x.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,c.jsx)(x.Button,{variant:e.isHolding&&((zt=($t=e.callData)==null?void 0:$t.status)==null?void 0:zt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:r=>{r.stopPropagation(),xn()},sx:e.isHolding&&((Kt=(qt=e.callData)==null?void 0:qt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?p({},a):((Wt=(Ft=e.callData)==null?void 0:Ft.status)==null?void 0:Wt.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((Yt=(Gt=e.callData)==null?void 0:Gt.status)==null?void 0:Yt.toUpperCase())!=="ONCALL"&&!e.isHolding||Se,children:Se?(0,c.jsx)(x.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?(0,c.jsx)(L.PlayArrow,{}):(0,c.jsx)(L.Pause,{})})}),(0,c.jsx)(x.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,c.jsx)(x.Button,{variant:e.isMuted&&((Xt=(jt=e.callData)==null?void 0:jt.status)==null?void 0:Xt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:r=>{r.stopPropagation(),Cn()},sx:e.isMuted&&((Vt=(Jt=e.callData)==null?void 0:Jt.status)==null?void 0:Vt.toUpperCase())==="ONCALL"?p({},a):((Qt=(Zt=e.callData)==null?void 0:Zt.status)==null?void 0:Qt.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((to=(eo=e.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())!=="ONCALL"&&!e.isMuted||ve,children:ve?(0,c.jsx)(x.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?(0,c.jsx)(L.MicOff,{}):(0,c.jsx)(L.Mic,{})})}),!((oo=e.sdkConfig)!=null&&oo.disableCallTransferButton)&&(0,c.jsx)(x.Tooltip,{title:"Transfer Call",children:(0,c.jsx)(x.Button,{variant:e.openCallTransferDialog?"contained":"outlined",onClick:r=>{var h,H;((H=(h=e.callData)==null?void 0:h.status)==null?void 0:H.toUpperCase())==="ONCALL"&&(r.stopPropagation(),y.setOpenCallTransferDialog(!0))},sx:e.openCallTransferDialog?p({},a):((so=(no=e.callData)==null?void 0:no.status)==null?void 0:so.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((io=(ao=e.callData)==null?void 0:ao.status)==null?void 0:io.toUpperCase())!=="ONCALL",children:(0,c.jsx)(L.TransferWithinAStation,{})})}),!((ro=e.sdkConfig)!=null&&ro.disableConferenceButton)&&(0,c.jsx)(x.Tooltip,{title:"Conference Call",children:(0,c.jsx)(x.Button,{variant:e.openConferenceDialog?"contained":"outlined",onClick:r=>{var h,H;((H=(h=e.callData)==null?void 0:h.status)==null?void 0:H.toUpperCase())==="ONCALL"&&(r.stopPropagation(),y.setOpenConferenceDialog(!0))},sx:e.openConferenceDialog?p({},a):((co=(lo=e.callData)==null?void 0:lo.status)==null?void 0:co.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((uo=(po=e.callData)==null?void 0:po.status)==null?void 0:uo.toUpperCase())!=="ONCALL",children:(0,c.jsx)(L.Group,{})})}),!((go=e.sdkConfig)!=null&&go.disableEndCallButton)&&(0,c.jsx)(x.Tooltip,{title:"End Call",children:(0,c.jsx)(x.Button,{variant:((mo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())==="ONCALL"||((Co=(xo=e.callData)==null?void 0:xo.status)==null?void 0:Co.toUpperCase())==="RINGING"||((yo=(bo=e.callData)==null?void 0:bo.status)==null?void 0:yo.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:r=>{var h,H,se,re,ge,fe;(((H=(h=e.callData)==null?void 0:h.status)==null?void 0:H.toUpperCase())==="ONCALL"||((re=(se=e.callData)==null?void 0:se.status)==null?void 0:re.toUpperCase())==="RINGING"||((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())==="WRAPUP")&&(r.stopPropagation(),v(!0))},sx:((Eo=(ho=e.callData)==null?void 0:ho.status)==null?void 0:Eo.toUpperCase())==="ONCALL"||((So=(To=e.callData)==null?void 0:To.status)==null?void 0:So.toUpperCase())==="RINGING"||((Do=(vo=e.callData)==null?void 0:vo.status)==null?void 0:Do.toUpperCase())==="WRAPUP"?Y(p({},a),{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}`}}):Y(p({},i),{minWidth:"60px !important"}),disabled:((Io=(Lo=e.callData)==null?void 0:Lo.status)==null?void 0:Io.toUpperCase())!=="ONCALL"&&((Ro=(_o=e.callData)==null?void 0:_o.status)==null?void 0:Ro.toUpperCase())!=="RINGING"&&((wo=(ko=e.callData)==null?void 0:ko.status)==null?void 0:wo.toUpperCase())!=="WRAPUP"||Le,children:Le?(0,c.jsx)(x.CircularProgress,{size:"20px",color:"error"}):(0,c.jsx)(L.CallEnd,{})})})]})]})})})}),(0,c.jsx)(x.Fade,{in:!0,timeout:300,children:(0,c.jsxs)(x.Paper,{ref:oe,elevation:te?4:1,sx:{position:"absolute",left:V.x,top:V.y,borderRadius:2,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:U&&!((No=e.sdkConfig)!=null&&No.disableSoftPhone)?"visible":"hidden",userSelect:"none"},children:[(0,c.jsxs)(x.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll",padding:"0px 10px"},onMouseDown:ue,onTouchStart:we,children:[(0,c.jsx)(L.DragIndicator,{sx:{transform:"rotate(90deg)",color:"#7b7b7b"}})," ",(0,c.jsx)(x.IconButton,{onClick:()=>N(!1),children:(0,c.jsx)(L.Close,{})})]}),(0,c.jsx)(x.Box,{children:(0,c.jsx)("iframe",{src:`https://${Ke}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(Ao=e.process)==null?void 0:Ao.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})})]})}),(0,c.jsx)(x.Menu,{anchorEl:Z,open:!!Z,onClose:qe,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,c.jsxs)(x.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,c.jsx)(x.TextField,{size:"small",value:B,placeholder:"Enter Mobile No.",onChange:r=>{W(r.target.value)}}),(0,c.jsx)(x.IconButton,{color:"info",onClick:()=>{mn(B)},children:Ae?(0,c.jsx)(x.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,c.jsx)(L.Phone,{color:"success"})})]})}),(0,c.jsx)(x.Menu,{anchorEl:M,open:!!M,onClose:un,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,c.jsx)(x.MenuItem,{onClick:()=>fn("Lunch"),children:"- Break"})}),(0,c.jsx)(x.Menu,{anchorEl:S,open:!!S,onClose:$e,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,c.jsxs)(x.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,c.jsx)(x.Chip,{icon:(0,c.jsx)(L.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,c.jsx)(x.Chip,{icon:(0,c.jsx)(L.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,c.jsx)(x.Chip,{icon:(0,c.jsx)(L.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!e.openConferenceDialog&&(0,c.jsx)(nn,{}),!!e.openCallTransferDialog&&(0,c.jsx)(sn,{open:e.openCallTransferDialog}),!!A&&(0,c.jsx)(an,{open:A,setOpen:v,onSubmitDisposition:bn}),!!ae&&(0,c.jsx)(ln,{open:ae,setOpen:ie})]})}var pn=require("react");var dn=require("react/jsx-runtime"),nt=(0,pn.memo)(({children:t})=>(0,dn.jsx)(tn,{children:t}));nt.displayName="SDKProvider";var st=require("react/jsx-runtime"),at=(0,Je.memo)(({onDataChange:t})=>{let o=(0,Je.useCallback)(e=>{try{t&&typeof t=="function"&&t(e)}catch(l){console.error("Error in CallControlPanel data change handler:",l)}},[t]);return(0,st.jsx)(nt,{children:(0,st.jsx)(cn,{onDataChange:o})})});at.displayName="CallControlPanel";async function zn({apiKey:t,tenantId:o,agentId:e,sdkConfig:l}){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("SDK initialization failed: API key is required and must be a non-empty string");if(!o||typeof o!="string"||o.trim().length===0)throw new Error("SDK initialization failed: Tenant ID is required and must be a non-empty string");if(!e||typeof e!="string"||e.trim().length===0)throw new Error("SDK initialization failed: Agent ID is required and must be a non-empty string");try{let i=await tt.init({apiKey:t.trim(),tenantId:o.trim(),agentId:e.trim(),baseUrl:$});if(i)console.log("SDK initialized successfully"),y.initialize(t.trim(),o.trim(),e.trim(),l,i);else throw console.error("SDK initialization failed: Event tracker initialization returned false"),y.setInitCheck(),new Error("SDK initialization failed: Unable to establish connection with the CTI system")}catch(i){throw console.error("SDK initialization error:",i),y.setInitCheck(),i instanceof Error?i:new Error(`SDK initialization failed: ${String(i)}`)}}function qn(){return"6.x.x"}function Kn(){return y.getState().isInitialized}0&&(module.exports={CallControlPanel,getSDKVersion,initSDK,isSDKInitialized,useClickToCall,useEndCall,useGetAuthorizationToken,useGetCallerData,useLogout});
|
|
1
|
+
"use strict";var bn=Object.create;var Pe=Object.defineProperty,hn=Object.defineProperties,Dn=Object.getOwnPropertyDescriptor,En=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertyNames,Xo=Object.getOwnPropertySymbols,Tn=Object.getPrototypeOf,jo=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable;var ze=(t,o,e)=>o in t?Pe(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,p=(t,o)=>{for(var e in o||(o={}))jo.call(o,e)&&ze(t,e,o[e]);if(Xo)for(var e of Xo(o))Ln.call(o,e)&&ze(t,e,o[e]);return t},J=(t,o)=>hn(t,En(o));var yn=(t,o)=>{for(var e in o)Pe(t,e,{get:o[e],enumerable:!0})},Ko=(t,o,e,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Sn(o))!jo.call(t,i)&&i!==e&&Pe(t,i,{get:()=>o[i],enumerable:!(l=Dn(o,i))||l.enumerable});return t};var An=(t,o,e)=>(e=t!=null?bn(Tn(t)):{},Ko(o||!t||!t.__esModule?Pe(e,"default",{value:t,enumerable:!0}):e,t)),Pn=t=>Ko(Pe({},"__esModule",{value:!0}),t);var de=(t,o,e)=>ze(t,typeof o!="symbol"?o+"":o,e);var Wn={};yn(Wn,{CallControlPanel:()=>st,getSDKVersion:()=>jn,initSDK:()=>Xn,isSDKInitialized:()=>Kn,useClickToCall:()=>Vo,useEndCall:()=>Yo,useGetAuthorizationToken:()=>Zo,useGetCallerData:()=>zo,useLogout:()=>Go});module.exports=Pn(Wn);var Xe="uat-cti.aighospitals.com",w=`https://${Xe}:8095`,kn=`wss://${Xe}:8095`,q={v1:"/api/v1"},P={LOGIN:`${w}${q.v1}/cti/login?provider=convox`,READY_AGENT:`${w}${q.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${w}${q.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${w}${q.v1}/cti/calls?provider=convox`,HOLD_CALL:`${w}${q.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${w}${q.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${w}${q.v1}/cti/unmute-call?provider=convox`,END_CALL:`${w}${q.v1}/cti/calls/end?provider=convox`,LOGOUT:`${w}${q.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${w}${q.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${w}${q.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${w}${q.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${w}${q.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${w}${q.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${w}${q.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${w}${q.v1}/cti/users`,PROCESS_LIST:`${w}${q.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${w}${q.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${w}${q.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${w}${q.v1}/users/get_sentiment_analysis`},Wo={WS:`${kn}${q.v1}/cti/ws`},Re="call-control-sdk-state";var Ze=class{constructor(){de(this,"state");de(this,"listeners",[]);de(this,"STORAGE_KEY",Re);de(this,"apiKey");de(this,"tenantId");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{authorization:void 0,process:null,agentId:"",openConferenceDialog:!1,openCallTransferDialog:!1,isInitialized:!1,sdkConfig:{disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,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=J(p({},this.state),{agentId:e.agentId||"",authorization:e.authorization||void 0,process:e.process||null,openConferenceDialog:(e==null?void 0:e.openConferenceDialog)||!1,openCallTransferDialog:(e==null?void 0:e.openCallTransferDialog)||!1,isInitialized:e.isInitialized||!1,sdkConfig:e.sdkConfig||{disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,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={agentId:this.state.agentId,authorization:this.state.authorization,process:this.state.process,isInitialized:this.state.isInitialized,openConferenceDialog:this.state.openConferenceDialog,openCallTransferDialog:this.state.openCallTransferDialog,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())}validateCredentials(o,e){if(!o||typeof o!="string"||o.trim().length===0)throw new Error("API key not available");if(!e||typeof e!="string"||e.trim().length===0)throw new Error("Tenant ID not available");this.apiKey=o.trim(),this.tenantId=e.trim()}initialize(o,e,l,i,s){if(this.validateCredentials(o,e),!l||typeof l!="string"||l.trim().length===0)throw new Error("Agent ID not available");this.state.agentId=l,this.state.openConferenceDialog=!1,this.state.openCallTransferDialog=!1,this.state.authorization=s,this.state.sdkConfig=p({disableEndCallButton:!1,disabledDialButton:!1,disableCallTransferButton:!1,isDraggable:!0,disableSoftPhone:!1,disableConferenceButton:!1,disabled:{},enabled:{},outlined:{}},i),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return p({},this.state)}getCredentials(){return{apiKey:this.apiKey,tenantId:this.tenantId}}getSdkAuthToken(){var o;return(o=this.state.authorization)==null?void 0:o.accessToken}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()}setInitCheck(){this.state.isInitialized=!1,this.saveToStorage(),this.notifyListeners()}setOpenConferenceDialog(o){this.state.openConferenceDialog=o,this.saveToStorage(),this.notifyListeners()}setOpenCallTransferDialog(o){this.state.openCallTransferDialog=o,this.saveToStorage(),this.notifyListeners()}updateCallData(o){this.state.callData=p(p({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}updateConferenceData(o){this.state.conferenceLine=[...o],this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){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 e=(l=this.state.conferenceLine)==null?void 0:l.map(i=>i.line===o.line?o:i);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||[]}},x=new Ze;var et=class{constructor(){de(this,"config",null);de(this,"ticketId",null);de(this,"baseUrl","");de(this,"eventQueue",[]);de(this,"flushTimer",null)}async init(o){this.config=p({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 x.setInitCheck(),new Error(`Failed to initialize: ${o.status} ${o.statusText}`);let e=await o.json();return this.ticketId=e.ticketId,this.config.autoTrack&&this.setupAutoTracking(),e}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 l={eventType:o,eventData:e,timestamp:Date.now()};this.eventQueue.push(l),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift()}async makeRequest(o,e){var s;let l=`${this.baseUrl}${o}`,i=((s=this.config)==null?void 0:s.retryAttempts)||3;for(let u=1;u<=i;u++)try{return await fetch(l,e)}catch(c){if(u===i)throw c;let m=Math.min(1e3*Math.pow(2,u-1),1e4);await new Promise(f=>setTimeout(f,m))}throw new Error("Max retries exceeded")}setupAutoTracking(){var l;if(typeof window=="undefined"||!((l=this.config)!=null&&l.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(i=>console.warn("Failed to track page visit:",i)),o.clicks!==!1&&document.addEventListener("click",i=>{var u;let s=i.target;(s.tagName==="BUTTON"||s.tagName==="A"||s.onclick||s.getAttribute("role")==="button"||s instanceof HTMLButtonElement&&s.type==="button")&&this.logEvent("click",{element:s.tagName,text:(u=s.textContent)==null?void 0:u.trim().substring(0,100),href:s.getAttribute("href"),id:s.id,className:s.className,role:s.getAttribute("role"),position:{x:i.clientX,y:i.clientY},timestamp:new Date().toISOString()}).catch(c=>console.warn("Failed to track click:",c))}),o.forms!==!1&&document.addEventListener("submit",i=>{let s=i.target,u=new FormData(s),c={};u.forEach((m,f)=>{c[f]=m.toString()}),this.logEvent("formSubmission",{formId:s.id,action:s.action,method:s.method,fields:Object.keys(c),fieldCount:Object.keys(c).length,timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track form submission:",m))}),o.inputs!==!1){let i;document.addEventListener("input",s=>{let u=s.target;(u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.tagName==="SELECT")&&(clearTimeout(i),i=setTimeout(()=>{var c;this.logEvent("fieldChange",{element:u.tagName,type:u.getAttribute("type"),name:u.getAttribute("name"),id:u.id,valueLength:((c=u.value)==null?void 0:c.length)||0,timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track field change:",m))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let i=Date.now()-e;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:i,timestamp:new Date().toISOString()})}),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",i=>{this.logEvent("jsError",{message:i.message,filename:i.filename,lineno:i.lineno,colno:i.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",i=>{var s;this.logEvent("unhandledRejection",{reason:(s=i.reason)==null?void 0:s.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let i=window.performance.navigation,s=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:s.navigationStart,loadTime:s.loadEventEnd-s.navigationStart,domReady:s.domContentLoadedEventEnd-s.navigationStart,renderTime:s.loadEventEnd-s.domContentLoadedEventEnd,navigationType:i.type,redirectCount:i.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(window.addEventListener("online",()=>{console.log("EventTracker: Back online, flushing queued events")}),window.addEventListener("offline",()=>{console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){this.flushTimer&&clearInterval(this.flushTimer)}},tt=new et;typeof window!="undefined"&&(window.EventTracker=tt);var me=require("react");var qo=An(require("axios"));var Jo,vn=(Jo=x.getSdkAuthToken())!=null?Jo:"",In=6e4;function $n(){var t;return(t=x.getSdkAuthToken())!=null?t:""}function _n(){var o,e,l,i;let t=qo.default.create({baseURL:w,headers:{"Content-Type":"application/json",Accept:"application/json","x-tenant-id":(e=(o=x.getCredentials())==null?void 0:o.tenantId)!=null?e:"","x-api-key":(i=(l=x.getCredentials())==null?void 0:l.apiKey)!=null?i:"",Authorization:`${vn}`},timeout:In,withCredentials:!1});return t.interceptors.request.use(s=>{let u=$n();return u&&s.headers&&(s.headers.Authorization=`${u}`),s.metadata={startTime:new Date().getTime()},s},s=>(console.error("Request interceptor error:",s),Promise.reject(s))),t.interceptors.response.use(s=>{var m;let u=new Date().getTime(),c=(m=s.config.metadata)==null?void 0:m.startTime;return c&&console.log(`Request to ${s.config.url} took ${u-c}ms`),s},async s=>{var c;let u=s.config;return((c=s.response)==null?void 0:c.status)===401&&!u._retry&&(x.setInitCheck(),console.warn("Unauthorized request, attempting retry...")),s.response||(console.error("Network error:",s.message),s.message="Network error: Please check your internet connection"),s.response&&s.response.status>=500&&(console.error("Server error:",s.response.status,s.response.data),s.message="Server error: Please try again later"),Promise.reject(s)}),t}var Nn=_n(),ne=Nn;var Go=()=>{let[t,o]=(0,me.useState)(!1),[e,l]=(0,me.useState)(!1),[i,s]=(0,me.useState)(!1),[u,c]=(0,me.useState)(null),[m,f]=(0,me.useState)(null);return{logout:(0,me.useCallback)(async()=>{var h;let g=JSON.parse((h=localStorage.getItem(Re))!=null?h:"");o(!0);let C={action:"LOGOUTUSER",userId:g.agentId||""};return ne.post(P.LOGOUT,C).then(U=>(x.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(U==null?void 0:U.data),l(!0),U==null?void 0:U.data)).catch(U=>{var E;return s(!0),c(U),(E=U==null?void 0:U.response)==null?void 0:E.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:m}};var Ce=require("react");var Yo=()=>{let[t,o]=(0,Ce.useState)(!1),[e,l]=(0,Ce.useState)(!1),[i,s]=(0,Ce.useState)(!1),[u,c]=(0,Ce.useState)(null),[m,f]=(0,Ce.useState)(null);return{handleEndCall:(0,Ce.useCallback)(async g=>{var U,E,v,O,I,M,Q,z,X,$,S,y,Z,se,ie;let C=JSON.parse((U=localStorage.getItem(Re))!=null?U:"");o(!0);let h={action:"ENDCALL",userId:C==null?void 0:C.agentId,processid:(O=(v=(E=C==null?void 0:C.process)==null?void 0:E.process_id)==null?void 0:v.toString())!=null?O:"",process_name:(M=(I=C==null?void 0:C.process)==null?void 0:I.process_name)!=null?M:"",callreferenceid:(z=(Q=C==null?void 0:C.callData)==null?void 0:Q.convox_id)!=null?z:"",mobile_number:($=(X=C==null?void 0:C.callData)==null?void 0:X.phone_number)!=null?$:"",disposition:(S=g==null?void 0:g.disposition)!=null?S:"RES",set_followUp:(y=g==null?void 0:g.followUp)!=null?y:"N",callback_date:(Z=g==null?void 0:g.callbackDate)!=null?Z:"",callback_hrs:(se=g==null?void 0:g.callbackHrs)!=null?se:"",callback_mins:(ie=g==null?void 0:g.callbackMins)!=null?ie:"",endcall_type:"CLOSE"};return ne.post(P.END_CALL,h).then(D=>(x.endCall(),f(D==null?void 0:D.data),l(!0),D==null?void 0:D.data)).catch(D=>{var N;return s(!0),c(D),(N=D==null?void 0:D.response)==null?void 0:N.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:m}};var xe=require("react");var Vo=()=>{let[t,o]=(0,xe.useState)(!1),[e,l]=(0,xe.useState)(!1),[i,s]=(0,xe.useState)(!1),[u,c]=(0,xe.useState)(null),[m,f]=(0,xe.useState)(null);return{handleStartCall:(0,xe.useCallback)(async g=>{var h,U,E,v,O,I,M,Q,z;let C=JSON.parse((h=localStorage.getItem(Re))!=null?h:"");if(o(!0),((U=C==null?void 0:C.callData)==null?void 0:U.status)==="IDLE"){let X={action:"CALL",userId:C==null?void 0:C.agentId,phone_number:g==null?void 0:g.mobileNumber};return ne.post(P.CLICK_TO_CALL,X).then($=>(f($==null?void 0:$.data),l(!0),$==null?void 0:$.data)).catch($=>{var S;return s(!0),c($),(S=$==null?void 0:$.response)==null?void 0:S.data}).finally(()=>{o(!1)})}else if(((E=C==null?void 0:C.callData)==null?void 0:E.status)==="ONCALL"){let X=(O=(v=C==null?void 0:C.conferenceLine)==null?void 0:v.filter(S=>S.line!==1))==null?void 0:O.find(S=>S.status==="IDLE"&&!(S!=null&&S.isCallStart)),$={action:"EXTERNAL_CONFERENCE",operation:`CALL${X.line}`,line_used:String(X.line),thirdparty_no:g==null?void 0:g.mobileNumber,userid:(M=(I=C.callData)==null?void 0:I.agent_id)!=null?M:"",process:(z=(Q=C.callData)==null?void 0:Q.process_name)!=null?z:""};return ne.post(P.CONFERENCE_CALL,$).then(S=>(f(S==null?void 0:S.data),l(!0),x.setConferenceLine(J(p({},X),{isCallStart:!0,status:"ONCALL",phone:g==null?void 0:g.mobileNumber})),x.setOpenConferenceDialog(!0),S==null?void 0:S.data)).catch(S=>{var y;return s(!0),c(S),(y=S==null?void 0:S.response)==null?void 0:y.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:i,error:u,data:m}};var je=require("react");var zo=()=>{let{process_id:t,process_name:o,status:e,phone_number:l,agent_id:i,convox_id:s}=x.getState().callData,u={phone_number:l,status:e,callReferenceId:s,agent_id:i,process_id:t,process_name:o},[c,m]=(0,je.useState)(u);return(0,je.useEffect)(()=>x.subscribe(()=>{let{process_id:T,process_name:g,status:C,phone_number:h,agent_id:U,convox_id:E}=x.getState().callData;m({phone_number:h,status:C,callReferenceId:E,agent_id:U,process_id:T,process_name:g})}),[]),c};var Ke=require("react");var Zo=()=>{let[t,o]=(0,Ke.useState)(x.getSdkAuthToken());return(0,Ke.useEffect)(()=>x.subscribe(()=>{o(x.getSdkAuthToken())}),[]),t};var Ye=require("react");var L=require("@mui/icons-material"),R=require("@mui/material"),F=require("react");var pe=require("react");function ot(t,o){let[e,l]=(0,pe.useState)(t),[i,s]=(0,pe.useState)(!1),u=(0,pe.useRef)(),c=(0,pe.useRef)({x:0,y:0}),m=(0,pe.useRef)({x:0,y:0}),f=(0,pe.useCallback)(h=>{let U=u.current;if(!U)return;let E=U.getBoundingClientRect(),v=window.innerWidth,O=window.innerHeight,I={x:Math.max(0,Math.min(h.x,v-E.width)),y:Math.max(0,Math.min(h.y,O-E.height))};l(I),o==null||o(I)},[o]),T=(0,pe.useCallback)((h,U)=>{s(!0),c.current={x:h,y:U},m.current=e;let E=(M,Q)=>{let z=M-c.current.x,X=Q-c.current.y;f({x:m.current.x+z,y:m.current.y+X})},v=M=>{M.preventDefault(),E(M.clientX,M.clientY)},O=M=>{M.preventDefault();let Q=M.touches[0];Q&&E(Q.clientX,Q.clientY)},I=()=>{s(!1),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",I),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",I)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",I),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",I)},[e,f]),g=(0,pe.useCallback)(h=>{h.preventDefault(),T(h.clientX,h.clientY)},[T]),C=(0,pe.useCallback)(h=>{h.preventDefault();let U=h.touches[0];U&&T(U.clientX,U.clientY)},[T]);return{position:e,isDragging:i,dragRef:u,handleMouseDown:g,handleTouchStart:C}}var We=require("react");function De(){let[t,o]=(0,We.useState)(x.getState());return(0,We.useEffect)(()=>x.subscribe(()=>{o(x.getState())}),[]),t}var qe=require("react");var be=require("react"),Je=require("@mui/material"),ke=require("react/jsx-runtime"),en=(0,be.createContext)(void 0),he=()=>{let t=(0,be.useContext)(en);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},tn=({children:t})=>{let[o,e]=(0,be.useState)(!1),[l,i]=(0,be.useState)(""),[s,u]=(0,be.useState)("info"),c=(m,f="info")=>{i(m),u(f),e(!0)};return(0,ke.jsxs)(en.Provider,{value:{showToast:c},children:[t,(0,ke.jsx)(Je.Snackbar,{open:o,color:s,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,ke.jsx)(Je.Alert,{variant:"filled",severity:s,onClose:()=>e(!1),sx:{width:"100%"},children:l})})]})};var On={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},Mn=(t,o)=>{if(o.type==="isLoading")return J(p({},t),{isLoading:o.payload});if(o.type==="isSuccess")return J(p({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return J(p({},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 ce=(t={})=>{let{onSuccess:o=null,onError:e=null,disabledSuccessToast:l=!1}=t,{showToast:i}=he(),[s,u]=(0,qe.useReducer)(Mn,On);return[(0,qe.useCallback)((m,f,T={})=>{u({type:"isLoading",payload:!0}),ne.post(m,f,T).then(g=>{var C;u({type:"isSuccess",payload:g.data}),o==null||o(g.data,f),l||i((C=g.data)==null?void 0:C.message,"success")}).catch(g=>{var h,U,E,v,O,I,M,Q,z,X,$,S;let C={status:(U=(h=g.response)==null?void 0:h.status)!=null?U:500,message:((v=(E=g.response)==null?void 0:E.data)==null?void 0:v.detail)||((I=(O=g.response)==null?void 0:O.data)==null?void 0:I.message)||g.message||"An unknown error occurred",data:(Q=(M=g.response)==null?void 0:M.data)!=null?Q:null,statusText:(X=(z=g.response)==null?void 0:z.statusText)!=null?X:"",code:($=g==null?void 0:g.code)!=null?$:"",name:(S=g==null?void 0:g.name)!=null?S:""};i(C.message,"error"),u({type:"isError",payload:C}),e==null||e(C,f)}).finally(()=>{u({type:"isLoading",payload:!1})})},[o,e,i]),s]};var k=require("@mui/icons-material"),a=require("@mui/material"),le=require("react");var on=require("@mui/material");var Bn=({disabled:t,enabled:o,outlined:e})=>{let l=(0,on.useTheme)();return{disabled:p({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 ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},t),enabled:p({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${l.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},o),outlined:p({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:l.palette.grey[200],boxShadow:`0px 2px 1px ${l.palette.primary.light}`,border:`0px solid ${l.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${l.palette.primary.main}`,border:`0px solid ${l.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${l.palette.primary.light}`}},e)}},Ge=Bn;var n=require("react/jsx-runtime"),Hn=({each:t,isMergeCall:o})=>{var S,y,Z,se,ie;let e=De(),{showToast:l}=he(),{disabled:i,enabled:s,outlined:u}=Ge({disabled:((S=e.sdkConfig)==null?void 0:S.disabled)||{},enabled:((y=e.sdkConfig)==null?void 0:y.enabled)||{},outlined:((Z=e.sdkConfig)==null?void 0:Z.outlined)||{}}),c=(0,a.useTheme)(),[m,f]=(0,le.useState)(!1),[T,g]=(0,le.useState)(!1),[C,h]=(0,le.useState)(!1),[U,E]=(0,le.useState)(!1),[v,O]=(0,le.useState)(!1),I=(D,N)=>{x.setConferenceLine(p(p({},D),N))},M=(D,N)=>{var W,G,Y,ee;let B=p(p({},D),N);f(!0);let K={action:"EXTERNAL_CONFERENCE",operation:`CALL${B.line}`,line_used:String(B.line),thirdparty_no:B.phone,userid:(G=(W=e.callData)==null?void 0:W.agent_id)!=null?G:"",process:(ee=(Y=e.callData)==null?void 0:Y.process_name)!=null?ee:""};ne.post(P.CONFERENCE_CALL,K).then(_=>{var A;l((A=_.data)==null?void 0:A.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(_=>{var j,V,te,oe;let A=((V=(j=_.response)==null?void 0:j.data)==null?void 0:V.detail)||((oe=(te=_.response)==null?void 0:te.data)==null?void 0:oe.message)||_.message||"An unknown error occurred";l(A,"error")}).finally(()=>{f(!1)})},Q=(D,N)=>{var W,G,Y,ee;let B=p(p({},D),N);g(!0);let K={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(B.line),thirdparty_no:B.phone,userid:(G=(W=e.callData)==null?void 0:W.agent_id)!=null?G:"",process:(ee=(Y=e.callData)==null?void 0:Y.process_name)!=null?ee:""};ne.post(P.CONFERENCE_CALL,K).then(_=>{var A;l((A=_.data)==null?void 0:A.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(_=>{var j,V,te,oe;let A=((V=(j=_.response)==null?void 0:j.data)==null?void 0:V.detail)||((oe=(te=_.response)==null?void 0:te.data)==null?void 0:oe.message)||_.message||"An unknown error occurred";l(A,"error")}).finally(()=>{g(!1)})},z=(D,N,B)=>{var G,Y,ee,_;let K=p(p({},D),N);h(!0);let W={action:"EXTERNAL_CONFERENCE",operation:B,hold_channel_no:B==="HOLDUSER"?`hold${K.line}`:`unhold${K.line}`,userid:(Y=(G=e.callData)==null?void 0:G.agent_id)!=null?Y:"",process:(_=(ee=e.callData)==null?void 0:ee.process_name)!=null?_:""};ne.post(P.CONFERENCE_CALL_HOLD_OR_UN_HOLD,W).then(A=>{var j;l((j=A.data)==null?void 0:j.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(A=>{var V,te,oe,ue;let j=((te=(V=A.response)==null?void 0:V.data)==null?void 0:te.detail)||((ue=(oe=A.response)==null?void 0:oe.data)==null?void 0:ue.message)||A.message||"An unknown error occurred";l(j,"error")}).finally(()=>{h(!1)})},X=(D,N,B)=>{var G,Y,ee,_;let K=p(p({},D),N);E(!0);let W={action:"EXTERNAL_CONFERENCE",operation:B,channel_no:B==="MUTEUSER"?`mute${K.line}`:`play${K.line}`,userid:(Y=(G=e.callData)==null?void 0:G.agent_id)!=null?Y:"",thirdparty_no:K.phone,process:(_=(ee=e.callData)==null?void 0:ee.process_name)!=null?_:""};ne.post(P.CONFERENCE_CALL_MUTE_OT_UN_MUTE,W).then(A=>{var j;l((j=A.data)==null?void 0:j.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(A=>{var V,te,oe,ue;let j=((te=(V=A.response)==null?void 0:V.data)==null?void 0:te.detail)||((ue=(oe=A.response)==null?void 0:oe.data)==null?void 0:ue.message)||A.message||"An unknown error occurred";l(j,"error")}).finally(()=>{E(!1)})},$=(D,N)=>{var W,G,Y,ee;let B=p(p({},D),N);O(!0);let K={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(B.line),user_type:`THIRDPARTY${B.line-1}`,thirdparty_no:B.phone,userid:(G=(W=e.callData)==null?void 0:W.agent_id)!=null?G:"",process:(ee=(Y=e.callData)==null?void 0:Y.process_name)!=null?ee:""};ne.post(P.CONFERENCE_CALL_END,K).then(_=>{var A;l((A=_.data)==null?void 0:A.message,"success"),x.setConferenceLine(p(p({},D),N))}).catch(_=>{var j,V,te,oe;let A=((V=(j=_.response)==null?void 0:j.data)==null?void 0:V.detail)||((oe=(te=_.response)==null?void 0:te.data)==null?void 0:oe.message)||_.message||"An unknown error occurred";l(A,"error")}).finally(()=>{O(!1)})};return(0,n.jsxs)(a.TableRow,{sx:{border:"2px solid #fff"},children:[(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsxs)(a.Typography,{children:["Line ",(se=t==null?void 0:t.line)!=null?se:"",". "]})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(a.Typography,{variant:"body2",sx:{px:1,borderRadius:"10px"},children:(ie=t==null?void 0:t.status)!=null?ie:""})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(a.Button,{sx:{textTransform:"capitalize"},size:"small",children:(0,n.jsx)(a.Typography,{variant:"body2",children:(t==null?void 0:t.line)===1?"Internal":"External"})})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsx)(a.TextField,{size:"small",placeholder:"Phone Number",fullWidth:!0,value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="CONFERENCE"||(t==null?void 0:t.status)==="HOLD"||(t==null?void 0:t.status)==="MUTE",onChange:D=>{I(t,{phone:D.target.value})}})}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:(0,n.jsxs)(a.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[t.line!==1&&(0,n.jsx)(a.Tooltip,{title:"Call",children:(0,n.jsx)(a.Button,{variant:(t==null?void 0:t.status)!=="IDLE"?"outlined":"contained",color:"success",sx:(t==null?void 0:t.status)!=="IDLE"?p({},i):J(p({},s),{border:`0px solid ${c.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${c.palette.success.light}`,border:`0px solid ${c.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${c.palette.primary.light}`}}),onClick:()=>{M(t,{})},disabled:(t==null?void 0:t.status)!=="IDLE",children:m?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"success"}):(0,n.jsx)(k.Call,{sx:{color:(t==null?void 0:t.status)!=="IDLE"?"default":"#f3f2f2"}})})}),t.line===1&&(0,n.jsx)(a.Tooltip,{title:"Merge Call",children:(0,n.jsxs)(a.Button,{variant:o?"contained":"outlined",sx:o?J(p({},s),{padding:"0px 16px"}):J(p({},i),{padding:"0px 16px"}),onClick:()=>{Q(t,{isMergeCall:!0})},disabled:!o||T,children:[t!=null&&t.isMergeCall?"Merged":"Merge",T?(0,n.jsx)(a.CircularProgress,{size:"20px"}):(0,n.jsx)(k.CallSplit,{})]})}),(0,n.jsx)(a.Tooltip,{title:t.status!=="HOLD"?"Hold":"Un Hold",children:(0,n.jsx)(a.Button,{variant:t.status==="HOLD"?"contained":"outlined",sx:t.status==="DISCONNECTED"||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},i):(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},u):p({},i),onClick:()=>{t.status==="HOLD"?z(t,{isHold:!1},"UNHOLDUSER"):z(t,{isHold:!0},"HOLDUSER")},disabled:(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="IDLE"||C,children:C?(0,n.jsx)(a.CircularProgress,{size:"20px",sx:{color:c.palette.primary.main}}):t.status==="HOLD"?(0,n.jsx)(k.PlayArrow,{}):(0,n.jsx)(k.Pause,{})})}),(0,n.jsx)(a.Tooltip,{title:t.status!=="MUTE"?"Mute":"Un Mute",children:(0,n.jsx)(a.Button,{variant:t.status==="MUTE"?"contained":"outlined",sx:t.status==="DISCONNECTED"||(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},i):(t==null?void 0:t.status)==="ONCALL"||(t==null?void 0:t.status)==="CONFERENCE"?p({},u):p({},i),onClick:()=>{t.status==="MUTE"?X(t,{isMute:!1},"PLAYUSER"):X(t,{isMute:!0},"MUTEUSER")},disabled:(t==null?void 0:t.status)==="DISCONNECTED"||(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="HOLD"||U,children:U?(0,n.jsx)(a.CircularProgress,{size:"20px",sx:{color:c.palette.primary.main}}):t.status==="MUTE"?(0,n.jsx)(k.MicOff,{}):(0,n.jsx)(k.Mic,{})})}),(t==null?void 0:t.line)!==1?(0,n.jsx)(a.Tooltip,{title:"End Call",children:(0,n.jsx)(a.Button,{variant:(t==null?void 0:t.status)!=="IDLE"&&(t==null?void 0:t.status)!=="DISCONNECTED"?"contained":"outlined",color:"error",sx:(t==null?void 0:t.status)!=="IDLE"&&(t==null?void 0:t.status)!=="DISCONNECTED"?J(p({},s),{border:`0px solid ${c.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${c.palette.error.light}`,border:`0px solid ${c.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${c.palette.primary.light}`}}):p({},i),onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="DISCONNECTED"||v,children:v?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(k.CallEnd,{})})}):(0,n.jsx)(a.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:{display:"none"},onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1})},disabled:(t==null?void 0:t.status)==="IDLE"||(t==null?void 0:t.status)==="DISCONNECTED"||v,children:v?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"error"}):(0,n.jsx)(k.CallEnd,{})})]})})]},t.line)};function nn(){var c;let t=De(),{showToast:o}=he(),[e,l]=(0,le.useState)(!1),i=()=>{x.setOpenConferenceDialog(!1)},s=()=>{var f,T,g,C;l(!0);let m={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(T=(f=t.callData)==null?void 0:f.agent_id)!=null?T:"",process:(C=(g=t.callData)==null?void 0:g.process_name)!=null?C:""};ne.post(P.CONFERENCE_CALL_END_ALL,m).then(h=>{var U;o((U=h.data)==null?void 0:U.message,"success"),x.resetConferenceLines(),i()}).catch(h=>{var E,v,O,I;let U=((v=(E=h.response)==null?void 0:E.data)==null?void 0:v.detail)||((I=(O=h.response)==null?void 0:O.data)==null?void 0:I.message)||h.message||"An unknown error occurred";o(U,"error")}).finally(()=>{l(!1)})},u=(0,le.useMemo)(()=>{var m;return(m=t==null?void 0:t.conferenceLine)==null?void 0:m.some(f=>f.line!==1?f.status==="ONCALL":!1)},[t.conferenceLine]);return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t.openConferenceDialog,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 16px"},children:[(0,n.jsxs)(a.Typography,{variant:"body1",children:[(c=t==null?void 0:t.agentId)!=null?c:""," conference"]}),(0,n.jsx)(a.IconButton,{onClick:i,children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(a.Box,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:(0,n.jsx)(a.TableContainer,{component:a.Paper,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:(0,n.jsxs)(a.Table,{sx:{border:"4px solid #ffffff !important"},children:[(0,n.jsx)(a.TableHead,{children:(0,n.jsxs)(a.TableRow,{sx:{border:"2px solid #f3f3f3ff !important"},children:[(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Line"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Status"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Call Type"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Mobile Number"}),(0,n.jsx)(a.TableCell,{sx:{padding:"6px"},children:"Call Actions"})]})}),(0,n.jsx)(a.TableBody,{children:t==null?void 0:t.conferenceLine.map(m=>(0,n.jsx)(Hn,{each:m,isMergeCall:u}))})]})})}),(0,n.jsx)(a.Box,{textAlign:"center",m:2,children:(0,n.jsxs)(a.Button,{variant:"outlined",color:"error",size:"large",onClick:s,disabled:e,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[e?(0,n.jsx)(a.CircularProgress,{size:"20px",color:"error",sx:{marginRight:"8px"}}):(0,n.jsx)(a.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,n.jsx)(k.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function an({open:t}){var h,U,E,v,O,I,M,Q,z,X,$,S;let o=De(),[e]=ce({onSuccess:()=>{x.setOpenCallTransferDialog(!1)}}),[l,i]=(0,le.useState)("process"),[s,{data:u,isLoading:c}]=ce({disabledSuccessToast:!0}),[m,{data:f,isLoading:T}]=ce({disabledSuccessToast:!0}),g=()=>{x.setOpenCallTransferDialog(!1)},C=(y,Z)=>{var se,ie,D,N,B,K,W,G,Y,ee,_,A,j,V,te,oe,ue,ve,Ie,$e,_e,Ee,Ne,Se,Oe,Te,Me,Be,He,Le,we,Fe,Qe;if(Z==="PROCESS"){let Ue={mobile_number:(ie=(se=o.callData)==null?void 0:se.phone_number)!=null?ie:"",userid:(N=(D=o.callData)==null?void 0:D.agent_id)!=null?N:"",type:"PROCESS",transfer_to:(B=y==null?void 0:y.process_name)!=null?B:"",callreferenceid:(W=(K=o.callData)==null?void 0:K.convox_id)!=null?W:"",processid:String((Y=(G=o.callData)==null?void 0:G.process_id)!=null?Y:""),process_name:(_=(ee=o.callData)==null?void 0:ee.process_name)!=null?_:""};e(P.TRANSFER_CALL,Ue)}else if(Z==="QUEUE"){let Ue={mobile_number:(j=(A=o.callData)==null?void 0:A.phone_number)!=null?j:"",userid:(te=(V=o.callData)==null?void 0:V.agent_id)!=null?te:"",type:"QUEUE",transfer_to:(oe=y==null?void 0:y.queue_name)!=null?oe:"",callreferenceid:(ve=(ue=o.callData)==null?void 0:ue.convox_id)!=null?ve:"",processid:String(($e=(Ie=o.callData)==null?void 0:Ie.process_id)!=null?$e:""),process_name:(Ee=(_e=o.callData)==null?void 0:_e.process_name)!=null?Ee:""};e(P.TRANSFER_CALL,Ue)}else if(Z==="AGENT"){let Ue={mobile_number:(Se=(Ne=o.callData)==null?void 0:Ne.phone_number)!=null?Se:"",userid:(Te=(Oe=o.callData)==null?void 0:Oe.agent_id)!=null?Te:"",type:"AGENT",transfer_to:(Me=y==null?void 0:y.user_id)!=null?Me:"",callreferenceid:(He=(Be=o.callData)==null?void 0:Be.convox_id)!=null?He:"",processid:String((we=(Le=o.callData)==null?void 0:Le.process_id)!=null?we:""),process_name:(Qe=(Fe=o.callData)==null?void 0:Fe.process_name)!=null?Qe:""};e(P.TRANSFER_CALL,Ue)}};return(0,le.useEffect)(()=>{s(P.AGENTS_LIST,{status:"IDLE",active:!0}),m(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(a.Typography,{variant:"body1",children:" Call Transfer"}),(0,n.jsx)(a.IconButton,{onClick:g,children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsxs)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",gap:1},children:[(0,n.jsx)(a.Button,{variant:l==="process"?"contained":"outlined",onClick:()=>{i("process"),m(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Process"}),(0,n.jsx)(a.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>{i("queues"),m(P.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Queues"}),(0,n.jsx)(a.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>{i("agents"),s(P.AGENTS_LIST,{status:"IDLE",active:!0})},children:"Agents"})]}),(T||c)&&(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"80px"},children:[(0,n.jsx)(a.CircularProgress,{})," "]}),!T&&!c&&l==="process"&&(0,n.jsx)(a.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(h=f==null?void 0:f.data)!=null&&h.process&&((E=(U=f==null?void 0:f.data)==null?void 0:U.process)==null?void 0:E.length)>0?(O=(v=f==null?void 0:f.data)==null?void 0:v.process)==null?void 0:O.map((y,Z)=>(0,n.jsxs)(a.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,n.jsxs)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),y.process_name]}),(0,n.jsx)(a.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{C(y,"PROCESS")},children:(0,n.jsx)(k.Call,{})})]},Z)):(0,n.jsx)(a.Typography,{variant:"body1",sx:{fontSize:"16px",letterSpacing:"0.02em",textTransform:"capitalize",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",margin:"10px 0px",color:"gray",height:"60px"},children:"No Process Found"})}),!T&&!c&&l==="queues"&&(0,n.jsx)(a.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:(I=f==null?void 0:f.data)!=null&&I.queue&&((Q=(M=f==null?void 0:f.data)==null?void 0:M.queue)==null?void 0:Q.length)>0?(X=(z=f==null?void 0:f.data)==null?void 0:z.queue)==null?void 0:X.map((y,Z)=>{var se,ie,D,N,B,K;return(0,n.jsxs)(a.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,n.jsxs)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),y.queue_name,(D=(ie=(se=f==null?void 0:f.data)==null?void 0:se.process)==null?void 0:ie.find(W=>W.process_id===y.process_id))!=null&&D.process_name?(0,n.jsx)(a.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((K=(B=(N=f==null?void 0:f.data)==null?void 0:N.process)==null?void 0:B.find(W=>W.process_id===y.process_id))==null?void 0:K.process_name)+")"}):""]}),(0,n.jsx)(a.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{C(y,"QUEUE")},children:(0,n.jsx)(k.Call,{})})]},Z)}):(0,n.jsx)(a.Typography,{variant:"body1",sx:{fontSize:"16px",letterSpacing:"0.02em",textTransform:"capitalize",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",margin:"10px 0px",color:"gray",height:"60px"},children:"No Queues Found"})}),!T&&!c&&l==="agents"&&(0,n.jsx)(a.Box,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:u!=null&&u.data&&(($=u==null?void 0:u.data)==null?void 0:$.length)>0?(S=u==null?void 0:u.data)==null?void 0:S.map((y,Z)=>(0,n.jsxs)(a.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,n.jsxs)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),y.name]}),(0,n.jsx)(a.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{C(y,"AGENT")},children:(0,n.jsx)(k.Call,{})})]},Z)):(0,n.jsx)(a.Typography,{variant:"body1",sx:{fontSize:"16px",letterSpacing:"0.02em",textTransform:"capitalize",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",margin:"10px 0px",color:"gray",height:"60px"},children:"No Agents Found"})})]})]})})})}function sn({open:t,setOpen:o,onSubmitDisposition:e}){var T,g,C,h;let[l,i]=(0,le.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),s=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],u=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],c=(U,E)=>{i(v=>J(p({},v),{[U]:E}))},m=()=>{i({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{m(),o(!1)};return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsx)(a.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:(0,n.jsxs)(a.Typography,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),(0,n.jsxs)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:[(0,n.jsxs)(a.Box,{display:"flex",gap:2,children:[(0,n.jsx)(a.Autocomplete,{value:l.disposition,options:s,getOptionLabel:U=>U.label,onChange:(U,E)=>c("disposition",E),size:"small",renderInput:U=>(0,n.jsx)(a.TextField,J(p({},U),{label:"Disposition",fullWidth:!0})),sx:{flex:1}}),(0,n.jsx)(a.Autocomplete,{options:u,getOptionLabel:U=>U.label,value:l.followUp,onChange:(U,E)=>c("followUp",E),size:"small",renderInput:U=>(0,n.jsx)(a.TextField,J(p({},U),{label:"Follow Up",fullWidth:!0})),sx:{flex:1}})]}),((g=(T=l==null?void 0:l.followUp)==null?void 0:T.label)==null?void 0:g.toLowerCase())==="yes"&&(0,n.jsxs)(a.Box,{display:"flex",gap:2,mt:2,children:[(0,n.jsx)(a.TextField,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:l.callbackDate,onChange:U=>c("callbackDate",U.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(a.TextField,{size:"small",label:"Hours (0-23)",type:"text",value:l.callbackHrs,onChange:U=>c("callbackHrs",U.target.value),fullWidth:!0,sx:{flex:1}})]}),((h=(C=l==null?void 0:l.followUp)==null?void 0:C.label)==null?void 0:h.toLowerCase())==="yes"&&(0,n.jsxs)(a.Box,{display:"flex",gap:2,mt:2,children:[(0,n.jsx)(a.TextField,{size:"small",label:"Minutes (0-59)",type:"text",value:l.callbackMins,onChange:U=>c("callbackMins",U.target.value),fullWidth:!0,sx:{flex:1}}),(0,n.jsx)(a.Box,{sx:{flex:1}})]})]}),(0,n.jsxs)(a.Box,{textAlign:"right",m:2,children:[(0,n.jsx)(a.Button,{variant:"outlined",color:"error",size:"large",onClick:f,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,n.jsx)(a.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>e(l),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function rn({open:t,setOpen:o,processList:e=null,handleSelectedProcessor:l}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(a.Typography,{variant:"body1",children:" Process List"}),(0,n.jsx)(a.IconButton,{onClick:()=>{o(!1)},children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:e.length>0?e==null?void 0:e.map((s,u)=>(0,n.jsx)(a.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{l(s)},children:(0,n.jsxs)(a.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,n.jsx)(k.SupportAgent,{sx:{marginRight:"4px"}}),s.process_name]})},u)):null})]})})})}function ln({open:t,setOpen:o}){return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(a.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,n.jsxs)(a.Paper,{sx:{borderRadius:2},children:[(0,n.jsxs)(a.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,n.jsx)(a.Typography,{variant:"body1",children:" Call History"}),(0,n.jsx)(a.IconButton,{onClick:()=>{o(!1)},children:(0,n.jsx)(k.Close,{})})]}),(0,n.jsx)(a.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}var dn="./incoming-4WP3FJI4.mp3";var d=require("react/jsx-runtime"),Fn=(t,o,e)=>t.map(i=>{var s,u,c;if((i==null?void 0:i.line)===1){let m=`line_${i.line}_status`;return J(p({},i),{line:1,status:(s=o[m])!=null?s:e==null?void 0:e.status,phone:(u=e==null?void 0:e.phone_number)!=null?u:""})}else{let m=`line_${i.line}_status`,f=`line_${i.line}_phonenumber`;return J(p({},i),{status:(c=o[m])!=null?c:"IDLE",phone:o[f]!=="0"?o[f]:""})}}),Qn=t=>{let o=Math.floor(t/60),e=t%60;return`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`};function pn({onDataChange:t}){var it,rt,lt,dt,pt,ct,ut,gt,ft,Ut,Rt,mt,Ct,xt,bt,ht,Dt,Et,St,Tt,Lt,yt,At,Pt,kt,vt,It,$t,_t,Nt,Ot,Mt,Bt,Ht,wt,Ft,Qt,Xt,jt,Kt,Wt,Jt,qt,Gt,Yt,Vt,zt,Zt,eo,to,oo,no,ao,so,io,ro,lo,po,co,uo,go,fo,Uo,Ro,mo,Co,xo,bo,ho,Do,Eo,So,To,Lo,yo,Ao,Po,ko,vo,Io,$o;let o=(0,R.useTheme)(),e=De(),{showToast:l}=he(),{disabled:i,enabled:s,outlined:u}=Ge({disabled:((it=e.sdkConfig)==null?void 0:it.disabled)||{},enabled:((rt=e.sdkConfig)==null?void 0:rt.enabled)||{},outlined:((lt=e.sdkConfig)==null?void 0:lt.outlined)||{}}),c=(0,F.useRef)(null),m=(0,F.useRef)(null),f=(0,F.useRef)(null),T=(0,F.useRef)(null),g=(0,F.useRef)(0),C=60,h=1e3,U=3e4,[E,v]=(0,F.useState)(null),[O,I]=(0,F.useState)(!0),[M,Q]=(0,F.useState)(null),[z,X]=(0,F.useState)(null),[$,S]=(0,F.useState)(!1),[y,Z]=(0,F.useState)(!1),[se,ie]=(0,F.useState)(!1),[D,N]=(0,F.useState)(null),[B,K]=(0,F.useState)(""),[W,G]=(0,F.useState)(0),{position:Y,isDragging:ee,dragRef:_,handleMouseDown:A,handleTouchStart:j}=ot(e.controlPanelPosition,r=>x.setControlPanelPosition(r)),{position:V,isDragging:te,dragRef:oe,handleMouseDown:ue,handleTouchStart:ve}=ot(e.iframePosition,r=>x.setIframePosition(r)),[Ie,{isLoading:$e}]=ce({onSuccess:()=>{K(""),X(null)}}),[_e,{isLoading:Ee}]=ce({onSuccess:()=>{x.setHolding(!e.isHolding)},onError:r=>{console.log("\u274C Hold operation error:",r)}}),[Ne,{isLoading:Se}]=ce({onSuccess:()=>{x.setMuted(!e.isMuted)},onError:r=>{console.log("\u274C Mute operation error:",r)}}),[Oe,{isLoading:Te}]=ce(),[Me,{isLoading:Be}]=ce(),[He,{isLoading:Le}]=ce(),we=()=>{v(null)},Fe=r=>{I(!0),X(r.currentTarget),x.setStatus("dial")},Qe=()=>{e.status!=="on call"&&x.setStatus("idle"),X(null)},Ue=r=>{Q(r.currentTarget)},gn=()=>{Q(null)},fn=()=>{let r={action:"READYAGENT",userId:e.agentId};Oe(P.READY_AGENT,r)},Un=r=>{Q(null);let b={action:"AGENTBREAK",break_type:r,userId:e.agentId};Me(P.UPDATE_AGENT_BREAK,b)},Rn=r=>{if(r.length!==10)l("Invalid phone number","error");else if(!/^\d+$/.test(r))l("Invalid phone number","error");else{let b={action:"CALL",phone_number:r,userId:e.agentId};Ie(P.CLICK_TO_CALL,b)}},mn=()=>{let r={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};_e(P.HOLD_CALL,r)},Cn=()=>{let r={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};Ne(P.MUTE_CALL,r)},xn=r=>{var H,ae,re,ge,fe,ye,Ae,_o,No,Oo,Mo,Bo,Ho,wo,Fo,Qo;let b={action:"ENDCALL",userId:e.agentId,processid:(re=(ae=(H=e.process)==null?void 0:H.process_id)==null?void 0:ae.toString())!=null?re:"",process_name:(fe=(ge=e.process)==null?void 0:ge.process_name)!=null?fe:"",callreferenceid:(Ae=(ye=e.callData)==null?void 0:ye.convox_id)!=null?Ae:"",mobile_number:(No=(_o=e.callData)==null?void 0:_o.phone_number)!=null?No:"",disposition:(Mo=(Oo=r==null?void 0:r.disposition)==null?void 0:Oo.value)!=null?Mo:"",set_followUp:(Ho=(Bo=r==null?void 0:r.followUp)==null?void 0:Bo.value)!=null?Ho:"",callback_date:(wo=r==null?void 0:r.callbackDate)!=null?wo:"",callback_hrs:(Fo=r==null?void 0:r.callbackHrs)!=null?Fo:"",callback_mins:(Qo=r==null?void 0:r.callbackMins)!=null?Qo:"",endcall_type:"CLOSE"};K(""),He(P.END_CALL,b),x.endCall(),S(!1)};(0,F.useEffect)(()=>{let r=b=>{b.preventDefault()};return window.addEventListener("beforeunload",r),()=>{window.removeEventListener("beforeunload",r)}},[]),(0,F.useEffect)(()=>{let r;return e.callData.status&&e.callData.status==="ONCALL"?r=setInterval(()=>{let b=Math.floor((Date.now()-e.callStartTime)/1e3);G(b)},1e3):G(0),()=>{r&&clearInterval(r)}},[e.callData.status]),(0,F.useEffect)(()=>(m.current=new Audio(dn),m.current.loop=!0,m.current.volume=.7,()=>{m.current&&(m.current.pause(),m.current.currentTime=0,m.current=null)}),[]),(0,F.useEffect)(()=>{if(t&&e.callData){let{process_id:r,process_name:b,status:H,phone_number:ae,agent_id:re,convox_id:ge}=e.callData;t({phone_number:ae,status:H,callReferenceId:ge,agent_id:re,process_id:r,process_name:b})}},[e.callData,t]),(0,F.useEffect)(()=>{e.agentId?ne.post(P.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}).then(r=>{var b,H;r&&r.data&&((b=r==null?void 0:r.data)==null?void 0:b.length)>1?(N(r.data.data),Z(!0)):(x.setProcess((H=r==null?void 0:r.data)==null?void 0:H.data[0]),Z(!1))}).catch(r=>{l(r.response.data.message,"error")}):console.log("No agentId available, skipping API call")},[e.agentId]);let Ve=()=>{if(!e.agentId){console.log("No agentId available, cannot connect WebSocket");return}f.current&&(clearTimeout(f.current),f.current=null);try{c.current=new WebSocket(`${Wo.WS}?agent_id=${e.agentId}`),c.current.onopen=()=>{console.log("\u{1F310} WebSocket connection established"),g.current=0,T.current&&clearInterval(T.current),T.current=setInterval(()=>{if(c.current&&c.current.readyState===WebSocket.OPEN)try{c.current.send(JSON.stringify({type:"ping"})),console.log("\u{1F4E1} WebSocket ping sent")}catch(r){console.error("Failed to send ping:",r)}},3e4)},c.current.onmessage=r=>{try{let b=JSON.parse(r.data);if(b.type==="pong"){console.log("\u{1F4E1} WebSocket pong received");return}let H=Fn(e==null?void 0:e.conferenceLine,b==null?void 0:b.conferencestatus,b);x.updateCallData(b),x.updateConferenceData([...H]),(b.status==="RINGING"||b.status==="DIALING")&&m.current&&m.current.play().catch(ae=>{console.error("Failed to play ringtone:",ae)}),b.status==="ONCALL"&&(m.current&&(m.current.pause(),m.current.currentTime=0),x.startCall(),O||I(!0)),b.status==="WRAPUP"&&(m.current&&(m.current.pause(),m.current.currentTime=0),x.endCall())}catch(b){console.log("\u{1F4E8} Raw message:",r.data)}},c.current.onclose=r=>{if(console.log("\u{1F50C} WebSocket connection closed",r.code,r.reason),T.current&&(clearInterval(T.current),T.current=null),r.code!==1e3&&g.current<C){g.current+=1;let b=Math.min(h*Math.pow(2,g.current-1),U);console.log(`\u{1F504} Attempting to reconnect WebSocket (attempt ${g.current}/${C}) in ${b}ms`),f.current=setTimeout(()=>{Ve()},b)}else g.current>=C&&(console.error("\u274C Maximum reconnection attempts reached. Please refresh the page."),l("WebSocket connection failed. Please refresh the page.","error"))},c.current.onerror=r=>{console.error("\u274C WebSocket error:",r)}}catch(r){if(console.error("\u274C Failed to create WebSocket:",r),g.current<C){g.current+=1;let b=Math.min(h*Math.pow(2,g.current-1),U);f.current=setTimeout(()=>{Ve()},b)}}};return(0,F.useEffect)(()=>(e.agentId&&Ve(),()=>{f.current&&(clearTimeout(f.current),f.current=null),T.current&&(clearInterval(T.current),T.current=null),c.current&&(c.current.close(1e3,"Component unmounting"),c.current=null),g.current=0}),[e.agentId]),!e.isInitialized||!e.process?(0,d.jsx)(R.Box,{children:!!y&&(0,d.jsx)(rn,{processList:D,open:y,setOpen:Z,handleSelectedProcessor:r=>{x.setProcess(r)}})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(R.Box,{children:(0,d.jsx)(R.Fade,{in:!0,timeout:300,children:(0,d.jsx)(R.Paper,{ref:(dt=e.sdkConfig)!=null&&dt.isDraggable?_:null,elevation:ee?4:(pt=e.sdkConfig)!=null&&pt.isDraggable?1:0,sx:{position:(ct=e.sdkConfig)!=null&&ct.isDraggable?"fixed":"relative",left:(ut=e.sdkConfig)!=null&&ut.isDraggable?Y.x:"auto",top:(gt=e.sdkConfig)!=null&>.isDraggable?Y.y:"auto",display:"inline-block",width:"auto",flexShrink:0,whiteSpace:"nowrap",p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:(ft=e.sdkConfig)!=null&&ft.isDraggable?Number.MAX_SAFE_INTEGER:0,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:(0,d.jsxs)(R.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,d.jsxs)(R.Box,{sx:{display:"flex",alignItems:"center",gap:1,margin:"0px 10px"},children:[((Ut=e.sdkConfig)==null?void 0:Ut.isDraggable)&&(0,d.jsxs)(R.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:A,onTouchStart:j,children:[(0,d.jsx)(L.DragIndicator,{})," "]}),(0,d.jsx)(R.Box,{children:!((Rt=e.sdkConfig)!=null&&Rt.disabledDialButton)&&(0,d.jsx)(R.Tooltip,{title:"Dial",children:(0,d.jsx)(R.IconButton,{size:"small",onClick:r=>{var b,H,ae,re,ge,fe,ye,Ae;((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())!=="ONCALL"&&((re=(ae=e.callData)==null?void 0:ae.status)==null?void 0:re.toUpperCase())!=="BREAK"&&((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())!=="RINGING"&&((Ae=(ye=e.callData)==null?void 0:ye.status)==null?void 0:Ae.toUpperCase())!=="WRAPUP"&&Fe(r)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,d.jsx)(L.WifiCalling3,{sx:{color:((Ct=(mt=e.callData)==null?void 0:mt.status)==null?void 0:Ct.toUpperCase())==="ONCALL"||((bt=(xt=e.callData)==null?void 0:xt.status)==null?void 0:bt.toUpperCase())==="BREAK"||((Dt=(ht=e.callData)==null?void 0:ht.status)==null?void 0:Dt.toUpperCase())==="RINGING"||((St=(Et=e.callData)==null?void 0:Et.status)==null?void 0:St.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,d.jsx)(R.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px",fontSize:"18px",fontWeight:"600"},children:Qn(W)}),(0,d.jsx)(R.Chip,{sx:{padding:"18px 0px"},label:Be||Te?(0,d.jsx)(R.Box,{sx:{fontWeight:"bold",width:"60px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,d.jsx)(R.CircularProgress,{size:"20px"})}):(0,d.jsx)(R.Typography,{variant:"body2",sx:{fontWeight:"bold",width:"60px",textAlign:"center"},children:(yt=(Lt=(Tt=e.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())!=null?yt:"N/A"}),onClick:Ue,deleteIcon:(0,d.jsx)(L.KeyboardArrowDown,{color:"primary"}),onDelete:Ue})]}),(0,d.jsxs)(R.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,d.jsx)(R.Tooltip,{title:"Agent Ready",children:(0,d.jsx)(R.Button,{variant:((Pt=(At=e.callData)==null?void 0:At.status)==null?void 0:Pt.toUpperCase())==="BREAK"||((vt=(kt=e.callData)==null?void 0:kt.status)==null?void 0:vt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:r=>{var b,H,ae,re;(((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="BREAK"||((re=(ae=e.callData)==null?void 0:ae.status)==null?void 0:re.toUpperCase())==="MISSED")&&(r.stopPropagation(),fn())},classes:{root:(($t=(It=e.callData)==null?void 0:It.status)==null?void 0:$t.toUpperCase())==="BREAK"||((Nt=(_t=e.callData)==null?void 0:_t.status)==null?void 0:Nt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:p({},((Mt=(Ot=e.callData)==null?void 0:Ot.status)==null?void 0:Mt.toUpperCase())==="BREAK"||((Ht=(Bt=e.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="MISSED"?u:s),disabled:Te,children:(0,d.jsx)(L.SupportAgent,{})})}),(0,d.jsx)(R.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,d.jsx)(R.Button,{variant:e.isHolding&&((Ft=(wt=e.callData)==null?void 0:wt.status)==null?void 0:Ft.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:r=>{r.stopPropagation(),mn()},sx:e.isHolding&&((Xt=(Qt=e.callData)==null?void 0:Qt.status)==null?void 0:Xt.toUpperCase())==="ONCALL"?p({},s):((Kt=(jt=e.callData)==null?void 0:jt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((Jt=(Wt=e.callData)==null?void 0:Wt.status)==null?void 0:Jt.toUpperCase())!=="ONCALL"&&!e.isHolding||Ee,children:Ee?(0,d.jsx)(R.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?(0,d.jsx)(L.PlayArrow,{}):(0,d.jsx)(L.Pause,{})})}),(0,d.jsx)(R.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,d.jsx)(R.Button,{variant:e.isMuted&&((Gt=(qt=e.callData)==null?void 0:qt.status)==null?void 0:Gt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:r=>{r.stopPropagation(),Cn()},sx:e.isMuted&&((Vt=(Yt=e.callData)==null?void 0:Yt.status)==null?void 0:Vt.toUpperCase())==="ONCALL"?p({},s):((Zt=(zt=e.callData)==null?void 0:zt.status)==null?void 0:Zt.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((to=(eo=e.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())!=="ONCALL"&&!e.isMuted||Se,children:Se?(0,d.jsx)(R.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?(0,d.jsx)(L.MicOff,{}):(0,d.jsx)(L.Mic,{})})}),!((oo=e.sdkConfig)!=null&&oo.disableCallTransferButton)&&(0,d.jsx)(R.Tooltip,{title:"Transfer Call",children:(0,d.jsx)(R.Button,{variant:e.openCallTransferDialog?"contained":"outlined",onClick:r=>{var b,H;((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="ONCALL"&&(r.stopPropagation(),x.setOpenCallTransferDialog(!0))},sx:e.openCallTransferDialog?p({},s):((ao=(no=e.callData)==null?void 0:no.status)==null?void 0:ao.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((io=(so=e.callData)==null?void 0:so.status)==null?void 0:io.toUpperCase())!=="ONCALL",children:(0,d.jsx)(L.TransferWithinAStation,{})})}),!((ro=e.sdkConfig)!=null&&ro.disableConferenceButton)&&(0,d.jsx)(R.Tooltip,{title:"Conference Call",children:(0,d.jsx)(R.Button,{variant:e.openConferenceDialog?"contained":"outlined",onClick:r=>{var b,H;((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="ONCALL"&&(r.stopPropagation(),x.setOpenConferenceDialog(!0))},sx:e.openConferenceDialog?p({},s):((po=(lo=e.callData)==null?void 0:lo.status)==null?void 0:po.toUpperCase())==="ONCALL"?p({},u):p({},i),disabled:((uo=(co=e.callData)==null?void 0:co.status)==null?void 0:uo.toUpperCase())!=="ONCALL",children:(0,d.jsx)(L.Group,{})})}),!((go=e.sdkConfig)!=null&&go.disableEndCallButton)&&(0,d.jsx)(R.Tooltip,{title:"End Call",children:(0,d.jsx)(R.Button,{variant:((Uo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:Uo.toUpperCase())==="ONCALL"||((mo=(Ro=e.callData)==null?void 0:Ro.status)==null?void 0:mo.toUpperCase())==="RINGING"||((xo=(Co=e.callData)==null?void 0:Co.status)==null?void 0:xo.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:r=>{var b,H,ae,re,ge,fe;(((H=(b=e.callData)==null?void 0:b.status)==null?void 0:H.toUpperCase())==="ONCALL"||((re=(ae=e.callData)==null?void 0:ae.status)==null?void 0:re.toUpperCase())==="RINGING"||((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())==="WRAPUP")&&(r.stopPropagation(),S(!0))},sx:((ho=(bo=e.callData)==null?void 0:bo.status)==null?void 0:ho.toUpperCase())==="ONCALL"||((Eo=(Do=e.callData)==null?void 0:Do.status)==null?void 0:Eo.toUpperCase())==="RINGING"||((To=(So=e.callData)==null?void 0:So.status)==null?void 0:To.toUpperCase())==="WRAPUP"?J(p({},s),{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}`}}):J(p({},i),{minWidth:"60px !important"}),disabled:((yo=(Lo=e.callData)==null?void 0:Lo.status)==null?void 0:yo.toUpperCase())!=="ONCALL"&&((Po=(Ao=e.callData)==null?void 0:Ao.status)==null?void 0:Po.toUpperCase())!=="RINGING"&&((vo=(ko=e.callData)==null?void 0:ko.status)==null?void 0:vo.toUpperCase())!=="WRAPUP"||Le,children:Le?(0,d.jsx)(R.CircularProgress,{size:"20px",color:"error"}):(0,d.jsx)(L.CallEnd,{})})})]})]})})})}),(0,d.jsx)(R.Fade,{in:!0,timeout:300,children:(0,d.jsxs)(R.Paper,{ref:oe,elevation:te?4:1,sx:{position:"absolute",left:V.x,top:V.y,borderRadius:2,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:O&&!((Io=e.sdkConfig)!=null&&Io.disableSoftPhone)?"visible":"hidden",userSelect:"none"},children:[(0,d.jsxs)(R.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll",padding:"0px 10px"},onMouseDown:ue,onTouchStart:ve,children:[(0,d.jsx)(L.DragIndicator,{sx:{transform:"rotate(90deg)",color:"#7b7b7b"}})," ",(0,d.jsx)(R.IconButton,{onClick:()=>I(!1),children:(0,d.jsx)(L.Close,{})})]}),(0,d.jsx)(R.Box,{children:(0,d.jsx)("iframe",{src:`https://${Xe}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${($o=e.process)==null?void 0:$o.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})})]})}),(0,d.jsx)(R.Menu,{anchorEl:z,open:!!z,onClose:Qe,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(R.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(R.TextField,{size:"small",value:B,placeholder:"Enter Mobile No.",onChange:r=>{K(r.target.value)}}),(0,d.jsx)(R.IconButton,{color:"info",onClick:()=>{Rn(B)},children:$e?(0,d.jsx)(R.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,d.jsx)(L.Phone,{color:"success"})})]})}),(0,d.jsx)(R.Menu,{anchorEl:M,open:!!M,onClose:gn,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsx)(R.MenuItem,{onClick:()=>Un("Lunch"),children:"- Break"})}),(0,d.jsx)(R.Menu,{anchorEl:E,open:!!E,onClose:we,onClick:r=>r.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(R.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(R.Chip,{icon:(0,d.jsx)(L.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,d.jsx)(R.Chip,{icon:(0,d.jsx)(L.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,d.jsx)(R.Chip,{icon:(0,d.jsx)(L.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!e.openConferenceDialog&&(0,d.jsx)(nn,{}),!!e.openCallTransferDialog&&(0,d.jsx)(an,{open:e.openCallTransferDialog}),!!$&&(0,d.jsx)(sn,{open:$,setOpen:S,onSubmitDisposition:xn}),!!se&&(0,d.jsx)(ln,{open:se,setOpen:ie})]})}var cn=require("react");var un=require("react/jsx-runtime"),nt=(0,cn.memo)(({children:t})=>(0,un.jsx)(tn,{children:t}));nt.displayName="SDKProvider";var at=require("react/jsx-runtime"),st=(0,Ye.memo)(({onDataChange:t})=>{let o=(0,Ye.useCallback)(e=>{try{t&&typeof t=="function"&&t(e)}catch(l){console.error("Error in CallControlPanel data change handler:",l)}},[t]);return(0,at.jsx)(nt,{children:(0,at.jsx)(pn,{onDataChange:o})})});st.displayName="CallControlPanel";async function Xn({apiKey:t,tenantId:o,agentId:e,sdkConfig:l}){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("SDK initialization failed: API key is required and must be a non-empty string");if(!o||typeof o!="string"||o.trim().length===0)throw new Error("SDK initialization failed: Tenant ID is required and must be a non-empty string");if(!e||typeof e!="string"||e.trim().length===0)throw new Error("SDK initialization failed: Agent ID is required and must be a non-empty string");try{let i=await tt.init({apiKey:t.trim(),tenantId:o.trim(),agentId:e.trim(),baseUrl:w});if(i)console.log("SDK initialized successfully"),x.initialize(t.trim(),o.trim(),e.trim(),l,i);else throw console.error("SDK initialization failed: Event tracker initialization returned false"),x.setInitCheck(),new Error("SDK initialization failed: Unable to establish connection with the CTI system")}catch(i){throw console.error("SDK initialization error:",i),x.setInitCheck(),i instanceof Error?i:new Error(`SDK initialization failed: ${String(i)}`)}}function jn(){return"6.x.x"}function Kn(){return x.getState().isInitialized}0&&(module.exports={CallControlPanel,getSDKVersion,initSDK,isSDKInitialized,useClickToCall,useEndCall,useGetAuthorizationToken,useGetCallerData,useLogout});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|