(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,69638,e=>{"use strict";var s=e.i(43476),t=e.i(71645);function a(){let[e,a]=(0,t.useState)([]),[r,l]=(0,t.useState)(""),[c,n]=(0,t.useState)([]),[o,d]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{fetch("/api/bots").then(e=>e.json()).then(e=>{a(e),e.length>0&&l(e[0]._id)}).catch(console.error)},[]),(0,t.useEffect)(()=>{r&&(d(!0),fetch(`/api/conversations/${r}`).then(e=>e.json()).then(e=>n(e.conversations||[])).catch(console.error).finally(()=>d(!1)))},[r]),(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-[var(--color-text-secondary)]",children:"Conversations"}),(0,s.jsx)("h1",{className:"font-display text-3xl font-bold",children:"Recent conversations"}),(0,s.jsx)("p",{className:"text-[var(--color-text-secondary)]",children:"View chat transcripts, leads captured, and channels."})]}),e.length>0&&(0,s.jsx)("select",{value:r,onChange:e=>l(e.target.value),className:"input max-w-xs",children:e.map(e=>(0,s.jsx)("option",{value:e._id,children:e.name},e._id))}),o?(0,s.jsx)("div",{className:"py-12 text-center text-[var(--color-text-secondary)]",children:"Loading conversations..."}):0===c.length?(0,s.jsxs)("div",{className:"rounded-2xl border border-[var(--color-border-light)] bg-white p-12 text-center shadow-sm",children:[(0,s.jsx)("p",{className:"text-lg font-semibold",children:"No conversations yet"}),(0,s.jsx)("p",{className:"mt-1 text-sm text-[var(--color-text-secondary)]",children:"Conversations will appear here once visitors start chatting."})]}):(0,s.jsx)("div",{className:"rounded-2xl border border-[var(--color-border-light)] bg-white shadow-sm",children:(0,s.jsx)("div",{className:"divide-y divide-[var(--color-border-light)]",children:c.map(e=>(0,s.jsxs)("div",{className:"flex flex-col gap-2 px-5 py-4 md:flex-row md:items-center md:justify-between",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-semibold text-white ${"whatsapp"===e.channel?"bg-green-500":"bg-[var(--color-bg-brand)]"}`,children:e.channel}),(0,s.jsxs)("span",{className:"text-xs text-[var(--color-text-secondary)]",children:[e.messageCount," messages"]})]}),(0,s.jsx)("p",{className:"mt-1 text-sm text-[var(--color-text-secondary)]",children:e.lastMessage||"No messages"})]}),(0,s.jsxs)("div",{className:"text-right text-sm",children:[e.lead?.email&&(0,s.jsx)("p",{className:"text-xs text-[var(--color-bg-brand)]",children:e.lead.email}),(0,s.jsx)("p",{className:"text-xs text-[var(--color-text-secondary)]",children:new Date(e.updatedAt).toLocaleString()})]})]},e._id))})})]})}e.s(["default",()=>a])}]);