1import{s as Ge,P as Je,r as o,u as se,F as E,j as e,C as v,d as N,I as T,B as m,x as O,b as Xe,h as pe,i as xe,k as fe,N as Ye,D as ge,G as je,U as we,m as ve,n as Ne,o as ye,p as be,an as Ce}from"./index-B1Dqzo5J.js";import{S as Se,a as ke,b as De,c as _e,d as Fe}from"./select-Ca3d8v_T.js";import{F as et}from"./file-up-CKHShBg6.js";import{F as tt}from"./filter-2SvwuFoN.js";import{T as st}from"./trending-up-BO7Qw_Yb.js";import{D as Ie}from"./download-z1nuDz5_.js";import{S as at}from"./search-BVlVOMyq.js";import{C as Re,a as Le}from"./chevron-right-Bg5s55bU.js";import{F as ae}from"./file-text-CdalUvKf.js";import{I as lt}from"./import-DREGEcIf.js";import{T as nt}from"./trash-2-CkEccJ5c.js";import"./index-B3_Bjc4w.js";const it=["ceo","founder","marketing","cfo","agency","saas","coach","realtor"];function le(l){return l.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean)}function ot(l){const n=(l??"").trim().replace(/^"|"$/g,"").toLowerCase();return n==="true"||n==="1"||n==="yes"||n==="y"}const Ue=["username","user_name","handle","twitter_handle","x_handle","screen_name","screenname","twitter","account","user","login","profile","profile_url","url","link","twitter_url","x_url"],rt=new Set([...Ue,"name","first_name","last_name","full_name","fullname","bio","description","about","location","followers","followers_count","following","following_count","verified","is_verified","can_dm","id","user_id","tweets","created_at","email","website"]);function A(l){let n=String(l??"").trim().replace(/^["']|["']$/g,"").trim();if(!n)return"";const i=n.match(/(?:^|\/\/|\.)(?:twitter|x)\.com\/(?:#!\/)?@?([A-Za-z0-9_]{1,15})/i);return i&&(n=i[1]),n=n.replace(/^@+/,"").split(/[/?#]/)[0],/^[A-Za-z0-9_]{1,15}$/.test(n)?n:""}function Pe(l){for(const n of Ue){const i=A(l[n]);if(i)return i}for(const[n,i]of Object.entries(l))if(!(n==="can_dm"||/count|follow|verified|^id$|user_id/.test(n))&&(/(?:twitter|x)\.com\//i.test(String(i??""))||String(i??"").trim().startsWith("@"))){const r=A(i);if(r)return r}return""}function K(l,n){const i=[];let r="",u=!1;for(let g=0;g<l.length;g++){const x=l[g];x==='"'?u&&l[g+1]==='"'?(r+='"',g++):u=!u:x===n&&!u?(i.push(r.trim()),r=""):r+=x}return i.push(r.trim()),i}function ct(l){const n=[",",";"," "].map(i=>({d:i,n:K(l,i).length}));return n.sort((i,r)=>r.n-i.n),n[0].n>1?n[0].d:","}function dt(l){const i=l.replace(/^/,"").split(/\r?\n/).filter(c=>c.trim());if(i.length===0)return{rows:[],headerless:!1};const r=ct(i[0]),u=K(i[0],r);if(u.length===1&&!rt.has(u[0].trim().toLowerCase())&&!!A(u[0]))return{headerless:!0,rows:i.map(c=>({username:K(c,r)[0]})).filter(c=>A(c.username))};const x=u.map(c=>c.trim().toLowerCase().replace(/^["']|["']$/g,"")),a=[];for(let c=1;c<i.length;c++){const j=K(i[c],r),y={};x.forEach((f,b)=>{y[f]=j[b]??""});for(let f=x.length;f<j.length;f++)y[`column_${f+1}`]=j[f];a.push(y)}return{rows:a,headerless:!1}}
1function ne(l){const n=l.bio||l.description;return n||Object.entries(l).filter(([r])=>r.includes("bio")||r.includes("description")||r.includes("about")).map(([,r])=>r).filter(Boolean).join(" ")||""}function bt(){const{toast:l}=Ge(),n=Je(),i=o.useRef(null),[r,u]=o.useState(!1),[g,x]=o.useState(!1),[a,c]=o.useState(null),[j,y]=o.useState(!0),[f,b]=o.useState(""),[C,S]=o.useState(1),$=10,[k,ie]=o.useState(""),[D,oe]=o.useState(1),H=5,[Ee,F]=o.useState(null),[I,B]=o.useState(""),[Te,R]=o.useState(null),[z,M]=o.useState(""),[re,L]=o.useState(""),[q,Q]=o.useState(!1),[ce,V]=o.useState(""),Oe=o.useMemo(()=>le(k),[k]),Ke=o.useCallback(t=>{ie(s=>{const d=le(s);return d.includes(t)?d.filter(h=>h!==t).join(", "):[...d,t].join(", ")})},[]),{data:W=[]}=se({queryKey:["/api/csv-uploads"]}),{data:Ae=[]}=se({queryKey:["/api/campaigns"]}),{data:de=[]}=se({queryKey:["/api/accounts"]}),Z=E({mutationFn:async t=>{const s=await fetch("/api/csv-uploads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"});if(!s.ok)throw new Error("Failed to save upload");return s.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["/api/csv-uploads"]}),l({title:"Upload saved!",description:"CSV data has been saved successfully."}),c(null)},onError:()=>{l({title:"Error",description:"Failed to save CSV upload",variant:"destructive"})}}),me=E({mutationFn:async t=>{if(!(await fetch(`/api/csv-uploads/${t}`,{method:"DELETE",credentials:"include"})).ok)throw new Error("Failed to delete")},onSuccess:()=>{n.invalidateQueries({queryKey:["/api/csv-uploads"]}),l({title:"Deleted",description:"CSV upload deleted"})}}),G=E({mutationFn:async({uploadId:t,accountId:s,name:d,isEnabled:h})=>{const p=await fetch(`/api/accounts/${s}/auto-follow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({csvUploadId:t,name:d,isEnabled:h}),credentials:"include"}),w=await p.json().catch(()=>({}));if(!p.ok)throw new Error(w?.message||"Could not start Auto Follow from this list");return w},onSuccess:t=>{n.invalidateQueries({queryKey:["/api/accounts"]}),R(null),M(""),L(""),Q(!1),l({title:t?.task?.status==="active"?"Auto Follow started":"Queued, paused",description:`${(t?.queuedCount??0).toLocaleString()} accounts queued${t?.task?.status==="active"?"":" â start it from the Auto Follow page"}`})},onError:t=>{l({title:"Could not import",description:t.message,variant:"destructive"})}}),J=E({mutationFn:async({uploadId:t,campaignId:s,bioKeywords:d})=>{const h=await fetch(`/api/csv-uploads/${t}/import-to-campaign`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({campaignId:s,bioKeywords:d}),credentials:"include"});if(!h.ok)throw new Error("Failed to import");return h.json()},onSuccess:t=>{n.invalidateQueries({queryKey:["/api/campaigns"]}),F(null),B(""),V(""),l({title:"Import Complete",description:`${t.imported} accounts imported to campaign`})},onError:()=>{l({title:"Error",description:"Failed to import to campaign",variant:"destructive"})}}),P=o.useCallback(t=>{if(!/\.(csv|txt|tsv)$/i.test(t.name)){l({title:"Unsupported file",description:"Upload a .csv, .tsv or .txt list",variant:"destructive"});return}x(!0);const s=new FileReader;s.onload=d=>{try{const h=d.target?.result,{rows:p,headerless:w}=dt(h);if(p.length===0){l({title:"Nothing to read",description:"No rows found in that file",variant:"destructive"}),x(!1);return}const U=p.some(_=>Object.prototype.hasOwnProperty.call(_,"can_dm")),te=le(k);let he=0;const Ve=p.filter(_=>{if(!Pe(_))return he++,!1;if(U&&j&&!ot(_.can_dm))return!1;if(te.length===0)return!0;const We=ne(_).toLowerCase();return te.some(Ze=>We.includes(Ze))});c({fileName:t.name,allRows:p,filteredRows:Ve,appliedKeywords:te,hasCanDm:U,withoutHandle:he,headerless:w}),S(1),b("")}catch{l({title:"Parse error",description:"Could not read that file",variant:"destructive"})}x(!1)},s.readAsText(t)},[k,j,l]),$e=o.useCallback(t=>{t.preventDefault(),u(!0)},[]),He=o.useCallback(t=>{t.preventDefault(),u(!1)},[]),Be=o.useCallback(t=>{t.preventDefault(),u(!1);const s=t.dataTransfer.files[0];s&&P(s)},[P]),ze=o.useCallback(t=>{const s=t.target.files?.[0];s&&P(s),i.current&&(i.current.value="")},[P]),Me=()=>{if(!a)return;const t=a.filteredRows.map(s=>({twitterHandle:Pe(s),twitterUserId:/^\d+$/.test((s.user_id||s.id||"").trim())?(s.user_id||s.id||"").trim():"",firstName:s.name||s.first_name||s.fullname||s.full_name||"",bio:ne(s),location:s.location||"",followersCount:parseInt(s.followers_count||s.followers||"0")||0,followingCount:parseInt(s.following_count||s.following||"0")||0,isVerified:s.verified?.toLowerCase()==="true"||s.is_verified?.toLowerCase()==="true"})).filter(s=>s.twitterHandle);if(t.length===0){l({title:"Nothing to import",description:a.withoutHandle===a.allRows.length?"No column in that file holds a usable handle.":"No rows are left once the filters are applied.",variant:"destructive"});return}Z.mutate({fileName:a.fileName,totalRows:a.allRows.length,filteredCount:t.length,contacts:t})},qe=()=>{if(!a)return;const t=Object.keys(a.filteredRows[0]||{}),s=[t.join(","),...a.filteredRows.map(w=>t.map(U=>`"${(w[U]||"").replace(/"/g,'""')}"`).join(","))].join(` 2`),d=new Blob([s],{type:"text/csv"}),h=URL.createObjectURL(d),p=document.createElement("a");p.href=h,p.download=`filtered_${a.fileName}`,p.click(),URL.revokeObjectURL(h)},X=a?.filteredRows.filter(t=>{if(!f)return!0;const s=f.toLowerCase();return Object.values(t).some(d=>d?.toLowerCase().includes(s))})||[],Y=Math.ceil(X.length/$),ue=X.slice((C-1)*$,C*$),ee=Math.ceil(W.length/H),Qe=W.slice((D-1)*H,D*H);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Upload CSV"}),e.jsx("p",{className:"text-muted-foreground",children:"Upload a list once, then send it to Auto Follow, to a DM campaign, or both"})]})}),e.jsx(v,{children:e.jsxs(N,{className:"pt-6",children:[e.jsxs("div",{className:"mb-4 space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Choose Bio Keywords Before Upload (optional)"}),e.jsx(T,{value:k,onChange:t=>ie(t.target.value),placeholder:"ceo, marketing, cfo",disabled:!!a}),e.jsx("div",{className:"flex flex-wrap gap-2",children:it.map(t=>{const s=Oe.includes(t);return e.jsx(m,{type:"button",size:"sm",variant:s?"default":"outline",className:"h-7 px-2 text-xs",disabled:!!a,onClick:()=>Ke(t),children:t},t)})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Bio keywords are matched as the file is read. A ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-[11px]",children:"can_dm"})," column is used if the file has one, and ignored if it does not.",a?' Click "New Upload" to change keywords.':""]}),a&&e.jsx(m,{type:"button",variant:"outline",size:"sm",onClick:()=>{c(null),b(""),S(1)},children:"New Upload"})]}),e.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors cursor-pointer 3 ${r?"border-primary bg-primary/5":"border-muted-foreground
3/25 hover:border-primary/50"}`,onDragOver:$e,onDragLeave:He,onDrop:Be,onClick:()=>i.current?.click(),children:[g?e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(O,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-lg font-medium",children:"Processing CSV..."})]}):e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"p-4 rounded-full bg-primary/10",children:e.jsx(et,{className:"h-10 w-10 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-medium",children:"Drag & drop your list here"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"or click to browse â .csv, .tsv or .txt. Any column holding handles, @handles or profile links works, and a plain list of handles one per line is fine too."})]})]}),e.jsx("input",{ref:i,type:"file",accept:".csv,.tsv,.txt",className:"hidden",onChange:ze})]})]})}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(v,{children:e.jsx(N,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10",children:e.jsx(Xe,{className:"h-5 w-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Accounts"}),e.jsx("p",{className:"text-2xl font-bold",children:a.allRows.length.toLocaleString()})]})]})})}),e.jsx(v,{children:e.jsx(N,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-green-500/10",children:e.jsx(tt,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:a.appliedKeywords.length>0?"Ready to import · bio matched":"Ready to import"}),e.jsx("p",{className:"text-2xl font-bold",children:a.filteredRows.length.toLocaleString()})]})]})})}),e.jsx(v,{children:e.jsx(N,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-purple-500/10",children:e.jsx(st,{className:"h-5 w-5 text-purple-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Kept from the file"}),e.jsxs("p",{className:"text-2xl font-bold",children:[a.allRows.length>0?(a.filteredRows.length/a.allRows.length*100).toFixed(1):0,"%"]})]})]})})})]}),e.jsxs(v,{children:[e.jsxs(pe,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(xe,{className:"text-lg",children:["Preview: ",a.fileName]}),e.jsxs(fe,{children:[a.filteredRows.length.toLocaleString()," of ",a.allRows.length.toLocaleString()," rows ready",a.appliedKeywords.length>0?` · bio matching: ${a.appliedKeywords.join(", ")}`:"",a.headerless?" · read as a plain handle list":""]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(m,{variant:"outline",size:"sm",onClick:qe,children:[e.jsx(Ie,{className:"h-4 w-4 mr-1"})," Download"]}),e.jsxs(m,{size:"sm",onClick:Me,disabled:Z.isPending||a.filteredRows.length===0,children:[Z.isPending?e.jsx(O,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Ye,{className:"h-4 w-4 mr-1"}),"Save & Add to History"]})]})]}),(a.hasCanDm||a.withoutHandle>0)&&e.jsxs("div",{className:"mt-2 space-y-1.5 text-sm",children:[a.hasCanDm&&e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-input",checked:j,onChange:t=>{y(t.target.checked),l({title:"Re-upload to apply",description:"Drop the file in again to re-read it with this setting."})},"data-testid":"checkbox-only-can-dm"}),e.jsxs("span",{children:["Keep only rows where ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-[11px]",children:"can_dm"})," is true",e.jsx("span",{className:"text-muted-foreground",children:" â this file has that column"})]})]}),a.withoutHandle>0&&e.jsxs("p",{className:"text-muted-foreground",children:[a.withoutHandle.toLocaleString()," row",a.withoutHandle===1?"":"s"," skipped â no handle, @handle or profile link in them."]})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(at,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(T,{placeholder:"Search accounts...",className:"pl-9",value:f,onChange:t=>{b(t.target.value),S(1)}})]})]}),e.jsxs(N,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-2 px-3 font-medium",children:"Username"}),e.jsx("th",{className:"text-left py-2 px-3 font-medium",children:"Name"}),e.jsx("th",{className:"text-left py-2 px-3 font-medium hidden md:table-cell",children:"Bio"}),e.jsx("th",{className:"text-right py-2 px-3 font-medium",children:"Followers"})]})}),e.jsxs("tbody",{children:[ue.map((t,s)=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[e.jsxs("td",{className:"py-2 px-3 font-medium",children:["@",t.username||t.handle||t.screen_name||"-"]}),e.jsx("td",{className:"py-2 px-3",children:t.name||t.first_name||t.fullname||"-"}),e.jsx("td",{className:"py-2 px-3 hidden md:table-cell max-w-[200px] truncate text-muted-foreground",children:ne(t)||"-"}),e.jsx("td",{className:"py-2 px-3 text-right",children:parseInt(t.followers_count||t.followers||"0").toLocaleStr
3ing()})]},s)),ue.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"py-8 text-center text-muted-foreground",children:"No results found"})})]})]})}),Y>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",C," of ",Y," (",X.length," results)"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(m,{variant:"ghost",size:"icon",disabled:C<=1,onClick:()=>S(t=>t-1),children:e.jsx(Re,{className:"h-4 w-4"})}),e.jsx(m,{variant:"ghost",size:"icon",disabled:C>=Y,onClick:()=>S(t=>t+1),children:e.jsx(Le,{className:"h-4 w-4"})})]})]})]})]})]}),e.jsxs(v,{children:[e.jsxs(pe,{children:[e.jsxs(xe,{className:"text-lg flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"})," Upload History"]}),e.jsx(fe,{children:"Uploaded lists, ready to send to Auto Follow or a DM campaign"})]}),e.jsx(N,{children:W.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ae,{className:"h-10 w-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No lists yet. Upload one above to get started."})]}):e.jsxs("div",{className:"space-y-3",children:[Qe.map(t=>e.jsx("div",{className:"p-4 border rounded-lg hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsx("span",{className:"font-medium truncate",children:t.fileName})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[e.jsxs("span",{children:[t.totalRows?.toLocaleString()," total"]}),e.jsxs("span",{className:"text-green-600 font-medium",children:[t.filteredCount?.toLocaleString()," contacts"]}),e.jsx("span",{children:new Date(t.createdAt).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("a",{href:`/api/csv-uploads/${t.id}/download`,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm border rounded-md hover:bg-muted transition-colors",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"})," Download"]}),e.jsxs(ge,{open:Te===t.id,onOpenChange:s=>{s||(R(null),M(""),L(""),Q(!1))},children:[e.jsx(je,{asChild:!0,children:e.jsxs(m,{variant:"outline",size:"sm",onClick:()=>{R(t.id),L(t.fileName.replace(/\.[^.]+$/,""))},"data-testid":`button-import-follow-${t.id}`,children:[e.jsx(we,{className:"h-3.5 w-3.5 mr-1"})," Import to Auto Follow"]})}),e.jsxs(ve,{children:[e.jsxs(Ne,{children:[e.jsx(ye,{children:"Import to Auto Follow"}),e.jsxs(be,{children:["Queue ",t.filteredCount?.toLocaleString(),' accounts from "',t.fileName,'" for one of your X accounts to follow.']})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Follow from"}),e.jsxs(Se,{value:z,onValueChange:M,children:[e.jsx(ke,{className:"mt-1","data-testid":"select-follow-account",children:e.jsx(De,{placeholder:"Select an X account"})}),e.jsx(_e,{children:de.length===0?e.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No X accounts connected yet."}):de.map(s=>e.jsxs(Fe,{value:String(s.id),children:["@",s.twitterHandle||s.handle||s.username]},s.id))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name this run"}),e.jsx(T,{className:"mt-1",value:re,onChange:s=>L(s.target.value),placeholder:"Auto Follow from list","data-testid":"input-follow-task-name"})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer text-sm",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 mt-0.5 rounded border-input",checked:q,onChange:s=>Q(s.target.checked),"data-testid":"checkbox-follow-start-now"}),e.jsxs("span",{children:["Start following straight away",e.jsx("span",{className:"block text-muted-foreground",children:"Leave this off to queue the list and start it yourself from the Auto Follow page. One account can only run one follow campaign at a time."})]})]})]}),e.jsxs(Ce,{children:[e.jsx(m,{variant:"outline",onClick:()=>R(null),children:"Cancel"}),e.jsxs(m,{disabled:!z||G.isPending,onClick:()=>G.mutate({uploadId:t.id,accountId:Number(z),name:re.trim()||`Auto Follow â ${t.fileName}`,isEnabled:q}),"data-testid":"button-confirm-import-follow",children:[G.isPending?e.jsx(O,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(we,{className:"h-4 w-4 mr-1"}),q?"Queue & start":"Queue it"]})]})]})]}),e.jsxs(ge,{open:Ee===t.id,onOpenChange:s=>{s||(F(null),B(""),V(""))},children:[e.jsx(je,{asChild:!0,children:e.jsxs(m,{variant:"outline",size:"sm",onClick:()=>F(t.id),children:[e.jsx(lt,{className:"h-3.5 w-3.5 mr-1"})," Import to Campaign"]})}),e.jsxs(ve,{children:[e.jsxs(Ne,{children:[e.jsx(ye,{children:"Import to Campaign"}
3),e.jsxs(be,{children:["Import ",t.filteredCount?.toLocaleString(),' can-DM accounts from "',t.fileName,'" into a DM campaign.']})]}),e.jsxs(Se,{value:I,onValueChange:B,children:[e.jsx(ke,{children:e.jsx(De,{placeholder:"Select a campaign"})}),e.jsx(_e,{children:Ae.map(s=>e.jsxs(Fe,{value:s.id.toString(),children:[s.name," (",s.status,")"]},s.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Bio Keywords (optional)"}),e.jsx(T,{value:ce,onChange:s=>V(s.target.value),placeholder:"ceo, marketing, cfo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If set, only uploaded contacts with matching bio keywords will be imported."})]}),e.jsxs(Ce,{children:[e.jsx(m,{variant:"outline",onClick:()=>F(null),children:"Cancel"}),e.jsxs(m,{disabled:!I||J.isPending,onClick:()=>{if(I){const s=ce.split(",").map(d=>d.trim().toLowerCase()).filter(Boolean);J.mutate({uploadId:t.id,campaignId:parseInt(I),bioKeywords:s.length>0?s:void 0})}},children:[J.isPending?e.jsx(O,{className:"h-4 w-4 mr-1 animate-spin"}):null,"Import"]})]})]})]}),e.jsx(m,{variant:"ghost",size:"icon",className:"text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>me.mutate(t.id),disabled:me.isPending,children:e.jsx(nt,{className:"h-4 w-4"})})]})]})},t.id)),ee>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",D," of ",ee]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(m,{variant:"ghost",size:"icon",disabled:D<=1,onClick:()=>oe(t=>t-1),children:e.jsx(Re,{className:"h-4 w-4"})}),e.jsx(m,{variant:"ghost",size:"icon",disabled:D>=ee,onClick:()=>oe(t=>t+1),children:e.jsx(Le,{className:"h-4 w-4"})})]})]})]})})]})]})}export{bt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.