var m=(t,n,e)=>new Promise((s,u)=>{var c=a=>{try{r(e.next(a))}catch(l){u(l)}},o=a=>{try{r(e.throw(a))}catch(l){u(l)}},r=a=>a.done?s(a.value):Promise.resolve(a.value).then(c,o);r((e=e.apply(t,n)).next())});import{m as I,cU as h,a3 as b,f as g,af as z,ac as F,ab as k,k as d,bz as A,r as p,cM as T,a as C,B as N,c as j,aH as S,c8 as D,aJ as f,o as w,aK as y,p as v,q as O,t as P,b6 as _,b as R,b2 as q,b3 as E,aW as U,b4 as V,b5 as H,j as J,b7 as $}from"./index.bde7963b.js";function K(t,n="value",e="change",s){const u=A(),c=u==null?void 0:u.emit,o=I({value:t[n]}),r=h(o),a=i=>{o.value=i};return b(()=>{o.value=t[n]}),[g({get(){return o.value},set(i){z(i,r.value)||(o.value=i,F(()=>{c==null||c(e,i,...k(d(s))||[])}))}}),a,r]}function L(t){const n=p(t),e=p(!1);let s;function u(){s&&window.clearInterval(s)}function c(){e.value=!1,u(),s=null}function o(){d(e)||!!s||(e.value=!0,s=setInterval(()=>{d(n)===1?(c(),n.value=t):n.value-=1},1e3))}function r(){n.value=t,c()}function a(){r(),o()}return T(()=>{r()}),{start:o,reset:r,restart:a,clear:u,stop:c,currentCount:n,isStart:e}}const M={value:{type:[Object,Number,String,Array]},count:{type:Number,default:60},beforeStartFunc:{type:Function,default:null}},W=C({name:"CountButton",components:{Button:N},props:M,setup(t){const n=p(!1),{currentCount:e,isStart:s,start:u,reset:c}=L(t.count),{t:o}=j(),r=g(()=>d(s)?o("component.countdown.sendText",[d(e)]):o("component.countdown.normalText"));b(()=>{t.value===void 0&&c()});function a(){return m(this,null,function*(){const{beforeStartFunc:l}=t;if(l&&D(l)){n.value=!0;try{(yield l())&&u()}finally{n.value=!1}}else u()})}return{handleStart:a,currentCount:e,loading:n,getButtonText:r,isStart:s}}});function x(t,n,e,s,u,c){const o=f("Button");return w(),y(o,_(t.$attrs,{disabled:t.isStart,onClick:t.handleStart,loading:t.loading}),{default:v(()=>[O(P(t.getButtonText),1)]),_:1},16,["disabled","onClick","loading"])}var B=S(W,[["render",x]]);const G={value:{type:String},size:{type:String,validator:t=>["default","large","small"].includes(t)},count:{type:Number,default:60},sendCodeApi:{type:Function,default:null}},Q=C({name:"CountDownInput",components:{CountButton:B},inheritAttrs:!1,props:G,setup(t){const{prefixCls:n}=R("countdown-input"),[e]=K(t);return{prefixCls:n,state:e}}});function X(t,n,e,s,u,c){const o=f("CountButton"),r=f("a-input");return w(),y(r,_(t.$attrs,{class:t.prefixCls,size:t.size,value:t.state}),q({addonAfter:v(()=>[J(o,{size:t.size,count:t.count,value:t.state,beforeStartFunc:t.sendCodeApi},null,8,["size","count","value","beforeStartFunc"])]),_:2},[E(Object.keys(t.$slots).filter(a=>a!=="addonAfter"),a=>({name:a,fn:v(l=>[U(t.$slots,a,V(H(l||{})))])}))]),1040,["class","size","value"])}var Y=S(Q,[["render",X]]);const nt=$(Y);$(B);export{nt as C,K as u};
