PageSourceSearch

https://www.getupgraded.ai/_next/static/chunks/65534-a109c3b3ad94f9fd.js

js getupgraded.ai collected 2026-10-05 15:23:05 UTC 215,725 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[65534],{26019:(e,t,a)=>{a.d(t,{d:()=>u});var r=a(95155),n=a(12115),l=a(57218),s=a(89731),o=a(9554),i=a(52325),c=a(18720);let d={general:"General",faq:"FAQ",product:"Product",pricing:"Pricing",company:"Company",process:"Process",objection:"Objections",competitors:"Competitors",icp:"ICP",booking:"Booking",social_proof:"Social Proof"};function u(e){var t,a;let{isDark:u}=e,[m,g]=(0,n.useState)([]),[x,h]=(0,n.useState)(!0),[p,y]=(0,n.useState)(""),[b,f]=(0,n.useState)(!1),[v,w]=(0,n.useState)(""),[j,N]=(0,n.useState)(""),[k,C]=(0,n.useState)("general"),[_,S]=(0,n.useState)(!1),[E,A]=(0,n.useState)(null),[L,I]=(0,n.useState)(""),[F,T]=(0,n.useState)(""),[D,O]=(0,n.useState)("all"),P=(0,n.useCallback)(async()=>{try{let t=await fetch("/api/brain/knowledge-base");if(t.ok){var e;let a=await t.json();g((null!=(e=a.entries)?e:[]).filter(e=>e.is_active))}}catch(e){}finally{h(!1)}},[]);(0,n.useEffect)(()=>{P()},[P]);let M=(0,n.useMemo)(()=>m.filter(e=>!p||e.title.toLowerCase().includes(p.toLowerCase())||e.content.toLowerCase().includes(p.toLowerCase())),[m,p]),R=(0,n.useMemo)(()=>{let e=M.reduce((e,t)=>{var a;let r=t.category||"general";return(null!=(a=e[r])?a:e[r]=[]).push(t),e},{}),t=Object.keys(d),a=Object.keys(e).filter(e=>!t.includes(e)).sort((e,t)=>e.localeCompare(t));return[...t,...a].map(t=>{var a;return[t,null!=(a=e[t])?a:[]]})},[M]),U="all"===D?R.filter(e=>{let[,t]=e;return t.length>0}):R.filter(e=>{let[t]=e;return t===D}),z=async()=>{if(!v.trim()||!j.trim())return void c.o.error("Title and content are required");S(!0);try{let e=await fetch("/api/brain/knowledge-base",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:v.trim(),content:j.trim(),category:k})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to create")}c.o.success("Entry created"),f(!1),w(""),N(""),C("general"),P()}catch(e){c.o.error(e instanceof Error?e.message:"Failed to create")}finally{S(!1)}},q=async e=>{if(L.trim()&&F.trim()){S(!0);try{if(!(await fetch("/api/brain/knowledge-base",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,title:L.trim(),content:F.trim()})})).ok)throw Error("Failed to update");c.o.success("Entry updated"),A(null),P()}catch(e){c.o.error("Failed to update")}finally{S(!1)}}},J=async e=>{try{if(!(await fetch("/api/brain/knowledge-base?id=".concat(e),{method:"DELETE"})).ok)throw Error("Failed to delete");c.o.success("Entry removed"),P()}catch(e){c.o.error("Failed to delete")}};if(x)return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-sm ".concat(u?"text-gray-400":"text-gray-500"),children:"Loading knowledge base…"});let B=e=>{var t;return null!=(t=d[e])?t:e};return(0,r.jsxs)("div",{className:"flex h-full min-h-0",children:[(0,r.jsxs)("nav",{"aria-label":"Knowledge base sections",className:"w-52 shrink-0 overflow-y-auto border-r px-2 py-3 ".concat(u?"border-gray-800":"border-[#e5e5e3]"),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>O("all"),className:"mb-1 flex w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-2.5 py-2 text-left text-[13px] font-medium transition-colors ".concat("all"===D?u?"bg-white/10 text-white":"bg-white text-gray-900 shadow-sm":u?"text-gray-300 hover:bg-white/[0.06]":"text-gray-700 hover:bg-white/70"),children:[(0,r.jsx)("span",{children:"All"}),(0,r.jsx)("span",{className:"text-[11px] tabular-nums ".concat(u?"text-gray-500":"text-gray-400"),children:M.length})]}),R.map(e=>{let[t,a]=e,n=D===t;return(0,r.jsxs)("button",{type:"button",onClick:()=>O(t),className:"flex w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-2.5 py-2 text-left text-[13px] font-medium transition-colors ".concat(n?u?"bg-white/10 text-white":"bg-white text-gray-900 shadow-sm":u?"text-gray-300 hover:bg-white/[0.06]":"text-gray-700 hover:bg-white/70"),children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:B(t)}),(0,r.jsx)("span",{className:"shrink-0 text-[11px] tabular-nums ".concat(u?"text-gray-500":"text-gray-400"),children:a.length})]},t)})]}),(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-5 py-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold ".concat(u?"text-gray-100":"text-gray-900"),children:"all"===D?"Knowledge Base":B(D)}),(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full ".concat(u?"text-gray-100 bg-gray-700":"text-white bg-gray-900"),children:"all"===D?M.length:null!=(a=null==(t=U[0])?void 0:t[1].length)?a:0}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("input",{type:"search",value:p,onChange:e=>y(e.target.value),placeholder:"Search…",className:"w-48 rounded-lg border px-3 py-1.5 text-[11px] focus:outline-none focus:ring-1 ".concat(u?"border-gray-600 bg-gray-700 text-white placeholder:text-gray-400 focus:ring-gray-500":"border-gray-200 bg-white focus:ring-gray-300")}),(0,r.jsxs)("button",{type:"button",onClick:()=>{f(!0),"all"!==D&&C(D)},className:"inline-flex items-center gap-1 px-2.5 py-1.5 text-[11px] font-medium rounded-lg transition-colors ".concat(u?"bg-gray-600 text-white hover:bg-gray-500":"bg-gray-900 text-white hover:bg-gray-800"),children:[(0,r.jsx)(l.A,{className:"h-3.5 w-3.5"}),"Add"]})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pb-6",children:[b&&(0,r.jsxs)("div",{className:"rounded-lg border p-3 space-y-2 ".concat(u?"border-gray-700 bg-gray-700/50":"border-gray-200 bg-gray-50"),children:[(0,r.jsx)("input",{type:"text",value:v,onCh
1ange:e=>w(e.target.value),placeholder:"Title",className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(u?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsx)("textarea",{value:j,onChange:e=>N(e.target.value),placeholder:"Content",rows:3,className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(u?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsx)("select",{value:k,onChange:e=>C(e.target.value),className:"rounded-lg border px-3 py-1.5 text-sm ".concat(u?"border-gray-600 bg-gray-700 text-white":"border-gray-200"),children:Object.entries(d).map(e=>{let[t,a]=e;return(0,r.jsx)("option",{value:t,children:a},t)})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:z,disabled:_||!v.trim()||!j.trim(),className:"inline-flex items-center justify-center rounded-lg bg-gray-900 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-gray-800 disabled:opacity-50",children:(0,r.jsx)(i.L,{reserve:"Creating…",children:_?"Creating…":"Create"})}),(0,r.jsx)("button",{type:"button",onClick:()=>{f(!1),w(""),N("")},className:"rounded-lg border px-3 py-1.5 text-[11px] font-medium ".concat(u?"border-gray-600 text-gray-300":"border-gray-200 text-gray-600"),children:"Cancel"})]})]}),U.every(e=>{let[,t]=e;return 0===t.length})?(0,r.jsx)("p",{className:"py-8 text-center text-sm ".concat(u?"text-gray-400":"text-gray-500"),children:p?"No entries match your search.":"all"===D?"No knowledge base entries yet. Add one above.":"No entries in ".concat(B(D)," yet.")}):U.map(e=>{let[t,a]=e;return(0,r.jsxs)("div",{children:["all"===D&&(0,r.jsx)("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wider ".concat(u?"text-gray-500":"text-gray-400"),children:B(t)}),(0,r.jsx)("div",{className:"space-y-1.5",children:a.map(e=>(0,r.jsx)("div",{className:"rounded-xl border p-4 ".concat(u?"border-gray-700 bg-gray-800/60":"border-[#e5e5e3] bg-white shadow-sm"),children:E===e.id?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("input",{type:"text",value:L,onChange:e=>I(e.target.value),className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(u?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsx)("textarea",{value:F,onChange:e=>T(e.target.value),rows:3,className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(u?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>q(e.id),disabled:_,className:"inline-flex items-center justify-center rounded px-2 py-1 text-xs font-medium text-white bg-gray-900 hover:bg-gray-800 disabled:opacity-50",children:(0,r.jsx)(i.L,{reserve:"Saving…",children:_?"Saving…":"Save"})}),(0,r.jsx)("button",{type:"button",onClick:()=>A(null),className:"rounded border px-2 py-1 text-xs font-medium ".concat(u?"border-gray-600 text-gray-300":"border-gray-200 text-gray-600"),children:"Cancel"})]})]}):(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium ".concat(u?"text-white":"text-gray-900"),children:e.title}),(0,r.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm leading-relaxed ".concat(u?"text-gray-300":"text-gray-600"),children:e.content})]}),(0,r.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{A(e.id),I(e.title),T(e.content)},className:"rounded p-1 ".concat(u?"text-gray-500 hover:text-gray-300":"text-gray-400 hover:text-gray-600"),title:"Edit",children:(0,r.jsx)(s.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>J(e.id),className:"rounded p-1 ".concat(u?"text-gray-500 hover:text-red-400":"text-gray-400 hover:text-red-500"),title:"Delete",children:(0,r.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})]})},e.id))})]},t)})]})]})]})}},29835:(e,t,a)=>{a.d(t,{R:()=>r});let r=["Will Richman","Haris Raheel","Serif Sav","Furqan Zaheer","Aayush Maharaj","Andy Guo","Shaurya Vardhan Shastri","Jintai Li","Mishal Poldas","Arianna Di Tommasso","Awais Aether","Nathan Law","Ben Hoppe","Daksh Mathur","Bryan Wong"]},65534:(e,t,a)=>{a.r(t),a.d(t,{LeadsTableModal:()=>tm,SAVED_FILTERS_KEY:()=>ex.of,excludeRoleEmailsForSavedView:()=>ex.JV,isQualificationFilter:()=>ex.U1,loadSavedFilters:()=>ex.L6});var r=a(95155),n=a(12115),l=a(15239),s=a(47650),o=a(18720),i=a(92302),c=a(85514),d=a(96059),u=a(78207),m=a(10874),g=a(45748),x=a(57218),h=a(38688),p=a(43569),y=a(88495),b=a(42610),f=a(68704),v=a(17918),w=a(41715),j=a(88453),N=a(34065),k=a(65361),C=a(83053),_=a(88592),S=a(49537),E=a(70861),A=a(66716),L=a(98498),I=a(52528),F=a(71078),T=a(9554),D=a(76414),O=a(36337),P=a(36834),M=a(56200),R=a(82158),U=a(54289),z=a(1919),q=a(59893),J=a(76799);let B=e=>!!e&&(!0===e.virtual||e.id.startsWith("virtual:"));function H(e){if(!e)return"—";let t=new Date(e);
1return isNaN(t.getTime())?"—":t.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function G(e){if(!e)return"—";let t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function K(e){if(!e)return"";let t=new Date(e);return isNaN(t.getTime())?"":"".concat(t.getFullYear(),"-").concat(String(t.getMonth()+1).padStart(2,"0"),"-").concat(String(t.getDate()).padStart(2,"0"))}let V=["","new","contacted","qualified"];function Q(e){var t,a;let{lead:l,onClose:s,onUpdateLead:i,isDark:c}=e,d=!i,[u,x]=(0,n.useState)(!1),[h,b]=(0,n.useState)(null),[f,v]=(0,n.useState)(null),[w,j]=(0,n.useState)(null),[N,C]=(0,n.useState)(null),[_,S]=(0,n.useState)(null),[E,A]=(0,n.useState)(null),L=(0,n.useRef)(null),[I,F]=(0,n.useState)(null),[T,D]=(0,n.useState)(!1),O=[l.first_name,l.last_name].filter(Boolean).join(" ")||l.email||"Lead",M=(0,n.useMemo)(()=>{var e,t;let a=null!=(e=l.next_meeting_at)?e:null;return a&&new Date(a).getTime()>Date.now()?{label:"Next meeting",iso:a,upcoming:!0}:{label:"Last meeting",iso:null!=(t=l.last_meeting_at)?t:null,upcoming:!1}},[l.next_meeting_at,l.last_meeting_at]);(0,n.useEffect)(()=>{x(!0)},[]),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&s()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]);let R=(0,n.useCallback)(async()=>{try{var e;let t=await fetch("/api/scorecard/leads/".concat(l.id,"/transcripts")),a=null!=(e=(await t.json().catch(()=>({}))).transcripts)?e:[];b(a),j(e=>{var t,r;return null!=(r=null!=e?e:null==(t=a[0])?void 0:t.id)?r:null})}catch(e){b([])}},[l.id]),U=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/scorecard/leads/".concat(l.id,"/attio-summary")),t=await e.json().catch(()=>({}));v(t)}catch(e){v({recordLinked:!1,connected:null,summary:null})}},[l.id]),J=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/scorecard/integrations-status"),t=await e.json().catch(()=>({}));F({googleCalendar:!!t.googleCalendar,calendly:!!t.calendly,attio:!!t.attio})}catch(e){F({googleCalendar:!1,calendly:!1,attio:!1})}},[]);(0,n.useEffect)(()=>{R(),U(),J()},[R,U,J]);let K=(0,n.useCallback)(async()=>{D(!0),L.current=null;try{await Promise.all([R(),U(),J()])}finally{D(!1)}},[R,U,J]);(0,n.useEffect)(()=>{var e,t;if(d||null===h||null===f||L.current===l.id)return;L.current=l.id;let a=null!=(t=null==(e=f.summary)?void 0:e.text)?t:null,r=!!a||!!l.meeting_summary;(h.some(e=>B(e)&&e.id.startsWith("virtual:last")&&(!!e.summary||r))||h.some(e=>!B(e)&&(e.summary||e.hasTranscript)&&0===e.action_items.length)||0===h.length&&r)&&(async()=>{try{var e;let t=await fetch("/api/scorecard/leads/".concat(l.id,"/transcripts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reconcile",attioSummary:null!=(e=null!=a?a:l.meeting_summary)?e:void 0})});if(!t.ok)return;let r=await t.json().catch(()=>({}));r.transcripts&&(b(r.transcripts),j(e=>{var t,a;return e&&r.transcripts.some(t=>t.id===e)?e:null!=(a=null==(t=r.transcripts[0])?void 0:t.id)?a:null}))}catch(e){}})()},[d,h,f,l.id,l.meeting_summary]);let V=null!=(t=null==h?void 0:h.find(e=>e.id===w))?t:null,Q=(e,t)=>b(a=>a?a.map(a=>a.id===e?{...a,...t}:a):a),$=async e=>{if(!(d||B(e))){C(e.id);try{var t,a,r,n,s,c;let d=await fetch("/api/scorecard/leads/".concat(l.id,"/transcripts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({transcriptId:e.id,action:"resummarize"})}),u=await d.json().catch(()=>({}));if(!d.ok||u.error)throw Error(u.error||"Couldn't generate action items");Q(e.id,{summary:null!=(n=u.summary)?n:e.summary,action_items:null!=(s=u.actionItems)?s:e.action_items,attio_synced_at:(null==(t=u.attio)?void 0:t.synced)?new Date().toISOString():e.attio_synced_at}),i&&u.summary&&i(l.id,{meeting_summary:u.summary,...(null==(c=u.lead)?void 0:c.last_meeting_at)?{last_meeting_at:u.lead.last_meeting_at}:{}}).catch(()=>{}),(null==(a=u.attio)?void 0:a.synced)?o.o.success("Action items generated and synced to Attio"):o.o.success("Action items generated".concat((null==(r=u.attio)?void 0:r.error)?" — Attio: ".concat(u.attio.error):""))}catch(e){o.o.error(e instanceof Error?e.message:"Failed to generate action items")}finally{C(null)}}},Z=async e=>{if(!(d||B(e))){S(e.id);try{var t,a;
1let r=await fetch("/api/scorecard/leads/".concat(l.id,"/transcripts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({transcriptId:e.id,action:"sync-attio"})}),n=await r.json().catch(()=>({}));if(!r.ok||n.error)throw Error(n.error||"Sync failed");(null==(t=n.attio)?void 0:t.synced)?(Q(e.id,{attio_synced_at:new Date().toISOString()}),o.o.success("Synced to Attio")):o.o.error((null==(a=n.attio)?void 0:a.error)||"Couldn't sync to Attio")}catch(e){o.o.error(e instanceof Error?e.message:"Sync failed")}finally{S(null)}}},X=async(e,t)=>{if(d||B(e))return;let a=!t.done;Q(e.id,{action_items:e.action_items.map(e=>e.id===t.id?{...e,done:a}:e)}),A(t.id);try{let r=await fetch("/api/scorecard/leads/".concat(l.id,"/transcripts"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({transcriptId:e.id,itemId:t.id,done:a})}),n=await r.json().catch(()=>({}));if(!r.ok||n.error)throw Error(n.error||"Couldn't save");n.actionItems&&Q(e.id,{action_items:n.actionItems})}catch(a){Q(e.id,{action_items:e.action_items.map(e=>e.id===t.id?{...e,done:t.done}:e)}),o.o.error(a instanceof Error?a.message:"Couldn't save")}finally{A(null)}},ee=c?"bg-gray-900 border-gray-800":"bg-[#FAFAF9] border-gray-200",et=c?"bg-gray-800/60 border-gray-700":"bg-white border-gray-200",ea=c?"text-gray-400":"text-gray-500",er=c?"text-gray-100":"text-gray-900",en="text-[11px] font-semibold uppercase tracking-wide ".concat(c?"text-gray-400":"text-gray-500");return(0,r.jsxs)("div",{className:"fixed inset-0 z-[75]",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/40 transition-opacity duration-300 ".concat(u?"opacity-100":"opacity-0"),onClick:s}),(0,r.jsxs)("div",{className:"absolute inset-y-0 right-0 w-full max-w-xl border-l shadow-2xl flex flex-col transform transition-transform duration-300 ".concat(ee," ").concat(u?"translate-x-0":"translate-x-full"),role:"dialog","aria-label":"Meeting details",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3 px-5 py-4 border-b shrink-0 ".concat(c?"border-gray-800":"border-gray-200"),children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-base font-semibold truncate ".concat(er),children:O}),(0,r.jsxs)("div",{className:"mt-0.5 flex items-center gap-2 text-[12px] ".concat(ea),children:[l.company&&(0,r.jsx)("span",{className:"truncate",children:l.company}),l.company&&(0,r.jsx)("span",{children:"\xb7"}),(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(y.A,{className:"h-3.5 w-3.5 ".concat(M.upcoming?"text-emerald-500":"text-blue-500")}),M.label,": ",H(M.iso)]})]})]}),(0,r.jsx)("button",{type:"button",onClick:s,className:"p-1.5 rounded-lg transition-colors ".concat(c?"text-gray-400 hover:bg-gray-800 hover:text-gray-200":"text-gray-400 hover:bg-gray-200 hover:text-gray-700"),children:(0,r.jsx)(p.A,{className:"w-5 h-5"})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{className:"".concat(en," mr-1"),children:"Connected"}),[{key:"googleCalendar",label:"Google Calendar"},{key:"calendly",label:"Calendly"},{key:"attio",label:"Attio"}].map(e=>{let{key:t,label:a}=e,n=null==I?void 0:I[t],l=null===I;return(0,r.jsxs)("span",{title:l?"Checking connection…":n?"".concat(a," is connected"):"".concat(a," isn't connected — use the sync buttons in the leads Tools menu or Settings → Apps"),className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium ".concat(n?c?"border-emerald-800 bg-emerald-900/30 text-emerald-300":"border-emerald-200 bg-emerald-50 text-emerald-700":c?"border-gray-700 text-gray-500":"border-gray-200 text-gray-400"),children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full ".concat(l?"bg-gray-400":n?"bg-emerald-500":"bg-gray-300")}),a]},t)})]}),(0,r.jsxs)("section",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("span",{className:en,children:["Meeting summary ",(null==f?void 0:f.recordLinked)?"\xb7 from Attio":""]}),(0,r.jsxs)("button",{type:"button",onClick:K,disabled:T,className:"text-[11px] inline-flex items-center gap-1 ".concat(ea," hover:underline disabled:opacity-60 disabled:cursor-wait"),title:"Reload meetings, the summary, and integration status for this lead",children:[(0,r.jsx)(m.A,{className:"w-3 h-3 ".concat(T?"animate-spin":"")}),T?"Refreshing…":"Refresh"]})]}),(0,r.jsx)("div",{className:"rounded-xl border px-4 py-3 text-[12px] ".concat(et),children:(0,r.jsx)(W,{attio:f,fallback:null!=(a=l.meeting_summary)?a:null,isDark:c,muted:ea})})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,r.jsxs)("span",{className:en,children:["AI action items ",V?"\xb7 ".concat(G(V.meeting_at)):""]})}),V?(0,r.jsxs)("div",{className:"rounded-xl border px-4 py-3 ".concat(et),children:[V.action_items.length>0?(0,r.jsx)("ul",{className:"space-y-1.5",children:V.action_items.map(e=>(0,r.jsxs)("li",{className:"flex items-start gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:d||E===e.id,onClick:()=>
1X(V,e),className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-colors disabled:cursor-not-allowed ".concat(e.done?"bg-emerald-500 border-emerald-500 text-white":c?"border-gray-600 hover:border-gray-400":"border-gray-300 hover:border-gray-500"),"aria-label":e.done?"Mark not done":"Mark done",children:e.done&&(0,r.jsx)(g.A,{className:"h-3 w-3"})}),(0,r.jsx)("span",{className:"text-[12px] ".concat(e.done?"line-through ".concat(ea):c?"text-gray-200":"text-gray-800"),children:e.text})]},e.id))}):(0,r.jsxs)("p",{className:"text-[12px] ".concat(ea),children:["No action items yet."," ",V.hasTranscript?"Generate them from the transcript.":"Generate them from the summary, or add a transcript via a notetaker."]}),!d&&(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>$(V),disabled:N===V.id,className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 cursor-pointer ".concat(c?"bg-blue-600 text-white hover:bg-blue-500":"bg-gray-900 text-white hover:bg-gray-800"),children:[N===V.id?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,r.jsx)(k.A,{className:"w-3.5 h-3.5"}),V.action_items.length>0?"Refresh action items":"Generate action items"]}),(0,r.jsxs)("button",{type:"button",onClick:()=>Z(V),disabled:_===V.id,className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-[11px] font-medium border transition-colors disabled:opacity-50 cursor-pointer ".concat(c?"border-gray-600 text-gray-200 hover:bg-gray-700":"border-gray-300 text-gray-700 hover:bg-gray-100"),title:"Write the summary + action items into the Attio contact as a note",children:[_===V.id?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,r.jsx)(q.A,{className:"w-3.5 h-3.5"}),"Sync to Attio"]}),V.attio_synced_at&&(0,r.jsxs)("span",{className:"text-[10px] ".concat(ea),children:["Synced ",G(V.attio_synced_at)]})]})]}):(0,r.jsx)("div",{className:"rounded-xl border px-4 py-3 text-[12px] ".concat(et," ").concat(ea),children:"No meetings 
1yet for this lead. Run a Calendly or Google Calendar sync, or connect a notetaker, to populate meetings."})]}),(0,r.jsxs)("section",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:en,children:"Meeting history"}),h&&(0,r.jsx)("span",{className:"text-[11px] ".concat(ea),children:h.length})]}),null===h?(0,r.jsx)("div",{className:"rounded-xl border px-4 py-6 text-center text-[12px] ".concat(et," ").concat(ea),children:"Loading…"}):0===h.length?(0,r.jsx)("div",{className:"rounded-xl border px-4 py-6 text-center text-[12px] ".concat(et," ").concat(ea),children:"No past meetings recorded yet."}):(0,r.jsx)("ul",{className:"space-y-2",children:h.map(e=>{let t=e.id===w,a=e.action_items.filter(e=>e.done).length;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>j(e.id),className:"w-full text-left rounded-xl border px-4 py-3 transition-colors ".concat(t?c?"border-blue-500/60 bg-gray-800":"border-blue-300 bg-blue-50/40":et+(c?" hover:bg-gray-800":" hover:bg-gray-50")),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-2 text-[12px] font-medium ".concat(er),children:[(0,r.jsx)(P.A,{className:"w-3.5 h-3.5 opacity-60"}),H(e.meeting_at)]}),(e=>{let t=(null!=e?e:"").toLowerCase(),a="calendly"===t?"Calendly":"google_calendar"===t?"Google Cal":"manual"===t?"Meeting":["webhook","fireflies","fathom","tldv","otter","zapier"].includes(t)?"Notetaker":e;return(0,r.jsx)("span",{className:"inline-block rounded px-1.5 py-px text-[9px] font-semibold uppercase tracking-wide ".concat(c?"bg-gray-700 text-gray-300":"bg-gray-100 text-gray-600"),children:a})})(e.source)]}),e.meeting_title&&(0,r.jsx)("p",{className:"mt-1 text-[12px] ".concat(c?"text-gray-300":"text-gray-700"),children:e.meeting_title}),(0,r.jsxs)("div",{className:"mt-1 flex items-center gap-3 text-[10px] ".concat(ea),children:[e.action_items.length>0&&(0,r.jsxs)("span",{children:[a,"/",e.action_items.length," action items"]}),e.summary?(0,r.jsx)("span",{children:"Summarized"}):(0,r.jsx)("span",{children:"No summary"}),e.attio_synced_at&&(0,r.jsx)("span",{children:"\xb7 In Attio"})]})]})},e.id)})})]}),(null==V?void 0:V.summary)&&(0,r.jsxs)("section",{children:[(0,r.jsx)("span",{className:en,children:"This meeting's notes"}),(0,r.jsx)("div",{className:"mt-2 rounded-xl border px-4 py-3 text-[12px] ".concat(et),children:(0,r.jsx)(z.MarkdownContent,{content:V.summary,theme:c?"dark":"light"})})]}),!d&&(0,r.jsx)(Y,{lead:l,onUpdateLead:i,isDark:c,cardBg:et,muted:ea,sectionLabel:en})]})]})]})}function W(e){var t;let{attio:a,fallback:n,isDark:l,muted:s}=e;return null===a?(0,r.jsx)("p",{className:"text-[12px] ".concat(s),children:"Loading…"}):(null==(t=a.summary)?void 0:t.text)?(0,r.jsxs)("div",{children:[a.summary.title&&(0,r.jsx)("p",{className:"mb-1 text-[12px] font-medium ".concat(l?"text-gray-200":"text-gray-800"),children:a.summary.title}),(0,r.jsx)(z.MarkdownContent,{content:a.summary.text,theme:l?"dark":"light"}),a.summary.createdAt&&(0,r.jsxs)("p",{className:"mt-2 text-[10px] ".concat(s),children:["From Attio \xb7 ",G(a.summary.createdAt)]})]}):n?(0,r.jsxs)("div",{children:[(0,r.jsx)(z.MarkdownContent,{content:n,theme:l?"dark":"light"}),(0,r.jsx)("p",{className:"mt-2 text-[10px] ".concat(s),children:a.recordLinked?"No Attio note yet — showing our summary.":"Not linked to Attio — showing our summary."})]}):a.recordLinked?!1===a.connected?(0,r.jsx)("p",{className:"text-[12px] ".concat(s),children:"Attio isn't connected."}):a.error?(0,r.jsx)("p",{className:"text-[12px] ".concat(s),children:a.error}):(0,r.jsx)("p",{className:"text-[12px] ".concat(s),children:"No summary in Attio for this contact yet."}):(0,r.jsx)("p",{className:"text-[12px] ".concat(s),children:"This lead isn't linked to an Attio record yet."})}function Y(e){var t,a;let{lead:l,onUpdateLead:s,isDark:i,cardBg:c,muted:u,sectionLabel:g}=e,[x,h]=(0,n.useState)(!1),[p,y]=(0,n.useState)(null!=(t=l.meeting_notes)?t:""),[b,f]=(0,n.useState)(K(l.last_meeting_at)),[v,w]=(0,n.use
1State)(!1),[j,N]=(0,n.useState)(!1),C=p!==(null!=(a=l.meeting_notes)?a:"")||b!==K(l.last_meeting_at),_="w-full text-[12px] border rounded-md px-3 py-2 focus:ring-1 focus:outline-none ".concat(i?"border-gray-600 bg-gray-800 text-gray-200 placeholder:text-gray-500 focus:ring-gray-600":"border-gray-300 bg-white text-gray-900 focus:ring-gray-900"),S=async()=>{w(!0);try{var e;let t=function(e){if(!e)return null;let t=new Date("".concat(e,"T12:00:00"));return isNaN(t.getTime())?null:t.toISOString()}(b),a={meeting_notes:p.trim()?p:null,last_meeting_at:t};t&&V.includes((null!=(e=l.stage)?e:"").toLowerCase())&&(a.stage="demo"),await s(l.id,a),o.o.success("Saved")}catch(e){o.o.error("Couldn't save")}finally{w(!1)}},E=async()=>{try{let e=await navigator.clipboard.readText();e&&y(t=>t.trim()?"".concat(t,"\n\n").concat(e):e)}catch(e){o.o.error("Couldn't read clipboard — paste with Ctrl/Cmd+V")}},A=async()=>{if(!p.trim())return void o.o.error("Add notes first");N(!0);try{C&&await s(l.id,{meeting_notes:p});let e=await fetch("/api/scorecard/leads/".concat(l.id,"/meeting-summary"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notes:p})}),t=await e.json().catch(()=>({}));if(!e.ok||!t.summary)throw Error(t.error||"Failed to generate summary");await s(l.id,{meeting_summary:t.summary}),o.o.success("Summary generated")}catch(e){o.o.error(e instanceof Error?e.message:"Failed to generate summary")}finally{N(!1)}};return(0,r.jsxs)("section",{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>h(e=>!e),className:"flex items-center gap-1 ".concat(g," cursor-pointer"),children:[(0,r.jsx)(d.A,{className:"w-3.5 h-3.5 transition-transform ".concat(x?"":"-rotate-90")}),"Add notes / paste a transcript"]}),x&&(0,r.jsxs)("div",{className:"mt-2 rounded-xl border px-4 py-3 space-y-2 ".concat(c),children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[11px] mb-1 ".concat(u),children:"Meeting date"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"date",value:b,onChange:e=>f(e.target.value),className:"".concat(_," max-w-[200px]")}),b&&(0,r.jsx)("button",{type:"button",onClick:()=>f(""),className:"text-[11px] ".concat(u," hover:underline"),children:"Clear"})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-[11px] ".concat(u),children:"Pasted notes generate a quick summary for this lead."}),(0,r.jsxs)("button",{type:"button",onClick:E,className:"inline-flex items-center gap-1 text-[11px] ".concat(u," hover:underline"),children:[(0,r.jsx)(J.A,{className:"w-3.5 h-3.5"})," Paste"]})]}),(0,r.jsx)("textarea",{value:p,onChange:e=>y(e.target.value),rows:6,placeholder:"Paste or type meeting notes…",className:"".concat(_," resize-y min-h-[110px]")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:S,disabled:v||!C,className:"rounded-lg px-3 py-1.5 text-[12px] font-medium transition-colors disabled:opacity-50 ".concat(i?"text-gray-300 hover:bg-gray-700":"text-gray-600 hover:bg-gray-100"),children:v?"Saving…":"Save"}),(0,r.jsxs)("button",{type:"button",onClick:A,disabled:j||!p.trim(),className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[12px] font-medium transition-colors disabled:opacity-50 cursor-pointer ".concat(i?"bg-blue-600 text-white hover:bg-blue-500":"bg-gray-900 text-white hover:bg-gray-800"),children:[j?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,r.jsx)(k.A,{className:"w-3.5 h-3.5"}),"Generate summary"]})]})]})]})}var $=a(17787),Z=a(49027),X=a(27587),ee=a(83528),et=a(52325);function ea(e){let{width:t,height:a,radius:l=10,phase:s,durationMs:o,onSonarComplete:i}=e,c=(0,n.useMemo)(()=>(function(e,t,a,r){let n=Math.max(e-5,0),l=Math.max(t-a,0),s=Math.min(r,n/2,l/2),o=2.5+n/2;return["M ".concat(o," ").concat(2.5),"L ".concat(2.5+n-s," ").concat(2.5),"A ".concat(s," ").concat(s," 0 0 1 ").concat(2.5+n," ").concat(2.5+s),"L ".concat(2.5+n," ").concat(2.5+l-s),"A ".concat(s," ").concat(s," 0 0 1 ").concat(2.5+n-s," ").concat(2.5+l),"L ".concat(2.5+s," ").concat(2.5+l),"A ".concat(s," ").concat(s," 0 0 1 ").concat(2.5," ").concat(2.5+l-s),"L ".concat(2.5," ").concat(2.5+s),"A ".concat(s," ").concat(s," 0 0 1 ").concat(2.5+s," ").concat(2.5),"L ".concat(o," ").concat(2.5)].join(" ")})(t,a,5,l),[t,a,5,l]);(0,n.useEffect)(()=>
1{if("sonar"!==s)return;let e=window.setTimeout(()=>null==i?void 0:i(),1500);return()=>window.clearTimeout(e)},[s,i]);let d="sonar"===s;return(0,r.jsxs)("div",{className:"lead-enrich-row-ring-inner",style:{width:t,height:a},children:[(0,r.jsxs)("svg",{className:"lead-enrich-row-ring-svg".concat("sonar"===s?" lead-enrich-row-ring-svg-fading":""),width:t,height:a,viewBox:"0 0 ".concat(t," ").concat(a),"aria-hidden":!0,children:[(0,r.jsx)("path",{d:c,className:"lead-enrich-row-ring-track",pathLength:100}),(0,r.jsx)("path",{d:c,className:"lead-enrich-row-ring-progress".concat(d?" lead-enrich-row-ring-progress-complete":""),pathLength:100,style:{"--enrich-duration":"".concat(Math.max(o,300),"ms")}})]}),"sonar"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"lead-enrich-row-sonar",style:{borderRadius:l}}),(0,r.jsx)("div",{className:"lead-enrich-row-sonar lead-enrich-row-sonar-delayed",style:{borderRadius:l}})]})]})}var er=a(58568),en=a(65057),el=a(59186),es=a(71587),eo=a(29835),ei=a(31566),ec=a(27809),ed=a(41450),eu=a(42205),em=a(9521),eg=a(52790),ex=a(81416),eh=a(73604),ep=a(75065),ey=a(39118),eb=a(26019),ef=a(89731);function ev(e){let{isDark:t}
1=e,[a,l]=(0,n.useState)([]),[s,i]=(0,n.useState)(!0),[c,d]=(0,n.useState)(""),[u,m]=(0,n.useState)(!1),[g,h]=(0,n.useState)(""),[p,y]=(0,n.useState)(""),[b,f]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1),[j,N]=(0,n.useState)(null),[k,C]=(0,n.useState)(""),[_,S]=(0,n.useState)(""),E=(0,n.useCallback)(async()=>{try{let t=await fetch("/api/inbox/templates");if(t.ok){var e;let a=await t.json();l(null!=(e=a.templates)?e:[])}}catch(e){}finally{i(!1)}},[]);(0,n.useEffect)(()=>{E()},[E]);let A=a.filter(e=>!c||e.name.toLowerCase().includes(c.toLowerCase())||e.body.toLowerCase().includes(c.toLowerCase())),L=A.filter(e=>e.is_quick_reply),I=A.filter(e=>!e.is_quick_reply),F=async()=>{if(!g.trim()||!p.trim())return void o.o.error("Name and content are required");w(!0);try{let e=await fetch("/api/inbox/templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g.trim(),body:p.trim(),is_quick_reply:b})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to create");o.o.success("Template created"),m(!1),h(""),y(""),f(!1),E()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to create")}finally{w(!1)}},T=async e=>{if(k.trim()&&_.trim()){w(!0);try{if(!(await fetch("/api/inbox/templates/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:k.trim(),body:_.trim()})})).ok)throw Error("Failed to update");o.o.success("Template updated"),N(null),E()}catch(e){o.o.error("Failed to update")}finally{w(!1)}}},O=async(e,t)=>{try{if(!(await fetch("/api/inbox/templates/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_quick_reply:!t})})).ok)throw Error("Failed");o.o.success(t?"Removed from quick replies":"Added to quick replies"),E()}catch(e){o.o.error("Failed to update")}};if(s)return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-sm ".concat(t?"text-gray-400":"text-gray-500"),children:"Loading templates…"});let P=e=>{let a=j===e.id;return(0,r.jsx)("div",{className:"rounded-lg border p-2.5 transition-colors ".concat(t?"border-gray-700 hover:bg-gray-700/50":"border-gray-200 hover:bg-gray-50"),children:a?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("input",{type:"text",value:k,onChange:e=>C(e.target.value),className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(t?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsx)("textarea",{value:_,onChange:e=>S(e.target.value),rows:3,className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(t?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>T(e.id),disabled:v,className:"inline-flex items-center justify-center rounded px-2 py-1 text-xs font-medium text-white bg-gray-900 hover:bg-gray-800 disabled:opacity-50",children:(0,r.jsx)(et.L,{reserve:"Saving…",children:v?"Saving…":"Save"})}),(0,r.jsx)("button",{type:"button",onClick:()=>N(null),className:"rounded border px-2 py-1 text-xs font-medium ".concat(t?"border-gray-600 text-gray-300":"border-gray-200 text-gray-600"),children:"Cancel"})]})]}):(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium ".concat(t?"text-white":"text-gray-900"),children:e.name}),(0,r.jsx)("p",{className:"mt-0.5 text-xs line-clamp-2 ".concat(t?"text-gray-400":"text-gray-500"),children:e.body})]}),(0,r.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>O(e.id,e.is_quick_reply),className:"rounded p-1 ".concat(e.is_quick_reply?t?"text-amber-400 hover:text-amber-300":"text-amber-500 hover:text-amber-600":t?"text-gray-500 hover:text-gray-300":"text-gray-400 hover:text-gray-600"),title:e.is_quick_reply?"Remove from quick replies":"Add to quick replies",children:(0,r.jsx)(D.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>
1{N(e.id),C(e.name),S(e.body)},className:"rounded p-1 ".concat(t?"text-gray-500 hover:text-gray-300":"text-gray-400 hover:text-gray-600"),title:"Edit",children:(0,r.jsx)(ef.A,{className:"h-3.5 w-3.5"})})]})]})},e.id)};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold ".concat(t?"text-gray-100":"text-gray-900"),children:"Templates"}),(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full ".concat(t?"text-gray-100 bg-gray-700":"text-white bg-gray-900"),children:a.length}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("input",{type:"search",value:c,onChange:e=>d(e.target.value),placeholder:"Search…",className:"w-48 rounded-lg border px-3 py-1.5 text-[11px] focus:outline-none focus:ring-1 ".concat(t?"border-gray-600 bg-gray-700 text-white placeholder:text-gray-400 focus:ring-gray-500":"border-gray-200 bg-white focus:ring-gray-300")}),(0,r.jsxs)("button",{type:"button",onClick:()=>m(!0),className:"inline-flex items-center gap-1 px-2.5 py-1.5 text-[11px] font-medium rounded-lg transition-colors ".concat(t?"bg-gray-600 text-white hover:bg-gray-500":"bg-gray-900 text-white hover:bg-gray-800"),children:[(0,r.jsx)(x.A,{className:"h-3.5 w-3.5"}),"Add"]})]}),u&&(0,r.jsxs)("div",{className:"rounded-lg border p-3 space-y-2 ".concat(t?"border-gray-700 bg-gray-700/50":"border-gray-200 bg-gray-50"),children:[(0,r.jsx)("input",{type:"text",value:g,onChange:e=>h(e.target.value),placeholder:"Template name",className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(t?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsx)("textarea",{value:p,onChange:e=>y(e.target.value),placeholder:"Template content",rows:3,className:"w-full rounded-lg border px-3 py-1.5 text-sm focus:outline-none focus:ring-1 ".concat(t?"border-gray-600 bg-gray-700 text-white focus:ring-gray-500":"border-gray-200 focus:ring-gray-300")}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs ".concat(t?"text-gray-300":"text-gray-600"),children:[(0,r.jsx)("input",{type:"checkbox",checked:b,onChange:e=>f(e.target.checked)}),"Add to quick replies"]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:F,disabled:v||!g.trim()||!p.trim(),className:"inline-flex items-center justify-center rounded-lg bg-gray-900 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-gray-800 disabled:opacity-50",children:(0,r.jsx)(et.L,{reserve:"Creating…",children:v?"Creating…":"Create"})}),(0,r.jsx)("button",{type:"button",onClick:()=>{m(!1),h(""),y("")},className:"rounded-lg border px-3 py-1.5 text-[11px] font-medium ".concat(t?"border-gray-600 text-gray-300":"border-gray-200 text-gray-600"),children:"Cancel"})]})]}),L.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wider ".concat(t?"text-gray-500":"text-gray-400"),children:"Quick Replies"}),(0,r.jsx)("div",{className:"space-y-1.5",children:L.map(P)})]}),I.length>0&&(0,r.jsxs)("div",{children:[L.length>0&&(0,r.jsx)("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wider ".concat(t?"text-gray-500":"text-gray-400"),children:"Templates"}),(0,r.jsx)("div",{className:"space-y-1.5",children:I.map(P)})]}),0===A.length&&!u&&(0,r.jsx)("p",{className:"py-8 text-center text-sm ".concat(t?"text-gray-400":"text-gray-500"),children:c?"No templates match your search.":"No templates yet. Create one above."})]})}function ew(e){let{isDark:t,onApply:a}=e,[l,s]=(0,n.useState)([]),[i,c]=(0,n.useState)(!0),d=(0,n.useCallback)(async()=>{try{let t=await fetch("/api/scorecard/saved-filters");if(t.ok){var e;let a=await t.json();s(null!=(e=a.filters)?e:[])}}catch(e){}finally{c(!1)}},[]);(0,n.useEffect)(()=>{d()},[d]);let[u,m]=(0,n.useState)(!1),g=async e=>{try{if(!(await fetch("/api/scorecard/saved-filters?id=".concat(e),{method:"DELETE"})).ok)throw Error("Failed");o.o.success("Filter deleted"),d()}catch(e){o.o.error("Failed to delete")}},x=async()=>
1{if(!confirm("Delete all ".concat(l.length," saved filters? This cannot be undone.")))return;m(!0);let e=0;for(let t of l)try{(await fetch("/api/scorecard/saved-filters?id=".concat(t.id),{method:"DELETE"})).ok&&e++}catch(e){console.warn("[SavedFiltersTab] Bulk delete failed for filter ".concat(t.id,":"),e)}o.o.success("Deleted ".concat(e," filters")),m(!1),d()};return i?(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-sm ".concat(t?"text-gray-400":"text-gray-500"),children:"Loading saved filters…"}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold ".concat(t?"text-gray-100":"text-gray-900"),children:"Saved Filters"}),(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full ".concat(t?"text-gray-100 bg-gray-700":"text-white bg-gray-900"),children:l.length}),l.length>1&&(0,r.jsx)("button",{type:"button",onClick:x,disabled:u,className:"ml-auto text-xs font-medium px-2.5 py-1 rounded-md transition-colors ".concat(t?"text-red-400 hover:bg-red-900/30 disabled:opacity-50":"text-red-600 hover:bg-red-50 disabled:opacity-50"),children:u?"Deleting...":"Delete All"})]}),0===l.length?(0,r.jsx)("p",{className:"py-8 text-center text-sm ".concat(t?"text-gray-400":"text-gray-500"),children:"No saved filters yet. Save a filter from the Leads tab to see it here."}):(0,r.jsx)("div",{className:"space-y-1.5",children:l.map(e=>(0,r.jsx)("div",{className:"rounded-lg border p-3 transition-colors ".concat(t?"border-gray-700 hover:bg-gray-700/50":"border-gray-200 hover:bg-gray-50"),children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium ".concat(t?"text-white":"text-gray-900"),children:e.label}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:(function(e){let t=[];return e.source&&t.push("Source: ".concat(e.source)),e.stage&&t.push("Stage: ".concat(e.stage)),e.location&&t.push("Location: ".concat(e.location)),e.employee_range&&t.push("Size: ".concat(e.employee_range)),e.industry&&t.push("Industry: ".concat(e.industry)),e.search&&t.push('Search: "'.concat(e.search,'"')),e.no_contact?t.push("Never contacted"):e.no_contact_days&&t.push("Not contacted in ".concat(e.no_contact_days," days")),0===t.length&&t.push("All leads"),t})(e.filters).map((e,a)=>(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full ".concat(t?"bg-gray-700 text-gray-300":"bg-gray-100 text-gray-600"),children:e},a))})]}),(0,r.jsxs)("div",{className:"flex shrink-0 gap-1.5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>a(e.filters),className:"rounded px-2 py-1 text-xs font-medium ".concat(t?"text-indigo-400 hover:bg-indigo-900/50":"text-indigo-600 hover:bg-indigo-50"),children:"Apply"}),(0,r.jsx)("button",{type:"button",onClick:()=>g(e.id),className:"rounded p-1 ".concat(t?"text-gray-500 hover:text-red-400":"text-gray-400 hover:text-red-500"),title:"Delete",children:(0,r.jsx)(T.A,{className:"h-3.5 w-3.5"})})]})]})},e.id))})]})}var ej=a(4625);function eN(e){let{children:t,isDark:a}=e;return(0,r.jsxs)("span",{className:"relative inline-flex shrink-0 group/actiontip",children:[(0,r.jsx)(i.A,{className:"w-3.5 h-3.5 cursor-help ".concat(a?"text-gray-500":"text-gray-400"),"aria-hidden":!0}),(0,r.jsx)("span",{className:"pointer-events-none invisible opacity-0 group-hover/actiontip:visible group-hover/actiontip:opacity-100 transition-opacity delay-75 absolute left-1/2 -translate-x-1/2 top-full mt-1.5 z-[100] w-[min(17.5rem,calc(100vw-2rem))] rounded-xl border px-3 py-2.5 text-[10px] leading-snug shadow-xl ring-1 [word-break:break-word] whitespace-normal ".concat(a?"bg-gray-900 border-white/10 ring-black/40 text-gray-200":"bg-white border-gray-100 ring-black/[0.04] text-gray-700"),children:t})]})}function ek(e){let{column:t,label:a,currentSort:n,currentDirection:l,onSort:s,isDark:o,className:i="",center:u=!1}=e,m=n===t;return(0,r.jsx)("th",{className:"".concat(u?"text-center":"text-left"," py-2.5 px-3 text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap cursor-pointer select-none transition-colors ").concat(o?"".concat(m?"text-gray-200 bg-white/[0.06]":"text-gray-500"," hover:text-gray-200 hover:bg-white/[0.04]"):"".concat(m?"text-gray-800 bg-gray-900/[0.05]":"text-gray-500"," hover:text-gray-800 hover:bg-gray-900/[0.03]")," ").concat(i),onClick:()=>s(t),children:(0,r.jsxs)("div",{className:"flex items-center gap-1 ".concat(u?"justify-center":""),children:[(0,r.jsx)("span",{children:a}),(0,r.jsx)("span",{className:"transition-opacity ".concat(m?"opacity-100":"opacity-0 group-hover:opacity-50"),children:m&&"asc"===l?(0,r.jsx)(c.A,{className:"w-3.5 h-3.5"}):m&&"desc"===l?(0,r.jsx)(d.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(c.A,{className:"w-3.5 h-3.5 opacity-30"})})]})})}let eC=["name","company","stage","source","contact_owner","tags","lead_score","deal_size","created_at","last_meeting"],e_="leads-column-order",eS={name:{label:"Name",sortKey:"name",thClass:"w-[240px] max-w-[240px]"}
1,company:{label:"Company",sortKey:"company",thClass:"w-[300px] max-w-[300px]"},stage:{label:"Stage",sortKey:"stage",thClass:"w-0 px-2"},source:{label:"Source",sortKey:"source",thClass:"w-0 px-2"},contact_owner:{label:"Contact owner",thClass:"w-0 px-2"},tags:{label:"Tags",thClass:"w-0 px-2"},lead_score:{label:"Lead Score",sortKey:"lead_score",thClass:"w-0 px-2",center:!0},deal_size:{label:"Deal Size",thClass:"w-0 px-2",center:!0},created_at:{label:"Created Date",sortKey:"created_at",thClass:"w-24"},last_meeting:{label:"Meetings",sortKey:"last_meeting",thClass:"w-0 px-2"}};function eE(e){let{id:t,editMode:a,sortColumn:n,sortDirection:l,onSort:s,isDark:o}=e,i=eS[t],{attributes:c,listeners:d,setNodeRef:m,transform:g,transition:x,isDragging:h}=(0,Z.gl)({id:t,disabled:!a}),p={transform:X.Ks.Transform.toString(g),transition:x,opacity:h?.6:1,zIndex:h?20:void 0,position:h?"relative":void 0};return a?(0,r.jsx)("th",{ref:m,style:p,...c,...d,className:"".concat(i.center?"text-center":"text-left"," py-2.5 px-3 text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap select-none cursor-grab active:cursor-grabbing rounded-lg ").concat(i.thClass," ").concat(o?"text-gray-200 bg-gray-700/60 ring-1 ring-white/10":"text-gray-700 bg-white shadow-sm ring-1 ring-black/[0.05]"),title:"Drag to reorder",children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(u.A,{className:"w-3 h-3 opacity-60 shrink-0"}),i.label]})}):i.sortKey?(0,r.jsx)(ek,{column:i.sortKey,label:i.label,currentSort:n,currentDirection:l,onSort:s,isDark:o,className:i.thClass,center:i.center}):(0,r.jsx)("th",{className:"".concat(i.center?"text-center":"text-left"," py-2.5 px-2 text-[10px] font-semibold uppercase tracking-wider whitespace-nowrap ").concat(i.thClass," ").concat("text-gray-500"),children:i.label})}let eA="enrich-all-progress",eL={active:!1,current:0,total:0,enriched:0,cacheHits:0,apiCalls:0},eI=new Set;function eF(e){if(eL={...eL,...e},eI.forEach(e=>e(eL)),eL.active&&eL.total>0){let e=Math.round(eL.current/eL.total*100);o.o.loading("Enriching leads: ".concat(eL.current,"/").concat(eL.total," domains (").concat(e,"%)"),{id:eA,duration:1/0})}}let eT="enrich-linkedin-leads-progress",eD={active:!1,current:0,total:0,enriched:0},eO=new Set;function eP(e){var t;if(eD={...eD,...e},eO.forEach(e=>e(eD)),!eD.active)return;let a=eD.batchIndex,r=null!=(t=eD.runEnriched)?t:eD.enriched;if(eD.total>0){let e=Math.round(eD.current/eD.total*100);o.o.loading("".concat(null!=a?"LinkedIn batch ".concat(a," \xb7 "):"").concat(eD.current,"/").concat(eD.total," (").concat(e,"%) \xb7 ").concat(r," enriched"),{id:eT,duration:1/0})}else null!=a&&o.o.loading("LinkedIn enrich: starting batch ".concat(a,"…"),{id:eT,duration:1/0})}let eM="enrich-linkedin-leads-clay-progress",eR={active:!1,current:0,total:0,enriched:0},eU=new Set;function ez(e){var t;if(eR={...eR,...e},eU.forEach(e=>e(eR)),!eR.active)return;let a=eR.batchIndex,r=null!=(t=eR.runEnriched)?t:eR.enriched;if(eR.total>0){let e=Math.round(eR.current/eR.total*100);o.o.loading("".concat(null!=a?"Clay batch ".concat(a," \xb7 "):"").concat(eR.current,"/").concat(eR.total," (").concat(e,"%) \xb7 ").concat(r," enriched"),{id:eM,duration:1/0})}else null!=a&&o.o.loading("Clay LinkedIn: starting batch ".concat(a,"…"),{id:eM,duration:1/0})}async function eq(e){if(eL.active)return void o.o.error("Finish domain (Attio) enrichment first");
1if(eD.active)return void o.o.error("Finish Unipile/Apollo LinkedIn enrichment first");if(eR.active)return void o.o.error("Clay LinkedIn batch already in progress");let t=new AbortController,a=0,r=0,n=0,l=0,s=0,i=!1,c=0;ez({active:!0,current:0,total:0,enriched:0,runEnriched:0,runSkipped:0,abortController:t}),o.o.loading("Starting Clay LinkedIn (all eligible batches)…",{id:eM,duration:1/0});try{for(;s<50&&n<500;){var d,u,m,g,x,h,p,y;let e;if(t.signal.aborted)throw new DOMException("Aborted","AbortError");s+=1,ez({batchIndex:s,current:0,total:0,runEnriched:a,runSkipped:r,enriched:a});let b=await fetch("/api/scorecard/enrich-linkedin-leads-clay",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({limit:20}),signal:t.signal});if(!b.ok){let e=await b.json().catch(()=>({}));throw Error(e.error||"Failed to run Clay LinkedIn batch")}let f=null==(d=b.body)?void 0:d.getReader(),v=new TextDecoder,w="",j=0,N=0,k=0,C=0;if(f)for(;;){let{done:t,value:r}=await f.read();if(t)break;let n=(w+=v.decode(r,{stream:!0})).split("\n");for(let t of(w=null!=(u=n.pop())?u:"",n))if(t.trim())try{let r=JSON.parse(t);if("start"===r.type&&null!=r.total)C=0,j=r.total,ez({total:r.total});else if("progress"===r.type)"number"==typeof r.enriched&&(C=r.enriched),ez({current:null!=(m=r.current)?m:eR.current,enriched:a+C,runEnriched:a+C,lastName:r.name}),"error"===r.status&&o.o.error("".concat(null!=(g=r.name)?g:"Contact",": ").concat(null!=(x=r.error)?x:"failed"));else if("done"===r.type)N=null!=(h=r.enriched)?h:0,k=null!=(p=r.skipped)?p:0,e=r.message;else if("error"===r.type)throw Error(null!=(y=r.error)?y:"Clay LinkedIn batch failed")}catch(e){if(e instanceof SyntaxError)continue;throw e}}if(0===j){o.o.success(null!=e?e:"No LinkedIn leads left for Clay in this queue.",{id:eM,duration:5e3}),i=!0;break}if(c=j,n+=j,a+=N,r+=k,ez({runEnriched:a,runSkipped:r,enriched:a}),0===N?l+=1:l=0,l>=2){o.o.message("Clay: stopped after 2 batches with no new enrichments (".concat(a," enriched so far). Check Unipile public URLs and Clay webhook."),{id:eM,duration:6500}),i=!0;break}if(j<20)break;if(n>=500){o.o.message("Clay: reached ".concat(500," contacts this run — run again if more remain."),{duration:6e3}),i=!0;break}}s>=50&&c>=20&&(o.o.message("Clay: stopped at ".concat(50," batches — run again to continue."),{id:eM,duration:6e3}),i=!0),n>0&&!i&&o.o.success("Clay finished: ".concat(a," enriched, ").concat(r," skipped \xb7 ").concat(s," batch(es)"),{id:eM,duration:6e3}),null==e||e()}catch(e){"AbortError"===e.name?o.o.error("Clay LinkedIn cancelled",{id:eM,duration:3e3}):o.o.error(e instanceof Error?e.message:"Clay LinkedIn batch failed",{id:eM})}finally{ez({active:!1,abortController:void 0,batchIndex:void 0,current:0,total:0,runEnriched:void 0,runSkipped:void 0})}}async function eJ(e){if(eL.active)return void o.o.error("Finish domain (Attio) enrichment first");
1if(eR.active)return void o.o.error("Finish Clay LinkedIn batch first");if(eD.active)return void o.o.error("LinkedIn enrichment already in progress");let t=new AbortController,a=0,r=0,n=0,l=0,s=!1,i=0;eP({active:!0,current:0,total:0,enriched:0,runEnriched:0,abortController:t}),o.o.loading("Starting LinkedIn enrichment (all eligible batches)…",{id:eT,duration:1/0});try{for(;l<50&&r<2e3;){var c,d,u,m,g,x,h;let e;if(t.signal.aborted)throw new DOMException("Aborted","AbortError");l+=1,eP({batchIndex:l,current:0,total:0,runEnriched:a,enriched:a});let p=await fetch("/api/scorecard/enrich-linkedin-leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({limit:40}),signal:t.signal});if(!p.ok){let e=await p.json().catch(()=>({}));throw Error(e.error||"Failed to enrich LinkedIn leads")}let y=null==(c=p.body)?void 0:c.getReader(),b=new TextDecoder,f="",v=0,w=0,j=0;if(y)for(;;){let{done:t,value:r}=await y.read();if(t)break;let n=(f+=b.decode(r,{stream:!0})).split("\n");for(let t of(f=null!=(d=n.pop())?d:"",n))if(t.trim())try{let r=JSON.parse(t);if("start"===r.type&&null!=r.total)j=0,v=r.total,eP({total:r.total});else if("progress"===r.type){"number"==typeof r.enriched&&(j=r.enriched),eP({current:null!=(u=r.current)?u:eD.current,enriched:a+j,runEnriched:a+j,lastName:r.name});let e=r.status;"error"===e&&o.o.error("".concat(null!=(m=r.name)?m:"Contact",": ").concat(null!=(g=r.error)?g:"failed"))}else if("done"===r.type)w=null!=(x=r.enriched)?x:0,e=r.message;else if("error"===r.type)throw Error(null!=(h=r.error)?h:"LinkedIn enrichment failed")}catch(e){if(e instanceof SyntaxError)continue;throw e}}if(0===v){o.o.success(null!=e?e:"No LinkedIn leads left for enrichment in this queue.",{id:eT,duration:5e3}),s=!0;break}if(i=v,r+=v,a+=w,eP({runEnriched:a,enriched:a}),0===w?n+=1:n=0,n>=2){o.o.message("LinkedIn enrich: stopped after 2 batches with no new enrichments (".concat(a," enriched so far)."),{id:eT,duration:6500}),s=!0;break}if(v<40)break;if(r>=2e3){o.o.message("LinkedIn enrich: reached ".concat(2e3," contacts this run — run again if more remain."),{duration:6e3}),s=!0;break}}l>=50&&i>=40&&(o.o.message("LinkedIn enrich: stopped at ".concat(50," batches — run again to continue."),{id:eT,duration:6e3}),s=!0),r>0&&!s&&o.o.success("LinkedIn enrich finished: ".concat(a," enriched \xb7 ").concat(l," batch(es)"),{id:eT,duration:6e3}),null==e||e()}catch(e){"AbortError"===e.name?o.o.error("LinkedIn enrichment cancelled",{id:eT,duration:3e3}):o.o.error(e instanceof Error?e.message:"Failed to enrich LinkedIn leads",{id:eT,duration:5e3})}finally{eP({active:!1,abortController:void 0,batchIndex:void 0,current:0,total:0,runEnriched:void 0})}}async function eB(e){if(eD.active)return void o.o.error("Finish LinkedIn enrichment first");
1if(eR.active)return void o.o.error("Finish Clay LinkedIn batch first");if(eL.active)return void o.o.error("Enrichment already in progress");let t=new AbortController;eF({active:!0,current:0,total:0,enriched:0,cacheHits:0,apiCalls:0,abortController:t}),o.o.loading("Starting enrichment...",{id:eA,duration:1/0});try{var a,r,n,l,s,i,c,d,u,m,g,x;let h=await fetch("/api/scorecard/enrich-leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({limit:500}),signal:t.signal});if(!h.ok){let e=await h.json().catch(()=>({}));throw Error(e.error||"Failed to enrich leads")}let p=null==(a=h.body)?void 0:a.getReader(),y=new TextDecoder,b="";if(p)for(;;){let{done:t,value:a}=await p.read();if(t)break;let h=(b+=y.decode(a,{stream:!0})).split("\n");for(let t of(b=null!=(r=h.pop())?r:"",h))if(t.trim())try{let a=JSON.parse(t);if("start"===a.type&&null!=a.total)eF({total:a.total});else if("progress"===a.type)eF({current:null!=(n=a.current)?n:eL.current,enriched:null!=(l=a.enriched)?l:eL.enriched,cacheHits:null!=(s=a.cacheHits)?s:eL.cacheHits,apiCalls:null!=(i=a.apiCalls)?i:eL.apiCalls,lastDomain:a.domain,lastCompany:null!=(c=a.companyName)?c:void 0});else if("done"===a.type){let t=null!=(d=a.enriched)?d:0,r=eL.total,n=null!=(u=a.cacheHits)?u:0,l=null!=(m=a.apiCalls)?m:0,s=null!=(g=a.skippedSyntheticPlaceholder)?g:0;if(t>0){let e=n>0?" (".concat(n," cached, ").concat(l," API)"):"";o.o.success("Enriched ".concat(t," leads across ").concat(r," companies").concat(e),{id:eA,duration:5e3})}else r>0?o.o.success("Checked ".concat(r," companies — no new data found"),{id:eA,duration:5e3}):s>0?o.o.success("No Attio-eligible domains in this batch — ".concat(s," lead(s) use @inbox.upgraded. Use Inbox → Enrich & Qualify or row LinkedIn enrich."),{id:eA,duration:7e3}):o.o.success("No leads needed enrichment—all have company data or use personal emails.",{id:eA,duration:5e3});s>0&&r>0&&o.o.info("".concat(s," inbox-placeholder lead(s) were skipped (Enrich All only uses real email domains)."),{duration:7e3}),null==e||e()}else if("error"===a.type)throw Error(null!=(x=a.error)?x:"Enrichment failed")}catch(e){if(e instanceof SyntaxError)continue;throw e}}}catch(e){"AbortError"===e.name?o.o.error("Enrichment cancelled",{id:eA,duration:3e3}):o.o.error(e instanceof Error?e.message:"Failed to enrich leads",{id:eA,duration:5e3})}finally{eF({active:!1,abortController:void 0})}}let eH=[...en.g3],eG=[...el.Zt];function eK(e,t){return t[e]?t[e]:el.KM[e]?el.KM[e]:e.charAt(0).toUpperCase()+e.slice(1)}let eV=ej.ll.map(e=>({value:e.value,label:e.label,group:e.country})),eQ=ej.g2.map(e=>({value:e,label:e})),eW=ej.a3.map(e=>({value:e,label:e})),eY=[{value:"Hot",label:"Hot"},{value:"Follow Up",label:"Follow Up"},{value:"Not Interested",label:"Not Interested"},{value:"Do Not Contact",label:"Do Not Contact"},{value:"Qualified",label:"Qualified"},{value:"ICP",label:"ICP"},{value:"Priority",label:"Priority"}],e$="pk_acnHOju_S3KawCcUE6Ek2Q";function eZ(e){let{linkedinUrl:t,isDark:a,size:n="sm"}=e,l=null==t?void 0:t.trim(),s=!!l,o=s?l.startsWith("http")?l:"https://".concat(l):"#";return(0,r.jsx)("a",{href:o,target:s?"_blank":void 0,rel:s?"noopener noreferrer":void 0,onClick:s?void 0:e=>e.preventDefault(),className:"shrink-0 ".concat(s?"":"pointer-events-none cursor-default"),title:s?"Open LinkedIn profile":"No LinkedIn profile","aria-label":s?"Open LinkedIn profile":"No LinkedIn profile",children:(0,r.jsx)("svg",{className:"".concat("sm"===n?"h-3 w-3":"h-3.5 w-3.5"," ").concat(s?"text-[#0A66C2]":a?"text-gray-600":"text-gray-300"),fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,children:(0,r.jsx)("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})})})}function eX(e){let{lead:t,displayName:a,inboxAvatarLookup:n,size:l="md",isDark:s}
1=e,o=function(e,t,a){let r=[e,t].filter(Boolean).join(" ").trim();if(r){let e=r.split(/\s+/);return e.length>=2?"".concat(e[0][0]).concat(e[e.length-1][0]).toUpperCase():r.slice(0,2).toUpperCase()}return a?a.slice(0,2).toUpperCase():"—"}(t.first_name,t.last_name,t.email),i=(0,eg.Lh)(t,n),c="sm"===l?"h-7 w-7":"h-8 w-8";return(0,r.jsxs)("div",{className:"relative shrink-0 ".concat(c),children:[(0,r.jsx)("div",{className:"flex ".concat(c," items-center justify-center rounded-full font-medium ").concat("sm"===l?"text-[10px]":"text-[11px]"," ").concat(s?"bg-gray-700 text-gray-300":"bg-gray-100 text-gray-600"),children:o}),i&&(0,r.jsx)("img",{src:i,alt:a,className:"absolute inset-0 ".concat(c," rounded-full object-cover"),onError:e=>{e.target.style.display="none"}})]})}function e0(e){let{leadId:t,attioPersonId:a,onPush:l,compact:s=!1,isDark:o=!1}=e,[i,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1),x=async()=>{c(!0),u(!1);try{await l(t),u(!0)}catch(e){alert(e instanceof Error?e.message:"Failed to push to Attio")}finally{c(!1)}},h="h-3 w-3 object-contain shrink-0",p="inline-flex items-center justify-center rounded p-0.5 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ".concat(o?"border border-gray-600 bg-gray-800 hover:bg-gray-700":"border border-gray-200 bg-white hover:bg-gray-50");return a?s?(0,r.jsx)("a",{href:"https://app.attio.com/people/".concat(a),target:"_blank",rel:"noopener noreferrer",title:"Open in Attio",className:"".concat(p," cursor-pointer"),children:(0,r.jsx)("img",{src:"https://img.logo.dev/attio.com?token=".concat(e$),alt:"Attio",className:h})}):(0,r.jsxs)("a",{href:"https://app.attio.com/people/".concat(a),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-md bg-gray-900 px-2 py-1 text-[11px] font-medium text-white hover:bg-gray-800 shadow-sm whitespace-nowrap cursor-pointer",children:[(0,r.jsx)("img",{src:"https://img.logo.dev/attio.com?token=".concat(e$),alt:"Attio",className:"h-3 w-3 object-contain"}),"Open in Attio"]}):s?(0,r.jsx)("button",{type:"button",onClick:x,disabled:i,title:d?"Synced to Attio":"Push to Attio",className:p,children:i?(0,r.jsx)(m.A,{className:"h-3 w-3 animate-spin shrink-0"}):d?(0,r.jsx)(g.A,{className:"h-3 w-3 shrink-0 ".concat(o?"text-green-400":"text-green-600")}):(0,r.jsx)("img",{src:"https://img.logo.dev/attio.com?token=".concat(e$),alt:"Attio",className:h})}):(0,r.jsxs)("button",{type:"button",onClick:x,disabled:i,title:"Push to Attio",className:"inline-flex items-center gap-1.5 rounded-md bg-gray-900 px-2 py-1 text-[11px] font-medium text-white hover:bg-gray-800 shadow-sm disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap cursor-pointer",children:[i?(0,r.jsx)(m.A,{className:"h-3 w-3 animate-spin shrink-0"}):d?(0,r.jsx)(g.A,{className:"h-3 w-3 text-green-400 shrink-0"}):(0,r.jsx)("img",{src:"https://img.logo.dev/attio.com?token=".concat(e$),alt:"Attio",className:"h-3 w-3 object-contain shrink-0"}),d?"Synced":"Push to Attio"]})}let e1=[{id:"attio",label:"Attio",logoUrl:(0,ei.j9)("attio")},{id:"apollo",label:"Apollo",logoUrl:(0,ei.j9)("apollo")},{id:"clay",label:"Clay",logoUrl:(0,ei.j9)("clay")}];function e5(e){var t;let{email:a,attioRecordId:s,companyDomain:i,hasAttio:c,onSuccess:d,compact:u=!1,isDark:m=!1}=e,[g,x]=(0,n.useState)(null),h=!!(null==a?void 0:a.trim()),p=(null==i?void 0:i.trim())||(h&&a.includes("@")?null==(t=a.split("@")[1])?void 0:t.toLowerCase():""),y=!!p&&!(0,eu.tr)(a),b=async(e,t)=>{if(!h)return void o.o.error("Email required to enrich");if("attio"===e&&!1===c)return void o.o.error("Attio not connected. Connect Attio in Apps/Connectors first.");if("company"===t&&!y)return void o.o.error("Domain required for company enrich (use work email or set company domain)");x("company"===t?"attio-company":e);try{let n=await fetch("/api/inbox/enrich-contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a.trim(),attioRecordId:(null==s?void 0:s.trim())||void 0,provider:e,mode:null!=t?t:"person",..."company"===t&&p?{domain:p}:{}})}),l=await n.json();if(!n.ok)throw Error(l.error||"Failed to enrich");if(l.queued){var r;o.o.info(null!=(r=l.message)?r:"Clay is enriching—try again in a minute.");return}o.o.success("company"===t?"Company data enriched from Attio":"Enriched with ".concat(e.charAt(0).toUpperCase()+e.slice(1))),null==d||d()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to enrich")}finally{x(null)}},f="inline-flex items-center justify-center rounded p-0.5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed ".concat(m?"border border-gray-600 bg-gray-800 hover:bg-gray-700":"border border-gray-200 bg-white hover:bg-gray-50"),v=u?12:16,w=u?"h-3 w-3 object-contain":"h-4 w-4 object-contain",j=u?"h-3 w-3":"h-4 w-4";return(0,r.jsxs)("div",{className:"flex items-center ".concat("gap-0.5"),children:[e1.map(e=>{let{id:t,label:a,logoUrl:n}=e,s="attio"===t&&!1===c||!h,o=null!==g||s;return(0,r.jsx)("button",{type:"button",onClick:()=>
1!o&&b(t),disabled:o,title:s?"attio"===t?"Attio not connected":"Email required":"Enrich person with ".concat(a),className:u?f:"inline-flex items-center justify-center rounded-sm shadow-lg bg-white p-[2px] transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:g===t?(0,r.jsx)("span",{className:"".concat(j," animate-spin rounded-full border-2 border-gray-300 border-t-indigo-600")}):(0,r.jsx)(l.default,{src:n,alt:a,width:v,height:v,className:w})},t)}),c&&y&&(0,r.jsx)("button",{type:"button",onClick:()=>b("attio","company"),disabled:null!==g,title:"Enrich company from Attio (headcount, industry, etc.)",className:u?f:"inline-flex items-center justify-center rounded-sm shadow-lg bg-white p-[2px] transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"attio-company"===g?(0,r.jsx)("span",{className:"".concat(j," animate-spin rounded-full border-2 border-gray-300 border-t-indigo-600")}):(0,r.jsx)(l.default,{src:(0,ei.j9)("attio"),alt:"Attio Company",width:v,height:v,className:"".concat(w," opacity-70")})})]})}let e2={new:"bg-blue-500",contacted:"bg-amber-500",qualified:"bg-violet-500",demo:"bg-orange-500",won:"bg-green-500",lost:"bg-gray-400"},e3={tally:"bg-blue-500",lemlist:"bg-purple-500",apollo:"bg-orange-500",mailchimp:"bg-yellow-500",airtable:"bg-teal-500",calendly:"bg-sky-500",webflow:"bg-indigo-500",instantly:"bg-emerald-500",warmly:"bg-rose-500",linkedin_dm:"bg-[#0A66C2]",attio:"bg-violet-500",clay:"bg-amber-600",inbox:"bg-gray-500"};function e4(e){return e.startsWith("list-")?"bg-cyan-500":e3[e]||"bg-slate-500"}let e7={gray:"bg-gray-400",green:"bg-green-500",blue:"bg-blue-500",amber:"bg-amber-500",violet:"bg-violet-500",orange:"bg-orange-500",rose:"bg-rose-500",teal:"bg-teal-500",indigo:"bg-indigo-500",cyan:"bg-cyan-500",emerald:"bg-emerald-500",sky:"bg-sky-500",purple:"bg-purple-500",yellow:"bg-yellow-500",slate:"bg-slate-500"};function e6(e,t){return t||e7[null!=e?e:"gray"]}let e9={"bg-blue-500":"bg-blue-100 text-blue-800","bg-amber-500":"bg-amber-100 text-amber-800","bg-amber-600":"bg-amber-100 text-amber-800","bg-violet-500":"bg-violet-100 text-violet-800","bg-orange-500":"bg-orange-100 text-orange-800","bg-green-500":"bg-green-100 text-green-800","bg-emerald-500":"bg-emerald-100 text-emerald-800","bg-teal-500":"bg-teal-100 text-teal-800","bg-sky-500":"bg-sky-100 text-sky-800","bg-cyan-500":"bg-cyan-100 text-cyan-800","bg-indigo-500":"bg-indigo-100 text-indigo-800","bg-purple-500":"bg-purple-100 text-purple-800","bg-rose-500":"bg-rose-100 text-rose-800","bg-yellow-500":"bg-yellow-100 text-yellow-800","bg-slate-500":"bg-slate-100 text-slate-700","bg-gray-400":"bg-gray-100 text-gray-700","bg-gray-500":"bg-gray-100 text-gray-700","bg-[#0A66C2]":"bg-[#0A66C2]/10 text-[#0A66C2]"};function e8(e){return e&&e9[e]||"bg-gray-100 text-gray-700"}function te(e){let{color:t,customClass:a}=e;return(0,r.jsx)("span",{className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full ".concat(e6(t,a))})}function tt(e){let{text:t,className:a}=e,l=n.useRef(null),[s,o]=n.useState(!1);return n.useEffect(()=>{let e=l.current;if(!e)return;let t=()=>o(e.scrollWidth>e.clientWidth+1);t();let a=new ResizeObserver(t);return a.observe(e),()=>a.disconnect()},[t]),(0,r.jsx)("span",{ref:l,className:a,title:s?t:void 0,children:t})}function ta(e,t,a){let r=(null!=e?e:"").trim();if(!r||"unassigned"===r)return"Unassigned";if("me"===r)return"Me";if(new Set((null!=a?a:[]).map(e=>e.trim()).filter(Boolean)).has(r))return r;let n=t.find(e=>{var t;return(null!=(t=e.email)?t:e.member_id)===r});return n&&(n.name||n.email)||r}function tr(e){let t=Math.max(0,Math.min(100,e));return"hsl(".concat(t/100*120,", 65%, 42%)")}function tn(e){let{value:t,options:a,onChange:l,onBlur:s,size:i="sm",color:c="gray",colorClass:u,displayLabel:g,addCustomOption:h,addCustomPlaceholder:p,getOptionLabel:y,truncateLabel:b=!1}=e,[f,v]=(0,n.useState)(!1),[w,j]=(0,n.useState)(!1),[N,k]=(0,n.useState)(""),[C,_]=(0,n.use
1State)(!1),S=n.useRef(null);(0,n.useEffect)(()=>{if(!f)return;let e=e=>{S.current&&!S.current.contains(e.target)&&(v(!1),j(!1),k(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[f]);let E=e8(e6(c,u)),A=null!=g?g:y?y(t):t,L=async()=>{let e=N.trim();if(e&&h){_(!0);try{let t=await h.onAdd(e);t?(l(t),v(!1),j(!1),k("")):o.o.error("Could not add — try again or check your permissions")}finally{_(!1)}}};return(0,r.jsxs)("div",{ref:S,className:"relative ".concat(b?"max-w-[7.5rem]":""),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>v(!f),onBlur:()=>!w&&(null==s||s(),setTimeout(()=>v(!1),150)),className:"inline-flex max-w-full min-w-0 items-center gap-1 rounded-full font-medium leading-none cursor-pointer transition-all hover:brightness-[0.97] ".concat(E," ").concat("xs"===i?"text-[11px] px-2 py-1":"text-[11px] px-2.5 py-1"),children:[b?(0,r.jsx)(tt,{text:A,className:"min-w-0 flex-1 truncate"}):(0,r.jsx)("span",{className:"min-w-0",children:A}),(0,r.jsx)(d.A,{className:"h-3 w-3 shrink-0 opacity-50"})]}),f&&(0,r.jsx)("div",{className:"absolute left-0 top-full z-10 mt-1 min-w-[140px] max-h-40 overflow-auto rounded-xl border border-gray-100 bg-white py-1 shadow-xl",children:w?(0,r.jsxs)("div",{className:"px-2 py-1.5",onMouseDown:e=>e.preventDefault(),children:[(0,r.jsx)("input",{type:"text",value:N,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&L(),"Escape"===e.key&&(j(!1),k(""))},placeholder:null!=p?p:"Enter name",className:"w-full rounded border border-gray-300 px-2 py-1 text-[12px] focus:border-gray-900 focus:outline-none focus:ring-0.5 focus:ring-gray-900",autoFocus:!0}),(0,r.jsxs)("button",{type:"button",onClick:L,disabled:!N.trim()||C,className:"mt-1.5 w-full rounded bg-gray-900 px-2 py-1 text-[12px] text-white hover:bg-gray-800 disabled:opacity-50 inline-flex items-center justify-center gap-1.5",children:[C&&(0,r.jsx)(m.A,{className:"w-3 h-3 animate-spin shrink-0"}),(0,r.jsx)(et.L,{reserve:"Adding…",children:C?"Adding…":"Add"})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{j(!1),k("")},className:"mt-0.5 block w-full text-center text-[12px] text-gray-500 hover:text-gray-700",children:"Cancel"})]}):(0,r.jsxs)(r.Fragment,{children:[a.map(e=>(0,r.jsx)("button",{type:"button",className:"block w-full px-2 py-1 text-left text-[12px] hover:bg-gray-50 text-[#101010]",onMouseDown:t=>{t.preventDefault(),l(e),v(!1)},children:y?y(e):e},e)),h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"my-0.5 border-t border-gray-100",role:"separator"}),(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-left text-[12px] text-gray-600 hover:bg-gray-50",onMouseDown:e=>{e.preventDefault(),j(!0)},children:[(0,r.jsx)(x.A,{className:"h-3 w-3 shrink-0"}),h.label]})]})]})})]})}function tl(e){let{value:t,placeholder:a,onSave:l,onBlur:s,className:o="",truncate:i=!0,renderTrigger:c,inputClassName:d}=e,[u,m]=(0,n.useState)(!1),[g,x]=(0,n.useState)(t);(0,n.useEffect)(()=>{u||g===t||x(t)},[t,u]);let p=()=>{let e=g.trim();e!==t&&l(e),m(!1),null==s||s()};
1return u?(0,r.jsx)("input",{autoFocus:!0,type:"text",value:g,onChange:e=>x(e.target.value),onBlur:p,onKeyDown:e=>"Enter"===e.key&&p(),className:d||"min-w-0 rounded border border-gray-300 px-1 py-0.5 text-[11px] focus:border-gray-900 focus:outline-none focus:ring-0.5 focus:ring-gray-900 ".concat(o)}):c?(0,r.jsx)(r.Fragment,{children:c(()=>m(!0))}):(0,r.jsxs)("button",{type:"button",onClick:()=>m(!0),className:"group flex items-center gap-0.5 text-left hover:bg-gray-50 rounded px-0.5 -mx-0.5 ".concat(o),children:[(0,r.jsx)("span",{className:i?"truncate":"",children:t||a||"—"}),(0,r.jsx)(h.A,{className:"h-2.5 w-2.5 shrink-0 opacity-0 group-hover:opacity-50 text-gray-500"})]})}function ts(e){let{lead:t,onClose:a,onSave:l,isDark:s}=e,[i,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",company:t.company||"",title:t.title||"",phone:t.phone||"",linkedin_url:t.linkedin_url||"",company_linkedin_url:t.company_linkedin_url||"",company_domain:t.company_domain||"",company_location:t.company_location||"",company_employee_range:t.company_employee_range||"",company_categories:t.company_categories||""}),g=async()=>{c(!0);try{let e={};d.first_name!==(t.first_name||"")&&(e.first_name=d.first_name||void 0),d.last_name!==(t.last_name||"")&&(e.last_name=d.last_name||void 0),d.email!==(t.email||"")&&(e.email=d.email),d.company!==(t.company||"")&&(e.company=d.company||void 0),d.title!==(t.title||"")&&(e.title=d.title||void 0),d.phone!==(t.phone||"")&&(e.phone=d.phone||void 0),d.linkedin_url!==(t.linkedin_url||"")&&(e.linkedin_url=d.linkedin_url||void 0),d.company_linkedin_url!==(t.company_linkedin_url||"")&&(e.company_linkedin_url=d.company_linkedin_url||void 0),d.company_domain!==(t.company_domain||"")&&(e.company_domain=d.company_domain||void 0),d.company_location!==(t.company_location||"")&&(e.company_location=d.company_location||void 0),d.company_employee_range!==(t.company_employee_range||"")&&(e.company_employee_range=d.company_employee_range||void 0),d.company_categories!==(t.company_categories||"")&&(e.company_categories=d.company_categories||void 0),Object.keys(e).length>0&&await l(t.id,e),a()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to save")}finally{c(!1)}},x="w-full text-[12px] border rounded-md px-3 py-2 focus:ring-1 focus:outline-none ".concat(s?"border-gray-600 bg-gray-700 text-gray-200 placeholder:text-gray-500 focus:ring-gray-600 focus:border-gray-500":"border-gray-300 bg-white text-gray-900 focus:ring-gray-900 focus:border-gray-900"),h="block text-[11px] font-medium mb-1 ".concat(s?"text-gray-300":"text-gray-700");return(0,r.jsx)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4 bg-black/50",onClick:a,children:(0,r.jsxs)("div",{className:"rounded-xl shadow-xl border w-full max-w-lg max-h-[85vh] flex flex-col transition-all ".concat(s?"bg-gray-800 border-gray-700":"bg-[#FAFAF9] border-gray-100"),onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b shrink-0 ".concat(s?"border-gray-700":"border-gray-100"),children:[(0,r.jsx)("h3",{className:"text-base font-semibold ".concat(s?"text-gray-100":"text-gray-900"),children:"Edit Lead"}),(0,r.jsx)("button",{type:"button",onClick:a,className:"p-1.5 rounded-lg transition-all ".concat(s?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-400 hover:bg-gray-100 hover:text-gray-600"),children:(0,r.jsx)(p.A,{className:"w-5 h-5"})})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-[11px] font-semibold uppercase tracking-wide mb-3 ".concat(s?"text-gray-400":"text-gray-500"),children:"Contact Information"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"First Name"}),(0,r.jsx)("input",{type:"text",value:d.first_name,onChange:e=>u({...d,first_name:e.target.value}),className:x,placeholder:"John"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Last Name"}),(0,r.jsx)("input",{type:"text",value:d.last_name,onChange:e=>u({...d,last_name:e.target.value}),className:x,placeholder:"Doe"})]})]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{className:h,children:"Email"}),(0,r.jsx)("input",{type:"email",value:d.email,onChange:e=>u({...d,email:e.target.value}),className:x,placeholder:"[email protected]"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Title"}),(0,r.jsx)("input",{type:"text",value:d.title,onChange:e=>u({...d,title:e.target.value}),className:x,placeholder:"CEO"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Phone"}),(0,r.jsx)("input",{type:"tel",value:d.phone,onChange:e=>u({...d,phone:e.target.value}),className:x,placeholder:"+1 555-123-4567"})]})]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{className:h,children:"LinkedIn URL"}),(0,r.jsx)("input",{type:"url",value:d.linkedin_url,onChange:e=>u({...d,linkedin_url:e.target.value}),className:x,placeholder:"https://linkedin.com/in/johndoe"})]})]}),(0,r.jsxs)("div",{className:"pt-4 border-t ".concat(s?"border-gray-700":"border-gray-100"),children:[(0,r.jsx)("h4",{className:"text-[11px] font-semibold uppercase tracking-wide mb-3 ".concat(s?"text-gray-400":"text-gray-500"),children:"Company Information"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Company Name"}),(0,r.jsx)("input",{type:"text",value:d.company,onChange:e=>u({...d,company:e.target.value}),className:x,placeholder:"Acme Inc."})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Domain"}),(0,r.jsx)("input",{type:"text",value:d.company_domain,onChange:e=>u({...d,company_domain:e.target.value}),className:x,placeholder:"acme.com"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Location"}),(0,r.jsx)("input",{type:"text",value:d.company_location,onChange:e=>u({...d,company_location:e.target.value}),className:x,placeholder:"San Francisco, CA"})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Employee Range"}),(0,r.jsx)("input",{type:"text",value:d.company_employee_range,onChange:e=>u({...d,company_employee_range:e.target.value}),className:x,placeholder:"51-200"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:h,children:"Industry"}),(0,r.jsx)("input",{type:"text",value:d.company_categories,onChange:e=>u({...d,company_categories:e.target.value}),className:x,placeholder:"Software"})]})]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{className:h,children:"Company LinkedIn URL"}),(0,r.jsx)("input",{type:"url",value:d.company_linkedin_url,onChange:e=>u({...d,company_linkedin_url:e.target.value}),className:x,placeholder:"https://linkedin.com/company/acme"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 px-5 py-4 border-t shrink-0 ".concat(s?"border-gray-700":"border-gray-100"),children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"text-[12px] px-4 py-2 rounded-lg border font-medium transition-all ".concat(s?"border-gray-600 text-gray-300 hover:bg-gray-700":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"),children:"Cancel"}),(0,r.jsxs)("button",{type:"button",onClick:g,disabled:i,className:"text-[12px] px-4 py-2 rounded-lg font-medium disabled:opacity-50 flex items-center gap-1.5 shadow-sm transition-all ".concat(s?"bg-gray-600 text-gray-100 hover:bg-gray-500 hover:shadow":"bg-gray-900 text-white hover:bg-gray-800 hover:shadow"),children:[i&&(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin shrink-0"}),(0,r.jsx)(et.L,{reserve:"Save Changes",children:i?"Saving...":"Save Changes"})]})]})]})})}let to=["Qualified","Hot","Follow Up","Not Interested","Do Not Contact"];function ti(e){let t=e.toLowerCase();return"qualified"===t?"bg-green-100 text-green-800":"hot"===t||"priority"===t?"bg-red-100 text-red-800":"follow up"===t||"followup"===t?"bg-amber-100 text-amber-800":"not interested"===t||"do not contact"===t?"bg-gray-100 text-gray-600":"bg-blue-100 text-blue-800"}function tc(e){let{tags:t,onChange:a,disabled:l=!1}
1=e,[s,o]=(0,n.useState)(!1),[i,c]=(0,n.useState)(""),d=n.useRef(null);(0,n.useEffect)(()=>{if(!s)return;let e=e=>{d.current&&!d.current.contains(e.target)&&(o(!1),c(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]);let u=e=>{let r=e.trim();r&&!t.includes(r)&&a([...t,r]),c("")},m=to.filter(e=>!t.includes(e));return l?(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:0===t.length?(0,r.jsx)("span",{className:"text-[10px] text-gray-400",children:"—"}):t.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-1 text-[10px] font-medium leading-none ".concat(ti(e)),children:e},e))}):(0,r.jsxs)("div",{ref:d,className:"relative",children:[(0,r.jsx)("button",{type:"button",onClick:()=>o(!s),className:"flex flex-wrap gap-1 items-center min-h-[24px] hover:bg-gray-50 rounded px-1 -mx-1 cursor-pointer",children:0===t.length?(0,r.jsxs)("span",{className:"text-[10px] text-gray-400 flex items-center gap-0.5",children:[(0,r.jsx)(x.A,{className:"h-2.5 w-2.5"}),"Add tags"]}):t.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-1 text-[10px] font-medium leading-none ".concat(ti(e)),children:e},e))}),s&&(0,r.jsxs)("div",{className:"absolute left-0 top-full z-20 mt-1 w-48 rounded-xl border border-gray-100 bg-white py-1.5 shadow-xl",children:[t.length>0&&(0,r.jsxs)("div",{className:"px-2 py-1.5 border-b border-gray-100",children:[(0,r.jsx)("p",{className:"text-[10px] text-gray-500 mb-1",children:"Current tags:"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:t.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded-full pl-2 pr-1 py-1 text-[10px] font-medium leading-none ".concat(ti(e)),children:[e,(0,r.jsx)("button",{type:"button",onClick:r=>{r.stopPropagation(),a(t.filter(t=>t!==e))},className:"p-0.5 rounded-full hover:bg-black/10",children:(0,r.jsx)(p.A,{className:"h-2.5 w-2.5"})})]},e))})]}),(0,r.jsx)("div",{className:"px-2 py-1.5 border-b border-gray-100",children:(0,r.jsx)("input",{type:"text",value:i,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&u(i),"Escape"===e.key&&(o(!1),c(""))},placeholder:"Type to add...",className:"w-full text-[11px] border border-gray-200 rounded px-2 py-1 focus:border-gray-900 focus:outline-none focus:ring-0.5 focus:ring-gray-900",autoFocus:!0})}),m.length>0&&(0,r.jsxs)("div",{className:"py-1",children:[(0,r.jsx)("p",{className:"px-2 text-[10px] text-gray-500 mb-1",children:"Suggestions:"}),m.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>u(e),className:"w-full px-2 py-1 text-left text-[11px] hover:bg-gray-50 flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"inline-block h-2 w-2 rounded-full ".concat(ti(e).split(" ")[0])}),e]},e))]})]})]})}function td(e){let{leadId:t,value:a,teamMembers:n,rosterNames:l,onUpdateLead:s}=e,o=(null!=a?a:"").trim(),i=function(e,t,a){let r=new Set((null!=t?t:[]).map(e=>e.trim()).filter(Boolean)),n=["unassigned",...null!=t?t:[],...e.filter(e=>{var t;let a=(null!=(t=e.name)?t:"").trim();return!a||!r.size||!r.has(a)}).map(e=>{var t;return null!=(t=e.email)?t:e.member_id})],l=(null!=a?a:"").trim();return l&&"unassigned"!==l&&"me"!==l&&!n.includes(l)&&n.push(l),n}(n,l,a),c=ta(a,n,l);return(0,r.jsx)(tn,{value:o||"unassigned",options:i,onChange:e=>{s(t,{contact_owner:"unassigned"===e?null:e})},size:"xs",colorClass:"bg-indigo-500",displayLabel:c,truncateLabel:!0,getOptionLabel:e=>ta("unassigned"===e?null:e,n,l),addCustomOption:{label:"Custom email…",onAdd:async e=>{let a=e.trim();return a?(await s(t,{contact_owner:a}),a):null}},addCustomPlaceholder:"Enter email"})}function tu(e){var t;let{lead:a,isDark:n,onOpen:l}=e,s=null!=(t=a.next_meeting_at)?t:null,o=!!s&&new Date(s).getTime()>Date.now(),i=function(e){if(!e)return null;let t=new Date(e);return isNaN(t.getTime())?null:t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}(a.last_meeting_at),c=o?function(e){if(!e)return null;let t=new Date(e);return isNaN(t.getTime())?null:t.toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}(s):null,d=null!=c?c:i,u=!!(a.meeting_notes&&a.meeting_notes.trim()),m=o?n?"text-emerald-400":"text-emerald-600":i?n?"text-blue-400":"text-blue-600":n?"text-gray-600":"text-gray-400";return(0,r.jsxs)("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 text-[12px] curs
1or-pointer transition-colors ".concat(n?"hover:bg-gray-700 text-gray-200":"hover:bg-gray-100 text-gray-900"),title:o?"Upcoming meeting — click for details":"Meeting summary, action items & history",children:[(0,r.jsx)(y.A,{className:"h-3.5 w-3.5 shrink-0 ".concat(m)}),d?(0,r.jsxs)("span",{className:"font-medium whitespace-nowrap inline-flex items-center gap-1",children:[o&&(0,r.jsx)("span",{className:"inline-block rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ".concat(n?"bg-emerald-500/20 text-emerald-300":"bg-emerald-100 text-emerald-700"),children:"Next"}),d]}):(0,r.jsx)("span",{className:n?"text-gray-500":"text-gray-400",children:"Add"}),u&&(0,r.jsx)("span",{className:"ml-0.5 inline-block h-1.5 w-1.5 rounded-full ".concat(n?"bg-emerald-400":"bg-emerald-500"),title:"Has meeting notes"})]})}function tm(e){var t,a,i,z,q,J,B,H,G,K,V,W,Y,X,eg,ef,ej,ek,eS,eA,eF,eT,eP,eM,ez,e1,e3,e7,e6,e9,to,ti,tm,tg,tx,th,tp,ty,tb,tf,tv,tw,tj,tN,tk,tC,t_,tS,tE,tA,tL,tI,tF,tT,tD,tO,tP,tM,tR,tU,tz,tq,tJ,tB,tH,tG,tK,tV,tQ,tW,tY,t$,tZ,tX,t0,t1,t5,t2,t3,t4,t7,t6,t9,t8;let{open:ae,onClose:at,variant:aa="modal",initialViewMode:ar,onViewModeChange:an,onUpdateStage:al,onUpdateLead:as,onComposeToLead:ao,onPushToAttio:ai,isAdmin:ac,inboxAvatarLookup:ad}=e,au=(0,n.useContext)(er.hG),am=(0,n.useContext)(es.a5),ag=null!=(a=null==au?void 0:au.leadsData)?a:null,ax=null!=(i=null==au?void 0:au.leadsLoading)&&i,ah=null!=(z=null==au?void 0:au.leadsSourceFilter)?z:"",ap=null!=(q=null==au?void 0:au.setLeadsSourceFilter)?q:()=>{},ay=null!=(J=null==au?void 0:au.leadsStageFilter)?J:"",ab=null!=(B=null==au?void 0:au.setLeadsStageFilter)?B:()=>{},af=null!=(H=null==au?void 0:au.leadsLocationFilter)?H:"",av=null!=(G=null==au?void 0:au.setLeadsLocationFilter)?G:()=>{},aw=null!=(K=null==au?void 0:au.leadsEmployeeFilter)?K:"",aj=null!=(V=null==au?void 0:au.setLeadsEmployeeFilter)?V:()=>{},aN=null!=(W=null==au?void 0:au.leadsIndustryFilter)?W:"",ak=null!=(Y=null==au?void 0:au.setLeadsIndustryFilter)?Y:()=>{},aC=null!=(X=null==au?void 0:au.leadsTagsFilter)?X:"",a_=null!=(eg=null==au?void 0:au.setLeadsTagsFilter)?eg:()=>{},aS=null!=(ef=null==au?void 0:au.leadsContactOwnerFilter)?ef:"",aE=null!=(ej=null==au?void 0:au.setLeadsContactOwnerFilter)?ej:()=>{},aA=null!=(ek=null==au?void 0:au.leadsSort)?ek:"created_at",aL=null!=(eS=null==au?void 0:au.setLeadsSort)?eS:()=>{},aI=null!=(eA=null==au?void 0:au.leadsSearch)?eA:"",aF=null!=(eF=null==au?void 0:au.setLeadsSearch)?eF:()=>{},aT=null!=(eT=null==au?void 0:au.leadsPage)?eT:1,aD=null!=(eP=null==au?void 0:au.setLeadsPage)?eP:()=>{},aO=null!=(eM=null==au?void 0:au.leadsPageSize)?eM:er.AG,aP=null!=(ez=null==au?void 0:au.setLeadsPageSize)?ez:()=>{};null==au||au.editingLeadId;let aM=null!=(e3=null!=(e1=e.onEditingLeadIdChange)?e1:null==au?void 0:au.setEditingLeadId)?e3:()=>{};null==au||au.leadSourceLabels,null==au||au.canEditLeadSources;let[aR,aU]=(0,n.useState)([]),[az,aq]=(0,n.useState)([]),[aJ,aB]=(0,n.useState)({}
1),[aH,aG]=(0,n.useState)([]),[aK,aV]=(0,n.useState)({}),[aQ,aW]=(0,n.useState)([]),aY=null!=(e7=null==au?void 0:au.customLeadSources)?e7:aR,a$=null!=(e6=null==au?void 0:au.setCustomLeadSources)?e6:aU,aZ=null!=(e9=null==au?void 0:au.leadSourceLabels)?e9:aJ,aX=null!=(to=null==au?void 0:au.setLeadSourceLabels)?to:aB,a0=null!=(ti=null==au?void 0:au.leadSourceIds)?ti:aH,a1=null!=(tm=null==au?void 0:au.setLeadSourceIds)?tm:aG,a5=null!=(tg=null==au?void 0:au.customStages)?tg:az,a2=null!=(tx=null==au?void 0:au.setCustomStages)?tx:aq,a3=null!=(th=null==au?void 0:au.leadStageLabels)?th:aK,a4=null!=(tp=null==au?void 0:au.setLeadStageLabels)?tp:aV,a7=null!=(ty=null==au?void 0:au.leadStageIds)?ty:aQ,a6=null!=(tb=null==au?void 0:au.setLeadStageIds)?tb:aW,a9=null!=(tf=null==au?void 0:au.leadsFiltersRef)?tf:{current:{location:"",employee_range:"",industry:"",tags:"",contact_owner:""}},a8=null!=(tv=null==au?void 0:au.fetchLeads)?tv:async()=>{},re=null!=(tw=null==au?void 0:au.setInboxAppliedLeadsFilters)?tw:()=>{},rt=null!=(tj=null==au?void 0:au.teamMembers)?tj:[],ra=null!=(tN=null==am?void 0:am.hasAttio)&&tN,rr=null!=(tC=e.leads)?tC:null!=(tk=null==ag?void 0:ag.leads)?tk:[],rn=null!=(tS=e.total)?tS:null!=(t_=null==ag?void 0:ag.total)?t_:0,rl=null!=(tE=e.loading)?tE:ax,rs=null!=(tA=e.sourceFilter)?tA:ah,ro=null!=(tL=e.stageFilter)?tL:ay,ri=null!=(tI=e.locationFilter)?tI:af,rc=null!=(tF=e.employeeFilter)?tF:aw,rd=null!=(tT=e.industryFilter)?tT:aN,ru=null!=(tD=e.tagsFilter)?tD:aC,rm=null!=(tO=e.sort)?tO:aA,rg=null!=(tP=e.search)?tP:aI,rx=null!=(tM=e.page)?tM:aT,rh=null!=(tR=e.pageSize)?tR:aO,rp=(0,n.useRef)(null!=ar?ar:"table"),ry=(0,n.useRef)(!1),rb=(0,n.useCallback)(()=>"kanban"===rp.current||"funnel"===rp.current?er.tr:rh,[rh]),rf=null!=(tU=e.sourceOptions)?tU:a0.length>0?a0:eH,rv=null!=(tz=e.stageOptions)?tz:a7.length>0?a7:eG,rw=(0,n.useMemo)(()=>[...new Set([...rf,...aY.map(e=>(0,en.GM)(e.id))])],[rf,aY]),rj=(0,n.useMemo)(()=>[...new Set([...rv,...a5.map(e=>(0,el.Fb)(e.id))])],[rv,a5]),rN=(0,n.useMemo)(()=>{var t;let a={...null!=(t=e.channelLabels)?t:aZ,...aZ};for(let{id:e,label:t}of aY){let r=(0,en.GM)(e);(null==t?void 0:t.trim())&&(a[r]=t.trim())}return a},[e.channelLabels,aZ,aY]),rk=(0,n.useMemo)(()=>{var t;let a={...null!=(t=e.stageLabels)?t:Object.keys(a3).length>0?a3:{}};for(let{id:e,label:t}of a5){let r=(0,el.Fb)(e);(null==t?void 0:t.trim())&&(a[r]=t.trim())}return a},[e.stageLabels,a3,a5]);e.editingLeadId;let rC=null!=(tq=e.currentUserId)?tq:null==(t=rt[0])?void 0:t.member_id,r_=null!=(tJ=e.teamMembers)?tJ:rt.map(e=>{var t;return{id:e.member_id,name:e.name||(null==(t=e.email)?void 0:t.split("@")[0])||"Team Member"}}),rS=null!=(tB=e.hasAttio)?tB:ra,rE=(0,n.useMemo)(()=>{let e=new Map;for(let t of r_)e.set(t.id,t.name);return e},[r_]),[rA,rL]=(0,n.useState)(!1),[rI,rF]=(0,n.useState)(!1),[rT,rD]=(0,n.useState)(!1),[rO,rP]=(0,n.useState)(!1),[rM,rR]=(0,n.useState)(!1),[rU,rz]=(0,n.useState)(!1),[rq,rJ]=(0,n.useState)(!1),[rB,rH]=(0,n.useState)("and"),[rG,rK]=(0,n.useState)(!1),[rV,rQ]=(0,n.useState)(!0),[rW,rY]=(0,n.use
1State)(""),[r$,rZ]=(0,n.useState)(""),[rX,r0]=(0,n.useState)("any"),[r1,r5]=(0,n.useState)(7),[r2,r3]=(0,n.useState)(!1),r4=(0,n.useRef)(null),r7=(0,n.useCallback)(e=>{e.customLeadSources&&a$(e.customLeadSources),e.customStages&&a2(e.customStages),e.leadSourceLabels&&aX(e.leadSourceLabels),e.leadSourceIds&&a1(e.leadSourceIds),e.leadStageLabels&&a4(e.leadStageLabels),e.leadStageIds&&a6(e.leadStageIds)},[a$,a2,aX,a1,a4,a6]),r6=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/scorecard/team");if(!e.ok)return;let t=await e.json();r7(t)}catch(e){}},[r7]);(0,n.useEffect)(()=>{ae&&r6()},[ae,r6]);let r9=(0,n.useCallback)(async e=>{let t=e.trim();if(!t)return null;try{var a;let e=await fetch("/api/scorecard/lead-options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"source",label:t})}),r=await e.json().catch(()=>({}));if(!e.ok)throw Error(r.error||"Failed to add source");r7(r);let n=null!=(a=r.id)?a:(0,en.GM)(t);return r.alreadyExists?o.o.message('Source "'.concat(t,'" already exists')):o.o.success('Added source "'.concat(t,'"')),n}catch(e){return o.o.error(e instanceof Error?e.message:"Failed to add source"),null}},[r7]),r8=(0,n.useCallback)(async e=>{let t=e.trim();if(!t)return null;try{var a;let e=await fetch("/api/scorecard/lead-options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"stage",label:t})}),r=await e.json().catch(()=>({}));if(!e.ok)throw Error(r.error||"Failed to add stage");r7(r);let n=null!=(a=r.id)?a:(0,el.Fb)(t);return r.alreadyExists?o.o.message('Stage "'.concat(t,'" already exists')):o.o.success('Added stage "'.concat(t,'"')),n}catch(e){return o.o.error(e instanceof Error?e.message:"Failed to add stage"),null}},[r7]),ne=e.onUpdateLead?r9:void 0,nt=e.onUpdateLead?r8:void 0,na=(0,n.useCallback)(()=>({source:rs,stage:ro,location:ri,employee_range:rc,industry:rd,contact_owner:aS,sort:rm,search:rg,sourceExclude:rA,stageExclude:rI,locationExclude:rT,employeeExclude:rO,industryExclude:rM,contactOwnerExclude:rq,tags:ru||void 0,tagsExclude:rU||void 0,starred:rG||void 0,exclude_role_emails:rV||void 0,filter_combine:rB,channel:rW||void 0,linkedin_reachable:r$||void 0,no_contact:"never"===rX||void 0,no_contact_days:"days"===rX?r1:void 0}),[rs,ro,ri,rc,rd,aS,rm,rg,rA,rI,rT,rO,rM,rq,ru,rU,rG,rV,rB,rW,r$,rX,r1]),nr=(0,n.useCallback)(e=>({location:e.location||void 0,employee_range:e.employee_range||void 0,industry:e.industry||void 0,contact_owner:e.contact_owner||void 0,tags:e.tags||void 0,starred:e.starred||void 0,exclude_role_emails:e.exclude_role_emails||void 0,source_exclude:e.sourceExclude||void 0,stage_exclude:e.stageExclude||void 0,location_exclude:e.locationExclude||void 0,employee_exclude:e.employeeExclude||void 0,industry_exclude:e.industryExclude||void 0,tags_exclude:e.tagsExclude||void 0,contact_owner_exclude:e.contactOwnerExclude||void 0,filter_combine:e.filter_combine,channel:e.channel||void 0,no_contact:e.no_contact||void 0,no_contact_days:e.no_contact_days||void 0}),[]),nn=(0,n.useCallback)(e=>({...nr(na()),...e}),[nr,na]),nl=(0,n.useCallback)(e=>{let t=null!=e?e:na();aD(1),a8(t.source||void 0,t.search||void 0,0,t.stage||void 0,t.sort,{limit:rb()},nr(t))},[a8,na,nr,aD,rb]),ns=(0,n.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};nl({...na(),...e})},[nl,na]),no=(0,n.useCallback)(e=>{rY(e),ns({channel:e||void 0})},[ns]),ni=(0,n.useCallback)((e,t)=>{r0(e),r5(t),ns({no_contact:"never"===e||void 0,no_contact_days:"days"===e?t:void 0})},[ns]),nc=(0,n.useCallback)(e=>{ap(e),ns({source:e})},[ap,ns]),nd=(0,n.useCallback)(e=>{ab(e),ns({stage:e})},[ab,ns]),nu=(0,n.useCallback)(e=>{av(e),ns({location:e})},[av,ns]),nm=(0,n.useCallback)(e=>{aj(e),ns({employee_range:e})},[aj,ns]),ng=(0,n.useCallback)(e=>{ak(e),ns({industry:e})},[ak,ns]),nx=(0,n.useCallback)(e=>{a_(e),ns({tags:e||void 0})},[a_,ns]),nh=(0,n.useCallback)(e=>{aE(e),ns({contact_owner:e})},[aE,ns]),np=(0,n.useCallback)(e=>{aL(e),ns({sort:e})},[aL,ns]),ny=(0,n.useCallback)(e=>aF(e),[aF]),nb=(0,n.useCallback)(e=>{aD(e),a8(rs||void 0,rg||void 0,(e-1)*rh,ro||void 0,rm,{limit:rh},nn())},[aD,a8,rs,rg,rh,ro,rm,nn]),nf=(0,n.useCallback)(e=>{aP(e),aD(1),a8(rs||void 0,rg||void 0,0,ro||void 0,rm,{limit:e},nn())},[aP,aD,a8,rs,rg,ro,rm,nn]),nv=(0,n.useCallback)(()=>a8(rs||void 0,rg||void 0,0,ro||void 0,rm,{silent:!0,limit:rb()},nn()),[a8,rs,rg,ro,rm,rb,nn]),nw=(0,n.useCallback)(()=>a8(rs||void 0,rg||void 0,0,ro||void 0,rm,{limit:rb()},nn()),[a8,rs,rg,ro,rm,rb,nn]),nj=(0,n.useCallback)(e=>{var t,a,r,n;rH(null!=(t=e.filter_combine)?t:"and"),rL(!!e.sourceExclude),rF(!!e.stageExclude),rD(!!e.locationExclude),rP(!!e.employeeExclude),rR(!!e.industryExclude),rz(!!e.tagsExclude),rJ(!!e.contactOwnerExclude),rK(!!e.starred),rQ(!1!==e.exclude_role_emails),rY(null!=(a=e.channel)?a:""),rZ(null!=(r=e.linkedin_reachable)?r:""),e.no_contact?r0("never"):e.no_contact_days?(r0("days"),r5(e.no_contact_days)):r0("any"),ap(e.source),ab(e.stage),av(e.location),aj(e.employee_range),ak(e.industry),a_(null!=(n=e.tags)?n:""),aE(e.contact_owner||""),aL(e.sort),aF(e.search),nl(e)},[nl,ap,ab,av,aj,ak,a_,aE,aL,aF]),nN=(0,n.useCallback)(()=>{rH("and"),rL(!1),rF(!1),rD(!1),rP(!1),rR(!1),rz(!1),rJ(!1),ap(""),ab(""),av(""),aj(""),ak(""),a_(""),aE(""),aL("created_at"),aF(""),rK(!1),rQ(!0),rY(""),rZ(""),r0("any"),r5(7
1),nl({source:"",stage:"",location:"",employee_range:"",industry:"",contact_owner:"",sort:"created_at",search:"",exclude_role_emails:!0}),re(null)},[nl,ap,ab,av,aj,ak,a_,aE,aL,aF,re]),nk=null!=(tH=e.onSourceFilterChange)?tH:nc,nC=(0,n.useCallback)(e=>{rZ(e),aD(1)},[aD]),n_=null!=(tG=e.onStageFilterChange)?tG:nd,nS=null!=(tK=e.onLocationFilterChange)?tK:nu,nE=null!=(tV=e.onEmployeeFilterChange)?tV:nm,nA=null!=(tQ=e.onIndustryFilterChange)?tQ:ng,nL=(0,n.useCallback)(e=>{rL(e),ns({sourceExclude:e})},[ns]),nI=(0,n.useCallback)(e=>{rF(e),ns({stageExclude:e})},[ns]),nF=(0,n.useCallback)(e=>{rD(e),ns({locationExclude:e})},[ns]),nT=(0,n.useCallback)(e=>{rP(e),ns({employeeExclude:e})},[ns]),nD=(0,n.useCallback)(e=>{rR(e),ns({industryExclude:e})},[ns]),nO=(0,n.useCallback)(e=>{rz(e),ns({tagsExclude:e})},[ns]),nP=(0,n.useCallback)(e=>{rJ(e),ns({contactOwnerExclude:e})},[ns]),nM=null!=(tW=e.onSourceExcludeChange)?tW:nL,nR=null!=(tY=e.onStageExcludeChange)?tY:nI,nU=null!=(t$=e.onLocationExcludeChange)?t$:nF,nz=null!=(tZ=e.onEmployeeExcludeChange)?tZ:nT,nq=null!=(tX=e.onIndustryExcludeChange)?tX:nD,nJ=null!=(t0=e.onTagsFilterChange)?t0:nx,nB=null!=(t1=e.onTagsExcludeChange)?t1:nO,nH=null!=(t5=e.onSortChange)?t5:np,nG=null!=(t2=e.onSearchChange)?t2:ny,nK=null!=(t3=e.onPageChange)?t3:nb,nV=null!=(t4=e.onEnriched)?t4:nv,nQ=null!=(t7=e.onLeadsUpdated)?t7:nw,nW=null!=(t6=e.onSearch)?t6:nl,nY=null!=(t9=e.onApplySavedFilter)?t9:nj,n$=null!=(t8=e.onClearFilters)?t8:nN,[nZ,nX]=(0,n.useState)(!1),[n0,n1]=(0,n.useState)(eC);(0,n.useEffect)(()=>{try{let e=localStorage.getItem(e_);e&&n1(function(e){if(!Array.isArray(e))return eC;let t=e.filter(e=>eC.includes(e)),a=eC.filter(e=>!t.includes(e));return[...t,...a]}(JSON.parse(e)))}catch(e){}},[]);let n5=(0,n.useCallback)(e=>{n1(e);try{localStorage.setItem(e_,JSON.stringify(e))}catch(e){}},[]),n2=(0,$.FR)((0,$.MS)($.AN,{activationConstraint:{distance:5}})),n3=(0,n.useCallback)(e=>{let{active:t,over:a}=e;if(!a||t.id===a.id)return;let r=n0.indexOf(t.id),n=n0.indexOf(a.id);r<0||n<0||n5((0,Z.be)(n0,r,n))},[n0,n5]),n4=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!ae){n4.current=!1;return}if(n4.current)return;n4.current=!0;let e=!1;return(async()=>{try{var t;let a=await fetch("/api/scorecard/leads/backfill-meeting-stage",{method:"POST"}),r=await a.json().catch(()=>({}));!e&&a.ok&&(null!=(t=r.promoted)?t:0)>0&&nQ()}catch(e){}})(),()=>{e=!0}},[ae,nQ]);let n7=(0,n.useCallback)(async()=>{sI(!0);try{var e,t,a,r,n;let l=await fetch("/api/scorecard/calendly-sync",{method:"POST"}),s=await l.json().catch(()=>({}));if(!1===s.connected){let e=await fetch("/api/apps/connect-toolkit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolkitSlug:"calendly"})}),t=await e.json().catch(()=>({}));if(t.redirectUrl){let e=t.redirectUrl;(0,o.o)("Connect your Calendly account",{description:"Opens Calendly login in a new tab. After approving, click Calendly again to sync your meetings.",duration:3e4,action:{label:"Open Calendly login",onClick:()=>window.open(e,"_blank","noopener,noreferrer")}})}else o.o.error(t.message||t.error||"Couldn't start Calendly connection.");return}if(!l.ok||s.error)return void o.o.error(s.error||"Calendly sync failed");let i=(null!=(e=s.updatedPast)?e:0)+(null!=(t=s.updatedNext)?t:0)+(null!=(a=s.clearedNext)?a:0),c=s.teamWide?" (team-wide)":"";if(i>0){let e=[];s.updatedNext&&e.push("".concat(s.updatedNext," upcoming")),s.updatedPast&&e.push("".concat(s.updatedPast," recent")),s.promoted&&e.push("".concat(s.promoted," → Demo"));let t=e.length?" (".concat(e.join(", "),")"):"";o.o.success("Calendly synced".concat(c," — updated ").concat(i," lead").concat(1===i?"":"s").concat(t,".")),nQ()}else{let e=(null!=(r=s.scannedPast)?r:0)+(null!=(n=s.scannedFuture)?n:0);o.o.success("Calendly synced".concat(c," — scanned ").concat(e," meeting").concat(1===e?"":"s",", nothing new to update."))}}catch(e){o.o.error(e instanceof Error?e.message:"Calendly sync failed")}finally{sI(!1)}},[nQ]),[n6,n9]=(0,n.useState)(!1),n8=(0,n.useCallback)(async()=>{n9(!0);try{var e,t,a,r,n;
1let l=await fetch("/api/scorecard/google-calendar-sync",{method:"POST"}),s=await l.json().catch(()=>({}));if(!1===s.connected){let e=await fetch("/api/apps/connect-toolkit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolkitSlug:"googlecalendar"})}),t=await e.json().catch(()=>({}));if(t.redirectUrl){let e=t.redirectUrl;(0,o.o)("Connect your Google Calendar",{description:"Opens Google sign-in in a new tab. After approving, click Google Calendar again to sync your meetings.",duration:3e4,action:{label:"Open Google sign-in",onClick:()=>window.open(e,"_blank","noopener,noreferrer")}})}else o.o.error(t.message||t.error||"Couldn't start Google Calendar connection.");return}if(!l.ok||s.error)return void o.o.error(s.error||"Google Calendar sync failed");let i=(null!=(e=s.updatedPast)?e:0)+(null!=(t=s.updatedNext)?t:0)+(null!=(a=s.clearedNext)?a:0);if(i>0){let e=[];s.updatedNext&&e.push("".concat(s.updatedNext," upcoming")),s.updatedPast&&e.push("".concat(s.updatedPast," recent")),s.promoted&&e.push("".concat(s.promoted," → Demo"));let t=e.length?" (".concat(e.join(", "),")"):"";o.o.success("Google Calendar synced — updated ".concat(i," lead").concat(1===i?"":"s").concat(t,".")),nQ()}else o.o.success("Google Calendar synced — scanned ".concat(null!=(r=s.totalEvents)?r:0," event").concat((null!=(n=s.totalEvents)?n:0)===1?"":"s",", nothing new to update."))}catch(e){o.o.error(e instanceof Error?e.message:"Google Calendar sync failed")}finally{n9(!1)}},[nQ]),[le,lt]=(0,n.useState)([]),[la,lr]=(0,n.useState)(!1),[ln,ll]=(0,n.use
1State)(!1),[ls,lo]=(0,n.useState)(!1),li=(0,n.useRef)(""),[lc,ld]=(0,n.useState)(!1),[lu,lm]=(0,n.useState)(!1),[lg,lx]=(0,n.useState)("idle"),lh=(0,n.useRef)(!1),lp=(0,n.useRef)(null),ly=(0,n.useRef)(null),[lb,lf]=(0,n.useState)(null),[lv,lw]=(0,n.useState)(null),[lj,lN]=(0,n.useState)(null),[lk,lC]=(0,n.useState)(0),[l_,lS]=(0,n.useState)(2e3),lE=(0,n.useRef)([]),lA=(0,n.useRef)(null),[lL,lI]=(0,n.useState)(null),[lF,lT]=(0,n.useState)(!1),[lD,lO]=(0,n.useState)(!1),[lP,lM]=(0,n.useState)([]),[lR,lU]=(0,n.useState)(null),[lz,lq]=(0,n.useState)(eL),[lJ,lB]=(0,n.useState)(eD),[lH,lG]=(0,n.useState)(eR),[lK,lV]=(0,n.useState)(!1),[lQ,lW]=(0,n.useState)(!1),[lY,l$]=(0,n.useState)(!1),[lZ,lX]=(0,n.useState)(!1),[l0,l1]=(0,n.useState)(!1),[l5,l2]=(0,n.useState)(!1),[l3,l4]=(0,n.useState)(!1),[l7,l6]=(0,n.useState)({name:"",email:"",company:"",title:""}),[l9,l8]=(0,n.useState)(""),[se,st]=(0,n.useState)(!1),[sa,sr]=(0,n.useState)([]),[sn,sl]=(0,n.useState)(0),[ss,so]=(0,n.useState)(null),[si,sc]=(0,n.useState)(null),[sd,su]=(0,n.useState)([]),[sm,sg]=(0,n.useState)({}),[sx,sh]=(0,n.useState)("new"),[sp,sy]=(0,n.useState)("none"),[sb,sf]=(0,n.useState)(""),[sv,sw]=(0,n.useState)(""),[sj,sN]=(0,n.useState)([]),[sk,sC]=(0,n.useState)(""),[s_,sS]=(0,n.useState)(null),[sE,sA]=(0,n.useState)(null),[sL,sI]=(0,n.useState)(!1),[sF,sT]=(0,n.useState)(null),[sD,sO]=(0,n.use
1State)("asc"),[sP,sM]=(0,n.useState)("leads"),sR=(0,n.useRef)(!1),[sU,sz]=(0,n.useState)(null!=ar?ar:"table");(0,n.useEffect)(()=>{if(ae&&ar){let e=ry.current&&rp.current!==ar;rp.current=ar,sz(ar),null==an||an(ar),e&&nW(na())}ry.current=ae},[ae,ar]);let[sq,sJ]=(0,n.useState)(new Set),[sB,sH]=(0,n.useState)(!1),[sG,sK]=(0,n.useState)(!1),[sV,sQ]=(0,n.useState)(null);(0,n.useCallback)(async()=>{if(0!==sq.size){sK(!0);try{let e=Array.from(sq).join(","),t=await fetch("/api/scorecard/leads/".concat(e),{method:"DELETE"}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed to delete");o.o.success("Deleted ".concat(a.deleted," lead").concat(1!==a.deleted?"s":"")),sJ(new Set),sH(!1),null==nQ||nQ()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to delete leads")}finally{sK(!1)}}},[sq,nQ]);let[sW,sY]=(0,n.useState)(!1),[s$,sZ]=(0,n.useState)(!1),[sX,s0]=(0,n.useState)(""),s1=(0,n.useCallback)(async e=>{let t=rr.map(e=>e.id).filter(e=>!!e);if(0===t.length)return;let a="unassigned"===e?null:e,r=a?rt.find(e=>{var t;return(null!=(t=e.email)?t:e.member_id)===a}):null,n=null===a?"Unassigned":(null==r?void 0:r.name)||(null==r?void 0:r.email)||a;if(!window.confirm("Assign ".concat(t.length," lead").concat(1===t.length?"":"s"," on this page to ").concat(n,"?")))return;sY(!0);let l=null==au?void 0:au.setLeadsData;if(l){let e=new Set(t);l(t=>t?{...t,leads:t.leads.map(t=>{let r=t.id;return r&&e.has(r)?{...t,contact_owner:a}:t})}:t)}let s=await Promise.allSettled(t.map(e=>fetch("/api/scorecard/leads/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({contact_owner:a})}).then(e=>{if(!e.ok)throw Error("Failed")}))),i=s.filter(e=>"fulfilled"===e.status).length,c=s.length-i;if(0===c)o.o.success("Assigned ".concat(i," lead").concat(1===i?"":"s"," to ").concat(n));else{o.o.error("Assigned ".concat(i,"/").concat(s.length,"; ").concat(c," failed"));let e=a9.current;a8(rs||void 0,rg||void 0,"kanban"===rp.current||"funnel"===rp.current?0:(rx-1)*rh,ro||void 0,rm,{limit:rb()},{location:e.location||void 0,employee_range:e.employee_range||void 0,industry:e.industry||void 0,tags:e.tags||void 0,contact_owner:e.contact_owner||void 0})}sY(!1)},[rr,au,rt,a8,a9,rs,rg,rx,rh,ro,rm,rb]),[s5,s2]=(0,n.useState)(null),[s3,s4]=(0,n.use
1State)(!1),s7=(0,n.useRef)(!0),[s6,s9]=(0,n.useState)(null),[s8,oe]=(0,n.useState)(null),ot=n.useRef(null),oa=n.useRef([]),or=n.useRef(null),on=n.useRef(null),ol=n.useRef(null),os=n.useRef(null),[oo,oi]=(0,n.useState)(!1),[oc,od]=(0,n.useState)("light"),ou="dark"===oc;(0,n.useEffect)(()=>{let e=localStorage.getItem("app-theme");("dark"===e||"light"===e)&&od(e);let t=e=>{od(e.detail.theme)};return window.addEventListener("themeChanged",t),()=>window.removeEventListener("themeChanged",t)},[]),(0,n.useEffect)(()=>{var e;ae||(rK(!1),rQ(!0),rY(""),r3(!1),oi(!1),s7.current=!0,lh.current=!1,null==(e=lp.current)||e.abort(),ly.current=null,lE.current=[],lx("idle"),lf(null),lI(null),lw(null),lN(null))},[ae]),(0,n.useEffect)(()=>{if(!ae)return;let e=setTimeout(()=>nW(na()),0);return()=>clearTimeout(e)},[ae]),(0,n.useEffect)(()=>{ae&&(lt((0,ex.L6)()),(0,ex.RI)().then(e=>{e.length>0&&lt(t=>{let a=new Set(e.map(e=>e.label));return[...e,...t.filter(e=>!a.has(e.label))]})}))},[ae]),(0,n.useEffect)(()=>{ae&&fetch("/api/scorecard/icp-criteria").then(e=>e.ok?e.json():null).then(e=>{s4(!!(null==e?void 0:e.has_workspace_icp))}).catch(()=>s4(!1))},[ae]),(0,n.useEffect)(()=>(lq(eL),eI.add(lq),()=>{eI.delete(lq)}),[]),(0,n.useEffect)(()=>(lB(eD),eO.add(lB),()=>{eO.delete(lB)}),[]),(0,n.useEffect)(()=>(lG(eR),eU.add(lG),()=>{eU.delete(lG)}),[]),(0,n.useEffect)(()=>{let e=e=>{ln&&or.current&&!or.current.contains(e.target)&&(ll(!1),lo(!1)),lK&&on.current&&!on.current.contains(e.target)&&lV(!1),lQ&&ol.current&&!ol.current.contains(e.target)&&lW(!1),oo&&os.current&&!os.current.contains(e.target)&&oi(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ln,lK,lQ,oo]);let om=(0,n.useCallback)(e=>{if("last_meeting"===e)return void("last_meeting"!==sF?(sT("last_meeting"),sO("desc"),nH("last_meeting")):"desc"===sD?(sO("asc"),nH("last_meeting_asc")):(sT(null),nH("created_at")));sF===e?sO(e=>"asc"===e?"desc":"asc"):(sT(e),sO("asc"))},[sF,sD,nH]);(0,n.useEffect)(()=>{if(!ae)return;if(s7.current){s7.current=!1;return}let e=setTimeout(()=>{ns({starred:rG||void 0,exclude_role_emails:rV||void 0})},50);return()=>clearTimeout(e)},[rG,rV,ae,ns]),(0,n.useEffect)(()=>{let e=e=>{r2&&r4.current&&!r4.current.contains(e.target)&&r3(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r2]);let og=(0,n.useMemo)(()=>{let e=rV?rr.filter(e=>!(0,eu.Xx)(e.email)):rr;return("linkedin"===rW?e=e.filter(e=>{var t;return(null!=(t=e.linkedin_url)?t:"").toLowerCase().includes("linkedin.com/in/")||(0,em.G_)(e.email)}):"email"===rW&&(e=e.filter(e=>{var t;return(null==(t=e.email)?void 0:t.includes("@"))&&!(0,em.G_)(e.email)})),r$&&(e=e.filter(e=>{var t;let a=null!=(t=e.linkedin_reachable_by)?t:[];return"me"===r$?!!rC&&a.includes(rC):"team"===r$?a.length>0:(0,em.G_)(e.email)&&0===a.length})),sF)?[...e].sort((e,t)=>{let a="",r="";switch(sF){case"name":a=[e.first_name,e.last_name].filter(Boolean).join(" ").toLowerCase(),r=[t.first_name,t.last_name].filter(Boolean).join(" ").toLowerCase();break;case"company":a=(e.company||"").toLowerCase(),r=(t.company||"").toLowerCase();break;case"stage":a=(e.stage||"new").toLowerCase(),r=(t.stage||"new").toLowerCase();break;case"lead_score":var n,l;a=null!=(n=e.lead_score)?n:0,r=null!=(l=t.lead_score)?l:0;break;case"source":a=(Array.isArray(e.sources)&&e.sources[0]||e.source||"").toLowerCase(),r=(Array.isArray(t.sources)&&t.sources[0]||t.source||"").toLowerCase();break;case"created_at":a=e.created_at||"",r=t.created_at||"";break;case"last_meeting":{let a=e=>{var t;let a=null!=(t=e.next_meeting_at)?t:e.last_meeting_at;return a?new Date(a).getTime():null},r=a(e),n=a(t);if(null===r&&null===n)return 0;if(null===r)return 1;if(null===n)return -1;return"asc"===sD?r-n:n-r}}if("number"==typeof a&&"number"==typeof r)return"asc"===sD?a-r:r-a;let s=String(a).localeCompare(String(r));return"asc"===sD?s:-s}):e},[rr,sF,sD,rV,rW,r$,rC]),ox=(0,n.useMemo)(()=>"p".concat(rx,":").concat(og.map(e=>e.id).join(",")),[rx,og]);(0,n.useEffect)(()=>{var e;let t=ly.current;t&&t.pageKey!==ox&&(ly.current=null,lh.current=!1,null==(e=lp.current)||e.abort(),lx("idle"),lf(null),lI(null),lw(null),lN(null))},[ox]);let oh=(0,n.useMemo)(()=>
1{if(rn<=0||"table"!==sU)return null;let e=(rx-1)*rh+1,t=Math.min(rx*rh,rn);return"Showing ".concat(e.toLocaleString(),"–").concat(t.toLocaleString()," of ").concat(rn.toLocaleString()," leads")},[rn,sU,rx,rh]),op=(0,n.useMemo)(()=>(0,ex.AB)(na()),[na]),oy=(0,n.useCallback)(async e=>{lV(!1),l$(!0);try{let t=("filtered"===e?function(e){var t,a,r,n,l,s,o,i;let c=new URLSearchParams;return(null==(t=e.source)?void 0:t.trim())&&c.set("source",e.source.trim()),(null==(a=e.stage)?void 0:a.trim())&&c.set("stage",e.stage.trim()),(null==(r=e.location)?void 0:r.trim())&&c.set("location",e.location.trim()),(null==(n=e.employee_range)?void 0:n.trim())&&c.set("employee_range",e.employee_range.trim()),(null==(l=e.industry)?void 0:l.trim())&&c.set("industry",e.industry.trim()),(null==(s=e.contact_owner)?void 0:s.trim())&&c.set("contact_owner",e.contact_owner.trim()),(null==(o=e.tags)?void 0:o.trim())&&c.set("tags",e.tags.trim()),(null==(i=e.search)?void 0:i.trim())&&c.set("search",e.search.trim()),e.sort&&c.set("sort",e.sort),e.sourceExclude&&c.set("source_exclude","true"),e.stageExclude&&c.set("stage_exclude","true"),e.locationExclude&&c.set("location_exclude","true"),e.employeeExclude&&c.set("employee_exclude","true"),e.industryExclude&&c.set("industry_exclude","true"),e.tagsExclude&&c.set("tags_exclude","true"),e.contactOwnerExclude&&c.set("contact_owner_exclude","true"),e.starred&&c.set("starred","true"),e.exclude_role_emails&&c.set("exclude_role_emails","true"),"or"===e.filter_combine&&c.set("filter_combine","or"),e.channel&&c.set("channel",e.channel),e.linkedin_reachable&&c.set("linkedin_reachable",e.linkedin_reachable),e.no_contact&&c.set("no_contact","true"),e.no_contact_days&&c.set("no_contact_days",String(e.no_contact_days)),c}(na()):new URLSearchParams).toString(),a=await fetch("/api/scorecard/leads/export".concat(t?"?".concat(t):""));if(!a.ok){let e=await a.json().catch(()=>({}));throw Error((null==e?void 0:e.error)||"Export failed")}let r=await a.blob(),n=URL.createObjectURL(r),l=document.createElement("a");l.href=n,l.download="leads-".concat(new Date().toISOString().slice(0,10),".csv"),document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(n),o.o.success("Leads exported")}catch(e){o.o.error(e instanceof Error?e.message:"Export failed")}finally{l$(!1)}},[na]),ob=(0,n.useCallback)(()=>{let e=na();(0,ex.AB)(e)?(re(e),o.o.success("Leads filters applied to inbox")):re(null),at()},[na,re,at]),of=(0,n.useCallback)(()=>{var e,t,a,r,n,l,s,i;let c=li.current.trim();if(!c)return void o.o.error("Enter a name for this filter");let d=na();if(!((null==(e=d.source)?void 0:e.trim())||(null==(t=d.stage)?void 0:t.trim())||(null==(a=d.location)?void 0:a.trim())||(null==(r=d.employee_range)?void 0:r.trim())||(null==(n=d.industry)?void 0:n.trim())||(null==(l=d.contact_owner)?void 0:l.trim())||(null==(s=d.tags)?void 0:s.trim())||(null==(i=d.search)?void 0:i.trim())||d.starred||d.exclude_role_emails||d.no_contact||d.no_contact_days))return void o.o.error("Set at least one filter (source, stage, contact owner, etc.) before saving");lt([...le,{id:crypto.randomUUID(),label:c,filters:d}]),fetch("/api/scorecard/saved-filters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:c,filters:d})}).catch(e=>{console.warn("[LeadsTableModal] Failed to persist saved filter:",e)}),li.current="",lo(!1),o.o.success('Saved "'.concat(c,'"'))},[na,le]),ov=(0,n.useCallback)(e=>{var t,a,r;rK(!!e.filters.starred),e.filters.no_contact?r0("never"):e.filters.no_contact_days?(r0("days"),r5(e.filters.no_contact_days)):r0("any"),rQ((0,ex.JV)(e.filters,e.label)),rL(!!e.filters.sourceExclude),rF(!!e.filters.stageExclude),rD(!!e.filters.locationExclude),rP(!!e.filters.employeeExclude),rR(!!e.filters.industryExclude),rz(!!e.filters.tagsExclude),rJ(!!e.filters.contactOwnerExclude),rH(null!=(t=e.filters.filter_combine)?t:"and"),rY(null!=(a=e.filters.channel)?a:""),rZ(null!=(r=e.filters.linkedin_reachable)?r:""),s2(e.label),null==nY||nY(e.filters),ll(!1)},[nY]),ow=(0,n.useCallback)(e=>{lt(t=>t.filter(t=>
1t.id!==e)),fetch("/api/scorecard/saved-filters?id=".concat(encodeURIComponent(e)),{method:"DELETE"}).catch(e=>{console.warn("[LeadsTableModal] Failed to delete saved filter on server:",e)}),ll(!1)},[]),[oj,oN]=(0,n.useState)(null),[ok,oC]=(0,n.useState)(""),o_=(0,n.useCallback)(e=>{let t=na();lt(a=>a.map(a=>a.id===e?{...a,filters:t}:a)),o.o.success("Filter updated")},[na]),oS=(0,n.useCallback)((e,t)=>{let a=t.trim();a&&(lt(t=>t.map(t=>t.id===e?{...t,label:a}:t)),oN(null),oC(""),o.o.success("Filter renamed"))},[]),oE=(0,n.useCallback)(async()=>{ld(!0);let e="score-leads-progress";try{var t,a,r,n,l,s,i,c,d;o.o.loading("Starting scoring...",{id:e,duration:1/0});let u=await fetch("/api/scorecard/score-leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({location:ri||void 0,employee_range:rc||void 0,industry:rd||void 0})});if(!u.ok){let e=await u.json().catch(()=>({}));throw Error(e.error||"Failed to score leads")}let m=null==(t=u.body)?void 0:t.getReader(),g=new TextDecoder,x="",h=!1;if(m)for(;;){let{done:t,value:u}=await m.read();if(t)break;let p=(x+=g.decode(u,{stream:!0})).split("\n");for(let t of(x=null!=(a=p.pop())?a:"",p))if(t.trim())try{let a=JSON.parse(t);if("start"===a.type){let t=(h=!!a.usedWorkspaceIcp)?" (saved workspace ICP)":"",r=0===a.total?"No leads to score":"Scoring ".concat(a.total," leads").concat(t,"...");o.o.loading(r,{id:e,duration:1/0})}else if("progress"===a.type){let t=Math.round((null!=(r=a.current)?r:0)/(null!=(n=a.total)?n:1)*100),l=a.company||a.leadName||"",s="number"==typeof a.score?" → ".concat(a.score):"";o.o.loading("Scoring: ".concat(a.current,"/").concat(a.total," (").concat(t,"%)").concat(l?" - ".concat(l).concat(s):""),{id:e,duration:1/0})}else if("done"===a.type){let t=null!=(l=a.updated)?l:0,r=null!=(s=a.highScoreCount)?s:0,n=null!=(i=a.mediumScoreCount)?i:0,d=null!=(c=a.lowScoreCount)?c:0;if(t>0){let a=h?" (using saved workspace ICP)":"";o.o.success("Scored ".concat(t," leads: ").concat(r," high (70+), ").concat(n," medium (40-69), ").concat(d," low (0-39)").concat(a),{id:e,duration:5e3})}else a.message?o.o.success(a.message,{id:e,duration:5e3}):o.o.success("No leads to score",{id:e,duration:5e3});null==nQ||nQ()}else if("error"===a.type)throw Error(null!=(d=a.error)?d:"Scoring failed")}catch(e){if(e instanceof SyntaxError)continue;throw e}}}catch(t){o.o.error(t instanceof Error?t.message:"Failed to score leads",{id:e,duration:5e3})}finally{ld(!1)}},[ri,rc,rd,nQ]),oA=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/credits/usage?feature=enrichment&period=monthly");if(e.ok){let t=await e.json();if(!t.allowed&&"Free"===t.tier)return void(0,o.o)("Monthly enrichment limit reached (".concat(t.used,"/").concat(t.limit,"). Upgrade for unlimited."),{icon:"⭐",action:{label:"See Plans",onClick:()=>window.open("/#pricing","_blank")},duration:6e3})}}catch(e){console.warn("[LeadsTableModal] Enrichment gate check failed; allowing through:",e)}eB(nQ)},[nQ]),oL=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/credits/usage?feature=enrichment&period=monthly");if(e.ok){let t=await e.json();if(!t.allowed&&"Free"===t.tier)return void(0,o.o)("Monthly enrichment limit reached (".concat(t.used,"/").concat(t.limit,"). Upgrade for unlimited."),{icon:"⭐",action:{label:"See Plans",onClick:()=>window.open("/#pricing","_blank")},duration:6e3})}}catch(e){console.warn("[LeadsTableModal] LinkedIn enrichment gate check failed; allowing through:",e)}eJ(nQ)},[nQ]),oI=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/credits/usage?feature=enrichment&period=monthly");if(e.ok){let t=await e.json();if(!t.allowed&&"Free"===t.tier)return void(0,o.o)("Monthly enrichment limit reached (".concat(t.used,"/").concat(t.limit,"). Upgrade for unlimited."),{icon:"⭐",action:{label:"See Plans",onClick:()=>window.open("/#pricing","_blank")},duration:6e3})}}catch(e){console.warn("[LeadsTableModal] LinkedIn Clay enrichment gate check failed; allowing through:",e)}eq(nQ)},[nQ]),oF=(0,n.useCallback)(async e=>{lm(!0);let t="qualify-leads-progress";try{var a,r,n,l,s,i,c;o.o.loading("Starting qualification...",{id:t,duration:1/0});
1let d=await fetch("/api/scorecard/qualify-leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({location:ri||void 0,employee_range:rc||void 0,industry:rd||void 0,linkedin_only:null!=e&&e})});if(!d.ok){let e=await d.json().catch(()=>({}));throw Error(e.error||"Failed to qualify leads")}let u=null==(a=d.body)?void 0:a.getReader(),m=new TextDecoder,g="";if(u)for(;;){let{done:a,value:d}=await u.read();if(a)break;let x=(g+=m.decode(d,{stream:!0})).split("\n");for(let a of(g=null!=(r=x.pop())?r:"",x))if(a.trim())try{let r=JSON.parse(a);if("start"===r.type){let e=0===r.total?"Checking ".concat(r.checked," leads against ICP..."):"Found ".concat(r.total," leads to qualify (").concat(null!=(n=r.alreadyQualified)?n:0," already qualified)");o.o.loading(e,{id:t,duration:1/0})}else if("progress"===r.type){let e=Math.round((null!=(l=r.current)?l:0)/(null!=(s=r.total)?s:1)*100),a=r.company||r.leadName||"";o.o.loading("Qualifying: ".concat(r.current,"/").concat(r.total," (").concat(e,"%)").concat(a?" - ".concat(a):""),{id:t,duration:1/0})}else if("done"===r.type){let a=null!=(i=r.updated)?i:0;a>0?o.o.success(e?"Tagged ".concat(a," LinkedIn leads as Qualified"):"Tagged ".concat(a," leads as Qualified"),{id:t,duration:5e3}):r.message?o.o.success(r.message,{id:t,duration:5e3}):o.o.success("No new leads to qualify",{id:t,duration:5e3}),null==nQ||nQ()}else if("error"===r.type)throw Error(null!=(c=r.error)?c:"Qualification failed")}catch(e){if(e instanceof SyntaxError)continue;throw e}}}catch(e){o.o.error(e instanceof Error?e.message:"Failed to qualify leads",{id:t,duration:5e3})}finally{lm(!1)}},[ri,rc,rd,nQ]),oT=(0,n.useCallback)(async()=>{let e=le.find(e=>(0,ex.U1)(e)),t=(null==e?void 0:e.filters)?{location:e.filters.location||void 0,employee_range:e.filters.employee_range||void 0,industry:e.filters.industry||void 0}:void 0,a=e=>!(null==e?void 0:e.location)&&!(null==e?void 0:e.employee_range)&&!(null==e?void 0:e.industry)&&!(null==e?void 0:e.title);if(a(t)&&(ri||rc||rd)&&(t={location:ri||void 0,employee_range:rc||void 0,industry:rd||void 0}),a(t)){let e=await fetch("/api/scorecard/icp-criteria"),a=await e.json().catch(()=>({}));e.ok&&a.has_workspace_icp&&a.filters&&(t={location:a.filters.location||void 0,employee_range:a.filters.employee_range||void 0,industry:a.filters.industry||void 0,title:a.filters.title||void 0})}return t},[le,ri,rc,rd]),oD=(0,n.useCallback)(async e=>{let t=async e=>{let t=0;for(;t<e;){if(lh.current)return!0;await new Promise(a=>{setTimeout(a,Math.min(50,e-t))}),t+=50}return!1},a=async e=>{var t,a,r,n,l,s,o,i;let c=null==(t=e.body)?void 0:t.getReader();if(!c){let t=await e.json();return{enriched:null!=(a=t.enriched)?a:0,qualified:null!=(r=t.qualified)?r:0}}let d=new TextDecoder,u="",m=0,g=0;for(;;){if(lh.current)throw c.cancel().catch(()=>void 0),new DOMException("Enrich paused","AbortError");let{done:e,value:t}=await c.read();if(e)break;let a=(u+=d.decode(t,{stream:!0})).split("\n");for(let e of(u=null!=(n=a.pop())?n:"",a))if(e.trim())try{let t=JSON.parse(e);if("progress"===t.type){if("processing"===t.status&&"number"==typeof t.current){let e=null!=(l=lE.current[t.current-1])?l:null;lf(e)}}else if("done"===t.type)m=null!=(s=t.enriched)?s:m,g=null!=(o=t.qualified)?o:g;else if("error"===t.type)throw Error(null!=(i=t.error)?i:"Enrichment failed")}catch(e){if(!(e instanceof SyntaxError))throw e}}return{enriched:m,qualified:g}};lh.current=!1,lx("running");let r=ly.current;if(!e||!r||r.pageKey!==ox){let e=og.map(e=>{var t;let a=(e.linkedin_url||"").trim();if(!a.includes("linkedin.com/in/"))return null;let r=[e.first_name,e.last_name].filter(Boolean).join(" ").trim()||(null==(t=e.email)?void 0:t.split("@")[0])||"Contact";return{leadId:e.id,profileUrl:a,name:r}}).filter(e=>!!e);if(0===e.length){o.o.error("No LinkedIn profiles in this list. Add linkedin.com/in/ URLs or filter to LinkedIn leads."),lx("idle");return}let t=e.slice(0,30);e.length>30&&(0,o.o)("Processing first 30 of ".concat(e.length," LinkedIn leads in this view"),{duration:4e3});let a=await oT();ly.current=r={pageKey:ox,batchSlice:t,nextIndex:0,totalEnriched:0,enrichIndex:0,qualificationCriteria:null!=a?a:null}}if(!r)return void lx("idle");let n=r;lE.current=n.batchSlice.map(e=>e.leadId);try{var l,s,i;for(let e=n.nextIndex;e<n.batchSlice.length;e++){if(lh.current){n.nextIndex=e,ly.current=n,lx("paused"),lf(null),lI(null),lw(null),lN(null);return}n.nextIndex=e,ly.current=n;let r=n.batchSlice[e],s=og.find(e=>e.id===r.leadId),o=!!(s&&function(e){var t,a,r,n,l;
1let s=(null!=(t=e.company)?t:"").trim(),o=(null!=(a=e.company_employee_range)?a:"").trim();return!!s&&!!o&&(!!(null!=(r=e.company_location)?r:"").trim()||!!(null!=(n=e.company_categories)?n:"").trim()||!!(null!=(l=e.title)?l:"").trim())}(s));lI(null),lC(e=>e+1),lf(r.leadId),lw(r.leadId),lN("progress"),lS(o?2e3:8e3);let i=async()=>{lf(null),lN("sonar");let e=await t(1500);return e||(lI(null),lw(null),lN(null)),e};if(o){if(await t(2e3)){n.nextIndex=e,ly.current=n,lx("paused"),lf(null),lI(null),lw(null),lN(null);return}if(await i()){n.nextIndex=e+1,ly.current=n,lx("paused"),lI(null),lw(null),lN(null);return}n.nextIndex=e+1;continue}lp.current=new AbortController;try{let t=await fetch("/api/scorecard/enrich-linkedin-conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profiles:[{profileUrl:r.profileUrl,name:r.name}],qualification_criteria:null!=(l=n.qualificationCriteria)?l:void 0,skip_qualify:!0}),signal:lp.current.signal});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"Failed to enrich")}let s=await a(t);n.totalEnriched+=s.enriched,n.enrichIndex+=1,n.nextIndex=e+1}catch(t){if(t instanceof DOMException&&"AbortError"===t.name){n.nextIndex=e,ly.current=n,lx("paused"),lf(null),lI(null),lw(null),lN(null);return}throw t}finally{lp.current=null}if(await i()){n.nextIndex=e+1,ly.current=n,lx("paused"),lI(null),lw(null),lN(null);return}}let e=n.qualificationCriteria,r=0;if(((null==e?void 0:e.location)||(null==e?void 0:e.employee_range)||(null==e?void 0:e.industry)||(null==e?void 0:e.title))&&n.totalEnriched>0){let t=await fetch("/api/scorecard/qualify-leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({location:null==e?void 0:e.location,employee_range:null==e?void 0:e.employee_range,industry:null==e?void 0:e.industry,title:null==e?void 0:e.title,linkedin_only:!0}),signal:null==(s=lp.current)?void 0:s.signal});if(t.ok&&t.body){let e=t.body.getReader(),a=new TextDecoder,n="";for(;;){let{done:t,value:l}=await e.read();if(t)break;let s=(n+=a.decode(l,{stream:!0})).split("\n");for(let e of(n=null!=(i=s.pop())?i:"",s))if(e.trim())try{let t=JSON.parse(e);"done"===t.type&&"number"==typeof t.updated&&(r=t.updated)}catch(e){}}}}0===n.enrichIndex?o.o.success("All visible LinkedIn leads are already enriched"):o.o.success(r>0?"Done: ".concat(n.totalEnriched," enriched, ").concat(r," qualified"):"Done: ".concat(n.totalEnriched," enriched")),null==nQ||nQ(),nW(na()),ly.current=null}catch(e){e instanceof DOMException&&"AbortError"===e.name||o.o.error(e instanceof Error?e.message:"Failed to enrich and qualify leads"),ly.current=null}finally{lh.current||(lf(null),lI(null),lw(null),lN(null),lE.current=[],lx("idle"))}},[ox,og,oT,nQ,nW,na]),oO=(0,n.useCallback)(()=>{if("running"===lg){var e;lh.current=!0,null==(e=lp.current)||e.abort(),lx("paused"),lf(null),lI(null),lw(null),lN(null);return}oD("paused"===lg)},[lg,oD]),oP=(0,n.useCallback)(()=>{let e=lA.current;if(!e||!lv)return void lI(null);let t=e.querySelector('tr[data-lead-id="'.concat(lv,'"]'));if(!t)return void lI(null);let a=t.getBoundingClientRect(),r=e.getBoundingClientRect();lI({leadId:lv,top:a.top-r.top+e.scrollTop,left:a.left-r.left+e.scrollLeft,width:a.width,height:a.height})},[lv]);(0,n.useLayoutEffect)(()=>{if(!lv||"table"!==sU)return void lI(null);oP();let e=lA.current;if(!e)return;let t=()=>oP();e.addEventListener("scroll",t,{passive:!0}),window.addEventListener("resize",t);let a=new ResizeObserver(t);return a.observe(e),()=>{e.removeEventListener("scroll",t),window.removeEventListener("resize",t),a.disconnect()}},[lv,sU,oP,og]);let oM=!!lv&&!!lj&&(null==lL?void 0:lL.leadId)===lv,[oR,oU]=(0,n.useState)(!1),[oz,oq]=(0,n.useState)(!1),oJ=(0,n.useCallback)(async e=>{for(let n=0;n<40;n++){var t,a,r;let n;await new Promise(e=>setTimeout(e,6e3));try{let a=await fetch("/api/scorecard/enrich-jobs");n=(null!=(t=(await a.json()).jobs)?t:[]).find(t=>t.id===e)}catch(e){continue}if(n){if("completed"===n.status){o.o.success((null==(a=n.result)?void 0:a.message)||"Background enrichment complete"),nW(na());return}if("failed"===n.status)return void o.o.error((null==(r=n.result)?void 0:r.message)||"Backgroun
1d enrichment failed");nW(na())}}},[nW,na]),oB=(0,n.useCallback)(async()=>{oU(!0);try{let e=await fetch("/api/scorecard/enrich-jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({job_type:"enrich_qualify"})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to queue job");o.o.success(t.reused?"A background enrichment is already running — you can safely close this page.":"Queued! Enriching in the background — safe to close this page. Click Refresh to see results."),oJ(t.job_id)}catch(e){o.o.error(e instanceof Error?e.message:"Failed to queue background job")}finally{oU(!1)}},[oJ]),oH=(0,n.useCallback)(async()=>{oq(!0);try{nW(na());try{var e,t,a;let r=await fetch("/api/scorecard/enrich-jobs?status=queued,processing"),n=(null!=(e=(await r.json()).jobs)?e:[])[0];n&&(null!=(t=n.total)?t:0)>0&&(0,o.o)("Background enrichment: ".concat(null!=(a=n.processed)?a:0,"/").concat(n.total," leads processed"))}catch(e){}}finally{setTimeout(()=>oq(!1),600)}},[nW,na]),oG=(0,n.useCallback)(async()=>{let e=new Set(["gmail.com","yahoo.com","hotmail.com","outlook.com","icloud.com","aol.com","live.com","proton.me","protonmail.com","inbox.upgraded"]),t=new Set,a=[];for(let n of og){var r;let l=(null==(r=n.email)?void 0:r.includes("@"))?n.email.split("@")[1]:"",s=(n.company_domain||l||"").toLowerCase().trim(),o=(n.company||"").trim();if(s&&e.has(s))continue;let i=s||o.toLowerCase();if(!(!i||t.has(i))&&(t.add(i),a.push({company_name:o||void 0,domain:s||void 0}),a.length>=200))break}if(0===a.length)return void o.o.error("No companies in the current view to search.");try{let e=await fetch("/api/scorecard/enrich-jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({job_type:"reverse_enrich",params:{targets:a}})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to queue");o.o.success(t.reused?"Already finding decision-makers in the background.":"Finding marketing decision-makers at ".concat(a.length," compan").concat(1===a.length?"y":"ies"," — running in the background. Click Refresh to see new leads.")),oJ(t.job_id)}catch(e){o.o.error(e instanceof Error?e.message:"Failed to queue decision-maker search")}},[og,oJ]),oK="w-full text-[12px] border rounded-lg px-3 py-2 focus:ring-1 focus:outline-none transition-all ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200 placeholder:text-gray-500 focus:ring-gray-600 focus:border-gray-500":"border-gray-200 bg-white text-gray-900 placeholder:text-gray-400 focus:ring-gray-300 focus:border-gray-300"),oV=(0,n.useCallback)(async()=>{let e=l7.name.trim(),t=l7.email.trim();if(!t||!t.includes("@"))return void o.o.error("Enter a valid email address.");let a=e.split(/\s+/).filter(Boolean),r=a[0]||void 0,n=a.length>1?a.slice(1).join(" "):void 0;l4(!0);try{let a=await fetch("/api/scorecard/leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,first_name:r,last_name:n,company:l7.company.trim()||void 0,title:l7.title.trim()||void 0})}),l=await a.json();if(!a.ok)throw Error(l.error||"Failed to add lead");o.o.success("Added ".concat(e||t)),l6({name:"",email:"",company:"",title:""}),l2(!1),nW(na()),null==nQ||nQ()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to add lead")}finally{l4(!1)}},[l7,nW,na,nQ]),oQ=!!(ri||rc||rd)||s3,oW=ou?"group flex flex-1 items-center gap-2 text-left text-[11px] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 text-gray-200 hover:text-white":"group flex flex-1 items-center gap-2 text-left text-[11px] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 text-gray-900 hover:text-black",oY="text-[10px] truncate text-gray-500",o$="flex items-center gap-1 px-2.5 py-2 rounded-lg transition-colors ".concat(ou?"hover:bg-white/5":"hover:bg-gray-100/80"),oZ="w-full flex items-center gap-2 px-2.5 py-2 text-[11px] font-medium rounded-lg transition-colors cursor-pointer border-0",oX=ou?"bg-transparent text-gray-300 hover:bg-white/5":"bg-transparent text-gray-700 hover:bg-gray-100",o0=ou?"bg-gray-700 text-white shadow-sm":"bg-gray-900 text-white shadow-sm",o1="w-full inline-flex items-center gap-2 text-[10px] px-2.5 py-2 rounded-lg font-medium transition-all cursor-pointer disabled:opacity-60 disabled:cursor-wait ".concat(ou?"bg-white/5 text-gray-300 hover:bg-white/10":"bg-gray-900/[0.04] text-gray-700 hover:bg-gray-900/[0.07]"),o5="inline-flex items-center justify-center gap-1.5 h-9 px-3 rounded-xl text-[11px] font-medium leading-none transition-all shrink-0",o2="".concat(o5," border cursor-pointer shadow-sm hover:shadow ").concat(ou?"border-white/10 bg-gray-700/80 text-gray-200 hover:bg-gray-700":"border-gray-200/70 bg-white text-gray-700 hover:bg-gray-50"),o3="".concat(o5," border cursor-pointer shadow-sm ").concat(ou?"border-white/15 bg-gray-600 text-white":"border-gray-300/70 bg-gray-100 text-gray-900"),o4="".concat(o5," font-bold text-white cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ").concat(ou?"bg-indigo-500 hover:bg-indigo-400 shadow-[0_3px_0_0_#3730a3] active:shadow-[0_1px_0_0_#3730a3]":"bg-indigo-600 hover:bg-indigo-500 shadow-[0_3px_0_0_#3730a3] active:shadow-[0_1px_0_0_#3730a3]"," active:translate-y-[2px] disabled:shadow-none disabled:translate-y-0"),o7="inline-flex items-center justify-center h-9 w-9 rounded-xl border cursor-pointer transition-all shadow-sm hover:shadow shrink-0 ".concat(ou?"border-white/10 bg-gray-700/80 text-gray-200 hover:bg-gray-700":"border-gray-200/70 bg-white text-gray-600 hover:bg-gray-50 hover:text-gray-900"),o6="inline-flex items-center justify-center h-9 w-9 rounded-xl border cursor-pointer transition-all shadow-sm shrink-0 ".concat(ou?"border-white/15 bg-gray-600 text-white":"border-gray-300/70 bg-gray-100 text-gray-900"),o9="h-9 text-[11px] rounded-full pl-8 pr-3 leading-none border border-transparent focus:outline-none transition-all ".concat(ou?"bg-gray-700/70 text-gray-200 placeholder:text-gray-500 focus:bg-gray-700 focus:border-white/15":"bg-gray-100/80 text-gray-900 placeholder:text-gray-400 focus:bg-white focus:border-gray-200 focus:shadow-sm"),o8="overflow-hidden rounded-2xl border py-1.5 shadow-lg ring-1 ".concat(ou?"border-white/10 bg-gray-800 ring-black/40":"border-gray-100 bg-white ring-black/[0.03]"),ie="flex w-full items-center gap-2.5 px-3 py-2 text-left text-[11px] cursor-pointer rounded-lg transition-colors ".concat(ou?"text-gray-200 hover:bg-white/5":"text-gray-900 hover:bg-gray-100/80"),it="px-3 pt-2 pb-1 text-[9px] font-semibold uppercase tracking-wider ".concat(ou?"text-gray-500":"text-gray-400"),ia="my-1 mx-2 border-t ".concat(ou?"border-white/10":"border-gray-100"),ir=(0,n.useCallback)(async()=>{try{var e,t,a,r,n,l,s,i,c;
1let d=await fetch("/api/scorecard/icp-criteria"),u=await d.json().catch(()=>({}));if(!d.ok)throw Error(u.error||"Failed to load workspace ICP");let m=!1;if(!u.has_workspace_icp){let e=null!=(r=null==ri?void 0:ri.trim())?r:"",t=null!=(n=null==rc?void 0:rc.trim())?n:"",a=null!=(l=null==rd?void 0:rd.trim())?l:"";if(!e&&!t&&!a)return void o.o.error("No workspace ICP saved yet. Set one or more of Location, Company size, or Industry in the filters, then click again — we will save those values as your workspace ICP and apply them.",{duration:7500});let s=await fetch("/api/scorecard/icp-criteria",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({location:e,employee_range:t,industry:a})}),i=await s.json().catch(()=>({}));if(!s.ok)throw Error(i.error||"Failed to save workspace ICP");if(s4(!0),m=!0,d=await fetch("/api/scorecard/icp-criteria"),u=await d.json().catch(()=>({})),!d.ok)throw Error(u.error||"Failed to reload workspace ICP")}let g=null!=(s=null==(e=u.filters)?void 0:e.location)?s:"",x=null!=(i=null==(t=u.filters)?void 0:t.employee_range)?i:"",h=null!=(c=null==(a=u.filters)?void 0:a.industry)?c:"";av(g),aj(x),ak(h),aD(1),s2("Workspace ICP"),await a8(rs||void 0,rg||void 0,0,ro||void 0,rm,{limit:rb()},{location:g||void 0,employee_range:x||void 0,industry:h||void 0,tags:ru||void 0,contact_owner:aS||void 0,starred:rG||void 0,exclude_role_emails:rV||void 0,no_contact:"never"===rX||void 0,no_contact_days:"days"===rX?r1:void 0,source_exclude:rA||void 0,stage_exclude:rI||void 0,location_exclude:rT||void 0,employee_exclude:rO||void 0,industry_exclude:rM||void 0}),o.o.success(m?"Saved workspace ICP from your filters and applied it":"Applied workspace ICP to filters")}catch(e){o.o.error(e instanceof Error?e.message:"Could not apply workspace ICP")}},[a8,rs,rg,ro,rm,ru,aS,rG,rV,rX,r1,rA,rI,rT,rO,rM,ri,rc,rd,av,aj,ak,aD,rb]),il=(0,n.useCallback)(async()=>{lT(!0);let e="classify-sentiment-progress";try{var t,a,r,n,l,s,i,c;o.o.loading("Analyzing conversations...",{id:e,duration:1/0});let d=await fetch("/api/scorecard/bulk-tag-leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:rs||void 0,stage:ro||void 0,search:rg||void 0,location:ri||void 0,employee_range:rc||void 0,industry:rd||void 0})});if(!d.ok){let e=await d.json().catch(()=>({}));throw Error(e.error||"Failed to classify leads")}let u=null==(t=d.body)?void 0:t.getReader(),m=new TextDecoder,g="";if(u)for(;;){let{done:t,value:d}=await u.read();if(t)break;let x=(g+=m.decode(d,{stream:!0})).split("\n");for(let t of(g=null!=(a=x.pop())?a:"",x))if(t.trim())try{let a=JSON.parse(t);if("start"===a.type){let t=0===a.total?"Checking ".concat(a.checked," leads..."):"Classifying ".concat(a.total," leads (").concat(null!=(r=a.alreadyTagged)?r:0," already classified)");o.o.loading(t,{id:e,duration:1/0})}else if("progress"===a.type){let t=Math.round((null!=(n=a.current)?n:0)/(null!=(l=a.total)?l:1)*100),r=a.leadName||a.company||"",s=a.sentiment?" → ".concat(a.sentiment):"";o.o.loading("Classifying: ".concat(a.current,"/").concat(a.total," (").concat(t,"%)").concat(r?" - ".concat(r):"").concat(s),{id:e,duration:1/0})}else if("done"===a.type){let t=null!=(s=a.classified)?s:0,r=null!=(i=a.skippedNoConvo)?i:0;t>0?o.o.success("Classified ".concat(t," leads").concat(r>0?" (".concat(r," skipped — no conversation)"):""),{id:e,duration:5e3}):a.message?o.o.success(a.message,{id:e,duration:5e3}):o.o.success("No new leads to classify",{id:e,duration:5e3}),null==nQ||nQ()}else if("error"===a.type)throw Error(null!=(c=a.error)?c:"Classification failed")}catch(e){if(e instanceof SyntaxError)continue;throw e}}}catch(t){o.o.error(t instanceof Error?t.message:"Failed to classify leads",{id:e,duration:5e3})}finally{lT(!1)}},[rs,ro,rg,ri,rc,rd,nQ]),is=(0,n.useCallback)(async()=>{try{var e;let t=await fetch("/api/inbox/sequences");if(!t.ok)return;let a=await t.json();lM((null!=(e=a.sequences)?e:[]).filter(e=>e.is_active).map(e=>({id:e.id,name:e.name})))}catch(e){console.warn("[LeadsTableModal] Failed to load active sequences:",e)}},[]),io=(0,n.useCallback)(async e=>{lU(e);try{let t=rr.map(e=>e.id);if(0===t.length)return void o.o.error("No leads to enroll");
1let a=await fetch("/api/inbox/sequences/".concat(e,"/enroll"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lead_ids:t})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||"Failed to enroll")}let r=await a.json();o.o.success("Enrolled ".concat(r.enrolled," leads").concat(r.skipped>0?" (".concat(r.skipped," already enrolled)"):""))}catch(e){o.o.error(e instanceof Error?e.message:"Failed to enroll leads")}finally{lU(null),lO(!1),lV(!1)}},[rr]),ii=(0,n.useCallback)(()=>{sc(null),l8(""),sr([]),sl(0),so(null),su([]),sg({}),sh("new"),sy("none"),sf(""),sw(""),sN([]),sC(""),oa.current=[],ot.current&&(ot.current.value="")},[]),ic=(0,n.useCallback)(e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];if(!a)return;sc(a),l8(a.name.replace(/\.csv$/i,""));let r=new FileReader;r.onload=e=>{var t;let a=null==(t=e.target)?void 0:t.result,{headers:r,rows:n}=(0,ec.Wk)(a);oa.current=n,su(r),sg((0,ec.Bz)(r)),sl(n.length),sr(n.slice(0,5))},r.readAsText(a)},[]),id=(0,n.useCallback)(async()=>{if(si){if("new"===sp&&!l9.trim())return void o.o.error("Name your new list, or pick a different source");if("existing"===sp&&!sb)return void o.o.error("Pick a source for these leads");st(!0),so(null);try{let e=(0,ec.HN)(oa.current,sm);if(0===e.length)throw Error("No importable rows — check your column mapping");let t=l9.trim(),a="new"===sp?{listName:t}:"existing"===sp?{sourceId:sb}:{sourceId:"none"},r=await (0,ec.E4)(e,{...a,stage:sx,contactOwner:sv||void 0,tags:sj.length?sj:void 0,onProgress:(e,t)=>so({done:e,total:t})}),n=(0,ec.MM)(r);if(r.failed>0?o.o.warning("Imported ".concat(n,". Some rows failed — try again.")):o.o.success("Imported ".concat(n)),"new"===sp&&r.listId){ne&&ne(t).catch(e=>console.warn("[LeadsTableModal] add custom source failed:",e));try{await fetch("/api/scorecard/saved-filters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:"List: ".concat(t),filters:{source:r.listId,stage:"",location:"",employee_range:"",industry:"",sort:"created_at",search:""}})})}catch(e){console.warn("[LeadsTableModal] Failed to auto-create saved filter for new list:",e)}}r.listId&&"none"!==r.listId&&(nk(r.listId),nW()),lX(!1),ii(),null==nQ||nQ()}catch(e){o.o.error(e instanceof Error?e.message:"Failed to import leads")}finally{st(!1),so(null)}}},[si,l9,sp,sb,sm,sx,sv,sj,ii,ne,nk,nW,nQ]);(0,n.useEffect)(()=>{ae&&!sR.current&&(sR.current=!0,(0,ex.hh)().catch(e=>console.warn("[LeadsTableModal] migrate saved filters to DB failed:",e)))},[ae]);let iu="page"===aa;if(!ae&&!iu)return null;let im=(0,r.jsx)("div",{className:iu?"flex h-full min-h-0 w-full flex-col":"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/30 backdrop-blur-md",onClick:iu?void 0:ob,children:(0,r.jsx)("div",{"data-tour":"agent-leads-table",className:"flex w-full flex-col overflow-hidden ".concat(iu?"h-full min-h-0":"h-[90vh] max-w-[95vw] rounded-2xl shadow-2xl ring-1"," ").concat(ou?iu?"bg-gray-900":"bg-gray-900 ring-white/10 shadow-black/60":iu?"bg-[#FAFAF9]":"bg-[#FAFAF9] ring-black/[0.04] shadow-gray-900/10"),onClick:e=>e.stopPropagation(),children:(0,r.jsxs)("div",{className:"flex flex-1 flex-col min-h-0 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0 px-4 py-2.5 sticky top-0 z-20 backdrop-blur-md ".concat(ou?"bg-gray-900/70":"bg-white/60"),children:[(0,r.jsx)("div",{className:"inline-flex items-center gap-0.5 p-1 rounded-full shadow-sm ring-1 shrink-0 ".concat(ou?"bg-gray-800/80 ring-white/10":"bg-gray-100/90 ring-black/[0.03]"),children:[{id:"leads",label:"Leads"},{id:"kb",label:"Knowledge Base"},{id:"templates",label:"Templates"},{id:"filters",label:"Saved Filters"}].map(e=>{let t=sP===e.id;return(0,r.jsx)("button",{type:"button",onClick:()=>sM(e.id),className:"px-3 py-1 text-[11px] rounded-full transition-all whitespace-nowrap cursor-pointer ".concat(t?ou?"bg-gray-700 text-white font-semibold shadow-md shadow-black/30":"bg-white text-gray-900 font-semibold shadow-md shadow-gray-900/10":ou?"text-gray-400 font-medium hover:text-gray-200":"text-gray-500 font-medium hover:text-gray-800"),children:e.label},e.id)})}),"leads"===sP&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full shrink-0 tabular-nums ".concat(ou?"text-gray-200 bg-white/10":"text-gray-700 bg-gray-900/[0.06]"),children:rn.toLocaleStr
1ing()}),(0,r.jsx)("div",{"data-tour":"agent-leads-views",className:"flex items-center gap-0.5 p-1 rounded-xl shrink-0 ".concat(ou?"bg-white/5":"bg-gray-100"),children:[{id:"table",icon:b.A},{id:"kanban",icon:f.A},{id:"funnel",icon:v.A}].map(e=>{let{id:t,icon:a}=e;return(0,r.jsx)("button",{type:"button",onClick:()=>{t!==sU&&(rp.current=t,sz(t),null==an||an(t),nW(na()))},className:"flex items-center justify-center h-7 w-8 rounded-lg transition-all cursor-pointer ".concat(sU===t?ou?"bg-gray-700 text-white shadow-sm":"bg-white text-gray-900 shadow-sm":ou?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),title:"".concat(t.charAt(0).toUpperCase()+t.slice(1)," view"),children:(0,r.jsx)(a,{className:"w-3.5 h-3.5"})},t)})}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative shrink-0","data-tour":"agent-leads-search",children:[(0,r.jsx)(w.A,{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 ".concat(ou?"text-gray-500":"text-gray-400")}),(0,r.jsx)("input",{type:"search",placeholder:"Search leads…",value:rg,onChange:e=>nG(e.target.value),onKeyDown:e=>"Enter"===e.key&&nW(na()),className:"".concat(o9," w-56"),"aria-label":"Search leads by name, email, company"})]}),(0,r.jsxs)("div",{className:"relative shrink-0",ref:os,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>oi(e=>!e),className:oo||"created_at"!==rm?o3:o2,title:"lead_score"===rm?"Sorted by lead score":"last_meeting"===rm||"last_meeting_asc"===rm?"Sorted by meetings":"Sorted by newest",children:[(0,r.jsxs)("span",{className:"inline-flex flex-col leading-none -space-y-0.5","aria-hidden":!0,children:[(0,r.jsx)(c.A,{className:"w-2.5 h-2.5"}),(0,r.jsx)(d.A,{className:"w-2.5 h-2.5"})]}),"Sort"]}),oo&&(0,r.jsx)("div",{className:"absolute right-0 top-full mt-2 z-[60] w-40 px-1.5 ".concat(o8),children:[{value:"created_at",label:"Newest"},{value:"lead_score",label:"Lead Score"},{value:"last_meeting",label:"Meetings"}].map(e=>{let t="last_meeting"===e.value?"last_meeting"===rm||"last_meeting_asc"===rm:rm===e.value;return(0,r.jsxs)("button",{type:"button",onClick:()=>{nH(e.value),oi(!1)},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left text-[11px] rounded-lg cursor-pointer transition-colors ".concat(t?ou?"text-indigo-300 bg-indigo-500/15 font-semibold":"text-indigo-700 bg-indigo-50 font-semibold":ou?"text-gray-200 hover:bg-white/5":"text-gray-900 hover:bg-gray-100/80"),children:[t&&(0,r.jsx)(g.A,{className:"w-3 h-3 shrink-0"}),(0,r.jsx)("span",{className:t?"":"pl-5",children:e.label})]},e.value)})})]}),(0,r.jsxs)("div",{className:"relative shrink-0",ref:on,children:[(0,r.jsx)("button",{type:"button","data-tour":"agent-leads-more",onClick:()=>lV(e=>!e),className:lK?o6:o7,title:"More actions — refresh, export, enrich, qualify, sequences","aria-label":"More actions","aria-expanded":lK,children:oz||lY?(0,r.jsx)(m.A,{className:"w-4 h-4 shrink-0 animate-spin"}):(0,r.jsx)(j.A,{className:"w-5 h-5 shrink-0"})}),lK&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 z-[60] w-64 px-1.5 rounded-2xl border py-1.5 shadow-lg ring-1 ".concat(ou?"border-white/10 bg-gray-800 ring-black/40":"border-gray-100 bg-white ring-black/[0.03]"),children:[(0,r.jsx)("div",{className:o$,children:(0,r.jsxs)("button",{type:"button",onClick:()=>{oH(),lV(!1)},disabled:oz,className:oW,title:"Reload the latest saved leads from the database (and any background enrichment progress)",children:[(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 shrink-0 ".concat(oz?"animate-spin":"")}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(et.L,{reserve:"Refreshing…",align:"start",children:oz?"Refreshing…":"Refresh"}),(0,r.jsx)("p",{className:oY,children:"Pull the latest saved leads"})]})]})}),(0,r.jsx)("div",{className:ia}),(0,r.jsx)("p",{className:it,children:"Export"}),(0,r.jsx)("div",{className:o$,children:(0,r.jsxs)("button",{type:"button",onClick:()=>{oy("filtered")},disabled:lY,className:oW,children:[(0,r.jsx)(N.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(et.L,{reserve:"Export filtered leads",align:"start",children:lY?"Exporting…":"Export filtered leads"}),(0,r.jsxs)("p",{className:oY,children:["Matches current filters",rn?" (".concat(rn.toLocaleStr
1ing(),")"):""]})]})]})}),(0,r.jsx)("div",{className:o$,children:(0,r.jsxs)("button",{type:"button",onClick:()=>{oy("all")},disabled:lY,className:oW,children:[(0,r.jsx)(b.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Export all leads"}),(0,r.jsx)("p",{className:oY,children:"Every lead, ignoring filters"})]})]})}),(0,r.jsx)("div",{className:ia}),(0,r.jsx)("p",{className:it,children:"Bulk actions"}),rS&&(lz.active?(0,r.jsx)("div",{className:o$,children:(0,r.jsxs)("button",{type:"button",onClick:()=>{eL.abortController&&eL.abortController.abort(),lV(!1)},className:oW,children:[(0,r.jsx)(p.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("span",{children:["Cancel (",lz.current,"/",lz.total,")"]}),(0,r.jsx)("p",{className:oY,children:lz.lastCompany||lz.lastDomain||"Processing..."})]})]})}):(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{oA(),lV(!1)},disabled:lJ.active||lH.active,className:oW,children:[(0,r.jsx)(m.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Enrich All"}),(0,r.jsx)("p",{className:oY,children:"Company data via work email domains"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["Fetches company info (size, industry, location) from Attio using work-email domains. Skips gmail-style addresses and ",(0,r.jsx)("code",{className:"text-[9px]",children:"@inbox.upgraded"})," placeholders — for those, use ",(0,r.jsx)("strong",{children:"Enrich LinkedIn"})," below or Inbox → Enrich & Qualify. Requires Attio."]})]})),rS&&(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{oB(),lV(!1)},disabled:oR,className:oW,children:[(0,r.jsx)(k.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Enrich & Qualify in background"}),(0,r.jsx)("p",{className:oY,children:"Runs server-side — safe to close this page"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["Queues a server-side job that enriches company data (Attio) for every lead with a work-email domain, then tags & stages your ICP matches as ",(0,r.jsx)("strong",{children:"Qualified"})," — autosaving row-by-row. You can close the Leads page and it keeps running; click ",(0,r.jsx)("strong",{children:"Refresh"})," to pull the latest results."]})]}),(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{oG(),lV(!1)},className:oW,children:[(0,r.jsx)(k.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Find marketing decision-makers"}),(0,r.jsx)("p",{className:oY,children:"Top marketing exec per company (reverse enrichment)"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["For each company in the current view, finds the highest-ranking marketing leader — ",(0,r.jsx)("strong",{children:"CMO → VP Marketing → Director → Head of PR"})," — via Apollo and saves them as a new lead. Runs in the background; click ",(0,r.jsx)("strong",{children:"Refresh"})," to see the new contacts. Requires Apollo."]})]}),lJ.active?(0,r.jsx)("div",{className:o$,children:(0,r.jsxs)("button",{type:"button",onClick:()=>{eD.abortController&&eD.abortController.abort(),lV(!1)},className:oW,children:[(0,r.jsx)(p.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("span",{children:["Cancel LinkedIn (",lJ.current,"/",lJ.total,")"]}),(0,r.jsx)("p",{className:oY,children:lJ.lastName||"Processing..."})]})]})}):(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",disabled:lz.active||lH.active,onClick:()=>{oL(),lV(!1)},className:oW,children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 shrink-0",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:(0,r.jsx)("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Enrich LinkedIn"}),(0,r.jsx)("p",{className:oY,children:"All eligible \xb7 40/request \xb7 max 2000"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["Fetches person and company fields from LinkedIn (Unipile) or Apollo using each lead's profile URL. When Unipile exposes a public vanity URL, the lead is updated so you see ",(0,r.jsx)("code",{className:"text-[9px]",children:"[email protected]"})," instead of the ACoAA id. Leads that already have a company size band are skipped so the same contact is not re-enriched. ",(0,r.jsx)("strong",{children:"One click"})," chains batches (40 per request, up to 50 batches / 2000 contacts) until the queue is drained or limits are hit."]})]}),lH.active?(0,r.jsx)("div",{className:o$,children:(0,r.jsxs)("button",{type:"button",onClick:()=>{eR.abortController&&eR.abortController.abort(),lV(!1)},className:oW,children:[(0,r.jsx)(p.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("span",{children:["Cancel Clay (",lH.current,"/",lH.total,")"]}),(0,r.jsx)("p",{className:oY,children:lH.lastName||"Processing..."})]})]})}):(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",disabled:lz.active||lJ.active,onClick:()=>{oI(),lV(!1)},className:oW,children:[(0,r.jsx)("span",{className:"text-[10px] font-semibold shrink-0 leading-none","aria-hidden":!0,
1children:"C"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Enrich LinkedIn (Clay)"}),(0,r.jsx)("p",{className:oY,children:"All eligible \xb7 20/request \xb7 max 500"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["Sends each lead's ",(0,r.jsx)("strong",{children:"public"})," LinkedIn URL to your Clay webhook (set ",(0,r.jsx)("code",{className:"text-[9px]",children:"CLAY_LINKEDIN_ENRICH_WEBHOOK_URL"}),"). Internal ACoAA URLs are resolved via Unipile first when connected. ",(0,r.jsx)("strong",{children:"One click"})," chains batches until eligible leads are done or limits are hit (50 batches / 500 contacts). Skips rows already marked Clay-enriched and rows that already have company size."]})]}),(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{oE(),lV(!1)},disabled:lc||!oQ,className:oW,children:[lc?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,r.jsx)(k.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Score leads"}),(0,r.jsx)("p",{className:oY,children:"Rank by filter match (0-100)"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["Scores each lead 0-100 based on how well they match your ICP filters (location, company size, industry). ",!oQ&&(0,r.jsx)("strong",{className:ou?"text-gray-400":"text-gray-600",children:'Set filters below, save workspace ICP on your scorecard, or use "Apply workspace ICP" in the sidebar.'})]})]}),(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{oF(!1),lV(!1)},disabled:lu||!oQ,className:oW,children:[lu?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,r.jsx)(C.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Qualify leads"}),(0,r.jsx)("p",{className:oY,children:"Tag + stage Qualified"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["Adds the Qualified tag and sets pipeline stage to Qualified for ICP matches. ",!oQ&&(0,r.jsx)("strong",{className:ou?"text-gray-400":"text-gray-600",children:"Set filters, configure workspace ICP, or apply it from the sidebar."})]})]}),(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{oF(!0),lV(!1)},disabled:lu||!oQ,className:oW,children:[lu?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,r.jsx)(C.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Qualify LinkedIn"}),(0,r.jsx)("p",{className:oY,children:"LinkedIn: tag + stage"})]})]}),(0,r.jsxs)(eN,{isDark:ou,children:["Same as Qualify, only leads with a LinkedIn URL. ",!oQ&&(0,r.jsx)("strong",{className:ou?"text-gray-400":"text-gray-600",children:"Set filters, workspace ICP, or apply from sidebar."})]})]}),(0,r.jsx)("div",{className:ia}),(0,r.jsxs)("div",{className:o$,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{il(),lV(!1)},disabled:lF,className:"".concat(oW," cursor-pointer"),children:[lF?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,r.jsx)(_.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Classify sentiment"}),(0,r.jsx)("p",{className:oY,children:"AI-tag leads by conversation tone"})]})]}),(0,r.jsx)(eN,{isDark:ou,children:"Uses AI to analyze conversation tone and auto-tags leads as positive, neutral, or negative sentiment. Always available."})]}),(0,r.jsxs)("div",{className:"relative ".concat(o$),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{lD||is(),lO(e=>!e)},className:"".concat(oW," cursor-pointer"),children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75Z"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:"Add to Sequence"}),(0,r.jsx)("p",{className:oY,children:"Enroll filtered leads"})]}),(0,r.jsx)(S.A,{className:"w-3 h-3 opacity-50"})]}),lD&&(0,r.jsx)("div",{className:"absolute right-full top-0 mr-1.5 z-[70] w-48 px-1.5 ".concat(o8),children:0===lP.length?(0,r.jsx)("p",{className:"px-2.5 py-2 text-[11px] ".concat(ou?"text-gray-500":"text-gray-400"),children:"No sequences yet"}):lP.map(e=>(0,r.jsxs)("button",{type:"button",disabled:lR===e.id,onClick:()=>io(e.id),className:"".concat(ie," disabled:opacity-50"),children:[lR===e.id?(0,r.jsx)(m.A,{className:"w-3 h-3 animate-spin"}):(0,r.jsx)("span",{className:"w-3 h-3 flex items-center justify-center text-[8px]",children:"⚡"}),(0,r.jsx)("span",{className:"truncate",children:e.name})]},e.id))})]}),ac&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:ia}),(0,r.jsx)("div",{className:o$,children:(0,r.jsxs)("button",{type:"button",onClick:()=>{lr(e=>!e),lV(!1)},className:oW,children:[(0,r.jsx)(E.A,{className:"w-3.5 h-3.5"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{children:la?"Hide debug":"Debug mode"}),(0,r.jsx)("p",{className:oY,children:"View raw lead data"})]})]})})]})]})]}),(0,r.jsxs)("div",{className:"relative shrink-0",ref:ol,children:[(0,r.jsxs)("button",{type:"button","data-tour":"agent-leads-add",onClick:()=>lW(e=>!e),className:lQ?o3:o2,title:"Add leads from a CSV or Apollo",children:[(0,r.jsx)(x.A,{className:"w-3.5 h-3.5 shrink-0"}),"Add Leads",(0,r.jsx)(d.A,{className:"w-3 h-3 shrink-0 transition-transform ".concat(lQ?"rotate-180":"")})]}),lQ&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 z-[60] w-56 px-1.5 ".concat(o8),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{lX(!0),lW(!1)},className:ie,children:[(0,r.jsx)(A.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"font-medium",children:"Upload CSV"}),(0,r.jsx)("p",{className:oY,children:"Import your contact list"})]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{l1(!0),lW(!1)},className:ie,children:[(0,r.jsx)(l.default,{src:(0,ei.j9)("apollo"),alt:"Apollo",width:14,height:14,className:"rounded-sm shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"font-medium",children:"Find with Apollo"}),(0,r.jsx)("p",{className:oY,children:"Search and import prospects"})]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{l2(!0),lW(!1)},className:ie,children:[(0,r.jsx)(x.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"font-medium",children:"Add one lead"}),(0,r.jsx)("p",{className:oY,children:"Enter a name & email manually"})]})]})]})]}),(0,r.jsx)("div",{className:"relative shrink-0",children:(0,r.jsxs)("button",{type:"button","data-tour":"agent-leads-e
1nrich",onClick:oO,disabled:"idle"===lg&&(lJ.active||lH.active||lz.active),className:o4,title:"running"===lg?"Pause enrichment on this page":"paused"===lg?"Resume enrichment from where you left off":"Enrich and qualify visible LinkedIn leads",children:["running"===lg?(0,r.jsx)(L.A,{className:"w-3.5 h-3.5 shrink-0"}):"paused"===lg?(0,r.jsx)(I.A,{className:"w-3.5 h-3.5 shrink-0"}):(0,r.jsx)(k.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)(et.L,{reserve:"Enrich & Qualify",children:"running"===lg?"Pause":"paused"===lg?"Resume":"Enrich & Qualify"})]})})]})]})]}),"leads"===sP&&(0,r.jsxs)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[(0,r.jsx)("div",{"data-tour":"agent-leads-filters",className:"w-52 shrink-0 overflow-y-auto ".concat(ou?"bg-white/[0.02]":"bg-gray-50/60"),children:(0,r.jsxs)("div",{className:"p-2.5 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1",children:[(0,r.jsx)("span",{className:"text-[9px] font-semibold uppercase tracking-wider leading-none ".concat(ou?"text-gray-500":"text-gray-400"),children:"Lead Filters"}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5 p-0.5 rounded-full shrink-0 ".concat(ou?"bg-white/5":"bg-gray-200/70"),children:[(0,r.jsx)("button",{type:"button",onClick:()=>{"and"!==rB&&(rH("and"),ns({filter_combine:"and"}))},className:"px-2 py-[3px] rounded-full text-[9px] leading-none font-semibold transition-all cursor-pointer ".concat("and"===rB?ou?"bg-gray-700 text-white shadow-sm":"bg-white text-gray-900 shadow-sm":ou?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),title:"Match every filter category (Location AND Industry AND …). Multiple selections within one filter use OR.",children:"All"}),(0,r.jsx)("button",{type:"button",onClick:()=>{"or"!==rB&&(rH("or"),ns({filter_combine:"or"}))},className:"px-2 py-[3px] rounded-full text-[9px] leading-none font-semibold transition-all cursor-pointer ".concat("or"===rB?ou?"bg-gray-700 text-white shadow-sm":"bg-white text-gray-900 shadow-sm":ou?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),title:"Match any filter category (Location OR Industry OR …). Multiple selections within one filter still use OR.",children:"Any"})]})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsxs)("div",{className:"relative flex-1 min-w-0",ref:or,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>ll(e=>!e),className:"w-full inline-flex items-center gap-1.5 text-[10px] px-2.5 py-2 rounded-lg font-medium transition-all cursor-pointer shadow-sm ".concat(s5?ou?"bg-indigo-500/20 text-indigo-200":"bg-indigo-50 text-indigo-800":ou?"bg-gray-800/70 text-gray-300 hover:bg-gray-700":"bg-white text-gray-700 hover:bg-gray-50"),children:[(0,r.jsx)(F.A,{className:"w-3 h-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:s5||(le.length>0?"Views (".concat(le.length,")"):"Views")}),(0,r.jsx)(d.A,{className:"w-3 h-3 ml-auto shrink-0"})]}),ln&&(0,r.jsx)("div",{className:"absolute left-0 top-full mt-1.5 z-20 w-56 px-1.5 ".concat(o8),children:0===le.length?(0,r.jsx)("p",{className:"px-2.5 py-2 text-[10px] ".concat(ou?"text-gray-400":"text-gray-500"),children:"No saved views yet"}):le.map(e=>(0,r.jsx)("div",{className:"group",children:oj===e.id?(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1",children:[(0,r.jsx)("input",{type:"text",value:ok,onChange:e=>oC(e.target.value),onKeyDown:t=>{"Enter"===t.key&&oS(e.id,ok),"Escape"===t.key&&(oN(null),oC(""))},className:"flex-1 text-[11px] border rounded px-2 py-1 ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200":"border-gray-300 bg-white text-gray-900"),autoFocus:!0}),(0,r.jsx)("button",{type:"button",onClick:()=>oS(e.id,ok),className:"text-[10px] px-1.5 py-1 rounded ".concat(ou?"bg-gray-600 text-gray-100":"bg-gray-900 text-white"),children:"Save"}),(0,r.jsx)("button",{type:"button",onClick:()=>{oN(null),oC("")},className:"text-[10px] px-1.5 py-1 rounded border ".concat(ou?"border-gray-600 text-gray-400":"border-gray-300 text-gray-600"),children:"Cancel"})]}):(0,r.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,r.jsxs)("button",{type:"button",className:"flex-1 px-2.5 py-1 text-left text-[10px] flex items-center gap-1.5 min-w-0 ".concat(ou?"text-gray-200 hover:bg-gray-700/80":"text-gray-800 hover:bg-gray-50"),onClick:()=>ov(e),children:[(0,r.jsx)("span",{className:"truncate",children:e.label}),(0,ex.U1)(e)&&(0,r.jsx)("span",{className:"shrink-0 rounded px-1 py-0.5 text-[9px] font-medium ".concat(ou?"bg-green-900/50 text-green-400":"bg-green-100 text-green-800"),title:"Used for Score/Qualify leads",children:"ICP"})]}),(0,r.jsx)("button",{type:"button",onClick:()=>o_(e.id),className:"p-1 rounded opacity-0 group-hover:opacity-100 ".concat(ou?"text-gray-500 hover:text-blue-400":"text-gray-400 hover:text-blue-600"),"aria-label":"Update view with current filters",title:"Update with current filters",children:(0,r.jsx)(F.A,{className:"w-3 h-3"})}),(0,r.jsx)("button",{type:"button",onClick:()=>{oN(e.id),oC(e.label)},className:"p-1 rounded opacity-0 group-hover:opacity-100 ".concat(ou?"text-gray-500 hover:text-gray-300":"text-gray-400 hover:text-gray-600"),"aria-label":"Rename view",title:"Rename",children:(0,r.jsx)(h.A,{className:"w-3 h-3"})}),(0,r.jsx)("button",{type:"button",onClick:()=>ow(e.id),className:"p-1 rounded opacity-0 group-hover:opacity-100 ".concat(ou?"text-gray-500 hover:text-red-400":"text-gray-400 hover:text-red-600"),"aria-label":"Delete view",title:"Delete",children:(0,r.jsx)(T.A,{className:"w-3 h-3"})})]})},e.id))})]}),!ls&&(0,r.jsx)("button",{type:"button",disabled:!op,onClick:()=>op&&lo(!0),title:op?"Save current filters as a view":"Set at least one filter to save a view",className:"shrink-0 inline-flex items-center justify-center w-7 h-[30px] rounded-lg border transition-all ".concat(op?ou?"border-gray-600 bg-gray-700 text-gray-300 hover:bg-gray-600 cursor-pointer":"border-gray-200 bg-white text-gray-600 hover:bg-gray-50 cursor-pointer":ou?"border-gray-700 bg-gray-800/50 text-gray-600 cursor-not-allowed opacity-60":"border-gray-200 bg-gray-100 text-gray-400 cursor-not-allowed opacity-60"),children:(0,r.jsx)(x.A,{className:"w-3.5 h-3.5"})})]}),ls&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("input",{type:"text",autoFocus:!0,placeholder:"View name...",defaultValue:"",onChange:e=>{li.current=e.target.value},onKeyDown:e=>{"Enter"===e.key&&of(),"Escape"===e.key&&lo(!1)},className:"flex-1 min-w-0 text-[10px] border rounded-lg px-2 py-1.5 focus:ring-1 focus:outline-none ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200 placeholder:text-gray-500 focus:ring-gray-500":"border-gray-200 bg-white text-gray-900 placeholder:text-gray-400 focus:ring-gray-300")}),(0,r.jsx)("button",{type:"button",onClick:of,className:"shrink-0 text-[10px] px-2 py-1.5 rounded-lg font-medium cursor-pointer ".concat(ou?"bg-gray-600 text-gray-100":"bg-gray-900 text-white"),children:"Save"}),(0,r.jsx)("button",{type:"button",onClick:()=>lo(!1),className:"shrink-0 inline-flex items-center justify-center w-7 rounded-lg border cursor-pointer ".concat(ou?"border-gray-600 text-gray-400":"border-gray-200 text-gray-600"),children:(0,r.jsx)(p.A,{className:"w-3 h-3"})})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{ir()},className:"w-full inline-flex items-center gap-1.5 text-[10px] px-2 py-1 rounded-lg transition-all cursor-pointer text-left ".concat(ou?"text-indigo-300 hover:bg-indigo-950/40":"text-indigo-700 hover:bg-indigo-50"),title:"Load workspace ICP from scorecard, or save your current Location / Company size / Industry filters as workspace ICP if none is saved yet",children:[(0,r.jsx)(k.A,{className:"w-3 h-3 shrink-0"}),(0,r.jsx)("span",{className:"leading-tight",children:"Apply workspace ICP"})]}),!s3&&(0,r.jsx)("p",{className:"text-[9px] px-2 leading-snug ".concat("text-gray-500"),children:"Set Location, size, or Industry, then apply to save as ICP."}),n$&&(0,r.jsx)("button",{type:"button",onClick:()=>
1{rK(!1),rQ(!0),r0("any"),r5(7),s2(null),n$()},className:"w-full text-[10px] px-2 py-1 rounded-lg font-medium transition-all cursor-pointer text-left ".concat(ou?"text-gray-400 hover:text-gray-200 hover:bg-gray-700":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"),children:"Clear all"})]})]}),(0,r.jsxs)("div",{className:"rounded-xl p-1 space-y-0.5 shadow-sm ring-1 ".concat(ou?"bg-gray-800/50 ring-white/5":"bg-white ring-black/[0.03]"),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>rK(!rG),className:"".concat(oZ," ").concat(rG?o0:oX),title:"Show only starred leads",children:[rG?(0,r.jsx)(U.A,{className:"w-3.5 h-3.5 text-amber-400 shrink-0"}):(0,r.jsx)(D.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:rG?"Starred only":"Starred"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>rQ(!rV),className:"".concat(oZ," ").concat(rV?o0:oX),title:"Hide shared inboxes like info@, sales@, accounting@, support@",children:[(0,r.jsx)(O.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:rV?"People only":"Hide role emails"})]}),(0,r.jsxs)("div",{className:"relative w-full",ref:r4,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>r3(e=>!e),className:"".concat(oZ," ").concat("any"!==rX?o0:oX),title:"Team-wide: 'Never contacted' means no one on your team has ever reached out. Counts outbound messages only, so a lead who emailed you and never got a reply still counts as never contacted.",children:[(0,r.jsx)(P.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)("span",{className:"flex-1 text-left truncate min-w-0",children:"never"===rX?"Never contacted":"days"===rX?"Not in ".concat(r1," days"):"Last contacted"}),(0,r.jsx)(d.A,{className:"w-3 h-3 shrink-0 transition-transform ".concat(r2?"rotate-180":"")})]}),r2&&(0,r.jsxs)("div",{className:"absolute left-0 top-full mt-1.5 z-20 w-full px-1.5 ".concat(o8),children:[[{key:"any",label:"Any"},{key:"never",label:"Never contacted"},{key:"d7",label:"Not in 7 days"},{key:"d30",label:"Not in 30 days"}].map(e=>{let t="any"===e.key&&"any"===rX||"never"===e.key&&"never"===rX||"d7"===e.key&&"days"===rX&&7===r1||"d30"===e.key&&"days"===rX&&30===r1;return(0,r.jsxs)("button",{type:"button",onClick:()=>{r3(!1),"any"===e.key?ni("any",r1):"never"===e.key?ni("never",r1):"d7"===e.key?ni("days",7):ni("days",30)},className:"w-full px-2 py-1.5 text-left text-[10px] flex items-center gap-1.5 rounded-lg cursor-pointer transition-colors ".concat(t?ou?"text-indigo-300 bg-indigo-500/15 font-semibold":"text-indigo-700 bg-indigo-50 font-semibold":ou?"text-gray-300 hover:bg-white/5":"text-gray-700 hover:bg-gray-100/80"),children:[t&&(0,r.jsx)(g.A,{className:"w-3 h-3 shrink-0"}),(0,r.jsx)("span",{className:t?"":"pl-[18px]",children:e.label})]},e.key)}),(0,r.jsx)("div",{className:"border-t my-0.5 ".concat(ou?"border-gray-700":"border-gray-100")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1",children:[(0,r.jsx)("span",{className:"text-[10px] ".concat(ou?"text-gray-400":"text-gray-500"),children:"Not in"}),(0,r.jsx)("input",{type:"number",min:1,max:3650,value:r1,onChange:e=>{let t=parseInt(e.target.value,10);ni("days",Number.isFinite(t)?Math.max(1,Math.min(3650,t)):1)},className:"w-12 rounded border px-1 py-0.5 text-[10px] ".concat(ou?"border-gray-600 bg-gray-900 text-gray-200":"border-gray-300 bg-white text-gray-800")}),(0,r.jsx)("span",{className:"text-[10px] ".concat(ou?"text-gray-400":"text-gray-500"),children:"days"})]})]})]}),(0,r.jsx)(eh.c,{variant:"sidebar",stacked:!0,placeholder:"Stage",options:rj.map(e=>({value:e,label:eK(e,rk)})),value:ro?ro.split(",").map(e=>e.trim()).filter(Boolean):[],onChange:e=>n_(e.join(",")),exclude:rI,onExcludeChange:nR,isDark:ou,addCustom:nt?{label:"Add custom stage…",placeholder:"Stage name (e.g. Negotiation)",onAdd:nt}:void 0}),(0,r.jsx)(eh.c,{variant:"sidebar",stacked:!0,placeholder:"Contact Owner",options:[{value:"unassigned",label:"Unassigned"},...eo.R.map(e=>({value:e,label:e})),...(()=>{let e=new Set(eo.R);return rt.filter(t=>{var a;let r=(null!=(a=t.name)?a:"").trim();return!r||!e.has(r)}).map(e=>{var t;return{value:null!=(t=e.email)?t:e.member_id,label:e.name||e.email||"Team member"}})})()],value:aS?aS.split(",").map(e=>
1e.trim()).filter(Boolean):[],onChange:e=>nh(e.join(",")),exclude:rq,onExcludeChange:nP,isDark:ou}),(0,r.jsx)(eh.c,{variant:"sidebar",stacked:!0,placeholder:"Source",options:rw.map(e=>({value:e,label:rN[e]||e})),value:rs?rs.split(",").map(e=>e.trim()).filter(Boolean):[],onChange:e=>nk(e.join(",")),exclude:rA,onExcludeChange:nM,searchable:!0,isDark:ou,addCustom:ne?{label:"Add custom source…",placeholder:"Source name (e.g. Eventbrite)",onAdd:ne}:void 0}),(0,r.jsx)(ep.J,{variant:"sidebar",stacked:!0,defaultValue:"",placeholder:"Channel",options:[{value:"",label:"All channels"},...em.Jd.map(e=>({value:e.value,label:e.label}))],value:rW,onChange:e=>no("email"===e||"linkedin"===e?e:""),getLabel:e=>{var t,a;return e?null!=(a=null==(t=em.Jd.find(t=>t.value===e))?void 0:t.label)?a:e:"All channels"},isDark:ou}),(0,r.jsx)(eh.c,{variant:"sidebar",stacked:!0,placeholder:"Location",options:eV,value:ri?ri.split(",").map(e=>e.trim()).filter(Boolean):[],onChange:e=>null==nS?void 0:nS(e.join(",")),exclude:rT,onExcludeChange:nU,grouped:!0,searchable:!0,isDark:ou}),(0,r.jsx)(eh.c,{variant:"sidebar",stacked:!0,placeholder:"Size",options:eQ,value:rc?rc.split(",").map(e=>e.trim()).filter(Boolean):[],onChange:e=>null==nE?void 0:nE(e.join(",")),exclude:rO,onExcludeChange:nz,isDark:ou}),(0,r.jsx)(eh.c,{variant:"sidebar",stacked:!0,placeholder:"Industry",options:eW,value:rd?rd.split(",").map(e=>e.trim()).filter(Boolean):[],onChange:e=>null==nA?void 0:nA(e.join(",")),exclude:rM,onExcludeChange:nq,searchable:!0,isDark:ou}),(0,r.jsx)(eh.c,{variant:"sidebar",stacked:!0,placeholder:"Tags",options:eY,value:ru?ru.split(",").map(e=>e.trim()).filter(Boolean):[],onChange:e=>null==nJ?void 0:nJ(e.join(",")),exclude:rU,onExcludeChange:nB,isDark:ou}),(0,r.jsx)(ep.J,{variant:"sidebar",stacked:!0,defaultValue:"",placeholder:"LinkedIn reach",options:[{value:"",label:"Any reach"},{value:"me",label:"Reachable by me"},{value:"team",label:"Reachable by team"},{value:"none",label:"No one connected"}],value:r$,onChange:e=>nC("me"===e||"team"===e||"none"===e?e:""),getLabel:e=>"me"===e?"Reachable by me":"team"===e?"Reachable by team":"none"===e?"No one connected":"Any reach",isDark:ou})]}),(0,r.jsx)("p",{className:"text-[9px] font-semibold uppercase tracking-wider pt-2 px-1 ".concat(ou?"text-gray-500":"text-gray-400"),children:"Tools"}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("button",{type:"button",onClick:n7,disabled:sL,className:o1,title:"Sync most recent meeting dates from Calendly (connects Calendly if needed)",children:[sL?(0,r.jsx)(m.A,{className:"w-3 h-3 animate-spin shrink-0"}):(0,r.jsx)(y.A,{className:"w-3 h-3 shrink-0"}),(0,r.jsx)(et.L,{reserve:"Calendly Sync",align:"start",className:"flex-1 min-w-0",children:sL?"Syncing…":"Calendly Sync"})]}),(0,r.jsxs)("button",{type:"button",onClick:n8,disabled:n6,className:o1,title:"Sync meeting dates + history from Google Calendar (connects Google Calendar if needed). Includes meetings the AI Revenue agent booked.",children:[n6?(0,r.jsx)(m.A,{className:"w-3 h-3 animate-spin shrink-0"}):(0,r.jsx)(y.A,{className:"w-3 h-3 shrink-0"}),(0,r.jsx)(et.L,{reserve:"Google Calendar",align:"start",className:"flex-1 min-w-0",children:n6?"Syncing…":"Google Calendar"})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>nX(e=>!e),className:nZ?"w-full inline-flex items-center gap-2 text-[10px] px-2.5 py-2 rounded-lg font-semibold transition-all cursor-pointer bg-gray-900 text-white shadow-sm hover:bg-gray-800":o1,title:nZ?"Done — finish rearranging columns":"Rearrange columns (drag to reorder)",children:[nZ?(0,r.jsx)(g.A,{className:"w-3 h-3 shrink-0"}):(0,r.jsx)(u.A,{className:"w-3 h-3 shrink-0"}),(0,r.jsx)(et.L,{reserve:"Edit columns",align:"start",className:"flex-1 min-w-0",children:nZ?"Done":"Edit columns"})]})]})]})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"flex-1 overflow-auto","data-tour":"agent-leads-main",children:rl?(0,r.jsx)("div",{className:"flex justify-center items-center py-12",children:(0,r.jsx)(m.A,{className:"w-6 h-6 animate-spin ".concat(ou?"text-gray-400":"text-gray-900")})}):og.length?"kanban"===sU?(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)("div",{className:"flex gap-3 items-stretch min-w-max",children:rj.map(e=>
1{let t=og.filter(t=>(t.stage||"new")===e),a=eK(e,rk);return(0,r.jsxs)("div",{className:"flex flex-col w-72 shrink-0 rounded-2xl bg-transparent",onDragOver:e=>{e.preventDefault(),e.currentTarget.classList.add("ring-2","ring-blue-500/50")},onDragLeave:e=>{e.currentTarget.classList.remove("ring-2","ring-blue-500/50")},onDrop:t=>{if(t.preventDefault(),t.currentTarget.classList.remove("ring-2","ring-blue-500/50"),s6&&s6!==e){let t=og.find(e=>e.id===s6);t&&(t.stage||"new")!==e&&al(s6,e)}s9(null)},children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-2 py-2.5 backdrop-blur-md rounded-t-2xl ".concat(ou?"bg-gray-900/70":"bg-[#FAFAF9]/80"),children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-[-0.01em] ".concat(ou?"text-gray-200":"text-gray-800"),children:a}),(0,r.jsx)("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full tabular-nums ".concat(ou?"bg-white/10 text-gray-300":"bg-gray-900/[0.06] text-gray-600"),children:t.length})]}),(0,r.jsxs)("div",{className:"flex-1 px-1 pb-2 space-y-2",children:[t.map(e=>{var t;let a=[e.first_name,e.last_name].filter(Boolean).join(" ")||(null==(t=e.email)?void 0:t.split("@")[0])||"—",n=e.company_logo_url||(e.company_domain?"https://img.logo.dev/".concat(e.company_domain,"?token=").concat(e$):null);return(0,r.jsxs)("div",{draggable:!0,onDragStart:()=>s9(e.id),onDragEnd:()=>s9(null),className:"rounded-xl border p-3 shadow-sm cursor-grab active:cursor-grabbing transition-all ".concat(s6===e.id?"opacity-50 scale-95":""," ").concat(ou?"border-white/10 bg-gray-800 hover:bg-gray-700/70 hover:shadow-md":"border-gray-100 bg-white hover:shadow-md"),children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-1 mb-1",children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e.company&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[n?(0,r.jsx)("img",{src:n,alt:e.company,className:"w-4 h-4 rounded shrink-0 object-contain",onError:e=>{e.target.style.display="none"}}):(0,r.jsx)("div",{className:"w-4 h-4 rounded flex items-center justify-center shrink-0 text-[8px] font-bold ".concat(ou?"bg-gray-700 text-gray-400":"bg-gray-100 text-gray-500"),children:e.company.charAt(0).toUpperCase()}),(0,r.jsx)("span",{className:"text-[10px] font-medium truncate ".concat(ou?"text-gray-300":"text-gray-600"),children:e.company})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[ao&&(()=>{let t=(0,ey.q)(e);return(0,r.jsx)("button",{type:"button",disabled:!t,onClick:a=>{a.stopPropagation(),t&&ao(e)},onMouseDown:e=>e.stopPropagation(),title:t?"Message via ".concat(t.channel):"No contact channel for this lead","aria-label":t?"Message via ".concat(t.channel):"No contact channel for this lead",className:"p-0.5 shrink-0 transition-colors ".concat(ou?"text-gray-500":"text-gray-400"," ").concat(t?"cursor-pointer hover:scale-110 ".concat(ou?"hover:text-blue-400":"hover:text-blue-500"):"cursor-not-allowed opacity-40"),children:(0,r.jsx)(M.A,{className:"h-3.5 w-3.5"})})})(),(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),null==as||as(e.id,{starred:!e.starred})},className:"p-0.5 cursor-pointer shrink-0 transition-colors hover:scale-110",children:e.starred?(0,r.jsx)(U.A,{className:"h-3.5 w-3.5 text-amber-400"}):(0,r.jsx)(D.A,{className:"h-3.5 w-3.5 ".concat(ou?"text-gray-600 hover:text-amber-400":"text-gray-300 hover:text-amber-400")})})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(eX,{lead:e,displayName:a,inboxAvatarLookup:ad,size:"sm",isDark:ou}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-xs font-medium truncate ".concat(ou?"text-gray-100":"text-gray-900"),children:a}),(0,r.jsx)(eZ,{linkedinUrl:e.linkedin_url,isDark:ou,size:"sm"})]}),e.title&&(0,r.jsx)("p",{className:"text-[10px] truncate ".concat(ou?"text-gray-500":"text-gray-400"),children:e.title})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mt-2 pt-2 border-t border-dashed gap-2 relative",style:{borderColor:ou?"#374151":"#e5e7eb"},children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[null!=e.lead_score&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"text-[10px] ".concat(ou?"text-gray-500":"text-gray-400"),children:"Score"}),(0,r.jsx)("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded ".concat(e.lead_score>=70?"bg-green-100 text-green-700":e.lead_score>=40?"bg-yellow-100 text-yellow-700":ou?"bg-gray-700 text-gray-300":"bg-gray-100 text-gray-600"),children:e.lead_score})]}),null!=e.expected_deal_size&&(0,r.jsxs)("span",{className:"text-[10px] font-semibold ".concat(ou?"text-green-400":"text-green-700"),children:["$",e.expected_deal_size.toLocaleStr
1ing()]})]}),(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),oe(t=>t===e.id?null:e.id)},onMouseDown:e=>e.stopPropagation(),title:"Change stage",className:"p-0.5 rounded transition-colors shrink-0 ".concat(ou?"text-gray-500 hover:text-gray-300 hover:bg-gray-700":"text-gray-400 hover:text-gray-600 hover:bg-gray-100"),children:(0,r.jsx)(d.A,{className:"w-3 h-3 transition-transform ".concat(s8===e.id?"rotate-180":"")})}),s8===e.id&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>oe(null)}),(0,r.jsx)("div",{className:"absolute right-0 top-full mt-1 z-50 rounded-lg border shadow-lg py-1 min-w-[140px] max-h-[200px] overflow-y-auto ".concat(ou?"bg-gray-800 border-gray-600":"bg-white border-gray-200"),children:rj.map(t=>{let a=(e.stage||"new")===t;return(0,r.jsx)("button",{type:"button",onClick:r=>{r.stopPropagation(),a||al(e.id,t),oe(null)},className:"w-full text-left px-3 py-1.5 text-[11px] transition-colors ".concat(a?ou?"bg-gray-700 text-white font-semibold":"bg-gray-100 text-gray-900 font-semibold":ou?"text-gray-300 hover:bg-gray-700":"text-gray-900 hover:bg-gray-50"),children:eK(t,rk)},t)})})]})]})]},e.id)}),0===t.length&&(0,r.jsx)("p",{className:"text-center text-[10px] py-6 ".concat(ou?"text-gray-500":"text-gray-400"),children:"No leads"})]})]},e)})})}):"funnel"===sU?(()=>{let e=rj.filter(e=>"lost"!==e).map(e=>{let t=rr.filter(t=>(t.stage||"new")===e).length;return{stageId:e,label:eK(e,rk),count:t}}),t=rr.length,a=Math.max(...e.map(e=>e.count),1),n=[{bg:ou?"bg-blue-600/80":"bg-blue-500",text:"text-white"},{bg:ou?"bg-cyan-600/80":"bg-cyan-500",text:"text-white"},{bg:ou?"bg-teal-600/80":"bg-teal-500",text:"text-white"},{bg:ou?"bg-emerald-600/80":"bg-emerald-500",text:"text-white"},{bg:ou?"bg-green-600/80":"bg-green-500",text:"text-white"},{bg:ou?"bg-lime-600/80":"bg-lime-500",text:"text-white"}],l=rr.filter(e=>"lost"===(e.stage||"new")).length;return(0,r.jsxs)("div",{className:"p-6",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between mb-8",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-3xl font-bold ".concat(ou?"text-white":"text-gray-900"),children:t.toLocaleString()}),(0,r.jsx)("div",{className:"text-sm ".concat(ou?"text-gray-400":"text-gray-500"),children:"Total Leads"})]}),e.length>=2&&e[0].count>0&&(0,r.jsx)("div",{className:"flex items-center gap-8",children:e.slice(1).map((t,a)=>{let n=e[a].count,l=n>0?Math.round(t.count/n*100):0;return(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsxs)("div",{className:"text-xl font-bold ".concat(ou?"text-white":"text-gray-900"),children:[l,"%"]}),(0,r.jsxs)("div",{className:"text-[10px] ".concat(ou?"text-gray-500":"text-gray-400"),children:[e[a].label," → ",t.label]})]},t.stageId)})})]}),(0,r.jsx)("div",{className:"flex flex-col items-center gap-1",children:e.map((e,l)=>{let s=a>0?Math.max(e.count/a*100,12):12,o=n[l%n.length],i=t>0?Math.round(e.count/t*100):0;return(0,r.jsxs)("div",{className:"w-full flex items-center gap-4",children:[(0,r.jsx)("div",{className:"w-24 text-right text-xs font-medium shrink-0 ".concat(ou?"text-gray-400":"text-gray-500"),children:e.label}),(0,r.jsx)("div",{className:"flex-1 flex justify-center",children:(0,r.jsxs)("div",{className:"".concat(o.bg," ").concat(o.text," rounded-lg py-3 text-center text-sm font-semibold transition-all duration-500 relative overflow-hidden"),style:{width:"".concat(s,"%"),minWidth:80},children:[e.count.toLocaleString(),(0,r.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent"})]})}),(0,r.jsxs)("div",{className:"w-12 text-xs font-medium shrink-0 ".concat(ou?"text-gray-500":"text-gray-400"),children:[i,"%"]})]},e.stageId)})}),l>0&&(0,r.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-2 text-xs ".concat(ou?"text-gray-500":"text-gray-400"),children:[(0,r.jsx)("span",{className:"h-2 w-2 rounded-full bg-red-400"}),l.toLocaleString()," lost (",t>0?Math.round(l/t*100):0,"%)"]}),(0,r.jsx)("div",{className:"mt-8 flex items-center justify-center gap-6",children:e.map((e,t)=>{let a=n[t%n.length];return(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"h-2.5 w-2.5 rounded-full ".concat(a.bg)}),(0,r.jsx)("span",{className:"text-xs ".concat(ou?"text-gray-400":"text-gray-500"),children:e.label})]},e.stageId)})})]})})():(0,r.jsxs)("div",{className:"overflow-x-auto px-3 pb-3 relative",ref:lA,children:[oM&&lL&&(0,r.jsx)("div",{className:"lead-enrich-row-ring",style:{to
1p:lL.top,left:lL.left,width:lL.width,height:lL.height},children:(0,r.jsx)(ea,{width:lL.width,height:lL.height,phase:lj,durationMs:l_},"".concat(lv,"-").concat(lk))}),(0,r.jsx)($.Mp,{sensors:n2,collisionDetection:$.fp,onDragEnd:n3,children:(0,r.jsxs)("table",{className:"w-full text-[12px] min-w-[900px]",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:ou?"bg-gray-900/40":"bg-gray-100/40",children:[(0,r.jsx)("th",{className:"text-center py-2.5 px-1 font-medium w-8 rounded-l-lg ".concat(ou?"text-gray-400":"text-gray-500"),children:(0,r.jsx)(D.A,{className:"h-3.5 w-3.5 mx-auto"})}),(0,r.jsx)(Z.gB,{items:n0,strategy:Z.m$,children:n0.map(e=>(0,r.jsx)(eE,{id:e,editMode:nZ,sortColumn:sF,sortDirection:sD,onSort:om,isDark:ou},e))})]})}),(0,r.jsx)("tbody",{children:og.map(e=>{var t,a,l;let s=e.extracted_fields,i=[e.first_name,e.last_name].filter(Boolean).join(" ")||"—",c=null!=(a=e.linkedin_reachable_by)?a:[],d=(0,em.G_)(e.email)?rC&&c.includes(rC)?{label:"You can message",tone:"you"}:c.length>0?{label:"".concat(c.map(e=>{var t;return null!=(t=rE.get(e))?t:"Teammate"}).join(", ")," connected"),tone:"team"}:{label:"No one connected",tone:"none"}:null,u=(0,en.rz)(((null==(t=e.sources)?void 0:t.length)?e.sources[0]:e.source)||e.source||"inbox"),m=e.stage||"new",g=eK(m,rk),x=null!=(l=e.lead_score)?l:0,p={...e,extracted_fields:s};return(0,r.jsxs)(n.Fragment,{children:[(0,r.jsxs)("tr",{"data-lead-id":e.id,className:"group relative transition-colors duration-150 ".concat(lb===e.id?"lead-row-enrich-active":""," ").concat(ou?"hover:bg-white/[0.04]":"hover:bg-gray-50"),children:[(0,r.jsx)("td",{className:"py-3 px-1 text-center align-middle w-8",children:(0,r.jsx)("button",{type:"button",onClick:()=>null==as?void 0:as(e.id,{starred:!e.starred}),className:"p-0.5 cursor-pointer transition-colors hover:scale-110",title:e.starred?"Unstar":"Star",children:e.starred?(0,r.jsx)(U.A,{className:"h-4 w-4 text-amber-400"}):(0,r.jsx)(D.A,{className:"h-4 w-4 ".concat(ou?"text-gray-600 hover:text-amber-400":"text-gray-300 hover:text-amber-400")})})}),(()=>{var t,a,l;let c={name:(0,r.jsx)("td",{className:"py-3 px-3 max-w-[240px] align-middle",children:(0,r.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,r.jsx)(eX,{lead:e,displayName:i,inboxAvatarLookup:ad,size:"md",isDark:ou}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("p",{className:"font-medium truncate text-[12px] min-w-0 ".concat(ou?"text-gray-100":"text-gray-900"),children:as?(0,r.jsx)(tl,{value:i,placeholder:"Name",onSave:t=>{let[a,...r]=t.split(/\s+/);as(e.id,{first_name:a||"",last_name:r.join(" ")||""})}}):i}),(0,r.jsx)(eZ,{linkedinUrl:e.linkedin_url,isDark:ou,size:"md"})]}),(0,r.jsx)("p",{className:"text-[11px] truncate ".concat(ou?"text-gray-400":"text-gray-500"),title:e.email,children:e.email}),(e.phone||e.title)&&(0,r.jsx)("p",{className:"text-[11px] truncate ".concat(ou?"text-gray-400":"text-gray-500"),children:[e.phone,e.title].filter(Boolean).join(" \xb7 ")}),d&&(0,r.jsxs)("span",{className:"mt-0.5 inline-flex max-w-full items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium truncate ".concat("you"===d.tone?ou?"bg-emerald-900/40 text-emerald-300":"bg-emerald-50 text-emerald-700":"team"===d.tone?ou?"bg-blue-900/40 text-blue-300":"bg-blue-50 text-blue-700":ou?"bg-gray-700 text-gray-400":"bg-gray-100 text-gray-500"),title:d.label,children:[(0,r.jsx)(te,{customClass:"you"===d.tone?"bg-emerald-500":"team"===d.tone?"bg-blue-500":"bg-gray-400"}),(0,r.jsx)("span",{className:"truncate",children:d.label})]})]})]})}),company:(0,r.jsx)("td",{className:"py-3 px-3 max-w-[300px] align-middle",children:(0,r.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.company_logo_url?(0,r.jsx)("img",{src:e.company_logo_url,alt:e.company||"",className:"h-7 w-7 rounded object-cover shrink-0"}):e.company?(0,r.jsx)("div",{className:"h-7 w-7 shrink-0 rounded flex items-center justify-center text-[10px] font-medium ".concat(ou?"bg-gray-700 text-gray-400":"bg-gray-200 text-gray-500"),children:(e.company||"?")[0].toUpperCase()}):null,(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("p",{className:"font-medium truncate min-w-0 text-[12px] ".concat(ou?"text-gray-100":"text-gray-900"),children:as?(0,r.jsx)(tl,{value:e.company||"",placeholder:"Company",onSave:t=>as(e.id,{company:t})}):e.company||"—"}),(0,r.jsx)("a",{href:e.company_linkedin_url||"#",target:e.company_linkedin_url?"_blank":void 0,rel:e.company_linkedin_url?"noopener noreferrer":void 0,className:"shrink-0 ".concat(e.company_linkedin_url?"cursor-pointer":"pointer-events-none cursor-default"),title:e.company_linkedin_url?"Company LinkedIn":"No company LinkedIn",children:(0,r.jsx)("svg",{className:"h-3 w-3 ".concat(e.company_linkedin_url?"text-[#0A66C2]":ou?"text-gray-600":"text-gray-300"),fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":!0,
1children:(0,r.jsx)("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})})}),as&&(0,r.jsx)("button",{type:"button",onClick:()=>sS(e),className:"shrink-0 p-0.5 rounded cursor-pointer ".concat(ou?"hover:bg-gray-700":"hover:bg-gray-100"),title:"Edit lead",children:(0,r.jsx)(h.A,{className:"h-3 w-3 ".concat(ou?"text-gray-500 hover:text-gray-300":"text-gray-400 hover:text-gray-600")})}),sV===e.id?(0,r.jsx)("button",{type:"button",onClick:async()=>{try{if(!(await fetch("/api/scorecard/leads/".concat(e.id),{method:"DELETE"})).ok)throw Error("Failed");o.o.success("Lead deleted"),sQ(null),null==nQ||nQ()}catch(e){o.o.error("Failed to delete lead")}},className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] font-semibold transition-colors cursor-pointer ".concat(ou?"bg-red-900/40 text-red-300 hover:bg-red-900/60":"bg-red-50 text-red-700 hover:bg-red-100"),title:"Click to confirm delete",children:"Confirm?"}):(0,r.jsx)("button",{type:"button",onClick:()=>{sQ(e.id),setTimeout(()=>sQ(t=>t===e.id?null:t),3e3)},className:"shrink-0 p-0.5 rounded cursor-pointer ".concat(ou?"hover:bg-gray-700":"hover:bg-gray-100"),title:"Delete lead",children:(0,r.jsx)(T.A,{className:"h-3 w-3 ".concat(ou?"text-gray-500 hover:text-red-400":"text-gray-400 hover:text-red-500")})})]}),(e.company_domain||e.company_location||e.company_employee_range||e.company_categories)&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] truncate mt-0.5 ".concat(ou?"text-gray-400":"text-gray-500"),children:[e.company_domain&&(0,r.jsx)("span",{children:e.company_domain}),e.company_location&&(0,r.jsx)("span",{children:e.company_location}),e.company_employee_range&&(0,r.jsx)("span",{children:e.company_employee_range}),e.company_categories&&(0,r.jsx)("span",{children:e.company_categories})]}),(ai||e.email)&&(0,r.jsxs)("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 z-10 flex items-center gap-0.5 rounded-full px-1.5 py-1 shadow-md ring-1 opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity duration-150 ".concat(ou?"bg-gray-800 ring-white/10":"bg-white ring-black/[0.06]"),children:[ai&&(0,r.jsx)(e0,{leadId:e.id,attioPersonId:null!=(t=null==s?void 0:s.attio_person_id)?t:e.attio_record_id,onPush:ai,compact:!0,isDark:ou}),(0,r.jsx)(e5,{email:e.email,attioRecordId:e.attio_record_id,companyDomain:e.company_domain,hasAttio:rS,onSuccess:nV,compact:!0,isDark:ou})]})]})]})}),stage:(0,r.jsx)("td",{className:"py-3 px-2 align-middle",children:(0,r.jsx)(tn,{value:m,options:rj,onChange:t=>al(e.id,t),onBlur:()=>aM(null),colorClass:e2[m]||"bg-slate-500",displayLabel:g,getOptionLabel:e=>eK(e,rk),addCustomOption:nt?{label:"Add custom stage…",onAdd:nt}:void 0})}),source:(0,r.jsx)("td",{className:"py-3 px-2 align-middle",children:as?(0,r.jsx)(tn,{value:u,options:[...new Set([u,...rw])],onChange:t=>as(e.id,{source:t,sources:[t]}),onBlur:()=>aM(null),size:"xs",colorClass:e4(u),displayLabel:rN[u]||u,truncateLabel:!0,getOptionLabel:e=>rN[e]||e,addCustomOption:ne?{label:"Add custom source…",onAdd:ne}:void 0}):(0,r.jsx)("span",{className:"inline-flex max-w-[7.5rem] min-w-0 items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium leading-none ".concat(e8(e4(u))),children:(0,r.jsx)(tt,{text:rN[u]||u,className:"min-w-0 flex-1 truncate"})})}),contact_owner:(0,r.jsx)("td",{className:"py-3 px-2 align-middle",children:as?(0,r.jsx)(td,{leadId:e.id,value:e.contact_owner,teamMembers:rt,rosterNames:eo.R,onUpdateLead:as}):(0,r.jsx)("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium leading-none ".concat(e8("bg-indigo-500")),children:(0,r.jsx)(tt,{text:ta(e.contact_owner,rt,eo.R),className:"min-w-0 max-w-[7.5rem] truncate"})})}),tags:(0,r.jsx)("td",{className:"py-3 px-2 align-middle",children:(0,r.jsx)(tc,{tags:null!=(a=e.tags)?a:[],onChange:t=>null==as?void 0:as(e.id,{tags:t}),disabled:!as})}),lead_score:(0,r.jsx)("td",{className:"py-3 px-2 align-middle text-center",children:as?(0,r.jsxs)("div",{className:"inline-flex items-center justify-center gap-1.5",style:{color:tr(x)},children:[(0,r.jsx)("span",{className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:tr(x)}}),(0,r.jsx)(tl,{value:String(x),onSave:t=>{let a=parseInt(t,10);!isNaN(a)&&a>=0&&a<=100&&as(e.id,{lead_score:a})},className:"text-[12px] font-medium",truncate:!1})]}):(0,r.jsxs)("span",{className:"inline-flex items-center justify-center gap-1.5 text-[12px] font-medium",children:[(0,r.jsx)("span",{className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:tr(x)}}),(0,r.jsx)("span",{style:{color:tr(x)},children:x})]})}),deal_size:(0,r.jsx)("td",{className:"py-3 px-2 align-middle text-center",children:as?(0,r.jsx)(tl,{value:null!=e.expected_deal_size?"$".concat(e.expected_deal_size.toLocaleStr
1ing()):"—",placeholder:"—",onSave:t=>{let a=parseFloat(t.replace(/[^0-9.]/g,""));!isNaN(a)&&a>=0&&as(e.id,{expected_deal_size:a})},className:"text-[12px] font-medium ".concat(ou?"text-green-400":"text-green-700"),truncate:!1}):(0,r.jsx)("span",{className:"text-[12px] font-medium ".concat(ou?"text-green-400":"text-green-700"),children:null!=e.expected_deal_size?"$".concat(e.expected_deal_size.toLocaleString()):"—"})}),created_at:(0,r.jsx)("td",{className:"py-2 px-3 whitespace-nowrap align-middle font-medium ".concat(ou?"text-gray-200":"text-gray-900"),children:new Date(null!=(l=null==s?void 0:s.lemlist_replied_at)?l:e.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),last_meeting:(0,r.jsx)("td",{className:"py-3 px-2 align-middle whitespace-nowrap",children:(0,r.jsx)(tu,{lead:e,isDark:ou,onOpen:()=>sA(e)})})};return n0.map(e=>(0,r.jsx)(n.Fragment,{children:c[e]},e))})()]}),ac&&la&&(0,r.jsx)("tr",{className:"border-b ".concat(ou?"bg-amber-900/20 border-amber-800":"bg-amber-50/50 border-amber-100"),children:(0,r.jsx)("td",{colSpan:n0.length+1,className:"py-2 px-3 align-top",children:(0,r.jsxs)("details",{className:"group",children:[(0,r.jsx)("summary",{className:"text-[10px] font-medium cursor-pointer ".concat(ou?"text-amber-400 hover:text-amber-300":"text-amber-800 hover:text-amber-900"),children:"Raw lead record"}),(0,r.jsx)("pre",{className:"mt-1 text-[10px] overflow-x-auto max-h-40 overflow-y-auto p-2 rounded border font-mono whitespace-pre-wrap break-all ".concat(ou?"bg-gray-900 border-amber-700 text-gray-300":"bg-white border-amber-200 text-gray-700"),children:JSON.stringify(p,null,2)})]})})})]},e.id)})})]})})]}):(0,r.jsx)("p",{className:"text-center py-12 text-xs ".concat(ou?"text-gray-400":"text-gray-500"),children:rr.length>0?"No leads match the current filters on this page.":rG?"No starred leads found.":"never"===rX?"No leads left that your team hasn't contacted.":"days"===rX?"No leads your team hasn't contacted in ".concat(r1," days."):"No leads yet. Sync a lead source (Tally, Lemlist, Apollo, etc.) to populate."})}),rn>0&&"table"===sU&&(0,r.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-4 pr-20 py-2.5 backdrop-blur-md ".concat(ou?"bg-gray-900/70":"bg-white/60"),children:[(0,r.jsx)("div",{className:"text-[11px] ".concat(ou?"text-gray-400":"text-gray-500"),children:oh}),rr.length>0&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("span",{className:"text-[11px] ".concat(ou?"text-gray-500":"text-gray-400"),children:["Assign all ",rr.length," on page to"]}),(0,r.jsxs)("select",{disabled:sW,value:"",onChange:e=>{let t=e.target.value;if(e.target.value="",t){if("custom"===t){sZ(!0),s0("");return}s1(t)}},className:"text-[11px] rounded-md border px-1.5 py-0.5 outline-none cursor-pointer disabled:opacity-50 disabled:cursor-wait ".concat(ou?"bg-gray-700 border-gray-600 text-gray-300 hover:border-gray-500":"bg-white border-gray-200 text-gray-600 hover:border-gray-300"),children:[(0,r.jsx)("option",{value:"",disabled:!0,children:"Choose owner…"}),(0,r.jsx)("option",{value:"unassigned",children:"Unassigned"}),rt.map(e=>{var t;let a=null!=(t=e.email)?t:e.member_id;return(0,r.jsx)("option",{value:a,children:e.name||e.email||"Team member"},a)}),(0,r.jsx)("option",{value:"custom",children:"Custom email…"})]}),s$&&(0,r.jsx)("input",{type:"email",autoFocus:!0,value:sX,onChange:e=>s0(e.target.value),onBlur:()=>{let e=sX.trim();sZ(!1),e&&s1(e)},onKeyDown:e=>{"Enter"===e.key&&e.target.blur(),"Escape"===e.key&&sZ(!1)},placeholder:"Enter email",className:"text-[11px] rounded-md border px-1.5 py-0.5 outline-none ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200 placeholder:text-gray-500":"border-gray-200 bg-white text-gray-700 placeholder:text-gray-400")}),sW&&(0,r.jsx)(m.A,{className:"w-3 h-3 animate-spin ".concat(ou?"text-gray-400":"text-gray-500")})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] ".concat(ou?"text-gray-500":"text-gray-400"),children:"Per page"}),(0,r.jsx)("select",{value:rh,onChange:e=>nf(Number(e.target.value)),className:"text-[11px] rounded-md border px-1.5 py-0.5 outline-none cursor-pointer ".concat(ou?"bg-gray-700 border-gray-600 text-gray-300 hover:border-gray-500":"bg-white border-gray-200 text-gray-600 hover:border-gray-300"),children:[50,100,200,500].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),nK&&rn>rh&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>nK(rx-1),disabled:rx<=1,className:"p-1.5 rounded-lg transition-all disabled:opacity-40 disabled:cursor-not-allowed ".concat(ou?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),"aria-label":"Previous page",children:(0,r.jsx)(R.A,{className:"w-4 h-4"})}),(()=>{let e=Math.ceil(rn/rh),t=[];t.push(1);let a=Math.max(2,rx-1),n=Math.min(e-1,rx+1);a>2&&t.push("ellipsis");for(let e=a;
1e<=n;e++)t.includes(e)||t.push(e);return n<e-1&&t.push("ellipsis"),e>1&&!t.includes(e)&&t.push(e),t.map((e,t)=>"ellipsis"===e?(0,r.jsx)("span",{className:"px-1 text-[11px] ".concat(ou?"text-gray-500":"text-gray-400"),children:"…"},"ellipsis-".concat(t)):(0,r.jsx)("button",{type:"button",onClick:()=>nK(e),className:"min-w-[28px] px-2 py-1 text-[11px] rounded-lg font-medium transition-all ".concat(e===rx?ou?"bg-gray-600 text-gray-100 shadow-sm":"bg-gray-900 text-white shadow-sm":ou?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-600 hover:bg-gray-100 hover:text-gray-900"),children:e},e))})(),(0,r.jsx)("button",{type:"button",onClick:()=>nK(rx+1),disabled:rx>=Math.ceil(rn/rh),className:"p-1.5 rounded-lg transition-all disabled:opacity-40 disabled:cursor-not-allowed ".concat(ou?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),"aria-label":"Next page",children:(0,r.jsx)(S.A,{className:"w-4 h-4"})})]})]}),(0,r.jsx)("input",{ref:ot,type:"file",accept:".csv",className:"hidden",onChange:ic}),s_&&as&&(0,r.jsx)(ts,{lead:s_,onClose:()=>sS(null),onSave:async(e,t)=>{await as(e,t),sS(null)},isDark:ou}),sE&&(0,r.jsx)(Q,{lead:sE,onClose:()=>sA(null),onUpdateLead:as,isDark:ou}),lZ&&(0,r.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/50",onClick:()=>lX(!1),children:(0,r.jsxs)("div",{className:"rounded-xl shadow-xl border w-full max-w-lg p-5 transition-all ".concat(ou?"bg-gray-800 border-gray-700":"bg-[#FAFAF9] border-gray-100"),onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h3",{className:"text-base font-semibold ".concat(ou?"text-gray-100":"text-gray-900"),children:"Upload contact list"}),(0,r.jsx)("button",{type:"button",onClick:()=>lX(!1),className:"p-1.5 rounded-lg transition-all ".concat(ou?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-400 hover:bg-gray-100 hover:text-gray-600"),children:(0,r.jsx)(p.A,{className:"w-4 h-4"})})]}),si?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-[11px] font-medium mb-1 ".concat(ou?"text-gray-300":"text-gray-700"),children:"Map columns"}),(0,r.jsx)("p",{className:"text-[10px] mb-2 ".concat(ou?"text-gray-400":"text-gray-500"),children:"We matched your columns automatically — change any below, or set them to “Don’t import”."}),(0,r.jsx)("div",{className:"border rounded-lg divide-y max-h-44 overflow-y-auto ".concat(ou?"border-gray-600 divide-gray-700":"border-gray-100 divide-gray-100"),children:sd.map(e=>{var t;return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[(0,r.jsx)("span",{className:"flex-1 min-w-0 truncate text-[11px] ".concat(ou?"text-gray-200":"text-gray-700"),title:e,children:e||"(unnamed)"}),(0,r.jsx)("span",{className:"text-[10px] ".concat(ou?"text-gray-500":"text-gray-400"),children:"→"}),(0,r.jsxs)("select",{value:null!=(t=sm[e])?t:"",onChange:t=>sg(a=>({...a,[e]:t.target.value})),className:"text-[11px] rounded-md border px-2 py-1 focus:outline-none focus:ring-1 ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200 focus:ring-gray-500":"border-gray-200 bg-white text-gray-800 focus:ring-gray-300"),children:[(0,r.jsx)("option",{value:"",children:"Don’t import"}),ec.nb.map(e=>(0,r.jsx)("option",{value:e.key,children:e.label},e.key))]})]},e)})})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-[11px] font-medium mb-1.5 ".concat(ou?"text-gray-300":"text-gray-700"),children:["Set labels ",(0,r.jsx)("span",{className:"font-normal ".concat(ou?"text-gray-500":"text-gray-400"),children:"(optional — applied to new leads)"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2.5",children:[(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"block text-[10px] mb-1 ".concat(ou?"text-gray-400":"text-gray-500"),children:"Stage"}),(0,r.jsx)("select",{value:sx,onChange:e=>sh(e.target.value),className:"w-full text-[11px] rounded-md border px-2 py-1.5 focus:outline-none focus:ring-1 ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200 focus:ring-gray-500":"border-gray-200 bg-white text-gray-800 focus:ring-gray-300"),children:ed.jI.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"block text-[10px] mb-1 ".concat(ou?"text-gray-400":"text-gray-500"),children:"Contact owner"}),(0,r.jsxs)("select",{value:sv,onChange:e=>sw(e.target.value),className:"w-full text-[11px] rounded-md border px-2 py-1.5 focus:outline-none focus:ring-1 ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200 focus:ring-gray-500":"border-gray-200 bg-white text-gray-800 focus:ring-gray-300"),children:[(0,r.jsx)("option",{value:"",children:"You (default)"}),(0,r.jsx)("option",{value:"unassigned",children:"Unassigned"}),r_.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.id))]})]}),(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"block text-[10px] mb-1 ".concat(ou?"text-gray-400":"text-gray-500"),children:"Source"}),(0,r.jsxs)("select",{value:"none"===sp?"none":"new"===sp?"__new__":sb,onChange:e=>{let t=e.target.value;"none"===t?(sy("none"),sf("")):"__new__"===t?sy("new"):(sy("existing"),sf(t))},className:"w-full text-[11px] rounded-md border px-2 py-1.5 focus:outline-none focus:ring-1 ".concat(ou?"border-gray-600 bg-gray-700 text-gray-200 focus:ring-gray-500":"border-gray-200 bg-white text-gray-800 focus:ring-gray-300"),children:[(0,r.jsx)("option",{value:"none",children:"None (default)"}),rw.map(e=>{var t;
1return(0,r.jsx)("option",{value:e,children:null!=(t=rN[e])?t:e},e)}),(0,r.jsx)("option",{value:"__new__",children:"+ Create new list…"})]})]}),"new"===sp&&(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"block text-[10px] mb-1 ".concat(ou?"text-gray-400":"text-gray-500"),children:"New list name"}),(0,r.jsx)("input",{type:"text",value:l9,onChange:e=>l8(e.target.value),placeholder:"e.g. Conference 2024",className:"w-full text-[11px] rounded-md border px-2 py-1.5 focus:outline-none focus:ring-1 ".concat(l9.trim()?ou?"border-gray-600 bg-gray-700 text-gray-200 focus:ring-gray-500":"border-gray-200 bg-white text-gray-800 focus:ring-gray-300":ou?"border-red-500 focus:ring-red-500":"border-red-300 focus:ring-red-300")})]})]}),(0,r.jsxs)("div",{className:"mt-2.5",children:[(0,r.jsx)("span",{className:"block text-[10px] mb-1 ".concat(ou?"text-gray-400":"text-gray-500"),children:"Tags"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 rounded-md border px-2 py-1.5 ".concat(ou?"border-gray-600 bg-gray-700":"border-gray-200 bg-white"),children:[sj.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full ".concat(ou?"bg-gray-600 text-gray-200":"bg-gray-100 text-gray-700"),children:[e,(0,r.jsx)("button",{type:"button",onClick:()=>sN(t=>t.filter(t=>t!==e)),className:"hover:text-red-500",children:"\xd7"})]},e)),(0,r.jsx)("input",{type:"text",value:sk,onChange:e=>sC(e.target.value),onKeyDown:e=>{if("Enter"===e.key||","===e.key){e.preventDefault();let t=sk.trim();t&&!sj.includes(t)&&sN(e=>[...e,t]),sC("")}else"Backspace"===e.key&&!sk&&sj.length&&sN(e=>e.slice(0,-1))},placeholder:sj.length?"":"Add a tag, press Enter",className:"flex-1 min-w-[80px] text-[11px] bg-transparent focus:outline-none ".concat(ou?"text-gray-200 placeholder:text-gray-500":"text-gray-800 placeholder:text-gray-400")})]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-[11px] font-medium mb-2 ".concat(ou?"text-gray-300":"text-gray-700"),children:sn>0?"Preview — first ".concat(sa.length," of ").concat(sn.toLocaleString()," row").concat(1!==sn?"s":""):"Preview (No data)"}),sa.length>0?(0,r.jsx)("div",{className:"border rounded-lg overflow-x-auto max-h-40 ".concat(ou?"border-gray-600":"border-gray-100"),children:(0,r.jsxs)("table",{className:"w-full text-[10px]",children:[(0,r.jsx)("thead",{className:ou?"bg-gray-700":"bg-gray-50",children:(0,r.jsx)("tr",{children:Object.keys(sa[0]).slice(0,5).map(e=>(0,r.jsx)("th",{className:"px-2 py-1 text-left font-medium whitespace-nowrap ".concat(ou?"text-gray-400":"text-gray-600"),children:e},e))})}),(0,r.jsx)("tbody",{children:sa.map((e,t)=>(0,r.jsx)("tr",{className:"border-t ".concat(ou?"border-gray-700":"border-gray-100"),children:Object.keys(sa[0]).slice(0,5).map(t=>(0,r.jsx)("td",{className:"px-2 py-1 truncate max-w-[120px] ".concat(ou?"text-gray-300":"text-gray-700"),children:e[t]||"—"},t))},t))})]})}):(0,r.jsx)("p",{className:"text-[11px] ".concat(ou?"text-gray-400":"text-gray-500"),children:"No valid rows found in CSV."})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:ii,disabled:se,className:"text-[11px] px-3 py-1.5 rounded-lg border transition-all disabled:opacity-50 ".concat(ou?"border-gray-600 text-gray-400 hover:bg-gray-700":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"),children:"Choose different file"}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("button",{type:"button",onClick:()=>lX(!1),disabled:se,className:"text-[11px] px-3 py-1.5 rounded-lg border transition-all disabled:opacity-50 ".concat(ou?"border-gray-600 text-gray-400 hover:bg-gray-700":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"),children:"Cancel"}),(0,r.jsxs)("button",{type:"button",onClick:id,disabled:se||0===sn||"new"===sp&&!l9.trim()||"existing"===sp&&!sb,className:"text-[11px] px-4 py-1.5 rounded-lg font-medium disabled:opacity-50 flex items-center gap-1.5 shadow-sm transition-all ".concat(ou?"bg-gray-600 text-gray-100 hover:bg-gray-500 hover:shadow":"bg-gray-900 text-white hover:bg-gray-800 hover:shadow"),children:[se?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):(0,r.jsx)(A.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)(et.L,{reserve:"Importing 9,999 / 9,999…",children:se?ss?"Importing ".concat(ss.done.toLocaleStr
1ing()," / ").concat(ss.total.toLocaleString(),"…"):"Importing…":"new"!==sp||l9.trim()?sn>0?"Import ".concat(sn.toLocaleString()," lead").concat(1!==sn?"s":""):"Import leads":"Name your list first"})]})]})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("p",{className:"text-[12px] ".concat(ou?"text-gray-300":"text-gray-600"),children:["Upload a CSV file with your contacts. Recommended column: ",(0,r.jsx)("strong",{children:"email"})," — but rows without an email are kept too (identified by company + name). Optional: first_name, last_name, company, title, phone, linkedin_url."]}),(0,r.jsxs)("div",{className:"rounded-lg border p-3 text-[11px] space-y-1.5 ".concat(ou?"border-gray-600 bg-gray-700/50 text-gray-300":"border-gray-200 bg-gray-50 text-gray-600"),children:[(0,r.jsx)("p",{className:"font-medium",children:"Need a template?"}),(0,r.jsxs)("p",{children:[(0,r.jsxs)("a",{href:"/sample-leads.csv",download:"sample-leads.csv",className:"inline-flex items-center gap-1 font-medium underline underline-offset-2 ".concat(ou?"text-blue-400 hover:text-blue-300":"text-blue-600 hover:text-blue-700"),children:[(0,r.jsx)(A.A,{className:"w-3 h-3 rotate-180"}),"Download sample CSV"]})," ","— 3 example rows with all supported columns. Edit in Excel or Google Sheets, then upload."]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=ot.current)?void 0:e.click()},className:"w-full py-8 border-2 border-dashed rounded-xl transition-all flex flex-col items-center gap-2 ".concat(ou?"border-gray-600 hover:border-gray-500 hover:bg-gray-700/30":"border-gray-200 hover:border-gray-300 hover:bg-gray-50"),children:[(0,r.jsx)(A.A,{className:"w-8 h-8 ".concat(ou?"text-gray-500":"text-gray-400")}),(0,r.jsx)("span",{className:"text-[12px] ".concat(ou?"text-gray-400":"text-gray-600"),children:"Click to select CSV file"})]})]})]})}),l5&&(0,r.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/50",onClick:()=>l2(!1),children:(0,r.jsxs)("div",{className:"rounded-xl shadow-xl border w-full max-w-sm p-5 ".concat(ou?"bg-gray-800 border-gray-700":"bg-[#FAFAF9] border-gray-100"),onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h3",{className:"text-base font-semibold ".concat(ou?"text-gray-100":"text-gray-900"),children:"Add a lead"}),(0,r.jsx)("button",{type:"button",onClick:()=>l2(!1),className:"p-1.5 rounded-lg transition-all ".concat(ou?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-400 hover:bg-gray-100 hover:text-gray-600"),children:(0,r.jsx)(p.A,{className:"w-4 h-4"})})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[11px] font-medium mb-1 ".concat(ou?"text-gray-300":"text-gray-700"),children:"Name"}),(0,r.jsx)("input",{type:"text",value:l7.name,autoFocus:!0,onChange:e=>l6(t=>({...t,name:e.target.value})),placeholder:"Jane Smith",className:oK})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"block text-[11px] font-medium mb-1 ".concat(ou?"text-gray-300":"text-gray-700"),children:["Email ",(0,r.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,r.jsx)("input",{type:"email",value:l7.email,onChange:e=>l6(t=>({...t,email:e.target.value})),onKeyDown:e=>"Enter"===e.key&&!l3&&l7.email.trim()&&oV(),placeholder:"[email protected]",className:oK})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[11px] font-medium mb-1 ".concat(ou?"text-gray-300":"text-gray-700"),children:"Company"}),(0,r.jsx)("input",{type:"text",value:l7.company,onChange:e=>l6(t=>({...t,company:e.target.value})),placeholder:"Optional",className:oK})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[11px] font-medium mb-1 ".concat(ou?"text-gray-300":"text-gray-700"),children:"Title"}),(0,r.jsx)("input",{type:"text",value:l7.title,onChange:e=>l6(t=>({...t,title:e.target.value})),placeholder:"Optional",className:oK})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>l2(!1),className:"text-[11px] px-3 py-1.5 rounded-lg border transition-all ".concat(ou?"border-gray-600 text-gray-400 hover:bg-gray-700":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"),children:"Cancel"}),(0,r.jsxs)("button",{type:"button",onClick:oV,disabled:l3||!l7.email.trim(),className:"text-[11px] px-4 py-1.5 rounded-lg font-medium disabled:opacity-50 flex items-center gap-1.5 shadow-sm transition-all ".concat(ou?"bg-gray-600 text-gray-100 hover:bg-gray-500":"bg-gray-900 text-white hover:bg-gray-800"),children:[l3?(0,r.jsx)(m.A,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):(0,r.jsx)(x.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)(et.L,{reserve:"Add lead",children:l3?"Adding…":"Add lead"})]})]})]})]})})]})]}),"kb"===sP&&(0,r.jsx)("div",{className:"flex flex-1 flex-col min-h-0 overflow-hidden",children:(0,r.jsx)(eb.d,{isDark:ou})}),"templates"===sP&&(0,r.jsx)("div",{className:"flex flex-1 flex-col min-h-0 overflow-hidden",children:(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(ev,{isDark:ou})})}),"filters"===sP&&(0,r.jsx)("div",{className:"flex flex-1 flex-col min-h-0 overflow-hidden",children:(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",children:(0,r.jsx)(ew,{isDark:ou,onApply:e=>{null==nY||nY(e),sM("leads")}})})}),(0,r.jsx)(ee.I,{open:l0,onClose:()=>l1(!1),onSuccess:()=>{null==nQ||nQ(),l1(!1)},isDark:ou})]})})});return iu?im:(0,s.createPortal)(im,document.body)}}}]);

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.