1import{j as e}from"./vendor-radix-BnNg3BH5.js";import{r as C,Q as $e}from"./vendor-react-67mgcWXU.js";import{M as I}from"./metric-DK0Tcl4m.js";import{C as b,a as $,b as T,c as q,d as w}from"./card-DpKBVi42.js";import{b as Q,s as v,q as f,B as N,L as P,S as W,I as me,H as ue,F as X,C as se,X as te,E as he,U as Te,V as Pe,W as O,Y as E,w as ae,x as re,y as ne,z as le,A as D}from"./index-Epr9psQo.js";import{B as g}from"./badge-Cl7apleB.js";import{T as F,a as M,b as _,c as m,d as U,e as u}from"./table-023rHGnC.js";import{P as ie}from"./progress-OXAVVpg3.js";import{a as V,u as Z,c as K}from"./vendor-query-PMAhJHCS.js";import{C as Y}from"./checkbox-CaPhqoy3.js";import{f as Ae}from"./useBlogPosts-Caq9J4gs.js";import{M as Re}from"./map-pin-CFiJTnw_.js";import{G as xe}from"./globe-DQzIP_ik.js";import{R as G}from"./refresh-cw-j1umLsSM.js";import{C as Le}from"./circle-check-Cv8aCTuA.js";import{C as ze}from"./circle-alert-CFN03ksH.js";import{E as Ke}from"./external-link-DnfaRxEP.js";import{T as qe}from"./trash-2-EIFrPvgK.js";import{L as ee}from"./link-2-Bu8oQt2W.js";import{C as Be}from"./check-check-BONXlGbt.js";import{C as J}from"./chart-column-6WlVTHnt.js";import{T as ge}from"./trending-up-CXZcoU_y.js";import{T as Ie}from"./triangle-alert-C6ISfBPd.js";import{Z as ce}from"./zap-DC4LlnWT.js";import{T as oe}from"./target-CyHaUH9t.js";import{S as Fe}from"./search-BnpyGpZl.js";import{A as Me}from"./arrow-up-right-zF0c4Zfm.js";import{A as Ue}from"./arrow-down-right-CZbhTnfW.js";import{M as Oe}from"./minus-CdxVbKUw.js";import"./vendor-supabase-CTlrDMdV.js";import"./vendor-charts-Dck3qfzI.js";import"./vendor-motion-CSzk-Fqg.js";function Ee(){const{currentTenant:n}=Q();return V({queryKey:["keyword_tracking",n?.id],queryFn:async()=>{const{data:h,error:o}=await v.from("keyword_tracking").select("*").eq("tenant_id",n.id).order("tier",{ascending:!0}).order("search_volume",{ascending:!1});if(o)throw o;return h},enabled:!!n?.id})}function De(n){const{currentTenant:h}=Q();return V({queryKey:["seo_tracking",h?.id,n],queryFn:async()=>{let o=v.from("seo_tracking").select("*").eq("tenant_id",h.id).order("snapshot_date",{ascending:!1}).limit(50);const{data:x,error:p}=await o;if(p)throw p;return x},enabled:!!h?.id})}function Ge(){const n=Z(),{currentTenant:h}=Q();return K({mutationFn:async o=>{const{data:x,error:p}=await v.functions.invoke("ahrefs-seo-data",{body:{...o,tenant_id:h?.id}});if(p)throw p;return x},onSuccess:(o,x)=>{n.invalidateQueries({queryKey:["seo_tracking"]}),n.invalidateQueries({queryKey:["keyword_tracking"]}),f.success(`Ahrefs ${x.action} completed`)},onError:o=>{const x=o?.message||"Ahrefs API call failed";x.includes("api_plan_limited")?f.warning("This feature requires a higher Ahrefs plan."):f.error(x)}})}function Ve(){const n=Z(),{currentTenant:h}=Q();return K({mutationFn:async()=>{const{data:o,error:x}=await v.functions.invoke("ahrefs-seo-data",{body:{action:"seed_keywords",tenant_id:h?.id}});if(x)throw x;return o},onSuccess:o=>{n.invalidateQueries({queryKey:["keyword_tracking"]}),f.success(`Seeded ${o?.seeded||0} keywords for tracking`)},onError:o=>{f.error(o?.message||"Failed to seed keywords")}})}function Qe(){return K({mutationFn:async n=>{const{data:h,error:o}=await v.functions.invoke("submit-to-google-index",{body:n});if(o)throw o;return h},onSuccess:(n,h)=>{if(n?.setup_required){f.warning("Google Service Account not configured. Add the GOOGLE_SERVICE_ACCOUNT_JSON secret.");return}h.action==="submit_batch"?f.success(`Submitted ${n?.submitted||0} URLs to Google for indexing`):h.action==="submit_url"?f.success("URL submitted to Google for indexing"):h.action==="check_status"?f.info("Indexing status retrieved"):f.success("URL removal requested")},onError:n=>{const h=n?.message||"Google Indexing API call failed";f.error(h)}})}const s="https://incommand.ai";function He(){const[n,h]=C.useState(""),[o,x]=C.useState(new Set),[p,A]=C.useState("idle"),{data:t=[]}=Ae(),c=Qe(),l=[{url:`${s}/`,label:"Home",type:"page"},{url:`${s}/features`,label:"Features",type:"page"},{url:`${s}/pricing`,label:"Pricing",type:"page"},{url:`${s}/about`,label:"About",type:"page"},{url:`${s}/contact`,label:"Contact",type:"page"},{url:`${s}/solutions`,label:"Solutions",type:"page"},{url:`${s}/blog`,label:"Blog Index",type:"page"},{url:`${s}/resources`,label:"Resources",type:"page"},{url:`${s}/security`,label:"Security",type:"page"},{url:`${s}/privacy`,label:"Privacy",type:"page"},{url:`${s}/terms`,label:"Terms",type:"page"},{url:`${s}/compare`,label:"Compare",type:"page"},{url:`${s}/glossary`,label:"Glossary",type:"page"},{url:`${s}/best`,label:"Best Of",type:"page"},{url:`${s}/problems`,label:"Problems",type:"page"},{url:`${s}/signup`,label:"Signup",type:"page"},{url:`${s}/features/time-tracking`,label:"Time Tracking",type:"feature"},{url:`${s}/features/proposals`,label:"Proposals",type:"feature"},{url:`${s}/features/projects`,label:"Projects",type:"feature"},{url:`${s}/features/revenue-intel`,label:"Revenue Intel",type:"feature"},{url:`${s}/features/battlecards`,label:"Battlecards",type:"feature"},{url:`${s}/features/knowledge`,label:"Knowledge",type:"feature"},{url:`${s}/solutions/consulting`,label:"Consulting",type:"solution"},{url:`${s}/solutions/it-services`,label:"IT Services",type:"solution"},{url:`${s}/solutions/legal`,label:"Legal",type:"solution"},{url:`${s}/solutions/accounting`,label:"Accounting",type:"solution"},{url:`${s}/solutions/marketing-agencies`,label:"Marketing Agencies",type:"solution"},{url:`${s}/solutions/architecture-engineering`,label:"Architecture & Engineering",type:"solution"},{url:`${s}/solutions/hr-recruiting`,label:"HR & Recruiting",type:"solution"},{url:`${s}
1/solutions/financial-advisory`,label:"Financial Advisory",type:"solution"},{url:`${s}/solutions/healthcare`,label:"Healthcare",type:"solution"},{url:`${s}/compare/harvest`,label:"vs Harvest",type:"compare"},{url:`${s}/compare/teamwork`,label:"vs Teamwork",type:"compare"},{url:`${s}/compare/bigtime`,label:"vs BigTime",type:"compare"},{url:`${s}/compare/accelo`,label:"vs Accelo",type:"compare"},{url:`${s}/compare/kantata`,label:"vs Kantata",type:"compare"},{url:`${s}/compare/scoro`,label:"vs Scoro",type:"compare"},{url:`${s}/compare/monday`,label:"vs Monday",type:"compare"},{url:`${s}/compare/clickup`,label:"vs ClickUp",type:"compare"},{url:`${s}/compare/wrike`,label:"vs Wrike",type:"compare"},{url:`${s}/compare/toggl`,label:"vs Toggl",type:"compare"},{url:`${s}/compare/clockify`,label:"vs Clockify",type:"compare"},{url:`${s}/compare/hubspot`,label:"vs HubSpot",type:"compare"},{url:`${s}/compare/salesforce`,label:"vs Salesforce",type:"compare"},{url:`${s}/compare/connectwise`,label:"vs ConnectWise",type:"compare"},{url:`${s}/compare/autotask`,label:"vs Autotask",type:"compare"},{url:`${s}/compare/productive`,label:"vs Productive",type:"compare"},{url:`${s}/compare/financialforce`,label:"vs FinancialForce",type:"compare"},{url:`${s}/glossary/psa-software`,label:"PSA Software",type:"glossary"},{url:`${s}/glossary/utilization-rate`,label:"Utilization Rate",type:"glossary"},{url:`${s}/glossary/billable-hours`,label:"Billable Hours",type:"glossary"},{url:`${s}/glossary/revenue-leakage`,label:"Revenue Leakage",type:"glossary"},{url:`${s}/glossary/resource-management`,label:"Resource Management",type:"glossary"},{url:`${s}/glossary/consulting-profitability`,label:"Consulting Profitability",type:"glossary"},{url:`${s}/glossary/scope-creep`,label:"Scope Creep",type:"glossary"},{url:`${s}/glossary/time-tracking`,label:"Time Tracking",type:"glossary"},{url:`${s}/glossary/statement-of-work`,label:"Statement of Work",type:"glossary"},{url:`${s}/glossary/sales-battlecard`,label:"Sales Battlecard",type:"glossary"},{url:`${s}/glossary/capacity-planning`,label:"Capacity Planning",type:"glossary"},{url:`${s}/glossary/realization-rate`,label:"Realization Rate",type:"glossary"},{url:`${s}/glossary/proposal-management`,label:"Proposal Management",type:"glossary"},{url:`${s}/glossary/competitive-intelligence`,label:"Competitive Intelligence",type:"glossary"},{url:`${s}/glossary/change-order`,label:"Change Order",type:"glossary"},{url:`${s}/glossary/project-margin`,label:"Project Margin",type:"glossary"},{url:`${s}/glossary/client-lifetime-value`,label:"Client Lifetime Value",type:"glossary"},{url:`${s}/glossary/ai-time-tracking`,label:"AI Time Tracking",type:"glossary"},{url:`${s}/glossary/consulting-utilization-optimization`,label:"Utilization Optimization",type:"glossary"},{url:`${s}/glossary/revenue-forecasting`,label:"Revenue Forecasting",type:"glossary"},{url:`${s}/glossary/proposal-automation`,label:"Proposal Automation",type:"glossary"},{url:`${s}/best/best-psa-software`,label:"Best PSA Software",type:"best"},{url:`${s}/best/best-consulting-time-tracking-software`,label:"Best Time Tracking",type:"best"},{url:`${s}/best/best-proposal-software-consulting`,label:"Best Proposal Software",type:"best"},{url:`${s}/best/best-resource-management-software`,label:"Best Resource Mgmt",type:"best"},{url:`${s}/best/best-consulting-crm`,label:"Best Consulting CRM",type:"best"},{url:`${s}/best/best-knowledge-management-software-consulting`,label:"Best Knowledge Mgmt",type:"best"},{url:`${s}/problems/tool-fatigue`,label:"Tool Fatigue",type:"problem"},{url:`${s}/problems/unprepared-meetings`,label:"Unprepared Meetings",type:"problem"},{url:`${s}/problems/unprofitable-projects`,label:"Unprofitable Projects",type:"problem"},{url:`${s}/problems/revenue-leakage`,label:"Revenue Leakage",type:"problem"},{url:`${s}/problems/knowledge-silos`,label:"Knowledge Silos",type:"problem"},{url:`${s}/problems/proposal-bottleneck`,label:"Proposal Bottleneck",type:"problem"},{url:`${s}/problems/inconsistent-delivery`,label:"Inconsistent Delivery",type:"problem"},{url:`${s}/problems/talent-retention`,label:"Talent Retention",type:"problem"},...t.map(d=>({url:`${s}/blog/${d.slug}`,label:d.title,type:"blog"}))],B=d=>{const z=new Set(o);z.has(d)?z.delete(d):z.add(d),x(z)},S=()=>{o.size===l.length?x(new Set):x(new Set(l.map(d=>d.url)))},r=()=>{const d=Array.from(o);if(d.length===0){f.warning("Select at least one URL to submit");return}d.length===1?c.mutate({action:"submit_url",url:d[0]}):c.mutate({action:"submit_batch",urls:d})},j=()=>
1{if(!n.trim())return;const d=n.startsWith("http")?n:`${s}${n}`;c.mutate({action:"submit_url",url:d}),h("")},k=d=>{c.mutate({action:"check_status",url:d})},i=async()=>{A("loading");try{const{data:d,error:z}=await v.functions.invoke("generate-sitemap");if(z)throw z;A("done"),f.success("Sitemap validated successfully. Publish to update the live sitemap.xml")}catch{A("error"),f.error("Failed to validate sitemap")}},y=`${s}/sitemap.xml`;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-5 w-5"})," Sitemap"]}),e.jsx(q,{children:"Static sitemap.xml served from your domain with all published blog posts and marketing pages. Submit this URL to Google Search Console."})]}),e.jsxs(w,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[e.jsx(xe,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-sm flex-1 font-mono break-all",children:y}),e.jsx(N,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(y),f.success("Sitemap URL copied")},children:"Copy"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:i,disabled:p==="loading",children:[p==="loading"?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(G,{className:"h-4 w-4 mr-2"}),"Test Sitemap"]}),p==="done"&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-success",children:[e.jsx(Le,{className:"h-4 w-4"})," Working"]}),p==="error"&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-destructive",children:[e.jsx(ze,{className:"h-4 w-4"})," Error"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Submit ",e.jsx("code",{className:"bg-muted px-1 rounded",children:y}),' in Google Search Console â Sitemaps â "Add a new sitemap". Publish to update the live sitemap after adding new blog posts.']})]})]}),e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(W,{className:"h-5 w-5"})," Google Indexing API"]}),e.jsx(q,{children:"Programmatically request Google to crawl and index your pages immediately. Requires a Google service account with Indexing API enabled."})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(me,{placeholder:"Enter URL or path (e.g., /blog/my-post)",value:n,onChange:d=>h(d.target.value),onKeyDown:d=>d.key==="Enter"&&j()}),e.jsxs(N,{onClick:j,disabled:c.isPending||!n.trim(),children:[c.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(W,{className:"h-4 w-4 mr-2"}),"Submit"]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{checked:o.size===l.length&&l.length>0,onCheckedChange:S}),e.jsx("span",{className:"text-sm font-medium",children:o.size>0?`${o.size} URL${o.size>1?"s":""} selected`:"Select URLs to submit"})]}),e.jsxs(N,{size:"sm",onClick:r,disabled:o.size===0||c.isPending,children:[c.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(W,{className:"h-4 w-4 mr-2"}),"Submit ",o.size>0?`(${o.size})`:""]})]}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{className:"w-10"}),e.jsx(m,{children:"URL"}),e.jsx(m,{className:"w-20",children:"Type"}),e.jsx(m,{className:"w-24",children:"Actions"})]})}),e.jsx(U,{children:l.map(d=>e.jsxs(_,{children:[e.jsx(u,{children:e.jsx(Y,{checked:o.has(d.url),onCheckedChange:()=>B(d.url)})}),e.jsx(u,{children:e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:d.label}),e.jsx("span",{className:"block text-xs text-muted-foreground font-mono",children:d.url.replace(s,"")})]})}),e.jsx(u,{children:e.jsx(g,{variant:d.type==="blog"?"default":"secondary",children:d.type})}),e.jsx(u,{children:e.jsx("div",{className:"flex gap-1",children:e.jsx(N,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>k(d.url),title:"Check status",children:e.jsx(Ke,{className:"h-3 w-3"})})})})]},d.url))})]})})]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 p-3 text-xs text-muted-foreground space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Setup Instru
1ctions:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[e.jsx("li",{children:'Create a Google Cloud project and enable the "Indexing API"'}),e.jsx("li",{children:"Create a Service Account and download the JSON key file"}),e.jsx("li",{children:"Add the service account email as an owner in Google Search Console"}),e.jsxs("li",{children:["Add the JSON key content as the ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"GOOGLE_SERVICE_ACCOUNT_JSON"})," secret"]})]})]})]})]})]})}function We(){const{currentTenant:n}=Q(),h=Z(),[o,x]=C.useState(null),{data:p=[],isLoading:A}=V({queryKey:["content-briefs",n?.id],queryFn:async()=>{if(!n?.id)return[];const{data:r,error:j}=await v.from("content_briefs").select("*").eq("tenant_id",n.id).order("priority_score",{ascending:!1});if(j)throw j;return r},enabled:!!n?.id}),{data:t=[]}=V({queryKey:["keyword-gaps",n?.id],queryFn:async()=>{if(!n?.id)return[];const{data:r}=await v.from("keyword_tracking").select("*").eq("tenant_id",n.id).order("search_volume",{ascending:!1}),{data:j}=await v.from("content_briefs").select("target_keyword").eq("tenant_id",n.id),k=new Set((j||[]).map(i=>i.target_keyword?.toLowerCase()));return(r||[]).filter(i=>!k.has(i.keyword?.toLowerCase()))},enabled:!!n?.id}),c=K({mutationFn:async r=>{x(r);const{data:j,error:k}=await v.functions.invoke("generate-content-brief",{body:{keyword:r,tenant_id:n?.id}});if(k)throw k;if(j?.error)throw new Error(j.error);return j},onSuccess:()=>{h.invalidateQueries({queryKey:["content-briefs"]}),h.invalidateQueries({queryKey:["keyword-gaps"]}),h.invalidateQueries({queryKey:["content-backlog"]}),f.success("Content brief generated & added to backlog"),x(null)},onError:r=>{f.error(`Failed: ${r.message}`),x(null)}}),l=K({mutationFn:async r=>{const j=`/blog/${r.target_keyword.toLowerCase().replace(/\s+/g,"-")}`,{error:k}=await v.from("content_backlog").upsert({tenant_id:n?.id,target_keyword:r.target_keyword,search_volume:r.search_volume,difficulty:r.difficulty,priority:r.priority_score>100?"P0":r.priority_score>50?"P1":"P2",recommended_title:r.title,target_url:j,content_type:"Blog Post",content_pillar:null,notes:`From content brief. Outline: ${(r.outline||[]).map(i=>i.heading).join(" â ")}`,status:"pending"},{onConflict:"tenant_id,target_keyword",ignoreDuplicates:!0});if(k)throw k},onSuccess:()=>{h.invalidateQueries({queryKey:["content-backlog"]}),f.success("Added to content backlog")},onError:r=>f.error(`Failed: ${r.message}`)}),B=K({mutationFn:async r=>{const{error:j}=await v.from("content_briefs").delete().eq("id",r);if(j)throw j},onSuccess:()=>{h.invalidateQueries({queryKey:["content-briefs"]}),h.invalidateQueries({queryKey:["keyword-gaps"]}),f.success("Brief deleted")}}),S=r=>{switch(r){case"draft":return e.jsx(g,{variant:"outline",children:"Draft"});case"approved":return e.jsx(g,{className:"bg-info/20 text-info",children:"Approved"});case"in_progress":return e.jsx(g,{className:"bg-warning/20 text-warning",children:"In Progress"});case"published":return e.jsx(g,{className:"bg-success/20 text-success",children:"Published"});default:return e.jsx(g,{variant:"outline",children:r})}};return e.jsxs("div",{className:"space-y-6",children:[t.length>0&&e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5"})," Keyword Gaps (",t.length,")"]}),e.jsx(q,{children:"Keywords you track but don't have content for. Generate a brief to plan content."})]}),e.jsx(w,{children:e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{children:"Keyword"}),e.jsx(m,{className:"text-right",children:"Volume"}),e.jsx(m,{className:"text-center",children:"Difficulty"}),e.jsx(m,{className:"text-center",children:"Tier"}),e.jsx(m,{className:"text-right",children:"Action"})]})}),e.jsx(U,{children:t.slice(0,15).map(r=>e.jsxs(_,{children:[e.jsx(u,{className:"font-medium",children:r.keyword}),e.jsx(u,{className:"text-right",children:r.search_volume?.toLocaleString()??"â"}),e.jsx(u,{className:"text-center",children:e.jsx(g,{variant:"outline",children:r.difficulty??"â"})}),e.jsxs(u,{className:"text-center",children:["T",r.tier??"â"]}),e.jsx(u,{className:"text-right",children:e.jsxs(N,{size:"sm",variant:"outline",onClick:()=>
1c.mutate(r.keyword),disabled:o===r.keyword,children:[o===r.keyword?e.jsx(P,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(X,{className:"h-3 w-3 mr-1"}),"Generate Brief"]})})]},r.id))})]})})]}),e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"})," Content Briefs (",p.length,")"]}),e.jsx(q,{children:"Generated content briefs with outlines and internal link suggestions."})]}),e.jsx(w,{children:A?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(P,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):p.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(X,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"No content briefs yet. Generate one from the keyword gaps above."})]}):e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{children:"Title"}),e.jsx(m,{children:"Keyword"}),e.jsx(m,{className:"text-right",children:"Volume"}),e.jsx(m,{className:"text-center",children:"Priority"}),e.jsx(m,{className:"text-center",children:"Status"}),e.jsx(m,{className:"text-right",children:"Actions"})]})}),e.jsx(U,{children:p.map(r=>e.jsxs(_,{children:[e.jsx(u,{className:"font-medium max-w-[300px] truncate",children:r.title}),e.jsx(u,{className:"text-muted-foreground",children:r.target_keyword}),e.jsx(u,{className:"text-right",children:r.search_volume?.toLocaleString()??"â"}),e.jsx(u,{className:"text-center",children:e.jsx(g,{variant:r.priority_score>100?"default":"outline",children:r.priority_score})}),e.jsx(u,{className:"text-center",children:S(r.status)}),e.jsx(u,{className:"text-right",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(N,{size:"sm",variant:"outline",onClick:()=>l.mutate(r),disabled:l.isPending,title:"Send to Content Backlog",children:[e.jsx(W,{className:"h-3 w-3 mr-1"})," Backlog"]}),e.jsx(N,{size:"sm",variant:"ghost",onClick:()=>B.mutate(r.id),children:e.jsx(qe,{className:"h-3 w-3"})})]})})]},r.id))})]})})]})]})}function Je(){const{currentTenant:n}=Q(),h=Z(),{data:o=[],isLoading:x}=V({queryKey:["internal-link-suggestions",n?.id],queryFn:async()=>{if(!n?.id)return[];const{data:i,error:y}=await v.from("internal_link_suggestions").select("*").eq("tenant_id",n.id).order("created_at",{ascending:!1});if(y)throw y;return i},enabled:!!n?.id}),p=K({mutationFn:async()=>{const{data:i,error:y}=await v.functions.invoke("analyze-internal-links",{body:{tenant_id:n?.id}});if(y)throw y;if(i?.error)throw new Error(i.error);return i},onSuccess:i=>{h.invalidateQueries({queryKey:["internal-link-suggestions"]}),f.success(`Found ${i.suggestions_count} link opportunities`)},onError:i=>f.error(`Failed: ${i.message}`)}),A=K({mutationFn:async({id:i,status:y})=>{const{error:d}=await v.from("internal_link_suggestions").update({status:y}).eq("id",i);if(d)throw d},onSuccess:()=>{h.invalidateQueries({queryKey:["internal-link-suggestions"]})}}),t=K({mutationFn:async({ids:i,status:y})=>{const{error:d}=await v.from("internal_link_suggestions").update({status:y}).in("id",i);if(d)throw d},onSuccess:(i,y)=>{h.invalidateQueries({queryKey:["internal-link-suggestions"]}),f.success(`${y.status==="applied"?"Applied":"Dismissed"} ${y.ids.length} suggestions`)},onError:i=>f.error(`Bulk update failed: ${i.message}`)}),[c,l]=$e.useState(new Set),B=i=>{l(y=>{const d=new Set(y);return d.has(i)?d.delete(i):d.add(i),d})},S=()=>{c.size===r.length?l(new Set):l(new Set(r.map(i=>i.id)))},r=o.filter(i=>i.status==="pending"),j=o.filter(i=>i.status==="applied"),k=o.filter(i=>i.status==="dismissed");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(b,{children:e.jsxs(w,{className:"pt-6",children:[e.jsx(I,{size:"md",children:r.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending Suggestions"})]})}),e.jsx(b,{children:e.jsxs(w,{className:"pt-6",children:[e.jsx(I,{size:"md",className:"text-success",children:j.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Applied"})]})}),e.jsx(b,{children:e.jsxs(w,{className:"pt-6",children:[e.jsx(I,{size:"md",className:"text-muted-foreground",children:k.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dismissed"})]})})]}),e.jsxs(b,{children:[e.jsx($,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-5 w-5"})," Internal Link Suggestions"]}
1),e.jsx(q,{children:"Keywords found in blog posts that aren't linked to their target pages."})]}),e.jsxs("div",{className:"flex gap-2",children:[c.size>0&&e.jsxs(e.Fragment,{children:[e.jsxs(N,{size:"sm",variant:"outline",onClick:()=>t.mutate({ids:Array.from(c),status:"applied"}),disabled:t.isPending,children:[e.jsx(se,{className:"h-4 w-4 mr-1"})," Apply ",c.size]}),e.jsxs(N,{size:"sm",variant:"ghost",onClick:()=>t.mutate({ids:Array.from(c),status:"dismissed"}),disabled:t.isPending,children:[e.jsx(te,{className:"h-4 w-4 mr-1"})," Dismiss ",c.size]})]}),e.jsxs(N,{size:"sm",variant:"default",onClick:()=>{const i=r.map(y=>y.id);i.length>0&&t.mutate({ids:i,status:"applied"})},disabled:t.isPending||r.length===0,children:[e.jsx(Be,{className:"h-4 w-4 mr-1"})," Apply All"]}),e.jsxs(N,{onClick:()=>p.mutate(),disabled:p.isPending,children:[p.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(G,{className:"h-4 w-4 mr-2"}),"Analyze Posts"]})]})]})}),e.jsx(w,{children:x?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(P,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ee,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:'No pending suggestions. Click "Analyze Posts" to scan for opportunities.'})]}):e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{className:"w-10",children:e.jsx(Y,{checked:c.size===r.length&&r.length>0,onCheckedChange:S})}),e.jsx(m,{children:"Source Page"}),e.jsx(m,{children:"Keyword"}),e.jsx(m,{children:"Target URL"}),e.jsx(m,{children:"Context"}),e.jsx(m,{className:"text-right",children:"Actions"})]})}),e.jsx(U,{children:r.map(i=>e.jsxs(_,{children:[e.jsx(u,{children:e.jsx(Y,{checked:c.has(i.id),onCheckedChange:()=>B(i.id)})}),e.jsx(u,{className:"font-mono text-xs",children:i.source_page}),e.jsx(u,{className:"font-medium",children:i.keyword}),e.jsx(u,{className:"font-mono text-xs",children:i.target_url}),e.jsx(u,{className:"text-xs text-muted-foreground max-w-[200px] truncate",children:i.context_snippet}),e.jsx(u,{className:"text-right",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(N,{size:"sm",variant:"outline",className:"h-7",onClick:()=>A.mutate({id:i.id,status:"applied"}),children:e.jsx(se,{className:"h-3 w-3"})}),e.jsx(N,{size:"sm",variant:"ghost",className:"h-7",onClick:()=>A.mutate({id:i.id,status:"dismissed"}),children:e.jsx(te,{className:"h-3 w-3"})})]})})]},i.id))})]})})]})]})}function Ye(){const{data:n=[],isLoading:h}=V({queryKey:["seo-visitor-intelligence"],queryFn:async()=>{const t=new Date;t.setDate(t.getDate()-30);const{data:c,error:l}=await v.from("site_visitors").select("page_url, traffic_source, time_on_page, scroll_depth, referrer_url").gte("visited_at",t.toISOString()).limit(1e3);if(l)throw l;return c||[]}}),o=C.useMemo(()=>n.filter(t=>t.traffic_source==="Organic Search"),[n]),x=C.useMemo(()=>{const t={};for(const c of o){const l=c.page_url||"/";t[l]||(t[l]={visits:0,totalTime:0,totalScroll:0}),t[l].visits++,t[l].totalTime+=c.time_on_page||0,t[l].totalScroll+=c.scroll_depth||0}return Object.entries(t).map(([c,l])=>({page:c,visits:l.visits,avgTime:Math.round(l.totalTime/l.visits),avgScroll:Math.round(l.totalScroll/l.visits)})).sort((c,l)=>l.visits-c.visits).slice(0,15)},[o]),p=C.useMemo(()=>{const t={};for(const c of o){const l=c.page_url||"/";t[l]||(t[l]={total:0,bounced:0}),t[l].total++,(c.scroll_depth||0)<20&&(c.time_on_page||0)<10&&t[l].bounced++}return Object.entries(t).filter(([c,l])=>l.total>=3).map(([c,l])=>({page:c,visits:l.total,bounceRate:Math.round(l.bounced/l.total*100)})).filter(c=>c.bounceRate>60).sort((c,l)=>l.bounceRate-c.bounceRate).slice(0,10)},[o]),A=C.useMemo(()=>{const t={};for(const c of n){const l=c.traffic_source||"Unknown";t[l]=(t[l]||0)+1}return Object.entries(t).map(([c,l])=>({source:c,count:l})).sort((c,l)=>l.count-c.count)},[n]);return h?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(P,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[{label:"Total Visits (30d)",value:n.length,color:""},{label:"Organic Search Visits",value:o.length,color:"text-success"},{label:"Organic Share",value:`${n.length>0?Math.round(o.length/n.length*100):0}%`,color:""},{label:"Organic Landing Pages",value:x.length,color:""}].map(t=>e.jsx(b,{className:"cursor-pointer transition-all hover:ring-2 hover:ring-primary/30",children:e.jsxs(w,{className:"pt-6",children:[e.jsx(I,{size:"md",className:t.color,children:t.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.label})]})},t.label))}),e.jsxs(b,{children:[e.jsx($,{children:e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"})," Traffic Sources (30d)"]}
1)}),e.jsx(w,{children:e.jsx("div",{className:"space-y-2",children:A.map(({source:t,count:c})=>e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{children:t}),e.jsx("span",{className:"text-muted-foreground",children:c})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full",style:{width:`${c/n.length*100}%`}})})]})},t))})})]}),e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5"})," Top Organic Landing Pages"]}),e.jsx(q,{children:"Pages receiving the most organic search traffic in the last 30 days."})]}),e.jsx(w,{children:x.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(he,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"No organic traffic data yet."})]}):e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{children:"Page"}),e.jsx(m,{className:"text-right",children:"Visits"}),e.jsx(m,{className:"text-right",children:"Avg Time (s)"}),e.jsx(m,{className:"text-right",children:"Avg Scroll %"})]})}),e.jsx(U,{children:x.map(t=>e.jsxs(_,{children:[e.jsx(u,{className:"font-mono text-xs",children:t.page}),e.jsx(u,{className:"text-right font-medium",children:t.visits}),e.jsxs(u,{className:"text-right",children:[t.avgTime,"s"]}),e.jsxs(u,{className:"text-right",children:[t.avgScroll,"%"]})]},t.page))})]})})]}),p.length>0&&e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"h-5 w-5 text-warning"})," High Bounce Organic Pages"]}),e.jsx(q,{children:"Pages with organic traffic but high bounce rates â potential content quality issues."})]}),e.jsx(w,{children:e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{children:"Page"}),e.jsx(m,{className:"text-right",children:"Visits"}),e.jsx(m,{className:"text-right",children:"Bounce Rate"})]})}),e.jsx(U,{children:p.map(t=>e.jsxs(_,{children:[e.jsx(u,{className:"font-mono text-xs",children:t.page}),e.jsx(u,{className:"text-right",children:t.visits}),e.jsx(u,{className:"text-right",children:e.jsxs(g,{variant:t.bounceRate>80?"destructive":"outline",children:[t.bounceRate,"%"]})})]},t.page))})]})})]})]})}const de=["incommand.ai","scoro.com","accelo.com","kantata.com","productive.io","bigtime.net","harvest.com"];function Ps(){const[n,h]=C.useState(""),[o,x]=C.useState("all"),[p,A]=C.useState("all"),{data:t=[],isLoading:c}=Ee(),{data:l=[],isLoading:B}=De(),S=Ge(),r=Ve(),j=C.useMemo(()=>{const a={};for(const L of l){const R=`${L.domain}_${L.metric_type}`;a[R]||(a[R]=L)}return a},[l]),k=j["incommand.ai_all_metrics"]?.metric_data?.domain_rating??j["incommand.ai_domain_rating"]?.metric_data,i=typeof k=="number"?k:typeof k?.domain_rating=="number"?k.domain_rating:null;j["incommand.ai_metrics"]?.metric_data;const y=j["incommand.ai_all_metrics"]?.metric_data?.backlinks??j["incommand.ai_backlinks"]?.metric_data,d=C.useMemo(()=>t.filter(a=>{const L=!n||a.keyword.toLowerCase().includes(n.toLowerCase()),R=o==="all"||a.tier===parseInt(o),H=p==="all"||a.category===p;return L&&R&&H}),[t,n,o,p]),z=C.useMemo(()=>{const a=new Set(t.map(L=>L.category).filter(Boolean));return Array.from(a).sort()},[t]),pe=()=>{S.mutate({action:"all_metrics",domains:de})},je=()=>{S.mutate({action:"domain_rating",domain:"incommand.ai"})},ye=()=>{S.mutate({action:"organic_keywords",domain:"incommand.ai"})},fe=()=>{S.mutate({action:"backlinks_stats",domain:"incommand.ai"})},be=a=>a?a<=3?e.jsx(g,{className:"bg-success text-white",children:a}):a<=10?e.jsx(g,{className:"bg-success text-white",children:a}):a<=20?e.jsx(g,{className:"bg-warning text-white",children:a}):a<=50?e.jsx(g,{className:"bg-warning text-white",children:a}):e.jsx(g,{variant:"secondary",children:a}):e.jsx(g,{variant:"outline",children:"N/R"}),Ne=(a,L)=>{if(!a||!L)return null;const R=L-a;return R>0?e.jsxs("span",{className:"flex items-center gap-1 text-success text-xs font-medium",children:[e.jsx(Me,{className:"h-3 w-3"}),"+",R]}):R<0?e.jsxs("span",{className:"flex items-center gap-1 text-destructive text-xs font-medium",children:[e.jsx(Ue,{className:"h-3 w-3"}),R]}):e.jsx(Oe,{className:"h-3 w-3 text-muted-foreground"})},we=a=>{switch(a){case 1:return e.jsx(g,{variant:"default",className:"bg-primary",children:"T1"});case 2:return e.jsx(g,{variant:"secondary",children:"T2"});case 3:return e.jsx(g,{variant:"outline",children:"T3"});default:return e.jsx(g,{variant:"outline",children:"-"})}},ve=a=>{switch(a){case"low":return e.jsx(g,{className:"bg-success/20 text-success border-success/30",children:"Low"});case"medium":return e.jsx(g,{className:"bg-warning/20 text-warning border-warning/30",children:"Med"});case"high":return e.jsx(g,{className:"bg-destructive/20 text-destructive border-destructive/30",children:"High"});default:return e.jsx(g,{variant:"outline",children:"-"})}},ke=t.length,_e=t.filter(a=>a.tier===1).length,Se=t.filter(a=>a.current_position&&a.current_position<=100).length,Ce=t.filter(a=>a.current_position&&a.current_position<=10).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"SEO
1Command Center"}),e.jsx("p",{className:"text-muted-foreground",children:"Track rankings, monitor competitors, and dominate search results."})]}),e.jsxs("div",{className:"flex gap-2",children:[t.length===0&&e.jsxs(N,{onClick:()=>r.mutate(),disabled:r.isPending,variant:"outline",children:[r.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ce,{className:"h-4 w-4 mr-2"}),"Seed Keywords"]}),e.jsxs(N,{onClick:pe,disabled:S.isPending,children:[S.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(G,{className:"h-4 w-4 mr-2"}),"Refresh All from Ahrefs"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs(b,{children:[e.jsx($,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Domain Rating"})}),e.jsxs(w,{children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(I,{size:"lg",children:i??"â"}),e.jsx("span",{className:"text-muted-foreground text-sm mb-1",children:"/100"})]}),i!==null&&e.jsx(ie,{value:i,className:"mt-2"}),e.jsxs(N,{variant:"ghost",size:"sm",className:"mt-2 -ml-2",onClick:je,disabled:S.isPending,children:[e.jsx(G,{className:"h-3 w-3 mr-1"})," Refresh"]})]})]}),e.jsxs(b,{children:[e.jsx($,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Tracked Keywords"})}),e.jsxs(w,{children:[e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(I,{size:"lg",children:ke})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[_e," quick wins ⢠",Se," ranking"]})]})]}),e.jsxs(b,{children:[e.jsx($,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Top 10 Rankings"})}),e.jsxs(w,{children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(I,{size:"lg",children:Ce}),e.jsx("span",{className:"text-muted-foreground text-sm mb-1",children:"keywords"})]}),e.jsxs(N,{variant:"ghost",size:"sm",className:"mt-2 -ml-2",onClick:ye,disabled:S.isPending,children:[e.jsx(G,{className:"h-3 w-3 mr-1"})," Refresh"]})]})]}),e.jsxs(b,{children:[e.jsx($,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Backlinks"})}),e.jsxs(w,{children:[e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(I,{size:"lg",children:y?.live?y.live.toLocaleString():"â"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:y?.ref_domains?`${y.ref_domains.toLocaleString()} referring domains`:"Click refresh to fetch"}),e.jsxs(N,{variant:"ghost",size:"sm",className:"mt-2 -ml-2",onClick:fe,disabled:S.isPending,children:[e.jsx(G,{className:"h-3 w-3 mr-1"})," Refresh"]})]})]})]}),e.jsxs(Te,{defaultValue:"keywords",className:"space-y-4",children:[e.jsxs(Pe,{className:"flex-wrap",children:[e.jsxs(O,{value:"keywords",children:[e.jsx(oe,{className:"h-4 w-4 mr-2"})," Keywords"]}),e.jsxs(O,{value:"content",children:[e.jsx(ue,{className:"h-4 w-4 mr-2"})," Content Gaps"]}),e.jsxs(O,{value:"links",children:[e.jsx(ee,{className:"h-4 w-4 mr-2"})," Internal Links"]}),e.jsxs(O,{value:"visitors",children:[e.jsx(he,{className:"h-4 w-4 mr-2"})," Visitor Intel"]}),e.jsxs(O,{value:"competitors",children:[e.jsx(J,{className:"h-4 w-4 mr-2"})," Competitors"]}),e.jsxs(O,{value:"indexing",children:[e.jsx(W,{className:"h-4 w-4 mr-2"})," Indexing"]}),e.jsxs(O,{value:"history",children:[e.jsx(ge,{className:"h-4 w-4 mr-2"})," History"]})]}),e.jsxs(E,{value:"keywords",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-sm",children:[e.jsx(Fe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(me,{placeholder:"Search keywords...",value:n,onChange:a=>h(a.target.value),className:"pl-9"})]}),e.jsxs(ae,{value:o,onValueChange:x,children:[e.jsx(re,{className:"w-[130px]",children:e.jsx(ne,{placeholder:"All Tiers"})}),e.jsxs(le,{children:[e.jsx(D,{value:"all",children:"All Tiers"}),e.jsx(D,{value:"1",children:"Tier 1 (Quick Wins)"}),e.jsx(D,{value:"2",children:"Tier 2 (Strategic)"}),e.jsx(D,{value:"3",children:"Tier 3 (Long-term)"})]})]}),e.jsxs(ae,{value:p,onValueChange:A,children:[e.jsx(re,{className:"w-[200px]",children:e.jsx(ne,{placeholder:"All Categories"})}),e.jsxs(le,{children:[e.jsx(D,{value:"all",children:"All Categories"}),z.map(a=>e.jsx(D,{value:a,children:a},a))]})]})]}),c?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(P,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):d.length===0?e.jsx(b,{children:e.jsxs(w,{className:"py-12 text-center",children:[e.jsx(oe,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Keywords Tracked"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Seed 37 pre-researched keywords from your competitor analysis to start tracking."}),e.jsxs(N,{onClick:()=>r.mutate(),disabled:r.isPending,children:[r.isPending?e.jsx(P,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ce,{className:"h-4 w-4 mr-2"}),"Seed Keywords"]})]})}):e.jsx(b,{children:e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{children:"Keyword"}),e.jsx(m,{className:"text-center",children:"Tier"}),e.jsx(m,{className:"text-center",children:"Position"}),e.jsx(m,{className:"text-center",children:"Change"}),e.jsx(m,{className:"text-right",children:"Volume"}),e.jsx(m,{className:"text-center",children:"KD"}),e.jsx(m,{children:"Category"}),e.jsx(m,{children:"Target URL"})]})}),e.jsx(U,{children:d.map(a=>e.jsxs(_,{children:[e.jsx(u,{className:"font-medium",children:a.keyword}),e.jsx(u,{className:"text-center",children:we(a.tier)}),e.jsx(u,{className:"text-center",children:be(a.current_position)}),e.jsx(u,{className:"text-center",children:Ne(a.current_position,a.previous_position)}),e.jsx(u,{className:"text-right",children:a.search_volume?.toLocaleStr
1ing()??"â"}),e.jsx(u,{className:"text-center",children:ve(a.difficulty)}),e.jsx(u,{children:e.jsx("span",{className:"text-xs text-muted-foreground",children:a.category})}),e.jsx(u,{children:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:a.target_url})})]},a.id))})]})})]}),e.jsx(E,{value:"content",className:"space-y-4",children:e.jsx(We,{})}),e.jsx(E,{value:"links",className:"space-y-4",children:e.jsx(Je,{})}),e.jsx(E,{value:"visitors",className:"space-y-4",children:e.jsx(Ye,{})}),e.jsx(E,{value:"competitors",className:"space-y-4",children:e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-5 w-5"})," Competitor Domain Ratings"]}),e.jsx(q,{children:'Compare your domain authority against competitors. Click "Refresh All" to fetch latest data.'})]}),e.jsx(w,{children:B?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(P,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"space-y-3",children:de.map(a=>{const R=(j[`${a}_all_metrics`]?.metric_data?.domain_rating??j[`${a}_domain_rating`]?.metric_data)?.domain_rating??null,H=a==="incommand.ai";return e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${H?"bg-primary/10 border border-primary/20":"bg-muted/30"}`,children:[e.jsx("div",{className:"flex-1",children:e.jsxs("span",{className:`font-medium ${H?"text-primary":""}`,children:[a,H&&e.jsx(g,{className:"ml-2 bg-primary/20 text-primary",variant:"outline",children:"You"})]})}),e.jsx("div",{className:"w-48",children:e.jsx(ie,{value:R??0,className:"h-2"})}),e.jsx("div",{className:"w-12 text-right",children:e.jsx("span",{className:"font-bold",children:R??"â"})})]},a)})})})]})}),e.jsx(E,{value:"indexing",className:"space-y-4",children:e.jsx(He,{})}),e.jsx(E,{value:"history",className:"space-y-4",children:e.jsxs(b,{children:[e.jsxs($,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"})," Data Snapshots"]}),e.jsx(q,{children:"Historical Ahrefs data snapshots. Each refresh creates a new snapshot for trend tracking."})]}),e.jsx(w,{children:B?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(P,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):l.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(J,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:'No snapshots yet. Click "Refresh All from Ahrefs" to create the first one.'})]}):e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(_,{children:[e.jsx(m,{children:"Date"}),e.jsx(m,{children:"Domain"}),e.jsx(m,{children:"Metric Type"}),e.jsx(m,{children:"Status"})]})}),e.jsx(U,{children:l.map(a=>e.jsxs(_,{children:[e.jsx(u,{className:"font-mono text-sm",children:a.snapshot_date}),e.jsx(u,{children:a.domain}),e.jsx(u,{children:e.jsx(g,{variant:"outline",children:a.metric_type})}),e.jsx(u,{children:a.metric_data?.error?e.jsx(g,{variant:"destructive",children:a.metric_data.error}):e.jsx(g,{className:"bg-success/20 text-success",children:"OK"})})]},a.id))})]})})]})})]})]})}export{Ps 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.