1import{ad as m,ae as h,af as x,r as d,c,d as I,j as e,F as $,a as o,e as y,i as j,f as L,g as O,B as p,y as ke,D as N,aD as r,h as Ae,I as E,P as Be,ag as Qe,b6 as ze,b7 as Ve,b8 as H,b9 as W,ar as U,as as J,at as X,au as Y,av as D,x as Se,aO as Ge,aP as He,aQ as We,aR as Ue,aS as Je}from"./index-DQ05VIVn.js";import{l as Xe,d as Ye,s as Ze,D as es}from"./DuplicateClientsPanel-BzYUFXTq.js";import{S as ss}from"./search-Dov9od80.js";import"./arrow-right-B-H8xdPn.js";const as=m({method:"GET"}).middleware([h]).handler(x("src_lib_identity_functions_ts--getIdentityOverview_createServerFn_handler")),ts=m({method:"GET"}).middleware([h]).handler(x("src_lib_identity_functions_ts--listIdentityReviewQueue_createServerFn_handler")),ns=m({method:"GET"}).middleware([h]).handler(x("src_lib_identity_functions_ts--listIdentityMappingSubjects_createServerFn_handler")),ls=m({method:"GET"}).middleware([h]).handler(x("src_lib_identity_functions_ts--listIdentityKeys_createServerFn_handler")),is=m({method:"POST"}).middleware([h]).handler(x("src_lib_identity_functions_ts--resolveIdentityReviewItem_createServerFn_handler")),rs=m({method:"POST"}).middleware([h]).handler(x("src_lib_identity_functions_ts--ignoreIdentityReviewItem_createServerFn_handler")),ds=m({method:"POST"}).middleware([h]).handler(x("src_lib_identity_functions_ts--reopenIdentityReviewItem_createServerFn_handler")),cs=m({method:"POST"}).middleware([h]).handler(x("src_lib_identity_functions_ts--deleteIdentityKey_createServerFn_handler")),os=m({method:"GET"}).middleware([h]).handler(x("src_lib_identity_functions_ts--searchIdentityEverywhere_createServerFn_handler")),us=m({method:"GET"}).middleware([h]).handler(x("src_lib_identity_functions_ts--getIdentityDossier_createServerFn_handler")),ms=m({method:"POST"}).middleware([h]).handler(x("src_lib_identity_functions_ts--bulkResolveIdentityItems_createServerFn_handler")),hs=m({method:"POST"}).middleware([h]).handler(x("src_lib_identity_functions_ts--bulkIgnoreIdentityItems_createServerFn_handler")),xs=m({method:"POST"}).middleware([h]).handler(x("src_lib_identity_functions_ts--addIdentityKeyManually_createServerFn_handler")),ps=m({method:"GET"}).middleware([h]).handler(x("src_lib_identity-perf_functions_ts--getIdentityPerfOverview_createServerFn_handler")),_e={ledger:"Answered from memory (fast path)",resolver:"Full history scan (slow path)",unmatched:"Nothing matched",invalid:"Not a valid identifier"},ys=[{label:"Last hour",hours:1},{label:"Last 24 hours",hours:24},{label:"Last 7 days",hours:168},{label:"Last 30 days",hours:720}];function ne({label:a,value:u,hint:v}){return e.jsxs("div",{className:"rounded-lg border p-3",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:a}),e.jsx("div",{className:"mt-1 text-xl font-semibold",children:u}),v?e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:v}):null]})}function js({workspaceId:a}){const[u,v]=d.useState(24),R=c(ps),{data:i,isLoading:F}=I({queryKey:["identity-perf",a,u],queryFn:()=>R({data:{workspaceId:a,hours:u}}),enabled:!!a,refetchInterval:3e4});if(F)return e.jsx($,{className:"h-64 w-full"});const g=i&&i.trend.earlier.medianMs>0?Math.round((i.trend.recent.medianMs-i.trend.earlier.medianMs)/i.trend.earlier.medianMs*100):null;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:ys.map(n=>e.jsx(o,{size:"sm",variant:u===n.hours?"default":"outline",onClick:()=>v(n.hours),children:n.label},n.hours))}),!i||i.total===0?e.jsx(y,{children:e.jsx(j,{className:"py-8 text-sm text-muted-foreground",children:"No lookups recorded in this window yet. Search an email, phone number or domain in the app and the timings will show up here within a few seconds."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(ne,{label:"Lookups",value:String(i.total),hint:`Last ${i.windowHours}h`}),e.jsx(ne,{label:"Typical time",value:`${i.overall.medianMs} ms`,hint:`p95 ${i.overall.p95Ms} ms · worst ${i.overall.worstMs} ms`}),e.jsx(ne,{label:"Database reads per lookup",value:String(i.overall.avgDbQueries),hint:"Lower is cheaper and faster"}),e.jsx(ne,{label:"AI calls per lookup",value:String(i.overall.avgAiCalls),hint:"Credit spend on this flow"})]}),e.jsxs(y,{children:[e.jsx(L,{className:"pb-2",children:e.jsx(O,{className:"text-base",children:"Did it get faster?"})}),e.jsxs(j,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("span",{children:["Earlier half: ",i.trend.earlier.medianMs," ms typical"]}),e.jsx("span",{children:"â"}),e.jsxs("span",{children:["Recent half: ",i.trend.recent.medianMs," ms typical"]}),g!==null?e.jsx(p,{variant:g<=0?"secondary":"destructive",children:g<=0?`${Math.abs(g)}% faster`:`${g}% slower`}):null]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Compares the first and second half of the selected window, so you can confirm a fix landed instead of guessing."})]})]}),e.jsxs(y,{children:[e.jsx(L,{className:"pb-2",children:e.jsx(O,{className:"text-base",children:"How lookups were answered"})}),e.jsx(j,{className:"space-y-2",children:i.byPath.map(n=>e.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium",children:_e[n.label]??n.label}),e.jsxs("span",{className:"text-muted-foreground",children:[n.count," lookups · ",n.share,"% of all"]})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["typical ",n.medianMs," ms · p95 ",n.p95Ms," ms · worst ",n.worstMs," ms · ",n.avgDbQueries," ","database reads · ",n.avgAiCalls," AI calls · matched ",n.matchRate,"%"]})]},n.label))})]}),e.jsxs(y,{children:[e.jsx(L,{className:"pb-2",children:e.jsx(O,{className:"text-base",children:"Slowest lookups, step by step"})}),e.jsx(j,{className:"space-y-2",children:i.slowest.map((n,P)=>e.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{className:"font-medium",children:[n.totalMs," ms · ",_e[n.path]??n.path,n.kind?` · ${n.kind}`:""]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(n.createdAt).toLocaleStr
1ing()})]}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:n.spans.length?n.spans.map(w=>`${w.name} ${w.ms} ms`).join(" · "):"No step detail recorded"})]},`${n.createdAt}-${P}`))})]})]})]})}function vs({workspaceId:a}){const u=ke(),v=c(Xe),R=c(Ye),i=c(Ze),[F,g]=d.useState(""),n=I({queryKey:["company-domains",a],enabled:!!a,queryFn:()=>v({data:{workspaceId:a}})}),P=()=>{u.invalidateQueries({queryKey:["company-domains",a]}),u.invalidateQueries({queryKey:["client-book"]})},w=N({mutationFn:()=>R({data:{workspaceId:a}}),onSuccess:l=>{r.success(l.found.added.length?`Found ${l.found.added.length} new company domain(s): ${l.found.added.join(", ")}`:"No new company domains found in the meeting history."),P()},onError:l=>r.error(l.message)}),q=N({mutationFn:l=>i({data:{workspaceId:a,...l}}),onSuccess:(l,A)=>{r.success(A.active?`${A.domain} marked as ours`:`${A.domain} turned off`),g(""),P()},onError:l=>r.error(l.message)});return e.jsxs(y,{children:[e.jsxs(L,{children:[e.jsx(O,{children:"Our own email domains"}),e.jsx(Ae,{children:"Email domains that belong to the company, not to a client. Brain will never file a meeting under a client because of one of these addresses, and a meeting where everyone is on one of these domains is treated as an internal team meeting."})]}),e.jsxs(j,{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(E,{placeholder:"yourcompany.com",value:F,onChange:l=>g(l.target.value)}),e.jsxs(o,{onClick:()=>q.mutate({domain:F.trim(),active:!0}),disabled:!F.trim()||q.isPending||!a,children:[e.jsx(Be,{className:"mr-1 h-4 w-4"}),"Add"]}),e.jsxs(o,{variant:"outline",onClick:()=>w.mutate(),disabled:w.isPending||!a,title:"Look through the meeting history for domains that behave like company mailboxes",children:[e.jsx(ss,{className:"mr-1 h-4 w-4"}),w.isPending?"Lookingâ¦":"Find ours automatically"]})]}),n.isLoading?e.jsx($,{className:"h-16 w-full"}):(n.data??[]).length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No company domains recorded yet. Add yours, or let Brain look through the meeting history."}):e.jsx("div",{className:"space-y-2",children:(n.data??[]).map(l=>e.jsxs("div",{className:"flex items-center justify-between rounded-md border p-2 text-sm",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:l.domain}),e.jsx(p,{variant:"outline",className:"text-[10px]",children:l.source==="manual"?"added by hand":"found automatically"}),!l.is_active&&e.jsx(p,{variant:"outline",className:"text-[10px]",children:"off"})]}),e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[l.detected_mailboxes??0," mailboxes seen across ",l.detected_meetings??0," ","meetings"]})]}),e.jsx(o,{size:"sm",variant:"ghost",disabled:q.isPending,onClick:()=>q.mutate({domain:l.domain,active:!l.is_active}),children:l.is_active?"Turn off":"Turn on"})]},l.id))})]})]})}const k={email:"Email address",phone10:"Phone number",domain:"Company domain",calendar_event:"Calendar event",thread:"Message thread",stripe_customer:"Stripe customer",lead_event:"Lead record",name:"Full name"},Ce=Object.keys(k);function le({label:a,value:u,hint:v}){return e.jsx(y,{children:e.jsxs(j,{className:"pt-5",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:a}),e.jsx("div",{className:"mt-1 text-2xl font-semibold",children:u}),v?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:v}):null]})})}function ws(){const a=Qe()??"",u=ke(),v=c(as),R=c(ts),i=c(ns),F=c(ls),g=c(os),n=c(us),P=c(is),w=c(rs),q=c(ds),l=c(cs),A=c(xs),Ie=c(ms),Fe=c(hs),[B,Ke]=d.useState(""),[S,ie]=d.useState(null),[b,Te]=d.useState("open"),[Q,he]=d.useState("all"),[z,xe]=d.useState(""),[re,M]=d.useState({}),[de,Pe]=d.useState(""),[ce,qe]=d.useState({}),[Z,Me]=d.useState(""),[ee,De]=d.useState("all"),[_,se]=d.useState({kind:"email",value:"",subject:""}),{data:f}=I({queryKey:["identity-overview",a],queryFn:()=>v({data:{workspaceId:a}}),enabled:!!a}),{data:oe,isFetching:Ee}=I({queryKey:["identity-search",a,B],queryFn:()=>g({data:{workspaceId:a,query:B}}),enabled:!!a&&B.trim().length>=2}),{data:pe,isLoading:$e}=I({queryKey:["identity-dossier",a,S?.subjectType,S?.subjectId],queryFn:()=>n({data:{workspaceId:a,subjectType:S.subjectType,subjectId:S.subjectId}}),enabled:!!a&&!!S}),{data:V,isLoading:Le}=I({queryKey:["identity-queue",a,b],queryFn:()=>R({data:{workspaceId:a,status:b,limit:300}}),enabled:!!a}),{data:ye}=I({queryKey:["identity-subjects",a,z],queryFn:()=>i({data:{workspaceId:a,...z?{search:z}:{}}}),enabled:!!a}),{data:je,isLoading:Oe}=I({queryKey:["identity-keys",a,Z,ee],queryFn:()=>F({data:{workspaceId:a,...Z?{search:Z}:{},...ee!=="all"?{kind:ee}:{}}}),enabled:!!a}),K=()=>
1{u.invalidateQueries({queryKey:["identity-queue"]}),u.invalidateQueries({queryKey:["identity-keys"]}),u.invalidateQueries({queryKey:["identity-overview"]}),u.invalidateQueries({queryKey:["identity-search"]}),u.invalidateQueries({queryKey:["identity-dossier"]})},ue=s=>{const[t,T]=s.split(":");return{subjectType:t,subjectId:T}},ae=N({mutationFn:s=>P({data:{workspaceId:a,itemId:s.itemId,...ue(s.subject)}}),onSuccess:s=>{r.success(`Mapped ${s.keyValue} â Brain will remember it`),K()},onError:s=>r.error(s.message)}),ve=N({mutationFn:s=>w({data:{workspaceId:a,itemId:s}}),onSuccess:()=>{r.success("Set aside"),K()},onError:s=>r.error(s.message)}),ge=N({mutationFn:s=>q({data:{workspaceId:a,itemId:s}}),onSuccess:()=>{r.success("Back in the queue"),K()},onError:s=>r.error(s.message)}),fe=N({mutationFn:s=>Ie({data:{workspaceId:a,itemIds:s,...ue(de)}}),onSuccess:s=>{s.failed.length?r.warning(`${s.mapped} mapped, ${s.failed.length} skipped`):r.success(`${s.mapped} details mapped`),M({}),K()},onError:s=>r.error(s.message)}),be=N({mutationFn:s=>Fe({data:{workspaceId:a,itemIds:s}}),onSuccess:s=>{r.success(`${s.ignored} set aside`),M({}),K()},onError:s=>r.error(s.message)}),te=N({mutationFn:s=>l({data:{workspaceId:a,keyId:s}}),onSuccess:()=>{r.success("Removed â the next matching item will ask again"),K()},onError:s=>r.error(s.message)}),Ne=N({mutationFn:()=>A({data:{workspaceId:a,kind:_.kind,value:_.value,...ue(_.subject)}}),onSuccess:s=>{r.success(`${s.value} now points at that record`),se(t=>({...t,value:""})),K()},onError:s=>r.error(s.message)}),me=d.useMemo(()=>(ye??[]).map(s=>({value:`${s.subjectType}:${s.subjectId}`,label:s.label,hint:s.subjectType==="client"?"Client":"Contact"})),[ye]),C=d.useMemo(()=>(V??[]).filter(s=>Q==="all"||s.keyKind===Q),[V,Q]),G=d.useMemo(()=>C.filter(s=>re[s.id]).map(s=>s.id),[C,re]),Re=C.length>0&&G.length===C.length,we=d.useMemo(()=>{const s=new Map;for(const t of V??[])s.set(t.keyKind,(s.get(t.keyKind)??0)+1);return[...s.entries()].sort((t,T)=>T[1]-t[1])},[V]);return e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Identity & mapping"}),e.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:'One place to answer "who is this?". Search a person or a company by anything you have â a name, an email address, a phone number, a company domain â see every detail Brain holds on them, and clear the handful it refused to guess.'})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(le,{label:"Details on file",value:f?String(f.totalKeys):"â",hint:"Each one is an instant lookup"}),e.jsx(le,{label:"Waiting for you",value:f?String(f.openReviews):"â",hint:"Brain refused to guess these"}),e.jsx(le,{label:"Details on clients",value:f?String(f.clientsCovered):"â"}),e.jsx(le,{label:"Details on contacts",value:f?String(f.peopleCovered):"â"})]}),e.jsxs(ze,{defaultValue:"find",children:[e.jsxs(Ve,{children:[e.jsx(H,{value:"find",children:"Find anyone"}),e.jsxs(H,{value:"queue",children:["Needs mapping",f?.openReviews?e.jsx(p,{variant:"secondary",className:"ml-2",children:f.openReviews}):null]}),e.jsx(H,{value:"duplicates",children:"Same person twice"}),e.jsx(H,{value:"keys",children:"What Brain knows"}),e.jsx(H,{value:"performance",children:"Speed & cost"})]}),e.jsx(W,{value:"duplicates",className:"mt-4",children:e.jsx(es,{workspaceId:a})}),e.jsxs(W,{value:"find",className:"mt-4 space-y-4",children:[e.jsxs(y,{children:[e.jsx(L,{className:"pb-2",children:e.jsx(O,{className:"text-base",children:"Search people and companies"})}),e.jsxs(j,{className:"space-y-3",children:[e.jsx(E,{autoFocus:!0,className:"max-w-xl",placeholder:"Name, email, phone number, company domain, Stripe customerâ¦",value:B,onChange:s=>Ke(s.target.value)}),B.trim().length<2?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Type at least two characters. Exact details (an email, a phone number) always beat a name, and every result tells you why it matched."}):Ee?e.jsx($,{className:"h-24 w-full"}):oe?.nothingOnFile?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Nothing on file carries that. Use"," ",e.jsx("span",{className:"font-medium",children:"Point a detail at a record"})," below to teach Brain who it belongs to."]}):e.jsxs("div",{className:"divide-y rounded-md border",children:[(oe?.subjects??[]).map(s=>e.jsxs("button",{type:"button",className:"flex w-full flex-wrap items-center gap-2 px-3 py-2 text-left text-sm hover:bg-muted/60",onClick:()=>ie({subjectType:s.subjectType,subjectId:s.subjectId,label:s.label}),children:[e.jsx("span",{className:"font-medium",children:s.label}),e.jsx(p,{variant:"secondary",children:s.subjectType==="client"?"Client":"Contact"}),s.hint?e.jsx("span",{className:"text-xs text-muted-foreground",children:s.hint}):null,e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:s.why})]},`${s.subjectType}:${s.subjectId}`)),(oe?.queue??[]).map(s=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-muted/30 px-3 py-2 text-sm",children:[e.jsx("span",{className:"font-mono",children:s.keyValue}),e.jsx(p,{variant:"outline",children:k[s.keyKind]??s.keyKind}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Waiting in Needs mapping (",s.status,")"]})]},s.id))]})]})]}),e.jsxs(y,{children:[e.jsx(L,{className:"pb-2",children:e.jsx(O,{className:"text-base",children:"Point a detail at a record"})}),e.jsxs(j,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Use this when you already know the answer â a client's billing address, a second phone number. Brain uses it for every future meeting, call, text and email without looking anything up."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(U,{value:_.kind,onValueChange:s=>se(t=>({...t,kind:s})),children:[e.jsx(J,{className:"w-56",children:e.jsx(X,{})}),e.jsx(Y,{children:Ce.map(s=>e.jsx(D,{value:s,children:k[s]},s))})]}),e.jsx(E,{className:"w-full max-w-sm",placeholder:"Value",value:_.value,onChange:s=>se(t=>({...t,value:s.target.value}))}),e.jsx(E,{className:"w-full max-w-xs",placeholder:"Search clients / contactsâ¦",value:z,onChange:s=>xe(s.target.value)}),e.jsxs(U,{value:_.subject,onValueChange:s=>se(t=>({...t,subject:s})),children:[e.jsx(J,{className:"w-full max-w-sm",children:e.jsx(X,{placeholder:"Belongs toâ¦"})}),e.jsx(Y,{children:me.map(s=>e.jsxs(D,{value:s.value,children:[s.label," · ",s.hint]},s.value))})]}),e.jsx(o,{disabled:!_.value||!_.subject||Ne.isPending,onClick:()=>Ne.mutate(),children:"Save mapping"})]})]})]})]}),e.jsxs(W,{value:"queue",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["open","resolved","ignored"].map(s=>e.jsx(o,{size:"sm",variant:b===s?"default":"outline",onClick:()=>{Te(s),M({})},children:s==="open"?"Open":s==="resolved"?"Mapped":"Set aside"},s)),e.jsx(E,{className:"ml-auto w-full max-w-xs",placeholder:"Search clients / contactsâ¦",value:z,onChange:s=>xe(s.target.value)})]}),we.length>1?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(o,{size:"sm",variant:Q==="all"?"secondary":"ghost",onClick:()=>he("all"),children:["All (",(V??[]).length,")"]}),we.map(([s,t])=>
1e.jsxs(o,{size:"sm",variant:Q===s?"secondary":"ghost",onClick:()=>he(s),children:[k[s]??s," (",t,")"]},s))]}):null,b==="open"&&G.length>0?e.jsx(y,{className:"border-primary/40",children:e.jsxs(j,{className:"flex flex-wrap items-center gap-2 py-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[G.length," selected"]}),e.jsxs(U,{value:de,onValueChange:Pe,children:[e.jsx(J,{className:"w-full max-w-sm",children:e.jsx(X,{placeholder:"Map all of them toâ¦"})}),e.jsx(Y,{children:me.map(s=>e.jsxs(D,{value:s.value,children:[s.label," · ",s.hint]},s.value))})]}),e.jsx(o,{size:"sm",disabled:!de||fe.isPending,onClick:()=>fe.mutate(G),children:"Map selected"}),e.jsx(o,{size:"sm",variant:"ghost",disabled:be.isPending,onClick:()=>be.mutate(G),children:"Not clients"}),e.jsx(o,{size:"sm",variant:"ghost",onClick:()=>M({}),children:"Clear"})]})}):null,Le?e.jsx($,{className:"h-40 w-full"}):C.length===0?e.jsx(y,{children:e.jsx(j,{className:"py-10 text-center text-sm text-muted-foreground",children:b==="open"?"Nothing to map. Every incoming meeting, call, text and email matched a record on its own.":"Nothing here yet."})}):e.jsx(y,{children:e.jsxs(j,{className:"p-0",children:[b==="open"?e.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2 text-xs text-muted-foreground",children:[e.jsx(Se,{checked:Re,onCheckedChange:s=>M(s?Object.fromEntries(C.map(t=>[t.id,!0])):{}),"aria-label":"Select all"}),"Select all ",C.length]}):null,e.jsx("div",{className:"divide-y",children:C.map(s=>e.jsxs("div",{className:"flex flex-wrap items-start gap-3 px-4 py-3",children:[b==="open"?e.jsx(Se,{className:"mt-1",checked:!!re[s.id],onCheckedChange:t=>M(T=>({...T,[s.id]:t===!0})),"aria-label":`Select ${s.keyValue}`}):null,e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-mono",children:s.keyValue}),e.jsx(p,{variant:"outline",children:k[s.keyKind]??s.keyKind}),s.seenCount>1?e.jsxs(p,{variant:"secondary",children:["seen ",s.seenCount,"Ã"]}):null,e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.reason??"Nobody on file carries this detail yet."," From"," ",s.origin.replace(/_/g," "),"."]})]}),s.candidates.length>0&&b==="open"?e.jsx("div",{className:"flex flex-wrap gap-2",children:s.candidates.map(t=>e.jsxs(o,{size:"sm",variant:"secondary",disabled:ae.isPending,onClick:()=>ae.mutate({itemId:s.id,subject:`${t.subjectType}:${t.subjectId}`}),children:[t.label,e.jsx("span",{className:"ml-2 text-xs opacity-70",children:t.reason})]},`${t.subjectType}:${t.subjectId}`))}):null,b==="open"?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(U,{value:ce[s.id]??"",onValueChange:t=>qe(T=>({...T,[s.id]:t})),children:[e.jsx(J,{className:"w-full max-w-sm",children:e.jsx(X,{placeholder:"Attach toâ¦"})}),e.jsx(Y,{children:me.map(t=>e.jsxs(D,{value:t.value,children:[t.label," · ",t.hint]},t.value))})]}),e.jsx(o,{size:"sm",disabled:!ce[s.id]||ae.isPending,onClick:()=>ae.mutate({itemId:s.id,subject:ce[s.id]}),children:"Map it"}),e.jsx(o,{size:"sm",variant:"ghost",disabled:ve.isPending,onClick:()=>ve.mutate(s.id),children:"Not a client"})]}):e.jsx(o,{size:"sm",variant:"outline",disabled:ge.isPending,onClick:()=>ge.mutate(s.id),children:"Put back in the queue"})]})]},s.id))})]})})]}),e.jsxs(W,{value:"keys",className:"mt-4 space-y-4",children:[e.jsx(vs,{workspaceId:a}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(E,{className:"w-full max-w-sm",placeholder:"Search an email, phone, domainâ¦",value:Z,onChange:s=>Me(s.target.value)}),e.jsxs(U,{value:ee,onValueChange:De,children:[e.jsx(J,{className:"w-56",children:e.jsx(X,{})}),e.jsxs(Y,{children:[e.jsx(D,{value:"all",children:"All kinds"}),Ce.map(s=>e.jsx(D,{value:s,children:k[s]},s))]})]})]}),Oe?e.jsx($,{className:"h-40 w-full"}):e.jsx(y,{children:e.jsx(j,{className:"p-0",children:e.jsx("div",{className:"divide-y",children:(je??[]).length===0?e.jsx("div",{className:"py-10 text-center text-sm text-muted-foreground",children:"Nothing on file matches that."}):(je??[]).map(s=>e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 text-sm",children:[e.jsx("span",{className:"font-mono",children:s.keyValue}),e.jsx(p,{variant:"outline",children:k[s.keyKind]??s.keyKind}),e.jsx("span",{className:"text-muted-foreground",children:"â"}),e.jsx("button",{type:"button",className:"font-medium underline-offset-2 hover:underline",onClick:()=>ie({subjectType:s.subjectType,subjectId:s.subjectId,label:s.subjectLabel}),children:s.subjectLabel}),e.jsx(p,{variant:"secondary",children:s.subjectType==="client"?"Client":"Contact"}),s.isManual?e.jsx(p,{children:"Set by a person"}):null,e.jsx(o,{size:"sm",variant:"ghost",className:"ml-auto",disabled:te.isPending,onClick:()=>te.mutate(s.id),children:"Remove"})]},s.id))})})})]}),e.jsx(W,{value:"performance",className:"mt-4",children:e.jsx(js,{workspaceId:a})})]}),e.jsx(Ge,{open:!!S,onOpenChange:s=>!s&&ie(null),children:e.jsxs(He,{className:"max-w-2xl",children:[e.jsxs(We,{children:[e.jsx(Ue,{children:S?.label}),e.jsxs(Je,{children:["Everything Brain holds on this ",S?.subjectType==="client"?"client":"contact",". Remove anything that points here by mistake â the next item carrying it asks again."]})]}),$e?e.jsx($,{className:"h-32 w-full"}):(pe?.keys??[]).length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No details on file yet. Add one from Find anyone and every future call, text and email carrying it lands here instantly."}):e.jsx("div",{className:"max-h-[60vh] divide-y overflow-y-auto rounded-md border",children:(pe?.keys??[]).map(s=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 text-sm",children:[e.jsx("span",{className:"font-mono",children:s.keyValue}),e.jsx(p,{variant:"outline",children:k[s.keyKind]??s.keyKind}),s.isManual?e.jsx(p,{children:"Set by a person"}):null,e.jsxs("span",{className:"text-xs text-muted-foreground",children:["used ",s.hits??0,"à · from ",s.source.replace(/_/g," ")
1]}),e.jsx(o,{size:"sm",variant:"ghost",className:"ml-auto",disabled:te.isPending,onClick:()=>te.mutate(s.id),children:"Remove"})]},s.id))})]})})]})}export{ws as component};
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.