import{e as w}from"./vendor-ui-CGT0cG1n.js";import{v as x,aA as h,a4 as y,ab as C,j as b,aO as r,r as _,ax as u,X as g,q as B,ap as k,af as I,g as S}from"./vendor-core-BKehvho7.js";import{_ as T}from"./LoadingWrapper.vue_vue_type_script_setup_true_lang-kJcgjuK5.js";const q=x({inheritAttrs:!1,__name:"AuthCodeSendBtn",props:{type:{default:"primary"},disabled:{type:Boolean,default:!1},text:{default:""},countdownText:{default:""},duration:{default:60}},emits:["send","finish"],setup(o,{expose:d,emit:i}){const{t:c}=h(),a=o,s=i,e=I(0);let t=null;const f=S(()=>e.value>0?c(a.countdownText,{n:e.value.toString()}):a.text),l=()=>{e.value=a.duration,t=window.setInterval(()=>{e.value--,e.value<=0&&(clearInterval(t),t=null,s("finish"))},1e3)},p=async n=>{a.disabled||e.value>0||(n.start(),s("send",{end:n.end,startCountdown:l}))};return y(()=>{t&&(clearInterval(t),t=null)}),d({startCountdown:l,getCountdown:()=>e.value}),(n,A)=>(C(),b(u(T),null,{default:r(({instance:m,loading:v})=>[_(u(w),g(n.$attrs,{type:o.type??"default",loading:v,disabled:o.disabled||e.value>0,class:"whitespace-nowrap",onClick:$=>p(m)}),{default:r(()=>[B(k(f.value),1)]),_:1},16,["type","loading","disabled","onClick"])]),_:1}))}});export{q as _};
