import{g as r,s as l,p as c}from"./authShared.js";import"./index.js";import"./config.js";async function g(){const i=r("login"),t=r("email"),n=r("password"),o=r("status");if(!i||!t||!n){console.error("Login form not found");return}i.addEventListener("submit",async a=>{a.preventDefault(),o&&(o.textContent="Signing in...",o.style.cssText=`
        margin-top: 10px;
        font-size: 12px;
        padding: 8px 10px;
        border-radius: 6px;
        background: rgba(55,149,189,.1);
        color: #3795BD;
        border: 1px solid rgba(55,149,189,.3);
        display: block;
      `);const p=t.value.trim(),d=n.value;try{const{data:s,error:e}=await l.auth.signInWithPassword({email:p,password:d});if(e){console.error("Sign-in error:",e),o&&(o.textContent=`Error: ${e.message}`,o.style.cssText=`
            margin-top: 10px;
            font-size: 12px;
            padding: 8px 10px;
            border-radius: 6px;
            background: rgba(239,68,68,.1);
            color: #ef4444;
            border: 1px solid rgba(239,68,68,.3);
            display: block;
          `);return}await c(s.session),o&&(o.textContent="Signed in successfully! Redirecting...",o.style.cssText=`
          margin-top: 10px;
          font-size: 12px;
          padding: 8px 10px;
          border-radius: 6px;
          background: rgba(55,149,189,.1);
          color: #3795BD;
          border: 1px solid rgba(55,149,189,.3);
          display: block;
        `),setTimeout(()=>{window.close&&window.close()},1500)}catch(s){console.error("Login failed:",s),o&&(o.textContent="Login failed. Please try again.",o.style.cssText=`
          margin-top: 10px;
          font-size: 12px;
          padding: 8px 10px;
          border-radius: 6px;
          background: rgba(239,68,68,.1);
          color: #ef4444;
          border: 1px solid rgba(239,68,68,.3);
          display: block;
        `)}})}g();
//# sourceMappingURL=login.js.map
