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