1import{r as f,j as t,L as Pe,d as ot}from"./react-vendor-DlfacoUt.js";import{E as Ie}from"./EntityActionRow-DM2Bxf3K.js";import{d as it}from"./entityAction-DSkBX_DA.js";import{v as ke}from"./tileDrill-HoqwHavQ.js";import{I as lt}from"./IntentBar-CK-k4DD3.js";import{b as ct,c as dt,s as ut,m as mt,S as ft,a as pt}from"./ScreenActionsBar-DELqF7U2.js";import{C as Ue}from"./CompanyLogo-BUKTjfRA.js";import{P as gt,a as xt,b as ht}from"./popover-4PGUv3TA.js";import{C as bt}from"./calendar-8YcV_QYK.js";import{s as I,Z as yt,T as Ye,bb as vt,d as jt,d8 as fe,c as _,Q as St,a2 as Le,au as _t,E as Me,P as Nt,B as wt}from"./index-B7ErYi-u.js";import{a as A}from"./query-vendor-BRUoyimQ.js";import{k as kt}from"./directoryBrowse-Dq4v90oL.js";import{u as Lt,E as Mt,a as Ct,S as Ce,G as Tt}from"./useExpeditionMarketLens-S6X6jG3x.js";import{g as Et}from"./expeditionContext-C3DbC4Pw.js";import{R as Te}from"./expeditionLens-Cq-BBA5F.js";import{c as Dt,aM as Ft,aF as At,a as zt,X as Rt,L as Ee,bW as $t,aq as qt,g as Ot,w as Pt}from"./icons-vendor-iDMXddrC.js";import{T as It,a as pe,b as Ut,c as Yt,d as L}from"./table-Ci3MS0r6.js";import{D as Be,t as Bt,f as Ke,a as Ve,c as De,d as Kt,p as Vt,e as Gt,g as Fe,h as Ae,j as Wt,r as Ht,k as ze,l as Qt,m as Zt,n as Jt}from"./dealsTable-oomMMXyI.js";import{S as Ge}from"./SafeCitationLink-Dj1sNFsY.js";import{M as Xt}from"./MethodologyLink-CUWkwkxG.js";import{S as Re,a as me}from"./SegmentedTabs-CIxONAW8.js";import{p as es}from"./pageAllRows-CkJj5JKE.js";import"./useWatch-DssCDY7X.js";import"./useWatchlist-uUyh5qib.js";import"./AddToPipelineDialog-XopumkQM.js";import"./dialog-D3QU6WBB.js";import"./radix-vendor-Bnc9sXGn.js";import"./supabase-vendor-BFpL0hm0.js";import"./input-D46aJJ9k.js";import"./textarea-Dni_-p1y.js";import"./label-aBq373ll.js";import"./select-Dwg7O8SN.js";import"./SignUpPromptDialog-DqD4J54D.js";import"./frankContextCard-BXIvOreQ.js";import"./getCompanyLogoUrl-DaGxGj66.js";import"./canonicalTarget-WIkO891G.js";import"./intelKpis-DwH5pgos.js";import"./csvImport-CYBp-ZCr.js";import"./papaparse.min-CRakR6r7.js";import"./contactHandles-BpyolCGH.js";import"./signalRuleParse-DzEGmNke.js";import"./en-US-C5vD-bVu.js";import"./endOfMonth-B_ILu3ZT.js";import"./format-CrSKL9PJ.js";import"./investorScreen-C4kIrROE.js";import"./citationUrl-DfhFAwY4.js";import"./checkbox-Dn4U3HF9.js";import"./scroll-area-BOI3aX3g.js";import"./tabs-Bc40huyk.js";import"./useExpeditionContext-T0G94kD5.js";import"./linkHealthStore-CwscwB55.js";function ts(e){const{enabled:s=!0,...r}=e;return A({queryKey:["deals-search",r],enabled:s,queryFn:async()=>{var i,x,y,g,p,h,S;const{data:n,error:o}=await I.rpc("search_deals",{p_q:((i=r.q)==null?void 0:i.trim())||null,p_sectors:(x=r.sectors)!=null&&x.length?r.sectors:null,p_stages:(y=r.stages)!=null&&y.length?r.stages:null,p_countries:(g=r.countries)!=null&&g.length?r.countries:null,p_states:(p=r.states)!=null&&p.length?r.states:null,p_counties:(h=r.counties)!=null&&h.length?r.counties:null,p_zips:(S=r.zips)!=null&&S.length?r.zips:null,p_from:r.from||null,p_to:r.to||null,p_amount_min:r.amountMin!=null?r.amountMin:null,p_amount_max:r.amountMax!=null?r.amountMax:null,p_limit:r.limit,p_offset:r.offset});if(o)throw o;const l=n??[],u=l.length?Number(l[0].total_count):0;return{rows:l.map(({total_count:j,...m})=>({...m,investors:Array.isArray(m.investors)?m.investors:[]})),total:u,hasMore:r.offset+r.limit<u}},placeholderData:(n,o)=>kt(n,o,["deals-search",r]),staleTime:6e4})}function ss(){return A({queryKey:["deal-facets"],queryFn:async()=>{const{data:e,error:s}=await I.rpc("deal_facets");if(s)throw s;return e??[]},staleTime:30*6e4})}function rs(){const{data:e}=A({queryKey:["deal-geo-facets"],queryFn:async()=>{const{data:s,error:r}=await I.rpc("deal_geo_facets");if(r)throw r;return s??[]},staleTime:18e5});return f.useMemo(()=>{const s=[];for(const r of e??[]){const n={country:r.country_code,state_code:r.state_code,county_fips:r.county_fips,county_name:r.county_name,zip:r.zip},o=Math.max(0,Math.floor(r.n));for(let l=0;l<o;l++)s.push(n)}return s},[e])}function ns(e){if(e>=1e3){const s=e/1e3;return`$${s%1===0?s.toFixed(0):s.toFixed(1)}B`}return e<1?`$${Math.round(e*1e3)}k`:`$${e%1===0?e.toFixed(0):e.toFixed(1)}M`}const We=yt,K=3;function ge(e){const s=new Set,r=[];for(const n of e){const o=n.trim();if(!o)continue;const l=o.toLowerCase();s.has(l)||(s.add(l),r.push(o))}return r}function D(e){return typeof e!="number"||!Number.isFinite(e)?null:e}function B(e){const s=e.trim();if(!s)return"";const r=s.toLowerCase().replace(/_/g," ").replace(/\s+/g," ");return r==="pre-seed"||r==="preseed"||r==="pre seed"?"Pre-seed":r==="seed"?"Seed":r==="series a"||r==="series-a"?"Series A":r==="series b"||r==="series-b"?"Series B":r==="series c"||r==="series-c"?"Series C":r.startsWith("series d")||r==="series d+"||r==="growth"?"Series D+":r==="late stage"||r==="late-stage"?"Late Stage":s}function as(e){return e.expeditionTemplateKey==="deploy_capital"?"investor":e.expeditionTemplateKey==="fundraise"?"founder":e.persona==="investor"?"investor":"founder"}function He(e){return e==="investor"?"deals":"companies"}function os(e){if(!e)return null;const s=e.toLowerCase();return/pre[-\s]?seed/.test(s)?"Pre-seed":/\bseries\s*a\b/.test(s)?"Series A":/\bseries\s*b\b/.test(s)?"Series B":/\bseries\s*c\b/.test(s)?"Series C":/\bseries\s*d
1/.test(s)?"Series D+":/\bseed\b/.test(s)?"Seed":null}function is(e){var r,n;const s=ge(e.expeditionStages.map(B).filter(Boolean));if(!s.length){if(e.layer==="founder"&&e.companyStage){const l=B(e.companyStage);if(l)return{stage:l,options:[l],source:"profile"}}if(e.layer==="investor"&&((r=e.investmentStages)!=null&&r.length)){const l=ge(e.investmentStages.map(B).filter(Boolean));if(l.length)return{stage:l[0],options:l,source:"investment"}}const o=e.inferredStage?B(e.inferredStage):"";return o?{stage:o,options:[o],source:"inferred"}:{stage:null,options:[],source:"none"}}if(s.length===1)return{stage:s[0],options:s,source:"expedition"};if(e.layer==="founder"&&e.companyStage){const o=B(e.companyStage).toLowerCase(),l=s.find(u=>u.toLowerCase()===o);if(l)return{stage:l,options:s,source:"profile"}}if(e.layer==="investor"&&((n=e.investmentStages)!=null&&n.length)){const o=new Set(e.investmentStages.map(u=>B(u).toLowerCase())),l=s.find(u=>o.has(u.toLowerCase()));if(l)return{stage:l,options:s,source:"investment"}}return{stage:s[0],options:s,source:"expedition"}}function ls(e){const s=[];for(const r of e){const n=We[r.trim().toLowerCase()];n&&s.push(n)}return ge(s)}function cs(e){const s=ls(e),r=s.length>0,n=new Set;for(const o of e){const l=o.trim();if(!l||We[l.toLowerCase()])continue;const u=Te[l],c=u?[l,u]:Object.entries(Te).find(([i])=>i.toLowerCase()===l.toLowerCase());if(c){if(c[0].toLowerCase()==="north america"&&r)continue;for(const i of c[1])n.add(i);continue}/^[A-Za-z]{2}$/.test(l)&&n.add(l.toUpperCase())}return{countries:[...n].sort(),states:s}}function ds(e,s){const r=He(s);return`Median ${e||"round"} for ${r} like yours`}function us(e){return e?`Most active ${e} leads`:"Most active leads"}function $e(e){if(!Number.isFinite(e)||e<=0)return"â";if(e<45)return`${Math.round(e)} days`;if(e<365){const r=e/30.437;return`${r%1<.05||r%1>.95?Math.round(r):r.toFixed(1)} mo`}const s=e/365.25;return`${s%1<.05||s%1>.95?Math.round(s):s.toFixed(1)} yr`}function ms(e){const s=(e??"").trim()||null;if(!s)return{minM:null,maxM:null,label:null};const r=(u,c)=>{const i=c.toLowerCase();return i.startsWith("b")?u*1e3:i.startsWith("k")?u/1e3:u},n=s.match(/^(?:under|up to|<)\s*\$?\s*([\d.]+)\s*([kmb])?/i);if(n)return{minM:null,maxM:r(Number(n[1]),n[2]||"m"),label:s};const o=s.match(/\$?\s*([\d.]+)\s*([kmb])?\s*\+/i);if(o)return{minM:r(Number(o[1]),o[2]||"m"),maxM:null,label:s};const l=s.match(/\$?\s*([\d.]+)\s*([kmb])?\s*[-ââto]+\s*\$?\s*([\d.]+)\s*([kmb])?/i);if(l){const u=l[4]||l[2]||"m",c=l[2]||u;return{minM:r(Number(l[1]),c),maxM:r(Number(l[3]),u),label:s}}return{minM:null,maxM:null,label:s}}function fs(e){const s=e&&typeof e=="object"?e:{},r=Array.isArray(s.leads)?s.leads:[],n=[];for(const u of r){if(!u||typeof u!="object")continue;const c=u,i=typeof c.name=="string"?c.name.trim():"",x=D(c.n);!i||x==null||x<=0||n.push({name:i,n:x})}const o=D(s.disclosed)??0,l=D(s.median_m);return{total:Math.max(0,D(s.total)??0),disclosed:Math.max(0,o),medianM:o>=K?l:null,p25M:D(s.p25_m),p75M:D(s.p75_m),minM:D(s.min_m),maxM:D(s.max_m),medianRoundDays:D(s.median_round_days),roundSample:Math.max(0,D(s.round_sample)??0),leads:n}}function Q(e){return e==null?"â":ns(e)}async function ps(e){const{data:s,error:r}=await I.from("profiles").select("company_stage, investment_stages, check_size_range").eq("id",e).maybeSingle();if(r||!s)return{companyStage:null,investmentStages:[],checkSizeRange:null};const n=s.investment_stages;
1return{companyStage:typeof(s==null?void 0:s.company_stage)=="string"?s.company_stage:null,investmentStages:Array.isArray(n)?n.filter(o=>typeof o=="string"&&o.trim().length>0):[],checkSizeRange:typeof(s==null?void 0:s.check_size_range)=="string"?s.check_size_range:null}}async function gs(e){const{data:s,error:r}=await I.from("expedition_summit").select("template_key").eq("expedition_id",e).maybeSingle();return r||!s?null:typeof s.template_key=="string"?s.template_key:null}async function xs(e){const{data:s,error:r}=await I.rpc("deals_like_yours_stats",{p_sectors:e.sectors.length?fe(e.sectors):null,p_stages:e.stages.length?e.stages:null,p_countries:e.countries.length?e.countries:null,p_states:e.states.length?e.states:null,p_amount_min:null,p_amount_max:null,p_lead_limit:8});if(r)throw r;return fs(s)}function hs(e){var C,w,V,T,k,R;const s=Ye(),{persona:r}=vt(),{user:n}=jt(),o=((C=s==null?void 0:s.activeExpedition)==null?void 0:C.id)??null,l=A({queryKey:["expedition-context",o],queryFn:()=>Et(o),enabled:e.enabled&&!!o,staleTime:5*6e4}),u=A({queryKey:["like-yours-profile",n==null?void 0:n.id],queryFn:()=>ps(n.id),enabled:e.enabled&&!!(n!=null&&n.id),staleTime:5*6e4}),c=A({queryKey:["like-yours-summit",o],queryFn:()=>gs(o),enabled:e.enabled&&!!o,staleTime:5*6e4}),i=f.useMemo(()=>{var b;return((b=l.data)==null?void 0:b.sectors)??[]},[(w=l.data)==null?void 0:w.sectors]),x=f.useMemo(()=>{var b;return((b=l.data)==null?void 0:b.stages)??[]},[(V=l.data)==null?void 0:V.stages]),y=f.useMemo(()=>{var b;return((b=l.data)==null?void 0:b.geographies)??[]},[(T=l.data)==null?void 0:T.geographies]),g=f.useMemo(()=>cs(y),[y]),p=f.useMemo(()=>as({persona:r,expeditionTemplateKey:c.data}),[r,c.data]),h=f.useMemo(()=>{var b;return os(((b=s==null?void 0:s.activeExpedition)==null?void 0:b.name)??null)},[(k=s==null?void 0:s.activeExpedition)==null?void 0:k.name]),S=f.useMemo(()=>{var b,J;return is({expeditionStages:x,layer:p,companyStage:(b=u.data)==null?void 0:b.companyStage,investmentStages:(J=u.data)==null?void 0:J.investmentStages,inferredStage:h})},[x,p,u.data,h]),j=e.stageOverride&&S.options.includes(e.stageOverride)?e.stageOverride:S.stage,m=i.length>0||x.length>0||g.countries.length>0||g.states.length>0,d=!!j,N=!m&&d,F=A({queryKey:["like-yours-stats",o,i,j,g.countries,g.states],queryFn:()=>xs({sectors:i,stages:j?[j]:[],countries:g.countries,states:g.states}),enabled:e.enabled&&!!o&&d,staleTime:5*6e4}),z=f.useMemo(()=>{var b;return p!=="investor"?null:ms(((b=u.data)==null?void 0:b.checkSizeRange)??null).label},[p,(R=u.data)==null?void 0:R.checkSizeRange]);return{isLoading:l.isLoading||u.isLoading||c.isLoading||!!d&&F.isLoading,hasContext:d,layer:p,stage:j,stageOptions:S.options,sectors:i,geos:y,countries:g.countries,states:g.states,checkSizeLabel:z,usedFallback:N,stats:F.data??null}}function bs({enabled:e,onUseOnPage:s,onSearchLead:r}){const[n,o]=f.useState(null),[l,u]=f.useState(null),c=hs({enabled:e,stageOverride:n});if(!e||!c.hasContext&&!c.isLoading)return null;const i=c.stats,x=He(c.layer),y=[c.stage,c.sectors.slice(0,2).join(", "),c.states.length?c.states.join(", "):c.geos.slice(0,2).join(", ")].filter(Boolean),g=c.isLoading&&!i?"â¦":(i==null?void 0:i.medianM)!=null?Q(i.medianM):"â",p=c.isLoading&&!i?"â¦":(i==null?void 0:i.medianRoundDays)!=null&&(i.roundSample??0)>=K?$e(i.medianRoundDays):"â",h=i==null?void 0:i.leads[0],S=c.isLoading&&!i?"â¦":h?h.name:"â",j=c.isLoading&&!i?"â¦":((i==null?void 0:i.total)??0).toLocaleString(),m=d=>u(N=>N===d?null:d);return t.jsxs("div",{className:"mb-4 space-y-2",children:[t.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Like yours",c.usedFallback?" · from your raise":" · My expedition",y.length?` · ${y.join(" · ")}`:"",c.layer==="investor"?" · deals you would have taken":"",c.usedFallback?" · add sector / geo on Watch to tighten":""]}),c.stageOptions.length>1&&t.jsx("div",{className:"inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1",children:c.stageOptions.map(d=>t.jsx("button",{type:"button",onClick:()=>o(d),className:_("rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",c.stage===d?"bg-background border border-border text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:d},d))}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[t.jsx(ne,{id:"median",open:l==="median",onToggle:()=>m("median"),label:ds(c.stage,c.layer),value:g,context:(i==null?void 0:i.medianM)!=null?`of ${i.disclosed.toLocaleStr
1ing()} disclosed`:i?`need â¥${K} disclosed`:" "}),t.jsx(ne,{id:"time",open:l==="time",onToggle:()=>m("time"),label:"Median deal time",value:p,context:i&&i.roundSample>=K?`from prior raise · ${i.roundSample.toLocaleString()} ${x}`:"from prior raise"}),t.jsx(ne,{id:"leads",open:l==="leads",onToggle:()=>m("leads"),label:us(c.stage),value:S,context:h?`${h.n.toLocaleString()} like-yours deals`:"named leads only"}),t.jsx(ne,{id:"count",open:l==="count",onToggle:()=>m("count"),label:"Deals like yours",value:j,context:i?`${i.disclosed.toLocaleString()} disclosed`:"matching this round"})]}),l==="median"&&i&&t.jsxs(ae,{children:[t.jsxs("p",{children:["Median disclosed ",c.stage||"round"," for ",x," like yours.",i.medianM!=null?t.jsxs(t.Fragment,{children:[" ","Middle 50% ",Q(i.p25M)," â ",Q(i.p75M),". Range ",Q(i.minM)," â ",Q(i.maxM),"."]}):t.jsxs(t.Fragment,{children:[" Need at least ",K," disclosed amounts."]})]}),c.layer==="investor"&&c.checkSizeLabel&&t.jsxs("p",{children:["Your typical check ",c.checkSizeLabel," â not used as a round-size filter."]}),s&&t.jsx("button",{type:"button",onClick:()=>s(c.stage),className:qe,children:"Show this round on the page"})]}),l==="time"&&i&&t.jsxs(ae,{children:[t.jsxs("p",{children:["Median days from that companyâs previous disclosed raise to this",c.stage?` ${c.stage}`:""," round. Not time-to-close â we do not have first-meeting dates."]}),i.roundSample<K?t.jsxs("p",{children:["Only ",i.roundSample," paired prior raises in this set."]}):t.jsxs("p",{children:[$e(i.medianRoundDays??0)," across"," ",i.roundSample.toLocaleString()," ",x,"."]})]}),l==="leads"&&i&&t.jsx(ae,{children:i.leads.length===0?t.jsx("p",{children:"No named leads in this set."}):t.jsx("ul",{className:"space-y-1",children:i.leads.map(d=>t.jsxs("li",{className:"flex items-center justify-between gap-3",children:[r?t.jsx("button",{type:"button",onClick:()=>r(d.name),className:"text-left text-foreground hover:underline",children:d.name}):t.jsx("span",{className:"text-foreground",children:d.name}),t.jsx("span",{className:"tabular-nums text-muted-foreground",children:d.n.toLocaleString()})]},d.name))})}),l==="count"&&i&&t.jsxs(ae,{children:[t.jsxs("p",{children:[i.total.toLocaleString()," ",c.stage||"matching"," deals in this expedition set. ",i.disclosed.toLocaleString()," disclose an amount. The big number on the filter row is the page list â All market is the whole book."]}),s&&t.jsx("button",{type:"button",onClick:()=>s(c.stage),className:qe,children:"Show this round on the page"})]})]})}const qe="text-[11px] font-medium text-foreground underline-offset-2 hover:underline";function ne({id:e,open:s,onToggle:r,label:n,value:o,context:l}){return t.jsxs("button",{type:"button","aria-expanded":s,"aria-controls":`like-yours-${e}`,onClick:r,className:_("text-left rounded-xl border bg-card px-3.5 py-3 transition-colors",s?"border-primary/40":"border-border hover:border-primary/30"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("p",{className:"text-[11px] font-medium text-muted-foreground leading-snug",children:n}),t.jsx(Dt,{className:_("h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/70 transition-transform",s&&"rotate-180")})]}),t.jsx("p",{className:"mt-1.5 text-lg font-semibold tabular-nums text-foreground truncate",children:o}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:l})]})}function ae({children:e}){return t.jsx("div",{className:"rounded-xl border border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground space-y-1.5",children:e})}const M="px-2 py-1 text-xs leading-tight",ys="h-8 px-2 py-0 text-[11px] leading-none";function Z(e){return(e||"").trim()||"â"}function vs(){return t.jsxs(pe,{className:"border-border",children:[t.jsx(L,{className:_(M,"sticky left-0 z-10 bg-background"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-5 w-5 shrink-0 animate-pulse rounded-sm bg-muted"}),t.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-muted"})]})}),Array.from({length:Be.length-1}).map((e,s)=>t.jsx(L,{className:M,children:t.jsx("div",{className:"h-3 w-16 animate-pulse rounded bg-muted"})},s))]})}function js({row:e}){const s=t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Ue,{companyName:e.companyName,domain:null,logoUrl:e.logoUrl,
1size:20,className:"rounded-sm flex-shrink-0"}),t.jsx("span",{className:"truncate font-medium text-foreground group-hover:underline underline-offset-2",children:e.companyName})]});return e.href?e.hrefExternal?t.jsx(Ge,{href:e.href,className:"min-w-0",children:s}):t.jsx(Pe,{to:e.href,className:"min-w-0",children:s}):s}function Ss({rows:e,startIndex:s,loading:r}){return t.jsx("div",{className:"flex-1 min-h-0 rounded-[14px] border border-border overflow-auto",children:t.jsxs("table",{className:"w-full caption-bottom text-xs",children:[t.jsx(It,{children:t.jsx(pe,{className:"bg-muted hover:bg-muted border-border",children:Be.map((n,o)=>t.jsx(Ut,{className:_(ys,"sticky top-0 z-20 overflow-hidden bg-muted text-muted-foreground font-medium whitespace-nowrap shadow-[inset_0_-1px_0_0_hsl(var(--border))]",o===1&&"left-0 z-40 min-w-[200px] shadow-[1px_0_0_0_hsl(var(--border)),inset_0_-1px_0_0_hsl(var(--border))]",n.id==="n"&&"w-8 text-right",n.id==="dealSize"&&"text-right",n.id==="dealDate"&&"text-right",n.id==="actions"&&"w-20"),children:n.label},n.id))})}),t.jsx(Yt,{children:r?Array.from({length:10}).map((n,o)=>t.jsx(vs,{},o)):e.map((n,o)=>{const l=Bt(n);return t.jsxs(pe,{className:"group border-border hover:bg-muted/60",children:[t.jsx(L,{className:_(M,"text-right tabular-nums text-muted-foreground"),children:s+o+1}),t.jsx(L,{className:_(M,"sticky left-0 z-10 bg-background group-hover:bg-muted min-w-[200px] shadow-[1px_0_0_0_hsl(var(--border))]"),children:t.jsx(js,{row:n})}),t.jsx(L,{className:_(M,"text-right tabular-nums whitespace-nowrap text-foreground"),children:Ke(n.dealSizeMillions)}),t.jsx(L,{className:_(M,"text-right tabular-nums whitespace-nowrap text-muted-foreground"),children:Z(Ve(n.happenedOn))}),t.jsx(L,{className:_(M,"whitespace-nowrap text-foreground"),children:n.dealType}),t.jsx(L,{className:_(M,"max-w-[220px] truncate text-muted-foreground"),title:n.investors,children:Z(n.investors)}),t.jsx(L,{className:_(M,"max-w-[140px] truncate text-muted-foreground"),children:Z(n.sector)}),t.jsx(L,{className:_(M,"max-w-[140px] truncate text-muted-foreground"),children:Z(n.hq)}),t.jsx(L,{className:_(M,"max-w-[140px] truncate text-muted-foreground"),children:Z(n.lead)}),t.jsx(L,{className:M,onClick:u=>u.stopPropagation(),children:l&&t.jsx(Ie,{entity:l,variant:"compact",watchSource:"list"})})]},n.id)})})]})})}const _s="row_id,company,acquirer_name,event_subtype,event_date,sector,deal_value_millions,source_url,country,state_code,company_logo_url",Ns="row_id,company,event_subtype,event_date,sector,source_url,country,state_code,company_logo_url";async function Oe(e,s,r,n){const{rows:o,error:l}=await es((u,c,i)=>{let x=I.from(e).select(s,i?{count:"exact"}:void 0).order("event_date",{ascending:!1}).order("row_id",{ascending:!1}).range(u,c);return r&&(x=x.gte("event_date",r)),n&&(x=x.lte("event_date",n)),x},{maxRows:8e3});if(l)throw l;return o}function ws(e){const{family:s,from:r,to:n,match:o,page:l,pageSize:u,enabled:c}=e,i=s==="ipo"?"mv_market_ipo":"mv_market_ma",x=s==="ipo"?Ns:_s,y=A({queryKey:["deals-family",s,r??null,n??null],enabled:c&&s!=="raise",staleTime:5*60*1e3,queryFn:async()=>Oe(i,x,r,n)}),g=f.useMemo(()=>{const S=y.data??[],j=[];if(s==="ipo"){for(const d of S){const N=De({id:d.row_id,company:d.company,subtype:d.event_subtype,eventDate:d.event_date,sector:d.sector,dealValueMillions:null,sourceUrl:d.source_url,country:d.country,stateCode:d.state_code,logoUrl:d.company_logo_url,family:"ipo"});N&&j.push(N)}return j}const m=s==="pe"?"pe":"ma";for(const d of S){if(m==="pe"&&d.event_subtype!=="buyout")continue;const N=De({id:d.row_id,company:d.company,acquirer:d.acquirer_name,subtype:d.event_subtype,eventDate:d.event_date,sector:d.sector,dealValueMillions:d.deal_value_millions,sourceUrl:d.source_url,country:d.country,stateCode:d.state_code,logoUrl:d.company_logo_url,family:m});N&&j.push(N)}return j},[y.data,s]),p=f.useMemo(()=>g.filter(S=>Kt(S,o)),[g,o]),h=f.useMemo(()=>Vt(p,l,u),[p,l,u]);return{rows:h.slice,total:h.total,hasMore:h.hasMore,isFetching:y.isFetching,isError:y.isError,showingSkeleton:y.isLoading&&h.slice.length===0}}const ks=[{value:"7D",label:"7D"},{value:"30D",label:"30D"},{value:"90D",label:"QTD"},{value:"YTD",label:"YTD"}],oe=e=>typeof e=="object"&&e.kind==="custom",ie=e=>e.toISOString().slice(0,10);function Ls({row:e}){const s=it({id:e.id,company_name:e.companyName,sector:e.sector,company_logo_url:e.logoUrl,
1slug:null}),r="group bg-card rounded-2xl border border-border hover:border-primary/30 hover:shadow-md transition-all duration-200 p-5 flex flex-col gap-3",n=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Ue,{companyName:e.companyName,domain:null,logoUrl:e.logoUrl,size:44,className:"rounded-xl flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-semibold text-foreground text-sm truncate",children:e.companyName}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground/70",children:[t.jsx("span",{className:"tabular-nums font-medium text-foreground/80",children:Ke(e.dealSizeMillions)}),e.dealType&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground/40",children:"·"}),t.jsx("span",{className:"truncate",children:e.dealType})]})]})]}),e.happenedOn&&t.jsx("span",{className:"flex-shrink-0 text-[11px] text-muted-foreground/60 tabular-nums",children:Ve(e.happenedOn)})]}),e.investors&&t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.investors}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-auto pt-2 border-t border-border/60",children:[e.sector&&t.jsx("span",{className:"inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground/80 border border-border max-w-[60%] truncate",children:e.sector}),e.hq&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground/70",children:[t.jsx(Pt,{className:"h-3 w-3"}),e.hq]})]})]}),o=e.href?e.hrefExternal?t.jsx(Ge,{href:e.href,className:"flex flex-col gap-3",children:n}):t.jsx(Pe,{to:e.href,className:"flex flex-col gap-3",children:n}):t.jsx("div",{className:"flex flex-col gap-3",children:n});return t.jsxs("div",{className:r,children:[o,s&&t.jsx(Ie,{entity:s,variant:"full",watchSource:"list"})]})}function Ms(){return t.jsxs("div",{className:"bg-card rounded-2xl border border-border p-5 flex flex-col gap-3 animate-pulse",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-11 h-11 rounded-xl bg-muted"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3.5 bg-muted rounded w-2/3"}),t.jsx("div",{className:"h-2.5 bg-muted rounded w-1/2"})]})]}),t.jsx("div",{className:"h-2.5 bg-muted rounded w-full"}),t.jsx("div",{className:"h-6 bg-muted rounded-full w-1/3 mt-1"})]})}function Cs(e,s){const[r,n]=f.useState(e);return f.useEffect(()=>{const o=setTimeout(()=>n(e),s);return()=>clearTimeout(o)},[e,s]),r}function Lr(){var Se,_e,Ne,we;const{filters:e,setFilters:s}=St(),[r,n]=ot(),o=Gt(r.get("family")),[l,u]=f.useState(()=>{try{return Fe(localStorage.getItem(Ae))}catch{return"table"}}),c=r.get("view")?Fe(r.get("view")):l,i=f.useCallback(a=>{try{localStorage.setItem(Ae,a)}catch{}u(a),n(E=>{const v=new URLSearchParams(E);return a==="table"?v.delete("view"):v.set("view","cards"),v},{replace:!0})},[n]),x=f.useCallback(a=>{n(E=>{const v=new URLSearchParams(E);return a==="raise"?v.delete("family"):v.set("family",a),v},{replace:!0})},[n]),y=Jt(c),g=Lt(),p=ke(r.get("tf")),h=f.useCallback(a=>{n(E=>{const v=new URLSearchParams(E);return a==="ALL"?v.delete("tf"):typeof a=="string"?v.set("tf",a):v.set("tf",`${a.from}:${a.to}`),v},{replace:!0})},[n]),[S,j]=f.useState(!1),[m,d]=f.useState(()=>{const a=ke(r.get("tf"));if(typeof a=="object"&&a.kind==="custom")return{from:new Date(a.from+"T00:00:00"),to:new Date(a.to+"T00:00:00")}}),[N,F]=f.useState(()=>r.get("q")||""),[z,C]=f.useState(0),[w,V]=f.useState(null),T=Cs(N.trim(),300),k=Ye(),R=f.useCallback(a=>{var E;if(V(a),s(ct(Me,a,{replace:!0})),a.keywords!=null&&a.keywords.trim()?F(a.keywords):F(""),a.timeframe){if(h(a.timeframe),typeof a.timeframe=="object"&&a.timeframe.kind==="custom"){const v=new Date(a.timeframe.from+"T00:00:00"),at=new Date(a.timeframe.to+"T00:00:00");d({from:v,to:at})}}else h("ALL"),d(void 0);C(0),a.thresholdAlert&&dt(a,{expeditionId:((E=k==null?void 0:k.activeExpedition)==null?void 0:E.id)??null}).then(v=>{v.ok?Le.success("Threshold alert live â agent + Signals rule created"):v.reason&&Le.error(v.reason)})},[s,h,(Se=k==null?void 0:k.activeExpedition)==null?void 0:Se.id]),b=f.useCallback(()=>{V(null),s({...Me,geo:{..._t}}),F(""),h("ALL"),C(0)},[s,h]),J=f.useCallback(a=>
1{if(!ut(a)&&!a.thresholdAlert){b();return}R(a)},[R,b]),{data:xe}=ss(),Qe=rs(),he=f.useMemo(()=>(xe??[]).map(a=>a.sector),[xe]),Ze=f.useMemo(()=>p==="ALL"?void 0:Nt(p).startIso,[p]),Je=f.useMemo(()=>oe(p)?p.to:void 0,[p]),Xe=()=>{!(m!=null&&m.from)||!(m!=null&&m.to)||(h({kind:"custom",from:ie(m.from),to:ie(m.to)}),j(!1))},be=a=>{a.stopPropagation(),d(void 0),h("ALL")},$=e.sectors,X=e.stages,q=e.geo.countries,O=e.geo.states,ee=e.geo.counties,te=e.geo.zips,G=(w==null?void 0:w.dealSizeMin)??e.dealSizeMin,W=(w==null?void 0:w.dealSizeMax)??e.dealSizeMax,et=JSON.stringify({q:T,sectors:$,stages:X,countries:q,states:O,counties:ee,zips:te,tf:p,amountMin:G,amountMax:W,family:o,view:c});f.useEffect(()=>{C(0)},[et]);const U=ts({q:T||void 0,sectors:$.length?fe($):void 0,stages:X.length?X:void 0,countries:q.length?q:void 0,states:O.length?O:void 0,counties:ee.length?ee:void 0,zips:te.length?te:void 0,from:Ze,to:Je,amountMin:G??null,amountMax:W??null,limit:y,offset:z*y,enabled:o==="raise"}),ye=Wt(o,p),tt=f.useMemo(()=>({q:T||void 0,sectors:$.length?fe($):void 0,countries:q.length?q:void 0,states:O.length?O:void 0,amountMin:G??null,amountMax:W??null}),[T,$,q,O,G,W]),Y=ws({family:o,from:ye.from,to:ye.to,match:tt,page:z,pageSize:y,enabled:o!=="raise"}),ve=((_e=U.data)==null?void 0:_e.rows)??[],P=o==="raise"?ve.map(Ht):Y.rows,le=o==="raise"?((Ne=U.data)==null?void 0:Ne.total)??0:Y.total,st=o==="raise"?((we=U.data)==null?void 0:we.hasMore)??!1:Y.hasMore,se=o==="raise"?U.isFetching:Y.isFetching,H=o==="raise"?U.isError:Y.isError,re=o==="raise"?U.isFetching&&ve.length===0:Y.showingSkeleton,ce=!!T||$.length>0||o==="raise"&&X.length>0||q.length>0||O.length>0||ee.length>0||te.length>0||G!=null||W!=null||p!=="ALL"||o!=="raise",rt=o==="raise"?"deal":ze(o).toLowerCase(),je=ce?`${le.toLocaleString()} ${rt}${le===1?"":"s"} match`:"Every tracked raise back to 2005 â searchable, filterable, newest first",de=f.useMemo(()=>w||(ce?mt(e,{keywords:T||void 0,timeframe:p==="ALL"?void 0:p}):null),[w,ce,e,T,p]),nt=f.useMemo(()=>P.map(a=>({name:a.companyName,id:a.id,sector:a.sector,logoUrl:a.logoUrl,slug:a.href&&!a.hrefExternal?a.href.split("/").pop():void 0})),[P]),ue=a=>`inline-flex items-center rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${a?"bg-background border border-border text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`;return t.jsxs("div",{className:"max-w-[1600px] mx-auto w-full p-6 md:p-8",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:"Deals"}),t.jsx(Xt,{hash:"deals"})]}),t.jsx("p",{className:"text-muted-foreground mt-1",children:g.scopeLabel?`${g.scopeLabel} · ${je}`:je})]}),!g.loading&&(g.hasLens?t.jsx(Mt,{mode:g.mode,onChange:g.setMode,expeditionName:g.expeditionName,className:"flex-shrink-0"}):t.jsx(Ct,{expeditionName:g.expeditionName,className:"flex-shrink-0"}))]}),t.jsx(lt,{surface:"db:deals",surfaceLabel:"Deals",activeSector:e.sectors.length===1?e.sectors[0]:null,activeStage:e.stages.length===1?e.stages[0]:null,onApplyScreen:R,className:"mb-3"}),t.jsx(bs,{enabled:o==="raise"&&!!(k!=null&&k.activeExpedition)&&(g.mode==="expedition"||!g.hasLens),onUseOnPage:a=>{a&&(s({...e,stages:[a]}),C(0))},onSearchLead:a=>{F(a),C(0)}}),de&&t.jsxs("div",{className:"mb-6 space-y-2",children:[t.jsx(ft,{spec:de,onCh
1ange:J,onClear:b}),t.jsx(pt,{surface:"db:deals",spec:de,results:nt,onLoadScreen:R})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[t.jsx(Re,{size:"sm",children:Qt.map(a=>t.jsx(me,{label:a.label,active:o===a.id,onClick:()=>x(a.id),size:"sm"},a.id))}),t.jsxs(Re,{size:"sm",children:[t.jsx(me,{icon:Ft,label:"Table",active:c==="table",onClick:()=>i("table"),size:"sm"}),t.jsx(me,{icon:At,label:"Cards",active:c==="cards",onClick:()=>i("cards"),size:"sm"})]})]}),Zt(o,p)&&t.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[ze(o)," on All uses year-to-date. All-time is the raise set."]}),t.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center gap-3 mb-6",children:[t.jsxs("div",{className:"relative w-full max-w-sm",children:[t.jsx(zt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60"}),t.jsx("input",{value:N,onChange:a=>F(a.target.value),placeholder:"Search company or investorâ¦",className:"w-full h-10 pl-9 pr-4 rounded-xl bg-card border border-border text-sm text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/40"})]}),t.jsxs("div",{className:"flex items-center gap-1 w-full lg:w-auto overflow-x-auto scrollbar-hide pb-1 lg:pb-0 lg:ml-auto",children:[t.jsxs("div",{className:"inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1 flex-shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>h("ALL"),className:ue(p==="ALL"),children:"All"}),ks.map(a=>t.jsx("button",{type:"button",onClick:()=>h(a.value),className:ue(p===a.value),children:a.label},a.value)),t.jsxs(gt,{open:S,onOpenChange:j,children:[t.jsx(xt,{asChild:!0,children:t.jsxs("button",{type:"button",className:`${ue(oe(p))} inline-flex items-center gap-1.5`,children:[oe(p)?`${p.from} â ${p.to}`:"Custom",oe(p)&&t.jsx("span",{role:"button",tabIndex:0,"aria-label":"Clear date range",onClick:be,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&be(a)},className:"-mr-1 rounded p-0.5 text-muted-foreground hover:text-foreground hover:bg-muted",children:t.jsx(Rt,{className:"h-3 w-3"})})]})}),t.jsxs(ht,{align:"end",className:"w-auto p-0 overflow-hidden",sideOffset:6,children:[t.jsx("div",{className:"px-3 py-2 border-b border-border",children:t.jsx("span",{className:"text-xs font-medium text-foreground",children:"Pick a date range"})}),t.jsx(bt,{mode:"range",numberOfMonths:1,selected:m,onSelect:d,defaultMonth:(m==null?void 0:m.from)??void 0,captionLayout:"dropdown-buttons",fromYear:2005,toYear:new Date().getFullYear(),className:"px-2",classNames:{caption_dropdowns:"flex justify-center gap-1",caption_label:"flex items-center gap-1 text-sm font-medium",dropdown_month:"relative inline-flex items-center rounded-md px-1.5 py-0.5 hover-supported:hover:bg-accent",dropdown_year:"relative inline-flex items-center rounded-md px-1.5 py-0.5 hover-supported:hover:bg-accent",dropdown:"absolute inset-0 w-full cursor-pointer appearance-none opacity-0",vhidden:"sr-only"}}),t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-border bg-muted/40",children:[t.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[m!=null&&m.from?ie(m.from):"â"," â ",m!=null&&m.to?ie(m.to):"â"]}),t.jsx(wt,{size:"sm",onClick:Xe,disabled:!(m!=null&&m.from)||!(m!=null&&m.to),className:"h-7 text-xs",children:"Apply"})]})]})]})]}),t.jsx(Ce,{mode:"sector",filters:e,onChange:s,availableSectors:he}),o==="raise"&&t.jsx(Ce,{mode:"stage",filters:e,onChange:s,availableSectors:he}),t.jsx(Tt,{value:e.geo,onChange:a=>s({...e,geo:a}),startups:Qe}),t.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap tabular-nums pl-2 inline-flex items-center gap-2 flex-shrink-0",children:[le.toLocaleString()," deals",se&&t.jsx(Ee,{className:"h-3.5 w-3.5 animate-spin"})]})]})]}),H&&t.jsx("div",{className:"rounded-xl border border-border bg-card p-8 text-center text-sm text-muted-foreground",children:"Couldnât load deals. Please try again."}),!H&&c==="table"&&(re||P.length>0)&&t.jsx(Ss,{rows:P,startIndex:z*y,loading:re}),!H&&c==="cards"&&t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:re?Array.from({length:12}).map((a,E)=>t.jsx(Ms,{},E)):P.map(a=>t.jsx(Ls,{row:a},a.id))}),!H&&!re&&P.length===0&&t.jsxs("div",{className:"rounded-xl border border-border bg-card p-12 text-center",children:[t.jsx($t,{className:"h-8 w-8 mx-auto text-muted-foreground
1/40 mb-3"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No deals matched these filters."})]}),!H&&P.length>0&&t.jsxs("div",{className:"flex items-center justify-between mt-8",children:[t.jsxs("span",{className:"text-xs text-muted-foreground/70 inline-flex items-center gap-2",children:["Page ",z+1,se&&t.jsx(Ee,{className:"h-3.5 w-3.5 animate-spin"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{type:"button",disabled:z===0||se,onClick:()=>C(a=>Math.max(0,a-1)),className:"inline-flex items-center gap-1 h-9 px-3 rounded-lg border border-border bg-card text-sm text-foreground disabled:opacity-40 disabled:cursor-not-allowed hover:border-primary/30 transition-colors",children:[t.jsx(qt,{className:"h-4 w-4"})," Prev"]}),t.jsxs("button",{type:"button",disabled:!st||se,onClick:()=>C(a=>a+1),className:"inline-flex items-center gap-1 h-9 px-3 rounded-lg border border-border bg-card text-sm text-foreground disabled:opacity-40 disabled:cursor-not-allowed hover:border-primary/30 transition-colors",children:["Next ",t.jsx(Ot,{className:"h-4 w-4"})]})]})]})]})}export{Lr as default};
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.