var p=(a,c,n)=>new Promise((l,t)=>{var u=o=>{try{s(n.next(o))}catch(m){t(m)}},b=o=>{try{s(n.throw(o))}catch(m){t(m)}},s=o=>o.done?l(o.value):Promise.resolve(o.value).then(u,b);s((n=n.apply(a,c)).next())});import{b7 as N,bh as S,b6 as e,b8 as C,bi as v}from"./bootstrap-Bqxdt4iG.js";import{T as V}from"./auth-title-Cr5EWHYB.js";import{a1 as w,P as $,E as y,ap as P,aj as B,p as T,ai as L,an as E,ak as f,al as k,ax as h,ay as g,a9 as i,az as _,aR as A,L as D}from"../jse/index-index-BUJ_4tQs.js";const F={class:"text-muted-foreground"},R=w({name:"AuthenticationCodeLogin",__name:"code-login",props:{formSchema:{},loading:{type:Boolean,default:!1},loginPath:{default:"/auth/login"},title:{default:""},subTitle:{default:""},submitButtonText:{default:""},showBack:{type:Boolean,default:!0}},emits:["submit"],setup(a,{expose:c,emit:n}){const l=a,t=n,u=N(),[b,s]=S($({commonConfig:{hideLabel:!0,hideRequiredMark:!0},schema:y(()=>l.formSchema),showDefaultActions:!1}));function o(){return p(this,null,function*(){const{valid:r}=yield s.validate(),d=yield s.getValues();r&&t("submit",d)})}function m(){u.push(l.loginPath)}return c({getFormApi:()=>s}),(r,d)=>(B(),P("div",null,[T(V,null,{desc:f(()=>[_("span",F,[k(r.$slots,"subTitle",{},()=>[h(g(a.subTitle||i(e)("authentication.codeSubtitle")),1)])])]),default:f(()=>[k(r.$slots,"title",{},()=>[h(g(a.title||i(e)("authentication.welcomeBack"))+" 📲 ",1)])]),_:3}),T(i(b)),T(i(C),{class:A([{"cursor-wait":a.loading},"w-full"]),loading:a.loading,onClick:o},{default:f(()=>[k(r.$slots,"submitButtonText",{},()=>[h(g(a.submitButtonText||i(e)("common.login")),1)])]),_:3},8,["class","loading"]),a.showBack?(B(),L(i(C),{key:0,class:"mt-4 w-full",variant:"outline",onClick:d[0]||(d[0]=z=>m())},{default:f(()=>[h(g(i(e)("common.back")),1)]),_:1})):E("",!0)]))}}),x=6,H=w({name:"CodeLogin",__name:"code-login",setup(a){const c=D(!1),n=y(()=>[{component:"VbenInput",componentProps:{placeholder:e("authentication.mobile")},fieldName:"phoneNumber",label:e("authentication.mobile"),rules:v().min(1,{message:e("authentication.mobileTip")}).refine(t=>/^\d{11}$/.test(t),{message:e("authentication.mobileErrortip")})},{component:"VbenPinInput",componentProps:{codeLength:x,createText:t=>t>0?e("authentication.sendText",[t]):e("authentication.sendCode"),placeholder:e("authentication.code")},fieldName:"code",label:e("authentication.code"),rules:v().length(x,{message:e("authentication.codeTip",[x])})}]);function l(t){return p(this,null,function*(){console.log(t)})}return(t,u)=>(B(),L(i(R),{"form-schema":n.value,loading:c.value,onSubmit:l},null,8,["form-schema","loading"]))}});export{H as default};
