1import{c as _t,d as kt,y as Ct,O as At,k as _,D as St,E as Et,e as a,bk as Mt,a as r,o as i,f as e,g as k,i as v,j as et,u as c,aj as Ot,dd as Pt,t as n,bc as m,G as Dt,w as st,bS as ot,b as Lt,F as O,r as P,m as Vt,n as $,cX as Bt,bt as It,B as Tt,N as $t}from"./index-CfV0kGTY.js";import{m as Nt}from"./vue3-apexcharts-BMI_dvvJ.js";import{_ as C}from"./StatCard.vue_vue_type_script_setup_true_lang-DuCm3v9z.js";import{_ as G}from"./BreakdownBars.vue_vue_type_script_setup_true_lang-mHdCwaI4.js";import{C as Rt}from"./chart-column-B3WNCP-Z.js";import{E as Ut}from"./eye-CZFIOV0F.js";import{Q as Gt}from"./quote-QA4Ig-y2.js";import{C as jt}from"./crown-BrYNfFSq.js";/** 2 * @license lucide-vue-next v0.554.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 Kt=_t("swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]),Ft={class:"flex-1 p-8 bg-surface-subtle overflow-y-auto h-full animate-in fade-in duration-500"},qt={class:"max-w-7xl mx-auto"},zt={class:"flex justify-between items-center mb-6 gap-4 flex-wrap"},Ht={class:"flex items-center gap-3"},Qt={key:0,class:"flex items-center gap-2 text-sm text-content-secondary"},Wt={key:0,class:"mb-6 flex items-center justify-between gap-4 rounded-xl border border-status-danger/40 bg-status-danger/10 px-4 py-3 text-sm text-status-danger"},Xt={class:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4 mb-6"},Jt={class:"flex flex-wrap items-center gap-3 mb-4"},Yt={value:""},Zt=["value"],te={class:"bg-surface-card rounded-2xl border border-line shadow-sm p-5 mb-6"},ee={class:"text-sm font-bold text-content-primary mb-2"},se={key:0,class:"text-sm text-content-secondary italic py-10 text-center"},oe={key:1,class:"aeo-chart"},ne={key:0,class:"text-xs text-content-tertiary mt-1"},le={key:2,class:"text-sm text-content-secondary italic py-10 text-center"},ae={class:"grid grid-cols-1 lg:grid-cols-3 gap-4 mb-6"},ie={key:1,class:"bg-surface-card rounded-2xl border border-line shadow-sm p-5 flex items-center justify-center text-center"},re={class:"bg-surface-card rounded-2xl border border-line shadow-sm mb-6 overflow-hidden"},ce={class:"flex items-center justify-between gap-3 px-5 py-4 border-b border-line-subtle flex-wrap"},ue={class:"flex items-center gap-1.5"},de=["onClick"],pe={class:"w-full text-sm"},be={class:"px-5 py-2.5 font-medium text-content-primary truncate max-w-[280px]"},ve={class:"px-3 py-2.5"},me={class:"px-3 py-2.5 text-content-secondary"},ye={class:"px-3 py-2.5 text-right tabular-nums text-content-primary font-semibold"},xe={class:"px-3 py-2.5 text-right tabular-nums text-content-secondary"},he={class:"px-5 py-2.5 text-right tabular-nums text-content-secondary"},ge={key:0},fe={class:"bg-surface-card rounded-2xl border border-line shadow-sm overflow-hidden"},we={class:"px-5 py-4 border-b border-line-subtle text-sm font-bold text-content-primary"},_e={class:"text-content-tertiary font-normal"},ke={class:"w-full text-sm"},Ce=["onClick"],Ae={class:"px-5 py-3"},Se={class:"font-semibold text-content-primary truncate max-w-[240px]"},Ee={class:"flex items-center gap-1.5 mt-1 flex-wrap"},Me={key:0,class:"text-[10px] font-semibold px-1.5 py-0.5 rounded bg-surface-hover text-content-tertiary"},Oe={class:"px-3 py-3"},Pe={class:"px-3 py-3 text-right tabular-nums text-content-secondary"},De={class:"px-3 py-3 text-right tabular-nums text-content-secondary"},Le={class:"px-5 py-3 text-right tabular-nums text-content-secondary"},Ve={key:0},j=8,Fe=kt({__name:"AdminAeoOverviewView",setup(Be){const nt=Nt,lt=$t(),K=Tt("selectAccount"),{dateParams:A}=Ct(),{isDark:at,chartOptions:it}=At(),w=_(null),S=_(!0),D=_(null),N=async()=>{S.value=!0,D.value=null;try{const t=new URLSearchParams;A.value.startDate&&t.set("startDate",A.value.startDate),A.value.endDate&&t.set("endDate",A.value.endDate);const s=await fetch(`/api/admin/aeo/overview?${t.toString()}`,{credentials:"include"});if(!s.ok)throw new Error(`Server returned ${s.status}`);w.value=await s.json()}catch(t){console.error("Failed to load AEO overview",t),D.value=t instanceof Error?t.message:"Request failed"}finally{S.value=!1}};St(N),Et(A,N);const g=a(()=>{var t;return((t=w.value)==null?void 0:t.accounts)??[]}),y=_("tag"),h=_(""),rt=["source","cohort","tag"],ct=a(()=>rt.includes(y.value)),F=a(()=>y.value!=="model"),L=t=>t.length?t.reduce((s,o)=>s+o,0)/t.length:null,q=t=>t?Bt[t]||t:"Unset",ut=t=>Mt[t]||t,z=t=>y.value==="source"?[q(t.source)]:y.value==="cohort"?[t.cohort||"Unset"]:t.tags.length?t.tags:["Untagged"],H=a(()=>{const t=g.value.find(s=>
6s.series.length);return t?t.series.map(s=>s.date):[]}),R=a(()=>{var Y,Z;const t=H.value,s=(l,d)=>t.length?t.map((u,b)=>{const x=l.map(f=>d(f,b)).filter(f=>f!=null);return x.length?Math.round(L(x)):null}):null;if(y.value==="engine"){const l=new Set;for(const u of g.value)for(const b of u.perEngine)l.add(b.engineKey);const d=new Map((((Y=w.value)==null?void 0:Y.citationsByEngine)??[]).map(u=>[u.engineKey,u.timesCited]));return[...l].map(u=>{const b=L(g.value.map(x=>{var f;return(f=x.perEngine.find(T=>T.engineKey===u))==null?void 0:f.pct}).filter(x=>x!=null));return{label:ut(u),logoKey:u,visibilityPct:b===null?null:Math.round(b),trackedCites:d.get(u)??0,series:s(g.value,(x,f)=>{var T,tt;return(tt=(T=x.perEngineSeries[u])==null?void 0:T[f])==null?void 0:tt.value})}}).sort((u,b)=>(b.visibilityPct??-1)-(u.visibilityPct??-1))}if(y.value==="model")return(((Z=w.value)==null?void 0:Z.citationsByModel)??[]).map(l=>({label:l.modelName,visibilityPct:null,trackedCites:l.timesCited,series:null}));const o=new Map,p=new Map,M=new Map;for(const l of g.value)for(const d of z(l)){if(l.visibilityPct!==null){const b=o.get(d)??[];b.push(l.visibilityPct),o.set(d,b)}p.set(d,(p.get(d)??0)+l.trackedCites);const u=M.get(d)??[];l.series.length&&u.push(l),M.set(d,u)}return[...new Set([...o.keys(),...p.keys()])].map(l=>{const d=L(o.get(l)??[]);return{label:l,visibilityPct:d===null?null:Math.round(d),trackedCites:p.get(l)??0,series:s(M.get(l)??[],(u,b)=>{var x;return(x=u.series[b])==null?void 0:x.value})}}).sort((l,d)=>(d.visibilityPct??-1)-(l.visibilityPct??-1))}),V=a(()=>R.value.map(t=>t.label)),U=a(()=>h.value?R.value.filter(t=>t.label===h.value):R.value),E=a(()=>ct.value&&h.value?g.value.filter(t=>z(t).includes(h.value)):g.value),dt=a(()=>E.value.map(t=>t.visibilityPct).filter(t=>t!==null)),pt=a(()=>{const t=L(dt.value);return t===null?"â":`${Math.round(t)}%`}),bt=a(()=>E.value.reduce((t,s)=>t+s.trackedCites,0)),B=a(()=>{var t;return((t=w.value)==null?void 0:t.ownershipTotals)??[]}),vt=a(()=>{var o;const t=B.value.reduce((p,M)=>p+M.timesCited,0),s=((o=B.value.find(p=>p.ownership==="owned"))==null?void 0:o.timesCited)??0;return t>0?`${Math.round(s/t*100)}%`:"â"}),mt=a(()=>{var t;return((t=B.value.find(s=>s.ownership==="competitor_owned"))==null?void 0:t.timesCited)??0}),yt=a(()=>{var t;return((t=w.value)==null?void 0:t.domains.length)??0}),Q={owned:"Owned",competitor_owned:"Competitor",third_party:"Third-party",unknown:"Unknown"},xt=a(()=>U.value.filter(t=>t.visibilityPct!==null).map(t=>({label:t.label,count:t.visibilityPct,logoKey:t.logoKey})).sort((t,s)=>s.count-t.count)),ht=a(()=>U.value.map(t=>({label:t.label,count:t.trackedCites,logoKey:t.logoKey})).sort((t,s)=>s.count-t.count)),gt=a(()=>B.value.map(t=>({label:Q[t.ownership]??t.ownership,count:t.timesCited}))),W=a(()=>U.value.filter(t=>t.series&&t.series.some(s=>s!=null)).slice(0,j).map(t=>({name:t.label,data:t.series}))),ft=a(()=>{const t=it.value;return{chart:{type:"line",toolbar:{show:!1},fontFamily:"Inter, sans-serif",animations:{enabled:!1},foreColor:t.label},stroke:{curve:"smooth",width:2},xaxis:{categories:H.value,type:"datetime",labels:{datetimeUTC:!0},tickAmount:8,axisBorder:{color:t.grid},axisTicks:{color:t.grid}},yaxis:{min:0,max:100,labels:{formatter:s=>`${Math.round(s)}%`}},legend:{position:"bottom"},tooltip:{theme:at.value?"dark":"light",x:{format:"dd MMM"},y:{formatter:s=>s==null?"â":`${s}%`}},grid:{borderColor:t.grid},dataLabels:{enabled:!1},markers:{size:0}}}),I=_(""),X={owned:"bg-status-success-soft text-status-success",competitor_owned:"bg-status-danger-soft text-status-danger",third_party:"bg-accent-soft text-accent-text",unknown:"bg-surface-hover text-content-tertiary"},J=a(()=>{var s;const t=((s=w.value)==null?void 0:s.domains)??[];return(I.value?t.filter(o=>o.ownership===I.value):t).slice(0,50)}),wt=t=>{K&&K({id:t.accountId,name:t.name,googleAdsId:null,facebookAdsId:null,ga4Id:null,shopifyId:null,instagramId:null,facebookPageId:null,gscId:null,tiktokId:null,gmbId:null,googleAdsCurrency:null,facebookAdsCurrency:null,shopifyCurrency:null,reportingCurrency:null,initialImportStatus:null}),lt.push("/aeo")};return(t,s)=>(i(),r("div",Ft,[e("div",qt,[e("div",zt,[s[4]||(s[4]=e("div",null,[e("h1",{class:"text-3xl font-bold text-content-primary"},"AEO Overview"),e("p",{class:"text-sm text-content-secondary mt-1"},"Visibility, citations & cited domains across all accounts")],-1)),e("div",Ht,[S.value?(i(),r("div",Qt,[v(c(Ot),{class:"w-4 h-4 animate-spin"}),s[3]||(s[3]=et(" Loading⦠",-1))])):k("",!0),v(Pt)])]),D.value?(i(),r("div",Wt,[e("span",null,"Failed to load AEO overview â "+n(D.value)+". The selected range may be too large.",1),e("button",{class:"shrink-0 rounded-lg border border-status-danger/40 px-3 py-1.5 font-semibold hover:bg-status-danger/10",onClick:N}," Retry ")])):k("",!0),e("div",Xt,[v(C,{label:"Accounts Measured",value:g.value.length?c(m)(g.value.length):"â",icon:c(Rt)},null,8,["value","icon"]),v(C,{label:"Avg Visibility",value:pt.value,tone:"accent",icon:c(Ut)},null,8,["value","icon"]),v(C,{label:"Tracked Citations",value:c(m)(bt.value),icon:c(Gt)},null,8,["value","icon"]),v(C,{label:"Owned Citation Share",value:vt.value,tone:"success",icon:c(jt)},null,8,["value","icon"]),v(C,{label:"Competitor Citations",value:c(m)(mt.value),tone:"danger",icon:c(Kt)},null,8,["value","icon"]),v(C,{label:"Unique Domains",value:c(m)(yt.value),icon:c(Dt)},null,8,["value","icon"])]),e("div",Jt,[s[6]||(s[6]=e("span",{class:"text-xs font-bold text-content-tertiary uppercase tracking-wider"},"Group by",-1)),st(e("select",{"onUpdate:modelValue":s[0]||(s[0]=o=>y.value=o),onChange:s[1]||(s[1]=o=>h.value=""),"aria-label":"Group by",class:"border border-line-strong rounded-lg px-3 py-2 text-sm text-content-primary bg-surface-card"},[...s[5]||(s[5]=[Lt('<option value="source">Source</option><option value="cohort">Cohort</option><option value="tag">Tag</option><option value="engine">LLM Engine</option><option value="model">LLM Model</option>',5)])],544),[[ot,y.value]]),st(e("select",{"onUpdate:modelValue":s[2]||(s[2]=o=>h.value=o),"aria-label":"Filter groups",class:"border border-line-strong rounded-lg px-3 py-2 text-sm text-content-primary bg-surface-card"},[e("option",Yt,"All "+n(c(m)(V.value.length))+" groups",1),(i(!0),r(O,null,P(V.value,o=>(i(),r("option",{key:o,value:o},n(o),9,Zt))),128))],512),[[ot,h.value]])]),e("div",te,[e("div",ee,"Visibility over time "+n(h.value?`· ${h.value}`:`· by ${y.value}`),1),F.value?W.value.length?(i(),r("div",oe,[v(c(nt),{type:"line",height:"320",options:ft.value,series:W.value},null,8,["options","series"]),!h.value&&V.value.length>j?(i(),r("p",ne," Showing top "+n(j)+" of "+n(V.value.length)+" groups â filter to a group to see the rest. ",1)):k("",!0)])):(i(),r("div",le,"No measurable visibility in this range.")):(i(),r("div",se," Visibility isn't measured per model â see the citation breakdowns below. "))]),e("div",ae,[F.value?(i(),Vt(G,{key:0,title:`Avg Visibility by ${y.value}`,items:xt.value,"bar-class":"bg-accent"},null,8,["title","items"])):(i(),r("div",ie,[...s[7]||(s[7]=[e("span",{class:"text-xs text-content-tertiary"},"Visibility isn't measured per model â group by engine for per-engine visibility.",-1)])])),v(G,{title:`Tracked Citations by ${y.value}`,items:ht.value,"bar-class":"bg-status-success"},null,8,["title","items"]),v(G,{title:"Citations by Ownership",items:gt.value,"bar-class":"bg-status-warning"},null,8,["items"])]),e("div",re,[e("div",ce,[s[8]||(s[8]=e("div",{class:"text-sm font-bold text-content-primary"},"Global Cited Domains",-1)),e("div",ue,[(i(),r(O,null,P([{v:"",l:"All"},{v:"owned",l:"Owned"},{v:"competitor_owned",l:"Competitor"},{v:"third_party",l:"Third-party"}],o=>e("button",{key:o.v,onClick:p=>I.value=o.v,class:$(["text-xs font-semibold px-2.5 py-1 rounded-lg border",I.value===o.v?"border-accent bg-accent-soft text-accent-text":"border-line-strong text-content-secondary hover:bg-surface-hover"])},n(o.l),11,de)),64))])]),e("table",pe,[s[10]||(s[10]=e("thead",null,[e("tr",{class:"text-[11px] font-bold uppercase tracking-wider text-content-tertiary border-b border-line-subtle"},[e("th",{class:"text-left px-5 py-2 font-bold"},"Domain"),e("th",{class:"text-left px-3 py-2 font-bold"},"Ownership"),e("th",{class:"text-left px-3 py-2 font-bold"},"Channel"),e("th",{class:"text-right px-3 py-2 font-bold"},"Cites"),e("th",{class:"text-right px-3 py-2 font-bold"},"URLs"),e("th",{class:"text-right px-5 py-2 font-bold"},"Accounts")])],-1)),e("tbody",null,[(i(!0),r(O,null,P(J.value,o=>(i(),r("tr",{key:o.hostname,class:"border-b border-line-subtle last:border-0 hover:bg-surface-hover"},[e("td",be,n(o.hostname),1),e("td",ve,[e("span",{class:$(["text-[10px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded",X[o.ownership]||X.unknown])},n(Q[o.ownership]??o.ownership),3)]),e("td",me,n(o.channelType),1),e("td",ye,n(c(m)(o.timesCited)),1),e("td",xe,n(c(m)(o.urlCount)),1),e("td",he,n(c(m)(o.accountCount)),1)]))),128)),!J.value.length&&!S.value?(i(),r("tr",ge,[...s[9]||(s[9]=[e("td",{colspan:"6",class:"px-5 py-8 text-center text-content-secondary italic"},"No citations in this range.",-1)])])):k("",!0)])])]),e("div",fe,[e("div",we,[s[11]||(s[11]=et(" Accounts ",-1)),e("span",_e,"("+n(c(m)(E.value.length))+")",1)]),e("table",ke,[s[13]||(s[13]=e("thead",null,[e("tr",{class:"text-[11px] font-bold uppercase tracking-wider text-content-tertiary border-b border-line-subtle"},[e("th",{class:"text-left px-5 py-2 font-bold"},"Account"),e("th",{class:"text-left px-3 py-2 font-bold"},"Visibility"),e("th",{class:"text-left px-3 py-2 font-bold w-[180px]"},"Trend"),e("th",{class:"text-right px-3 py-2 font-bold"},"Tracked"),e("th",{class:"text-right px-3 py-2 font-bold"},"Owned %"),e("th",{class:"text-right px-3 py-2 font-bold"},"Domains"),e("th",{class:"text-right px-5 py-2 font-bold"},"Runs")])],-1)),e("tbody",null,[(i(!0),r(O,null,P(E.value,o=>(i(),r("tr",{key:o.accountId,onClick:p=>wt(o),class:"border-b border-line-subtle last:border-0 hover:bg-surface-hover cursor-pointer"},[e("td",Ae,[e("div",Se,n(o.name),1),e("div",Ee,[o.source?(i(),r("span",Me,n(q(o.source)),1)):k("",!0),(i(!0),r(O,null,P(o.tags,p=>(i(),r("span",{key:p,class:"text-[10px] font-semibold px-1.5 py-0.5 rounded bg-accent-soft text-accent-text"},n(p),1))),128))])]),e("td",{class:$(["px-3 py-3 tabular-nums font-bold",o.visibilityPct!==null?"text-content-primary":"text-content-tertiary"])},n(o.visibilityPct!==null?`${Math.round(o.visibilityPct)}%`:"â"),3),e("td",Oe,[v(It,{points:o.series,theme:"light",fluid:"",height:32}
6,null,8,["points"])]),e("td",Pe,n(c(m)(o.trackedCites)),1),e("td",{class:$(["px-3 py-3 text-right tabular-nums",o.ownedShare!==null?"text-content-primary":"text-content-tertiary"])},n(o.ownedShare!==null?`${o.ownedShare}%`:"â"),3),e("td",De,n(c(m)(o.uniqueDomains)),1),e("td",Le,n(c(m)(o.runCount)),1)],8,Ce))),128)),!E.value.length&&!S.value?(i(),r("tr",Ve,[...s[12]||(s[12]=[e("td",{colspan:"7",class:"px-5 py-10 text-center text-content-secondary italic"},"No accounts with AEO data in this range.",-1)])])):k("",!0)])])])])]))}});export{Fe 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.