1import{h as K,j as e,B as k,v as x,r as l,w as ke,T as Te,x as Ee,y as Le,aa as De,z as Me,O as me,u as $e,g as ge,C as He,Y as ze,U as Pe,ao as Be,ac as Ce,D as Se,c as ye,M as Ie,d as Re,e as Ae,$ as pe}from"./index-BA-hDO3C.js";import{B as Fe}from"./badge-BmS2sdGI.js";import{C as Ge}from"./checkbox-ZpY8b9Nw.js";import{M as Oe}from"./mail-ZTV35zlk.js";import{C as Ue}from"./contact-row-DhEji99D.js";import{C as We}from"./chevron-left-CJuQnFIJ.js";import{B as Je}from"./building-2-B59OQuVd.js";import{G as Ye}from"./globe-B4oBl9ot.js";import{M as Ze}from"./map-pin-CADt7NYp.js";import{E as _e}from"./external-link-BC7xl8Dm.js";import"./ban-Z2WHw_L5.js";import"./linkedin-UAFeFJyr.js";import"./phone-CNUoMUC0.js";import"./message-square-CUDKYNfg.js";import"./star-CLniQGze.js";import"./thumbs-down-R5QH_mmm.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const qe=K("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ke=K("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** 12 * @license lucide-react v0.453.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Qe=K("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);function Xe({onSearch:s,isSearching:u=!1,className:j}){return e.jsxs(k,{variant:"ghost",size:"sm",onClick:s,disabled:u,className:x("px-2 h-6 text-[11px] font-medium transition-all","hover:bg-muted/50 text-gray-400/60 hover:text-gray-500",j),"data-testid":"find-emails-button",children:[e.jsx(Oe,{className:x("h-3 w-3 mr-0.5",u&&"animate-spin")}),u?"Searching...":"Find Emails"]})}function Ve({query:s,currentResults:u,onResultsExtended:j,onLoginRequired:T,isAuthenticated:y,className:D=""}){const[w,c]=l.useState(!1),{toast:h}=ke(),M=async()=>{if(!y){T();return}if(!s||!u){h({title:"No search to extend",description:"Please run a search first before extending",variant:"destructive"});return}c(!0);try{const o=localStorage.getItem("contactSearchConfig");let f=null;if(o)try{f=JSON.parse(o)}catch(p){console.error("Error parsing contact search config:",p)}const d=await(await me("POST","/api/search/extend",{query:s,excludeCompanyIds:u.map(p=>({name:p.name}))||[],contactSearchConfig:f||{enableCoreLeadership:!0,enableDepartmentHeads:!0,enableMiddleManagement:!0}})).json();if(d.jobId&&d.companies&&d.companies.length>0){console.log(`[ExtendSearch] Extending search with ${d.companies.length} new companies`),h({title:"Finding more companies",description:`Adding ${d.companies.length} additional companies with contacts and emails.`});const p=setInterval(async()=>{try{const v=await(await me("GET",`/api/search-jobs/${d.jobId}`)).json();if(v.status==="completed"&&v.results){clearInterval(p),c(!1);const $=v.results.companies||[],H=[...u||[],...$];j(s,H),h({title:"Search extended",description:`Added ${$.length} new companies to your results.`})}else v.status==="failed"&&(clearInterval(p),c(!1),h({title:"Extension failed",description:"Could not fetch additional companies. Please try again.",variant:"destructive"}))}catch(E){console.error("[ExtendSearch] Error polling job:",E)}},2e3);setTimeout(()=>{clearInterval(p),c(!1)},3e4)}else if(d.companies&&d.companies.length===0)c(!1),h({title:"No additional companies found",description:"We couldn't find more companies matching your search criteria."});else throw c(!1),new Error(d.error||"Failed to extend search")}catch(o){c(!1),console.error("[ExtendSearch] Error extending search:",o),h({title:"Error",description:o instanceof Error?o.message:"Failed to extend search",variant:"destructive"})}};return e.jsx(Te,{children:e.jsxs(Ee,{children:[e.jsx(Le,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"sm",className:x("px-2 h-6 text-[11px] font-medium transition-all","hover:bg-muted/50 text-gray-400/60 hover:text-gray-500",D),onClick:M,disabled:w,"data-testid":"extend-search-button",children:[e.jsx(De,{className:x("h-3 w-3 mr-0.5",w&&"animate-spin")}),w?"Extending...":"5 More"]})}),e.jsx(Me,{side:"top",children:e.jsx("p",{className:"text-xs",children:"Expand the search to include another five companies with the same prompt"})})]})})}const ve=({company:s,isExpanded:u,onToggleExpand:j,isSelected:T,onToggleSelection:y,selectedContacts:D,onToggleContactSelection:w,companySelectionState:c,onCompanyCheckboxChange:h,shouldShowCompanyCheckbox:M,handleCompanyView:o,handleComprehensiveEmailSearch:f,handleFindMobilePhone:g,pendingContactIds:d,pendingComprehensiveSearchIds:p,pendingPhoneRevealIds:E,onContactClick:v,onContactHover:$,onContactLeave:H,shouldShowCheckbox:z,setLocation:I,sortedContacts:b,viewMode:F,selectedEmailContact:m,showAllContacts:P,onToggleShowAllContacts:n,showDescription:B,onToggleDescription:G,isAuthenticated:O})=>{const C=l.useRef(null);return l.useEffect(()=>{if(C.current&&c==="indeterminate"){const i=C.current.querySelector("input");i&&(i.indeterminate=!0)}},[c]),e.jsxs(ze,{className:x("rounded-none md:rounded-lg transition-all duration-200 cursor-pointer","bg-card hover:bg-card-hover hover:shadow-md hover:border-border",T&&"border-blue-400 dark:border-blue-600",!T&&"border-border"),children:[e.jsx("div",{onClick:j,className:"p-3",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:x("transition-all duration-300 ease-out overflow-hidden",M?"w-6 mr-1":"w-0 mr-0"),children:e.jsx(Ge,{ref:C,checked:c==="checked"||c==="indeterminate",onCheckedChange:h,onClick:i=>i.stopPropagation(),"aria-label":`Select ${s.name}`,className:"mt-0.5"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("h3",{className:"font-semibold text-base leading-tight flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4 text-muted-foreground"}),s.name,s.description&&e.jsx("button",{onClick:i=>{i.stopPropagation(),G()},className:x("p-0.5 rounded transition-all border relative","before:absolute before:inset-[-8px] before:content-['']",B?"text-foreground
16/70 border-transparent":"text-muted-foreground border-transparent hover:text-foreground/70"),"aria-label":"Show company description","data-testid":`button-info-company-${s.id}`,children:e.jsx(qe,{className:"h-3.5 w-3.5"})})]}),B&&s.description&&e.jsx("div",{className:"mt-1.5 p-2 bg-muted/50 rounded-md text-sm text-muted-foreground leading-relaxed",onClick:i=>i.stopPropagation(),"data-testid":`text-description-company-${s.id}`,children:s.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.website&&e.jsxs("a",{href:s.website.startsWith("http")?s.website:`https://${s.website}`,target:"_blank",rel:"noopener noreferrer",onClick:i=>i.stopPropagation(),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-primary transition-colors",children:[e.jsx(Ye,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[200px]",children:s.website.replace(/^https?:\/\//,"").replace(/\/$/,"")})]}),(s.city||s.country)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ze,{className:"h-3 w-3"}),e.jsx("span",{children:[s.city,s.country].filter(Boolean).join(", ")})]}),s.contacts&&s.contacts.length>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Pe,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.contacts.length," contacts"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.contacts&&s.contacts.length>0&&F==="scroll"&&e.jsx(Fe,{variant:"outline",className:"text-xs cursor-pointer hover:bg-accent-hover",children:u?e.jsx(Be,{className:"h-3 w-3"}):e.jsx(Ce,{className:"h-3 w-3"})}),e.jsxs(Se,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(k,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:i=>i.stopPropagation(),children:e.jsx(Ie,{className:"h-4 w-4"})})}),e.jsx(Re,{align:"end",children:e.jsxs(Ae,{onClick:()=>o(s),children:[e.jsx(_e,{className:"mr-2 h-4 w-4"}),"View Details"]})})]})]})]})})]})}),u&&b.length>0&&e.jsx(pe,{className:"pt-0 px-3 pb-3",children:e.jsx("div",{className:"border-t pt-2",children:e.jsxs("div",{className:x("space-y-1.5",P&&b.length>10&&"max-h-[400px] overflow-y-auto pr-2"),children:[b.map((i,U)=>e.jsx("div",{className:x(U>2&&!P&&"hidden"),children:e.jsx(Ue,{contact:i,isSelected:D.has(i.id),onToggleSelection:L=>w(null,L),onClick:()=>v==null?void 0:v(i,s),onHover:$,onLeave:H,showCheckbox:(z==null?void 0:z(i.id))??!1,isHighlighted:(m==null?void 0:m.id)===i.id,isAuthenticated:O,handleContactView:L=>{const W=L.slug||L.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").substring(0,50);I(`/p/${W}/${L.id}`)},handleComprehensiveEmailSearch:f,handleFindMobilePhone:g,pendingComprehensiveSearchIds:p,pendingPhoneRevealIds:E})},`${s.id}-contact-${i.id}`)),b.length>3&&e.jsx("div",{className:"pt-2",children:e.jsx(k,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),n()},className:"w-full text-xs text-muted-foreground hover:text-foreground hover:bg-accent-hover transition-all py-2 rounded-md",children:P?"Show fewer contacts":`+${b.length-3} more contacts available`})})]})})}),u&&b.length===0&&e.jsx(pe,{className:"pt-0 px-4 pb-4",children:e.jsx("div",{className:"border-t pt-3",children:e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"No contacts found for this company"})})})]})};function gs({companies:s,handleCompanyView:u,handleComprehensiveEmailSearch:j,handleFindMobilePhone:T,pendingContactIds:y,pendingComprehensiveSearchIds:D,pendingPhoneRevealIds:w,onContactClick:c,onViewModeChange:h,selectedEmailContact:M,selectedContacts:o=new Set,onContactSelectionChange:f,getCompanySelectionState:g,onCompanySelectionChange:d,topActionsTrailing:p,onShowReport:E,onFindKeyEmails:v,isFindingEmails:$,query:H,onExtendSearch:z,isAuthenticated:I,onLoginRequired:b}){const[,F]=$e(),[m,P]=l.useState("scroll"),[n,B]=l.useState(0),[G,O]=l.useState(new Set),[C,i]=l.useState(new Set),[U,L]=l.useState(new Set),[W,Q]=l.useState(!1),[be,X]=l.useState(null),[J,V]=l.useState(null),[q,ee]=l.useState(!1),[je,se]=l.useState(null),[Y,te]=l.useState(null),re=t=>{O(r=>{const a=new Set(r);return a.has(t)?a.delete(t):a.add(t),a})},ae=t=>{i(r=>{const a=new Set(r);return a.has(t)?a.delete(t):a.add(t),a})},ie=t=>{L(r=>{const a=new Set(r);return a.has(t)?a.delete(t):a.add(t),a})},oe=t=>m==="slides"?!0:G.has(t),we=()=>{B(t=>t>0?t-1:s.length-1)},Ne=()=>{B(t=>t<s.length-1?t+1:0)};l.useEffect(()=>{m==="slides"&&n>=s.length&&B(Math.max(0,s.length-1))},[s.length,m,n]);const ne=(t,r)=>{t&&t.stopPropagation(),f&&(f(r),!q&&!o.has(r)&&setTimeout(()=>ee(!0),500))},le=t=>{J&&clearTimeout(J);const r=setTimeout(()=>{X(t)},5e3);V(r)},de=()=>
16{J&&(clearTimeout(J),V(null)),X(null)},ce=(t,r)=>{c&&c(t,r)},he=t=>"ontouchstart"in window||navigator.maxTouchPoints>0?!0:be===t||o.has(t)||q;l.useEffect(()=>{ee(o.size>0)},[o.size]);const ue=t=>{Y&&clearTimeout(Y);const r=setTimeout(()=>{se(t)},1500);te(r)},xe=()=>{Y&&(clearTimeout(Y),te(null)),se(null)},fe=t=>{if("ontouchstart"in window||navigator.maxTouchPoints>0)return!0;const a=s.find(R=>R.id===t);if(!a)return!1;const N=g==null?void 0:g(a);return je===t||N!=="unchecked"||q},Z=l.useMemo(()=>{const t=new Map;return s.forEach(r=>{if(r.contacts&&r.contacts.length>0){const a=[...r.contacts].sort((N,R)=>(R.probability||0)-(N.probability||0));t.set(r.id,a)}}),t},[s]);return l.useEffect(()=>{if(s.length>0&&G.size===0){const t=s[0],r=Z.get(t.id);r&&r.length>0&&(console.log("Auto-expanding first company to show contacts:",t.name),O(new Set([t.id])))}},[s,Z]),e.jsxs("div",{className:"w-full space-y-1 bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between -mt-1 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const t=s.reduce((_,S)=>{var A;return _+(((A=S.contacts)==null?void 0:A.length)||0)},0),r=o.size,a=t>0&&r===t,N=r>0&&r<t,R=r===0;return e.jsxs("button",{onClick:()=>{a||N?Array.from(o).forEach(S=>{f==null||f(S)}):s.forEach(_=>{var S;(S=_.contacts)==null||S.forEach(A=>{o.has(A.id)||f==null||f(A.id)})})},className:x("h-4 w-4 rounded-sm border ring-offset-background transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","ml-2 mr-2 flex items-center justify-center",a&&"bg-primary border-primary",N&&"border-primary bg-card",R&&"border-input bg-card hover:border-primary/50"),"aria-label":a?"Deselect all contacts":N?`${r} of ${t} selected`:"Select all contacts","data-testid":"checkbox-master-select-all",children:[a&&e.jsx(ge,{className:"h-3 w-3 text-primary-foreground"}),N&&e.jsx(ge,{className:"h-2.5 w-2.5 text-primary"})]})})(),p&&e.jsx("div",{className:"hidden md:flex",children:p}),e.jsxs("div",{className:"flex items-center gap-0.5 bg-muted/20 rounded-md p-0.5",children:[e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>{P("scroll"),h==null||h("scroll")},className:x("px-2 h-6 text-[11px] font-medium transition-all",m==="scroll"?"bg-background text-foreground shadow-sm":"hover:bg-muted-hover text-muted-foreground/60 hover:text-muted-foreground"),children:[e.jsx(Qe,{className:"h-3 w-3 mr-0.5"}),"Scroll"]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>{P("slides"),h==null||h("slides"),Q(!0),setTimeout(()=>Q(!1),1e3)},className:x("px-2 h-6 text-[11px] font-medium transition-all",m==="slides"?"bg-background text-foreground shadow-sm":"hover:bg-muted-hover text-muted-foreground/60 hover:text-muted-foreground"),children:[e.jsx(Ke,{className:"h-3 w-3 mr-0.5"}),"Slides"]})]}),v&&e.jsx(Xe,{onSearch:v,isSearching:$}),H&&z&&b&&e.jsx(Ve,{query:H,currentResults:s,onResultsExtended:z,isAuthenticated:I??!1,onLoginRequired:b}),E&&e.jsx("button",{onClick:E,className:"text-[11px] text-muted-foreground/60 hover:text-muted-foreground hover:underline ml-2 transition-colors","data-testid":"link-show-report",children:"Report"})]}),m==="slides"&&s.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(k,{variant:"outline",size:"sm",onClick:we,className:x("h-8 w-8 p-0 transition-all",W?"bg-primary/20 border-primary":"border-muted-foreground/20"),children:e.jsx(We,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground px-1",children:[n+1," of ",s.length]}),e.jsx(k,{variant:"outline",size:"sm",onClick:Ne,className:x("h-8 w-8 p-0 transition-all",W?"bg-primary/20 border-primary":"border-muted-foreground/20"),children:e.jsx(He,{className:"h-4 w-4"})})]})]}),m==="scroll"?s.map(t=>e.jsx("div",{onMouseEnter:()=>ue(t.id),onMouseLeave:()=>xe(),children:e.jsx(ve,{company:t,isExpanded:oe(t.id),onToggleExpand:()=>re(t.id),isSelected:!1,onToggleSelection:()=>{},selectedContacts:o,onToggleContactSelection:ne,companySelectionState:g==null?void 0:g(t),onCompanyCheckboxChange:()=>d==null?void 0:d(t),shouldShowCompanyCheckbox:fe(t.id),handleCompanyView:u,handleComprehensiveEmailSearch:j,handleFindMobilePhone:T,pendingContactIds:y,pendingComprehensiveSearchIds:D,pendingPhoneRevealIds:w,onContactClick:ce,onContactHover:le,onContactLeave:de,shouldShowCheckbox:he,setLocation:F,sortedContacts:Z.get(t.id)||[],viewMode:m,selectedEmailContact:M,showAllContacts:C.has(t.id),onToggleShowAllContacts:()=>ae(t.id),showDescription:U.has(t.id),onToggleDescription:()=>ie(t.id),isAuthenticated:I})},`company-${t.id}`)):s.length>0&&e.jsx("div",{onMouseEnter:()=>ue(s[n].id),onMouseLeave:()=>xe(),children:e.jsx(ve,{company:s[n],isExpanded:oe(s[n].id),onToggleExpand:()=>re(s[n].id),isSelected:!1,onToggleSelection:()=>{},selectedContacts:o,onToggleContactSelection:ne,companySelectionState:g==null?void 0:g(s[n]),onCompanyCheckboxChange:()=>d==null?void 0:d(s[n]),shouldShowCompanyCheckbox:fe(s[n].id),handleCompanyView:u,handleComprehensiveEmailSearch:j,handleFindMobilePhone:T,pendingContactIds:y,pendingComprehensiveSearchIds:D,pendingPhoneRevealIds:w,onContactClick:ce,onContactHover:le,onContactLeave:de,shouldShowCheckbox:he,setLocation:F,sortedContacts:Z.get(s[n].id)||[],viewMode:m,selectedEmailContact:M,showAllContacts:C.has(s[n].id),onToggleShowAllContacts:()=>ae(s[n].id),showDescription:U.has(s[n].id),onToggleDescription:()=>ie(s[n].id),isAuthenticated:I},`company-${s[n].id}`)})]})}export{gs 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.