import{defineComponent as w,ref as D,computed as S,createVNode as p}from"vue";import L from"../../_util/hooks/useRefs.mjs";import A from"../../_util/props-util/initDefaultProps.mjs";import{useTransitionDuration as M,defaultProps as T}from"./common.mjs";import{propTypes as V}from"./types.mjs";let v=0;function j(e){return+e.replace("%","")}function x(e){return Array.isArray(e)?e:[e]}function O(e,k,$,c,f=0,g){const t=50-c/2;let o=0,r=-t,i=0,s=-2*t;switch(g){case"left":o=-t,r=0,i=2*t,s=0;break;case"right":o=t,r=0,i=-2*t,s=0;break;case"bottom":r=t,s=2*t;break}const u=`M 50,50 m ${o},${r}
   a ${t},${t} 0 1 1 ${i},${-s}
   a ${t},${t} 0 1 1 ${-i},${s}`,a=Math.PI*2*t,n={stroke:$,strokeDasharray:`${k/100*(a-f)}px ${a}px`,strokeDashoffset:`-${f/2+e/100*(a-f)}px`,transition:"stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s"};return{pathString:u,pathStyle:n}}const Y=w({compatConfig:{MODE:3},name:"VCCircle",props:A(V,T),setup(e){v+=1;const k=D(v),$=S(()=>x(e.percent)),c=S(()=>x(e.strokeColor)),[f,g]=L();M(g);const t=()=>{const{prefixCls:o,strokeWidth:r,strokeLinecap:i,gapDegree:s,gapPosition:u}=e;let a=0;return $.value.map((n,y)=>{const d=c.value[y]||c.value[c.value.length-1],m=Object.prototype.toString.call(d)==="[object Object]"?`url(#${o}-gradient-${k.value})`:"",{pathString:b,pathStyle:h}=O(a,n,d,r,s,u);a+=n;const P={key:y,d:b,stroke:m,"stroke-linecap":i,"stroke-width":r,opacity:n===0?0:1,"fill-opacity":"0",class:`${o}-circle-path`,style:h};return p("path",{ref:f(y),...P},null)})};return()=>{const{prefixCls:o,strokeWidth:r,trailWidth:i,gapDegree:s,gapPosition:u,trailColor:a,strokeLinecap:n,strokeColor:y,...d}=e,{pathString:m,pathStyle:b}=O(0,100,a,r,s,u);delete d.percent;const h=c.value.find(l=>Object.prototype.toString.call(l)==="[object Object]"),P={d:m,stroke:a,"stroke-linecap":n,"stroke-width":i||r,"fill-opacity":"0",class:`${o}-circle-trail`,style:b};return p("svg",{class:`${o}-circle`,viewBox:"0 0 100 100",...d},[h&&p("defs",null,[p("linearGradient",{id:`${o}-gradient-${k.value}`,x1:"100%",y1:"0%",x2:"0%",y2:"0%"},[Object.keys(h).sort((l,C)=>j(l)-j(C)).map((l,C)=>p("stop",{key:C,offset:l,"stop-color":h[l]},null))])]),p("path",P,null),t().reverse()])}}});export{Y as default};
