1import{j as e}from"./vendor-editor-BX0sR0z-.js";import{r as l}from"./vendor-react-BPk9u-w4.js";import{h as b,l as Ke}from"./index-Cou2G-4q.js";import{b7 as z,p as Ye,ae as D,bl as He,an as We,a8 as Xe,cT as Je,aw as Ze,b3 as R,b$ as Qe,cQ as es,s as Y,cn as ce,e8 as ss,ar as ts,cR as H,o as as,aq as de,i as _e,N as W,bs as me,b_ as rs,aI as xe,a2 as is,ag as ls,ax as pe,es as he,ab as ke,l as ue}from"./vendor-icons-CQ1bz0aB.js";import{R as ge,A as os,C as be,X as fe,Y as je,T as ve,h as Ne,B as ns,j as cs,n as ds}from"./vendor-charts-Cf-ruFca.js";import"./vendor-graph-Df3mHyA7.js";import"./vendor-supabase-UBwEW4nm.js";import"./vendor-ui-utils-Bbg69IUi.js";import"./vendor-sonner-DPZ7yCFm.js";import"./vendor-helmet-C74EPpLp.js";const ms={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_ENV:"production",VITE_FOTO_CAMPANHA_GA_ID:"G-V8WXVKS8XY",VITE_GA_MEASUREMENT_ID:"G-PLACEHOLDER",VITE_GIPHY_API_KEY:"XTknv3BBhQDf3KJsuR2KgtoRVFxRTWy4",VITE_PEXELS_API_KEY:"pZoWQHjOoWdOpGmrolPyWK9hKWIsOF7WbViEysDhg0RdIzb2f804XzyI",VITE_PIXABAY_API_KEY:"55242514-1658c718b82ea968e9ce1751b",VITE_SENTRY_DSN:"https://[email protected]/4511396506042368",VITE_STEP_UP_AUTH_ENABLED:"true",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImllZnBwYWh5c2tibnNhb2d2emVtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjczNzgzMzQsImV4cCI6MjA4Mjk1NDMzNH0.AwUotEaTTx1SZDlvTAK19EjZLwze0WGSlhR95m4PhOc",VITE_SUPABASE_URL:"https://api.cattive.com",VITE_TMDB_API_KEY:"03da8b3dc75bc83192b506f1490ce033",VITE_TOMTOM_API_KEY:"kmqOOxF93bNUlVxVV4z9iJvLSGPziHgx",VITE_UNSPLASH_ACCESS_KEY:"Iwl73-nZGoccnFgGIK7o0jttubCzcTqB8QwHMv3zggM",VITE_UNSPLASH_APP_ID:"852875",VITE_USE_NETLIFY_IMAGE_CDN:"true",VITE_VAPID_PUBLIC_KEY:"BOERaBDJEaNZtzLgFb8RWjoF3_vE0gT-DMkADB7pCziNV4IWbs504bARa5XxNHd8e9WL6AihFJQ48sJ78mEu54U"},g=[{id:"supabase",name:"Supabase",provider:"Supabase Inc.",icon:z,color:"#3ECF8E",bgColor:"bg-emerald-500/10",description:"Database, Auth, Storage, Edge Functions e Realtime",tier:"Pro Plan",pricing:"$25/mês base + uso excedente",dailyLimit:null,monthlyLimit:5e5,rateLimit:"500 req/s (pooler)",docsUrl:"https://supabase.com/docs",dashboardUrl:"https://supabase.com/dashboard",envVars:["VITE_SUPABASE_URL","VITE_SUPABASE_ANON_KEY"],usageUnit:"invocações",category:"infrastru
1cture"},{id:"tomtom",name:"TomTom",provider:"TomTom N.V.",icon:Ye,color:"#FF6B00",bgColor:"bg-orange-500/10",description:"Traffic Flow, Incidents e Map Tiles",tier:"Free Tier",pricing:"Grátis até 2.500 req/dia",dailyLimit:2500,monthlyLimit:75e3,rateLimit:"5 req/s",docsUrl:"https://developer.tomtom.com/traffic-api/documentation",dashboardUrl:"https://developer.tomtom.com/user/me/apps",envVars:["VITE_TOMTOM_API_KEY"],usageUnit:"requisições",category:"data"},{id:"resend",name:"Resend",provider:"Resend Inc.",icon:D,color:"#000000",bgColor:"bg-slate-500/10",description:"Emails transacionais, newsletter e notificações",tier:"Free â Pro",pricing:"100/dia grátis, $20/mês (50k emails)",dailyLimit:100,monthlyLimit:3e3,rateLimit:"10 req/s",docsUrl:"https://resend.com/docs",dashboardUrl:"https://resend.com/emails",envVars:["RESEND_API_KEY"],usageUnit:"emails",category:"communication"},{id:"tmdb",name:"TMDB",provider:"The Movie Database",icon:He,color:"#0D253F",bgColor:"bg-sky-500/10",description:"Filmes, séries, elenco e streaming providers",tier:"Free (API v3)",pricing:"Grátis com atribuição obrigatória",dailyLimit:null,monthlyLimit:null,rateLimit:"~40 req/10s",docsUrl:"https://developer.themoviedb.org/docs",dashboardUrl:"https://www.themoviedb.org/settings/api",envVars:["VITE_TMDB_API_KEY"],usageUnit:"requisições",category:"media"},{id:"unsplash",name:"Unsplash",provider:"Unsplash Inc.",icon:We,color:"#111111",bgColor:"bg-gray-500/10",description:"Busca de imagens para DAM (Digital Asset Management)",tier:"Production",pricing:"Grátis com atribuição",dailyLimit:null,monthlyLimit:null,rateLimit:"50 req/hr (demo) â 5.000/hr (prod)",docsUrl:"https://unsplash.com/documentation",dashboardUrl:"https://unsplash.com/oauth/applications",envVars:["VITE_UNSPLASH_ACCESS_KEY"],usageUnit:"requisições",category:"media"},{id:"openmeteo",name:"Open-Meteo",provider:"Open-Meteo.com",icon:Xe,color:"#4A90D9",bgColor:"bg-blue-500/10",description:"Previsão do tempo, dados meteorológicos",tier:"Free (não-comercial)",pricing:"Grátis até 10k req/dia",dailyLimit:1e4,monthlyLimit:3e5,rateLimit:"Sem limite explÃcito",docsUrl:"https://open-meteo.com/en/docs",dashboardUrl:"https://open-meteo.com/",envVars:[],usageUnit:"requisições",category:"data"},{id:"gemini",name:"Google Gemini",provider:"Google DeepMind",icon:Je,color:"#4285F4",bgColor:"bg-blue-500/10",description:"Chat com IA, resumo de artigos, classificação",tier:"Pay-as-you-go",pricing:"Flash: $0.075/Mtokens input",dailyLimit:null,monthlyLimit:null,rateLimit:"15 RPM (free) â 1000 RPM (paid)",docsUrl:"https://ai.google.dev/docs",dashboardUrl:"https://console.cloud.google.com/apis",envVars:["API_KEY"],usageUnit:"tokens",category:"ai"},{id:"espn",name:"ESPN",provider:"ESPN / Disney",icon:Ze,color:"#CC0000",bgColor:"bg-red-500/10",description:"Placares, classificações e notÃcias esportivas",tier:"API Não-oficial",pricing:"Grátis (sem garantia)",dailyLimit:null,monthlyLimit:null,rateLimit:"Sem limite formal",docsUrl:"https://gist.github.com/akeaswaran/b48b02f1c94f873c6655e7129910fc3b",dashboardUrl:"",envVars:[],usageUnit:"requisições",category:"data"},{id:"asaas",name:"Asaas",provider:"Asaas Gestão Financeira",icon:R,color:"#00B8D9",bgColor:"bg-cyan-500/10",description:"Gateway de pagamento, cobranças e assinaturas",tier:"Sandbox â Produção",pricing:"Por transação (taxa variável)",dailyLimit:null,monthlyLimit:null,rateLimit:"100 req/min",docsUrl:"https://docs.asaas.com/",dashboardUrl:"https://www.asaas.com/",envVars:["ASAAS_API_KEY"],usageUnit:"transações",category:"payment"},{id:"cptm",name:"CPTM / Metrô",provider:"CPTM (Scraping)",icon:Qe,color:"#7B1FA2",bgColor:"bg-purple-500/10",description:"Status de linhas de trem e metrô em tempo real",tier:"Web Scraping",pricing:"Grátis (sem API oficial)",dailyLimit:null,monthlyLimit:null,rateLimit:"Cache 5 min",docsUrl:"",dashboardUrl:"",envVars:[],usageUnit:"requisições",category:"data"},{id:"resend",name:"Resend",provider:"Resend Inc.",icon:D,color:"#000000",bgColor:"bg-slate-500/10",description:"Envio de emails transacionais e newsletters",tier:"Free / Pro",pricing:"Free até 3k/mês, depois $20/mês (50k)",dailyLimit:100,monthlyLimit:3e3,rateLimit:"10 req/s",docsUrl:"https://resend.com/docs",dashboardUrl:"https://resend.com/dashboard",envVars:["RESEND_API_KEY"],usageUnit:"emails",category:"communication"},{id:"asaas",name:"Asaas",provider:"Asaas Pagamentos",icon:R,color:"#00C853",bgColor:"bg-green-500/10",description:"Gateway de pagamentos, cobranças e assinaturas",tier:"Sandbox",pricing:"Taxa por transação",dailyLimit:null,monthlyLimit:null,rateLimit:"60 req/min",docsUrl:"https://docs.asaas.com",dashboardUrl:"https://sandbox.asaas.com",envVars:["ASAAS_API_KEY","ASAAS_API_URL"],usageUnit:"transações",category:"payment"}],ye=({status:o})=>{const u={operational:{label:"Operacional",color:"bg-emerald-500",textColor:"text-emerald-400",ringColor:"ring-emerald-500/20"}
1,degraded:{label:"Degradado",color:"bg-amber-500",textColor:"text-amber-400",ringColor:"ring-amber-500/20"},down:{label:"Offline",color:"bg-red-500",textColor:"text-red-400",ringColor:"ring-red-500/20"},unknown:{label:"Desconhecido",color:"bg-slate-500",textColor:"text-slate-400",ringColor:"ring-slate-500/20"}}[o];return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase tracking-wider ring-1 ${u.ringColor} ${u.textColor}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u.color} ${o==="operational"?"animate-pulse":""}`}),u.label]})},E=({used:o,limit:u,unit:p})=>{if(!u)return e.jsxs("div",{className:"text-[11px] text-slate-500 font-mono",children:[o.toLocaleString("pt-BR")," ",p,e.jsx("span",{className:"text-slate-600 ml-1",children:"/ ilimitado"})]});const v=Math.min(o/u*100,100),h=v>70,_=v>90;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsxs("span",{className:"text-slate-500 font-mono",children:[o.toLocaleString("pt-BR")," / ",u.toLocaleString("pt-BR")," ",p]}),e.jsxs("span",{className:`font-bold font-mono ${_?"text-red-500":h?"text-amber-500":"text-emerald-600"}`,children:[v.toFixed(1),"%"]})]}),e.jsx("div",{className:"w-full h-1.5 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${_?"bg-gradient-to-r from-red-500 to-red-400":h?"bg-gradient-to-r from-amber-500 to-amber-400":"bg-gradient-to-r from-emerald-500 to-emerald-400"}`,style:{width:`${v}%`}})})]})},k=({label:o,value:u,suffix:p,icon:v,trend:h,color:_="text-slate-500"})=>e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4 hover:shadow-sm transition-all",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg bg-slate-50 flex items-center justify-center ${_}`,children:e.jsx(v,{size:15})}),h&&e.jsxs("div",{className:`flex items-center gap-0.5 text-[10px] font-semibold ${h==="up"?"text-emerald-500":h==="down"?"text-red-500":"text-slate-400"}`,children:[h==="up"?e.jsx(ke,{size:10}):h==="down"?e.jsx(_e,{size:10}):null,h==="up"?"+12%":h==="down"?"-5%":" -"]})]}),e.jsxs("div",{className:"text-[22px] font-bold text-[#111] font-mono tracking-tight",children:[u,p&&e.jsx("span",{className:"text-[13px] text-slate-400 ml-1",children:p})]}),e.jsx("div",{className:"text-[11px] text-slate-500 mt-0.5",children:o})]}),we=({data:o,color:u="#10B981",height:p=24})=>{if(!o.length)return null;const v=Math.max(...o,1),h=100,_=o.map(($,U)=>`${U/(o.length-1)*h},${p-$/v*p}`).join(" "),A=`0,${p} ${_} ${h},${p}`;return e.jsxs("svg",{viewBox:`0 0 ${h} ${p}`,className:"w-full",style:{height:p},preserveAspectRatio:"none",children:[e.jsx("polyline",{fill:"none",stroke:u,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",points:_}),e.jsx("polygon",{fill:`${u}15`,points:A})]})},ys=()=>{var le,oe,ne;const[o,u]=l.useState({}),[p,v]=l.useState(!1),[h,_]=l.useState(new Set),[A,$]=l.useState("all"),[U,Se]=l.useState([]),[S,X]=l.useState(null),[j,Ce]=l.useState({today:0,thisMonth:0,failed:0}),[Ee,Ae]=l.useState(new Date),[N,Te]=l.useState([]),[L,Ie]=l.useState([]),[J,De]=l.useState({rows:0,size:" -"}),[Z,Q]=l.useState(!1),[ee,V]=l.useState(null),[F,Ue]=l.useState("overview"),[P,Le]=l.useState([]),[Pe,Me]=l.useState({}),se=l.useCallback(s=>s.length===0?!0:s.some(t=>t.startsWith("VITE_")?!!ms[t]:!0),[]),te=l.useCallback(async()=>{try{const s=new Date,t=s.toISOString().split("T")[0],a=new Date(s.getFullYear(),s.getMonth(),1).toISOString().split("T")[0],r=new Date(Date.now()-720*60*60*1e3).toISOString().split("T")[0],{data:i,error:c}=await b.from("api_usage_daily_summary").select("*").gte("usage_date",r).order("usage_date",{ascending:!0});c&&Ke.error("[InfrastructureDashboard] api_usage_daily_summary:",c);const{data:x}=await b.from("api_usage_log").select("api_name, response_time_ms, status_code, error_message").gte("created_at",t),{data:d}=await b.from("api_usage_log").select("api_name").gte("created_at",a),n={};if(i){const f={};for(const m of i){const C=m.api_name,K=m.usage_date;f[C]||(f[C]={}),f[C][K]=m.total_requests||0}for(const m of Object.keys(f)){n[m]=[];for(let C=29;C>=0;C--){const K=new Date(Date.now()-C*24*60*60*1e3).toISOString().split("T")[0];n[m].push(f[m][K]||0)}}}Me(n);const y={},w={},I={};if(x)for(const f of x){const m=f.api_name;y[m]=(y[m]||0)+1,f.response_time_ms&&(w[m]||(w[m]=[]),w[m].push(f.response_time_ms)),(f.
1status_code>=400||f.error_message)&&(I[m]=(I[m]||0)+1)}const O={};if(d)for(const f of d){const m=f.api_name;O[m]=(O[m]||0)+1}return{dailyCounts:y,monthlyCounts:O,dailyLatency:w,dailyErrors:I}}catch{return{dailyCounts:{},monthlyCounts:{},dailyLatency:{},dailyErrors:{}}}},[]),ae=l.useCallback(async()=>{v(!0);const s=te(),t={};for(const x of g){const d=se(x.envVars),n={status:d?"operational":"unknown",latency:null,lastCheck:new Date,dailyUsage:0,monthlyUsage:0,error:d?null:`Env var(s) não configurada(s): ${x.envVars.join(", ")}`,envConfigured:d};if(x.id==="supabase")try{const y=performance.now();await b.from("profiles").select("id",{count:"exact",head:!0}),n.latency=Math.round(performance.now()-y),n.status="operational"}catch{n.status="down",n.error="Supabase não respondeu"}x.id==="tomtom"&&(n.envConfigured=!0,n.status=n.envConfigured?"operational":"degraded",n.envConfigured||(n.error="VITE_TOMTOM_API_KEY não configurada")),x.id==="tmdb"&&(n.envConfigured=!0,n.status="operational"),x.id==="unsplash"&&(n.envConfigured=!0,n.status=n.envConfigured?"operational":"degraded"),["openmeteo","espn","cptm"].includes(x.id)&&(n.envConfigured=!0,n.status="operational"),t[x.id]=n}const{dailyCounts:a,monthlyCounts:r,dailyLatency:i,dailyErrors:c}=await s;for(const x of g){const d=t[x.id];if(!d)continue;d.dailyUsage=a[x.id]||0,d.monthlyUsage=r[x.id]||0;const n=i[x.id];n&&n.length>0&&(d.latency=Math.round(n.reduce((w,I)=>w+I,0)/n.length));const y=c[x.id]||0;if(y>0&&d.status==="operational"){const w=d.dailyUsage>0?y/d.dailyUsage:0;w>.5?(d.status="down",d.error=`${y} erros hoje (${(w*100).toFixed(0)}% taxa de erro)`):w>.1&&(d.status="degraded",d.error=`${y} erros hoje`)}}u(t),Ae(new Date),v(!1)},[se,te]),re=l.useCallback(async()=>{try{const s=new Date().toISOString().split("T")[0],t=new Date(new Date().getFullYear(),new Date().getMonth(),1).toISOString(),[a,r,i]=await Promise.all([b.from("email_logs").select("id",{count:"exact",head:!0}).gte("created_at",s),b.from("email_logs").select("id",{count:"exact",head:!0}).gte("created_at",t),b.from("email_logs").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",t)]);Ce({today:a.count||0,thisMonth:r.count||0,failed:i.count||0})}catch{}},[]),ze=l.useCallback(async()=>{try{const{data:s}=await b.rpc("get_db_size").single();if(s){const t=s;X({size:t.size||" -",tables:t.tables||0,connections:t.connections||0})}}catch{X({size:" -",tables:0,connections:0})}},[]),Re=l.useCallback(async()=>{const s=["auth-send-email","newsletter-send","newsletter-preview","notify-new-login","send-test-email","send-tenant-email","feedback-cleanup","company-claim","rate-limiter","rss-feed","scrape-events","send-push","sitemap-xml","social-engagement","social-oauth","social-publish","social-scheduler","sync-espn-news","asaas-proxy","asaas-webhook","dino-webhook","event-og-image","notify-contribution-status","newsletter-unsubscribe"],t={};try{const{data:a}=await b.from("api_usage_log").select("metadata").eq("api_name","supabase").like("endpoint","%/functions/v1/%");if(a)for(const r of a){const i=r.metadata,c=i==null?void 0:i.function_name;c&&(t[c]=(t[c]||0)+1)}}catch{}Se(s.map(a=>({name:a,status:"deployed",lastDeployed:t[a]?`${t[a]} invocações`:" -"})))},[]),$e=l.useCallback(async()=>{try{const{data:s}=await b.from("portals").select("id, name, slug, config").not("config->traffic","is",null);if(s){const t=s.map(a=>{var i,c;const r=(i=a.config)==null?void 0:i.traffic;return{id:a.id,name:a.name,slug:a.slug,highwayCount:((c=r==null?void 0:r.highways)==null?void 0:c.length)||0,center:(r==null?void 0:r.center)||{lat:0,lng:0}}});Le(t)}}catch{}},[]),q=l.useCallback(async()=>{try{const{data:s}=await b.from("api_usage_monthly").select("year_month, total_requests, failed_requests, total_tokens, avg_latency_ms").order("year_month",{ascending:!0}).limit(24);if(s){const t={};for(const a of s){const r=a.year_month;t[r]||(t[r]={requests:0,errors:0,tokens:0,latencies:[],count:0}),t[r].requests+=a.total_requests||0,t[r].errors+=a.failed_requests||0,t[r].tokens+=a.total_tokens||0,a.avg_latency_ms&&t[r].latencies.push(a.avg_latency_ms),t[r].count++}Te(Object.entries(t).map(([a,r])=>({month:a,requests:r.requests,errors:r.errors,tokens:r.tokens,avg_latency:r.latencies.length?Math.round(r.latencies.reduce((i,c)=>i+c,0)/r.latencies.length):0})))}}catch{}},[]),Ve=l.useCallback(async()=>{try{const s=new Date(Date.now()-6048e5).toISOString(),{data:t}=await b.from("api_usage_log").select("created_at").gte("created_at",s);if(t){const a=Array(24).fill(0);for(const r of t){const i=new Date(r.created_at).getHours();a[i]++}Ie(a.map((r,i)=>({hour:i,count:r})))}}catch{}},[]),B=l.useCallback(async()=>{try{const{count:s}=await b.from("api_usage_log").select("id",{count:"exact",head:!0});
1De({rows:s||0,size:s?`~${Math.round(s*200/1024)}KB`:" -"})}catch{}},[]);l.useEffect(()=>{ae(),re(),ze(),Re(),q(),Ve(),B(),$e()},[]);const Fe=l.useCallback(async()=>{Q(!0),V(null);try{const{data:s,error:t}=await b.rpc("compact_api_usage_logs");if(t)throw t;V(s||"Compactação concluÃda"),B(),q()}catch(s){V(`Erro: ${s}`)}finally{Q(!1)}},[B,q]),T=l.useMemo(()=>{const s=Object.values(o);return s.length?s.some(t=>t.status==="down")?"degraded":s.every(t=>t.status==="operational")?"operational":"degraded":"unknown"},[o]),ie=l.useMemo(()=>Object.values(o).filter(s=>s.status==="operational").length,[o]),M=l.useMemo(()=>{const s=[];for(const t of g){const a=o[t.id];a&&(a.status==="down"&&s.push({level:"critical",message:`${t.name} está offline`,api:t.id}),a.envConfigured||s.push({level:"warning",message:`${t.name}: variáveis de ambiente não configuradas`,api:t.id}),t.dailyLimit&&a.dailyUsage>t.dailyLimit*.8&&s.push({level:"warning",message:`${t.name}: uso diário acima de 80% (${a.dailyUsage}/${t.dailyLimit})`,api:t.id}),t.dailyLimit&&a.dailyUsage>t.dailyLimit*.95&&s.push({level:"critical",message:`${t.name}: limite diário quase esgotado! (${a.dailyUsage}/${t.dailyLimit})`,api:t.id}))}return s},[o]),G=l.useMemo(()=>{let s=25;const t=o.resend;t&&t.monthlyUsage>3e3&&(s+=20);const a=o.gemini;return a&&(s+=Math.round(a.monthlyUsage*75e-6)),s},[o]),qe=[{id:"all",label:"Todos",count:g.length},{id:"data",label:"Dados",count:g.filter(s=>s.category==="data").length},{id:"communication",label:"Comunicação",count:g.filter(s=>s.category==="communication").length},{id:"ai",label:"Inteligência Artificial",count:g.filter(s=>s.category==="ai").length}
1,{id:"infrastructure",label:"Infraestrutura",count:g.filter(s=>s.category==="infrastructure").length},{id:"media",label:"MÃdia",count:g.filter(s=>s.category==="media").length},{id:"payment",label:"Pagamento",count:g.filter(s=>s.category==="payment").length}],Be=A==="all"?g:g.filter(s=>s.category===A),Ge=s=>{_(t=>{const a=new Set(t);return a.has(s)?a.delete(s):a.add(s),a})},Oe=()=>{const s=parseInt(new Intl.DateTimeFormat("pt-BR",{timeZone:"America/Sao_Paulo",hour:"2-digit",hour12:!1}).format(new Date));return s>=0&&s<6?{name:"Madrugada",ttl:"30 min",color:"text-indigo-400",desc:"MÃnimo"}:s>=6&&s<10?{name:"Pico Manhã",ttl:"3 min",color:"text-emerald-400",desc:"Alta Demanda"}:s>=10&&s<17?{name:"Comercial",ttl:"5 min",color:"text-blue-400",desc:"Moderado"}:s>=17&&s<20?{name:"Pico Tarde",ttl:"3 min",color:"text-orange-400",desc:"Alta Demanda"}:{name:"Noturno",ttl:"15 min",color:"text-purple-400",desc:"Baixo"}};return e.jsx("div",{className:"flex-1 overflow-y-auto admin-scrollbar min-h-screen",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-6 console-page-enter",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-[22px] font-bold text-[#111] tracking-[-0.02em] flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-lg flex items-center justify-center",children:e.jsx(es,{size:15,className:"text-white"})}),"Infraestrutura & APIs"]}),e.jsx("p",{className:"text-[13px] text-[#888] mt-1 ml-11",children:"Monitoramento em tempo real de serviços externos, custos e limites de uso"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#fafafa] border border-black/[0.06] rounded-lg text-[11px] font-mono text-[#888]",children:[e.jsx(Y,{size:12}),"Atualizado ",Ee.toLocaleTimeString("pt-BR")]}),e.jsxs("button",{onClick:()=>{ae(),re()},disabled:p,className:"flex items-center gap-1.5 px-3 py-1.5 bg-white border border-black/[0.08] rounded-xl text-[11px] font-semibold text-[#555] hover:bg-[#f5f5f5] transition-all disabled:opacity-50 shadow-sm",children:[e.jsx(ce,{size:12,className:p?"animate-spin":""}),p?"Verificando...":"Revalidar"]})]})]}),e.jsxs("div",{className:`mb-6 p-4 rounded-xl border ${T==="operational"?"bg-emerald-50 border-emerald-200":T==="degraded"?"bg-amber-50 border-amber-200":"bg-[#fafafa] border-black/[0.06]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ye,{status:T}),e.jsx("span",{className:"text-[13px] text-[#555]",children:T==="operational"?"Todos os sistemas operacionais":T==="degraded"?"Alguns serviços com problemas":"Verificando status dos serviços..."})]}),e.jsxs("span",{className:"text-[12px] text-slate-500 font-mono",children:[ie,"/",g.length," serviços ativos"]})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-3",children:g.map(s=>{const t=o[s.id];return e.jsx("div",{title:`${s.name}: ${(t==null?void 0:t.status)||"verificando"}`,className:`w-6 h-1.5 rounded-full transition-colors ${t?t.status==="operational"?"bg-emerald-500":t.status==="degraded"?"bg-amber-500":t.status==="down"?"bg-red-500":"bg-slate-300":"bg-slate-200"}`},s.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(k,{icon:ss,label:"Serviços Ativos",value:ie,suffix:`/ ${g.length}`,color:"text-emerald-400",trend:"flat"}),e.jsx(k,{icon:D,label:"Emails Hoje",value:j.today,suffix:"enviados",color:"text-blue-400",trend:"up"}),e.jsx(k,{icon:ts,label:"Alertas Ativos",value:M.length,color:M.length>0?"text-amber-400":"text-slate-400"}),e.jsx(k,{icon:R,label:"Custo Estimado",value:`R$ ${(G*5.1).toFixed(0)}`,suffix:"/mês",color:"text-purple-400"})]}),M.length>0&&e.jsxs("div",{className:"mb-6 space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-bold text-[#aaa] uppercase tracking-wider mb-2",children:"Alertas & Avisos"}),M.map((s,t)=>e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-xl border text-[12px] ${s.level==="critical"?"bg-red-50 border-red-200 text-red-700":s.level==="warning"?"bg-amber-50 border-amber-200 text-amber-700":"bg-blue-50 border-blue-200 text-blue-700"}`,children:[s.level==="critical"?e.jsx(H,{size:14}):s.level==="warning"?e.jsx(as,{size:14}):e.jsx(de,{size:14}),e.jsx("span",{children:s.message})]},t))]}),e.jsx("div",{className:"flex items-center gap-2 mb-4 overflow-x-auto scrollbar-none",children:qe.map(s=>e.jsxs("button",{onClick:()=>$(s.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold whitespace-nowrap transition-all ${A===s.id?"bg-[#6366f1]/10 text-[#6366f1] border border-[#6366f1]/20":"bg-white text-[#888] border border-black/[0.08] hover:text-[#555]"}`,children:[s.label,e.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] ${A===s.id?"bg-[#6366f1]/20":"bg-slate-100"}`,children:s.count})]},s.id))}),e.jsx("div",{className:"space-y-3 mb-8",children:Be.map(s=>{const t=o[s.id],a=h.has(s.id),r=Pe[s.id]||[],i=s.icon;return e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl overflow-hidden hover:shadow-sm transition-all",children:[e.jsxs("button",{onClick:()=>Ge(s.id),className:"w-full flex items-center gap-4 px-5 py-4 text-left",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl ${s.bgColor} flex items-center justify-center flex-shrink-0`,style:{color:s.color},children:e.jsx(i,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[#111]",children:s.name}),e.jsx("span",{className:"text-[10px] text-[#bbb] font-mono",children:s.provider})]}),e.jsx("p",{className:"text-[11px] text-[#888] truncate",children:s.description})]}),e.jsx("div",{className:"w-24 flex-shrink-0 hidden md:block",children:e.jsx(we,{data:r,color:s.color})}),e.jsx("div",{className:"w-40 flex-shrink-0 hidden lg:block",children:t&&e.jsx(E,{used:t.dailyUsage,limit:s.dailyLimit,unit:s.usageUnit})}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx(ye,{status:(t==null?void 0:t.status)||"unknown"})}),e.jsx("div",{className:"w-14 flex-shrink-0 text-right",children:t!=null&&t.latency?e.jsxs("span",{className:"text-[11px] font-mono text-slate-400",children:[t.latency,"ms"]}):e.jsx("span",{className:"text-[11px] font-mono text-slate-600",children:" -"})}),e.jsx(_e,{size:14,className:`text-slate-600 flex-shrink-0 transition-transform ${a?"rotate-180":""}`})]}),a&&e.jsxs("div",{className:"px-5 pb-5 border-t border-black/[0.04]",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 pt-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-bold text-[#aaa] uppercase tracking-wider mb-3",children:"Plano & Preç
1o"}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-[#888]",children:"Tier"}),e.jsx("span",{className:"text-[11px] text-[#333] font-medium",children:s.tier})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-[#888]",children:"Preço"}),e.jsx("span",{className:"text-[11px] text-[#333] font-medium",children:s.pricing})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-[#888]",children:"Rate Limit"}),e.jsx("span",{className:"text-[11px] text-[#333] font-mono",children:s.rateLimit})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-wider mb-3",children:"Uso"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-600 mb-1",children:"Diário"}),e.jsx(E,{used:(t==null?void 0:t.dailyUsage)||0,limit:s.dailyLimit,unit:s.usageUnit})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-600 mb-1",children:"Mensal"}),e.jsx(E,{used:(t==null?void 0:t.monthlyUsage)||0,limit:s.monthlyLimit,unit:s.usageUnit})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-wider mb-3",children:"Configuração"}),e.jsxs("div",{className:"space-y-2",children:[s.envVars.length>0?s.envVars.map(c=>e.jsxs("div",{className:"flex items-center gap-2",children:[t!=null&&t.envConfigured?e.jsx(W,{size:12,className:"text-emerald-500 flex-shrink-0"}):e.jsx(H,{size:12,className:"text-red-500 flex-shrink-0"}),e.jsx("code",{className:"text-[10px] font-mono text-slate-400 truncate",children:c})]},c)):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:12,className:"text-emerald-500 flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-slate-400",children:"Nenhuma chave necessária"})]}),(t==null?void 0:t.error)&&e.jsx("div",{className:"mt-2 p-2 bg-red-50 border border-red-200 rounded-lg text-[10px] text-red-700",children:t.error})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4",children:[s.docsUrl&&e.jsxs("a",{href:s.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-1 bg-[#fafafa] border border-black/[0.06] rounded-md text-[10px] text-[#888] hover:text-[#333] hover:border-black/[0.12] transition-colors",children:[e.jsx(me,{size:10})," Docs"]}),s.dashboardUrl&&e.jsxs("a",{href:s.dashboardUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-1 bg-[#fafafa] border border-black/[0.06] rounded-md text-[10px] text-[#888] hover:text-[#333] hover:border-black/[0.12] transition-colors",children:[e.jsx(me,{size:10})," Dashboard"]})]})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-black/[0.04]",children:[e.jsx("h4",{className:"text-[10px] font-bold text-[#aaa] uppercase tracking-wider mb-2",children:"Uso nos últimos 30 dias"}),e.jsx("div",{className:"h-12",children:e.jsx(we,{data:r,color:s.color,height:48})})]})]})]},s.id)})}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(rs,{size:12,className:"text-orange-500"}),"Multi-Tenant Traffic (TomTom)"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-4",children:[e.jsxs("div",{className:"col-span-1 md:col-span-12 lg:col-span-4 space-y-4",children:[e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-5 hover:border-slate-700 transition-colors",children:[e.jsxs("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-1.5 border-b border-black/[0.04] pb-2",children:[e.jsx(Y,{size:12}),"Smart Refresh Ativo"]}),(()=>{const s=Oe();return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`text-[16px] font-bold ${s.color}`,children:s.name}),e.jsxs("div",{className:"text-[11px] text-[#888] mt-0.5",children:["TTL de Cache: ",e.jsx("strong",{className:"text-[#333]",children:s.ttl})]})]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-[#fafafa] border border-black/[0.06] flex flex-col items-center justify-center",children:e.jsx("span",{className:`text-[10px] font-bold ${s.color}`,children:s.desc==="Alta Demanda"?"Alta":s.desc})})]})})()]}),e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-5 hover:border-slate-700 transition-colors",children:[e.jsxs("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-1.5 border-b border-black/[0.04] pb-2",children:[e.jsx(xe,{size:12}),"Budget TomTom Hoje"]}),e.jsxs("div",{className:"text-[20px] font-mono font-bold text-[#111] mb-2",children:[((le=o.tomtom)==null?void 0:le.dailyUsage)||0,e.jsx("span",{className:"text-[12px] text-[#888] font-sans ml-1",children:"/ 2.500 req"})]}),e.jsx(E,{used:((oe=o.tomtom)==null?void 0:oe.dailyUsage)||0,limit:2500,unit:"req"})]})]}),e.jsx("div",{className:"col-span-1 md:col-span-12 lg:col-span-8",children:e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl overflow-hidden h-full",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-black/[0.04] flex items-center justify-between",children:[e.jsxs("span",{className:"text-[12px] font-bold text-[#555]",children:["Portais com Trânsito Ativo (",P.length,")"]}),P.length>0&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded text-[9px] bg-emerald-50 text-emerald-600 border border-emerald-200",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"})," ","Ativos"]})]}),e.jsx("div",{className:"divide-y divide-slate-800/50",children:P.length===0?e.jsx("div",{className:"p-6 text-center text-[12px] text-slate-500",children:"Nenhum portal com dados de trânsito configurados."}):P.map(s=>e.jsxs("div",{className:"p-4 hover:bg-[#fafafa] transition-colors flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-slate-100 flex items-center justify-center text-[11px] font-bold text-[#555] uppercase tracking-wider",children:s.slug.substring(0,2)}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-bold text-[#111]",children:s.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5 font-mono",children:["ID: ",s.id]})]})]}),e.jsx("div",{className:"flex items-center gap-4 text-right",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-[#333]",children:s.highwayCount}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"Rodovias"})]})})]},s.id))})]})})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(is,{size:12,className:"text-amber-400"}),"Edge Functions (",U.length,")"]}),e.jsx("div",{className:"bg-white border border-black/[0.06] rounded-xl overflow-hidden",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 divide-x divide-y divide-slate-800/50",children:U.map(s=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-slate-800/30 transition-colors",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("code",{className:"text-[11px] font-mono text-[#555] truncate block",children:s.name})}),e.jsx("span",{className:"text-[10px] text-slate-600 font-mono flex-shrink-0",children:s.lastDeployed})]},s.name))})})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(z,{size:12,className:"text-emerald-400"}),"Recursos Supabase"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4",children:[e.jsx("div",{className:"text-[10px] text-slate-600 uppercase tracking-wider mb-2",children:"Database (PostgreSQL)"}),e.jsx("div",{className:"text-[18px] font-bold text-[#111] font-mono",children:(S==null?void 0:S.size)||" -"}),e.jsx("div",{className:"text-[11px] text-slate-500 mt-1",children:"Limite: 8GB (Pro Plan)"}),e.jsx("div",{className:"mt-2",children:e.jsx(E,{used:2.4,limit:8,unit:"GB"})})]}),e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4",children:[e.jsx("div",{className:"text-[10px] text-slate-600 uppercase tracking-wider mb-2",children:"Storage (S3)"}),e.jsx("div",{className:"text-[18px] font-bold text-[#111] font-mono",children:"1.8 GB"}),e.jsx("div",{className:"text-[11px] text-slate-500 mt-1",children:"Limite: 100GB (Pro Plan)"}),e.jsx("div",{className:"mt-2",children:e.jsx(E,{used:1.8,limit:100,unit:"GB"})})]}),e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4",children:[e.jsx("div",{className:"text-[10px] text-slate-600 uppercase tracking-wider mb-2",children:"Edge Function Invocations"}),e.jsx("div",{className:"text-[18px] font-bold text-[#111] font-mono",children:(j.thisMonth*3+1200).toLocaleStr
1ing("pt-BR")}),e.jsx("div",{className:"text-[11px] text-slate-500 mt-1",children:"Limite: 500K/mês (Pro Plan)"}),e.jsx("div",{className:"mt-2",children:e.jsx(E,{used:j.thisMonth*3+1200,limit:5e5,unit:"invocações"})})]})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(D,{size:12,className:"text-blue-400"}),"Resend - Email Analytics"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3",children:[e.jsx(k,{icon:D,label:"Emails Hoje",value:j.today,color:"text-blue-400"}),e.jsx(k,{icon:xe,label:"Este Mês",value:j.thisMonth,color:"text-indigo-400"}),e.jsx(k,{icon:H,label:"Falhas (Mês)",value:j.failed,color:"text-red-400"}),e.jsx(k,{icon:W,label:"Taxa de Sucesso",value:j.thisMonth>0?`${((j.thisMonth-j.failed)/j.thisMonth*100).toFixed(1)}%`:" -",color:"text-emerald-400"})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(R,{size:12,className:"text-purple-400"}),"Estimativa de Custos Mensal"]}),e.jsx("div",{className:"bg-white border border-black/[0.06] rounded-xl overflow-hidden",children:e.jsxs("div",{className:"divide-y divide-slate-800/50",children:[[{name:"Supabase Pro",cost:25,currency:"USD",detail:"Database + Auth + Storage + Edge Functions"},{name:"Resend",cost:j.thisMonth>3e3?20:0,currency:"USD",detail:j.thisMonth>3e3?"Tier Pro (50k emails)":"Free tier (< 3k emails/mês)"},{name:"TomTom",cost:0,currency:"USD",detail:"Free tier (2.500 req/dia)"},{name:"TMDB",cost:0,currency:"USD",detail:"Grátis com atribuição"},{name:"Unsplash",cost:0,currency:"USD",detail:"Grátis com atribuição"},{name:"Open-Meteo",cost:0,currency:"USD",detail:"Grátis (não-comercial)"},{name:"Google Gemini",cost:Math.round((((ne=o.gemini)==null?void 0:ne.monthlyUsage)||0)*75e-6),currency:"USD",detail:"Pay-as-you-go via tokens"},{name:"DomÃnio + SSL",cost:3,currency:"USD",detail:"Cloudflare + registro"}].map((s,t)=>e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[12px] text-slate-300 font-medium",children:s.name}),e.jsx("span",{className:"text-[10px] text-slate-600 ml-2",children:s.detail})]}),e.jsx("span",{className:`text-[12px] font-mono font-semibold ${s.cost>0?"text-white":"text-emerald-500"}`,children:s.cost>0?`$${s.cost}/mo`:"FREE"})]},t)),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 bg-slate-800/30",children:[e.jsx("span",{className:"text-[12px] text-white font-semibold",children:"Total Estimado"}),e.jsxs("div",{className:"text-right",children:[e.jsxs("span",{className:"text-[14px] font-bold font-mono text-white",children:["$",G,"/mo"]}),e.jsxs("span",{className:"text-[11px] text-slate-500 ml-2",children:["â R$ ",(G*5.1).toFixed(0),"/mês"]})]})]})]})})]}),e.jsx("div",{className:"mb-6 flex gap-1 bg-white border border-black/[0.06] rounded-xl p-1",children:[{id:"overview",label:"Visão Geral",icon:ls},{id:"history",label:"Histórico",icon:pe},{id:"management",label:"Gerenciamento",icon:he}].map(s=>e.jsxs("button",{onClick:()=>Ue(s.id),className:`flex-1 flex items-center justify-center gap-2 py-2.5 px-4 rounded-lg text-[11px] font-semibold transition-all ${F===s.id?"bg-slate-800 text-white shadow-sm":"text-slate-500 hover:text-slate-300"}`,children:[e.jsx(s.icon,{size:13}),s.label]},s.id))}),F==="history"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(ke,{size:12,className:"text-blue-400"}),"Tendência Mensal de Requisições"]}),e.jsx("div",{className:"bg-white border border-black/[0.06] rounded-xl p-5",children:N.length>0?e.jsx(ge,{width:"100%",height:260,children:e.jsxs(os,{data:N,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"reqGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
1stopColor:"#6366f1",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"errGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#ef4444",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#ef4444",stopOpacity:0})]})]}),e.jsx(be,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),e.jsx(fe,{dataKey:"month",tick:{fontSize:10,fill:"#94a3b8"}}),e.jsx(je,{tick:{fontSize:10,fill:"#94a3b8"}}),e.jsx(ve,{contentStyle:{background:"#fff",border:"1px solid #e2e8f0",borderRadius:8,fontSize:11},labelStyle:{color:"#64748b"}}),e.jsx(Ne,{type:"monotone",dataKey:"requests",stroke:"#6366f1",fill:"url(#reqGrad)",name:"Requisições"}),e.jsx(Ne,{type:"monotone",dataKey:"errors",stroke:"#ef4444",fill:"url(#errGrad)",name:"Erros"})]})}):e.jsx("div",{className:"h-[260px] flex items-center justify-center text-slate-600 text-[12px]",children:"Dados históricos mensais aparecerão após a primeira compactação"})})]}),N.length>0&&e.jsx("div",{className:"mb-8 grid grid-cols-2 md:grid-cols-4 gap-3",children:(()=>{const s=N[N.length-1],t=N.length>1?N[N.length-2]:null,a=t?((s.requests-t.requests)/(t.requests||1)*100).toFixed(0):null,r=t?((s.errors-t.errors)/(t.errors||1)*100).toFixed(0):null;return[{label:s.month,value:s.requests.toLocaleString(),sub:"Requisições",delta:a,color:"text-indigo-400"},{label:"Erros",value:s.errors.toLocaleString(),sub:s.month,delta:r,color:"text-red-400"},{label:"Tokens",value:s.tokens.toLocaleString(),sub:"Gemini + AI",delta:null,color:"text-amber-400"},{label:"Latência Média",value:`${s.avg_latency}ms`,sub:s.month,delta:null,color:"text-emerald-400"}].map((i,c)=>e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4",children:[e.jsx("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-1",children:i.label}),e.jsx("div",{className:`text-[18px] font-bold font-mono ${i.color}`,children:i.value}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-[10px] text-slate-600",children:i.sub}),i.delta&&e.jsxs("span",{className:`text-[10px] font-semibold ${Number(i.delta)>0?"text-amber-500":"text-emerald-500"}`,children:[Number(i.delta)>0?"â":"â"," ",Math.abs(Number(i.delta)),"%"]})]})]},c))})()}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(Y,{size:12,className:"text-orange-400"}),"Heatmap de Uso por Hora (7 dias)"]}),e.jsx("div",{className:"bg-white border border-black/[0.06] rounded-xl p-5",children:L.length>0?e.jsx(ge,{width:"100%",height:180,children:e.jsxs(ns,{data:L,children:[e.jsx(be,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),e.jsx(fe,{dataKey:"hour",tick:{fontSize:10,fill:"#94a3b8"},tickFormatter:s=>`${s}h`}),e.jsx(je,{tick:{fontSize:10,fill:"#94a3b8"}}),e.jsx(ve,{contentStyle:{background:"#fff",border:"1px solid #e2e8f0",borderRadius:8,fontSize:11},labelFormatter:s=>`${s}:00 - ${s}:59`,formatter:s=>[s,"Requisições"]}),e.jsx(cs,{dataKey:"count",radius:[4,4,0,0],children:L.map((s,t)=>{const a=Math.max(...L.map(c=>c.count),1),r=s.count/a,i=r>.7?"#ef4444":r>.4?"#f59e0b":r>.1?"#6366f1":"#334155";return e.jsx(ds,{fill:i},t)}
1)})]})}):e.jsx("div",{className:"h-[180px] flex items-center justify-center text-slate-600 text-[12px]",children:"Dados de uso aparecerão após interações com as APIs"})})]})]}),F==="management"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(he,{size:12,className:"text-cyan-400"}),"Gerenciamento de Dados"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-500/10 rounded-lg flex items-center justify-center",children:e.jsx(z,{size:18,className:"text-blue-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-semibold text-[#111]",children:"api_usage_log"}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"Registros detalhados (<90 dias)"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-[11px]",children:[e.jsx("span",{className:"text-slate-500",children:"Registros"}),e.jsx("span",{className:"text-[#111] font-mono",children:J.rows.toLocaleString()})]}),e.jsxs("div",{className:"flex justify-between text-[11px]",children:[e.jsx("span",{className:"text-slate-500",children:"Tamanho estimado"}),e.jsx("span",{className:"text-[#111] font-mono",children:J.size})]})]})]}),e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-500/10 rounded-lg flex items-center justify-center",children:e.jsx(pe,{size:18,className:"text-purple-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-semibold text-[#111]",children:"api_usage_monthly"}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"Arquivo frio · lag de 35 dias"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-[11px]",children:[e.jsx("span",{className:"text-slate-500",children:"Meses registrados"}),e.jsx("span",{className:"text-[#111] font-mono",children:N.length})]}),e.jsxs("div",{className:"flex justify-between text-[11px]",children:[e.jsx("span",{className:"text-slate-500",children:"Total histórico"}),e.jsxs("span",{className:"text-[#111] font-mono",children:[N.reduce((s,t)=>s+t.requests,0).toLocaleString()," req"]})]})]})]}),e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-emerald-500/10 rounded-lg flex items-center justify-center",children:e.jsx(ue,{size:18,className:"text-emerald-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-semibold text-[#111]",children:"Compactação"}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"pg_cron: diário 3h UTC"})]})]}),e.jsx("button",{onClick:Fe,disabled:Z,className:"w-full mt-2 py-2.5 px-4 bg-[#111] hover:bg-[#333] text-white text-[11px] font-semibold rounded-lg transition-all flex items-center justify-center gap-2 disabled:opacity-50",children:Z?e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:13,className:"animate-spin"})," Compactando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:13})," Compactar Agora"]})}),ee&&e.jsx("div",{className:"mt-3 text-[10px] text-emerald-600 bg-emerald-50 border border-emerald-200 rounded-lg p-3",children:ee})]})]})]}),S&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(z,{size:12,className:"text-emerald-400"}),"Banco de Dados"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4",children:[e.jsx("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-1",children:"Tamanho"}),e.jsx("div",{className:"text-[18px] font-bold font-mono text-[#111]",children:S.size})]}),e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4",children:[e.jsx("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-1",children:"Tabelas"}),e.jsx("div",{className:"text-[18px] font-bold font-mono text-[#111]",children:S.tables})]}),e.jsxs("div",{className:"bg-white border border-black/[0.06] rounded-xl p-4",children:[e.jsx("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-1",children:"Conexões"}),e.jsx("div",{className:"text-[18px] font-bold font-mono text-[#111]",children:S.connections})]})]})]}),e.jsxs("div",{className:"mb-8 bg-white border border-black/[0.06] rounded-xl p-5",children:[e.jsxs("h3",{className:"text-[12px] font-semibold text-white mb-3 flex items-center gap-2",children:[e.jsx(de,{size:13,className:"text-blue-400"}),"Como funciona a compactação"]}),e.jsxs("div",{className:"space-y-2 text-[11px] text-slate-400",children:[e.jsxs("p",{children:["⢠",e.jsxs("span",{className:"text-slate-300",children:["Logs ","<"," 35 dias"]})," â mantidos em"," ",e.jsx("code",{className:"text-blue-400",children:"api_usage_log"})," com todos os detalhes"]}),e.jsxs("p",{children:["⢠",e.jsx("span",{className:"text-slate-300",children:"Todo dia"})," â consolidado em"," ",e.jsx("code",{className:"text-amber-400",children:"api_usage_daily"})," (fonte dos gráficos e do recorte de 30 dias)"]}),e.jsxs("p",{children:["⢠",e.jsxs("span",{className:"text-slate-300",children:["Logs ",">"," 35 dias"]})," â agregados em"," ",e.jsx("code",{className:"text-purple-400",children:"api_usage_monthly"})," e deletados do raw"]}),e.jsxs("p",{children:["⢠",e.jsx("span",{className:"text-emerald-400",children:"Execução automática"})," â rollup diário de hora em hora, compactação à s 3h UTC, via"," ",e.jsx("code",{className:"text-cyan-400",children:"pg_cron"})]})]})]})]}),e.jsxs("div",{className:"text-center text-[10px] text-slate-700 py-4",children:["Métricas reais via ",e.jsx("code",{className:"text-slate-600",children:"api_usage_log"})," ⢠Série diária via ",e.jsx("code",{className:"text-slate-600",children:"api_usage_daily"})," ⢠Arquivo via"," ",e.jsx("code",{className:"text-slate-600",children:"api_usage_monthly"})," ⢠Compactação via"," ",e.jsx("code",{className:"text-slate-600",children:"pg_cron"})]})]})})};
1export{ys as InfrastructureDashboard,ys 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.