import{Dt as e,En as t,Et as n,F as r,Gt as i,It as a,On as o,Pt as s,Rt as c,St as l,Tt as ee,U as u,a as d,b as f,cn as p,ht as m,o as h,t as g,tn as _,xt as te,yt as v}from"./_plugin-vue_export-helper-Df8BHgqR.js";import{g as y,h as b,j as x,p as S}from"./index-BanWZHpm.js";import{t as C}from"./PageHeader-CZdSfouL.js";var w={class:`page-container`},T={key:0,class:`grid items-start gap-8 md:grid-cols-2`},E={class:`grid gap-8`},D={class:`grid grid-cols-1 gap-4 sm:grid-cols-2`},O={class:`flex items-center gap-2 text-stone-100`},k={class:`font-bold`},A={class:`text-muted font-mono text-xs`},j={class:`mt-2 flex flex-wrap gap-1`},M={key:0,class:`text-muted text-xs italic`},N={key:1,class:`flex items-center gap-2`},P={class:`grid grid-cols-1 gap-4 sm:grid-cols-2`},F={class:`mt-1 font-mono text-2xl text-stone-100`},I={class:`mt-1 font-mono text-2xl text-stone-100`},L={class:`mt-1 font-mono text-2xl text-stone-100`},R={class:`mt-1 font-mono text-2xl text-stone-100`},ne={class:`mt-1 font-mono text-2xl text-stone-100`},z={class:`grid gap-8`},B={class:`space-y-4`},V={class:`font-mono text-lg`},H={class:`font-mono text-lg`},U={class:`space-y-4`},W={class:`grid grid-cols-1 gap-4 sm:grid-cols-2`},G={class:`font-mono text-lg`},K={class:`font-mono text-lg`},q={class:`mt-8 flex flex-col items-center gap-4`},J=[`disabled`,`title`],Y={key:1,class:`relative flex h-64 items-center justify-center`},X=g(e({__name:`StatsView`,setup(e){let g=_(null),X=_([]),Z=_(!1),Q=_(``),re=async()=>{try{let e=await fetch(`/api/active-honeypots`);e.ok&&(X.value=await e.json())}catch(e){console.error(`Failed to fetch active honeypots`,e)}},$=async()=>{try{let e=await fetch(`/api/system-stats`);e.ok&&(g.value=await e.json())}catch(e){console.error(`Failed to fetch system stats`,e)}},ie=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},ae=async()=>{if(!Z.value){Z.value=!0,Q.value=``;try{(await fetch(`/api/system/update-geodb`,{method:`POST`})).ok?(Q.value=`GeoLite database updated successfully`,await $()):Q.value=`Failed to update GeoLite database`}catch(e){console.error(`Failed to update GeoDB`,e),Q.value=`Error updating GeoLite database`}finally{Z.value=!1}}};return s(()=>{$(),re()}),(e,s)=>(a(),l(`div`,w,[n(C,{title:`System Statistics`,icon:p(x).activity},null,8,[`icon`]),g.value?(a(),l(`div`,T,[v(`div`,E,[n(S,{title:`Active Honeypots`,icon:p(x).honeypotType},{default:i(()=>[v(`div`,D,[(a(!0),l(m,null,c(X.value,e=>(a(),l(`div`,{key:e.name,class:`flex flex-col rounded-lg border border-stone-800 bg-stone-900 p-4`},[v(`div`,O,[v(`span`,k,o(e.label),1),v(`span`,A,`(`+o(e.name)+`)`,1)]),v(`div`,j,[!e.ports||e.ports.length===0?(a(),l(`div`,M,` No active ports (passive) `)):(a(),l(`div`,N,[s[0]||=v(`span`,{class:`text-muted text-xs`},`Ports:`,-1),(a(!0),l(m,null,c(e.ports,e=>(a(),l(`div`,{key:e,class:`rounded bg-stone-800 px-2 py-0.5 font-mono text-xs font-semibold text-stone-100`},o(e),1))),128))]))])]))),128))])]),_:1},8,[`icon`]),n(S,{title:`Database`,icon:p(u)},{default:i(()=>[v(`div`,P,[n(y,{label:`Total Size`,class:`bg-stone-900`},{default:i(()=>[v(`div`,F,o(ie(g.value.database.database_size)),1)]),_:1}),n(y,{label:`Total Events`,class:`bg-stone-900`},{default:i(()=>[v(`div`,I,o(p(h)(g.value.database.rows_events)),1)]),_:1}),n(y,{label:`Tracked IPs`,class:`bg-stone-900`},{default:i(()=>[v(`div`,L,o(p(h)(g.value.database.rows_ips)),1)]),_:1}),n(y,{label:`Blocklist Entries`,class:`bg-stone-900`},{default:i(()=>[v(`div`,R,o(p(h)(g.value.database.rows_blocklist)),1)]),_:1}),n(y,{label:`Unresolved IPs`,class:`bg-stone-900`},{default:i(()=>[v(`div`,ne,o(p(h)(g.value.database.rows_unresolved_ips)),1)]),_:1})])]),_:1},8,[`icon`])]),v(`div`,z,[n(S,{title:`Tickers & Caches`,icon:p(x).time},{default:i(()=>[v(`div`,B,[n(y,{label:`IP Info Updater`,class:`bg-stone-900`},{default:i(()=>[s[1]||=v(`div`,{class:`mt-4 text-stone-400`},`Last successful run`,-1),v(`div`,V,o(p(d)(g.value.ip_info_last_run)),1)]),_:1}),n(y,{label:`Score Cache`,class:`bg-stone-900`},{default:i(()=>[s[2]||=v(`div`,{class:`mt-4`},[v(`div`,{class:`text-stone-400`},`Last updated`)],-1),v(`div`,H,o(p(d)(g.value.score_cache_updated)),1)]),_:1})])]),_:1},8,[`icon`]),n(S,{title:`GeoLite Databases`,icon:p(r)},{default:i(()=>[v(`div`,U,[v(`div`,W,[n(y,{label:`ASN Database`,class:`bg-stone-900`},{default:i(()=>[s[3]||=v(`div`,{class:`mt-4 text-stone-400`},`Last updated`,-1),v(`div`,G,o(p(d)(g.value.geolite_asn_date)),1)]),_:1}),n(y,{label:`City Database`,class:`bg-stone-900`},{default:i(()=>[s[4]||=v(`div`,{class:`mt-4 text-stone-400`},`Last updated`,-1),v(`div`,K,o(p(d)(g.value.geolite_city_date)),1)]),_:1})]),v(`div`,q,[v(`button`,{onClick:ae,disabled:Z.value||!g.value.geolite_urls_set,title:g.value.geolite_urls_set?``:`Download URLs not configured`,class:`btn-secondary px-4 py-2 text-sm disabled:opacity-50`},[n(p(f),{class:t([`h-5 w-5`,{"animate-spin":Z.value}])},null,8,[`class`]),ee(` `+o(Z.value?`Updating...`:`Update GeoLite Database`),1)],8,J),Q.value?(a(),l(`div`,{key:0,class:t([`text-sm font-semibold`,Q.value.includes(`success`)?`text-secondary-400`:`text-rose-400`])},o(Q.value),3)):te(``,!0)])])]),_:1},8,[`icon`])])])):(a(),l(`div`,Y,[n(b)]))]))}}),[[`__scopeId`,`data-v-dcbe9fab`]]);export{X as default};