1 line
26 KiB
JavaScript
1 line
26 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,8225,e=>{"use strict";let t="http://localhost:8000/api";function s(e){return{...e,images:e.images?JSON.parse(e.images):[],closing_alerts_sent:e.closing_alerts_sent?JSON.parse(e.closing_alerts_sent):[]}}async function r(e=100){let n=await fetch(`${t}/listings?limit=${e}`);if(!n.ok)throw Error("Failed to fetch listings");return(await n.json()).map(s)}async function n(){if(!(await fetch(`${t}/listings`,{method:"DELETE"})).ok)throw Error("Failed to clear listings")}async function i(){let e=await fetch(`${t}/listings/countdown-sync`);if(!e.ok)throw Error("Failed to sync countdown");return e.json()}e.s(["deleteAllListings",()=>n,"fetchCountdownSync",()=>i,"fetchListings",()=>r,"getExportUrl",0,e=>`${t}/export/${e}`])},78928,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(46932),n=e.i(96666),i=e.i(47163);let a=[{id:"scanned",label:"Lots Scanned",sub:"Processed this session",gradFrom:"#00e87b",gradTo:"#06b6d4",icon:(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.35-4.35"})]})},{id:"alerts",label:"Alerts Fired",sub:"Qualifying matches",gradFrom:"#fbbf24",gradTo:"#f59e0b",icon:(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,t.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})},{id:"keywords",label:"Active Targets",sub:"Keyword strategies",gradFrom:"#a78bfa",gradTo:"#3b82f6",icon:(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"}),(0,t.jsx)("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]})},{id:"uptime",label:"Engine Uptime",sub:"Continuous runtime",gradFrom:"#3b82f6",gradTo:"#06b6d4",icon:(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,t.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}];function o({scanned:e,alerts:s,keywords:n,uptime:o}){let l={scanned:String(e),alerts:s,keywords:n,uptime:o};return(0,t.jsx)("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-4",children:a.map((e,n)=>{let a=l[e.id],o="alerts"===e.id&&s>0;return o&&e.gradFrom,(0,t.jsxs)(r.motion.div,{initial:{opacity:1,y:18,scale:.97},animate:{opacity:1,y:0,scale:1},transition:{duration:.55,delay:.07*n,ease:[.22,1,.36,1]},className:"g-card-glow p-5 flex flex-col gap-3.5 group cursor-default select-none",children:[(0,t.jsxs)("div",{className:"relative z-10 flex items-start justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-g-faint leading-none mt-0.5",children:e.label}),(0,t.jsx)("div",{className:"shrink-0 w-7 h-7 rounded-lg flex items-center justify-center transition-all duration-300 group-hover:scale-110",style:{background:`linear-gradient(135deg, ${e.gradFrom}18, ${e.gradTo}10)`,border:`1px solid ${e.gradFrom}25`,color:e.gradFrom,boxShadow:`0 0 12px ${e.gradFrom}15`},children:e.icon})]}),(0,t.jsx)("div",{className:"relative z-10",children:(0,t.jsx)("span",{className:(0,i.cn)("g-stat-num transition-colors duration-300",o?"text-g-amber":"text-g-text"),style:{},children:a})}),(0,t.jsx)("p",{className:"relative z-10 text-[10px] text-g-faint/50 leading-none font-medium",children:e.sub}),(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-px opacity-20 group-hover:opacity-40 transition-opacity",style:{background:`linear-gradient(90deg, transparent, ${e.gradFrom}80, ${e.gradTo}50, transparent)`}}),o&&(0,t.jsx)("div",{className:"absolute top-4 right-4 w-1.5 h-1.5 rounded-full",style:{background:e.gradFrom,boxShadow:`0 0 6px ${e.gradFrom}`,animation:"pulse-ring 2s ease-out infinite"}})]},e.id)})})}var l=e.i(88653),d=e.i(8225);function c({mins:e}){if(null===e)return(0,t.jsx)("span",{className:"text-[10px] text-g-faint font-mono",children:"—"});let s=e<=60,r=e>60&&e<=180;return s?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold text-g-red tabular-nums",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-g-red shrink-0",style:{animation:"pulse-ring 1.5s ease-out infinite",boxShadow:"0 0 6px #f43f5e"}}),(0,i.formatMins)(e)]}):r?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-g-amber tabular-nums",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-g-amber/60 shrink-0"}),(0,i.formatMins)(e)]}):(0,t.jsx)("span",{className:"text-[10px] text-g-faint/70 font-mono tabular-nums",children:(0,i.formatMins)(e)})}function x({match:e}){return 1===e?(0,t.jsx)("span",{className:"g-badge g-badge-green text-[9px] tracking-wide",children:"✓ AI"}):0===e?(0,t.jsx)("span",{className:"g-badge g-badge-red text-[9px] tracking-wide",children:"✗ AI"}):null}function g({score:e}){return(0,t.jsx)("span",{className:(0,i.cn)("text-[11px] font-bold tabular-nums font-mono",e>=50?"text-g-green":e>=20?"text-g-amber":e>=0?"text-g-muted":"text-g-red"),children:e>0?`+${e}`:e})}function u({src:e}){let[r,n]=(0,s.useState)(!1);return!e||r?(0,t.jsx)("div",{className:"w-9 h-9 rounded-lg bg-g-raised border border-g-border/40 flex items-center justify-center shrink-0",children:(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3d4f78",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,t.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,t.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}):(0,t.jsx)("img",{src:e,alt:"",onError:()=>n(!0),className:"w-9 h-9 rounded-lg object-cover shrink-0 border border-g-border/30 bg-g-raised",loading:"lazy"})}function h(){let[e,n]=(0,s.useState)([]),[a,o]=(0,s.useState)(!0),[h,p]=(0,s.useState)(null),m=(0,s.useRef)(!0),f=(0,s.useCallback)(async()=>{try{let e=await (0,d.fetchListings)(10);m.current&&(n(e),p(new Date),o(!1))}catch{m.current&&o(!1)}},[]);return(0,s.useEffect)(()=>{m.current=!0,f();let e=setInterval(f,1e4);return()=>{m.current=!1,clearInterval(e)}},[f]),(0,t.jsxs)(r.motion.div,{initial:{opacity:1,y:12},animate:{opacity:1,y:0},transition:{delay:.1,duration:.5,ease:[.22,1,.36,1]},className:"g-card flex flex-col overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3.5 border-b border-g-border/40 shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"g-pulse-dot"}),(0,t.jsx)("span",{className:"text-sm font-bold text-g-text tracking-tight",children:"Recent Captures"})]}),(0,t.jsxs)("span",{className:"text-[10px] text-g-faint tabular-nums font-mono",children:[e.length," lots"]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[h&&(0,t.jsx)("span",{className:"text-[10px] text-g-faint/50 font-mono hidden sm:block",children:h.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),(0,t.jsxs)("button",{onClick:f,className:"g-btn h-7 px-2.5 text-xs gap-1.5",title:"Refresh now",children:[(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,t.jsx)("path",{d:"M3.51 15a9 9 0 1 0 .49-3.51"})]}),"Refresh"]})]})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",style:{maxHeight:440},children:a?(0,t.jsx)("div",{className:"space-y-0",children:Array.from({length:6}).map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-g-border/20 last:border-0",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-lg bg-g-raised shrink-0 shimmer"}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5",children:[(0,t.jsx)("div",{className:"h-3 bg-g-raised rounded shimmer w-3/4"}),(0,t.jsx)("div",{className:"h-2.5 bg-g-raised rounded shimmer w-1/3"})]}),(0,t.jsx)("div",{className:"h-3 w-12 bg-g-raised rounded shimmer"})]},s))}):0===e.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[(0,t.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-g-raised border border-g-border/40 flex items-center justify-center",children:(0,t.jsxs)("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"#3d4f78",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,t.jsx)("path",{d:"m21 21-4.35-4.35"})]})}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("p",{className:"text-sm text-g-muted font-medium",children:"No lots captured yet"}),(0,t.jsx)("p",{className:"text-xs text-g-faint mt-1",children:"Start the engine to begin scanning"})]})]}):(0,t.jsx)(l.AnimatePresence,{mode:"popLayout",initial:!1,children:e.map((e,s)=>(0,t.jsxs)(r.motion.a,{href:e.link,target:"_blank",rel:"noopener noreferrer",initial:{opacity:1,x:-8},animate:{opacity:1,x:0},exit:{opacity:0,x:8,height:0},transition:{delay:.03*s,duration:.3},className:"group flex items-center gap-3 px-5 py-3 border-b border-g-border/20 last:border-0 hover:bg-g-raised/50 transition-colors duration-150 cursor-pointer",children:[(0,t.jsx)(u,{src:e.images?.[0]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 space-y-0.5",children:[(0,t.jsx)("p",{className:"text-[12px] font-medium text-g-text group-hover:text-g-green transition-colors leading-snug line-clamp-1",title:e.title,children:e.title}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[10px] text-g-faint bg-g-raised px-1.5 py-0.5 rounded font-medium border border-g-border/30",children:e.site_name}),(0,t.jsxs)("span",{className:"text-[10px] text-g-faint/60 font-mono",children:["#",e.keyword]}),(0,t.jsx)(x,{match:e.ai_match})]})]}),(0,t.jsxs)("div",{className:"text-right shrink-0 min-w-[64px]",children:[(0,t.jsx)("p",{className:"text-[13px] font-bold text-g-text tabular-nums leading-none",children:(0,i.formatPrice)(e.price,e.currency,e.price_usd)}),e.price_usd&&"USD"!==e.currency&&(0,t.jsxs)("p",{className:"text-[10px] text-g-faint/50 tabular-nums mt-0.5",children:["$",e.price_usd.toFixed(0)," USD"]})]}),(0,t.jsx)("div",{className:"shrink-0 w-[52px] text-right",children:(0,t.jsx)(c,{mins:e.time_left_mins})}),(0,t.jsx)("div",{className:"shrink-0 w-[36px] text-right",children:(0,t.jsx)(g,{score:e.score})}),(0,t.jsx)("div",{className:"shrink-0 w-4 flex items-center justify-end",children:(0,t.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-g-faint/30 group-hover:text-g-green transition-colors",children:(0,t.jsx)("polyline",{points:"9 18 15 12 9 6"})})})]},e.id))})}),e.length>0&&(0,t.jsxs)("div",{className:"px-5 py-2.5 border-t border-g-border/30 flex items-center justify-between shrink-0 bg-g-base/30",children:[(0,t.jsxs)("span",{className:"text-[10px] text-g-faint/50",children:["Refreshes every ",10,"s"]}),(0,t.jsxs)("a",{href:"/listings",className:"text-[10px] text-g-muted hover:text-g-green transition-colors font-semibold flex items-center gap-1",children:["View all listings",(0,t.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polyline",{points:"9 18 15 12 9 6"})})]})]})]})}let p=e=>fetch(`http://localhost:8000/api/engine/${e}`,{method:"POST"});function m({status:e}){let s={Running:{color:"#00e87b",label:"Running",shadow:"rgba(0,232,123,0.5)"},Paused:{color:"#fbbf24",label:"Paused",shadow:"rgba(251,191,36,0.5)"},Idle:{color:"#3d4f78",label:"Idle",shadow:"rgba(61,79,120,0.3)"}},r=s[e]??s.Idle;return(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsxs)("div",{className:"relative flex items-center justify-center",children:["Running"===e&&(0,t.jsx)("span",{className:"absolute inline-flex rounded-full opacity-60",style:{width:20,height:20,background:r.color,filter:"blur(6px)",animation:"glow-pulse 2s ease-in-out infinite"}}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full",style:{width:10,height:10,background:r.color,boxShadow:`0 0 10px ${r.shadow}`,animation:"Running"===e?"pulse-ring 2s ease-out infinite":void 0}})]}),(0,t.jsx)("span",{className:"text-[13px] font-bold tracking-tight",style:{color:r.color},children:r.label})]})}function f({label:e,icon:n,onClick:a,variant:o,disabled:l}){let[d,c]=(0,s.useState)(!1),x=async()=>{if(!d&&!l){c(!0);try{await a()}finally{setTimeout(()=>c(!1),1500)}}};return(0,t.jsxs)(r.motion.button,{whileHover:l?void 0:{scale:1.03,y:-1},whileTap:l?void 0:{scale:.96},onClick:x,disabled:l||d,className:(0,i.cn)("flex items-center justify-center gap-1.5 rounded-xl text-[11px] font-semibold px-3 py-2.5 transition-all duration-200","border disabled:opacity-40 disabled:cursor-not-allowed","danger"===o?"border-g-red/25 bg-g-red/8 text-g-red hover:bg-g-red/15 hover:border-g-red/40 hover:shadow-[0_0_20px_rgba(244,63,94,0.12)]":"border-g-border/60 bg-g-raised/60 text-g-muted hover:text-g-text hover:border-g-line hover:bg-g-raised hover:shadow-[0_4px_16px_rgba(0,0,0,0.4)]"),children:[d?(0,t.jsx)("svg",{className:"animate-spin shrink-0",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,t.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}):n,e]})}function b({site:e}){let s=1===e.enabled,r=!!e.cooldown_until&&new Date(e.cooldown_until)>new Date,n=e.consecutive_failures>0,i="#3d4f78",a="Disabled";return s&&r?(i="#fbbf24",a="Cooldown"):s&&n?(i="#f43f5e",a=`${e.consecutive_failures}x fail`):s&&(i="#00e87b",a="Active"),(0,t.jsxs)("div",{className:"flex items-center gap-2.5 py-2 px-4 border-b border-g-border/15 last:border-0 group",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0 transition-all",style:{background:i,boxShadow:!s||r||n?void 0:`0 0 5px ${i}80`}}),(0,t.jsx)("span",{className:"flex-1 text-[11px] text-g-muted group-hover:text-g-text transition-colors truncate font-medium",children:e.name}),(0,t.jsx)("span",{className:"text-[10px] font-semibold shrink-0 tabular-nums",style:{color:i},children:a})]})}function j(){let{status:e,uptime_seconds:a,total_scanned:o,last_cycle:l,isOffline:d}=(0,n.useEngineStore)(),[c,x]=(0,s.useState)([]),[g,u]=(0,s.useState)("—"),h=(0,s.useRef)(!0),j=(0,s.useCallback)(async()=>{try{let e=await fetch("http://localhost:8000/api/sites"),t=await e.json();h.current&&x(Array.isArray(t)?t:[])}catch{}},[]);(0,s.useEffect)(()=>{h.current=!0,j();let e=setInterval(j,25e3);return()=>{h.current=!1,clearInterval(e)}},[j]),(0,s.useEffect)(()=>{let e=()=>u((0,i.timeAgo)("Never"===l?null:l));e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[l]);let v="Running"===e,y="Paused"===e,N=c.filter(e=>1===e.enabled).length,w=[{label:"Pause",variant:"default",disabled:!v,onClick:()=>p("pause"),icon:(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,t.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]})},{label:"Resume",variant:"default",disabled:!y,onClick:()=>p("resume"),icon:(0,t.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})},{label:"Restart",variant:"default",disabled:!1,onClick:()=>p("restart"),icon:(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,t.jsx)("path",{d:"M3.51 15a9 9 0 1 0 .49-3.51"})]})},{label:"Kill",variant:"danger",disabled:!1,onClick:()=>p("kill"),icon:(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,t.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}];return(0,t.jsxs)(r.motion.div,{initial:{opacity:1,x:12},animate:{opacity:1,x:0},transition:{delay:.2,duration:.5,ease:[.22,1,.36,1]},className:"g-card flex flex-col overflow-hidden",children:[(0,t.jsxs)("div",{className:"px-5 pt-5 pb-4 border-b border-g-border/40 space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-g-faint",children:"Engine Status"}),d&&(0,t.jsx)("span",{className:"g-badge g-badge-red text-[9px]",children:"OFFLINE"})]}),(0,t.jsx)(m,{status:e}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"bg-g-raised/50 rounded-xl p-3 border border-g-border/30",children:[(0,t.jsx)("p",{className:"text-[9px] uppercase tracking-widest text-g-faint font-bold mb-1",children:"Uptime"}),(0,t.jsx)("p",{className:"text-sm font-bold text-g-text tabular-nums font-mono",children:(0,i.formatUptime)(a)})]}),(0,t.jsxs)("div",{className:"bg-g-raised/50 rounded-xl p-3 border border-g-border/30",children:[(0,t.jsx)("p",{className:"text-[9px] uppercase tracking-widest text-g-faint font-bold mb-1",children:"Last Scan"}),(0,t.jsx)("p",{className:"text-sm font-bold text-g-text tabular-nums font-mono",children:g})]}),(0,t.jsxs)("div",{className:"bg-g-raised/50 rounded-xl p-3 border border-g-border/30 col-span-2",children:[(0,t.jsx)("p",{className:"text-[9px] uppercase tracking-widest text-g-faint font-bold mb-1",children:"Lots Scanned"}),(0,t.jsx)("p",{className:"text-sm font-bold text-g-text tabular-nums font-mono",children:o.toLocaleString()})]})]})]}),(0,t.jsxs)("div",{className:"px-5 py-4 border-b border-g-border/40 space-y-2.5",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-g-faint block",children:"Controls"}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2",children:w.map(e=>(0,t.jsx)(f,{...e},e.label))})]}),(0,t.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-g-border/25",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-g-faint",children:"Sites"}),(0,t.jsxs)("span",{className:"text-[10px] text-g-faint/50 font-mono ml-auto",children:[N,"/",c.length," active"]})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",style:{maxHeight:200},children:0===c.length?(0,t.jsx)("p",{className:"text-[11px] text-g-faint/40 text-center py-6",children:"No sites configured"}):c.map(e=>(0,t.jsx)(b,{site:e},e.id))})]})]})}let v=1;function y(e,t="info"){return{id:v++,time:new Date().toLocaleTimeString(),msg:e,level:t}}let N={info:"text-g-muted",success:"text-g-green",warn:"text-g-amber",error:"text-g-red"},w={info:"bg-g-faint/40",success:"bg-g-green",warn:"bg-g-amber",error:"bg-g-red"};function k(){let[e,i]=(0,s.useState)(()=>[y("Ghost Node dashboard initialised.","success")]),[a,o]=(0,s.useState)(""),d=(0,s.useRef)(null),{status:c,last_cycle:x,total_alerts:g}=(0,n.useEngineStore)(),u=(0,s.useRef)(null),h=(0,s.useRef)(null),p=(0,s.useRef)(-1),m=(0,s.useCallback)((e,t="info")=>{i(s=>[...s.slice(-199),y(e,t)])},[]);(0,s.useEffect)(()=>{if(null===u.current){u.current=c;return}u.current!==c&&("Running"===c?m("Engine started.","success"):"Paused"===c?m("Engine paused.","warn"):"Idle"===c&&m("Engine stopped.","warn"),u.current=c)},[c,m]),(0,s.useEffect)(()=>{if(null===h.current){h.current=x;return}h.current!==x&&(x&&"Never"!==x&&m("Scan cycle completed.","info"),h.current=x)},[x,m]),(0,s.useEffect)(()=>{if(-1===p.current){p.current=g;return}if(g>p.current){let e=g-p.current;m(`${e} new alert${e>1?"s":""} fired!`,"success")}p.current=g},[g,m]),(0,s.useEffect)(()=>{d.current?.scrollIntoView({behavior:"smooth"})},[e]);let f=a?e.filter(e=>e.msg.toLowerCase().includes(a.toLowerCase())):e;return(0,t.jsxs)(r.motion.div,{initial:{opacity:1,y:12},animate:{opacity:1,y:0},transition:{delay:.2,duration:.4,ease:[.22,1,.36,1]},className:"g-card overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3.5 border-b border-g-border/40",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"g-pulse-dot"}),(0,t.jsx)("span",{className:"text-sm font-bold text-g-text tracking-tight",children:"Activity Log"})]}),(0,t.jsxs)("span",{className:"text-[10px] text-g-faint font-mono tabular-nums",children:[e.length," events"]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsx)("input",{value:a,onChange:e=>o(e.target.value),placeholder:"Filter events…",className:"g-input w-36 h-7 text-[11px] py-0 px-2.5"}),(0,t.jsx)("button",{onClick:()=>d.current?.scrollIntoView({behavior:"smooth"}),className:"g-btn h-7 px-2 text-xs",title:"Scroll to bottom",children:(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,t.jsx)("polyline",{points:"19 12 12 19 5 12"})]})}),(0,t.jsx)("button",{onClick:()=>i([]),className:"g-btn h-7 px-2.5 text-xs hover:!text-g-red hover:!border-g-red/30",children:"Clear"})]})]}),(0,t.jsxs)("div",{className:"h-48 overflow-y-auto p-4 font-mono",children:[0===f.length?(0,t.jsx)("p",{className:"text-g-faint/30 text-[11px] text-center py-8",children:"No events"}):(0,t.jsx)(l.AnimatePresence,{mode:"popLayout",initial:!1,children:f.map(e=>(0,t.jsxs)(r.motion.div,{initial:{opacity:1,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,height:0},transition:{duration:.2},className:"flex items-start gap-3 py-1.5 group",children:[(0,t.jsx)("span",{className:"shrink-0 text-[10px] text-g-faint/40 pt-px tabular-nums leading-relaxed",children:e.time}),(0,t.jsx)("span",{className:`w-1 h-1 rounded-full mt-1.5 shrink-0 ${w[e.level]}`}),(0,t.jsx)("span",{className:`text-[11px] leading-relaxed transition-opacity group-hover:opacity-100 opacity-80 ${N[e.level]}`,children:e.msg})]},e.id))}),(0,t.jsx)("div",{ref:d})]})]})}let L="http://localhost:8000";function S(){let[e,r]=(0,s.useState)("");return(0,s.useEffect)(()=>{let e=()=>new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});r(e());let t=setInterval(()=>r(e()),1e3);return()=>clearInterval(t)},[]),(0,t.jsx)("span",{className:"text-[12px] font-mono text-g-faint/60 tabular-nums tracking-widest select-none",children:e})}function C({offline:e}){return(0,t.jsxs)("div",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full border text-[10px] font-bold tracking-wide transition-all duration-500 ${e?"bg-g-red/8 border-g-red/20 text-g-red":"bg-g-green/8 border-g-green/15 text-g-green"}`,children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:e?"#f43f5e":"#00e87b",boxShadow:e?"0 0 6px #f43f5e80":"0 0 6px #00e87b80",animation:e?void 0:"pulse-ring 2s ease-out infinite"}}),e?"OFFLINE":"LIVE"]})}function E({children:e}){return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-g-faint/70 whitespace-nowrap",children:e}),(0,t.jsx)("div",{className:"flex-1 h-px bg-gradient-to-r from-g-border/60 to-transparent"})]})}function $(){let{status:e,uptime_seconds:a,total_scanned:l,total_alerts:d,isOffline:c}=(0,n.useEngineStore)(),[x,g]=(0,s.useState)(0);return(0,s.useEffect)(()=>{fetch(`${L}/api/keywords`).then(e=>e.json()).then(e=>{Array.isArray(e)&&g(e.length)}).catch(()=>{})},[]),(0,t.jsxs)("div",{className:"space-y-8",children:[(0,t.jsxs)(r.motion.div,{initial:{opacity:1,y:-10},animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]},className:"flex items-end justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("h1",{className:"text-[22px] font-extrabold tracking-[-0.04em] leading-none bg-gradient-to-r from-g-text to-g-muted bg-clip-text text-transparent",children:"Mission Control"}),(0,t.jsx)(C,{offline:c})]}),(0,t.jsx)("p",{className:"text-[12px] text-g-faint font-medium",children:"Auction intelligence engine · Ghost Node v2.7"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)(S,{}),(0,t.jsxs)("a",{href:`${L}/api/export/csv`,target:"_blank",rel:"noopener noreferrer",className:"g-btn h-8 px-3 text-[11px] gap-1.5",title:"Export all listings as CSV",children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,t.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,t.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Export"]})]})]}),(0,t.jsx)("div",{className:"glow-line"}),(0,t.jsx)("section",{children:(0,t.jsx)(o,{scanned:l,alerts:d,keywords:x,uptime:(0,i.formatUptime)(a)})}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsx)(E,{children:"Live Feed"}),(0,t.jsxs)("div",{className:"grid grid-cols-1 xl:grid-cols-[1fr_360px] gap-5",children:[(0,t.jsx)(h,{}),(0,t.jsx)(j,{})]})]}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsx)(E,{children:"Activity Log"}),(0,t.jsx)(k,{})]})]})}e.s(["default",()=>$],78928)}]); |