PageSourceSearch

https://upcode.com/assets/AdminAnalytics-DUPnV8aD.js

js upcode.com collected 2026-10-02 05:46:45 UTC 34,301 bytes, 6 lines download raw bytes

1import{j as e,E as Be,F as ns}from"./vendor-ui-CNxyfBKX.js";import{r as c,L as ls}from"./vendor-react-CyCAQrU1.js";import{b as cs,X as os,O as ds,ae as y,W as Se,S as ne,a5 as _e,B as z,e as hs,a2 as ms}from"./index-3hASqYY4.js";import{C as d}from"./card-OEjrJOgG.js";import{L as Ce}from"./label-AIPo0Go_.js";import{T as xs,a as us,b as V}from"./tabs-JFLdNNAn.js";import{L as D}from"./loader-circle-dXlbm01G.js";import{S as Ae}from"./sparkles-B4lZfioV.js";import{G as ps}from"./globe-rp2a7vzQ.js";import{L as fs}from"./link-B41__ALT.js";import{L as gs}from"./log-out-Blh4Vj53.js";import{E as Te}from"./eye-BHWGA3cj.js";import{U as ws}from"./users-_xCTUJaz.js";import{T as bs}from"./trending-up-BmKC9Nzm.js";import{F as js}from"./file-text-D4d8ypuX.js";import{A as vs}from"./activity-C8PQPL9j.js";import{R as P,i as Ns,a as Ee,X as Re,Y as Le,T as I,j as ys,B as ks,b as Ss,k as le,l as ce,m as oe,L as de}from"./vendor-charts-pU0kIp3O.js";import"./vendor-3d-DEv8pFk_.js";import"./vendor-query-TL9NOarz.js";import"./vendor-supabase-ClCNGvGL.js";import"./vendor-animation-MSaj4l-p.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const _s=cs("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]),Cs={exit_intent:"Exit Intent",timer_30s:"30s Timer",scroll_60:"Scroll 60%",inline_section:"Inline Section",inline_home:"Home Inline",inline_blog:"Blog Inline",sticky_cta:"Sticky CTA"},Pe=i=>Cs[i]||i,As=({rangeDays:i})=>{const[o,u]=c.useState([]),[w,p]=c.useState([]),[j,S]=c.useState(!0);c.useEffect(()=>{(async()=>{S(!0);const l=new Date(Date.now()-i*24*60*60*1e3).toISOString(),[{data:x},{data:N}]=await Promise.all([y.from("lead_captures").select("id,email,source,page_path,created_at").gte("created_at",l).order("created_at",{ascending:!1}).limit(1e3),y.from("conversion_events").select("id,event_type,source,page_path,created_at").gte("created_at",l).order("created_at",{ascending:!1}).limit(5e3)]);u(x||[]),p(N||[]),S(!1)})()},[i]);const v=c.useMemo(()=>{const h=w.filter(m=>m.event_type==="lead_popup_shown").length,l=w.filter(m=>m.event_type==="lead_popup_dismissed").length,x=w.filter(m=>m.event_type==="lead_popup_submitted").length,N=o.length,O=h?x/h*100:0,A={};o.forEach(m=>{A[m.source]=(A[m.source]||0)+1});const k=Object.entries(A).map(([m,b])=>({source:m,count:b})).sort((m,b)=>b.count-m.count),R={};o.forEach(m=>{const b=m.page_path||"—";R[b]=(R[b]||0)+1});const T=Object.entries(R).map(([m,b])=>({page:m,count:b})).sort((m,b)=>b.count-m.count).slice(0,10);return{shown:h,dismissed:l,submitted:x,totalLeads:N,conversionRate:O,sourceRows:k,pageRows:T}},[o,w]);return j?e.jsx(d,{className:"p-6 bg-white/5 border-white/10 flex items-center justify-center",children:e.jsx(D,{className:"w-6 h-6 animate-spin text-white/60"})}):e.jsxs(d,{className:"p-6 bg-white/5 border-white/10 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"w-5 h-5 text-purple-400"}),e.jsx("h2",{className:"text-lg font-bold uppercase tracking-wide",children:"Lead Capture Funnel"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"rounded-lg bg-white/5 border border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-xs uppercase tracking-wide mb-1",children:[e.jsx(_s,{className:"w-4 h-4"})," Popup Shown"]}),e.jsx("div",{className:"text-2xl font-bold",children:v.shown})]}),e.jsxs("div",{className:"rounded-lg bg-white/5 border border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-xs uppercase tracking-wide mb-1",children:[e.jsx(os,{className:"w-4 h-4"})," Dismissed"]}),e.jsx("div",{className:"text-2xl font-bold",children:v.dismissed})]}),e.jsxs("div",{className:"rounded-lg bg-white/5 border border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-xs uppercase tracking-wide mb-1",children:[e.jsx(ds,{className:"w-4 h-4"})," Total Leads"]}),e.jsx("div",{className:"text-2xl font-bold text-purple-300",children:v.totalLeads})]}),e.jsxs("div",{className:"rounded-lg bg-white/5 border border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-xs uppercase tracking-wide mb-1",children:[e.jsx(Ae,{className:"w-4 h-4"})," Popup Conv. Rate"]}),e.jsxs("div",{className:"text-2xl font-bold",children:[v.conversionRate.toFixed(1),"%"]})]})]}),v.totalLeads===0?e.jsx("p",{className:"text-white/50 text-sm text-center py-6",children:"No leads captured yet. The popup, inline section, and sticky CTA will start collecting emails as visitors interact with the site."}):e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white/70 uppercase tracking-wide mb-3",children:"Leads by Source"}),e.jsx("div",{className:"space-y-1.5",children:v.sourceRows.map(({source:h,count:l})=>e.jsxs("div",{className:"flex items-center justify-between text-sm py-1.5 px-3 bg-white/5 rounded",children:[e.jsx("span",{className:"text-white/80",children:Pe(h)}),e.jsx("span",{className:"font-bold",children:l})]},h))})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white/70 uppercase tracking-wide mb-3",children:"Top Convert
6ing Pages"}),e.jsx("div",{className:"space-y-1.5",children:v.pageRows.map(({page:h,count:l})=>e.jsxs("div",{className:"flex items-center justify-between text-sm py-1.5 px-3 bg-white/5 rounded gap-3",children:[e.jsx("span",{className:"text-white/80 truncate",children:h}),e.jsx("span",{className:"font-bold shrink-0",children:l})]},h))})]})]}),o.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-white/70 uppercase tracking-wide mb-3",children:"Recent Leads"}),e.jsx("div",{className:"rounded-lg border border-white/10 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-white/5 text-white/60 text-xs uppercase",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left py-2 px-3",children:"Email"}),e.jsx("th",{className:"text-left py-2 px-3 hidden sm:table-cell",children:"Source"}),e.jsx("th",{className:"text-left py-2 px-3 hidden md:table-cell",children:"Page"}),e.jsx("th",{className:"text-right py-2 px-3",children:"When"})]})}),e.jsx("tbody",{children:o.slice(0,20).map(h=>e.jsxs("tr",{className:"border-t border-white/5",children:[e.jsx("td",{className:"py-2 px-3 text-white/90 truncate max-w-[180px]",children:h.email}),e.jsx("td",{className:"py-2 px-3 text-white/70 hidden sm:table-cell",children:Pe(h.source)}),e.jsx("td",{className:"py-2 px-3 text-white/60 hidden md:table-cell truncate max-w-[200px]",children:h.page_path||"—"}),e.jsx("td",{className:"py-2 px-3 text-right text-white/50 text-xs",children:new Date(h.created_at).toLocaleString()})]},h.id))})]})})]})]})},Ts={direct:"Direct / Bookmark / Typed",organic:"Organic Search (Google/Bing/etc.)",social:"Social Network",ai:"AI Assistant (ChatGPT/Perplexity/etc.)",email:"Email Campaign",paid:"Paid Ads",referral:"Referral Site",internal:"Internal (own site)",chat_app:"Chat App (Slack/Discord/Notion)",developer:"Developer Site (GitHub/etc.)",publication:"Publication (Substack/Medium/HN)",unknown_app:"Mobile App (likely IG/TikTok/Mail — referrer stripped)",offline:"Offline / QR / Print"};function Es(i){if(!i)return"(no referrer)";
6try{return new URL(i).hostname.replace(/^www\./,"")}catch{return"(no referrer)"}}function Rs({rows:i}){const{categories:o,referrers:u,totalVisitors:w}=c.useMemo(()=>{const p={},j={};i.forEach(l=>{const x=l.source_category||"direct";p[x]||(p[x]=new Set),p[x].add(l.visitor_id);const N=Es(l.referrer);j[N]||(j[N]={visitors:new Set,sample:l.referrer}),j[N].visitors.add(l.visitor_id)});const S=Object.entries(p).map(([l,x])=>({key:l,label:Ts[l]||l,visitors:x.size})).sort((l,x)=>x.visitors-l.visitors),v=Object.entries(j).map(([l,x])=>({host:l,visitors:x.visitors.size,sample:x.sample})).sort((l,x)=>x.visitors-l.visitors).slice(0,30),h=new Set(i.map(l=>l.visitor_id)).size;return{categories:S,referrers:v,totalVisitors:h}},[i]);return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-1 uppercase tracking-wide flex items-center gap-2",children:[e.jsx(ps,{className:"w-5 h-5"})," How Visitors Got Here"]}),e.jsx("p",{className:"text-[11px] text-white/40 mb-4",children:"By unique visitor — most reliable signal of source."}),e.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:o.map(p=>{const j=w?p.visitors/w*100:0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-white/80",children:p.label}),e.jsxs("span",{className:"text-white/60",children:[p.visitors," ",e.jsxs("span",{className:"text-white/40 text-xs",children:["(",j.toFixed(0),"%)"]})]})]}),e.jsx("div",{className:"h-1.5 bg-white/5 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-purple-500",style:{width:`${j}%`}})})]},p.key)})})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-1 uppercase tracking-wide",children:"Actual Referrer URLs"}),e.jsx("p",{className:"text-[11px] text-white/40 mb-4",children:"The real domains sending traffic. Hover for full URL."}),e.jsx("div",{className:"space-y-1.5 max-h-96 overflow-y-auto",children:u.map(p=>e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-white/5 last:border-0",title:p.sample||"",children:[e.jsx("span",{className:"text-sm text-white/80 truncate flex-1 pr-2",children:p.host}),e.jsx("span",{className:"text-sm font-bold text-white/90 shrink-0",children:p.visitors})]},p.host))})]})]})}const Me=c.forwardRef(({className:i,...o},u)=>e.jsx(Be,{className:Se("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",i),...o,ref:u,children:e.jsx(ns,{className:Se("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Me.displayName=Be.displayName;const Ie={"24h":1,"7d":7,"30d":30,"90d":90},F=["#a855f7","#8b5cf6","#7c3aed","#6366f1","#3b82f6","#06b6d4","#10b981"],Ls={direct:"Direct",organic:"Organic Search",social:"Social",ai:"AI Assistants",email:"Email",referral:"Referral",internal:"Internal"},Ps={US:"United States",CA:"Canada",GB:"United Kingdom",AU:"Australia",DE:"Germany",FR:"France",IN:"India",BR:"Brazil",MX:"Mexico",JP:"Japan",CN:"China",IT:"Italy",ES:"Spain",NL:"Netherlands",SE:"Sweden",NO:"Norway",DK:"Denmark",FI:"Finland",PL:"Poland",IE:"Ireland",PT:"Portugal",BE:"Belgium",CH:"Switzerland",AT:"Austria",NZ:"New Zealand",SG:"Singapore",KR:"South Korea",AE:"UAE",ZA:"South Africa",AR:"Argentina",CL:"Chile",CO:"Colombia",PH:"Philippines",ID:"Indonesia",TH:"Thailand",VN:"Vietnam",TR:"Turkey",IL:"Israel",SA:"Saudi Arabia"};function he(i){return i==="/"||i===""?"/ (Home)":i}function De(i){if(!i)return"Direct";try{const o=new URL(i);return o.hostname.includes("upcode.com")||o.hostname.includes("launch-replicator")?"Internal":o.hostname.replace(/^www\./,"")}catch{return"Direct"}}
6function me(i){if(!i||i<1e3)return"0s";const o=Math.round(i/1e3);if(o<60)return`${o}s`;const u=Math.floor(o/60),w=o%60;return u<60?`${u}m ${w}s`:`${Math.floor(u/60)}h ${u%60}m`}function Oe(i){return i?Ps[i.toUpperCase()]||i.toUpperCase():"Unknown"}const st=()=>{const[i,o]=c.useState(null),[u,w]=c.useState(null),[p,j]=c.useState(!0),[S,v]=c.useState(""),[h,l]=c.useState(""),[x,N]=c.useState(null),[O,A]=c.useState(!1),[k,R]=c.useState("7d"),[T,m]=c.useState(null),[b,xe]=c.useState(!1),[ue,$e]=c.useState({}),[H,Ue]=c.useState(!1);c.useEffect(()=>{const{data:a}=y.auth.onAuthStateChange((n,f)=>{o((f==null?void 0:f.user)??null)});return y.auth.getSession().then(({data:{session:n}})=>{o((n==null?void 0:n.user)??null),j(!1)}),()=>a.subscription.unsubscribe()},[]),c.useEffect(()=>{if(!i){w(null);return}y.from("admin_users").select("id").eq("user_id",i.id).maybeSingle().then(({data:a})=>w(!!a))},[i]),c.useEffect(()=>{u&&y.from("blog_posts").select("slug,title").then(({data:a})=>{if(!a)return;const n={};a.forEach(f=>n[`/blog/${f.slug}`]=f.title),$e(n)})},[u]);const ze=async()=>{xe(!0);const a=new Date(Date.now()-Ie[k]*24*60*60*1e3).toISOString(),{data:n,error:f}=await y.from("page_views").select("id,path,referrer,visitor_id,session_id,device_type,browser,country,country_code,region,city,source_category,utm_source,utm_medium,utm_campaign,time_on_page_ms,created_at").gte("created_at",a).order("created_at",{ascending:!1}).limit(5e4);f||m(n),xe(!1)};c.useEffect(()=>{u&&ze()},[u,k]);const B=c.useMemo(()=>T?H?T:T.filter(a=>{if(a.source_category==="internal")return!1;const n=a.referrer||"";return!(/lovable\.dev|lovableproject\.com|lovable\.app/i.test(n)||a.path&&/forceHideBadge/i.test(a.path))}):null,[T,H]),r=c.useMemo(()=>{var Ne;if(!B)return null;const a=B,n=new Set(a.map(s=>s.visitor_id)).size,f=new Set(a.map(s=>s.session_id)).size,M=a.length,_={};a.forEach(s=>{const t=new Date(s.created_at).getTime();_[s.session_id]||(_[s.session_id]={times:[],visitor:s.visitor_id,views:[]}),_[s.session_id].times.push(t),_[s.session_id].views.push(s)});let fe=0,G=0,ge=0;const K={},q={};Object.values(_).forEach(s=>{var ye,ke;s.times.sort((ie,re)=>ie-re),s.views.sort((ie,re)=>new Date(ie.created_at).getTime()-new Date(re.created_at).getTime());const t=s.times[s.times.length-1]-s.times[0];s.times.length>1?(fe+=t,G+=1):ge+=1;const g=(ye=s.views[0])==null?void 0:ye.path,ae=(ke=s.views[s.views.length-1])==null?void 0:ke.path;g&&(K[g]=(K[g]||0)+1),ae&&(q[ae]=(q[ae]||0)+1)});const Fe=G?fe/G:0,He=f?ge/f*100:0,Ge=k==="24h",W={};a.forEach(s=>{const t=new Date(s.created_at),g=Ge?`${t.getMonth()+1}/${t.getDate()} ${String(t.getHours()).padStart(2,"0")}:00`:`${t.getMonth()+1}/${t.getDate()}`;W[g]=(W[g]||0)+1});const Ke=Object.entries(W).map(([s,t])=>({name:s,views:t})).reverse(),C={};a.forEach(s=>{const t=s.path;C[t]||(C[t]={views:0,visitors:new Set,totalTime:0,timeCount:0}),C[t].views+=1,C[t].visitors.add(s.visitor_id),s.time_on_page_ms&&s.time_on_page_ms>0&&(C[t].totalTime+=s.time_on_page_ms,C[t].timeCount+=1)});const we=Object.entries(C).map(([s,t])=>({path:s,views:t.views,visitors:t.visitors.size,avgTime:t.timeCount?t.totalTime/t.timeCount:0,title:ue[s]||null,isBlog:s.startsWith("/blog/")&&s!=="/blog"})).sort((s,t)=>t.views-s.views),qe=we.filter(s=>s.isBlog).slice(0,20),We=Object.entries(K).map(([s,t])=>({path:s,count:t})).sort((s,t)=>t.count-s.count).slice(0,10),Ye=Object.entries(q).map(([s,t])=>({path:s,count:t})).sort((s,t)=>t.count-s.count).slice(0,10),Y={};a.forEach(s=>{const t=De(s.referrer);Y[t]=(Y[t]||0)+1});const Xe=Object.entries(Y).map(([s,t])=>({name:s,value:t})).sort((s,t)=>t.value-s.value),X={};a.forEach(s=>{let t=s.source_category;if(!t){const g=De(s.referrer);g==="Direct"?t="direct":g==="Internal"?t="internal":t="referral"}X[t]=(X[t]||0)+1});const Ze=Object.entries(X).map(([s,t])=>({name:Ls[s]||s,value:t,key:s})).sort((s,t)=>t.value-s.value),Z={},$={};a.forEach(s=>{const t=(s.country_code||s.country||"").toUpperCase()||"??";if(Z[t]=(Z[t]||0)+1,s.city){const g=`${s.city}|${t}`;$[g]||($[g]={count:0,country:t}),$[g].count+=1}});const be=Object.entries(Z).map(([s,t])=>({code:s,name:Oe(s),value:t})).sort((s,t)=>t.value-s.value),Je=Object.entries($).map(([s,t])=>({city:s.split("|")[0],country:Oe(t.country),count:t.count})).sort((s,t)=>t.count-s.count).slice(0,25),Qe=be.filter(s=>s.code!=="??"),es=((Ne=be.find(s=>
6s.code==="??"))==null?void 0:Ne.value)||0,J={};a.forEach(s=>{if(!s.utm_source&&!s.utm_campaign)return;const t=`${s.utm_source||"—"} / ${s.utm_medium||"—"} / ${s.utm_campaign||"—"}`;J[t]=(J[t]||0)+1});const ss=Object.entries(J).map(([s,t])=>({name:s,value:t})).sort((s,t)=>t.value-s.value),Q={};a.forEach(s=>{const t=new Date(s.created_at).getTime();(!Q[s.visitor_id]||t<Q[s.visitor_id])&&(Q[s.visitor_id]=t)});const U={};a.forEach(s=>{U[s.visitor_id]||(U[s.visitor_id]=new Set),U[s.visitor_id].add(s.session_id)});let je=0,ve=0;Object.values(U).forEach(s=>{s.size>1?ve+=1:je+=1});const ts=[{name:"New",value:je},{name:"Returning",value:ve}],ee=Array.from({length:7},()=>Array(24).fill(0));a.forEach(s=>{const t=new Date(s.created_at);ee[t.getDay()][t.getHours()]+=1});const as=Math.max(1,...ee.flat()),se={};a.forEach(s=>{const t=s.device_type||"unknown";se[t]=(se[t]||0)+1});const is=Object.entries(se).map(([s,t])=>({name:s,value:t})),te={};a.forEach(s=>{const t=s.browser||"Other";te[t]=(te[t]||0)+1});const rs=Object.entries(te).map(([s,t])=>({name:s,value:t})).sort((s,t)=>t.value-s.value);return{visitors:n,sessions:f,pageViews:M,avgSessionDuration:Fe,bounceRate:He,timeseries:Ke,topPages:we.slice(0,30),topBlogPosts:qe,landingPages:We,exitPages:Ye,referrers:Xe.slice(0,15),sources:Ze,countries:Qe.slice(0,12),unknownCountryCount:es,cities:Je,utmRows:ss.slice(0,20),newVsReturning:ts,heatmap:ee,heatmapMax:as,devices:is,browsers:rs}},[B,k,ue]),Ve=async a=>{a.preventDefault(),A(!0),N(null);const{error:n}=await y.auth.signInWithPassword({email:S,password:h});n&&N(n.message),A(!1)},pe=async()=>{await y.auth.signOut(),m(null)};if(p)return e.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:e.jsx(D,{className:"w-8 h-8 animate-spin text-white"})});if(!i)return e.jsxs("div",{className:"min-h-screen bg-black text-white flex items-center justify-center px-4",children:[e.jsx(ne,{title:"Admin Analytics — Upcode",description:"Internal dashboard",noIndex:!0}),e.jsxs(d,{className:"w-full max-w-md p-8 bg-white/5 border-white/10 backdrop-blur",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2 uppercase tracking-wide",children:"Admin Sign In"}),e.jsx("p",{className:"text-sm text-white/60 mb-6",children:"Authorized accounts only."}),e.jsxs("form",{onSubmit:Ve,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(Ce,{htmlFor:"email",className:"text-white/80",children:"Email"}),e.jsx(_e,{id:"email",type:"email",value:S,onChange:a=>v(a.target.value),required:!0,className:"bg-black/40 border-white/10 text-white"})]}),e.jsxs("div",{children:[e.jsx(Ce,{htmlFor:"password",className:"text-white/80",children:"Password"}),e.jsx(_e,{id:"password",type:"password",value:h,onChange:a=>l(a.target.value),required:!0,className:"bg-black/40 border-white/10 text-white"})]}),x&&e.jsx("p",{className:"text-red-400 text-sm",children:x}),e.jsx(z,{type:"submit",disabled:O,className:"w-full bg-purple-600 hover:bg-purple-700",children:O?e.jsx(D,{className:"w-4 h-4 animate-spin"}):"Sign In"})]})]})]});if(u===!1)return e.jsxs("div",{className:"min-h-screen bg-black text-white flex items-center justify-center px-4",children:[e.jsx(ne,{title:"Admin Analytics — Upcode",description:"Internal dashboard",noIndex:!0}),e.jsxs(d,{className:"w-full max-w-md p-8 bg-white/5 border-white/10 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Access Denied"}),e.jsxs("p",{className:"text-white/60 mb-6",children:["Your account (",i.email,") is not authorized."]}),e.jsx(z,{onClick:pe,variant:"outline",className:"border-white/20 text-white",children:"Sign Out"})]})]});if(u===null)return e.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:e.jsx(D,{className:"w-8 h-8 animate-spin text-white"})});const L={background:"#0a0a0a",border:"1px solid #ffffff20",borderRadius:8};return e.jsxs("div",{className:"min-h-screen bg-black text-white",children:[e.jsx(ne,{title:"Admin Analytics — Upcode",description:"Internal traffic dashboard",noIndex:!0}),e.jsx("div",{className:"border-b border-white/10 bg-black/80 backdrop-blur sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 py-4 flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold uppercase tracking-wide",children:"Traffic Analytics"}),e.jsx("p",{className:"text-xs text-white/50",children:i.email})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-white/70 mr-2",children:[e.jsx(Me,{checked:H,onCheckedChange:Ue}),"Show internal"]}
6),e.jsx(xs,{value:k,onValueChange:a=>R(a),children:e.jsxs(us,{className:"bg-white/5 border border-white/10",children:[e.jsx(V,{value:"24h",children:"24h"}),e.jsx(V,{value:"7d",children:"7d"}),e.jsx(V,{value:"30d",children:"30d"}),e.jsx(V,{value:"90d",children:"90d"})]})}),e.jsx(ls,{to:"/admin/utm",children:e.jsxs(z,{size:"sm",variant:"outline",className:"border-white/20 text-white hover:bg-white/10",children:[e.jsx(fs,{className:"w-4 h-4 mr-1"})," UTM Builder"]})}),e.jsxs(z,{size:"sm",variant:"outline",onClick:pe,className:"border-white/20 text-white hover:bg-white/10",children:[e.jsx(gs,{className:"w-4 h-4 mr-1"})," Sign out"]})]})]})}),e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 py-8",children:b&&!r?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(D,{className:"w-8 h-8 animate-spin text-white/60"})}):!r||r.pageViews===0?e.jsxs(d,{className:"p-12 text-center bg-white/5 border-white/10",children:[e.jsx(Te,{className:"w-10 h-10 text-white/40 mx-auto mb-3"}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:"No traffic recorded yet"}),e.jsx("p",{className:"text-white/60",children:"Tracking is now live. Page views will start appearing as visitors browse the site."})]}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:[e.jsx(E,{icon:e.jsx(Te,{className:"w-5 h-5"}),label:"Page Views",value:r.pageViews}),e.jsx(E,{icon:e.jsx(ws,{className:"w-5 h-5"}),label:"Unique Visitors",value:r.visitors}),e.jsx(E,{icon:e.jsx(bs,{className:"w-5 h-5"}),label:"Sessions",value:r.sessions}),e.jsx(E,{icon:e.jsx(js,{className:"w-5 h-5"}),label:"Pages / Visitor",value:r.visitors?(r.pageViews/r.visitors).toFixed(1):"0"}),e.jsx(E,{icon:e.jsx(hs,{className:"w-5 h-5"}),label:"Avg. Session",value:me(r.avgSessionDuration)}),e.jsx(E,{icon:e.jsx(vs,{className:"w-5 h-5"}),label:"Bounce Rate",value:`${r.bounceRate.toFixed(0)}%`})]}),e.jsx(As,{rangeDays:Ie[k]}),e.jsx(Rs,{rows:B||[]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Page Views Over Time"}),e.jsx("div",{className:"w-full h-64",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(Ns,{data:r.timeseries,children:[e.jsx(Ee,{strokeDasharray:"3 3",stroke:"#ffffff10"}),e.jsx(Re,{dataKey:"name",stroke:"#ffffff60",fontSize:12}),e.jsx(Le,{stroke:"#ffffff60",fontSize:12}),e.jsx(I,{contentStyle:L}),e.jsx(ys,{type:"monotone",dataKey:"views",stroke:"#a855f7",strokeWidth:2,dot:!1})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide flex items-center gap-2",children:[e.jsx(ms,{className:"w-5 h-5"})," Top Countries"]}),r.countries.length===0?e.jsx("p",{className:"text-white/50 text-sm py-8 text-center",children:"No country data yet. Geo will populate as new traffic comes in."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full h-64",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(ks,{data:r.countries,layout:"vertical",margin:{left:20},children:[e.jsx(Ee,{strokeDasharray:"3 3",stroke:"#ffffff10"}),e.jsx(Re,{type:"number",stroke:"#ffffff60",fontSize:12}),e.jsx(Le,{dataKey:"name",type:"category",stroke:"#ffffff60",fontSize:11,width:110}),e.jsx(I,{contentStyle:L}),e.jsx(Ss,{dataKey:"value",fill:"#a855f7",radius:[0,4,4,0]})]})})}),r.unknownCountryCount>0&&e.jsxs("p",{className:"text-[11px] text-white/40 mt-2",children:[r.unknownCountryCount," view",r.unknownCountryCount===1?"":"s"," with unknown location."]})]})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Top Cities"}),r.cities.length===0?e.jsx("p",{className:"text-white/50 text-sm py-8 text-center",children:"No city data yet."}):e.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:r.cities.map((a,n)=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-white/5 last:border-0",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm truncate",children:a.city}),e.jsx("div",{className:"text-[11px] text-white/40",children:a.country})]}),e.jsx("div",{className:"text-sm font-bold",children:a.count})]},`${a.city}-${n}`))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Traffic Sources"}),e.jsx("div",{className:"w-full h-64",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(le,{children:[e.jsx(ce,{data:r.sources,dataKey:"value",nameKey:"name",innerRadius:45,outerRadius:80,paddingAngle:2,children:r.sources.map((a,n)=>e.jsx(oe,{fill:F[n%F.length]},n))}),e.jsx(de,{wrapperStyle:{fontSize:11,color:"#fff"}}),e.jsx(I,{contentStyle:L})]})})})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10 lg:col-span-2",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Top Referrers"}),e.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:r.referrers.map(a=>{var f;
6const n=((f=r.referrers[0])==null?void 0:f.value)||1;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-white/80",children:a.name}),e.jsx("span",{className:"text-white/60",children:a.value})]}),e.jsx("div",{className:"h-1.5 bg-white/5 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-purple-500",style:{width:`${a.value/n*100}%`}})})]},a.name)})})]})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Campaigns (UTM)"}),r.utmRows.length===0?e.jsx("p",{className:"text-white/50 text-sm py-4",children:"No campaign-tagged traffic in this range. Add `?utm_source=...&utm_medium=...&utm_campaign=...` to your campaign links."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-white/50 text-xs uppercase",children:e.jsxs("tr",{className:"border-b border-white/10",children:[e.jsx("th",{className:"text-left py-2 font-normal",children:"Source / Medium / Campaign"}),e.jsx("th",{className:"text-right py-2 font-normal",children:"Views"})]})}),e.jsx("tbody",{children:r.utmRows.map(a=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-2 text-white/80",children:a.name}),e.jsx("td",{className:"py-2 text-right font-bold",children:a.value})]},a.name))})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Top Pages"}),e.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:r.topPages.map(a=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 border-b border-white/5 last:border-0",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"text-sm truncate text-white/90",children:[a.title||he(a.path),a.isBlog&&e.jsx("span",{className:"ml-2 text-[10px] bg-purple-600/30 text-purple-200 px-1.5 py-0.5 rounded",children:"BLOG"})]}),a.title&&e.jsx("div",{className:"text-[11px] text-white/40 truncate",children:a.path})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"text-sm font-bold",children:a.views}),e.jsxs("div",{className:"text-[10px] text-white/50",children:[a.visitors," unique · ",me(a.avgTime)]})]})]},a.path))})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Top Blog Posts"}),r.topBlogPosts.length===0?e.jsx("p",{className:"text-white/50 text-sm py-8 text-center",children:"No blog traffic in this range yet."}):e.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:r.topBlogPosts.map(a=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-2 border-b border-white/5 last:border-0",children:[e.jsxs("a",{href:a.path,target:"_blank",rel:"noreferrer",className:"min-w-0 flex-1 hover:text-purple-300",children:[e.jsx("div",{className:"text-sm truncate",children:a.title||a.path}),e.jsx("div",{className:"text-[11px] text-white/40 truncate",children:a.path})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-sm font-bold",children:a.views}),e.jsx("div",{className:"text-[10px] text-white/50",children:me(a.avgTime)})]})]},a.path))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Landing Pages"}),e.jsx("p",{className:"text-[11px] text-white/40 -mt-3 mb-3",children:"First page visitors saw in their session."}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:r.landingPages.map(a=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-white/5 last:border-0",children:[e.jsx("div",{className:"text-sm truncate",children:he(a.path)}),e.jsx("div",{className:"text-sm font-bold",children:a.count})]},a.path))})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Exit Pages"}),e.jsx("p",{className:"text-[11px] text-white/40 -mt-3 mb-3",children:"Last page visitors saw before leaving."}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:r.exitPages.map(a=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-white/5 last:border-0",children:[e.jsx("div",{className:"text-sm truncate",children:he(a.path)}),e.jsx("div",{className:"text-sm font-bold",children:a.count})]},a.path))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"New vs Returning"}),e.jsx("div",{className:"w-full h-56",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(le,{children:[e.jsx(ce,{data:r.newVsReturning,dataKey:"value",nameKey:"name",innerRadius:45,outerRadius:75,paddingAngle:2,children:r.newVsReturning.map((a,n)=>e.jsx(oe,{fill:n===0?"#a855f7":"#06b6d4"},n))}),e.jsx(de,{wrapperStyle:{fontSize:12,color:"#fff"}}),e.jsx(I,{contentStyle:L})]})})})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10 lg:col-span-2",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Activity by Hour"}),e.jsx("p",{className:"text-[11px] text-white/40 -mt-3 mb-3",children:"Local browser time. Darker = busier."}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"text-[10px]",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-8"}),Array.from({length:24}).map((a,n)=>e.jsx("th",{className:"text-white/40 font-normal w-5 text-center",children:n%3===0?n:""},n))]})}),e.jsx("tbody",{children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((a,n)=>e.jsxs("tr",{children:[e.jsx("td",{className:"text-white/50 pr-2",children:a}),r.heatmap[n].map((f,M)=>{const _=f/r.heatmapMax;return e.jsx("td",{className:"p-0.5",children:e.jsx("div",{title:`${a} ${M}:00 — ${f} views`,className:"w-full aspect-square rounded-sm",style:{backgroundColor:f===0?"rgba(255,255,255,0.04)":`rgba(168, 85, 247, ${.15+_*.85})`}})},M)})]},a))})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(d,{className:"p-6 bg-white/5 border-white/10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Devices"}),e.jsx("div",{className:"w-full h-56",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(le,{children:[e.jsx(ce,{data:r.devices,dataKey:"value",nameKey:"name",innerRadius:40,outerRadius:70,paddingAngle:2,children:r.devices.map((a,n)=>e.jsx(oe,{fill:F[n%F.length]},n))}),e.jsx(de,{wrapperStyle:{fontSize:12,color:"#fff"}}),e.jsx(I,{contentStyle:L})]})})})]}),e.jsxs(d,{className:"p-6 bg-white/5 border-white/10 lg:col-span-2",children:[e.jsx("h2",{className:"text-lg font-bold mb-4 uppercase tracking-wide",children:"Browsers"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 ga
6p-3",children:r.browsers.map(a=>e.jsxs("div",{className:"bg-black/30 border border-white/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.value}),e.jsx("div",{className:"text-xs text-white/60",children:a.name})]},a.name))})]})]})]})})]})},E=({icon:i,label:o,value:u})=>e.jsxs(d,{className:"p-5 bg-white/5 border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-xs uppercase tracking-wide mb-2",children:[i,o]}),e.jsx("div",{className:"text-2xl lg:text-3xl font-bold",children:u})]});export{st 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.