import{t as f,k as y,j as s}from"./vendor-react-DrAK5R0M.js";import{T as h}from"./TopBar-C2CFg9gl.js";import{h as b,b_ as g,E as n,D as j,C as N}from"./index-7eqLqzhB.js";import{h as p}from"./headerCopy-CYEmez92.js";import{U as v,b as C,c as S,F as _,A as w,C as B,g as U,o as u}from"./vendor-icons-Cu2Ube6F.js";import"./vendor-visuals-BHLltLY6.js";import"./vendor-radix-CwTvaGVy.js";function A(a){return a.name??[a.first_name,a.last_name].filter(Boolean).join(" ")??a.email??"Unnamed contact"}function P(){const[a]=f(),o=y(),{openDrawer:i}=b(),c=a.get("q")??"",{data:t,isLoading:x}=g(c),d=[{key:"contacts",label:"Contacts",icon:v,color:n.contacts.text,items:(t==null?void 0:t.contacts)??[],open:e=>{o("/contacts"),i("contact",e.id)},title:A,detail:e=>e.email??e.company_name??e.company??""},{key:"accounts",label:"Accounts",icon:C,color:n.accounts.text,items:(t==null?void 0:t.accounts)??[],open:e=>{o("/accounts"),i("account",e.id)},title:e=>e.name??e.domain??"Unnamed account",detail:e=>e.domain??e.industry??""},{key:"opportunities",label:"Opportunities",icon:S,color:n.opportunities.text,items:(t==null?void 0:t.opportunities)??[],open:e=>{o("/opportunities"),i("opportunity",e.id)},title:e=>e.name??"Unnamed opportunity",detail:e=>[e.stage,e.amount?j(Number(e.amount)):null].filter(Boolean).join(" · ")},{key:"useCases",label:"Use Cases",icon:_,color:n.useCases.text,items:(t==null?void 0:t.useCases)??[],open:e=>{o("/use-cases"),i("use-case",e.id)},title:e=>e.name??"Unnamed use case",detail:e=>e.stage??e.description??""},{key:"activities",label:"Activities",icon:w,color:n.activities.text,items:(t==null?void 0:t.activities)??[],open:()=>o("/activities"),title:e=>e.subject??e.body??"Activity",detail:e=>e.activity_type??e.type??""},{key:"assignments",label:"Handoffs",icon:B,color:n.assignments.text,items:(t==null?void 0:t.assignments)??[],open:e=>{o("/handoffs"),i("assignment",e.id)},title:e=>e.title??"Handoff",detail:e=>[e.status,e.priority].filter(Boolean).join(" · ")},{key:"contextEntries",label:"Signals & Memory",icon:U,color:n.context.text,items:(t==null?void 0:t.contextEntries)??[],open:e=>o(e.memory_status==="signal"?"/context?tab=signals":"/context?tab=browser"),title:e=>e.title??e.body??"Context entry",detail:e=>[e.memory_status==="signal"?"Signal":"Memory",e.context_type,e.subject_type].filter(Boolean).join(" · ")}],l=d.reduce((e,m)=>e+m.items.length,0);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(h,{title:"Search",icon:u,iconClassName:"text-primary",description:c?p(`Visible results for "${c}"`,l,"result"):p("Search records and customer context visible to you",l,"result")}),s.jsx("div",{className:"flex-1 overflow-y-auto px-4 md:px-6 pb-24 md:pb-6 pt-2",children:x?s.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(e=>s.jsx("div",{className:"h-16 rounded-xl bg-muted/50 animate-pulse"},e))}):l===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[s.jsx(u,{className:"w-8 h-8 text-muted-foreground/40 mb-3"}),s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"No results found"}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Try a customer name, account domain, email, deal, context phrase, or handoff title."})]}):s.jsx("div",{className:"space-y-5",children:d.filter(e=>e.items.length>0).map(e=>{const m=e.icon;return s.jsxs("section",{className:"space-y-2",children:[s.jsx("h2",{className:"text-xs font-display font-semibold uppercase tracking-wide text-muted-foreground",children:e.label}),s.jsx("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:e.items.map(r=>s.jsxs("button",{onClick:()=>e.open(r),className:"w-full flex items-center gap-3 px-4 py-3 text-left border-b border-border last:border-0 hover:bg-muted/40 transition-colors",children:[s.jsx(m,{className:N("w-4 h-4 flex-shrink-0",e.color)}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:e.title(r)}),e.detail(r)&&s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.detail(r)})]})]},r.id))})]},e.key)})})})]})}export{P as SearchResultsPage};
