import{u as b,e as x,x as k}from"./links.w575jfOL.js";import{S as C,a as T}from"./LicenseConditions.D0P8U_He.js";import{b as D}from"./Caret.B8YmKvEY.js";import{C as M}from"./Tooltip.u2Cos2P_.js";import{G as A}from"./Graph.WtVg2p4K.js";import{a as G}from"./index.vo0_cz49.js";import{_ as L}from"./_plugin-vue_export-helper.BN1snXvA.js";import{v as c,o as a,c as d,F as B,J as N,a as l,x as V,t as _,k as g,l as S,C as p,b as f,G as m,j}from"./runtime-dom.esm-bundler.CWn9hmRK.js";const F={setup(){return{rootStore:b(),searchStatisticsStore:x()}},components:{CoreLoader:D,CoreTooltip:M,Graph:A,Statistic:C,SvgCircleQuestionMark:G},mixins:[T],data(){return{statisticsStrings:[{name:"impressions",label:this.$t.__("Search Impressions",this.$td),tooltip:this.$t.sprintf(this.$t.__("The %1$stotal number of times your website appeared in search results%2$s within the selected timeframe.",this.$td),"<strong>","</strong>")},{name:"clicks",label:this.$t.__("Total Clicks",this.$td),tooltip:this.$t.sprintf(this.$t.__("The %1$stotal number of clicks that your website received from search results%2$s within the selected timeframe.",this.$td),"<strong>","</strong>")},{name:"ctr",label:this.$t.__("Avg. CTR",this.$td),tooltip:this.$t.sprintf(this.$t.__("The %1$saverage click-through rate of your content in search results%2$s within the selected timeframe.",this.$td),"<strong>","</strong>")},{name:"position",label:this.$t.__("Avg. Position",this.$td),tooltip:this.$t.sprintf(this.$t.__("The %1$saverage position of your content in search results%2$s within the selected timeframe.",this.$td),"<strong>","</strong>")},{name:"keywords",label:this.$t.__("Total Keywords",this.$td),tooltip:this.$t.sprintf(this.$t.__("The %1$stotal number of keywords that your website ranks for in search results%2$s within the selected timeframe.",this.$td),"<strong>","</strong>")}]}},props:{statistics:{type:Array,default(){return[]}},statisticsData:{type:Object,default(){return null}},view:{type:String,default:"grid"},showGraph:{type:Boolean,default:!0}},computed:{seoStatistics(){const t=[];return this.statistics.forEach(s=>{const i=this.statisticsStrings.find(r=>r.name===s);i&&t.push({...i,data:this.getData(s)})}),t},style(){const t=[];switch(this.view){case"side-by-side":t.push({"grid-template-columns":`repeat(${this.statistics.length}, 1fr)`});break;case"grid":t.push({"grid-template-columns":`repeat(${Math.ceil(this.statistics.length/2)}, 1fr)`,"grid-template-rows":`repeat(${Math.ceil(this.statistics.length/2)}, 1fr)`});break}return t}},methods:{getData(t){var i,r,u,o,h;const s=this.statisticsData?this.statisticsData:(r=(i=this.searchStatisticsStore.data)==null?void 0:i.seoStatistics)==null?void 0:r.statistics;return s?{total:s[t]||0,difference:s.difference&&Math.abs(s.difference[t])||0,direction:s.difference&&0>s.difference[t]?"down":"up",chart:(h=(o=(u=this.searchStatisticsStore.data)==null?void 0:u.seoStatistics)==null?void 0:o.intervals)==null?void 0:h.map(n=>({x:k(new Date(n.date+" 00:00:00"),this.rootStore.aioseo.data.dateFormat),y:n[t]?n[t]:0}))}:{total:0,difference:0,direction:"up",chart:[]}}}},O={class:"statistics-title"},R=["innerHTML"],q={class:"statistics-current"},z={class:"statistics-current-total"},E={key:0,class:"statistics-chart"};function H(t,s,i,r,u,o){const h=c("svg-circle-question-mark"),n=c("core-tooltip"),$=c("statistic"),y=c("graph"),v=c("core-loader");return a(),d("div",{class:m(["aioseo-seo-statistics-overview",{[i.view]:!0,"hide-graph":!i.showGraph}]),style:j(o.style)},[(a(!0),d(B,null,N(o.seoStatistics,(e,w)=>(a(),d("div",{key:w,class:"statistics"},[l("div",{class:m([{blurred:r.searchStatisticsStore.loading.seoStatistics}])},[l("div",O,[V(_(e.label)+" ",1),e.tooltip?(a(),g(n,{key:0},{tooltip:S(()=>[l("span",{innerHTML:e.tooltip},null,8,R)]),default:S(()=>[p(h)]),_:2},1024)):f("",!0)]),l("div",q,[l("div",z,_(t.formatStatistic(e.name,e.data.total)),1),p($,{class:m(["statistics-current-difference","statistics-current-difference--"+e.data.direction]),difference:e.data.difference,type:e.name,showCurrent:!1,"tooltip-offset":"-90px,0"},null,8,["class","difference","type"])]),i.showGraph?(a(),d("div",E,[p(y,{series:[{name:e.label,data:e.data.chart}],height:60,preset:"overview","invert-y-axis":e.name==="position"},null,8,["series","invert-y-axis"])])):f("",!0)],2),r.searchStatisticsStore.loading.seoStatistics?(a(),g(v,{key:0,dark:""})):f("",!0)]))),128))],6)}const Y=L(F,[["render",H]]);export{Y as S};
