1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-globe.gl-DqAfY7sq.js","assets/query-vendor-Dp9tfhuh.js","assets/chart-vendor-BoynbIzZ.js","assets/react-vendor-DfslLuwi.js"])))=>i.map(i=>d[i]); 2import{s as b,h as x,m as h,B as N,R as k,i as S,k as L,S as _,L as A,_ as E}from"./index-CgOeqv80.js";import{r,j as t}from"./query-vendor-Dp9tfhuh.js";import{B as D}from"./badge-CarGzGVG.js";import{S as z}from"./skeleton-U7PtyM3w.js";import{M as R}from"./map-pin-B63H-upO.js";import{U as T}from"./users-9XO_ctWv.js";import{aP as U}from"./DashboardLayout-v_SFEx5M.js";import{G as C}from"./globe-C_UDh3Yp.js";import{P as V}from"./pause-DWfQPC5O.js";import{P as G}from"./play-CVPqrcf1.js";import"./react-vendor-DfslLuwi.js";import"./ui-vendor-DW4RoVmg.js";import"./chart-vendor-BoynbIzZ.js";import"./use-mobile-CojsY12Z.js";import"./input-go5takyh.js";import"./separator-DP1KYTpB.js";import"./sheet-bqYui_d3.js";import"./tooltip-CSLOX5Ak.js";import"./Logo-Dty4QCqO.js";import"./calendar-days-Cbs598pa.js";import"./building-2-BMIYvzwG.js";import"./wrench-CDdvezGQ.js";import"./wifi-off-BfVaxzCl.js";import"./message-square-B81woyC-.js";import"./file-text-CuOiBfSM.js";import"./credit-card-B-2xvAjl.js";import"./panel-top-BGv8mfXo.js";import"./mail-CObWevXE.js";import"./log-out-SS0g6Uak.js";import"./scroll-area-DpCy8yLM.js";import"./index-BdQq_4o_.js";import"./bell-D0vTOuek.js";import"./check-check-2zE5w8gN.js";import"./formatDistanceToNow-DExfhm_y.js";import"./en-US-5rFTtd83.js";import"./LanguageSwitcher-DHMsopEY.js";import"./dropdown-menu-BeZf8kFV.js";import"./chevron-right-BdUdHP_I.js";import"./check-v4vwqlB-.js";import"./circle-pSWMGBM_.js";import"./languages-DOZFgZ9Q.js";import"./message-circle-BYe5rrWz.js";import"./activity-CfnIewRD.js";import"./arrow-down-CIVFAk8G.js";import"./arrow-left-BmX2tYO6.js";import"./arrow-right-left-DF8EQ874.js";import"./arrow-right-ksEPM703.js";import"./banknote-CdW1Jv9F.js";import"./bed-B88pYHvh.js";import"./list-ordered-hB6RbGtG.js";import"./book-open-check-DYZCLGLv.js";import"./book-open-D0Y1dKqG.js";import"./brain-BohJitgU.js";import"./building-DasY5zOg.js";import"./calculator-ByooPTmb.js";import"./calendar-D4RFJDPY.js";import"./car-D3b4R55M.js";import"./landmark-BwZdzl4J.js";import"./chart-no-axes-column-increasing-C6Bh1bTG.js";import"./chart-pie-7jztI-xg.js";import"./chevron-down-Bm2Y15mk.js";import"./chevron-left-DCDYd6CA.js";import"./chevron-up-DVBQQKr7.js";import"./circle-check-big-CQmmVCDK.js";import"./circle-check-CLkepror.js";import"./message-square-text-W-2xUYbe.js";import"./circle-help-Cpt-rFJF.js";import"./circle-x-CMEjdGNX.js";import"./clipboard-check-Cvc1fMv5.js";import"./clipboard-list-FvLR_NG8.js";import"./clipboard-viWVwQwk.js";import"./clock-BmPJ466V.js";import"./copy-BEDU18te.js";import"./database-kv95WpLa.js";import"./dollar-sign-D0iC4HrG.js";import"./download-B3iahoQg.js";import"./zoom-out-zrJfLdu9.js";import"./external-link-BIGsQXrz.js";import"./twitter-BaxQU1X8.js";import"./file-chart-column-increasing-DEN9Rsed.js";import"./file-check-cM7E4NaC.js";import"./file-spreadsheet-ZK-q7Zgc.js";import"./filter-Bs-PYMIY.js";import"./folder-open-DFmVGiUq.js";import"./tree-pine-CouWAS-6.js";import"./video-DaS8rS9K.js";import"./hammer-691LkvTd.js";import"./heart-Dv9Odr8c.js";import"./hotel-C1w3GOsr.js";import"./house-5R4LHGOP.js";import"./image-plus-xT5L-tET.js";import"./image-CayqqQKD.js";import"./infinity-wq20aEtI.js";import"./key-round-Dh3U7Shh.js";import"./pen-tool-_n2hBO7N.js";import"./keyboard-CSqz3mRU.js";import"./layers-D0VRol72.js";import"./lightbulb-DlRuWc33.js";import"./list-checks-coQAK2sr.js";import"./list-BJoWfKXY.js";import"./lock-B0M9hAnN.js";import"./map-pinned-B-fJbXg-.js";import"./map-C8rxfYCS.js";import"./maximize-2-CZGGiq67.js";import"./maximize-DHDDLx00.js";import"./menu-DuKtMQlr.js";import"./minus-04ztrfH_.js";import"./mouse-pointer-click-Bc_ivnf4.js";import"./mouse-CUCnDlYq.js";import"./navigation-mR6QetLo.js";import"./pencil-d1bR18nI.js";import"./ruler-BoWqmUga.js";import"./phone-I9m-09C5.js";import"./plus-CYnN_kFu.js";import"./printer-DjW2gpx9.js";import"./refresh-ccw-BR8hKK-Q.js";
2import"./rocket-DxjHbFsp.js";import"./rotate-ccw-CE2HFYnH.js";import"./rotate-cw-n6J_8Piu.js";import"./route-Df-61sSI.js";import"./save-DF6x0jpO.js";import"./scale-CZXGlUhc.js";import"./search-Dx_o7OfG.js";import"./send-Blf9Z7mq.js";import"./share-2-sKHj2vjO.js";import"./square-plus-Dp1sCmj5.js";import"./skip-forward-eFm9X_4U.js";import"./smartphone-CBjqwShe.js";import"./square-check-big-DF0dFzei.js";import"./square-pen-Bg7uj701.js";import"./square-MsVDU0g-.js";import"./star-DlIZz9Im.js";import"./trash-2-DAqLpVlV.js";import"./trending-down-COltpy2W.js";import"./trending-up-CRE5UWZg.js";import"./upload-55xlfOPi.js";import"./user-check-XkucE5f8.js";import"./user-DV5oCLCs.js";import"./volume-2-DTT7l7C1.js";import"./volume-x-BBMkTIRp.js";import"./wallet-_cnDvlQk.js";import"./workflow-Bfwpj-zP.js";import"./zap-BKGpOGd1.js";import"./useIsRTL-D_a81cVb.js";import"./useOrganization-msM7McOc.js";const I=(a,p)=>{const m=(Date.now()-p.getTime())/36e5;return m<24?"#3b82f6":m<168?"#8b5cf6":"#6b7280"},H=a=>Math.min(1.5,Math.max(.3,Math.log10(a+1)*.5+.3)),M=()=>{const[a,p]=r.useState([]),[m,l]=r.useState([]),[f,d]=r.useState(!0),[v,g]=r.useState(null),[w,c]=r.useState({totalLocations:0,activeNow:0,countries:0}),j=r.useCallback(async()=>{try{const{data:o,error:s}=await b.from("globe_location_cache").select("*").order("visitor_count",{ascending:!1});if(s)throw console.error("Error fetching location cache:",s),s;return(o||[]).map(e=>({id:e.id,lat:e.latitude,lng:e.longitude,city:e.city,country:e.country,visitorCount:e.visitor_count,isActive:!1,lastSeen:new Date(e.last_seen),size:H(e.visitor_count),color:I(!1,new Date(e.last_seen))}))}catch(o){return console.error("Error fetching historical data:",o),[]}},[]),n=r.useCallback(async()=>{try{const{data:o,error:s}=await b.from("globe_visitor_points").select("*").eq("is_active",!0);if(s)throw console.error("Error fetching active visitors:",s),s;return(o||[]).map(e=>({id:e.id,lat:e.latitude,lng:e.longitude,city:e.city,country:e.country||"Unknown",visitorCount:1,isActive:!0,lastSeen:new Date,size:.6,color:"#22c55e"}))}catch(o){return console.error("Error fetching active visitors:",o),[]}},[]),u=r.useCallback(async()=>{d(!0),g(null);try{const[o,s]=await Promise.all([j(),n()]);p(o),l(s);const i=new Set(o.map(e=>e.country));c({totalLocations:o.length,activeNow:s.length,countries:i.size})}catch(o){g("Failed to load globe data"),console.error(o)}finally{d(!1)}},[j,n]);return r.useEffect(()=>{u()},[u]),r.useEffect(()=>{const o=b.channel("globe-realtime").on("postgres_changes",{event:"*",schema:"public",table:"globe_visitor_points"},s=>{if(console.log("Globe realtime update:",s),s.eventType==="INSERT"){const i=s.new;i.is_active&&(l(e=>[...e,{id:i.id,lat:i.latitude,lng:i.longitude,city:i.city,country:i.country||"Unknown",visitorCount:1,isActive:!0,lastSeen:new Date,size:.6,color:"#22c55e"}]),c(e=>({...e,activeNow:e.activeNow+1})))}else if(s.eventType==="UPDATE"){const i=s.new;i.is_active||(l(e=>e.filter(P=>P.id!==i.id)),c(e=>({...e,activeNow:Math.max(0,e.activeNow-1)})))}else if(s.eventType==="DELETE"){const i=s.old.id;l(e=>e.filter(P=>P.id!==i))}}).subscribe();return()=>{b.removeChannel(o)}},[]),{points:[...a,...m],historicalPoints:a,activePoints:m,isLoading:f,error:v,stats:w,refetch:u}},$=r.lazy(()=>E(()=>import("./react-globe.gl-DqAfY7sq.js"),__vite__mapDeps([0,1,2,3]))),ki=()=>{const a=r.useRef(null),{points:p,activePoints:m,isLoading:l,error:f,stats:d,refetch:v}=M(),[g,w]=r.useState(!1),[c,j]=r.useState(!0),[n,u]=r.useState(null);r.useEffect(()=>{if(a.current){const i=a.current.controls();i&&(i.autoRotate=c,i.autoRotateSpeed=.5,i.enableZoom=!0,i.minDistance=150,i.maxDistance=500)}},[c]),r.useEffect(()=>{a.current&&a.current.pointOfView({lat:30,lng:0,altitude:2.5},1e3)},[]);const y=g?m:p,o=r.useCallback(i=>{const e=i;u(e),a.current&&a.current.pointOfView({lat:e.lat,lng:e.lng,altitude:1.5},1e3)},[]),s=r.useCallback(i=>{i?document.body.style.cursor="pointer":document.body.style.cursor="default"},[]);return f?t.jsx(x,{className:"w-full",children:t.jsxs(h,{className:"flex flex-col items-center justify-center py-12",children:[t.jsx("p",{className:"text-destructive mb-4",children:f}),t.jsxs(N,{onClick:v,variant:"outline",children:[t.jsx(k,{className:"mr-2 h-4 w-4"}),"Retry"]})]})}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsx(x,{children:t.jsxs(h,{className:"flex items-center gap-3 py-4",children:[t.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:t.jsx(R,{className:"h-5 w-5 text-primary"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Locations"}),t.jsx("p",{className:"text-2xl font-bold",children:d.totalLocations})]})]})}),t.jsx(x,{children:t.jsxs(h,{className:"flex items-center gap-3 py-4",children:[t.jsx("div",{className:"p-2 bg-green-500/10 rounded-lg",children:t.jsx(T,{className:"h-5 w-5 text-green-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Now"}),t.jsx("p",{className:"text-2xl font-bold text-green-500",children:d.activeNow})]})]})}),t.jsx(x,{children:t.jsxs(h,{className:"flex items-center gap-3 py-4",children:[t.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:t.jsx(U,{className:"h-5 w-5 text-blue-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Countries"}),t.jsx("p",{className:"text-2xl font-bold",children:d.countries})]})]})}),t.jsx(x,{children:t.jsxs(h,{className:"flex items-center gap-3 py-4",children:[t.jsx("div",{className:"p-2 bg-purple-500/10 rounded-lg",children:t.jsx(C,{className:"h-5 w-5 text-purple-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Points"}),t.jsx("p",{className:"text-2xl font-bold",children:y.length})]})]})})]}),t.jsxs(x,{className:"relative overflow-hidden",children:[t.jsxs(S,{className:"flex flex-row items-center justify-between pb-2",children:[t.jsxs(L,{className:"flex items-center gap-2",children:[t.jsx(C,{className:"h-5 w-5"}),"User Globe"]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_,{id:"active-only",checked:g,onCheckedChange:w}),t.jsx(A,{htmlFor:"active-only",className:"text-sm",children:"Active only"})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(N,{variant:"outline",size:"sm",onClick:()=>j(!c),children:c?t.jsx(V,{className:"h-4 w-4"}):t.jsx(G,{className:"h-4 w-4"})})}),t.jsx(N,{variant:"outline",size:"sm",onClick:v,disabled:l,children:t.jsx(k,{className:`h-4 w-4 ${l?"animate-spin":""}`})})]})]}),t.jsx(h,{className:"p-0",children:t.jsxs("div",{className:"relative h-[600px] w-full bg-background/50",children:[l&&!p.length?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx(z,{className:"h-[400px] w-[400px] rounded-full"})}):t.jsx(r.Suspense,{fallback:t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsxs("div",{className:"text-center",children:[t.jsx(C,{className:"h-12 w-12 animate-pulse mx-auto mb-2"}),t.jsx("p",{children:"Loading globe..."})]})}),children:t.jsx($,{ref:a,globeImageUrl:"//unpkg.com/three-globe/example/img/earth-blue-marble.jpg",bumpImageUrl:"//unpkg.com/three-globe/example/img/earth-topology.png",backgroundImageUrl:"//unpkg.com/three-globe/example/img/night-sky.png",pointsData:y,pointLat:i=>i.lat,pointLng:i=>i.lng,pointAltitude:i=>i.size*.01,pointRadius:i=>i.size,pointColor:i=>i.color,pointLabel:i=>{const e=i;return` 3 <div style="background: rgba(0,0,0,0.8); padding: 8px 12px; border-radius: 8px; color: white; font-size: 12px;"> 4 <div style="font-weight: bold;">${e.city||"Unknown"}, ${e.country}</div> 5 <div>Visitors: ${e.visitorCount}</div> 6 <div style="color: ${e.isActive?"#22c55e":"#6b7280"}"> 7 ${e.isActive?"ð¢ Active now":"Last seen: "+e.lastSeen.toLocaleDateString()} 8 </div> 9 </div> 10 `},onPointClick:o,onPointHover:s,width:typeof window<"u"?window.innerWidth-400:800,height:600,atmosphereColor:"#3b82f6",atmosphereAltitude:.25})}),t.jsxs("div",{className:"absolute bottom-4 left-4 bg-background/90 backdrop-blur-sm p-3 rounded-lg border shadow-lg",children:[t.jsx("p",{className:"text-xs font-semibold mb-2",children:"Legend"}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),t.jsx("span",{className:"text-xs",children:"Active now"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),t.jsx("span",{className:"text-xs",children:"Last 24 hours"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-purple-500"}),t.jsx("span",{className:"text-xs",children:"Last week"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-500"}),t.jsx("span",{className:"text-xs",children:"Historical"})]})]})]}),n&&t.jsxs("div",{className:"absolute top-4 right-4 bg-background/90 backdrop-blur-sm p-4 rounded-lg border shadow-lg max-w-xs",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"font-semibold",children:n.city||"Unknown City"}),t.jsx(D,{variant:n.isActive?"default":"secondary",children:n.isActive?"Active":"Historical"})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n.country}),t.jsxs("div",{className:"mt-2 text-sm",children:[t.jsxs("p",{children:["Visitors: ",n.visitorCount]}
10),t.jsxs("p",{children:["Last seen: ",n.lastSeen.toLocaleString()]})]}),t.jsx(N,{variant:"ghost",size:"sm",className:"mt-2 w-full",onClick:()=>u(null),children:"Close"})]})]})})]})]})};export{ki 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.