1import{r as y,w as $,l as n,m as i,B as F,q as a,u as l,D as B,J as Q,F as S,v as R,aa as W,ac as Z,Z as H,K as u,p as c,y as z,e as O}from"./vue-vendor-B52ivs5F.js";import{b as X}from"./query-vendor-Ab0nfCYP.js";import{_ as tt}from"./DateRangeButton-VLsqmGWj.js";import{_ as et}from"./Pagination-BR1DzaAC.js";import{S as at}from"./companies-DMwAHpDz.js";import{r as rt}from"./knox-BBPew7c8.js";import{_ as st}from"./KnoxAdminTabs-eC8apC-I.js";import{_ as ot}from"./KnoxConversationModal-CGUBZHRy.js";import{R as nt}from"./ui-vendor-D-1UBobO.js";import"./DateRangePicker-DiHdPMGJ.js";import"./date-vendor-HBGOQ70J.js";import"./index-NM9cAr_v.js";import"./twilio-DAuME2Y9.js";import"./charts-D4hDxUnJ.js";import"./socket-CzTGKfeH.js";const lt={class:"flex h-full flex-col"},dt={class:"flex items-center justify-between border-b border-gray-200 bg-white px-6 py-4 dark:border-gray-700 dark:bg-gray-800"},it=["disabled"],ut={class:"flex flex-wrap items-center gap-2 border-b border-gray-200 bg-white px-6 py-3 dark:border-gray-700 dark:bg-gray-800"},yt=["onClick"],pt=["disabled"],gt={class:"flex items-center gap-1.5 text-xs text-gray-600 dark:text-gray-400"},xt={class:"ml-auto text-[11px] text-gray-500 dark:text-gray-400"},mt={key:0},ct={class:"flex-1 overflow-y-auto p-6"},ft={key:0,class:"flex items-center justify-center py-20"},bt={key:1,class:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-300"},vt={key:0,class:"rounded-xl border border-dashed border-gray-300 px-6 py-16 text-center text-sm text-gray-500 dark:border-gray-600 dark:text-gray-400"},_t={key:1,class:"overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800"},kt={class:"min-w-full text-sm"},ht={class:"divide-y divide-gray-100 dark:divide-gray-700"},wt=["onClick"],Dt={class:"px-4 py-2 text-[11px] whitespace-nowrap text-gray-600 dark:text-gray-300"},Ct={class:"px-4 py-2 text-[11px] whitespace-nowrap"},Ft={key:0,class:"font-medium text-gray-700 dark:text-gray-200"},St={class:"font-mono text-gray-400 dark:text-gray-500"},Nt={class:"max-w-md truncate px-4 py-2 text-gray-900 dark:text-gray-100"},It={class:"px-4 py-2 text-xs text-gray-600 dark:text-gray-300"},Tt={key:0,class:"rounded-full bg-gray-100 px-2 py-0.5 dark:bg-gray-700"},Mt={class:"px-4 py-2 text-xs text-gray-600 dark:text-gray-300"},Lt={key:0,class:"rounded-full bg-teal-50 px-2 py-0.5 text-teal-700 dark:bg-teal-900/30 dark:text-teal-300"},$t={class:"px-4 py-2 text-right text-xs text-gray-700 tabular-nums dark:text-gray-200"},Bt={class:"px-4 py-2 text-right text-xs text-gray-700 tabular-nums dark:text-gray-200"},Rt={class:"px-4 py-2 text-right text-xs text-gray-700 tabular-nums dark:text-gray-200"},zt={class:"px-4 py-2 text-right text-xs text-gray-700 tabular-nums dark:text-gray-200"},Xt={__name:"KnoxConversations",setup(Ot){const K=[{key:"today",label:"Today"},{key:"yesterday",label:"Yesterday"},{key:"last_7_days",label:"Last 7 days"},{key:"last_30_days",label:"Last 30 days"},{key:"last_90_days",label:"Last 90 days"}],D=y("last_7_days"),f=y(""),b=y(""),x=y(L("last_7_days")),C=y(""),k=y(""),m=y(1),v=y(25),h=y(null),q=O(()=>["admin","knox","conversations",x.value.from,x.value.to,k.value,m.value,v.value]),{data:g,isLoading:P,isFetching:N,error:I,refetch:T}=X({queryKey:q,queryFn:()=>rt({from:x.value.from,to:x.value.to,companyId:k.value||void 0,page:m.value,pageSize:v.value}),refetchOnWindowFocus:!1,keepPreviousData:!0}),_=y({});$(()=>g.value?.rows,async r=>{if(!Array.isArray(r)||!r.length)return;const t=[...new Set(r.map(e=>e.company_id).filter(Boolean))].filter(e=>_.value[e]===void 0);if(t.length)try{const e=await at(t),o={..._.value};for(const s of e?.rows||[])o[s._id]=s.company_name||"";for(const s of t)o[s]===void 0&&(o[s]="");_.value=o}catch{}},{immediate:!0});const V=O(()=>{const r=I.value;return r?r.response?.data?.message||r.message||"Failed to load conversations.":""});$([x,k,v],()=>{m.value=1});function A(r){D.value=r,f.value="",b.value="",x.value=L(r)}function U(){if(!f.value||!b.value)return;D.value=null;const[r,t,e]=f.value.split("-").map(Number),[o,s,p]=b.value.split("-").map(Number),d=new Date(r,t-1,e),J=new Date(o,s-1,p+1);x.value={from:d.toISOString(),to:J.toISOString()}}function M(){k.value=C.value.trim()}function Y(r){h.value=r}function L(r){const t=new Date,e=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()),o=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()+1);let s,p;switch(r){case"today":s=e(t),p=o(t);break;case"yesterday":{const d=new Date(t);d.setDate(d.getDate()-1),s=e(d),p=e(t);break}case"last_7_days":s=e(t),s.setDate(s.getDate()-6),p=o(t);break;case"last_30_days":s=e(t),s.setDate(s.getDate()-29),p=o(t);break;case"last_90_days":s=e(t),s.setDate(s.getDate()-89),p=o(t);break;default:s=e(t),p=o(t)}return{from:s.toISOString(),to:p.toISOString()}}const w=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});function j(r){const e=(new Date(r).getTime()-Date.now())/1e3,o=Math.abs(e);return o<60?w.format(Math.round(e),"second"):o<3600?w.format(Math.round(e/60),"minute"):o<86400?w.format(Math.round(e/3600),"hour"):o<604800?w.format(Math.round(e/86400),"day"):new Date(r).toLocaleDateString()}function E(r){const t=Number(r||0);return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"k":String(t)}function G(r){const t=Number(r||0);return t>=1e3?(t/1e3).toFixed(1)+"s":t+"ms"}return(r,t)=>(n(),i("div",lt,[F(st),a("div",dt,[t[10]||(t[10]=a("div",null,[a("h1",{class:"text-xl font-bold text-gray-900 dark:text-white"},"Conversations"),a("p",{class:"mt-0.5 text-xs text-gray-500 dark:text-gray-400"}," Browse Nox conversation threads. Click a row to open the full chat replay with inline tool calls. ")],-1)),a("button",{onClick:t[0]||(t[0]=(...e)=>l(T)&&l(T)(...e)),disabled:l(N),class:"inline-flex items-center gap-2 rounded-lg bg-teal-50 px-4 py-2 text-sm font-medium text-teal-600 transition-colors hover:bg-teal-100 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-teal-500/20 dark:text-teal-400 dark:hover:bg-teal-500/30"},[F(l(nt),{size:16,class:B(l(N)?"animate-spin":"")},null,8,["class"]),t[9]||(t[9]=Q(" Refresh ",-1))],8,it)]),a("div",ut,[(n(),i(S,null,R(K,e=>a("button",{key:e.key,onClick:o=>A(e.key),class:B(["rounded-full border px-3 py-1 text-xs transition-colors",D.value===e.key?"border-teal-400 bg-teal-50 text-teal-700 dark:border-teal-500 dark:bg-teal-900/30 dark:text-teal-400":"border-gray-300 bg-white text-gray-600 hover:border-teal-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300"])},u(e.label),11,yt)),64)),t[12]||(t[12]=a("span",{class:"mx-2 h-5 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),F(tt,{start:f.value,"onUpdate:start":t[1]||(t[1]=e=>f.value=e),end:b.value,"onUpdate:end":t[2]||(t[2]=e=>b.value=e)},null,8,["start","end"]),a("button",{onClick:U,disabled:!f.value||!b.value,class:"rounded-lg border border-teal-400 px-3 py-1 text-xs font-medium text-teal-600 hover:bg-teal-50 disabled:opacity-40 dark:border-teal-500 dark:text-teal-400 dark:hover:bg-teal-900/30"}," Apply ",8,pt),t[13]||(t[13]=a("span",{class:"mx-2 h-5 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),a("label",gt,[t[11]||(t[11]=a("span",null,"Company ID",-1)),W(a("input",{"onUpdate:modelValue":t[3]||(t[3]=e=>C.value=e),type:"text",placeholder:"all companies",class:"w-64 roun
1ded-lg border border-gray-300 px-2 py-1 font-mono text-xs dark:border-gray-600 dark:bg-gray-700 dark:text-white",onKeyup:H(M,["enter"])},null,544),[[Z,C.value]])]),a("button",{onClick:M,class:"rounded-lg border border-gray-300 px-3 py-1 text-xs font-medium text-gray-700 hover:border-teal-300 dark:border-gray-600 dark:text-gray-200"}," Filter "),a("span",xt,[l(g)?(n(),i("span",mt,u(l(g).total)+" threads",1)):c("",!0)])]),a("div",ct,[l(P)?(n(),i("div",ft,[...t[14]||(t[14]=[a("div",{class:"h-10 w-10 animate-spin rounded-full border-4 border-teal-200 border-t-teal-600"},null,-1)])])):l(I)?(n(),i("div",bt,u(V.value),1)):l(g)?(n(),i(S,{key:2},[l(g).rows.length?(n(),i("div",_t,[a("table",kt,[t[15]||(t[15]=a("thead",{class:"border-b border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900/40"},[a("tr",{class:"text-[11px] tracking-wide text-gray-500 uppercase dark:text-gray-400"},[a("th",{class:"px-4 py-2 text-left font-medium"},"Latest"),a("th",{class:"px-4 py-2 text-left font-medium"},"Company"),a("th",{class:"px-4 py-2 text-left font-medium"},"Last question"),a("th",{class:"px-4 py-2 text-left font-medium"},"Agent"),a("th",{class:"px-4 py-2 text-left font-medium"},"Intent"),a("th",{class:"px-4 py-2 text-right font-medium"},"Turns"),a("th",{class:"px-4 py-2 text-right font-medium"},"Tools"),a("th",{class:"px-4 py-2 text-right font-medium"},"Tokens"),a("th",{class:"px-4 py-2 text-right font-medium"},"Latency")])],-1)),a("tbody",ht,[(n(!0),i(S,null,R(l(g).rows,e=>(n(),i("tr",{key:e.thread_id,onClick:o=>Y(e.thread_id),class:"cursor-pointer hover:bg-teal-50/50 dark:hover:bg-teal-900/10"}
1,[a("td",Dt,u(j(e.latest_at)),1),a("td",Ct,[_.value[e.company_id]?(n(),i("div",Ft,u(_.value[e.company_id]),1)):c("",!0),a("div",St,u(e.company_id),1)]),a("td",Nt,u(e.last_question),1),a("td",It,[e.last_routed_agent?(n(),i("span",Tt,u(e.last_routed_agent),1)):c("",!0)]),a("td",Mt,[e.last_intent?.primary_intent?(n(),i("span",Lt,u(e.last_intent.primary_intent),1)):c("",!0)]),a("td",$t,u(e.turn_count),1),a("td",Bt,u(e.total_tool_calls),1),a("td",Rt,u(E(e.total_input_tokens+e.total_output_tokens)),1),a("td",zt,u(G(e.total_latency_ms)),1)],8,wt))),128))])])])):(n(),i("div",vt," No conversations in this window. ")),l(g)?.rows?.length?(n(),z(et,{key:2,page:m.value,"page-size":v.value,total:l(g).total||0,"item-name":"threads","show-per-page-selector":"","show-page-buttons":"",onPrev:t[4]||(t[4]=e=>m.value--),onNext:t[5]||(t[5]=e=>m.value++),onGoto:t[6]||(t[6]=e=>m.value=e),"onUpdate:pageSize":t[7]||(t[7]=e=>v.value=e)},null,8,["page","page-size","total"])):c("",!0)],64)):c("",!0)]),h.value?(n(),z(ot,{key:0,"thread-id":h.value,onClose:t[8]||(t[8]=e=>h.value=null)},null,8,["thread-id"])):c("",!0)]))}};export{Xt 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.