1import{aq as ie,r,j as s}from"./main-pnTGyimK.js";import{u as c}from"./useServerFn-DUeU0Ufg.js";import{u as U}from"./useQuery-FTT3c7Hc.js";import{u as d}from"./useMutation-B_BKdajJ.js";import{B as n}from"./button-DIR9WBfX.js";import{I as D}from"./input-CJacE37n.js";import{T as g}from"./textarea-B_OcCr5H.js";import{l as ce,i as de,g as oe}from"./marketing.functions-D7I-7rl7.js";import{d as me,c as xe,r as ue,g as he,s as pe,p as ge,h as ye}from"./marketing-autonomous.functions-CSo3E_6w.js";import{t as a}from"./index-Df_8PB_U.js";import"./client.server-BJo0ePXJ.js";function we(){const o=ie(),$=c(ce),G=c(de),B=c(oe),T=c(me),O=c(xe),H=c(ue),I=c(he),V=c(pe),Y=c(ge),J=c(ye),y=U({queryKey:["mkt-prospects"],queryFn:()=>$({data:{}})}),W=U({queryKey:["calendly"],queryFn:()=>I({data:{}})}),[b,A]=r.useState(""),[E,X]=r.useState("Türkiye online butik shopify"),[z,Z]=r.useState(8),[m,ee]=r.useState(!1),[l,se]=r.useState(null),[j,R]=r.useState(""),[N,q]=r.useState(!1),[k,te]=r.useState(null),[v,f]=r.useState(null),[S,u]=r.useState(""),[i,h]=r.useState(null),_=d({mutationFn:()=>{const e=b.split(` 2`).map(t=>t.trim()).filter(Boolean).map(t=>{const[F,re,Q]=t.split(",").map(ne=>ne?.trim());return{handle:F.replace(/^@/,""),display_name:re,follower_count:Q?Number(Q):void 0}});return G({data:{rows:e}})},onSuccess:e=>{a.success(`${e.count} aday eklendi${e.skipped?` · ${e.skipped} gönderilmiÅ maÄaza atlandı`:""}`),A(""),o.invalidateQueries({queryKey:["mkt-prospects"]})},onError:e=>a.error(e?.message??"CSV hatası")}),M=d({mutationFn:()=>T({data:{query:E,limit:z,aggressive:m}}),onSuccess:e=>{se(e),a.success(e.message??`${e.count} aday eklendi`),e.needsManualUrls&&q(!0),o.invalidateQueries({queryKey:["mkt-prospects"]})},onError:e=>a.error(e?.message??"KeÅif hatası")}),C=d({mutationFn:()=>{const e=j.split(/[\s,]+/).map(t=>t.trim()).filter(t=>/^https?:\/\//i.test(t));if(e.length===0)throw new Error("Geçerli URL bulunamadı (http/https ile baÅlamalı).");return Y({data:{urls:e}})},onSuccess:e=>{te(e),a.success(e.message),R(""),o.invalidateQueries({queryKey:["mkt-prospects"]})},onError:e=>a.error(e?.message??"Manuel URL hatası")}),P=d({mutationFn:()=>V({data:{limit:15}}),onSuccess:e=>{a.success(e.message??`${e.scored} aday skorlandı`),o.invalidateQueries({queryKey:["mkt-prospects"]})},onError:e=>a.error(e?.message??"Skorlama hatası")}),[p,ae]=r.useState(null),x=d({mutationFn:e=>J({data:{...e,limit:15}}),onSuccess:e=>{ae(e),a.success(e.message),o.invalidateQueries({queryKey:["mkt-prospects"]})},onError:e=>a.error(e?.message??"Email tarama hatası")}),L=d({mutationFn:e=>B({data:{prospect_id:e}}),onSuccess:()=>{a.success("3 DM taslaÄı üretildi"),o.invalidateQueries({queryKey:["mkt-prospects"]})},onError:e=>a.error(e?.message??"Hata")}),w=d({mutationFn:()=>O({data:{prospect_id:v,reply_text:S}}),onSuccess:e=>{h(e),a.success(`Sentiment: ${e.sentiment}`),o.invalidateQueries({queryKey:["mkt-prospects"]})},onError:e=>a.error(e?.message??"Analiz hatası")}),K=d({mutationFn:e=>H({data:{prospect_id:v,body:e}}),onSuccess:()=>{a.success("Yanıt kaydedildi"),u(""),h(null),f(null)},onError:e=>a.error(e?.message??"Hata")}),le=W.data?.link;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-slate-50",children:"Smart Prospector"}),s.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"Otomatik butik keÅfi (Firecrawl + Gemini), CSV import, DM üretimi ve gelen yanıt sentiment analizi."})]}),!le&&s.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-200",children:"CALENDLY_LINK secret tanımlı görünmüyor â positive yanıtlara otomatik takvim linki eklenmeyecek."}),s.jsxs("section",{className:"rounded-xl border border-cyan-500/30 bg-cyan-500/5 p-5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-cyan-100",children:"â¡ Otonom KeÅif (Firecrawl + Gemini)"}),s.jsx("p",{className:"mt-1 text-xs text-cyan-200/70",children:m?"AGRESİF: niÅ arama operatörleri (myshopify, ticimax, tsoft) + geniÅ fallback. Filtreler gevÅek, ikinci turda Gemini kalite skoru verir.":"Tech-stack tespit eder (Shopify/IdeaSoft/Ticimax vs.), Gemini butik uygunluÄunu skorlar, adaylıÄa otomatik düÅer."})]}),s.jsxs("label",{className:"flex shrink-0 cursor-pointer items-center gap-2 rounded-md border border-cyan-500/40 bg-slate-950/60 px-2.5 py-1.5 text-xs text-cyan-100",children:[s.jsx("input",{type:"checkbox",checked:m,onChange:e=>ee(e.target.checked),className:"accent-cyan-500"}),"Agresif tarama"]})]}),s.jsxs("div",{className:"mt-3 grid gap-2 md:grid-cols-[1fr_120px_auto_auto]",children:[s.jsx(D,{value:E,onChange:e=>X(e.target.value),disabled:m,className:"bg-slate-950 border-slate-700",placeholder:m?"Agresif modda niÅ query seti otomatik kullanılır":"arama sorgusu"}),s.jsx(D,{type:"number",min:1,max:20,value:z,onChange:e=>Z(Math.max(1,Math.min(20,Number(e.target.value)||8))),className:"bg-slate-950 border-slate-700"}),s.jsx(n,{onClick:()=>M.mutate(),disabled:M.isPending,className:"bg-cyan-500 text-slate-950 hover:bg-cyan-400",children:M.isPending?"Aranıyor...":m?"Agresif tara":"Butik avla"}),s.jsx(n,{onClick:()=>P.mutate(),disabled:P.isPending,variant:"outline",className:"border-cyan-500/40 text-cyan-100 hover:bg-cyan-500/10",children:P.isPending?"Skorlanıyor...":"Kalite skorla"}),s.jsx(n,{onClick:()=>x.mutate({only_missing:!0}),disabled:x.isPending,variant:"outline",className:"border-emerald-500/40 text-emerald-100 hover:bg-emerald-500/10 md:col-span-4",children:x.isPending?"ð§ Mailler toplanıyor...":"ð§ E-mail topla (e-postası olmayan adaylardan)"})]}),l&&s.jsxs("div",{className:"mt-4 rounded-md border border-slate-800 bg-slate-950/70 p-3 text-xs",children:[s.jsxs("p",{className:"text-cyan-200",children:["Rapor: ",l.count," eklendi · ",l.scanned," site tarandı",l.aggressive?" · agresif":""]}),s.jsx("p",{className:"mt-1 text-slate-400",children:l.message}),Array.isArray(l.report)&&l.report.length>0&&s.jsxs("table",{className:"mt-2 w-full text-[11px] text-slate-300",children:[s.jsx("thead",{className:"text-slate-500",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left font-normal",children:"Sorgu"}),s.jsx("th",{className:"text-right font-normal",children:"Bulundu"}),s.jsx("th",{className:"text-right font-normal",children:"Kabul"}),s.jsx("th",{className:"text-left font-normal pl-3",children:"Sebep"})]})}),s.jsx("tbody",{children:l.report.map((e,t)=>s.jsxs("tr",{className:"border-t border-slate-800/60",children:[s.jsx("td",{className:"py-1 pr-2 font-mono text-[10px] text-cyan-300/80",children:e.query}),s.jsx("td",{className:"py-1 text-right",children:e.found}),s.jsx("td",{className:`py-1 text-right ${e.accepted>0?"text-emerald-300":"text-rose-300"}`,children:e.accepted}),s.jsx("td",{className:"py-1 pl-3 text-slate-400",children:e.reason??"â"})]},t))})]}),Array.isArray(l.skipped)&&l.skipped.length>0&&s.jsxs("p",{className:"mt-2 text-[10px] text-slate-500",children:["Atlanan örnekler: ",l.skipped.join(" · ")]})]}),p&&s.jsxs("div",{className:"mt-4 rounded-md border border-emerald-500/30 bg-emerald-500/5 p-3 text-xs",children:[s.jsxs("p",{className:"text-emerald-200",children:["ð§ ",p.message]}),p.results?.length>0&&s.jsx("ul",{className:"mt-2 space-y-1 text-[11px] max-h-48 overflow-auto",children:p.results.map(e=>s.jsxs("li",{className:e.emails.length>0?"text-emerald-300":"text-slate-500",children:[e.emails.length>0?"â":"â"," @",e.handle,e.emails.length>0&&s.jsx("span",{className:"ml-2 text-emerald-200",children:e.emails.join(", ")})]},e.id))})]})]}),s.jsxs("section",{className:`rounded-xl border p-5 ${N||l&&l.count===0?"border-amber-500/40 bg-amber-500/5":"border-slate-800 bg-slate-900/50"}`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-amber-100",children:"ð Manuel URL Listesi â Otonom Tech-Stack Analizi"}),s.jsxs("p",{className:"mt-1 text-xs text-amber-200/70",children:["Google'dan kopyaladıÄınız butik URL'lerini y
2apıÅtırın. Sistem her birini Firecrawl ile tarar, tech-stack tespiti yapar ve aday olarak ekler.",l&&l.needsManualUrls&&" Otonom keÅif 0 sonuç döndü â devreye giriyor."]})]}),s.jsx(n,{size:"sm",variant:"ghost",onClick:()=>q(e=>!e),className:"text-amber-200 hover:bg-amber-500/10",children:N?"Gizle":"Aç"})]}),N&&s.jsxs(s.Fragment,{children:[s.jsx(g,{value:j,onChange:e=>R(e.target.value),rows:5,placeholder:`https://butik1.com 3https://butik2.com.tr 4https://shop.butik3.com`,className:"mt-3 bg-slate-950 border-slate-700 text-sm font-mono"}),s.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Her satıra bir URL (max 40). Virgül/boÅluk/satırsonu ayraç olarak kabul edilir."}),s.jsx(n,{onClick:()=>C.mutate(),disabled:!j.trim()||C.isPending,className:"mt-3 bg-amber-500 text-slate-950 hover:bg-amber-400",children:C.isPending?"Taranıyor...":"URL listesini tara"}),k&&s.jsxs("div",{className:"mt-3 rounded-md border border-slate-800 bg-slate-950/70 p-3 text-xs",children:[s.jsx("p",{className:"text-amber-200",children:k.message}),s.jsx("ul",{className:"mt-2 space-y-1 text-[11px]",children:(k.results??[]).map((e,t)=>s.jsxs("li",{className:e.ok?"text-emerald-300":"text-rose-300",children:[e.ok?"â":"â"," ",e.host??e.url,e.ok&&e.tech_stack?.length>0&&s.jsxs("span",{className:"text-cyan-400/80",children:[" · ",e.tech_stack.join(", ")]}),!e.ok&&s.jsxs("span",{className:"text-slate-500",children:[" â ",e.reason]})]},t))})]})]})]}),s.jsxs("section",{className:"rounded-xl border border-slate-800 bg-slate-900/50 p-5",children:[s.jsx("p",{className:"text-sm font-medium text-slate-200",children:"Manuel CSV import"}),s.jsxs("p",{className:"mt-1 text-xs text-slate-400",children:["Satır baÅına: ",s.jsx("code",{className:"text-cyan-300",children:"handle, ad, takipçi"})]}),s.jsx(g,{value:b,onChange:e=>A(e.target.value),rows:4,placeholder:"butik_aysenur, AyÅenur Moda, 12500",className:"mt-2 bg-slate-950 border-slate-700 text-sm"}),s.jsx(n,{onClick:()=>_.mutate(),disabled:!b.trim()||_.isPending,className:"mt-3 bg-cyan-500 text-slate-950 hover:bg-cyan-400",children:_.isPending?"Ekleniyor...":"Adayları ekle"})]}),s.jsxs("section",{className:"rounded-xl border border-slate-800 bg-slate-900/50",children:[s.jsx("div",{className:"border-b border-slate-800 px-5 py-3",children:s.jsxs("p",{className:"text-sm font-medium text-slate-200",children:["Adaylar (",y.data?.items.length??0,")"]})}),s.jsxs("div",{className:"divide-y divide-slate-800",children:[(y.data?.items??[]).map(e=>s.jsxs("div",{className:"px-5 py-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"font-medium text-slate-100",children:["@",e.handle]}),s.jsxs("p",{className:"text-xs text-slate-400",children:[e.display_name??"â"," · ",e.follower_count??"?"," takipçi · ",e.status,e.last_sentiment?` · ${e.last_sentiment}`:""]}),e.website_url&&s.jsx("p",{className:"text-xs text-slate-500",children:e.website_url}),e.email?s.jsxs("p",{className:"text-xs text-emerald-300",children:["ð§ ",s.jsx("a",{href:`mailto:${e.email}`,className:"underline hover:text-emerald-200",children:e.email})]}):s.jsx("p",{className:"text-xs text-slate-600 italic",children:"ð§ e-posta yok"}),(e.tech_stack??[]).length>0&&s.jsxs("p",{className:"text-xs text-cyan-400/80",children:["Tech: ",e.tech_stack.join(", ")]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(n,{size:"sm",variant:"outline",className:"border-slate-700",onClick:()=>{f(e.id),u(""),h(null)},children:"Yanıt analizi"}),!e.email&&e.website_url&&s.jsx(n,{size:"sm",variant:"outline",className:"border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/10",onClick:()=>x.mutate({prospect_ids:[e.id],only_missing:!1}),disabled:x.isPending,children:"ð§ Mail bul"}),s.jsx(n,{size:"sm",variant:"outline",className:"border-slate-700",onClick:()=>L.mutate(e.id),disabled:L.isPending,children:"DM üret"})]})]}),v===e.id&&s.jsxs("div",{className:"mt-3 rounded-md border border-cyan-500/30 bg-slate-950/80 p-3",children:[s.jsx("p",{className:"text-xs font-medium text-cyan-200",children:"Gelen DM yanıtını yapıÅtır"}),s.jsx(g,{value:S,onChange:t=>u(t.target.value),rows:3,className:"mt-2 bg-slate-950 border-slate-700 text-sm",placeholder:"Aday butiÄin DM yanıtı..."}),s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsx(n,{size:"sm",onClick:()=>w.mutate(),disabled:!S.trim()||w.isPending,className:"bg-cyan-500 text-slate-950 hover:bg-cyan-400",children:w.isPending?"Analiz...":"Sentiment analiz et"}),s.jsx(n,{size:"sm",variant:"ghost",onClick:()=>{f(null),u(""),h(null)},children:"Kapat"})]}),i&&s.jsxs("div",{className:"mt-3 rounded-md border border-slate-800 bg-slate-900 p-3 text-xs space-y-2",children:[s.jsxs("p",{children:[s.jsx("span",{className:"text-cyan-300",children:"Sentiment:"})," ",s.jsx("b",{className:i.sentiment==="positive"?"text-emerald-400":i.sentiment==="negative"?"text-rose-400":"text-amber-300",children:i.sentiment}),i.pricing_objection&&s.jsx("span",{className:"ml-2 text-amber-300",children:"· fiyat itirazı"})]}),s.jsxs("p",{children:[s.jsx("span",{className:"text-cyan-300",children:"Aksiyon:"})," ",i.next_action]}),s.jsx("p",{className:"text-slate-400",children:i.ai_reasoning}),s.jsxs("div",{className:"rounded border border-slate-700 bg-slate-950 p-2",children:[s.jsx("p",{className:"text-xs text-emerald-300 mb-1",children:"Ãnerilen yanıt:"}),s.jsx(g,{defaultValue:i.suggested_reply,rows:4,className:"bg-slate-950 border-slate-800 text-xs",id:`sugg-${e.id}`}),i.calendly_link&&s.jsxs("p",{className:"mt-1 text-xs text-cyan-400",children:["ð ",i.calendly_link]}),s.jsx(n,{size:"sm",className:"mt-2 bg-emerald-500 text-slate-950 hover:bg-emerald-400",onClick:()=>{const F=document.getElementById(`sugg-${e.id}`)?.value||i.suggested_reply;K.mutate(F)},disabled:K.isPending,children:"Bu yanıtı gönderildi olarak iÅaretle"})]})]})]}),(e.marketing_dm_drafts??[]).length>0&&s.jsx("div",{className:"mt-3 grid gap-2 md:grid-cols-3",children:e.marketing_dm_drafts.map(t=>s.jsxs("div",{className:"rounded-md border border-slate-800 bg-slate-950/60 p-3",children:[s.jsx("p",{className:"text-xs font-medium text-cyan-300",children:t.variant_label}),s.jsx("p",{className:"mt-1 whitespace-pre-wrap text-xs text-slate-300",children:t.body})]},t.id))})]},e.id)),(y.data?.items??[]).length===0&&s.jsx("p",{className:"px-5 py-8 text-center text-sm text-slate-500",children:"Henüz aday yok."})]})]})]})}export{we as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.