import{d as e,c as a,b6 as t,aC as s,b7 as u,w as r,aH as n,e as l,f as i,m as o,i as d,n as c,r as m,y as v,z as p,F as g,G as f,h as x,p as h,O as b}from"./index-ip5gDR6L.js";/* empty css               *//* empty css               */import{_}from"./index.vue_vue_type_script_setup_true_lang-CCGboj8m.js";/* empty css                */import{f as y}from"./dashboard-C-Wq9kTO.js";import{E as j}from"./index-D5xppMej.js";import{E as w}from"./index-Ca1H-sCf.js";const C="easeOutExpo",S=e({__name:"index",props:{target:{default:0},duration:{default:2e3},autoStart:{type:Boolean,default:!0},decimals:{default:0},decimal:{default:"."},separator:{default:""},prefix:{default:""},suffix:{default:""},easing:{default:C},disabled:{type:Boolean,default:!1}},emits:["started","finished","paused","reset"],setup(e,{expose:m,emit:v}){const p=Number.EPSILON,g=e,f=v,x=(e,a,t)=>Number.isFinite(e)?e:t,h=(e,a,t)=>Math.max(a,Math.min(e,t)),b=a(()=>x(g.target,0,0)),_=a(()=>h(x(g.duration,0,2e3),100,6e4)),y=a(()=>h(x(g.decimals,0,0),0,10)),j=a(()=>{const e=g.easing;return e in t?e:C}),w=s(0),S=s(b.value),F=s(!1),N=s(!1),V=s(0),M=u(w,{duration:_,transition:a(()=>t[j.value]),onStarted:()=>{F.value=!0,N.value=!1,f("started",S.value)},onFinished:()=>{F.value=!1,N.value=!1,f("finished",S.value)}}),P=a(()=>{const e=N.value?V.value:M.value;if(!Number.isFinite(e))return`${g.prefix}0${g.suffix}`;const a=((e,a,t,s)=>{let u=a>0?e.toFixed(a):Math.floor(e).toString();if("."!==t&&u.includes(".")&&(u=u.replace(".",t)),s){const e=u.split(t);e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,s),u=e.join(t)}return u})(e,y.value,g.decimal,g.separator);return`${g.prefix}${a}${g.suffix}`}),$=()=>{N.value=!1,V.value=0},E=e=>{if(g.disabled)return;const a=void 0!==e?e:S.value;Number.isFinite(a)&&(S.value=a,(e=>{const a=N.value?V.value:M.value;return Math.abs(a-e)<p})(a)||(N.value&&(w.value=V.value,$()),c(()=>{w.value=a})))},O=()=>{(F.value||N.value)&&(w.value=0,$(),f("paused",0))};return r(b,e=>{g.autoStart&&!g.disabled?E(e):S.value=e},{immediate:g.autoStart&&!g.disabled}),r(()=>g.disabled,e=>{e&&F.value&&O()}),n(()=>{F.value&&O()}),m({start:E,pause:()=>{F.value&&!N.value&&(N.value=!0,V.value=M.value,w.value=V.value,f("paused",V.value))},reset:(e=0)=>{const a=x(e,0,0);w.value=a,S.value=a,$(),f("reset")},stop:O,setTarget:e=>{Number.isFinite(e)&&(S.value=e,!F.value&&!g.autoStart||g.disabled||E(e))},get isRunning(){return F.value},get isPaused(){return N.value},get currentValue(){return N.value?V.value:M.value},get targetValue(){return S.value},get progress(){const e=N.value?V.value:M.value,a=S.value;return 0===a?0===e?1:0:Math.abs(e/a)}}),(e,a)=>(i(),l("span",{class:d(["text-g-900 tabular-nums",F.value?"transition-opacity duration-300 ease-in-out":""])},o(P.value),3))}}),F={class:"art-card relative flex flex-col justify-center h-35 px-5 mb-5 max-sm:mb-4"},N={class:"text-g-700 text-sm"},V={class:"flex-c mt-1"},M={class:"absolute top-0 bottom-0 right-5 m-auto size-12.5 rounded-xl flex-cc bg-theme/10"},P=e({__name:"card-list",props:{range:{}},setup(e){const a=e,t=m([{des:"道具卡销量",icon:"ri:shopping-bag-3-line",startVal:0,duration:1e3,num:0,change:"+0%"},{des:"活动抽奖次数",icon:"ri:fire-line",startVal:0,duration:1e3,num:0,change:"+0%"},{des:"新用户注册数",icon:"ri:user-add-line",startVal:0,duration:1e3,num:0,change:"+0%"},{des:"用户总积分",icon:"ri:coin-line",startVal:0,duration:1e3,num:0,change:"+0%"}]);return r(()=>a.range,()=>{return e=this,s=null,u=function*(){try{const e=yield y(a.range);t[0].num=e.itemCardSales,t[0].change=e.itemCardChange,t[1].num=e.drawCount,t[1].change=e.drawChange,t[2].num=e.newUsers,t[2].change=e.newUserChange,t[3].num=e.totalPoints,t[3].change=e.pointsChange}catch(e){b.error("获取卡片数据失败")}},new Promise((a,t)=>{var r=e=>{try{l(u.next(e))}catch(a){t(a)}},n=e=>{try{l(u.throw(e))}catch(a){t(a)}},l=e=>e.done?a(e.value):Promise.resolve(e.value).then(r,n);l((u=u.apply(e,s)).next())});var e,s,u},{immediate:!0}),(e,a)=>{const s=S,u=_,r=j,n=w;return i(),v(n,{gutter:20,class:"flex"},{default:p(()=>[(i(!0),l(g,null,f(t,(e,t)=>(i(),v(r,{key:t,sm:12,md:6,lg:6},{default:p(()=>[x("div",F,[x("span",N,o(e.des),1),h(s,{class:"text-[26px] font-medium mt-2",target:e.num,duration:1300},null,8,["target"]),x("div",V,[a[0]||(a[0]=x("span",{class:"text-xs text-g-600"},"较上周",-1)),x("span",{class:d(["ml-1 text-xs font-semibold",[-1===e.change.indexOf("+")?"text-danger":"text-success"]])},o(e.change),3)]),x("div",M,[h(u,{icon:e.icon,class:"text-xl text-theme"},null,8,["icon"])])])]),_:2},1024))),128))]),_:1})}}});export{P as _};
