1import{r as e,a as t}from"./react-vendor-690ef4bc.js";import{B as a,g as l,F as n,R as r,a as s,e as i}from"./icons-142e3e49.js";import{m as o,A as c}from"./utils-b81ec68d.js";import{C as m,u as d,c as u}from"./useLiveTranscript-1237a3da.js";import{D as g}from"./Dropdown-c7653ff8.js";import{S as p}from"./skeleton-loader-c65511d9.js";import{A as f,c as b}from"./index-d3072779.js";import"./mui-core-0fc19580.js";import"./signalr-17eac150.js";const v=({className:n,callType:r="outbound",onViewDetails:s,callData:i,isSelected:c=!1,liveParticipant:m,liveSentiment:d,liveBullets:u,...g})=>{const[p,f]=e.useState(!1),b={ringing:{bg:"bg-blue-100",text:"text-blue-600",border:"border-blue-200",dot:"bg-blue-500",icon:"ð",animation:!1},live:{bg:"bg-green-50",text:"text-green-600",border:"border-green-200",dot:"bg-green-500",icon:"ð",animation:!0},ended:{bg:"bg-red-100",text:"text-red-500",border:"border-red-200",dot:"bg-red-400",icon:"ð´",animation:!1},"no answer":{bg:"bg-yellow-100",text:"text-yellow-600",border:"border-yellow-200",dot:"bg-yellow-500",icon:"â",animation:!1},failed:{bg:"bg-red-50",text:"text-red-600",border:"border-red-100",dot:"bg-red-300",icon:"â",animation:!1},initiated:{bg:"bg-yellow-50",text:"text-yellow-600",border:"border-yellow-200",dot:"bg-yellow-400",icon:"â±ï¸",animation:!1},default:{bg:"bg-gray-100",text:"text-gray-500",border:"border-gray-200",dot:"bg-gray-400",icon:"ð",animation:!1}},v={live:"live",ended:"ended",ringing:"ringing","no-answer":"no answer","no answer":"no answer",missed:"no answer",noanswer:"no answer",failed:"failed",initiated:"initiated"},E=e=>{if(0===e)return"0 sec";if(e<60)return`${e} sec`;const t=Math.floor(e/60),a=e%60;return 0===a?`${t} min`:`${t} min ${a} sec`},x=e=>{switch(e?.toLowerCase()){case"live":return"Live";case"ended":return"Ended";case"ringing":return"Ringing";case"no answer":case"no-answer":return"No Answer";case"failed":return"Failed";default:return e||"Ended"}},y=(()=>{if(!i?.statusOfCall)return b.default;const e=i.statusOfCall.toLowerCase().trim();return b[v[e]??"default"]??b.default})(),h="live"===i?.statusOfCall,w="ended"===i?.statusOfCall,N=h||w;return u&&u.length,t.createElement("div",{className:`w-full h-full bg-grey-100 rounded-[20px] p-1 pb-3 flex flex-col gap-3 items-center min-h-[520px] ${n} ${c?"ring-2 ring-green-400 ring-opacity-50":""}`},t.createElement("div",{className:`${c?"bg-green-50":p&&N?"bg-grey-50":"bg-white"} rounded-2xl p-4 flex flex-col gap-3 w-full h-full relative ${c?"shadow-lg shadow-green-100/50":p&&N?"shadow-md":"shadow-sm"} ${c?"border-2 border-green-500 shadow-green-100":p?"border border-green-300 border-2 shadow-md":"border border-grey-200"} transition-all duration-200`,onClick:N?()=>{N&&s&&s()}:void 0,onMouseEnter:()=>{f(!0)},onMouseLeave:()=>{f(!1)},role:N?"button":void 0,tabIndex:N?0:-1,onKeyDown:e=>{N&&("Enter"===e.key||" "===e.key)&&s&&(e.preventDefault(),s())},"aria-label":N?"View call transcript":"Call card","aria-selected":c},c&&t.createElement("div",{className:"absolute -top-2 -right-2 w-6 h-6 bg-green-500 rounded-full flex items-center justify-center"},t.createElement("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",d:"M5 13l4 4L19 7"}))),t.createElement("div",{className:"flex items-start justify-between w-full"},t.createElement("div",{className:"flex flex-col gap-1"},t.createElement("div",{className:"flex items-start gap-2"},t.createElement(a,{className:"shrink-0"}),t.createElement("span",{className:"text-sm font-semibold "+(c?"text-green-700":"text-black")},i?.brokerCompany||"â")),i?.brokerName&&t.createElement("span",{className:"text-grey-600 text-xs pl-7"},i.brokerName)),t.createElement("div",{className:`${y.bg} rounded-full border ${y.border} px-2 py-1 flex items-center gap-1 relative ${c?"border-green-300":""}`,onClick:e=>e.stopPropagation()},t.createElement(l,{className:"shrink-0"}),t.createElement("span",{className:`${y.text} text-xs font-medium flex items-center gap-1 whitespace-nowrap`},y.animation&&t.createElement(o.div,{className:`w-2 h-2 rounded-full ${y.dot}
1 shrink-0`,animate:{opacity:[1,.3,1],scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"}}),x(i?.statusOfCall||"ended")))),t.createElement("div",{className:"flex flex-col gap-3 w-full"},t.createElement("div",{className:`border-t ${c?"border-green-200":"border-grey-200"} w-full`}),t.createElement("div",{className:"flex items-center gap-2 flex-wrap"},i?.callTimestamp&&t.createElement(t.Fragment,null,t.createElement("span",{className:"text-xs "+(c?"text-green-600":"text-grey-500")},(e=>{try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch(t){return"Invalid date"}})(i.callTimestamp)),t.createElement("div",{className:"rounded-full w-1 h-1 "+(c?"bg-green-400":"bg-grey-500")}),t.createElement("span",{className:"text-xs "+(c?"text-green-600":"text-grey-500")},(e=>{try{return new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(t){return"Invalid time"}})(i.callTimestamp)),t.createElement("div",{className:"rounded-full w-1 h-1 "+(c?"bg-green-400":"bg-grey-500")}),t.createElement("span",{className:"text-xs "+(c?"text-green-600":"text-grey-500")},E(i.callDuration)))),t.createElement("div",{className:`border-t ${c?"border-green-200":"border-grey-200"} w-full`}),t.createElement("div",{className:"flex flex-col gap-1.5 w-full"},t.createElement("div",{className:"flex justify-between w-full"},t.createElement("span",{className:"text-xs "+(c?"text-green-500":"text-grey-500")},"Participant:"),t.createElement("span",{className:"text-xs "+(c?"text-green-700":"text-black")},h?m||"â":i?.brokerName||"â")),t.createElement("div",{className:"flex justify-between w-full items-center"},t.createElement("span",{className:"text-xs "+(c?"text-green-500":"text-grey-500")},"Sentiment:"),t.createElement("div",{className:"flex items-center gap-1 text-xs"},(e=>{if(!e)return"â";const a={positive:{text:"text-green-600",bg:"bg-green-50",icon:"ð"},negative:{text:"text-red-600",bg:"bg-red-50",icon:"ð"},neutral:{text:"text-gray-600",bg:"bg-gray-50",icon:"ð"}},l=a[e.toLowerCase()]||a.neutral;return t.createElement("span",{className:`${l.text} font-medium capitalize`},e)})(h?d??null:i?.sentiment??null))),t.createElement("div",{className:"flex justify-between w-full"},t.createElement("span",{className:"text-xs "+(c?"text-green-500":"text-grey-500")},"Phone #:"),t.createElement("span",{className:"text-xs "+(c?"text-green-600":"text-green-500")},i?.brokerNumber||"â"))),t.createElement("div",{className:`border-t ${c?"border-green-200":"border-grey-200"} w-full`}),t.createElement("div",{className:"text-xs w-full "+(c?"text-green-800":"text-black")},t.createElement("p",{className:"font-semibold mb-1"},h?"Live Call Summary":"Call Summary"),h?t.createElement("div",{className:"pl-5 text-gray-500 italic flex items-center gap-2"},t.createElement("span",{className:"animate-pulse"},"Listening"),t.createElement("span",{className:"animate-pulse delay-150"},"·"),t.createElement("span",{className:"animate-pulse delay-300"},"·"),t.createElement("span",{className:"animate-pulse delay-500"},"·")):w&&i?.summaryBullets?.length?t.createElement("ul",{className:"space-y-1 list-disc pl-5 transition-opacity duration-200"},i.summaryBullets.map((e,a)=>t.createElement("li",{key:a},e))):t.createElement("ul",{className:"space-y-1 list-disc pl-5"},t.createElement("li",null,"Company: ",i?.brokerCompany||"Unknown"),t.createElement("li",null,"Duration: ",i?E(i.callDuration):"N/A"),t.createElement("li",null,"Status: ",x(i?.statusOfCall||"ended")),t.createElement("li",null,"Sentiment:"," ",i?.sentiment?i.sentiment.charAt(0).toUpperCase()+i.sentiment.slice(1):"N/A"))))),t.createElement("button",{className:"rounded-full px-3 py-2.5 flex items-center justify-center gap-2.5 w-[252px] transition-colors "+(N?c?"bg-green-100 hover:bg-green-200 text-green-700":"bg-grey-200 hover:bg-grey-300":"bg-grey-100 cursor-not-allowed"),onClick:N?s:void 0,disabled:!N,title:N?"View call details":"No transcript available","aria-label":N?"View call transcript":"No transcript available"},t.createElement("span",{className:"text-sm font-medium "+(c?"text-green-700":N?"text-black":"text-grey-400")},N?"View Details":"No transcript available"),c&&N&&t.createElement("svg",{className:"w-4 h-4 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 5l7 7-7 7"}))))},E=({className:a,onClose:l,...i})=>{const[o,c]=e.useState(""),[d,u]=e.useState("");e.useState(!1),e.useState(null);const[p,f]=e.useState((new Date).getMonth()),[b,v]=e.useState((new Date).getFullYear()),[E,x]=e.useState(""),[y,h]=e.useState(null),[w,N]=e.useState(null);return t.createElement("div",{className:"bg-[#ffffff] rounded-2xl border-solid border-grey-colors-grey-200 border p-6 flex flex-col gap-0 items-center justify-start h-[936px] relative overflow-hidden "+a,style:{boxShadow:"-20px 20px 40px -4px rgba(136, 139, 161, 0.12)"}},t.createElement("div",{className:"flex flex-col gap-6 items-start justify-start self-stretch shrink-0 relative"},t.createElement("div",{className:"flex flex-row items-center justify-between self-stretch shrink-0 relative"},t.createElement("div",{className:"flex flex-row gap-3 items-center justify-start shrink-0 relative"},t.createElement(n,{strokeColor:"#30B87A",width:24,height:24}),t.createElement("div",{className:"text-basic-colors-black text-left font-h2-font-family text-h2-font-size leading-h2-line-height font-h2-font-we
1ight relative"},"Filters"," ")),t.createElement("div",{className:"flex flex-row gap-2 items-center justify-start shrink-0 relative"},t.createElement("div",{className:"bg-grey-colors-grey-100 rounded-[50px] p-2.5 flex flex-row gap-2.5 items-center justify-center shrink-0 relative cursor-pointer",onClick:()=>{c(""),u(""),h(null),N(null),x("");const e=new Date;f(e.getMonth()),v(e.getFullYear())}},t.createElement(r,null)),t.createElement("div",{className:"bg-grey-colors-grey-100 rounded-[50px] p-2.5 flex flex-row gap-2.5 items-center justify-center shrink-0 relative cursor-pointer",onClick:l},t.createElement(s,null)))),t.createElement("div",{className:"border-dashed border-grey-colors-grey-200 border-t border-r-[0] border-b-[0] border-l-[0] self-stretch shrink-0 h-0 relative",style:{marginTop:"-1px",transformOrigin:"0 0",transform:"rotate(0deg) scale(1, 1)"}}),t.createElement("div",{className:"flex flex-col gap-4 items-start justify-start self-stretch shrink-0 relative"},t.createElement("div",{className:"flex flex-row items-center justify-start self-stretch shrink-0 relative"},t.createElement("div",{className:"text-black-900 text-left font-sans text-text-sm-regular-font-size leading-text-sm-regular-line-height font-text-sm-regular-font-weight relative w-[100px]"},"Company"),t.createElement("div",{className:"relative w-full ml-4"},t.createElement(g,{options:[{label:"Company A",value:"company-a"},{label:"Company B",value:"company-b"},{label:"Company C",value:"company-c"}],selectedValue:o,onSelect:c,placeholder:"Select company",className:"w-full"}))),t.createElement("div",{className:"flex flex-row items-center justify-start self-stretch shrink-0 relative"},t.createElement("div",{className:"text-black-900 text-left font-sans text-text-sm-regular-font-size leading-text-sm-regular-line-height font-text-sm-regular-font-weight relative w-[100px]"},"Participants"," "),t.createElement("input",{type:"text",placeholder:"Enter participants",value:E,onChange:e=>x(e.target.value),className:"bg-grey-colors-grey-100 ml-4 flex flex-row gap-2 items-center justify-center flex-1 relative w-44 h-10 px-4 rounded-3xl border border-gray-300 mr-5 placeholder:text-grey-colors-grey-500"})),t.createElement("div",{className:"flex flex-row items-center justify-start self-stretch shrink-0 relative"},t.createElement("div",{className:"text-black-900 text-left font-sans text-text-sm-regular-font-size leading-text-sm-regular-line-height font-text-sm-regular-font-weight relative w-[100px]"},"Duration:"," "),t.createElement("div",{className:"relative w-full ml-4"},t.createElement(g,{options:[{label:"Short (under 1 min)",value:"short"},{label:"Medium (1â5 min)",value:"medium"},{label:"Long (over 5 min)",value:"long"}],selectedValue:d,onSelect:u,placeholder:"Select duration",className:"w-full"}))),t.createElement("div",{className:"flex flex-row items-center justify-start self-stretch shrink-0 relative"},t.createElement("div",{className:"text-black-900 text-left font-sans text-text-sm-regular-font-size leading-text-sm-regular-line-height font-text-sm-regular-font-weight relative w-[140px]"},"Date range:"),t.createElement(m,{selectedStartDate:y,selectedEndDate:w,onDateSelect:(e,t)=>{h(e),N(t)},className:"w-full"})))))},x=()=>t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},t.createElement("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"})),y=()=>t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},t.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),t.createElement("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})),h=()=>t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},t.createElement("polygon",{points:"5,3 19,12 5,21"})),w=()=>t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},t.createElement("circle",{cx:"11",cy:"11",r:"8"}),t.createElement("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}));function N(e){const t=e.toLowerCase();return t.includes("bot")||t.includes("ai")?"av-bot":t.includes("broker")?"av-broker":"av-driver"}const k=({name:e,time:a,content:l})=>{const n=e.toLowerCase().includes("bot")||e.toLowerCase().includes("ai");return t.createElement("div",{className:"msg"},t.createElement("div",{className:`msg-av ${N(e)}`},function(e){const t=e.toLowerCase();return t.includes("bot")||t.includes("ai")||t.includes("broker")?"B":e.charAt(0).toUpperCase()}(e)),t.createElement("div",{className:"msg-body"},t.createElement("div",{className:"msg-meta"},t.createElement("span",{className:"msg-name"},e),t.createElement("span",{className:"msg-time"},a)),t.createElement("div",{className:"msg-text "+(n?"bot-msg":"")},l)))},C=({messages:e=[],onSearch:a,onCopy:l,onDownload:n,onListen:r,isLoading:s=!1,error:i=null,speakerStats:m={},totalMessages:d=0,foundMessages:u=0,isLiveCall:g=!1,callData:f})=>{const b=e.length>0,v=s||!b;return t.createElement(t.Fragment,null,t.createElement("div",{className:"transcript-toolbar"},t.createElement("div",{className:"search-wrap"},t.createElement("div",{className:"search-icon"},t.createElement(w,null)),t.createElement("input",{type:"text",onCh
1ange:e=>{a?.(e.target.value)},placeholder:"Search...",disabled:v})),t.createElement("button",{type:"button",className:"t-btn",onClick:n,disabled:v},t.createElement(x,null),"Download"),t.createElement("button",{type:"button",className:"t-btn",onClick:l,disabled:v},t.createElement(y,null),"Copy"),t.createElement("button",{type:"button",className:"t-btn t-btn-green",onClick:r,disabled:v},t.createElement(h,null),"Listen")),b&&t.createElement("div",{className:"transcript-stats"},t.createElement("span",null,"Messages: ",t.createElement("strong",null,d)),Object.entries(m).map(([e,a])=>t.createElement("span",{key:e},e.charAt(0).toUpperCase()+e.slice(1),": ",t.createElement("strong",null,a)))),s?t.createElement("div",{className:"messages"},[...Array(5)].map((e,a)=>t.createElement(p,{key:a,height:"60px"}))):i?t.createElement("div",{className:"transcript-empty"},t.createElement("div",{className:"transcript-empty-title"},"Error loading transcript"),t.createElement("div",{className:"transcript-empty-sub"},i)):b?t.createElement("div",{className:"messages"},t.createElement(c,null,e.map((e,a)=>t.createElement(o.div,{key:`${a}-${e.time}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0}},t.createElement(k,{...e}))))):t.createElement("div",{className:"transcript-empty"},t.createElement("div",{className:"transcript-empty-title"},g?"Waiting for live transcript...":"No transcript available"),t.createElement("div",{className:"transcript-empty-sub"},g?"Transcript will appear here as the call progresses":!1===f?.isTranscriptComplete?"Transcript processing is not yet complete":"The transcript for this call is not available")),b&&t.createElement("div",{className:"transcript-footer"},"Showing ",u," of ",d," entries"))};function S(e){return null==e?"â":`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function L(e){return e&&e.trim()?e:"â"}const D={broker_name:"King of Freight LLC",origin:"Phoenix, AZ",destination:"Van Nuys, CA",pickupTime:"Feb 26, 2026 08:00 AM",deliveryTime:"Feb 27, 2026 06:00 PM",tripMiles:412,ratePerMile:2.8,finalRate:1153.6,load_type:"FTL",equipment_type:"Dry Van 53ft",commodity:"General Freight",weight:42e3},T={confirmData:D,sentiment:"negative",bullets:["Load not available - broker
1confirmed it's not available"]};function $(e){return!!e&&Object.values(e).some(e=>null!=e&&""!==e)}function j(e){const t=(e??"").toLowerCase();return t.includes("negative")?"sent-negative":t.includes("positive")?"sent-positive":"sent-neutral"}const I=({callData:e,activeTab:a,onTabChange:l,onClose:n,sentiment:r,transcriptContent:s,confirmContent:i})=>{const o=r??e.sentiment,c=e.brokerName??"Dan",m=function(e){if(null==e||e<=0)return"â";if(e<60)return`${e} sec`;const t=Math.floor(e/60),a=e%60;return a>0?`${t} min ${a} sec`:`${t} min`}(e.callDuration);return t.createElement("div",{className:"call-side-panel"},t.createElement("div",{className:"panel-header"},t.createElement("div",{className:"ph-left"},t.createElement("div",{className:"ph-title"},e.brokerCompany),t.createElement("div",{className:"ph-meta"},t.createElement("span",null,(e=>{try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return"Invalid date"}})(e.callTimestamp)," · ",m," · ",c),o&&t.createElement("span",{className:`sent-badge ${j(o)}`},o))),n&&t.createElement("button",{type:"button",className:"ph-close",onClick:n,"aria-label":"Close panel"},"â")),t.createElement("div",{className:"tabs"},t.createElement("button",{type:"button",className:"tab "+("transcript"===a?"active":""),onClick:()=>l("transcript")},"Transcript"),t.createElement("button",{type:"button",className:"tab "+("confirm"===a?"active":""),onClick:()=>l("confirm")},"Call Confirm Data")),t.createElement("div",{className:"tab-content "+("transcript"===a?"active":"")},s),t.createElement("div",{className:"tab-content "+("confirm"===a?"active":"")},i))},M=({id:e,label:a,value:l,isEdited:n,onChange:r,onFocus:s})=>t.createElement("div",{className:"field-item negotiable "+(n?"edited":""),onClick:()=>{const t=document.getElementById(`confirm-field-${e}`);t?.focus(),t?.select()}},t.createElement("div",{className:"fi-label"},a,t.createElement("span",{className:n?"edited-tag":"negotiate-tag"},n?"edited":"negotiate")),t.createElement("input",{id:`confirm-field-${e}`,className:"fi-input",value:l,onChange:t=>r(e,t.target.value),onFocus:()=>s(e),onClick:e=>e.stopPropagation()})),A=({label:e,value:a})=>t.createElement("div",{className:"field-item"},t.createElement("div",{className:"fi-label"},e),t.createElement("div",{className:"fi-val"},a)),F=({confirmData:a,insights:l,transcriptText:n="",brokerCompany:r,isLoading:s=!1})=>{const i=$(a)?a:D,o=$(a)?l:T,c=e.useMemo(()=>function(e,t){const a=[...e?.bullets??[],t??"",e?.sentiment??""].join(" ").toLowerCase();return["not available","it's not","load not available","no longer available","already covered","already booked"].some(e=>a.includes(e))?{status:"unavailable",title:"Load not available",subtitle:"Broker confirmed on call"}:["still available","load available","is available","confirmed available"].some(e=>a.includes(e))?{status:"available",title:"Load available",subtitle:"Broker confirmed on call"}:{status:"unknown",title:"Availability pending",subtitle:"Waiting for confirmation from call"}}(o,n),[o,n]),m=e.useMemo(()=>{return e=i,{pickup:L(e?.pickupTime),delivery:L(e?.deliveryTime),rpm:null!=e?.ratePerMile?S(e.ratePerMile):"â",final:null!=e?.finalRate?S(e.finalRate):"â",loadType:L(e?.load_type),equipment:L(e?.equipment_type),commodity:L(e?.commodity),weight:null!=e?.weight?(t=e.weight,null==t?"â":`${Number(t).toLocaleString()} lbs`):"â"};var e,t},[i]),[d,u]=e.useState(m),[g,p]=e.useState(new Set);e.useEffect(()=>{u(m),p(new Set)},[m]);const f=(e,t)=>{u(a=>({...a,[e]:t}))},v=e=>{p(t=>new Set(t).add(e))},E="â"!==L(i?.broker_name)?i?.broker_name:r??"King of Freight LLC";if(s&&$(a))return t.createElement("div",{className:"confirm-content",style:{display:"flex",alignItems:"center",justifyContent:"center"}},t.createElement("span",{style:{fontSize:12,color:"#888"}},"Loading confirm data..."));const x="available"===c.status?"available":"unavailable"===c.status?"unavailable":"pending",y="available"===c.status?"avail-dot-g":"unavailable"===c.status?"avail-dot-r":"avail-dot-grey",h="available"===c.status?"avail-text-g":"unavailable"===c.status?"avail-text-r":"avail-text-grey",w="unavailable"===c.status?"avail-sub-r":"avail-sub-default";return t.createElement(t.Fragment,null,t.createElement("div",{className:"confirm-content"},t.createElement("div",{className:`avail-row ${x}`},t.createElement("div",{className:"avail-left"},t.createElement("div",{className:`avail-dot ${y}`}),t.createElement("div",null,t.createElement("div",{className:`avail-text ${h}`},c.title),t.createElement("div",{className:`avail-sub ${w}`},c.subtitle)))),t.createElement("div",{className:"section-label"},"Load details"),t.createElement("div",{className:"fields-grid"},t.createElement(A,{label:"Origin",value:L(i?.origin)}),t.createElement(A,{label:"Destination",value:L(i?.destination)}),t.createElement(M,{id:"pickup",label:"Pickup date & time",value:d.pickup,isEdited:g.has("pickup"),onChange:f,onFocus:v}),t.createElement(M,{id:"delivery",label:"Delivery date & time",value:d.delivery,isEdited:g.has("delivery"),onChange:f,onFocus:v}),t.createElement(A,{label:"Trip miles",value:(N=i?.tripMiles,null==N?"â":`${Number(N).toLocaleStr
1ing()} mi`)}),t.createElement(A,{label:"Broker",value:L(E)})),t.createElement("div",{className:"section-label"},"Rate & load â negotiate changes below"),t.createElement("div",{className:"fields-grid"},t.createElement(M,{id:"rpm",label:"Rate per mile",value:d.rpm,isEdited:g.has("rpm"),onChange:f,onFocus:v}),t.createElement(M,{id:"final",label:"Final rate",value:d.final,isEdited:g.has("final"),onChange:f,onFocus:v}),t.createElement(M,{id:"loadType",label:"Load type",value:d.loadType,isEdited:g.has("loadType"),onChange:f,onFocus:v}),t.createElement(M,{id:"equipment",label:"Equipment type",value:d.equipment,isEdited:g.has("equipment"),onChange:f,onFocus:v}),t.createElement(M,{id:"commodity",label:"Commodity",value:d.commodity,isEdited:g.has("commodity"),onChange:f,onFocus:v}),t.createElement(M,{id:"weight",label:"Weight",value:d.weight,isEdited:g.has("weight"),onChange:f,onFocus:v}))),t.createElement("div",{className:"book-section"},t.createElement("div",{className:"book-note"},t.createElement("strong",null,"Tip:")," Edit any negotiable field above to propose your own terms before booking. Your values will be sent with the booking request."),t.createElement("button",{type:"button",className:"book-btn",onClick:()=>{Object.fromEntries([...g].map(e=>[e,d[e]]));b.success("Booking request submitted",{duration:3e3})}},t.createElement("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},t.createElement("polyline",{points:"20,6 9,17 4,12"})),"Book Load")));var N},B=({callData:a,onClose:l,className:n,liveTranscript:r,liveInsights:s,...i})=>{const o="live"===a?.statusOfCall,[c,m]=e.useState("transcript"),[u,g]=e.useState(),{insights:p,aiProcessingCompleteByCall:v}=d(),{transcript:E,isLoading:x,error:y,fetchTranscript:h,clearTranscript:w}=(()=>{const[t,a]=e.useState(null),[l,n]=e.useState(!1),[r,s]=e.useState(null);return{transcript:t,isLoading:l,error:r,fetchTranscript:e.useCallback(async e=>{if(e){n(!0),s(null);try{const t=sessionStorage.getItem("authToken");if(!t)throw new Error("Authentication token not found");const l=await fetch(`${f.BASE_URL}/Transcript/gettranscript`,{method:"POST",headers:{accept:"*/*",Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({callId:e})});if(!l.ok){const e=await l.json().catch(()=>({})),t=e.errorMessage||e.message||"Failed to fetch transcript";return b.error(t,{duration:3e3}),void s(t)}const n=await l.json();n.results&&n.results.length>0?a(n):(a({total:0,results:[]}),b.info("No transcript available for this call",{duration:3e3}))}catch(t){const e=t instanceof Error?t.message:"Failed to fetch transcript";b.error(e,{duration:3e3}),s(e),a(null)}finally{n(!1)}}else s("Call ID is required")},[]),clearTranscript:e.useCallback(()=>{a(null),s(null)},[])}})(),[N,k]=e.useState(""),[S,L]=e.useState([]),D=a?.callId?`calls:insights:${a.callId}`:null;e.useEffect(()=>{if(a?.callId&&!o)return h(a.callId),()=>{w()}},[a?.callId,o,h,w]),e.useEffect(()=>{if(D)try{const e=localStorage.getItem(D);g(e?JSON.parse(e):void 0)}catch{g(void 0)}else g(void 0)},[D]);const T=a?.callId?p[a.callId]:void 0,$=!!a?.callId&&!!v[a.callId];e.useEffect(()=>{if(!D||!a?.callId)return;const e=s??T;if(e&&($||a.isAIProcessingComplete)){try{localStorage.setItem(D,JSON.stringify(e))}catch{}g(e)}},[D,a?.callId,a?.isAIProcessingComplete,s,T,$]);const j=e.useMemo(()=>u??s??T??void 0,[u,s,T]),M=o?r??[]:E?.results??[];if(e.useEffect(()=>{if(!M.length)return void L([]);const e=M.map(e=>{let t="blue";t=["bot","ai"].includes(e.speaker.toLowerCase())?"blue":e.speaker.toLowerCase().includes("broker")?"green":"orange";return{speaker:e.speaker.charAt(0).toUpperCase(),name:e.speaker,time:(e=>{try{const t=new Date(e),a=new Date(M[0].timestamp).getTime(),l=Math.floor((t.getTime()-a)/1e3),n=Math.floor(l/60);return`${n}:${(l%60).toString().padStart(2,"0")}`}catch{return"0:00"}})(e.timestamp),content:e.text,color:t}}),t=N?e.filter(e=>e.content.toLowerCase().includes(N.toLowerCase())||e.name.toLowerCase().includes(N.toLowerCase())):e;L(t)},[M,N]),e.useEffect(()=>{m("transcript"),k("")},[a?.callId]),!a)return null;const A=o?M.reduce((e,t)=>
1{const a=t.speaker.toLowerCase();return e[a]=(e[a]||0)+1,e},{}):(E?.results??[]).reduce((e,t)=>{const a=t.speaker.toLowerCase();return e[a]=(e[a]||0)+1,e},{}),B=M.map(e=>e.text).join(" ");return t.createElement(I,{callData:a,activeTab:c,onTabChange:m,onClose:l,sentiment:j?.sentiment??a.sentiment,transcriptContent:t.createElement(C,{className:n,callData:a,messages:S,onSearch:e=>k(e),onCopy:()=>{if(!M.length)return void b.error("No transcript to copy",{duration:2e3});const e=M.map(e=>`[${e.timestamp}] ${e.speaker}: ${e.text}`).join("\n");navigator.clipboard.writeText(e),b.success("Transcript copied",{duration:2e3})},onDownload:()=>{if(!M.length)return void b.error("No transcript to download",{duration:2e3});const e=M.map(e=>`[${e.timestamp}] ${e.speaker}: ${e.text}`).join("\n"),t=new Blob([e],{type:"text/plain"}),l=URL.createObjectURL(t),n=document.createElement("a");n.href=l,n.download=`transcript-${a.callId.slice(0,8)}.txt`,n.click(),URL.revokeObjectURL(l)},onListen:()=>{b.info("Audio playback coming soon")},isLoading:!o&&x,error:o?null:y,speakerStats:A,totalMessages:M.length,foundMessages:S.length,isLiveCall:o,...i}),confirmContent:t.createElement(F,{confirmData:j?.confirmData,insights:j,transcriptText:B,brokerCompany:a.brokerCompany,isLoading:!o&&x})})},O=({className:a,...l})=>{const[n,r]=e.useState("all"),[s,m]=e.useState(!1),[g,x]=e.useState(!1),[y,h]=e.useState(null),[w,N]=e.useState("newest-first"),k={visible:{opacity:1,y:0,scale:1,transition:{type:"spring",stiffness:100,damping:15,mass:.5}},exit:{opacity:1,y:-20,scale:.95,transition:{duration:.2}},hover:{y:-4,scale:1.02},tap:{scale:.98}},{callsData:C,isLoading:S,error:L}=((t=4e3)=>{const[a,l]=e.useState([]),[n,r]=e.useState(!0),[s,i]=e.useState(null),[o,c]=e.useState(!0),m=e.useRef(null),d=e.useRef(!0),u=e.useRef(!1),g=()=>{m.current&&(clearInterval(m.current),m.current=null)},p=e=>{u.current||(b.error(e,{duration:3e3}),u.current=!0,setTimeout(()=>{u.current=!1},3e3))},v=e.useCallback(async()=>{if(!s||o)try{const e=sessionStorage.getItem("authToken");if(!e)throw new Error("Authentication token not found");const t=await fetch(`${f.BASE_URL}/call/get-calls`,{method:"GET",headers:{accept:"*/*",Authorization:`Bearer ${e}`}});if(!t.ok){const e=await t.json().catch(()=>({})),a=e.errorMessage||e.message||"Unable to fetch calls. Please try again.";return p(a),d.current&&(i(a),c(!1),l([])),void g()}const a=await t.json();if(!a.data||!Array.isArray(a.data)){if(a.message)p(a.message),d.current&&(l([]),i(a.message),c(!1));else{const e=a.errorMessage||a.message||"No calls data found";p(e),d.current&&(l([]),i(e),c(!1))}return void g()}if(0===a.data.length)return a.message?(p(a.message),d.current&&(l([]),i(a.message),c(!1))):(p("No calls found"),d.current&&(l([]),i("No calls found"),c(!1))),void g();d.current&&(l(a.data),i(null),u.current=!1),!o&&d.current&&c(!0)}catch(e){const t=e instanceof Error?e.message:"Unable to fetch calls. Please try again.";p(t),d.current&&(i(t),c(!1),l([])),g()}finally{d.current&&r(!1)}},[s,o]);return e.useEffect(()=>(d.current=!0,v(),t>0&&o&&(g(),m.current=setInterval(v,t)),()=>{d.current=!1,g()}),[v,t,o]),{callsData:a,isLoading:n,error:s,refetch:async()=>{r(!0),u.current=!1,await v()},resetPolling:()=>{u.current=!1,d.current&&(i(null),c(!0),r(!0)),g(),v(),t>0&&(m.current=setInterval(v,t))}}})(),{transcripts:D,insights:T}=d(),$=e.useMemo(()=>[...C.filter(e=>"all"===n||e.statusOfCall===n)].sort((e,t)=>{const a=new Date(e.callTimestamp).getTime(),l=new Date(t.callTimestamp).getTime();return"newest-first"===w?l-a:a-l}),[C,n,w]),j=e.useRef(new Set);e.useEffect(()=>{$&&0!==$.length&&$.forEach(e=>{"live"===e.statusOfCall?j.current.has(e.callId)||(u.joinCall(e.callId),j.current.add(e.callId)):j.current.has(e.callId)&&(u.leaveCall(e.callId),j.current.delete(e.callId))})},[$]);const I=()=>{m(!s),s||(x(!1),h(null))},M=()=>{x(!1),h(null)};return t.createElement("div",{className:`routes-container w-full ${a}`},t.createElement(c,null,s&&t.createElement("div",{className:"fixed inset-0 z-40"},t.createElement(o.div,{className:"fixed inset-0 bg-black/50",onClick:I,initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}}),t.createElement(o.div,{className:"fixed right-0 top-0 h-full w-80 bg-white shadow-lg z-50",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30}},t.createElement(E,{onClose:I})))),t.createElement(c,null,g&&t.createElement("div",{className:"fixed inset-0 z-40"},t.createElement(o.div,{className:"fixed inset-0 bg-black/50",onClick:M,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3}}),t.createElement(o.div,{className:"fixed right-0 top-0 h-full w-[30%] min-w-[320px] bg-white shadow-lg z-50",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30}},(()=>{const e=y?C.find(e=>e.callId===y):null;return e?t.createElement(B,{callData:e,onClose:M,liveTranscript:"live"===e.statusOfCall?D[e.callId]??[]:void 0,liveInsights:T[e.callId]}):null})()))),t.createElement("div",{className:"pt-6 pb-6 flex flex-col gap-6 items-start justify-start flex-1 relative"},t.createElement("div",{className:"routes-header"},t.createElement("div",{className:"flex flex-row gap-3 items-center"},t.createElement("h1",{className:"routes-title"},"Calls")),t.createElement("div",{className:"flex flex-row gap-2 items-center"},t.createElement("div",{className:"routes-tabs-container"},t.createElement("button",{className:"routes-tab "+("all"===n?"routes-tab-active":"routes-tab-inactive"),onClick:()=>{r("all"),g&&h(null)}},"All"),t.createElement("button",{className:"routes-tab "+("ringing"===n?"routes-tab-active":"routes-tab-inactive"),onClick:()=>{r("ringing"),g&&h(null)}},"Ringing"),t.createElement("button",{className:"routes-tab "+("live"===n?"routes-tab-active":"routes-tab-inactive"),onClick:()=>{r("live"),g&&h(null)}},"Live"),t.createElement("button",{className:"routes-tab "+("ended"===n?"routes-tab-active":"routes-tab-inactive"),onClick:()=>{r("ended"),g&&h(null)}},"Ended"),t.createElement("button",{className:"routes-tab "+("no-answer"===n?"routes-tab-active":"routes-tab-inactive"),onClick:()=>{r("no-answer"),g&&h(null)}},"No Answer"),t.createElement("button",{className:"routes-tab "+("failed"===n?"routes-tab-active":"routes-tab-inactive"),onClick:()=>{r("failed"),g&&h(null)}},"Failed")),t.createElement("div",{className:"flex flex-row gap-2 items-center"},t.createElement(o.button,{className:"sort-button",onClick:()=>{N(e=>"newest-first"===e?"oldest-first":"newest-first"),g&&h(null)},whileHover:{scale:1.05},whileTap:{scale:.95}},t.createElement(i,null),t.createElement("span",{className:"sort-label"},"Sort by:"),t.createElement(o.span,{key:w,className:"sort-value",initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3}},"newest-first"===w?"Newest first":"Oldest first"))))),S&&t.createElement(o.div,{className:"grid grid-cols-12 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6 w-full",initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.3}},[...Array(6)].map((e,a)=>t.createElement(o.div,{key:a,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1,transition:{delay:.1*a,duration:.3}}},t.createElement(p,null)))),!S&&L&&t.createElement("div",{className:"grid grid-cols-12 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6 w-full"},[...Array(6)].map((e,a)=>t.createElement(p,{key:a}))),!S&&!L&&t.createElement(c,{mode:"wait"},t.createElement(o.div,{key:`${n}-${w}`,className:"grid grid-cols-12 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6 w-full",variants:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.1,delayChildren:.2}}},initial:"hidden",animate:"visible",exit:"hidden"},$.length>0?$.map(e=>{const a=y===e.callId&&g,l="live"===e.statusOfCall?T[e.callId]:void 0,n=l?.confirmData?.broker_name??null,r=l?.sentiment??null,s=l?.bullets??null;return t.createElement(o.div,{key:e.callId,variants:k,layout:!0,initial:"hidden",animate:a?"selected":"visible",exit:"exit",whileHover:"hover",whileTap:"tap",transition:{layout:{duration:.3}},className:"relative rounded-xl overflow-hidden"},t.createElement(o.div,{className:"absolute inset-0 bg-gradient-to-r from-emerald-400/10 via-green-400/10 to-teal-400/10 rounded-xl",initial:{opacity:0}
1,animate:{opacity:a?1:0},whileHover:{opacity:1},transition:{duration:.2}}),t.createElement(o.div,{className:"absolute inset-0 border-3 border-transparent rounded-xl",animate:{borderColor:a?"rgba(16, 185, 129, 0.6)":"transparent",boxShadow:a?"inset 0 0 25px rgba(16, 185, 129, 0.15)":"none"},whileHover:{borderColor:"rgba(16, 185, 129, 0.6)",boxShadow:"inset 0 0 25px rgba(16, 185, 129, 0.15)"},transition:{duration:.2}}),t.createElement(v,{callType:"outbound",onViewDetails:()=>(e=>{const t=C.find(t=>t.callId===e);t&&("live"!==t.statusOfCall&&"ended"!==t.statusOfCall||(h(e),x(!0),m(!1)))})(e.callId),callData:e,isSelected:a,liveParticipant:n,liveSentiment:r,liveBullets:s}))}):t.createElement(o.div,{className:"col-span-full flex justify-center items-center py-12",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4}},t.createElement("p",{className:"text-gray-500"},"No calls found"))))))};export{O as CallsPage,O as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.