import{E as e,G as t,Pt as n,Tt as r}from"./vue-vendor-DMUmTARL.js";import{n as i}from"./index-y6crcKNt.js";import{t as a}from"./password-transfer-crypto-C0RfvJMz.js";import{c as o,l as s}from"./user-CkKt4DA-.js";var c=()=>i({url:`/api/sso/list`,method:`get`}),l=e=>i({url:`/sso/login/exchange`,method:`post`,params:{code:e},config:{showDefaultMsg:!1}}),u=e=>a({url:`/sso/binding/confirm`,method:`post`,data:e,config:{showDefaultMsg:!1}},[`loginRequest.password`]),d=e=>i({url:`/sso/binding/passkey/start`,method:`post`,data:{bindingToken:e},config:{showDefaultMsg:!1}}),f=e=>i({url:`/sso/binding/passkey/confirm`,method:`post`,data:e,config:{showDefaultMsg:!1}}),p=e=>i({url:`/sso/login/second-factor`,method:`post`,data:e,config:{showDefaultMsg:!1}}),m=()=>({requireImageCaptcha:!1,requireTwoFactor:!1,requireTurnstile:!1,turnstileSiteKey:``,ipLocked:!1,retryAfterSeconds:0}),h=e=>typeof e==`string`?{requireImageCaptcha:e===`image`,requireTwoFactor:e===`2fa`,requireTurnstile:!1,turnstileSiteKey:``,ipLocked:!1,retryAfterSeconds:0}:!e||typeof e!=`object`?m():{requireImageCaptcha:e.requireImageCaptcha===!0,requireTwoFactor:e.requireTwoFactor===!0,requireTurnstile:e.requireTurnstile===!0,turnstileSiteKey:typeof e.turnstileSiteKey==`string`?e.turnstileSiteKey:``,ipLocked:e.ipLocked===!0,retryAfterSeconds:typeof e.retryAfterSeconds==`number`&&e.retryAfterSeconds>0?Math.floor(e.retryAfterSeconds):0};function g(i,a,c,l){let u=r(m()),d=r({}),f=r(0),p=!1,g=null,_=e(()=>u.value.requireImageCaptcha),v=e(()=>u.value.requireTwoFactor),y=e(()=>u.value.requireTurnstile),b=e(()=>u.value.turnstileSiteKey),x=e(()=>u.value.ipLocked),S=()=>{g&&=(clearInterval(g),null)},C=e=>{S(),f.value=Math.max(0,Math.floor(e||0)),u.value.ipLocked=f.value>0,!(f.value<=0)&&(g=setInterval(()=>{if(f.value<=1){S(),f.value=0,u.value.ipLocked=!1;return}--f.value},1e3))},w=(e,n)=>{p||a?.remember&&(!a.username||!a.password||e!==a.username||n!==a.password||!_.value&&!v.value||(t(()=>{c?.()}),p=!0))},T=(e,t)=>s(n(i)).then(n=>{let r=_.value;return u.value=h(n.data),u.value.retryAfterSeconds>0?C(u.value.retryAfterSeconds):u.value.ipLocked||C(0),!r&&_.value&&E(),_.value||(d.value={}),w(e,t),l?.(),u.value}),E=()=>o().then(e=>(d.value=e.data,e.data));return{verifyState:u,requireImageCaptcha:_,requireTwoFactor:v,requireTurnstile:y,turnstileSiteKey:b,isLoginLocked:x,loginRetryAfterSeconds:f,setLoginRetryAfterSeconds:C,loginVerifyCodeImgData:d,loadLoginVerifyMode:T,loadLoginVerifyCodeImgData:E,cleanup:()=>{S()}}}export{c as a,l as i,u as n,d as o,f as r,p as s,g as t};