// @bun
import{gql as L}from"@apollo/client";import{useQuery as P}from"@apollo/client/react";import{useTemplateRuntime as W}from"@contractspec/lib.example-shared-ui";import{MessageCircle as X,Users as Z}from"lucide-react";import{useMemo as $}from"react";import{jsx as f,jsxs as k}from"react/jsx-runtime";var b=L`
  query Conversations($projectId: ID!) {
    conversations(projectId: $projectId) {
      id
      name
      isGroup
      updatedAt
      participants {
        id
        userId
        displayName
      }
    }
  }
`;function Y({selectedId:G,onSelect:H}){let{projectId:J}=W(),{data:B,loading:D}=P(b,{variables:{projectId:J},fetchPolicy:"cache-and-network"}),z=$(()=>B?.conversations??[],[B]);return k("aside",{className:"h-full overflow-y-auto rounded-2xl border border-border bg-card",children:[k("header",{className:"px -4 flex items-center justify-between border-border border-b px-4 py-3",children:[k("div",{children:[f("p",{className:"font-semibold text-sm",children:"Conversations"}),f("p",{className:"text-muted-foreground text-xs",children:D?"Loading\u2026":`${z.length} active`})]}),f(Z,{className:"h-4 w-4 text-muted-foreground"})]}),k("div",{className:"divide-y divide-border/70",children:[z.map((w)=>{let K=G===w.id;return k("button",{type:"button",className:`flex w-full flex-col items-start gap-1 px-4 py-3 text-left transition ${K?"bg-violet-500/10 text-foreground":"hover:bg-muted/40"}`,onClick:()=>H?.(w.id),children:[k("div",{className:"flex items-center gap-2",children:[f(X,{className:"h-4 w-4 text-muted-foreground"}),f("span",{className:"font-medium text-sm",children:w.name||"Untitled conversation"})]}),f("p",{className:"text-muted-foreground text-xs",children:w.participants.map((F)=>F.displayName||F.userId).join(" \xB7 ")})]},w.id)}),!D&&z.length===0?f("p",{className:"p-4 text-center text-muted-foreground text-xs",children:"No conversations yet."}):null]})]})}export{Y as ConversationList};
