import{b7 as se,u as ne,a as ae,aY as c,aT as m,b9 as g,c as u,N as f,a$ as l,b0 as y,ba as s,bc as P,b8 as te,r as _,aB as M,cf as ie,bf as O,cg as le,b_ as S,a_ as re,aX as ue}from"./index-xnhGKCfe.js";import{T as de}from"./TurnstileInline-BJynT3vQ.js";import{u as ce,L as r}from"./useLogin-B_VC5_H5.js";const me={class:"layout-warning"},ve={key:0,class:"login-section"},pe={key:0,class:"login-tabs"},fe={key:1,class:"verify-wrapper"},ge={class:"forget"},ye={class:"page-type"},be=["disabled"],Te=se({__name:"LogonComp",setup(ke){const{t:n}=ne(),{h5PhoneAreaCodeDictionary:R,isOpenUserOTPSMS:A,isOpenUserOTPEmail:I,loginEmail:b,loginMobile:T}=ae(),k=_(),w=_(),C=_(),B=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,U=o=>{if(!o)return;const e=o.includes("-")?o.split("-")[1]:o,t=Number(e);return Number.isNaN(t)?void 0:t},{loginForm:a,loginMode:v,loading:h,phoneArea:p,verifyCodeLoadingText:$,setLoginMode:L,setPhoneArea:F,handleSubmit:j,sendOTPCode:D,needTurnstileVerify:z,setTurnstileToken:G,setForm:X}=ce({phoneInputRef:w,initialMode:r.Password,isOnlyLogin:!0,onLoginSuccess:async()=>{window.location.reload()}}),Y=u(()=>b.value||T.value),q=u(()=>b.value&&T.value),x=o=>{a.value.loginType!==o&&(o==="Mobile"&&!T.value||o==="Email"&&!b.value||(X("loginType",o),L(r.Password)))},H=u(()=>h.value?n("t787"):n("t1")),J=o=>{G(o)},E=u(()=>{var t,i;if(a.value.loginType==="Email")return[{key:"userName",icon:"email",props:{placeholder:n("t39"),type:"text"},rule:{message:"Please enter a valid email.",validate:d=>B.test(`${d||""}`.trim())}}];const o=(i=(t=R.value)==null?void 0:t.find(d=>d.Area===p.value))==null?void 0:i.Len,e=U(o);return[{key:"userName",icon:"phone",prefix:!0,props:{placeholder:n("t782"),type:"number",maxlength:e},rule:{message:n("t783"),validate:d=>{var V;return(V=w.value)==null?void 0:V.validPhone(d)}}}]}),K=[{key:"password",icon:"lock",props:{placeholder:n("t5"),type:"password"},rule:{message:n("t5"),validate:o=>!!o}}],Q=u(()=>{const o=a.value.loginType==="Email";return[{key:"verifyCode",icon:o?"email":"safe",suffix:!0,props:{placeholder:n(o?"t14":"t786"),type:"text"},rule:{message:n("m13024"),validate:e=>!!e}}]}),W=u(()=>v.value===r.Password?[...E.value,...K]:v.value===r.OTP?[...E.value,...Q.value]:[]),N=u(()=>a.value.loginType==="Email"?!!I.value:!!A.value),Z=()=>{F(p.value)},ee=async()=>{var e;(e=k.value)!=null&&e.validate("userName")&&await D()};async function oe(o){var t,i;((t=k.value)==null?void 0:t.validate())&&(await j(o)||(i=C.value)==null||i.reset())}return(o,e)=>{const t=re;return m(),c("div",me,[Y.value?(m(),c("section",ve,[q.value?(m(),c("div",pe,[e[7]||(e[7]=l("div",{class:"tab-line"},null,-1)),l("div",{class:P(["tab",{active:s(a).loginType==="Mobile"}]),onClick:e[0]||(e[0]=()=>x("Mobile"))},y(s(n)("t2")),3),l("div",{class:P(["tab",{active:s(a).loginType==="Email"}]),onClick:e[1]||(e[1]=()=>x("Email"))},y(s(n)("t3")),3),l("div",{class:P(["tab-indicator",{right:s(a).loginType==="Email"}])},null,2)])):g("",!0),f(te,{ref_key:"formRef",ref:k,modelValue:s(a),"onUpdate:modelValue":e[3]||(e[3]=i=>M(a)?a.value=i:null),configs:W.value,"hide-submit":!0},ie({verifyCodeSuffix:O(()=>[l("button",{class:"send",onClick:ee,type:"button"},y(s($)),1)]),_:2},[s(a).loginType==="Mobile"?{name:"userNamePrefix",fn:O(()=>[f(le,{ref_key:"phoneInputRef",ref:w,modelValue:s(p),"onUpdate:modelValue":e[2]||(e[2]=i=>M(p)?p.value=i:null),onChangeArea:Z},null,8,["modelValue"])]),key:"0"}:void 0]),1032,["modelValue","configs"]),s(v)===s(r).Password&&s(z)?(m(),c("div",fe,[f(de,{ref_key:"turnstileRef",ref:C,onVerify:J},null,512)])):g("",!0),l("div",ge,[l("div",ye,[s(v)===s(r).Password&&N.value?(m(),c("div",{key:0,onClick:e[4]||(e[4]=()=>s(L)(s(r).OTP))},[e[8]||(e[8]=S(" OTP Login ",-1)),f(t,{name:"icon_enjoy_02","icon-class":"arrow"})])):s(v)===s(r).OTP&&N.value?(m(),c("div",{key:1,onClick:e[5]||(e[5]=()=>s(L)(s(r).Password))},[e[9]||(e[9]=S(" Password Login ",-1)),f(t,{name:"icon_enjoy_02","icon-class":"arrow"})])):g("",!0)])]),l("div",{class:"handle",onClick:e[6]||(e[6]=()=>oe())},[l("button",{disabled:s(h),class:"btn"},y(H.value),9,be)])])):g("",!0)])}}}),_e=ue(Te,[["__scopeId","data-v-57946a43"]]);export{_e as default};
