"use strict";const e=require("vue"),u=require("../Shared/base-iCmnU-fv.js"),E=require("../Shared/Index.vue_vue_type_script_setup_true_lang-Dd2V82en.js"),y={key:0,class:"inputCaptcha-count"},S=e.defineComponent({name:"ClInputCaptcha",components:{ClInput:E._sfc_main},__name:"Index",props:{value:{},className:{},theme:{},placeholder:{},countdownMax:{},onSendBefore:{type:Function}},emits:["update:value","onChange","onKeyupEnter","onSend"],setup(i,{expose:d,emit:m}){const a=i,c=m,C=e.ref(null),n=e.reactive({value:"",isSend:!1,isCountdown:!1,countdown:a.countdownMax||120}),r={intervalCountdownId:null},f=e.computed(()=>{const t={"panel-input-captcha":!0,"box-width":!0};return a.className&&!u.CommonBase.isEmpty(a.className)&&a.className.split(" ").forEach(o=>{u.CommonBase.isEmpty(o)||(t[o]=!0)}),t[`inputCaptcha-theme-${a.theme||"default"}`]=!0,t}),h=e.computed(()=>({"inputCaptcha-send":!0,"inputCaptcha-send-ing":n.isCountdown})),v=t=>{c("update:value",t),c("onChange",t)},w=()=>{c("onKeyupEnter",n.value)},_=()=>{c("onSend")};e.onMounted(()=>{e.nextTick(()=>{})});const B=t=>{v(t)},k=()=>{w()},p=()=>{const{countdownMax:t=120}=a;let o=n.countdown;if(o===t){let s=!1;a.onSendBefore&&(s=a.onSendBefore(),s=u.CommonBase.isBoolean(s)?s:!1),n.isSend=s,s&&(_(),o=t,n.isCountdown=!0,n.countdown=o,r.intervalCountdownId=setInterval(()=>{o-=1;let l=!1;o<=0?(clearInterval(r.intervalCountdownId),o=t,l=!1):l=!0,n.countdown=o,n.isCountdown=l},1e3))}};return d({getValue:()=>u.CommonBase.trim(n.value)}),(t,o)=>{const s=e.resolveComponent("cl-input");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(f.value)},[e.createVNode(s,{ref_key:"refElInput",ref:C,theme:"bottomLine",isNumber:!0,decimal:0,isThousand:!1,value:n.value,"onUpdate:value":o[0]||(o[0]=l=>n.value=l),placeholder:i.placeholder,isClean:!0,onOnKeyupEnter:k,onOnChange:B},null,8,["value","placeholder"]),e.createElementVNode("div",{class:e.normalizeClass(h.value)},[n.isSend?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n.isCountdown?(e.openBlock(),e.createElementBlock("span",y,e.toDisplayString(n.countdown)+"秒后重发",1)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"inputCaptcha-btn",onClick:e.withModifiers(p,["stop"])},"重新发送"))],64)):(e.openBlock(),e.createElementBlock("span",{key:1,class:"inputCaptcha-btn",onClick:e.withModifiers(p,["stop"])},"发送验证码"))],2)],2)}}});module.exports=S;
//# sourceMappingURL=ClInputCaptcha.cjs.map
