import{i as e,t}from"./react-B8IZ02wI.js";import{At as n,H as r,Ht as i,Ot as a,V as o,W as s,et as c,ht as l,k as u,ot as d,vn as f}from"./button-DqbiydrF.js";import{Qt as p,bt as m,xt as h}from"./index-Bg7bo8aA.js";var g=h,_=m,v=e(t()),y=e=>{let{value:t,formatter:n,precision:i,decimalSeparator:a,groupSeparator:o=``,prefixCls:c,className:l,style:u}=e,d;if(r(n))d=n(t);else{let e=String(t),n=e.match(/^(-?)(\d*)(\.(\d+))?$/);if(!n||e===`-`)d=e;else{let e=n[1],t=n[2]||`0`,r=n[4]||``;t=t.replace(/\B(?=(\d{3})+(?!\d))/g,o),s(i)&&(r=r.padEnd(i,`0`).slice(0,i>0?i:0)),r&&=`${a}${r}`,d=[v.createElement(`span`,{key:`int`,className:`${c}-content-value-int`},e,t),r&&v.createElement(`span`,{key:`decimal`,className:`${c}-content-value-decimal`},r)]}}return v.createElement(`span`,{className:l,style:u},d)},b=e=>{let{componentCls:t,marginXXS:n,padding:r,colorTextDescription:i,titleFontSize:a,colorTextHeading:o,contentFontSize:s,fontFamily:c}=e;return{[t]:{...d(e),[`${t}-header`]:{paddingBottom:n,[`${t}-title`]:{color:i,fontSize:a}},[`${t}-skeleton`]:{paddingTop:r},[`${t}-content`]:{color:o,fontSize:s,fontFamily:c,[`${t}-content-value`]:{display:`inline-block`,direction:`ltr`},[`${t}-content-prefix, ${t}-content-suffix`]:{display:`inline-block`},[`${t}-content-prefix`]:{marginInlineEnd:n},[`${t}-content-suffix`]:{marginInlineStart:n}}}}},x=c(`Statistic`,e=>b(l(e,{})),e=>{let{fontSizeHeading3:t,fontSize:n}=e;return{titleFontSize:n,contentFontSize:t}}),S=v.forwardRef((e,t)=>{let{prefixCls:s,className:c,rootClassName:l,style:u,valueStyle:d,value:f=0,title:m,valueRender:h,prefix:g,suffix:_,loading:b=!1,formatter:S,precision:C,decimalSeparator:w=`.`,groupSeparator:T=`,`,onMouseEnter:E,onMouseLeave:D,styles:O,classNames:k,...A}=e,{getPrefixCls:j,direction:M,className:N,style:P,classNames:F,styles:I}=a(`statistic`),L=j(`statistic`,s),[R,z]=x(L),B={...e,decimalSeparator:w,groupSeparator:T,loading:b,value:f},[V,H]=o([F,k],[I,O],{props:B}),U=n(L,{[`${L}-rtl`]:M===`rtl`},N,c,l,V.root,R,z),W=n(`${L}-header`,V.header),G=n(`${L}-title`,V.title),K=n(`${L}-content`,V.content),q=n(`${L}-content-value`,V.value),J=n(`${L}-content-prefix`,V.prefix),Y=n(`${L}-content-suffix`,V.suffix),X=v.createElement(y,{decimalSeparator:w,groupSeparator:T,prefixCls:L,formatter:S,precision:C,value:f,className:q,style:H.value}),Z=v.useRef(null);v.useImperativeHandle(t,()=>({nativeElement:Z.current}));let Q=i(A,{aria:!0,data:!0});return v.createElement(`div`,{...Q,className:U,style:{...H.root,...P,...u},ref:Z,onMouseEnter:E,onMouseLeave:D},m&&v.createElement(`div`,{className:W,style:H.header},v.createElement(`div`,{className:G,style:H.title},m)),v.createElement(p,{paragraph:!1,loading:b,className:`${L}-skeleton`,active:!0},v.createElement(`div`,{className:K,style:{...d,...H.content}},g&&v.createElement(`span`,{className:J,style:H.prefix},g),r(h)?h(X):X,_&&v.createElement(`span`,{className:Y,style:H.suffix},_))))}),C=[[`Y`,1e3*60*60*24*365],[`M`,1e3*60*60*24*30],[`D`,1e3*60*60*24],[`H`,1e3*60*60],[`m`,1e3*60],[`s`,1e3],[`S`,1]];function w(e,t){let n=e,r=/\[[^\]]*]/g,i=(t.match(r)||[]).map(e=>e.slice(1,-1)),a=t.replace(r,`[]`),o=C.reduce((e,[t,r])=>{if(e.includes(t)){let i=Math.floor(n/r);return n-=i*r,e.replace(RegExp(`${t}+`,`g`),e=>{let t=e.length;return i.toString().padStart(t,`0`)})}return e},a),s=0;return o.replace(r,()=>{let e=i[s];return s+=1,e})}function T(e,t,n){let{format:r=``}=t,i=new Date(e).getTime(),a=Date.now();return w(Math.max(n?i-a:a-i,0),r)}var E=1e3/60;function D(e){return new Date(e).getTime()}var O=e=>{let{value:t,format:n=`HH:mm:ss`,onChange:r,onFinish:i,type:a,...o}=e,s=a===`countdown`,[c,l]=v.useState(null),d=f(()=>{let e=Date.now(),n=D(t);l({});let a=s?n-e:e-n;return r?.(a),s&&n<e?(i?.(),!1):!0});v.useEffect(()=>{let e,t=()=>{d()||window.clearInterval(e)},n=()=>{e=window.setInterval(t,E)},r=()=>{window.clearInterval(e)};return n(),()=>{r()}},[t,s]),v.useEffect(()=>{l({})},[]);let p=(e,t)=>c?T(e,{...t,format:n},s):`-`,m=e=>u(e,{title:void 0});return v.createElement(S,{...o,value:t,valueRender:m,formatter:p})},k=v.memo(e=>v.createElement(O,{...e,type:`countdown`}));S.Timer=O,S.Countdown=k;var A=S;export{_ as n,g as r,A as t};