import{o as e}from"./chunk-CFjPhJqf.js";import{i as t,r as n}from"./bundle-mjs-DuVun8J2.js";import{c as r,t as i}from"./chunk-LFPYN7LY-Dq4q0Zxd.js";import{t as a}from"./button-DbPycOZU.js";import"./client-CfJnSvcd.js";import{Rt as o,Xt as s,at as c,hn as l,mn as u}from"./index-BZmR4FtW.js";var d=e(t(),1),f=n();function p(){let e=r(),t=o(),[n,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),g=u();async function _(n){if(n.preventDefault(),!g){h(`Microsoft Entra sign-in is not configured. Set VITE_ENTRA_CLIENT_ID and VITE_ENTRA_SCOPES before using this page.`);return}p(!0),h(null);try{await l(),t.capture(`user_logged_in`,{source:`login_page`}),e(`/app/workspace`,{replace:!0})}catch{h(`Microsoft sign-in did not complete. Try again, then verify your Entra tenant, redirect URI, and requested scopes.`)}finally{p(!1)}}return(0,f.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center bg-background px-4`,children:(0,f.jsx)(`div`,{className:`surface-raised-card w-full max-w-100 border border-border-subtle p-8`,children:(0,f.jsxs)(`form`,{onSubmit:_,className:`flex flex-col gap-5`,children:[(0,f.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2`,children:[(0,f.jsx)(c,{className:`w-8 h-3.75 text-foreground`}),(0,f.jsxs)(`div`,{className:`text-center`,children:[(0,f.jsx)(`h1`,{className:`text-foreground typo-h3`,children:`Sign in to Fleet RLM`}),(0,f.jsx)(`p`,{className:`text-muted-foreground mt-1 typo-caption`,children:`Continue with Microsoft Entra to open your RLM workspace`})]})]}),(0,f.jsx)(a,{type:`submit`,className:`w-full`,disabled:n||!g,children:n?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(s,{className:`size-4 animate-spin motion-reduce:animate-none`}),(0,f.jsx)(`span`,{className:`typo-label`,children:`Opening Microsoft sign-in...`})]}):(0,f.jsx)(`span`,{className:`typo-label`,children:`Continue with Microsoft`})}),m?(0,f.jsx)(`p`,{className:`text-center text-destructive typo-helper`,children:m}):null,(0,f.jsx)(`div`,{className:`text-center`,children:(0,f.jsx)(i,{to:`/signup`,className:`text-muted-foreground transition-colors hover:text-foreground typo-caption`,children:`Need access? Contact your workspace administrator`})}),(0,f.jsx)(`p`,{className:`text-center text-muted-foreground typo-helper`,children:g?`The same access token is reused for API and WebSocket runtime sessions.`:`Set the Entra client id, requested scopes, and optional authority override to enable Microsoft sign-in.`})]})})})}export{p as LoginPage};