import"../chunks/DsnmJJEf.js";import{o as v}from"../chunks/D9fbApi8.js";import{p as L,t as T,a as A,b as G,i as S,d as i,c as $,$ as x,s as b,r as c}from"../chunks/qex-fw8l.js";import{s as D}from"../chunks/vzbhwc8t.js";import{h as E}from"../chunks/CoLYeqRS.js";import{g as r}from"../chunks/XKwVQUgR.js";import{b as s}from"../chunks/dG3E5dY6.js";import{p as d}from"../chunks/Dmsi5yYR.js";import{i as o}from"../chunks/dc0o8kHW.js";import{e as M}from"../chunks/CmkZtgn8.js";import{L as O}from"../chunks/BnIIe8z2.js";import{t as g}from"../chunks/HL7kq492.js";var y=$('<div class="flex min-h-screen items-center justify-center bg-background p-4"><div class="flex items-center gap-3 text-muted-foreground"><!> <span class="text-sm"> </span></div></div>');function V(_,N){L(N,!0);function I(){const t=d.url.searchParams.get("returnTo");return!!t&&t.startsWith("/")&&!t.startsWith("//")&&!/[\u0000-\u001F\u007F\\]/.test(t)?t:`${s}/`}function m(){g.error(o.t("ADMIN_NEXT.LOGIN.SSO_FAILED")),r(`${s}/login`)}v(async()=>{const t=d.url.searchParams,e=I();if(t.get("sso_error")){m();return}const l=t.get("code");if(!l){r(`${s}/login`);return}try{const n=await M(l);if(n.requires2fa&&n.challengeToken){sessionStorage.setItem("grav_sso_2fa",n.challengeToken),r(`${s}/login?returnTo=${encodeURIComponent(e)}`);return}g.success(o.t("ADMIN_NEXT.LOGIN.SIGNED_IN_SUCCESSFULLY")),r(e)}catch{m()}});var a=y();E("13s5ly6",t=>{S(e=>{x.title=e??""},[()=>o.t("ADMIN_NEXT.LOGIN.LOGIN_GRAV_ADMIN")])});var p=i(a),f=i(p);O(f,{size:18,class:"animate-spin"});var u=b(f,2),h=i(u,!0);c(u),c(p),c(a),T(t=>D(h,t),[()=>o.t("ADMIN_NEXT.LOGIN.SIGNING_IN")]),A(_,a),G()}export{V as component};
