1import{u as ie,r as c,s as l,j as e,L as ne,B as b,A as ce,aA as le,as as de,aX as me,n as pe,F as ue,aL as fe,_ as xe,O as H,S as he,a as ge,b as je,c as be,d as _e,o as ye,w as we,R as ve,Q as V,G as Z,D as t}from"./index-BwaMfbd5.js";import{T as Ne}from"./ToolOnboarding-51IT1WYZ.js";import{C as Ie,O as ke}from"./OutreachDraftGenerator-Dy5qTMa0.js";import{s as Se}from"./sanitizeMarkdown-DtcAht-1.js";import{n as K}from"./shared-generation-cards-B6sSAxZv.js";import{S as Ce}from"./SavedGenerations-CbOi-1YQ.js";import{P as Me}from"./phone-IkZCt3hH.js";import{R as Ee}from"./rotate-ccw-BvIKsJnI.js";import"./calendar-BSmI-3yV.js";import"./building-2-BoehZm97.js";import"./linkedin-B9DVNZAB.js";import"./popover-CmSlzXqW.js";import"./index-B6dmojrU.js";import"./mediaAssets-DmbuxhZf.js";import"./scroll-area-DokqGbPN.js";import"./award-BpCaHk3W.js";import"./TikTokAdPreviewCard-CHU_GPfb.js";import"./GoogleAdPreviewCard-C5jY9Tvw.js";import"./UsageLimitModal-Bl_-mwAr.js";import"./image-C5Jyz2ta.js";import"./bookmark-C0NmHXuh.js";import"./music-BKzXt9YM.js";import"./mouse-pointer-click-CXMIhW8N.js";import"./dollar-sign-AcsFX6va.js";import"./type-CfpVrT6l.js";import"./lightbulb-Lt1y7v68.js";import"./download-CIy4X3xv.js";import"./circle-check-big-BgY6TOzv.js";import"./formatDistanceToNow-Q1M_WJaA.js";import"./en-US-xHSDCZDo.js";import"./endOfMonth-Dj-hEvVp.js";import"./es-mB7MmlTZ.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},N=new o.Error().stack;N&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[N]="0ff7e7fb-1c93-4a97-b10b-7e738124755a",o._sentryDebugIdIdentifier="sentry-dbid-0ff7e7fb-1c93-4a97-b10b-7e738124755a")}catch{}})();function ls(){var O;const{activeBrandId:o,setActiveBrand:N}=ie(),[I,W]=c.useState([]),[r,P]=c.useState(()=>o||""),X=s=>{P(s),s&&s!==o&&N(s)},[_,R]=c.useState(""),[i,E]=c.useState(""),[y,L]=c.useState(!1),[m,D]=c.useState("output"),[Q,Y]=c.useState(0),k=c.useRef(null),T=((O=I.find(s=>s.id===r))==null?void 0:O.brand_name)||"";c.useEffect(()=>{o&&o!==r&&P(o)},[o]),c.useEffect(()=>{l.from("projects").select("id, brand_name, brief, industry, tags, context_summary").order("brand_name").then(({data:s})=>{s&&W(s)})},[]);const ee=async()=>{var d,g,w,a,v,G,A;if(!r){t.error("toast_error.selecciona_un_proyecto_primero","Selecciona un proyecto primero");return}if(!_.trim()){t.error("toast_error.ingresa_al_menos_un","Ingresa al menos un dominio");return}L(!0),E(""),D("output");const s=_.split(` 2`).map(p=>p.trim()).filter(Boolean).slice(0,5);try{let p="";for(const h of s){t.info("toast_info.mapeando",`Mapeando ${h}...`);const{data:u}=await l.functions.invoke("firecrawl-map",{body:{url:h,options:{limit:50}}}),j=(u==null?void 0:u.links)||(u==null?void 0:u.data)||[],S=j.slice(0,30).join(` 3`),C=[/about/i,/pricing/i,/contact/i,/servic/i,/product/i,/nosotros/i,/equipo/i,/team/i],U=j.filter(n=>C.some(M=>M.test(n))).slice(0,4);let f=h.trim();f.startsWith("http")||(f=`https://${f}`);const q=[f,...U.filter(n=>n!==f)].slice(0,5);t.info("toast_info.scrapeando_páginas_de",`Scrapeando ${q.length} páginas de ${h}...`);const oe=await Promise.allSettled(q.map(n=>l.functions.invoke("firecrawl-scrape",{body:{url:n,options:{formats:["markdown"]}}})));let F=` 4 5=== DOMINIO: ${h} === 6Mapa del sitio (${j.length} URLs encontradas): 7${S} 8`;for(const n of oe)if(n.status==="fulfilled"&&n.value.data){const M=((g=(d=n.value.data)==null?void 0:d.data)==null?void 0:g.markdown)||((w=n.value.data)==null?void 0:w.markdown)||"";M&&(F+=` 9--- PÃGINA --- 10${M.substring(0,3e3)} 11`)}p+=F}if(!p.trim()){t.warning("toast_warning.no_se_pudo_extraer","No se pudo extraer contenido de los dominios."),L(!1);return}t.info("toast_info.maasy_ia_está_generando","Maasy IA está generando perfil enriquecido...");const $=await fetch("https://esptwxlgdbblvnmdpoao.supabase.co/functions/v1/be-tools-generate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImVzcHR3eGxnZGJibHZubWRwb2FvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Nzc3MzI4NTAsImV4cCI6MjA5MzMwODg1MH0.tjN9OV2oRxU1ScNLgLLlEZK-HEi7OoH9p2tnJghLjKI"},body:JSON.stringify({project_id:r,tool_type:"lead-intel",params:{domain:s.join(", "),scraped_content:p,site_map:p.substring(0,3e3)}})});if(!$.ok)throw new Error("Error al generar análisis");const B=(a=$.body)==null?void 0:a.getReader();if(!B)throw new Error("No stream");const ae=new TextDecoder;let z="",J="";for(;;){const{done:h,value:u}=await B.read();if(h)break;z+=ae.decode(u,{stream:!0});const j=z.split(` 12`);z=j.pop()||"";for(const S of j){if(!S.startsWith("data: "))continue;const C=S.slice(6).trim();if(C!=="[DONE]")try{const f=(A=(G=(v=JSON.parse(C).choices)==null?void 0:v[0])==null?void 0:G.delta)==null?void 0:A.content;f&&(J+=f,E(J),k.current&&(k.current.scrollTop=k.current.scrollHeight))}catch{}}}t.success("toast_success.perfil_de_prospecto_generado","Perfil de prospecto generado")}catch(p){t.error("toast_error.errmessage_error_al_generar",p.message||"Error al generar")}finally{L(!1)}},se=async()=>
12{if(!i||!r)return;const{data:{user:s}}=await l.auth.getUser();if(!s){t.error("toast_error.debes_iniciar_sesión","Debes iniciar sesión");return}const{error:d}=await l.from("tool_generations").insert([{project_id:r,tool_type:"lead-intel",title:`Lead Intelligence â ${T}`,content:i,params:{domains:_},created_by:s.id}]);d?t.error("toast_error.error_al_guardar","Error al guardar"):(t.success("toast_success.perfil_guardado","Perfil guardado"),Y(g=>g+1))},te=async()=>{if(!i||!r)return;const{data:s}=await l.from("project_deliverables").select("id").eq("project_id",r).eq("section_key","lead-intelligence").maybeSingle();if(s){const{error:d}=await l.from("project_deliverables").update({content:K(i)}).eq("id",s.id);d?t.error("toast_error.error_al_actualizar","Error al actualizar"):t.success("toast_success.sección_actualizada_en_documento","Sección actualizada en Documento Maestro")}else{const{error:d}=await l.from("project_deliverables").insert([{project_id:r,phase:"phase_1_diagnosis",section_key:"lead-intelligence",title:"Inteligencia de Prospectos / Leads",content:K(i),sort_order:100}]);d?t.error("toast_error.error_al_insertar","Error al insertar"):t.success("toast_success.insertado_en_documento_maestro","Insertado en Documento Maestro")}},re=async()=>{var w;if(!i)return;const{data:{user:s}}=await l.auth.getUser();if(!s){t.error("toast_error.debes_iniciar_sesión","Debes iniciar sesión");return}const g=_.split(` 13`).map(a=>a.trim()).filter(Boolean)[0]||"";t.info("toast_info.importando_al_crm","Importando al CRM...");try{const{data:a,error:v}=await l.functions.invoke("crm-import-from-intelligence",{body:{domain:g,intelligence_output:i,user_id:s.id}});if(v)throw v;a!=null&&a.success?t.success("toast_success.importada_al_crm_con",`${a.company_name} importada al CRM con ${((w=a.contact_ids)==null?void 0:w.length)||0} contactos`):t.error("toast_error.operation_failed",(a==null?void 0:a.error)||"Error al importar")}catch(a){t.error("toast_error.errmessage_error_al_enviar",a.message||"Error al enviar al CRM")}},x=I.find(s=>s.id===r);return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b px-6 py-4 flex items-center gap-3 bg-gradient-to-r from-card to-card/80",children:[e.jsx(ne,{to:"/be-tools",children:e.jsx(b,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ce,{className:"h-4 w-4"})})}),e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-primary/15 to-accent/10 shadow-colored",children:e.jsx(le,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold tracking-tight text-foreground",children:"Lead Intelligence"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enriquecimiento de prospectos desde su sitio web"})]})]}),e.jsx(Ne,{toolKey:"lead-intelligence",title:"Bienvenido a Maasy Leads Intelligenceâ¢",steps:[{icon:"1ï¸â£",text:"Descubre leads potenciales basados en tu ICP y mercado"},{icon:"2ï¸â£",text:"Enriquece leads con datos de empresa, cargo y señales de compra"},{icon:"3ï¸â£",text:"Exporta a CRM o envÃa follow-up directo con WhatsApp o email"}]}),e.jsxs("div",{className:"border-b px-6 pt-1 flex items-center justify-between",children:[e.jsx("div",{className:"inline-flex h-10 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground shadow-premium-xs",children:[{key:"output",label:"Perfil",icon:e.jsx(de,{className:"h-3.5 w-3.5 mr-1.5"})},{key:"saved",label:"Guardados",icon:null},{key:"call-prep",label:"Call Prep",icon:e.jsx(Me,{className:"h-3.5 w-3.5 mr-1.5"})},{key:"outreach",label:"Outreach",icon:e.jsx(me,{className:"h-3.5 w-3.5 mr-1.5"})}].map(s=>e.jsxs("button",{onClick:()=>D(s.key),className:pe("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium transition-all duration-200",m===s.key?"bg-background text-foreground shadow-premium-sm border-b-2 border-primary":"hover:text-foreground/80"),children:[s.icon,s.label]},s.key))}),i&&!y&&m==="output"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",variant:"outline",onClick:re,className:"h-7 text-xs gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}
13)," Enviar al CRM"]}),e.jsxs(b,{size:"sm",variant:"outline",onClick:te,className:"h-7 text-xs gap-1",children:[e.jsx(fe,{className:"h-3 w-3"})," Insertar al Doc"]}),e.jsxs(b,{size:"sm",onClick:se,className:"h-7 text-xs gap-1",children:[e.jsx(xe,{className:"h-3 w-3"})," Guardar"]})]})]}),m==="call-prep"&&e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Ie,{projectId:r,projectName:T})}),m==="outreach"&&e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(ke,{projectId:r,projectName:T})}),m!=="call-prep"&&m!=="outreach"&&e.jsxs("div",{className:"flex flex-col md:flex-row flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-full md:w-[380px] md:shrink-0 border-b md:border-b-0 md:border-r overflow-y-auto p-4 md:p-5 space-y-5 bg-muted/10 max-h-[40vh] md:max-h-none",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium",children:"Proyecto"}),e.jsxs(he,{value:r,onValueChange:X,children:[e.jsx(ge,{children:e.jsx(je,{placeholder:"Selecciona un proyecto"})}),e.jsx(be,{children:I.map(s=>e.jsx(_e,{value:s.id,children:s.brand_name},s.id))})]})]}),x&&e.jsx(ye,{className:"bg-muted/30 border-primary/10",children:e.jsxs(we,{className:"p-3 space-y-1.5 text-xs",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground",children:x.brand_name}),x.industry&&e.jsxs("p",{className:"text-muted-foreground",children:["Industria: ",e.jsx("span",{className:"text-foreground",children:x.industry})]}),x.tags&&x.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:x.tags.map(s=>e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-primary/10 text-primary text-[10px]",children:s},s))})]})}),e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-border to-transparent"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium",children:"Dominios de Prospectos"}),e.jsx(ve,{placeholder:`ejemplo.com 14otraempresa.com 15prospecto3.com`,value:_,onChange:s=>R(s.target.value),rows:5}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Un dominio por lÃnea. Máximo 5. El sistema mapeará y scrapeará cada sitio automáticamente."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(b,{onClick:ee,disabled:y||!r,className:"flex-1 shadow-colored active:scale-[0.98]",children:y?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"mr-2 h-4 w-4 animate-spin"})," Investigando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"mr-2 h-4 w-4"})," Investigar Prospectos"]})}),e.jsx(b,{variant:"outline",size:"icon",onClick:()=>{E(""),R("")},title:"Limpiar",children:e.jsx(Ee,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[m==="output"&&(i||y?e.jsxs("div",{ref:k,className:"p-6 overflow-y-auto h-full",children:[e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground",children:Se(i)}),y&&e.jsxs("div",{className:"flex items-center gap-2 mt-4 text-muted-foreground",children:[e.jsx(V,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Investigando sitio web..."})]})]}):e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("div",{className:"mx-auto w-20 h-20 rounded-2xl bg-gradient-to-br from-primary/10 to-accent/5 flex items-center justify-center",children:e.jsx(Z,{className:"h-10 w-10 text-primary/30"})}),e.jsx("p",{className:"text-sm font-medium",children:"Ingresa dominios de prospectos"}),e.jsx("p",{className:"text-xs opacity-60",children:"Mapeo automático, scraping y perfil enriquecido con Maasy IA"})]})})),m==="saved"&&e.jsx("div",{className:"overflow-y-auto h-full bg-muted/20",children:e.jsx(Ce,{toolType:"lead-intel",projectId:r},Q)})]})})]})]})}export{ls as default}; 16//# sourceMappingURL=BeToolLeadIntelligence-Dg0R7rj_.js.map
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.