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