import { useState, useEffect } from "react"; // ─── CONSTANTS ──────────────────────────────────────────────── const NAV = [ { id:"dashboard",icon:"🏠",label:"Dashboard" }, { id:"ads", icon:"📊",label:"FiltriAds" }, { id:"ranking", icon:"🏆",label:"FiltriRanking" }, { id:"page", icon:"🌐",label:"FiltriPage" }, { id:"magic", icon:"✨",label:"FiltriMagic" }, { id:"pixel", icon:"🔲",label:"FiltriPixel" }, { id:"blog", icon:"✍️",label:"FiltriArtigo" }, ]; const RANKING = { saude:[ {name:"Método Emagrecer de Vez",meta:"Kiwify · 60%",score:95}, {name:"Cardápio Low Carb Express",meta:"Kiwify · 50%",score:88}, {name:"Treino em Casa Pro",meta:"Kiwify · 55%",score:82}, {name:"Detox 21 Dias",meta:"Kiwify · 65%",score:76}, ], renda:[ {name:"Afiliado do Zero 3.0",meta:"Kiwify · 50%",score:97}, {name:"Fórmula Negócio Online",meta:"Kiwify · 40%",score:91}, {name:"Academia do Criador",meta:"Kiwify · 40%",score:85}, {name:"Tráfego Pago Master",meta:"Kiwify · 45%",score:79}, ], }; const TEMPLATES=[ {id:"cookies",icon:"🍪",name:"Cookies",desc:"Confirmação de cookies"}, {id:"captcha",icon:"🤖",name:"Captcha",desc:"Verificação anti-robô"}, {id:"idade",icon:"🎂",name:"Idade",desc:"Confirma faixa etária"}, {id:"genero",icon:"👥",name:"Gênero",desc:"Personalização por gênero"}, {id:"paises",icon:"🌍",name:"Países",desc:"Bandeiras dos países"}, {id:"nav",icon:"🧭",name:"Navegação",desc:"Review ou comprar"}, {id:"cupom",icon:"🏷️",name:"Cupom",desc:"Oferta especial"}, {id:"frete",icon:"🚚",name:"Frete",desc:"Frete grátis / expresso"}, {id:"review",icon:"⭐",name:"Review",desc:"Página de review completa"}, ]; // Ad Networks const AD_NETS = [ {key:"meta", flag:"📘",name:"Meta Ads", color:"#1877f2",idLabel:"Pixel ID", ph:"1234567890123456"}, {key:"google", flag:"🟢",name:"Google Ads", color:"#34a853",idLabel:"ID Conversão", ph:"AW-123456789"}, {key:"tiktok", flag:"🎵",name:"TikTok Ads", color:"#010101",idLabel:"Pixel ID", ph:"ABCDE12345"}, {key:"kwai", flag:"📹",name:"Kwai Ads", color:"#ff6600",idLabel:"Pixel ID", ph:"KW-987654321"}, {key:"pinterest",flag:"📌",name:"Pinterest Ads", color:"#e60023",idLabel:"Tag ID", ph:"123456789012345"}, {key:"snapchat", flag:"👻",name:"Snapchat Ads", color:"#ffcc00",idLabel:"Pixel ID", ph:"xxxxxxxx-xxxx-xxxx"}, {key:"twitter", flag:"🐦",name:"X (Twitter) Ads", color:"#000000",idLabel:"Pixel ID", ph:"o3abc"}, {key:"taboola", flag:"📰",name:"Taboola", color:"#5d5d5d",idLabel:"Account ID", ph:"1234567"}, {key:"outbrain", flag:"🔵",name:"Outbrain", color:"#003dcd",idLabel:"Pixel ID", ph:"abc123"}, {key:"mgid", flag:"🟠",name:"MGID", color:"#ff6d00",idLabel:"Client ID", ph:"1234567"}, ]; // Affiliate Platforms const AFF_BR = [ {key:"kiwify", flag:"🟣",name:"Kiwify", color:"#6c63ff",google:true, meta:true, tiktok:true}, {key:"hotmart", flag:"🔴",name:"Hotmart", color:"#f04e23",google:true, meta:true, tiktok:false}, {key:"monetizze", flag:"🔵",name:"Monetizze", color:"#00b4d8",google:true, meta:true, tiktok:false}, {key:"braip", flag:"🟢",name:"Braip", color:"#1db954",google:false,meta:true, tiktok:false}, {key:"perfectpay",flag:"🟡",name:"Perfect Pay", color:"#ff9800",google:true, meta:true, tiktok:false}, {key:"eduzz", flag:"🩷",name:"Eduzz", color:"#ff4081",google:true, meta:true, tiktok:false}, {key:"ticto", flag:"🟤",name:"Ticto", color:"#9c27b0",google:false,meta:true, tiktok:false}, ]; const AFF_INT = [ {key:"clickbank", flag:"🔴",name:"ClickBank", color:"#c0392b",google:false,meta:false,tiktok:false}, {key:"digistore", flag:"🔵",name:"Digistore24", color:"#2980b9",google:false,meta:false,tiktok:false}, {key:"buygoods", flag:"🟢",name:"BuyGoods", color:"#27ae60",google:false,meta:false,tiktok:false}, {key:"maxweb", flag:"🟣",name:"MaxWeb", color:"#8e44ad",google:false,meta:false,tiktok:false}, {key:"adcombo", flag:"🟠",name:"AdCombo", color:"#e67e22",google:false,meta:false,tiktok:false}, {key:"jvzoo", flag:"🟤",name:"JVZoo", color:"#16a085",google:false,meta:false,tiktok:false}, {key:"shareasale",flag:"⚫",name:"ShareASale", color:"#d35400",google:false,meta:true, tiktok:false}, {key:"cj", flag:"🔘",name:"CJ Affiliate", color:"#2c3e50",google:false,meta:true, tiktok:false}, {key:"rakuten", flag:"🔴",name:"Rakuten Ads", color:"#bf0000",google:false,meta:false,tiktok:false}, {key:"amazon", flag:"🟡",name:"Amazon Assoc.",color:"#ff9900",google:false,meta:false,tiktok:false}, ]; const RM_CHECKS=[ {id:"kw_title",group:"SEO Básico",label:"Palavra-chave no Título SEO",pts:8}, {id:"kw_desc",group:"SEO Básico",label:"Palavra-chave na Meta Description",pts:4}, {id:"kw_url",group:"SEO Básico",label:"Palavra-chave na URL (Slug)",pts:5}, {id:"kw_h1",group:"SEO Básico",label:"Palavra-chave no H1",pts:5}, {id:"kw_intro",group:"SEO Básico",label:"Palavra-chave no 1º parágrafo",pts:5}, {id:"kw_density",group:"SEO Básico",label:"Densidade da keyword (1–2%)",pts:5}, {id:"kw_h2h3",group:"SEO Básico",label:"Palavra-chave em H2/H3",pts:3}, {id:"title_len",group:"Título & Meta",label:"Título SEO 50–60 caracteres",pts:5}, {id:"desc_len",group:"Título & Meta",label:"Meta Description 120–160 chars",pts:5}, {id:"title_power",group:"Título & Meta",label:"Palavra de poder no título",pts:3}, {id:"title_number",group:"Título & Meta",label:"Número no título (ex: 5 formas...)",pts:2}, {id:"word_count",group:"Conteúdo",label:"Mínimo 600 palavras",pts:4}, {id:"has_image",group:"Conteúdo",label:"Artigo contém imagem",pts:4}, {id:"img_alt",group:"Conteúdo",label:"Alt text da imagem com keyword",pts:4}, {id:"internal_link",group:"Conteúdo",label:"Link interno presente",pts:4}, {id:"external_link",group:"Conteúdo",label:"Link externo (fonte confiável)",pts:4}, {id:"has_toc",group:"Conteúdo",label:"Índice (Table of Contents)",pts:2}, {id:"heading_struct",group:"Conteúdo",label:"Estrutura H2, H3 presente",pts:3}, {id:"short_parag",group:"Legibilidade",label:"Parágrafos curtos (máx 3 linhas)",pts:3}, {id:"transition",group:"Legibilidade",label:"Palavras de transição",pts:2}, {id:"passive_voice",group:"Legibilidade",label:"Voz passiva < 10% do texto",pts:2}, {id:"schema_faq",group:"Schema",label:"Schema FAQ (perguntas e respostas)",pts:5}, {id:"schema_art",group:"Schema",label:"Schema Article (autor, data)",pts:4}, {id:"schema_review",group:"Schema",label:"Schema Review (nota, estrelas)",pts:4}, {id:"og_title",group:"Social/SERP",label:"OG Title (compartilhamento social)",pts:2}, {id:"og_desc",group:"Social/SERP",label:"OG Description configurada",pts:2}, {id:"canonical",group:"Social/SERP",label:"URL canônica definida",pts:2}, ]; function calcScore(c){ const max=RM_CHECKS.reduce((a,x)=>a+x.pts,0); const got=RM_CHECKS.filter(x=>c[x.id]).reduce((a,x)=>a+x.pts,0); return Math.round((got/max)*100); } const sc=(s)=>s>=80?"#00e676":s>=50?"#ffab40":"#ff2d2d"; // ─── MAIN APP ──────────────────────────────────────────────── export default function App(){ const[page,setPage]=useState("dashboard"); const[adsKw,setAdsKw]=useState(""); const[adsRes,setAdsRes]=useState(null); const[adsLoad,setAdsLoad]=useState(false); const[mgLoad,setMgLoad]=useState(false); const[mgDone,setMgDone]=useState(false); const[selTpl,setSelTpl]=useState(null); // Pixel state const[activePixels,setActivePixels]=useState([]); const[selAdNet,setSelAdNet]=useState("meta"); const[pixelId,setPixelId]=useState(""); const[convLabel,setConvLabel]=useState(""); const[blockBots,setBlockBots]=useState(true); const[blockCompetitors,setBlockCompetitors]=useState(false); const[selAffBR,setSelAffBR]=useState([]); const[selAffInt,setSelAffInt]=useState([]); const[pixelTab,setPixelTab]=useState("redes"); const[copiedCode,setCopiedCode]=useState(false); // Blog state const[blogKw,setBlogKw]=useState(""); const[metaTitle,setMetaTitle]=useState(""); const[metaDesc,setMetaDesc]=useState(""); const[slug,setSlug]=useState(""); const[secKws,setSecKws]=useState(""); const[enableFaq,setEnableFaq]=useState(false); const[enableReview,setEnableReview]=useState(false); const[blogLoad,setBlogLoad]=useState(false); const[blogDone,setBlogDone]=useState(false); const[rmChecks,setRmChecks]=useState({}); const[rmScore,setRmScore]=useState(0); const[rmGroup,setRmGroup]=useState("SEO Básico"); useEffect(()=>{ if(blogKw){ setSlug(blogKw.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")); setMetaTitle(blogKw.charAt(0).toUpperCase()+blogKw.slice(1)+" | Guia Completo 2026"); setMetaDesc("Descubra como "+blogKw+" de forma simples e prática. Guia completo para começar hoje mesmo."); } },[blogKw]); useEffect(()=>{setRmScore(calcScore(rmChecks));},[rmChecks]); const toggleCheck=(id)=>setRmChecks(p=>({...p,[id]:!p[id]})); const addPixel=()=>{ if(!pixelId.trim())return; const net=AD_NETS.find(n=>n.key===selAdNet); const exists=activePixels.find(p=>p.key===selAdNet); if(exists){setActivePixels(activePixels.map(p=>p.key===selAdNet?{...p,id:pixelId,label:convLabel}:p));} else{setActivePixels([...activePixels,{key:selAdNet,id:pixelId,label:convLabel,on:true,blocked:0,conversions:0}]);} setPixelId(""); setConvLabel(""); }; const toggleAffBR=(k)=>setSelAffBR(p=>p.includes(k)?p.filter(x=>x!==k):[...p,k]); const toggleAffInt=(k)=>setSelAffInt(p=>p.includes(k)?p.filter(x=>x!==k):[...p,k]); const genPixelCode=()=>{ if(!activePixels.length)return "// Adicione pelo menos um pixel de rede de anúncios"; let c="\n\n"; if(blockBots) c+=`\n