1import{j as e}from"./ui-components-CrH3hhmI.js";import{b as R,r as l}from"./react-core-Df-1f7lZ.js";import{k as M,u as A,n as E,S as V,L as F,o as K,p as n,q as O,t as I,v as $,w as G}from"./index-baCrhAE7.js";import{OnScreenDiagnostic as U}from"./OnScreenDiagnostic-GyvtVO_q.js";import"./utils-BZSOOpUI.js";import"./editor-wwdhYSyT.js";import"./charts-DACaTPEh.js";const Q=()=>{const{setActivePage:b}=M(),{user:N}=A(),{selected:y}=E(),[w]=R(),i=w.get("domain"),[t,_]=l.useState(null),[d,k]=l.useState(null),[p,S]=l.useState(null),[v,D]=l.useState(null),[P,u]=l.useState(!1),[j,c]=l.useState(null),m=l.useRef(null),x=l.useRef(!1);l.useEffect(()=>{b(1)},[]),l.useEffect(()=>{if(!i){m.current!==null&&(m.current=null,x.current=!1,setSeoData(null),c(null),u(!1));return}if(m.current===i||x.current)return;m.current=i,x.current=!0,u(!0),c(null),setSeoData(null);let s=!0;return(async()=>{try{const a=y?.database?.encrypted||"default_cms";console.log("[Dashboard-2] Fetching data for:",i,"Encrypted DB ID:",a);const r=await O(i,a);if(!s)return;if(r.success&&r.data){_(r.data);const[h,g,f]=await Promise.all([I(i,a,30),$(i,a,4),G(i,a,30)]);if(!s)return;h.success&&h.data&&k(h.data),g.success&&g.data&&S(g.data),f.success&&f.data&&D(f.data)}else c(r.error||"No data available")}catch(a){if(!s)return;c(a.message||"Network Error")}finally{s&&(u(!1),x.current=!1)}})(),()=>{s=!1}},[i,N]);const T=l.useMemo(()=>new Date().toLocaleDateString("en-US",{month:"long",year:"numeric"}),[]),L=l.useMemo(()=>{if(d?.volume_trends&&d.volume_trends.length>0){const s=Math.max(...d.volume_trends.map(o=>o.total_volume||0));return d.volume_trends.slice(-7).map(o=>{const a=s>0?o.total_volume/s*50:15;return Math.max(a,10)})}return[15,25,18,35,28,42,38]},[d]),C=l.useMemo(()=>{if(d?.visibility_trends&&d.visibility_trends.length>0){const s=d.visibility_trends.reduce((a,r)=>(a[r.platform]||(a[r.platform]={count:0,score:0}),a[r.platform].count+=r.data_points||0,a[r.platform].score+=r.avg_score||0,a),{}),o={chatgpt:{logo:"/logos/open_ai_svg_1.svg",name:"ChatGPT"},google:{logo:"/logos/gemini_logo.png",name:"Google"},claude:{logo:"/logos/Claude_AI_logo.png",name:"Claude"},gemini:{logo:"/logos/gemini_logo.png",name:"Gemini"},perplexity:{logo:"/logos/Perplexity_logo_full.png",name:"Perplexity"}};return Object.entries(s).map(([a,r])=>({name:o[a]?.name||a,logo:o[a]?.logo||"/logos/gemini_logo.png",visits:r.count.toLocaleString()}))}return[{name:"ChatGPT",logo:"/logos/open_ai_svg_1.svg",visits:"â"},{name:"Google",logo:"/logos/gemini_logo.png",visits:"â"},{name:"Claude",logo:"/logos/Claude_AI_logo.png",visits:"â"},{name:"Perplexity",logo:"/logos/Perplexity_logo_full.png",visits:"â"}]},[d]);return e.jsxs(e.Fragment,{children:[e.jsx(V,{title:"Analytics Dashboard",description:"View your analytics dashboard",keywords:"dashboard, analytics",type:"website",canonical:"/business-hub-2"}),e.jsx("div",{className:"min-h-screen p-3 sm:p-6 bg-gray-50 dark:bg-transparent",children:e.jsxs("div",{className:"max-w-[1800px] mx-auto space-y-3",children:[i&&e.jsx("div",{className:"w-full rounded-2xl border bg-surface p-3 dark:border-none relative overflow-hidden",children:e.jsx("div",{className:"p-3",children:P?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(F,{className:"w-6 h-6 animate-spin text-primary mr-2"}),e.jsxs("span",{className:"text-sm text-muted",children:["Loading SEO data for ",i,"..."]})]}):j?e.jsx("div",{className:"overflow-clip rounded-xl border border-muted dark:border-muted/50 bg-surface-l1 p-6",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-regular",children:"SEO Data Unavailable"}),e.jsx("p",{className:"text-xs text-muted",children:j})]})}):seoData?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(K,{className:"w-5 h-5 text-primary"}),e.jsxs("h3",{className:"text-lg font-semibold text-regular",children:["SEO Analysis: ",i]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"overflow-clip rounded-xl border border-muted dark:border-muted/50 bg-surface-l1 p-4",children:[e.jsx("p",{className:"text-xs text-muted mb-2",children:"Organic Traffic"}),e.jsx("p",{className:"text-2xl font-bold text-regular",children:(seoData.domain?.organicTraffic||0).toLocaleStr
1ing()}),e.jsxs("p",{className:"text-xs text-muted mt-1",children:[(seoData.domain?.organicKeywords||0).toLocaleString()," keywords"]})]}),e.jsxs("div",{className:"overflow-clip rounded-xl border border-muted dark:border-muted/50 bg-surface-l1 p-4",children:[e.jsx("p",{className:"text-xs text-muted mb-2",children:"Top 10 Rankings"}),e.jsx("p",{className:"text-2xl font-bold text-regular",children:(seoData.domain?.top10Positions||0).toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted mt-1",children:[(seoData.domain?.topPositions||0).toLocaleString()," in top 3"]})]}),e.jsxs("div",{className:"overflow-clip rounded-xl border border-muted dark:border-muted/50 bg-surface-l1 p-4",children:[e.jsx("p",{className:"text-xs text-muted mb-2",children:"Rising Keywords"}),e.jsx("p",{className:"text-2xl font-bold text-green-500",children:(seoData.domain?.risingKeywords||0).toLocaleString()}),e.jsxs("p",{className:"text-xs text-red-500 mt-1",children:[(seoData.domain?.decliningKeywords||0).toLocaleString()," declining"]})]}),e.jsxs("div",{className:"overflow-clip rounded-xl border border-muted dark:border-muted/50 bg-surface-l1 p-4",children:[e.jsx("p",{className:"text-xs text-muted mb-2",children:"Traffic Value"}),e.jsxs("p",{className:"text-2xl font-bold text-regular",children:["$",(seoData.domain?.trafficValue||0).toLocaleString()]}),e.jsx("p",{className:"text-xs text-muted mt-1",children:"Est. value"})]})]}),seoData.competitors&&seoData.competitors.length>0&&e.jsxs("div",{className:"overflow-clip rounded-xl border border-muted dark:border-muted/50 bg-surface-l1 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-regular mb-3",children:"Top Competitors"}),e.jsx("div",{className:"space-y-2",children:seoData.competitors.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-muted/20 last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-regular",children:s.domain}),e.jsxs("p",{className:"text-xs text-muted",children:[(s.organicKeywords||0).toLocaleString()," keywords"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm font-medium text-primary",children:(s.organicTraffic||0).toLocaleString()}),e.jsx("p",{className:"text-xs text-muted",children:s.avgPosition?`Pos ${s.avgPosition.toFixed(1)}`:"â"})]})]},s.domain))})]})]}):null})}),e.jsx("div",{className:"w-full rounded-2xl border bg-surface p-3 dark:border-none relative overflow-hidden",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid items-center gap-3 px-3 pb-4 pt-2 sm:grid-cols-2 sm:pb-2 sm:pt-0",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-base text-regular font-medium",children:["Analytics Snapshot for ",e.jsx("span",{className:"text-primary dark:font-bold",children:T})]})}),e.jsx("div",{className:"sm:text-right",children:e.jsx("p",{className:"text-xs text-muted",children:"Real-time data updates"})})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-12",children:[e.jsx("div",{className:"lg:col-span-7",children:e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none h-full",children:e.jsx("div",{className:"flex h-full items-end",children:e.jsxs("div",{className:"p-6 w-full",children:[e.jsxs("div",{className:"-mx-2 -mt-2 mb-6 grid gap-3 sm:grid-cols-3",children:[e.jsx("div",{className:"group/progress flex flex-col gap-4 p-2",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-sm text-regular font-medium",children:t?.traffic_summary?.traffic_source==="dataforseo"?"Monthly Traffic":"Potential Traffic Volume"}),e.jsx("p",{className:"text-2xl font-bold text-regular",children:t?.total_volume?(t.total_volume/1e3).toFixed(0)+"K":"â"}),e.jsxs("p",{className:"text-sm text-muted",children:[t?.keywords_count||0," keywords",t?.traffic_summary?.traffic_source==="dataforseo"&&e.jsx("span",{className:"ml-1 text-green-500",children:"⢠Real"})]})]})}),e.jsx("div",{className:"group/progress flex flex-col gap-4 p-2",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-sm text-regular font-medium",children:t?.traffic_summary?.traffic_source==="dataforseo"?"Traffic Value":"Potential Traffic Value"}),e.jsxs("p",{className:"text-2xl font-bold text-regular",children:["$",t?.total_volume&&t?.avg_cpc?(t.total_volume*t.avg_cpc/1e3).toFixed(0)+"K":"0"]}),e.jsxs("p",{className:"text-sm text-muted",children:["$",t?.avg_cpc?.toFixed(2)||"0.00"," avg CPC"]})]})}),e.jsx("div",{className:"group/progress flex flex-col gap-4 p-2",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-sm text-regular font-medium",children:"AI Visibility"}),e.jsx("p",{className:"text-2xl font-bold text-regular",children:t?.visibility_score?.toFixed(0)||"0"}),e.jsx("p",{className:"text-sm text-muted",children:"Score"})]})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-4",children:e.jsx("p",{className:"text-xs text-muted font-medium",children:"Traffic by Source"})}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:C.map(s=>e.jsxs("div",{className:"flex flex-col items-center justify-center p-4 rounded-lg hover:bg-surface-l2/50 transition-colors group",children:[e.jsx("div",{className:"w-14 h-14 flex items-center justify-center mb-0.5",children:e.jsx("img",{src:s.logo,alt:s.name,className:"w-full h-full object-contain opacity-90 group-hover:opacity-100 transition-opacity"})}),e.jsx("p",{className:"text-xl font-bold text-regular",children:s.visits})]},s.name))}),e.jsx("div",{"data-orientation":"horizontal",role:"none",className:"bg-border shrink-0 h-[1px] w-full bg-foreground
1/10 my-3"}),e.jsxs("div",{className:"flex justify-between gap-3 text-sm",children:[e.jsx("div",{className:"text-subtle line-clamp-1 shrink-0 text-sm",children:e.jsx("span",{className:"text-primary font-medium",children:"Overall Performance"})}),e.jsx("div",{className:"flex max-w-md grow items-center justify-end gap-2 text-right",children:e.jsxs("span",{children:[t?.visibility_score?.toFixed(0)||"â","/100"]})})]})]})]})})})}),e.jsx("div",{className:"lg:col-span-5",children:e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none h-full",children:e.jsx("div",{className:"flex h-full items-end",children:e.jsxs("div",{className:"p-6 w-full",children:[e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"relative flex h-[100px] items-end gap-2",children:[L.map((s,o)=>e.jsx("button",{"data-state":"closed",type:"button",className:"flex z-10 items-end flex-1",style:{height:`${s}%`},children:e.jsx("div",{className:`h-full w-full rounded ${o===6?"bg-primary":"bg-surface-l3"}`})},o)),e.jsx("div",{className:"border-primary/25 absolute inset-x-0 h-px border-b border-dashed",style:{bottom:"42%"},children:e.jsx("div",{className:"text-primary flex justify-end py-1 text-xs",children:"Average"})})]})}),e.jsx("div",{className:"mt-6 flex items-end justify-between gap-3 sm:mt-10",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium text-regular",children:"Weekly Snapshot"}),e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsxs("p",{className:"text-sm text-muted",children:[e.jsx("span",{className:"text-primary font-medium",children:p?.totals?.avg_weekly_volume?(p.totals.avg_weekly_volume/7/1e3).toFixed(1)+"K":"â"})," searches / day"]}),e.jsxs("p",{className:"text-sm text-muted",children:[e.jsx("span",{className:"text-primary font-medium",children:v?.total_leads?Math.round(v.total_leads/30):"â"})," leads / day"]}),e.jsxs("p",{className:"text-sm text-muted",children:[e.jsx("span",{className:"text-primary font-medium",children:t?.visibility_score||"â"})," AI visibility score"]})]})]})})]})})})})]})]})}),e.jsx("div",{className:"w-full rounded-2xl border bg-surface p-3 dark:border-none relative overflow-hidden",children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:[e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none hover:ring-primary group relative h-full bg-gradient-to-tl shadow-sm ring-1 ring-transparent duration-150 hover:from-surface-l4 hover:to-surface-l1 hover:shadow-md",children:e.jsxs("div",{className:"p-6 flex h-full flex-col",children:[e.jsx("img",{src:"/icons/globe.svg",alt:"",className:"w-8 h-8 object-contain"}),e.jsxs("div",{className:"mt-6 flex flex-grow items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium text-regular",children:"Realtime Map"}),e.jsx("p",{className:"text-sm text-muted mt-1",children:"View visitor locations"})]}),e.jsx(n,{className:"w-5 h-5 origin-right -rotate-45 shrink-0"})]})]})}),e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none hover:ring-primary group relative h-full bg-gradient-to-tl shadow-sm ring-1 ring-transparent duration-150 hover:from-surface-l4 hover:to-surface-l1 hover:shadow-md",children:e.jsxs("div",{className:"p-6 flex h-full flex-col",children:[e.jsx("img",{src:"/icons/analysis.svg",alt:"",className:"w-8 h-8 object-contain"}),e.jsxs("div",{className:"mt-6 flex flex-grow items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium text-regular",children:"Track Performance"}),e.jsxs("p",{className:"text-sm text-muted mt-1",children:["Deep dive into metrics ",e.jsx("span",{className:"text-primary",children:"(See Realtime)"})]})]}),e.jsx(n,{className:"w-5 h-5 origin-right -rotate-45 shrink-0"})]})]})}),e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none hover:ring-primary group relative h-full bg-gradient-to-tl shadow-sm ring-1 ring-transparent duration-150 hover:from-surface-l4 hover:to-surface-l1 hover:shadow-md",children:e.jsxs("div",{className:"p-6 flex h-full flex-col",children:[e.jsx("img",{src:"/icons/team.svg",alt:"",className:"w-8 h-8 object-contain"}),e.jsxs("div",{className:"mt-6 flex flex-grow items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium text-regular",children:"Manage Team"}),e.jsxs("p",{className:"text-sm text-muted mt-1",children:["Access detailed reports ",e.jsx("span",{className:"text-primary",children:"(Create New Page)"})]})]}),e.jsx(n,{className:"w-5 h-5 origin-right -rotate-45 shrink-0"})]})]})}),e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none hover:ring-primary group relative h-full bg-gradient-to-tl shadow-sm ring-1 ring-transparent duration-150 hover:from-surface-l4 hover:to-surface-l1 hover:shadow-md",children:e.jsxs("div",{className:"p-6 flex h-full flex-col",children:[e.jsx("img",{src:"/icons/contacts.svg",alt:"",className:"w-8 h-8 object-contain"}),e.jsxs("div",{className:"mt-6 flex flex-grow items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium text-regular",children:"Contacts"}),e.jsxs("p",{className:"text-sm text-muted mt-1",children:["Understand your audience ",e.jsx("span",{className:"text-primary",children:"(See New Customers)"})]})]}),e.jsx(n,{className:"w-5 h-5 origin-right -rotate-45 shrink-0"})]})]})}),e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none hover:ring-primary group relative h-full bg-gradient-to-tl shadow-sm ring-1 ring-transparent duration-150 hover:from-surface-l4 hover:to-surface-l1 hover:shadow-md",children:e.jsxs("div",{className:"p-6 flex h-full flex-col",children:[e.jsx("img",{src:"/icons/magnet.svg",alt:"",className:"w-8 h-8 object-contain"}),e.jsxs("div",{className:"mt-6 flex flex-grow items-end justify-between gap-3",children:[e.jsx("div",{children:e.jsx("h4",{className:"text-base font-medium text-regular",children:"User Submissions"})}),e.jsx(n,{className:"w-5 h-5 origin-right -rotate-45 shrink-0"})]})]})}),e.jsx("div",{className:"overflow-clip rounded-xl border transition-all border-muted dark:border-muted/50 bg-surface-l1 dark:shadow-none hover:ring-primary group relative h-full bg-gradient-to-tl shadow-sm ring-1 ring-transparent duration-150 hover:from-surface-l4 hover:to-surface-l1 hover:shadow-md",children:e.jsxs("div",{className:"p-6 flex h-full flex-col",children:[e.jsx("img",{src:"/icons/integrations.svg",alt:"",className:"w-8 h-8 object-contain"}),e.jsxs("div",{className:"mt-6 flex flex-grow items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium text-regular",children:"Connect Data"}),e.jsxs("p",{className:"text-sm text-muted mt-1",children:["Download anal
1ytics ",e.jsx("span",{className:"text-primary",children:"(Connect Your Data)"})]})]}),e.jsx(n,{className:"w-5 h-5 origin-right -rotate-45 shrink-0"})]})]})})]})})]})}),e.jsx(U,{})]})};export{Q 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.