1import{y as ce,r as n,s as c,j as e,aA as le,h as de,as as me,aX as pe,m as ue,B as N,F as fe,aL as xe,_ as he,O as V,S as ge,a as je,b as be,c as _e,d as ye,n as we,q as ve,R as Ne,Q as Z,G as K,D as t}from"./index-CuMcGkrh.js";import{s as Ie}from"./sanitizeMarkdown-BKLTdyMt.js";import{n as W}from"./shared-generation-cards-BcnYV8lQ.js";import{T as ke}from"./ToolOnboarding-DAf_wZvi.js";import{C as Se,O as Ce}from"./OutreachDraftGenerator-DRZbJywG.js";import{S as Me}from"./SavedGenerations-DJMwqzFs.js";import{P as Ee}from"./phone-DiwC1bj0.js";import{R as Pe}from"./rotate-ccw-CopXHBuO.js";import"./popover-Ct6GlC1w.js";import"./index-6Azjw9Lk.js";import"./mediaAssets-DkhlN-rV.js";import"./scroll-area-CNj6EK8I.js";import"./award-Bx8KuJUn.js";import"./TikTokAdPreviewCard-BZ1-x86o.js";import"./GoogleAdPreviewCard-CFeWoOzV.js";import"./UsageLimitModal-C2c90czF.js";import"./image-SkV5sC4d.js";import"./bookmark-DC-aggmC.js";import"./music-Dp_lI__u.js";import"./mouse-pointer-click-Co28Cb-j.js";import"./dollar-sign-B2OY8-rg.js";import"./type-B82ed-Vx.js";import"./lightbulb-Cad6Pcoh.js";import"./download-B1BTuZAS.js";import"./circle-check-big-Bv244657.js";import"./formatDistanceToNow-GsinHOiH.js";import"./en-US-xHSDCZDo.js";import"./endOfMonth-CmwZJ6b_.js";import"./es-WaaJgypT.js";import"./calendar-DL9Dxjqm.js";import"./building-2-JF30UcJJ.js";import"./linkedin-Dtn9Ut-c.js";(function(){try{var x=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new x.Error().stack;l&&(x._sentryDebugIds=x._sentryDebugIds||{},x._sentryDebugIds[l]="6ba6b2ed-0b49-4acd-aa4b-d0e077c0ea85",x._sentryDebugIdIdentifier="sentry-dbid-6ba6b2ed-0b49-4acd-aa4b-d0e077c0ea85")}catch{}})();function ds(x){var G;const{activeBrandId:l,setActiveBrand:R}=ce(),X=x.canonicalId??l??"",[M,Q]=n.useState([]),[r,z]=n.useState(X),Y=s=>{z(s),s&&s!==l&&R(s)},[_,D]=n.useState(""),[o,E]=n.useState(""),[y,P]=n.useState(!1),[m,O]=n.useState("output"),[ee,se]=n.useState(0),I=n.useRef(null),T=((G=M.find(s=>s.id===r))==null?void 0:G.brand_name)||"";n.useEffect(()=>{l&&l!==r&&z(l)},[l]),n.useEffect(()=>{c.from("projects").select("id, brand_name, brief, industry, tags, context_summary").order("brand_name").then(({data:s})=>{s&&Q(s)})},[]);const te=async()=>{var d,j,w,a,v,$,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}P(!0),E(""),O("output");const s=_.split(` 2`).map(p=>p.trim()).filter(Boolean).slice(0,5);try{let p="";for(const g of s){t.info("toast_info.mapeando",`Mapeando ${g}...`);const{data:u}=await c.functions.invoke("firecrawl-map",{body:{url:g,options:{limit:50}}}),b=(u==null?void 0:u.links)||(u==null?void 0:u.data)||[],k=b.slice(0,30).join(` 3`),S=[/about/i,/pricing/i,/contact/i,/servic/i,/product/i,/nosotros/i,/equipo/i,/team/i],U=b.filter(i=>S.some(C=>C.test(i))).slice(0,4);let f=g.trim();f.startsWith("http")||(f=`https://${f}`);const F=[f,...U.filter(i=>i!==f)].slice(0,5);t.info("toast_info.scrapeando_páginas_de",`Scrapeando ${F.length} páginas de ${g}...`);const ne=await Promise.allSettled(F.map(i=>c.functions.invoke("firecrawl-scrape",{body:{url:i,options:{formats:["markdown"]}}})));let H=` 4 5=== DOMINIO: ${g} === 6Mapa del sitio (${b.length} URLs encontradas): 7${k} 8`;for(const i of ne)if(i.status==="fulfilled"&&i.value.data){const C=((j=(d=i.value.data)==null?void 0:d.data)==null?void 0:j.markdown)||((w=i.value.data)==null?void 0:w.markdown)||"";C&&(H+=` 9--- PÃGINA --- 10${C.substring(0,3e3)} 11`)}p+=H}if(!p.trim()){t.warning("toast_warning.no_se_pudo_extraer","No se pudo extraer contenido de los dominios."),P(!1);return}t.info("toast_info.maasy_ia_está_generando","Maasy IA está generando perfil enriquecido...");const B=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(!B.ok)throw new Error("Error al generar análisis");const J=(a=B.body)==null?void 0:a.getReader();if(!J)throw new Error("No stream");const ie=new TextDecoder;let L="",q="";for(;;){const{done:g,value:u}=await J.read();if(g)break;L+=ie.decode(u,{stream:!0});const b=L.split(` 12`);L=b.pop()||"";for(const k of b){if(!k.startsWith("data: "))continue;const S=k.slice(6).trim();if(S!=="[DONE]")try{const f=(A=($=(v=JSON.parse(S).choices)==null?void 0:v[0])==null?void 0:$.delta)==null?void 0:A.content;f&&(q+=f,E(q),I.current&&(I.current.scrollTop=I.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{P(!1)}},re=async()=>
12{if(!o||!r)return;const{data:{user:s}}=await c.auth.getUser();if(!s){t.error("toast_error.debes_iniciar_sesión","Debes iniciar sesión");return}const{error:d}=await c.from("tool_generations").insert([{project_id:r,tool_type:"lead-intel",title:`Lead Intelligence â ${T}`,content:o,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"),se(j=>j+1))},ae=async()=>{if(!o||!r)return;const{data:s}=await c.from("project_deliverables").select("id").eq("project_id",r).eq("section_key","lead-intelligence").maybeSingle();if(s){const{error:d}=await c.from("project_deliverables").update({content:W(o)}).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 c.from("project_deliverables").insert([{project_id:r,phase:"phase_1_diagnosis",section_key:"lead-intelligence",title:"Inteligencia de Prospectos / Leads",content:W(o),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")}},oe=async()=>{var w;if(!o)return;const{data:{user:s}}=await c.auth.getUser();if(!s){t.error("toast_error.debes_iniciar_sesión","Debes iniciar sesión");return}const j=_.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 c.functions.invoke("crm-import-from-intelligence",{body:{domain:j,intelligence_output:o,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")}},h=M.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("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",{className:"flex-1 min-w-0",children:[e.jsxs("h1",{className:"text-lg font-bold tracking-tight text-foreground flex items-center gap-2",children:["Lead Intelligence",e.jsx(de,{className:"h-3.5 w-3.5 text-primary/60"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enriquecimiento de prospectos desde su sitio web"})]})]}),e.jsx(ke,{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 flex-wrap gap-2",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(me,{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(Ee,{className:"h-3.5 w-3.5 mr-1.5"})},{key:"outreach",label:"Outreach",icon:e.jsx(pe,{className:"h-3.5 w-3.5 mr-1.5"})}].map(s=>e.jsxs("button",{onClick:()=>O(s.key),className:ue("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))}),o&&!y&&m==="output"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(N,{size:"sm",variant:"outline",onClick:oe,className:"h-7 text-xs gap-1",children:[e.jsx(fe,{className:"h-3 w-3"}
13)," Enviar al CRM"]}),e.jsxs(N,{size:"sm",variant:"outline",onClick:ae,className:"h-7 text-xs gap-1",children:[e.jsx(xe,{className:"h-3 w-3"})," Insertar al Doc"]}),e.jsxs(N,{size:"sm",onClick:re,className:"h-7 text-xs gap-1",children:[e.jsx(he,{className:"h-3 w-3"})," Guardar"]})]})]}),m==="call-prep"&&e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Se,{projectId:r,projectName:T})}),m==="outreach"&&e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Ce,{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(V,{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium",children:"Proyecto"}),e.jsxs(ge,{value:r,onValueChange:Y,children:[e.jsx(je,{children:e.jsx(be,{placeholder:"Selecciona un proyecto"})}),e.jsx(_e,{children:M.map(s=>e.jsx(ye,{value:s.id,children:s.brand_name},s.id))})]})]}),h&&e.jsx(we,{className:"bg-muted/30 border-primary/10",children:e.jsxs(ve,{className:"p-3 space-y-1.5 text-xs",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground",children:h.brand_name}),h.industry&&e.jsxs("p",{className:"text-muted-foreground",children:["Industria: ",e.jsx("span",{className:"text-foreground",children:h.industry})]}),h.tags&&h.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.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(V,{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium",children:"Dominios de Prospectos"}),e.jsx(Ne,{placeholder:`ejemplo.com 14otraempresa.com 15prospecto3.com`,value:_,onChange:s=>D(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(N,{onClick:te,disabled:y||!r,className:"flex-1 shadow-colored active:scale-[0.98]",children:y?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"mr-2 h-4 w-4 animate-spin"})," Investigando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"mr-2 h-4 w-4"})," Investigar Prospectos"]})}),e.jsx(N,{variant:"outline",size:"icon",onClick:()=>{E(""),D("")},title:"Limpiar",children:e.jsx(Pe,{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"&&(o||y?e.jsxs("div",{ref:I,className:"p-6 overflow-y-auto h-full",children:[e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground",children:Ie(o)}),y&&e.jsxs("div",{className:"flex items-center gap-2 mt-4 text-muted-foreground",children:[e.jsx(Z,{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(K,{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(Me,{toolType:"lead-intel",projectId:r},ee)})]})})]})]})}export{ds as default}; 16//# sourceMappingURL=LeadIntelligenceSheet-WfucdfjF.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.