1import{u as f,h as p}from"./useAuth.D6M6u0jB.js";import{r as n,a as i}from"./errors.zArzgm8s.js";import{t as y}from"./translate.MQ91wSt8.js";import{u as b}from"./useSocialAuth.DaCd8Pka.js";import"./runtime-core.esm-bundler.Dph-xoGs.js";const w="[data-login-form]";async function D(){const{setState:c,checkGuestRoute:u}=f(),{initLoginPostMessageListener:l}=b(),t=document.querySelector(w),o=t.querySelector('button[type="submit"]');o.disabled=!1,await u(),l(),t.addEventListener("submit",async d=>{d.preventDefault(),o.disabled=!0,n(t);const m=new FormData(t);try{o.disabled=!0;const s=Object.fromEntries(m),r=await p(t.action,{method:"POST",body:JSON.stringify(s)});if(!r.ok){const a=await r.json();r.status===422||r.status===401?i(t,a.errors):i(t,{all:[a.message||y("An error occurred. Please try again")]});return}const e=await r.json();e.user&&c(e.user,e.token,e.expires_in),e.redirect_url?window.location.href=e.redirect_url:window.location.reload()}catch(s){console.error("Login request error:",s)}finally{o.disabled=!1}}),t.addEventListener("input",()=>{n(t)})}export{D as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.