PageSourceSearch

https://voice.cognitiev.com/assets/CallLogsPage-BZaylXjZ.js

js cognitiev.com collected 2026-10-04 22:28:46 UTC 60,796 bytes, 8 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-excel-DfghFNgZ.js","assets/vendor-helpers-5liHvl6o.js"])))=>i.map(i=>d[i]);
2import{_ as mt}from"./vendor-helpers-5liHvl6o.js";import{j as e,a as o,k as xt,L as pt}from"./vendor-react-DoZqVJV9.js";import{i as ft,u as ht}from"./vendor-data-DIyefQL7.js";import{b1 as bt,ba as We,a6 as ue,cy as me,c9 as ke,b$ as Se,aa as Ce,S as He,dC as gt,dD as jt,aT as Ke,al as $e,au as yt,b_ as Nt,cb as wt,a7 as vt,c0 as Ve,az as kt,ab as De,W as St,bo as Fe,aS as Ct,bO as At,bN as Et,bL as be,as as _t,bY as we,ad as Tt,ac as Lt,bK as Rt,c5 as zt}from"./vendor-CYy89fbB.js";import{i as V,m as $t}from"./index-BWN_DVob.js";import{b as Ye}from"./softphone-Cd55gsEO.js";import{D as Dt}from"./DateRangeSelector-DHOQVZx5.js";import{P as Je}from"./Portal-B5Eh9ZFj.js";import{u as Ft}from"./useModalDismiss-zjqSj0RH.js";import{P as It}from"./PageHeader-BKdI5d6t.js";import{F as Ot,T as Mt,S as Ut,b as q}from"./index-BRBVc4Fs.js";import{D as Pt}from"./DockedPanel-VGLHPb29.js";import{D as Bt}from"./DataTable-SJ1euBs-.js";import{P as ie}from"./primitives-DnwAafit.js";import"./vendor-radix-Cf-gsRIn.js";import"./vendor-motion-CAHSrZCt.js";import"./utils-Bcil4Ihk.js";import"./button-CYHPeZSF.js";import"./calendar-DIkYxt6W.js";import"./popover-oQZXnssS.js";import"./context-CWgg3I6G.js";import"./motion-B_H_SukK.js";const Wt={pos:"bg-emerald-50 text-emerald-700 ring-emerald-200",neg:"bg-rose-50 text-rose-700 ring-rose-200",warn:"bg-amber-50 text-amber-700 ring-amber-200",neutral:"bg-surface-100 text-surface-500 ring-surface-200"},qe={pos:"bg-emerald-500",neg:"bg-rose-500",warn:"bg-amber-500",neutral:"bg-brand-400"},Ht=["summary","call_summary","callSummary","overview","complaint_text","complaintText","complaint","issue","query","description","details","notes"],Kt=["userSentiment","user_sentiment","sentiment","primaryEmotion","primary_emotion","mood"],Vt=["emotionBreakdown","emotion_breakdown","emotions","breakdown"];function ge(t){try{return JSON.parse(t)}catch{return}}function _e(t){const s=[];let r=!1,l=!1;for(let f=0;f<t.length;f+=1){const x=t[f];if(r){l?l=!1:x==="\\"?l=!0:x==='"'&&(r=!1);continue}x==='"'?r=!0:x==="{"?s.push("}"):x==="["?s.push("]"):(x==="}"||x==="]")&&s.pop()}let c=t;
2for(l&&(c=c.slice(0,-1)),r&&(c+='"'),c=c.replace(/[,:]\s*$/,""),s.includes("}")&&(c=c.replace(/,?\s*"[^"]*"\s*$/,""));s.length;)c+=s.pop();return ge(c)}function Yt(t){const s={},r=new Set,l=t.match(/"(emotionBreakdown|emotion_breakdown|breakdown|emotions)"\s*:\s*\{([^}]*)\}/);let c=null;if(l){c={};const b=/"([\w .-]+)"\s*:\s*(-?\d+(?:\.\d+)?)/g;let j;for(;(j=b.exec(l[2]))!==null;)c[j[1]]=Number(j[2]),r.add(j[1])}const f=/"([\w .-]+)"\s*:\s*(?:"((?:[^"\\]|\\.)*)"|(-?\d+(?:\.\d+)?)|(true|false|null))/g;let x;for(;(x=f.exec(t))!==null;){const b=x[1];b in s||r.has(b)||(x[2]!==void 0?s[b]=x[2].replace(/\\n/g,`
3`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):x[3]!==void 0?s[b]=Number(x[3]):s[b]=x[4]==="true"?!0:x[4]==="false"?!1:null)}return c&&Object.keys(c).length&&l&&(s[l[1]]=c),s}function Jt(t){const s=t.trim();if(!s.startsWith("{"))return;const r=ge(s);if(r&&typeof r=="object"&&!Array.isArray(r))return r;const l=_e(s);if(l&&typeof l=="object"&&!Array.isArray(l))return l;const c=Yt(s);return Object.keys(c).length?c:void 0}function G(t){const s=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim();return s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()}function Ge(t){const s=t.toLowerCase();return/(positive|happy|satisfied|glad|grateful|delight|pleased)/.test(s)?"pos":/(negative|angry|frustrat|upset|sad|annoyed|dissatisf)/.test(s)?"neg":/(concern|worried|anxious|confused|neutral-negative)/.test(s)?"warn":"neutral"}function Ae(t){return Number.isFinite(t)&&t>=0&&t<=1}function Qe(t){return Math.round(t*100)}function Ze({tone:t,children:s}){return e.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize ring-1 ${Wt[t]}`,children:s})}function qt({label:t,value:s}){const r=Qe(s),l=r>=66?"pos":r>=33?"warn":"neg";return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-xs text-surface-500",children:[e.jsx("span",{children:t}),e.jsxs("span",{className:"font-semibold tabular-nums text-surface-900",children:[r,"%"]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full border border-surface-200 bg-surface-100",children:e.jsx("span",{className:`block h-full rounded-full transition-[width] duration-300 ${qe[l]}`,style:{width:`${r}%`}})})]})}function Xe({data:t}){const s=Object.entries(t).filter(r=>typeof r[1]=="number").sort((r,l)=>l[1]-r[1]);return e.jsx("div",{className:"grid gap-2",children:s.map(([r,l])=>{const c=Ae(l)?Qe(l):Math.round(l);return e.jsxs("div",{className:"grid grid-cols-[110px_1fr_42px] items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs capitalize text-surface-700",children:G(r)}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full border border-surface-200 bg-surface-100",children:e.jsx("span",{className:`block h-full rounded-full transition-[width] duration-300 ${qe[Ge(r)]}`,style:{width:`${Math.min(c,100)}%`}})}),e.jsxs("span",{className:"text-right text-xs tabular-nums text-surface-400",children:[c,"%"]})]},r)})})}function Gt(t){if(/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(t)){const s=t.replace(/[_-]+/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}return t}function se({value:t}
3){if(t==null||t==="")return e.jsx("span",{className:"text-surface-400",children:"—"});if(typeof t=="boolean")return e.jsx(Ze,{tone:t?"pos":"neg",children:t?"Yes":"No"});if(typeof t=="number")return e.jsx("span",{className:"font-semibold tabular-nums",children:t});if(typeof t=="string"){const s=t.trim();if(s.startsWith("{")||s.startsWith("[")){const r=ge(s)??_e(s);if(r&&typeof r=="object")return e.jsx(se,{value:r})}return e.jsx("span",{children:Gt(t)})}return Array.isArray(t)?t.length?e.jsx("ul",{className:"m-0 list-disc pl-[18px]",children:t.map((s,r)=>e.jsx("li",{children:e.jsx(se,{value:s})},r))}):e.jsx("span",{className:"text-surface-400",children:"—"}):e.jsx("div",{className:"grid gap-1.5 rounded-lg border border-surface-200 bg-surface-50 px-2.5 py-2",children:Object.entries(t).map(([s,r])=>e.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-2.5 text-[13px] max-sm:grid-cols-1 max-sm:gap-0.5",children:[e.jsx("span",{className:"text-surface-400",children:G(s)}),e.jsx("span",{className:"break-words text-surface-800",children:e.jsx(se,{value:r})})]},s))})}function oe(t){const s=[],r=/(\*\*[^*]+\*\*|`[^`]+`)/g;let l=0,c,f=0;for(;(c=r.exec(t))!==null;){c.index>l&&s.push(t.slice(l,c.index));const x=c[0];x.startsWith("**")?s.push(e.jsx("strong",{children:x.slice(2,-2)},f++)):s.push(e.jsx("code",{className:"rounded border border-surface-200 bg-surface-100 px-1.5 py-px font-mono text-xs",children:x.slice(1,-1)},f++)),l=r.lastIndex}return l<t.length&&s.push(t.slice(l)),s}function Ie({text:t}){const s=t.replace(/\r\n/g,`
4`).split(`
5`),r=[];let l=0,c=0;for(;l<s.length;){const f=s[l];if(!f.trim()){l+=1;continue}if(f.includes("|")&&l+1<s.length&&/^\s*\|?[\s:-]+\|[\s:|-]*$/.test(s[l+1])){const j=f.split("|").map(w=>w.trim()).filter(Boolean),h=[];for(l+=2;l<s.length&&s[l].includes("|");)h.push(s[l].split("|").map(w=>w.trim()).filter((w,k,S)=>!(k===0&&S[0]===""))),l+=1;r.push(e.jsxs("table",{className:"my-1.5 w-full border-collapse text-[13px]",children:[e.jsx("thead",{children:e.jsx("tr",{children:j.map((w,k)=>e.jsx("th",{className:"border border-surface-200 bg-surface-50 px-2 py-1.5 text-left align-top text-surface-900",children:oe(w)},k))})}),e.jsx("tbody",{children:h.map((w,k)=>e.jsx("tr",{children:j.map((S,d)=>e.jsx("td",{className:"border border-surface-200 px-2 py-1.5 text-left align-top",children:oe(w[d]??"")},d))},k))})]},c++));continue}const x=f.match(/^(#{1,4})\s+(.*)$/);if(x){const j=x[1].length,h=oe(x[2]);r.push(j<=2?e.jsx("h4",{className:"mb-1.5 mt-1 text-sm font-bold text-surface-900",children:h},c++):e.jsx("h5",{className:"mb-1.5 mt-1 text-[13px] font-bold text-surface-900",children:h},c++)),l+=1;continue}if(/^\s*([-*]|\d+\.)\s+/.test(f)){const j=[],h=/^\s*\d+\.\s+/.test(f);for(;l<s.length&&/^\s*([-*]|\d+\.)\s+/.test(s[l]);)j.push(e.jsx("li",{children:oe(s[l].replace(/^\s*([-*]|\d+\.)\s+/,""))},j.length)),l+=1;r.push(h?e.jsx("ol",{className:"mb-2 list-decimal pl-[18px] text-sm leading-relaxed",children:j},c++):e.jsx("ul",{className:"mb-2 list-disc pl-[18px] text-sm leading-relaxed",children:j},c++));continue}const b=[];for(;l<s.length&&s[l].trim()&&!/^(#{1,4}\s|\s*([-*]|\d+\.)\s)/.test(s[l])&&!s[l].includes("|");)b.push(s[l]),l+=1;b.length?r.push(e.jsx("p",{className:"mb-2 text-sm leading-relaxed last:mb-0",children:oe(b.join(" "))},c++)):l+=1}return e.jsx("div",{className:"text-surface-700",children:r})}function Qt({value:t}
5){if(!t||!t.trim())return e.jsx("div",{className:"text-sm text-surface-400",children:"No summary captured."});const s=t.trim();if(s.startsWith("[")){const d=ge(s)??_e(s);if(Array.isArray(d))return e.jsx("div",{className:"grid gap-3.5 text-sm text-surface-700",children:e.jsx(se,{value:d})})}const r=Jt(t);if(!r)return e.jsx("div",{className:"grid gap-3.5 text-surface-700",children:e.jsx(Ie,{text:t})});const l=Object.entries(r),c=Ht.find(d=>typeof r[d]=="string"&&r[d].trim()),f=c?r[c]:"",x=l.filter(([d,y])=>Kt.includes(d)&&typeof y=="string"&&y),b=Vt.find(d=>r[d]&&typeof r[d]=="object"&&!Array.isArray(r[d])),j=l.filter(([d,y])=>typeof y=="number"&&(/score|confidence|rating|probability/i.test(d)||Ae(y))),h=new Set([...c?[c]:[],...x.map(([d])=>d),...b?[b]:[],...j.map(([d])=>d)]),w=l.filter(([d])=>!h.has(d)),k=w.filter(([,d])=>d===null||typeof d!="object"),S=w.filter(([,d])=>d!==null&&typeof d=="object");return e.jsxs("div",{className:"grid gap-3.5 text-surface-700",children:[f&&e.jsx("div",{className:"leading-relaxed",children:e.jsx(Ie,{text:f})}),x.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:x.map(([d,y])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-surface-400",children:G(d)}),e.jsx(Ze,{tone:Ge(String(y)),children:String(y)})]},d))}),j.length>0&&e.jsx("div",{className:"grid gap-2.5",children:j.map(([d,y])=>e.jsx(qt,{label:G(d),value:Ae(y)?y:Math.max(0,Math.min(1,y/100))},d))}),b&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-semibold text-surface-400",children:G(b)}),e.jsx(Xe,{data:r[b]})]}),k.length>0&&e.jsx("div",{className:"grid gap-0",children:k.map(([d,y])=>e.jsxs("div",{className:"grid grid-cols-[160px_1fr] gap-2.5 border-b border-dashed border-surface-200 py-1.5 text-[13px] last:border-0 max-sm:grid-cols-1 max-sm:gap-0.5",children:[e.jsx("span",{className:"text-surface-400",children:G(d)}),e.jsx("span",{className:"break-words text-surface-800",children:e.jsx(se,{value:y})})]},d))}),S.map(([d,y])=>e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-semibold text-surface-400",children:G(d)}),e.jsx("div",{className:"w-full",children:e.jsx(se,{value:y})})]},d))]})}const de=t=>{const s=Math.floor(t/60),r=Math.floor(t%60);return`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},Ee=t=>t?new Date(t).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit"}):"--:--",Oe={user_hangup:"User hangup",agent_hangup:"Agent hangup",call_transferred:"Call transferred",voicemail_reached:"Voicemail reached",dial_no_answer:"No answer",dial_failed:"Dial failed",invalid_destination:"Invalid destination",ivr_reached:"IVR reached",inactivity:"Inactivity",max_duration_reached:"Max duration reached",user_declined:"User declined",user_unavailable:"User unavailable",sip_trunk_failure:"SIP trunk failure",server_shutdown:"Server shutdown",caller_canceled:"Cancelled before answer",unknown:"Unknown"},Zt=t=>{if(!t)return"Ongoing / Unknown";const s=t.toLowerCase();return Oe[s]?Oe[s]:t.replace(/[_-]/g," ").replace(/\b\w/g,r=>r.toUpperCase())},Xt={positive:"Positive",negative:"Negative",neutral:"Neutral",unknown:"Unknown"},Me=t=>Xt[(t||"unknown").toLowerCase()]||"Unknown",es=t=>{if(Array.isArray(t))return t;if(typeof t!="string")return[];try{const s=JSON.parse(t);return Array.isArray(s)?s:[]}catch{return[]}},ts=t=>{if(Array.isArray(t))return t;if(typeof t!="string")return[];try{const s=JSON.parse(t);return Array.isArray(s)?s:[]}catch{return[]}},ss=t=>{if(t&&typeof t=="object"&&!Array.isArray(t))return t;if(typeof t=="string")try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))return s}catch{return{}}return{}},as=t=>{if(t&&typeof t=="object"&&!Array.isArray(t))return t;if(typeof t=="string")try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))return s}catch{return null}return null},rs=[{key:"pricing",terms:["price","cost","discount","budget","plan"]},{key:"support",terms:["issue","problem","help","error","not working"]},{key:"demo",terms:["demo","show me","walkthrough","trial"]},{key:"integration",terms:["api","integrat","webhook","crm","sync"]},{key:"follow_up",terms:["call back","follow up","later","tomorrow","next week"]}],ns=t=>{const s=new Map;for(const r of t){if(r.role!=="user")continue;const l=String(r.content||"").toLowerCase();for(const c of rs)c.terms.some(f=>l.includes(f))&&s.set(c.key,(s.get(c.key)||0)+1)}return Array.from(s.entries()).map(([r,l])=>({intent:r,score:l})).sort((r,l)=>l.score-r.score)},Ue=(t,s)=>{if(typeof t.offsetSec=="number"&&Number.isFinite(t.offsetSec))return Math.max(0,t.offsetSec);if(!t.timestamp||!s)return null;const r=new Date(t.timestamp).getTime(),l=new Date(s).getTime();return!Number.isFinite(r)||!Number.isFinite(l)?null:Math.max(0,(r-l)/1e3)},ls=t=>{if(t==null||typeof t=="string"&&t.trim()==="")return{kind:"empty",preview:"—",full:"",isLong:!1};if(typeof t=="boolean"){const r=t?"Yes":"No";return{kind:t?"bool-true":"bool-false",preview:r,full:r,isLong:!1}}if(typeof t=="number"){const r=String(t);return{kind:"number",preview:r,full:r,isLong:!1}}if(typeof t=="object")return{kind:"object",preview:JSON.stringify(t),full:JSON.stringify(t,null,2),isLong:!0};const s=String(t).trim();return{kind:"string",preview:s,full:s,isLong:s.length>46||s.includes(`
6`)}},is={"bool-true":{dot:"bg-emerald-500",value:"text-emerald-700"},"bool-false":{dot:"bg-rose-500",value:"text-rose-700"},number:{dot:"bg-indigo-500",value:"text-indigo-700"},string:{dot:"bg-brand-500",value:"text-surface-900"}
6,object:{dot:"bg-amber-500",value:"text-amber-700"},empty:{dot:"bg-surface-300",value:"text-surface-400"}},ve=t=>t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim(),Pe=({children:t,panel:s,className:r,disabled:l})=>{const c=o.useRef(null),f=o.useRef(null),x=o.useRef(null),[b,j]=o.useState(!1),[h,w]=o.useState(null),k=()=>{x.current!==null&&(window.clearTimeout(x.current),x.current=null)},S=()=>{l||(k(),j(!0))},d=()=>{k(),x.current=window.setTimeout(()=>j(!1),120)};return o.useLayoutEffect(()=>{if(!b){w(null);return}const y=c.current,I=f.current;if(!y||!I)return;const W=y.getBoundingClientRect(),A=I.getBoundingClientRect(),E=12;let C=W.left;C+A.width>window.innerWidth-E&&(C=window.innerWidth-A.width-E),C<E&&(C=E);let H=W.bottom+8;if(H+A.height>window.innerHeight-E){const R=W.top-A.height-8;H=R>=E?R:Math.max(E,window.innerHeight-A.height-E)}w({top:H,left:C})},[b]),o.useEffect(()=>()=>k(),[]),e.jsxs("span",{ref:c,className:r,tabIndex:l?-1:0,onMouseEnter:S,onMouseLeave:d,onFocus:S,onBlur:d,children:[t,b&&!l&&e.jsx(Je,{lockScroll:!1,children:e.jsx("div",{ref:f,role:"tooltip",onMouseEnter:k,onMouseLeave:d,style:{position:"fixed",top:h?.top??-9999,left:h?.left??-9999,opacity:h?1:0},className:"z-100000 w-max max-w-sm rounded-2xl border border-surface-200 bg-white p-3.5 text-sm text-surface-800 shadow-2xl ring-1 ring-black/5 transition-opacity duration-100",children:s})})]})},os=({msg:t,isActive:s,offsetSec:r,onSeek:l,activeRef:c})=>{const[f,x]=o.useState(!1),b=t.toolStatus==="error";return e.jsxs("div",{ref:c,className:"flex flex-col items-center",children:[e.jsxs("button",{type:"button",onClick:()=>x(j=>!j),title:f?"Hide tool call details":"Show tool call details",className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-semibold shadow-sm transition-all hover:shadow ${b?"border-red-200 bg-red-50 text-red-700":"border-amber-200 bg-amber-50/70 text-amber-700"} ${s?"ring-2 ring-amber-400":""}`,children:[e.jsx(Fe,{size:11}),e.jsx("span",{className:"font-mono",children:t.toolName||"tool"}),b?e.jsx(me,{size:11,className:"text-red-600"}):e.jsx(ue,{size:11,className:"text-emerald-600"}),e.jsx(Ct,{size:11,className:`transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsxs("div",{className:`mt-1.5 w-full max-w-[94%] rounded-2xl border px-4 py-3 shadow-sm ${b?"border-red-200 bg-red-50":"border-amber-200 bg-amber-50/70"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wider ${b?"text-red-600":"text-amber-700"}`,children:[e.jsx(Fe,{size:12})," Tool"]}),e.jsx("span",{className:"text-sm font-bold text-surface-900",children:t.toolName||"tool"}),e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-bold uppercase ${b?"bg-red-100 text-red-700":"bg-emerald-100 text-emerald-700"}`,children:[b?e.jsx(me,{size:10}):e.jsx(ue,{size:10}),b?"Error":"Success"]}),t.timestamp&&e.jsx("span",{className:"text-[9px] font-medium text-surface-300",children:Ee(t.timestamp)}),typeof r=="number"&&e.jsx("button",{className:"text-[9px] font-semibold text-brand-600 hover:underline",onClick:()=>l(r),children:de(r)})]}),t.toolArgs&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-surface-400 mb-0.5",children:"Arguments"}),e.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-lg border border-surface-200 bg-white/70 px-2.5 py-1.5 text-[11px] font-mono text-surface-700",children:t.toolArgs})]}),t.toolResult&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-surface-400 mb-0.5",children:"Result"}),e.jsx("pre",{className:"whitespace-pre-wrap break-words rounded-lg border border-surface-200 bg-white/70 px-2.5 py-1.5 text-[11px] font-mono text-surface-700",children:t.toolResult})]})]})]})};function cs({onClose:t}){return Ft(t),null}const ds=({call:t,onClose:s,inline:r=!1})=>{const l=o.useRef(null),c=o.useRef(null);o.useEffect(()=>{if(!r)return;const i=u=>{u.key==="Escape"&&s()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r,s]);
6const[f,x]=o.useState(null),[b,j]=o.useState(!1),[h,w]=o.useState(null),[k,S]=o.useState([]),[d,y]=o.useState(!1),[I,W]=o.useState(""),[A,E]=o.useState(""),[C,H]=o.useState(0),[R,ae]=o.useState(!1),[T,J]=o.useState(null);o.useEffect(()=>{const i=t?.id;if(!i){J(null);return}let u=!1;return J(null),ae(!1),V.get(`/calls/${i}`).then(({data:m})=>{!u&&m&&J(m)}).catch(()=>{}),()=>{u=!0}},[t?.id]);const n=o.useMemo(()=>T?{...t,...T}:t,[T,t]),K=o.useMemo(()=>es(n?.transcript),[n?.transcript]),O=o.useMemo(()=>ss(n?.emotionBreakdown),[n?.emotionBreakdown]),Y=o.useMemo(()=>as(n?.analysis),[n?.analysis]),M=o.useMemo(()=>ns(K),[K]),Q=o.useMemo(()=>n?K.map((i,u)=>({entry:i,index:u,offsetSec:Ue(i,n.startedAt)})).filter(i=>i.offsetSec!==null).sort((i,u)=>i.offsetSec-u.offsetSec):[],[K,n]),z=o.useMemo(()=>{if(!Q.length)return-1;let i=-1;for(const u of Q)u.offsetSec<=C+.2&&(i=u.index);return i},[Q,C]);if(o.useEffect(()=>{c.current&&c.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[z]),o.useEffect(()=>{if(!n)return;const i=ts(n.playbackBookmarks).sort((m,N)=>m.atSec-N.atSec);S(i),W(""),E("");let u=!1;return j(!0),w(null),x(null),V.get(`/calls/${n.id}/recording`).then(({data:m})=>{u||x(m.url)}).catch(m=>{u||(m?.response?.status===404?w("not-ready"):w("failed"))}).finally(()=>{u||j(!1)}),V.get(`/calls/${n.id}/playback`).then(({data:m})=>{if(u)return;const N=Array.isArray(m?.bookmarks)?m.bookmarks:[];S(N.sort(($,U)=>$.atSec-U.atSec))}).catch(()=>{u||S(i)}),()=>{u=!0}},[n?.id]),!n)return null;const Z=async i=>{y(!0),S(i);try{const{data:u}=await V.put(`/calls/${n.id}/playback`,{bookmarks:i}),m=Array.isArray(u?.bookmarks)?u.bookmarks:i;S(m.sort((N,$)=>N.atSec-$.atSec))}finally{y(!1)}},X=async()=>{if(!I.trim())return;const i=l.current?.currentTime??C,u=[...k,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,atSec:Number(i.toFixed(2)),label:I.trim(),note:A.trim()||void 0,createdAt:new Date().toISOString()}].sort((m,N)=>m.atSec-N.atSec);W(""),E(""),await Z(u)},xe=async(i,u)=>{const m=k.map(N=>N.id===i?{...N,note:u}:N);await Z(m)},je=async i=>{const u=k.filter(m=>m.id!==i);await Z(u)},ee=i=>{l.current&&(l.current.currentTime=Math.max(0,i),l.current.play().catch(()=>{H(i)}))},L=e.jsxs("aside",{role:r?"region":"dialog","aria-modal":r?void 0:!0,"aria-label":"Call details",className:r?"flex h-full min-h-0 w-full flex-col overflow-hidden bg-white":"relative flex h-full w-full flex-col bg-white shadow-2xl animate-cd-slide sm:w-[640px] sm:border-l sm:border-surface-200",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-surface-200 bg-surface-50 px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[n.type.includes("sip")?e.jsx("div",{className:"shrink-0 rounded-lg bg-purple-100 p-2 text-purple-700",children:e.jsx(bt,{size:16})}):e.jsx("div",{className:"shrink-0 rounded-lg bg-blue-100 p-2 text-blue-700",children:e.jsx(We,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-widest text-surface-400",children:"Session Intelligence"}),e.jsx("h3",{className:"truncate text-[17px] font-semibold tracking-tight text-surface-900",children:n.customerNumber||"Anonymous Web User"}),e.jsxs("p",{className:"mt-0.5 flex items-center gap-1.5 text-xs text-surface-400",children:[e.jsx("span",{className:"font-mono",children:n.id.split("-")[0]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-surface-300"}),new Date(n.createdAt||"").toLocaleDateString()]})]})]}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-[11px] font-semibold capitalize ring-1 ${n.type.includes("sip")?"bg-purple-50 text-purple-700 ring-purple-200":"bg-blue-50 text-blue-700 ring-blue-200"}`,children:n.type.replace(/_/g," ")}),e.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-[11px] font-semibold capitalize ring-1 ${n.sentiment==="positive"?"bg-emerald-50 text-emerald-700 ring-emerald-200":n.sentiment==="negative"?"bg-rose-50 text-rose-700 ring-rose-200":"bg-surface-100 text-surface-500 ring-surface-200"}`,children:Me(n.sentiment)}),n.successEvaluation===!0?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2.5 py-0.5 text-[11px] font-semibold text-emerald-700 ring-1 ring-emerald-200",children:[e.jsx(ue,{size:11})," Successful"]}):n.successEvaluation===!1?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-rose-50 px-2.5 py-0.5 text-[11px] font-semibold text-rose-700 ring-1 ring-rose-200",children:[e.jsx(me,{size:11})," Needs review"]}):null,n.hotLeadEvaluation===!0&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-orange-50 px-2.5 py-0.5 text-[11px] font-semibold text-orange-700 ring-1 ring-orange-200",children:[e.jsx(ke,{size:11,className:"fill-orange-500 text-orange-500"})," Hot lead"]})]}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:`/dashboard/call-quality?callId=${encodeURIComponent(n.id)}`,title:"Open this call's deep evaluation in Call Quality",className:"inline-flex items-center gap-1.5 rounded-lg border border-surface-200 bg-white px-2.5 py-1 text-[11px] font-semibold text-surface-700 hover:bg-surface-50",children:[e.jsx(Se,{size:12})," Call Quality"]}),e.jsx(us,{callId:n.id})]})]}),e.jsx("button",{onClick:s,"aria-label":"Close details",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-surface-200 bg-transparent text-surface-400 transition-colors hover:border-brand-500 hover:text-surface-900",children:e.jsx(Ce,{size:17})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 pb-8 pt-4",children:[e.jsxs("section",{className:"sticky top-0 z-20 mb-5 rounded-2xl border border-surface-200 bg-white px-4 py-3 shadow-[0_4px_24px_rgba(0,0,0,0.06)]",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsx("h4",{className:"m-0 text-[11px] font-semibold uppercase tracking-[0.06em] text-surface-400",children:"Recording"}),e.jsxs("span",{className:"text-[11px] font-semibold tabular-nums text-surface-400",children:["Timeline ",de(C)]})]}),b?e.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-sm font-medium text-surface-400",children:[e.jsx(He,{size:15,className:"animate-spin"})," Loading recording..."]}):h==="not-ready"?e.jsx("p",{className:"py-1.5 text-sm font-medium text-surface-400",children:"Recording is still processing. Please retry in a few seconds."}):h||!f?e.jsx("p",{className:"py-1.5 text-sm font-medium text-surface-400",children:"Recording unavailable."}):e.jsxs("audio",{ref:l,controls:!0,preload:"metadata",className:"h-9 w-full outline-none",onTimeUpdate:i=>H(i.currentTarget.currentTime||0),children:[e.jsx("source",{src:f,type:"video/mp4"}),"Your browser does not support the audio element."]})]}),e.jsxs("section",{className:"mb-6",children:[e.jsx("h4",{className:"mb-2 text-[11px] font-semibold uppercase tracking-[0.06em] text-surface-400",children:"Bookmarks"}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-[1fr_1fr_auto]",children:[e.jsx("input",{className:"rounded-xl border border-surface-200 px-3 py-2 text-sm",placeholder:"Bookmark label (e.g. pricing objection)",value:I,onChange:i=>W(i.target.value)}),e.jsx("input",{className:"rounded-xl border border-surface-200 px-3 py-2 text-sm",placeholder:"Optional note",value:A,onChange:i=>E(i.target.value)}),e.jsxs("button",{className:"inline-flex items-center justify-center gap-2 rounded-xl bg-brand-600 px-3 py-2 text-sm font-semibold text-white disabled:opacity-60",onClick:X,disabled:!I.trim()||d,children:[e.jsx(gt,{size:14})," Add @ ",de(C)]})]}),!!k.length&&e.jsx("div",{className:"mt-2 space-y-2",children:k.map(i=>e.jsxs("div",{className:"rounded-xl border border-surface-200 bg-white p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{className:"inline-flex items-center gap-2 text-left text-sm font-semibold text-surface-900 hover:text-brand-600",onClick:()=>ee(i.atSec),children:[e.jsx(jt,{size:14})," ",i.label," (",de(i.atSec),")"]}),e.jsx("button",{className:"text-xs font-semibold text-red-500",onClick:()=>je(i.id),children:"Remove"})]}),e.jsx("textarea",{className:"mt-2 w-full rounded-lg border border-surface-200 p-2 text-xs",rows:2,placeholder:"Add detail for this moment",value:i.note||"",onChange:u=>{const m=u.target.value;S(N=>N.map($=>
6$.id===i.id?{...$,note:m}:$))},onBlur:u=>{xe(i.id,u.target.value)}})]},i.id))})]}),e.jsxs("section",{className:"mb-6",children:[e.jsx("h4",{className:"mb-2 text-[11px] font-semibold uppercase tracking-[0.06em] text-surface-400",children:"Overview"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-3.5 rounded-2xl border border-surface-200 bg-surface-50 p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Duration"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[e.jsx(Ke,{size:12,className:"text-brand-500"})," ",n.duration||0,"s"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Messages"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[e.jsx($e,{size:12,className:"text-blue-500"})," ",(n.userMessageCount||0)+(n.agentMessageCount||0)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Latency"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[e.jsx(yt,{size:12,className:"text-amber-500"})," ",n.avgResponseTime?.toFixed(2)||"0.00","s"]}
6)]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Caller Identity"}),e.jsx("p",{className:"truncate text-sm font-semibold text-surface-800",children:n.customerNumber||"Anonymous Web User"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Sentiment"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[e.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${n.sentiment==="positive"?"bg-green-500":n.sentiment==="negative"?"bg-red-500":n.sentiment==="unknown"||!n.sentiment?"bg-surface-300":"bg-yellow-500"}`}),Me(n.sentiment),n.sentiment&&n.sentiment!=="unknown"?` (${(n.sentimentScore??0).toFixed(2)})`:""]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Primary Emotion"}),e.jsx("p",{className:"text-sm font-semibold capitalize text-surface-800",children:n.primaryEmotion||"neutral"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Tone Score"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[e.jsx(Nt,{size:12})," ",(n.toneScore??0).toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Speech Confidence"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[e.jsx(Se,{size:12})," ",(n.confidenceScore??0).toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"TTS Style"}),e.jsx("p",{className:"text-sm font-semibold capitalize text-surface-800",children:(n.ttsStyleUsed||"professional-neutral").replace(/-/g," ")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Started At"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[e.jsx(wt,{size:12})," ",Ee(n.startedAt)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"Disconnect Reason"}),e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-surface-800",children:[n.disconnectReason==="user_hangup"?e.jsx(vt,{size:12,className:"text-amber-500"}):null,n.mode==="human"&&n.disconnectReason==="agent_hangup"?"Rep hung up":Zt(n.disconnectReason)]})]}),n.dtmfDigits?e.jsxs("div",{children:[e.jsx("p",{className:"mb-0.5 text-[10px] font-bold uppercase tracking-wider text-surface-400",children:"DTMF Pressed"}),e.jsx("p",{className:"font-mono text-sm font-semibold tracking-widest text-surface-800",children:n.dtmfDigits})]}):null]})]}),!!Object.keys(O).length&&e.jsxs("section",{className:"mb-6",children:[e.jsx("h4",{className:"mb-2 text-[11px] font-semibold uppercase tracking-[0.06em] text-surface-400",children:"Emotion Breakdown"}),e.jsx(Xe,{data:O})]}),e.jsxs("div",{className:"mb-6 space-y-3",children:[n.mode==="human"&&e.jsxs("section",{className:"rounded-xl border border-brand-200 bg-brand-50/60 p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-brand-600 px-2 py-0.5 text-[11px] font-semibold text-white",children:[e.jsx(Ve,{size:11})," Human call"]}),e.jsxs("span",{className:"text-xs font-medium text-surface-700",children:["Handled by ",n.handledBy?.name||"a team member"," · playbook ",n.agent?.name||"agent"]}),n.disposition&&e.jsx("span",{className:"ml-auto rounded-full border border-surface-200 bg-white px-2 py-0.5 text-[11px] font-semibold text-surface-700",children:Ye[n.disposition]||n.disposition})]}),n.repNotes&&e.jsx("p",{className:"mt-2 whitespace-pre-wrap text-[13px] leading-relaxed text-surface-700",children:n.repNotes})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"m-0 text-[11px] font-semibold uppercase tracking-[0.06em] text-surface-400",children:"AI Executive Summary"}),n.summary?e.jsx("button",{type:"button",className:"text-[11px] font-semibold text-brand-600 hover:underline",onClick:()=>ae(i=>!i),children:R?"Formatted view":"Raw text"}):null]}),n.summary?R?e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-xl border border-surface-200 bg-surface-50 p-2.5 font-mono text-xs leading-normal text-surface-700",children:n.summary}):e.jsx(Qt,{value:n.summary}):e.jsx("p",{className:"text-sm text-surface-400",children:n.status==="active"?"Call is currently active. Summary will generate upon completion.":"No automated summary available for this interaction."})]}),e.jsxs("div",{className:"rounded-3xl border border-surface-200 bg-white p-5 space-y-4 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"grid h-9 w-9 place-items-center rounded-xl bg-linear-to-br from-brand-500 to-indigo-500 text-white shadow-md shadow-brand-500/20",children:e.jsx(kt,{size:17})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-surface-900 leading-tight",children:"Call Outcome"}),e.jsx("p",{className:"text-[11px] font-medium text-surface-400 mt-0.5",children:"Success evaluation & lead scoring"})]})]}),n.successEvaluation===!0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-emerald-50 px-3 py-1.5 text-xs font-bold text-emerald-700 ring-1 ring-emerald-200 whitespace-nowrap",children:[e.jsx(ue,{size:14})," Successful"]}):n.successEvaluation===!1?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-rose-50 px-3 py-1.5 text-xs font-bold text-rose-700 ring-1 ring-rose-200 whitespace-nowrap",children:[e.jsx(me,{size:14})," Needs review"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-surface-100 px-3 py-1.5 text-xs font-bold text-surface-500 ring-1 ring-surface-200 whitespace-nowrap",children:[e.jsx(De,{size:14})," Not evaluated"]})]}),n.hotLeadEvaluation!==void 0&&n.hotLeadEvaluation!==null&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-surface-400",children:"Lead"}),n.hotLeadEvaluation?e.jsxs("span",{title:"Promoted from postCallAnalysisData.hot_lead",className:"inline-flex items-center gap-1.5 rounded-full bg-orange-100 px-2.5 py-1 text-[11px] font-bold text-orange-700 ring-1 ring-orange-200",children:[e.jsx(ke,{size:12,className:"fill-orange-500 text-orange-500"})," Hot lead"]}):e.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-sky-50 px-2.5 py-1 text-[11px] font-bold text-sky-600 ring-1 ring-sky-200",children:"Cold lead"})]}),e.jsxs("div",{className:"rounded-2xl border border-surface-100 bg-surface-50 p-3.5",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-surface-400 mb-1",children:"Reason"}),n.successReason?e.jsx(Pe,{className:"block",disabled:n.successReason.length<=88&&!n.successReason.includes(`
7`),panel:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-surface-400",children:"Success reason"}),e.jsx("p",{className:"max-h-72 overflow-auto whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-surface-800",children:n.successReason})]}),children:e.jsx("span",{className:`block text-sm leading-relaxed text-surface-700 line-clamp-1 ${n.successReason.length>88||n.successReason.includes(`
8`)?"cursor-help underline decoration-dotted decoration-surface-300 underline-offset-4":""}`,children:n.successReason})}):e.jsx("p",{className:"text-sm italic text-surface-400",children:"No explicit success reason recorded."})]})]}),Y&&Object.keys(Y).length>0&&e.jsxs("div",{className:"rounded-3xl border border-surface-200 bg-white p-5 space-y-3.5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"grid h-9 w-9 place-items-center rounded-xl bg-brand-500 text-white shadow-sm shadow-brand-500/25",children:e.jsx(St,{size:17})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-surface-900 leading-tight",children:"Extracted Data"}),e.jsx("p",{className:"text-[11px] font-medium text-surface-400 mt-0.5",children:"Structured fields pulled from the conversation"})]})]}),e.jsxs("span",{className:"rounded-full bg-surface-100 px-2.5 py-1 text-[11px] font-bold text-surface-500 whitespace-nowrap",children:[Object.keys(Y).length," field",Object.keys(Y).length===1?"":"s"]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5",children:Object.entries(Y).map(([i,u])=>{const m=ls(u),N=is[m.kind];return e.jsxs("div",{className:"rounded-2xl border border-surface-200 bg-surface-50/70 px-3.5 py-3 transition-colors hover:border-surface-300 hover:bg-white",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${N.dot}`}),e.jsx("span",{className:"truncate text-[10px] font-bold uppercase tracking-wider text-surface-500",title:ve(i),children:ve(i)})]}),m.kind==="bool-true"||m.kind==="bool-false"?e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-bold ${m.kind==="bool-true"?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700"}`,children:[m.kind==="bool-true"?e.jsx(ue,{size:11}):e.jsx(me,{size:11}),m.preview]}):m.kind==="empty"?e.jsx("span",{className:"text-sm font-semibold text-surface-300",children:"—"}):e.jsx(Pe,{className:"block",disabled:!m.isLong,panel:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${N.dot}`}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-surface-400",children:ve(i)})]}),m.kind==="object"?e.jsx("pre",{className:"max-h-72 max-w-xs overflow-auto whitespace-pre-wrap wrap-break-word rounded-xl bg-surface-900 p-2.5 text-[11px] leading-relaxed text-surface-100",children:m.full}):e.jsx("p",{className:"max-h-72 overflow-auto whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-surface-800",children:m.full})]}),children:e.jsx("span",{className:`block truncate text-sm font-semibold ${N.value}
8 ${m.isLong?"cursor-help underline decoration-dotted decoration-surface-300 underline-offset-4":""}`,children:m.preview})})]},i)})}),e.jsxs("p",{className:"flex items-center gap-1 text-[10px] font-medium text-surface-400",children:[e.jsx(De,{size:11})," Hover a field to see its full value"]})]}),e.jsxs("div",{className:"rounded-2xl border border-surface-200 bg-white p-4 space-y-3",children:[e.jsx("p",{className:"text-[10px] uppercase font-bold tracking-widest text-surface-400",children:"Real-time Intent Classification"}),M.length?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:M.slice(0,6).map(i=>e.jsxs("div",{className:"rounded-xl border border-surface-200 bg-surface-50 p-2",children:[e.jsx("p",{className:"text-[10px] uppercase text-surface-500 font-bold",children:i.intent.replace("_"," ")}),e.jsx("p",{className:"text-sm font-bold text-surface-900",children:i.score})]},i.intent))}):e.jsx("p",{className:"text-sm text-surface-500",children:"No strong intents detected yet."})]})]}),e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-[11px] font-semibold uppercase tracking-[0.06em] text-surface-400",children:"Transcript With Playback Sync"}),K.length===0?e.jsxs("div",{className:"rounded-2xl border border-dashed border-surface-200 bg-surface-50 py-14 text-center",children:[e.jsx($e,{size:30,className:"mx-auto mb-3 text-surface-200"}),e.jsx("p",{className:"text-sm font-medium text-surface-500",children:"No transcript data found."}),e.jsx("p",{className:"mt-1 text-xs text-surface-400",children:"If the call just ended, it may take a moment to process."})]}):e.jsx("div",{className:"flex max-h-[460px] flex-col gap-2 overflow-y-auto rounded-xl border border-surface-200 bg-surface-50 bg-[radial-gradient(circle_at_20%_10%,rgba(99,102,241,0.06),transparent_55%)] p-2",children:K.map((i,u)=>{const m=Ue(i,n.startedAt),N=u===z,$=typeof m=="number";if(i.role==="tool"||i.toolName)return e.jsx(os,{msg:i,isActive:N,offsetSec:m,onSeek:ee,activeRef:N?c:null},`${u}-${i.timestamp||"tool"}`);const U=i.role==="user";return e.jsx("div",{ref:N?c:null,className:`flex w-full ${U?"justify-start":"justify-end"}`,children:e.jsxs("button",{type:"button",disabled:!$,onClick:()=>{$&&m!==null&&ee(m)},className:`max-w-[80%] rounded-2xl px-3 py-2 text-left shadow-sm transition-all ${U?"rounded-bl-sm border border-surface-200 bg-white":"rounded-br-sm border border-brand-200 bg-brand-50"} ${N?"ring-2 ring-amber-400":""} ${$?"cursor-pointer hover:opacity-90":"cursor-default"}`,children:[e.jsx("span",{className:`mb-0.5 block text-[11px] font-bold tracking-wide ${U?"text-surface-500":"text-brand-600"}`,children:U?"Customer":n.mode==="human"?n.handledBy?.name||"Rep":n.agent?.name||"Vaani AI"}),e.jsx("span",{className:"block whitespace-pre-wrap break-words text-[13.5px] font-medium leading-normal text-surface-900",children:i.content}),i.ttsStyleHint&&!U&&e.jsxs("span",{className:"mt-1.5 block text-[10px] uppercase text-surface-400",children:["Style: ",i.ttsStyleHint.replace(/-/g," ")]}),(i.timestamp||typeof m=="number")&&e.jsxs("span",{className:"mt-1 block text-right text-[10px] tabular-nums text-surface-400/80",children:[i.timestamp?Ee(i.timestamp):"",typeof m=="number"?`${i.timestamp?" • ":""}${de(m)}`:""]})]})},`${u}-${i.timestamp||"msg"}`)})})]})]})]});return r?L:e.jsxs(Je,{children:[e.jsx(cs,{onClose:s}),e.jsxs("div",{className:"fixed inset-0 z-100 flex justify-end pointer-events-auto",children:[e.jsx("div",{className:"absolute inset-0 bg-surface-950/50 backdrop-blur-[2px] animate-cd-fade",onClick:s}),L]})]})},us=({callId:t})=>{const[s,r]=o.useState(!1),[l,c]=o.useState(!1),[f,x]=o.useState(null),b=[{ext:"json",label:"JSON",mime:"application/json"},{ext:"txt",label:"Text",mime:"text/plain"},{ext:"csv",label:"CSV",mime:"text/csv"},{ext:"srt",label:"SRT subtitles",mime:"application/x-subrip"},{ext:"vtt",label:"WebVTT",mime:"text/vtt"}],j=async h=>{x(h);try{const w=`/calls/${t}/transcript.${h}${l?"?redact=1":""}`,S=(await V.get(w,{responseType:"blob"})).data,d=URL.createObjectURL(S),y=document.createElement("a");y.href=d,y.download=`vaani-call-${t.slice(0,8)}.${h}`,document.body.appendChild(y),y.click(),y.remove(),URL.revokeObjectURL(d),r(!1)}catch(w){console.error("Transcript export failed",w)}finally{x(null)}};return e.jsxs("div",{className:"relative z-[70]",children:[e.jsx("button",{type:"button",onClick:()=>r(h=>!h),className:"text-xs px-3 py-1.5 rounded-lg border border-surface-200 bg-white hover:bg-surface-50 font-semibold text-surface-700",children:"Export transcript ▾"}),s&&e.jsxs("div",{className:"absolute right-0 z-[80] mt-1 w-56 bg-white border border-surface-200 rounded-lg shadow-lg p-2",children:[e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 text-xs text-surface-600",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:h=>c(h.target.checked)}),"Redact PII (email / phone / card / SSN)"]}),e.jsx("div",{className:"border-t border-surface-100 my-1"}),b.map(h=>e.jsx("button",{type:"button",disabled:f===h.ext,onClick:()=>j(h.ext),className:"w-full text-left px-3 py-1.5 text-sm rounded hover:bg-brand-50 disabled:opacity-50",children:f===h.ext?"Downloading…":h.label},h.ext))]})]})},Be=t=>{if(!t)return"00:00";const s=Math.floor(t/60),r=t%60;return`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},ms=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-_]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||"all-agents",ce=t=>typeof t=="string"?t.trim():"",xs=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"active",label:"Active"},{value:"failed",label:"Failed"}],ps=[{value:"all",label:"All types"},{value:"web_call",label:"Web call"},{value:"sip_call",label:"Phone (inbound)"},{value:"sip_outbound",label:"Phone (outbound)"}],fs=[{value:"all",label:"All sentiment"},{value:"positive",label:"Positive"},{value:"neutral",label:"Neutral"},{value:"negative",label:"Negative"},{value:"unknown",label:"Unknown"}],hs=[{value:"all",label:"Any duration"},{value:"under_30s",label:"Under 30 sec"},{value:"30s_1m",label:"30 sec – 1 min"},{value:"1_3m",label:"1 – 3 min"},{value:"3_5m",label:"3 – 5 min"},{value:"over_5m",label:"Over 5 min"}],bs=[25,50,100],gs=t=>t==="completed"?"ok":t==="failed"?"bad":t==="active"?"info":"warn",js=t=>t==="positive"?"ok":t==="negative"?"bad":t==="neutral"?"muted":"warn",Bs=()=>{const t=ft(),[s,r]=xt(),l=ht(a=>
8a.agents.list),c=s.get("agentId"),[f,x]=o.useState([]),[b,j]=o.useState([]),[h,w]=o.useState(!0),[k,S]=o.useState(null),[d,y]=o.useState(""),[I,W]=o.useState(""),[A,E]=o.useState("all"),[C,H]=o.useState("all"),[R,ae]=o.useState("all"),[T,J]=o.useState(c||"all"),[n,K]=o.useState("all"),[O,Y]=o.useState("all"),[M,Q]=o.useState("all"),[z,Z]=o.useState(void 0),[X,xe]=o.useState(!1),[je,ee]=o.useState(!1),[L,i]=o.useState(1),[u,m]=o.useState(25),[N,$]=o.useState(0);o.useEffect(()=>{l.length===0&&t($t())},[t,l.length]),o.useEffect(()=>{J(c||"all")},[c]),o.useEffect(()=>{V.get("/sip/campaigns").then(({data:a})=>{const g=Array.isArray(a?.data)?a.data:Array.isArray(a)?a:[];j(g.map(_=>({id:_.id,name:_.name??null})))}).catch(()=>j([]))},[]),o.useEffect(()=>{const a=setTimeout(()=>W(d.trim()),350);return()=>clearTimeout(a)},[d]);const U=o.useMemo(()=>{const a={};return A==="hot"?a.hotLead="true":A==="cold"&&(a.hotLead="false"),C!=="all"&&(a.status=C),R!=="all"&&(a.type=R),T!=="all"&&(a.agentId=T),n!=="all"&&(a.campaignId=n),O!=="all"&&(a.sentiment=O),M!=="all"&&(a.duration=M),I&&(a.search=I),z?.from&&(a.from=At(z.from).toISOString()),z?.to&&(a.to=Et(z.to).toISOString()),a},[A,C,R,T,n,O,M,I,z]);o.useEffect(()=>{w(!0);const a={...U};a.take=String(u),a.skip=String((L-1)*u),V.get("/calls",{params:a}).then(g=>{const _=g.data,B=Array.isArray(_)?_:Array.isArray(_?.data)?_.data:Array.isArray(_?.calls)?_.calls:[];x(B);const ne=g.headers?.["x-total-count"],le=ne!=null?parseInt(String(ne),10):NaN;$(Number.isFinite(le)?le:B.length)}).catch(g=>{console.error(g),be.error(g?.response?.data?.message||"Failed to load call logs. Please try again.")}).finally(()=>w(!1))},[U,L,u]),o.useEffect(()=>{i(1)},[A,C,R,T,n,O,M,I,z]);const et=o.useMemo(()=>{let a=0;return C!=="all"&&a++,R!=="all"&&a++,T!=="all"&&a++,n!=="all"&&a++,O!=="all"&&a++,M!=="all"&&a++,(z?.from||z?.to)&&a++,a},[C,R,T,n,O,M,z]),re=o.useMemo(()=>{let a=0;return A!=="all"&&a++,n!=="all"&&a++,O!=="all"&&a++,M!=="all"&&a++,a},[A,n,O,M]),ye=et>0||A!=="all"||!!d.trim(),Te=()=>{y(""),E("all"),H("all"),ae("all"),J("all"),r({},{replace:!0}),K("all"),Y("all"),Q("all"),Z(void 0)},tt=a=>{J(a);const g=new URLSearchParams(s);a==="all"?g.delete("agentId"):g.set("agentId",a),r(g,{replace:!0})},st=o.useMemo(()=>{if(T==="all")return"all-agents";const a=l.find(g=>g.id===T)?.name||"agent";return ms(a)},[T,l]),at=async()=>{if(!X){xe(!0);try{const a=[];let _=0,B=null;for(let p=0;p<200;p++){const P=await V.get("/calls",{params:{...U,take:String(500),skip:String(_)}}),D=P.data,v=Array.isArray(D)?D:Array.isArray(D?.data)?D.data:Array.isArray(D?.calls)?D.calls:[];if(B===null){const F=P.headers?.["x-total-count"],he=F!=null?parseInt(String(F),10):NaN;B=Number.isFinite(he)?he:null}if(v.length===0||(a.push(...v),_+=v.length,B!==null&&B>0&&a.length>=B)||v.length<500)break}if(a.length===0){be.warning("No filtered call logs available to download.");return}const ne=a.filter(p=>!!ce(p.recordingUrl)),le=new Map;for(let p=0;p<ne.length;p+=10){const P=ne.slice(p,p+10);(await Promise.all(P.map(async v=>{try{const{data:F}=await V.get(`/calls/${encodeURIComponent(v.id)}/recording`),he=ce(F?.url);return[v.id,he||ce(v.recordingUrl)]}catch{return[v.id,ce(v.recordingUrl)]}}))).forEach(([v,F])=>{F&&le.set(v,F)})}const ct=await mt(()=>import("./vendor-excel-DfghFNgZ.js").then(p=>p.e),__vite__mapDeps([0,1])),Le=new ct.Workbook,fe=Le.addWorksheet("Call Logs",{views:[{state:"frozen",ySplit:1}]});fe.columns=[{header:"Call ID",key:"callId",width:24},{header:"Agent",key:"agent",width:20},{header:"Customer",key:"customer",width:18},{header:"Call Type",key:"callType",width:14},{header:"Status",key:"status",width:12},{header:"Hot Lead",key:"hotLead",width:10},{header:"Sentiment",key:"sentiment",width:12},{header:"Success",key:"success",width:10},{header:"Duration (sec)",key:"durationSec",width:14},{header:"Duration (mm:ss)",key:"durationText",width:16},{header:"Date",key:"date",width:14},{header:"Time",key:"time",width:12},{header:"Summary",key:"summary",width:78},{header:"Recording URL",key:"recordingUrl",width:60},{header:"Campaign ID",key:"campaignId",width:18}];const Re=fe.getRow(1);Re.height=26,Re.eachCell(p=>{p.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FF4472C4"}},p.font={color:{argb:"FFFFFFFF"},bold:!0,size:11},p.alignment={vertical:"middle",horizontal:"center",wrapText:!0},p.border={top:{style:"thin",color:{argb:"FFD9D9D9"}}
8,left:{style:"thin",color:{argb:"FFD9D9D9"}},bottom:{style:"thin",color:{argb:"FFD9D9D9"}},right:{style:"thin",color:{argb:"FFD9D9D9"}}}}),a.forEach(p=>{const P=new Date(p.createdAt),D=le.get(p.id)||ce(p.recordingUrl),v=fe.addRow({callId:p.id,agent:p.agent?.name||"V-Assistant",customer:p.customerNumber||"Unknown",callType:p.type||"",status:p.status||"",hotLead:p.hotLeadEvaluation===!0?"Yes":p.hotLeadEvaluation===!1?"No":"",sentiment:p.sentiment||"",success:p.successEvaluation===!0?"Yes":p.successEvaluation===!1?"No":"",durationSec:p.duration??"",durationText:Be(p.duration),date:P.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:P.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),summary:p.summary||"",recordingUrl:D,campaignId:p.campaignId||""});v.alignment={vertical:"top"},v.getCell("summary").alignment={vertical:"top",wrapText:!0};const F=v.getCell("recordingUrl");D&&(F.value={text:"Download Audio",hyperlink:D},F.font={color:{argb:"FF7030A0"},underline:!0},F.alignment={vertical:"top",wrapText:!1})}),fe.columns.forEach(p=>{if(p.key==="summary"||p.key==="recordingUrl"||!p.eachCell)return;let P=String(p.header??"").length+2;p.eachCell({includeEmpty:!0},D=>{const v=D.value,F=typeof v=="string"?v:v&&typeof v=="object"&&"text"in v&&typeof v.text=="string"?v.text:String(v??"");P=Math.max(P,Math.min(45,F.length+2))}),p.width=P});const dt=await Le.xlsx.writeBuffer(),ut=new Blob([dt],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),ze=URL.createObjectURL(ut),Ne=document.createElement("a");Ne.href=ze,Ne.download=`${st}-call-logs-${new Date().toISOString().slice(0,10)}.xlsx`,Ne.click(),URL.revokeObjectURL(ze),be.success(`Downloaded ${a.length} filtered call logs in Excel format.`)}catch(a){console.error(a);const g=a?.response?.data?.message;be.error(g||"Failed to download filtered call logs. Please try again.")}finally{xe(!1)}}},pe=f.filter(a=>a.hotLeadEvaluation===!0).length,te=Math.max(1,Math.ceil(N/u)),rt=N===0?0:(L-1)*u+1,nt=Math.min(N,L*u),lt=o.useMemo(()=>{const a=[];for(let g=1;g<=te;g++)g===1||g===te||g>=L-1&&g<=L+1?a.push(g):a[a.length-1]!=="gap"&&a.push("gap");return a},[L,te]),it=o.useMemo(()=>[{key:"customer",header:"Call",cell:a=>{const g=a.type==="web_call",_=a.type==="sip_outbound",B=g?We:_?_t:we;return e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-bg-elevated text-fg-muted group-hover:text-fg",children:e.jsx(B,{size:16})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-semibold text-fg",children:g?"Web browser":a.customerNumber||"Unknown caller"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] font-medium text-fg-subtle",children:[e.jsx("span",{children:g?"Web call":_?"Outbound":"Inbound"}),a.hotLeadEvaluation===!0&&e.jsxs(ie,{tone:"warn",children:[e.jsx(ke,{size:10})," Hot"]})]})]})]})}},{key:"agent",header:"Agent",hideBelow:"md",cell:a=>a.mode==="human"?e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-fg",children:a.handledBy?.name||"Team member"}),e.jsx("div",{className:"mt-1",children:e.jsxs(ie,{tone:"info",children:[e.jsx(Ve,{size:10})," Human",a.disposition?` - ${Ye[a.disposition]||a.disposition}`:""]})})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-fg",children:a.agent?.name||"V-Assistant"}),e.jsx("div",{className:"text-[11px] text-fg-subtle",children:"AI agent"})]})},{key:"created",header:"When",hideBelow:"lg",cell:a=>{const g=new Date(a.createdAt);return e.jsxs("div",{className:"whitespace-nowrap",children:[e.jsx("div",{className:"font-medium text-fg",children:g.toLocaleDateString("en-US",{month:"short",day:"numeric"})}),e.jsx("div",{className:"text-[11px] text-fg-subtle",children:g.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})})]})}},{key:"status",header:"Status",cell:a=>e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs(ie,{tone:gs(a.status),children:[a.status==="completed"?e.jsx(Tt,{size:11}):e.jsx(Lt,{size:11}),a.status]}),a.status==="completed"&&e.jsx(ie,{tone:js(a.sentiment),children:a.sentiment||"Unknown"})]})},{key:"metrics",header:"Metrics",hideBelow:"sm",cell:a=>e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg bg-bg-elevated px-2 py-1 font-semibold text-fg",children:[e.jsx(Ke,{size:12,className:"text-brand-500"})," ",Be(a.duration)]}),a.successEvaluation!==void 0&&a.successEvaluation!==null&&e.jsx(ie,{tone:a.successEvaluation?"ok":"bad",children:a.successEvaluation?"Success":"Review"})]})}],[]),ot=N>0?e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm font-medium text-fg-muted",children:[e.jsxs("span",{children:["Showing ",e.jsxs("span",{className:"font-semibold text-fg",children:[rt,"-",nt]})," of ",e.jsx("span",{className:"font-semibold text-fg",children:N.toLocaleStr
8ing()})]}),e.jsxs("label",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-subtle",children:"Rows"}),e.jsx("select",{value:u,onChange:a=>{m(Number(a.target.value)),i(1)},className:"h-8 rounded-lg border border-line bg-card px-2 text-sm font-semibold text-fg outline-none focus:ring-2 focus:ring-brand-500/20",children:bs.map(a=>e.jsx("option",{value:a,children:a},a))})]})]}),te>1&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>i(a=>Math.max(1,a-1)),disabled:L===1||h,className:"rounded-lg border border-line bg-card px-3 py-1.5 text-sm font-semibold text-fg-muted hover:bg-card-hover disabled:opacity-40",children:"Prev"}),lt.map((a,g)=>a==="gap"?e.jsx("span",{className:"px-2 text-fg-subtle",children:"..."},`gap-${g}`):e.jsx("button",{type:"button",onClick:()=>i(a),disabled:h,"aria-current":L===a?"page":void 0,className:`min-w-8 rounded-lg border px-2.5 py-1.5 text-sm font-bold transition-colors disabled:opacity-50 ${L===a?"border-brand-500 bg-brand-500 text-white":"border-line bg-card text-fg-muted hover:bg-card-hover"}`,children:a},a)),e.jsx("button",{type:"button",onClick:()=>i(a=>Math.min(te,a+1)),disabled:L===te||h,className:"rounded-lg border border-line bg-card px-3 py-1.5 text-sm font-semibold text-fg-muted hover:bg-card-hover disabled:opacity-40",children:"Next"})]})]}):null;return e.jsxs(Ot,{children:[e.jsx(It,{icon:we,title:"Call logs",description:"Review calls, recordings, transcripts, outcomes, and human-call notes.",actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:at,disabled:h||X||N===0,className:"inline-flex min-h-9 items-center justify-center gap-2 rounded-xl border border-line bg-card px-3 py-2 text-sm font-semibold text-fg-muted hover:bg-card-hover disabled:cursor-not-allowed disabled:opacity-40",children:[X?e.jsx(He,{size:16,className:"animate-spin"}):e.jsx(Rt,{size:16}),X?"Exporting...":"Export"]}),e.jsxs(pt,{to:"/dashboard/call-quality",className:"inline-flex min-h-9 items-center justify-center gap-2 rounded-xl border border-line bg-card px-3 py-2 text-sm font-semibold text-fg-muted hover:bg-card-hover",children:[e.jsx(Se,{size:16})," Quality"]})]})}),e.jsxs(Mt,{actions:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden items-center gap-2 text-xs text-fg-muted xl:flex",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-fg",children:N.toLocaleString()})," total"]}),pe>0&&e.jsxs("span",{children:[e.jsx("strong",{className:"text-fg",children:pe})," hot"]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>ee(a=>!a),className:`relative inline-flex h-9 items-center gap-1.5 rounded-xl border px-3 text-sm font-semibold ${re>0?"border-brand-500/40 bg-brand-500/[0.06] text-brand-700 dark:text-brand-200":"border-line bg-card text-fg-muted hover:bg-card-hover"}`,children:[e.jsx(zt,{size:14})," More filters",re>0&&e.jsx("span",{className:"grid h-5 min-w-5 place-items-center rounded-full bg-brand-500 px-1 text-[10px] font-bold text-white",children:re})]}),je&&e.jsxs("div",{className:"absolute right-0 z-30 mt-2 w-80 rounded-2xl border border-line bg-card p-3 shadow-xl",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(q,{value:A,onChange:E,label:"Lead",options:[{value:"all",label:`All leads${pe?` (${pe} hot)`:""}`},{value:"hot",label:"Hot leads"},{value:"cold",label:"Cold / none"}]}),e.jsx(q,{value:n,onChange:K,label:"Campaign",options:[{value:"all",label:"All campaigns"},...b.map(a=>({value:a.id,label:a.name||`Campaign ${a.id.slice(0,8)}`}))]}),e.jsx(q,{value:O,onChange:Y,label:"Sentiment",options:fs}),e.jsx(q,{value:M,onChange:Q,label:"Duration",options:hs})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between border-t border-line pt-3",children:[e.jsxs("span",{className:"text-xs text-fg-subtle",children:[re," secondary filter",re===1?"":"s"," active"]}),e.jsxs("button",{type:"button",onClick:()=>{Te(),ee(!1)},className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-line px-2.5 text-xs font-semibold text-fg-muted hover:bg-card-hover",children:[e.jsx(Ce,{size:13})," Clear"]})]})]})]}),ye&&e.jsxs("button",{type:"button",onClick:Te,className:"inline-flex h-9 items-center gap-1.5 rounded-xl border border-line bg-card px-3 text-sm font-semibold text-fg-muted hover:bg-card-hover",children:[e.jsx(Ce,{size:14})," Clear"]})]}),children:[e.jsx(Ut,{value:d,onChange:y,placeholder:"Search calls",className:"w-full sm:w-56"}),e.jsx(Dt,{dateRange:z,onDateRangeChange:Z,className:"w-full sm:w-auto"}),e.jsx(q,{value:T,onChange:tt,label:"Agent",options:[{value:"all",label:"All agents"},...l.map(a=>({value:a.id,label:a.name}))]}),e.jsx(q,{value:C,onChange:H,label:"Status",options:xs}),e.jsx(q,{value:R,onChange:ae,label:"Call type",options:ps})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Bt,{dense:!0,columns:it,rows:f,rowKey:a=>a.id,onRowClick:S,selectedKey:k?.id??null,loading:h,empty:{icon:we,title:ye?"No calls match these filters":"No calls yet",text:ye?"Clear filters or widen the date range.":"Completed and active calls will appear here."},footer:ot})}),k&&e.jsx(Pt,{storageKey:"call-details",width:640,label:"Call details",children:e.jsx(ds,{inline:!0,call:k,calls:f,onClose:()=>S(null),onSelectCall:S})})]})};export{Bs 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.