import{U as g}from"./AnimatedNumber.f40bef48.js";import{_}from"./_plugin-vue_export-helper.eefbdd86.js";import{o as n,c as s,q as k,x as u,b as r,G as d,N as x,a,H as w,m as v,l as C,t as h,K as m}from"./runtime-dom.esm-bundler.c4caba60.js";const N={emits:["resize"],props:{targetLineCount:{default:1,type:Number},unit:{default:"px",type:String},min:{default:12,type:Number},max:{default:36,type:Number},constrainToElement:{type:[Boolean,Element],default(){return!1}},elementPadding:{type:Number,default(){return 0}}},data(){return{observer:null}},methods:{calculate(){const e=this.$el,i=this.unit==="px"?1:.05;let t=this.max;if(e.style.display="inline-block",e.style.lineHeight="1px",e.style.fontSize=t+this.unit,this.constrainToElement)for(;e.offsetWidth>this.constrainToElement.offsetWidth-this.elementPadding&&t>this.min;)t-=i,e.style.fontSize=t+this.unit;else for(;e.offsetHeight>this.targetLineCount&&t>this.min;)t-=i,e.style.fontSize=t+this.unit;this.$emit("resize",{size:t,unit:this.unit}),e.style.display=null,e.style.lineHeight=null}},mounted(){this.calculate(),"MutationObserver"in window&&this.observer===null&&(this.observer=new MutationObserver(this.calculate),this.observer.observe(this.$el,{subtree:!0,characterData:!0})),window.addEventListener("resize",this.calculate)},beforeUnmount:function(){this.observer.disconnect(),window.removeEventListener("resize",this.calculate)}};function z(e,i,t,f,y,l){return n(),s("span",null,[k(e.$slots,"default")])}const L=_(N,[["render",z]]),M={components:{UtilAnimatedNumber:g,UtilFitText:L},props:{parts:{type:Array,required:!0},label:{type:String,required:!0},total:{type:Number,required:!0},animatedNumber:{type:Boolean,default(){return!0}},maxTotal:{type:String,required:!1},isLabelColored:{type:Boolean,default(){return!1}}},computed:{getColorClass(){if(!this.maxTotal)return"";switch(!0){case 33>=this.total:return"red";case 66>=this.total:return"orange";default:return"green"}},getClass(){return`total-container-large ${this.getColorClass}`}}},S={class:"aioseo-donut-chart"},T={key:0,viewBox:"0 0 33.83098862 33.83098862",xmlns:"http://www.w3.org/2000/svg"},B=a("circle",{class:"aioseo-donut-chart-score__circle",stroke:"#e8e8eb","stroke-dasharray":"100","stroke-linecap":"round","stroke-width":2,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,-1),F=[B],E={key:1,viewBox:"0 0 33.83098862 33.83098862",xmlns:"http://www.w3.org/2000/svg"},$=["stroke-dasharray"],H=["stroke","stroke-dasharray"],q={class:"total-amount-wrapper"},A={class:"total-amount"},U={class:"total"},D=["innerHTML"],I={key:2,class:"total-max"};function P(e,i,t,f,y,l){const p=u("util-animated-number"),b=u("util-fit-text");return n(),s("div",S,[t.total===0?(n(),s("svg",T,F)):r("",!0),0<t.total?(n(),s("svg",E,[(n(!0),s(d,null,x(t.parts,(o,c)=>(n(),s(d,{key:c},[Math.round(o.ratio)&&c!==0?(n(),s("circle",{key:0,class:"aioseo-donut-chart-score__circle",stroke:"#FFFFFF","stroke-dasharray":`${Math.round(o.ratio)} ${parseFloat(99-Math.round(o.ratio))}`,"stroke-linecap":"round","stroke-width":2.5,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,8,$)):r("",!0),Math.round(o.ratio)?(n(),s("circle",{key:1,class:"aioseo-donut-chart-score__circle",stroke:o.color,"stroke-dasharray":`${Math.round(o.ratio)===100?100:Math.round(o.ratio)-1} 100`,"stroke-linecap":"round","stroke-width":2,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,8,H)):r("",!0)],64))),128))])):r("",!0),a("div",q,[a("div",A,[a("div",U,[w(b,{max:32,"constrain-to-element":e.$el,class:m(["total-container",l.getClass])},{default:v(()=>[t.animatedNumber?(n(),C(p,{key:0,number:parseInt(t.total)},null,8,["number"])):(n(),s("div",{key:1,innerHTML:parseInt(t.total)},null,8,D)),t.maxTotal?(n(),s("span",I," / "+h(parseInt(t.maxTotal)),1)):r("",!0)]),_:1},8,["constrain-to-element","class"])]),a("div",{class:m(["label",{[l.getColorClass]:t.isLabelColored}])},h(t.label),3)])])])}const G=_(M,[["render",P]]);export{G as C};
