1import{eo as j,dM as o,dC as e,aE as u,aB as x,v,aL as N,aH as k,dH as p,ed as r,e0 as S}from"./index-DxZC4wz5.js";import{S as E}from"./SiteShell--Ab6qTyv.js";import"./Footer-CkLLfwWT.js";import"./menu-BnHDQWbq.js";import"./Logo-m6omsZqH.js";import"./StickySignUpCTA-RLvwsABK.js";function C(){try{const s=new URLSearchParams(window.location.search).get("redirect");if(s&&s.startsWith("/")&&!s.startsWith("//"))return s}catch{}return"/dashboard"}function L(){try{const s=new URLSearchParams(window.location.search).get("email");if(s&&/.+@.+\..+/.test(s))return s}catch{}return""}function O(){const s=j(),[n,i]=o.useState(!1),[a,h]=o.useState(L),[g,f]=o.useState(!1),[d,c]=o.useState(null);async function b(){if(!a){r.error("Enter your email above first.");return}const{error:t}=await p.resetPasswordForEmail(a,{redirectTo:`${window.location.origin}/reset-password`});if(t){r.error(t.message);return}r.success("Check your inbox for a reset link.")}async function w(){if(!a){r.error("Enter your email above first.");return}i(!0);try{await S({data:{email:a}})}finally{i(!1)}f(!0),r.success("If that email is registered, a sign-in link is on its way.")}async function y(t){t.preventDefault();const m=new FormData(t.currentTarget);i(!0),c(null);const{error:l}=await p.signInWithPassword({email:String(m.get("email")||""),password:String(m.get("password")||"")});if(i(!1),l){c(l.message),r.error(l.message);return}s({to:C()})}return e.jsx(E,{children:e.jsxs("section",{className:"mx-auto max-w-md px-4 py-20 sm:px-6 lg:px-8",children:[e.jsx("h1",{className:"font-display text-3xl font-bold text-primary",children:"Sign in"}),e.jsxs("div",{className:"mt-5 rounded-2xl border border-emerald-200 bg-emerald-50 p-4 text-sm text-emerald-900",children:[e.jsx("p",{className:"font-semibold",children:"Welcome to OneBill's new dashboard."}),e.jsx("p",{className:"mt-1.5 leading-relaxed",children:"We're moving all of our customers over from OneBill.ie to OneBill.ai. Enter your email below and we'll send you a one-click sign-in link so you can explore your new dashboard. If you already set a password you can sign in with that instead."})]}),e.jsxs("form",{method:"post",onSubmit:y,className:"mt-5 space-y-4 rounded-2xl border border-border bg-card p-6 shadow-soft",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{htmlFor:"email",children:"Email"}),e.jsx(x,{id:"email",name:"email",type:"email",required:!0,autoComplete:"username",value:a,onChange:t=>h(t.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{htmlFor:"password",children:"Password"}),e.jsx(x,{id:"password",name:"password",type:"password",required:!0,autoComplete:"current-password"})]}),d&&e.jsxs("p",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive",children:[e.jsx("span",{className:"font-medium",children:d}),e.jsx("span",{className:"mt-1 block text-destructive/90",children:"Check your email and password, or use the sign-in link below."})]}),e.jsx(v,{type:"submit",size:"lg",disabled:n,"aria-busy":n,className:"w-full bg-accent text-accent-foreground hover:bg-accent/90",children:n?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"})," Signing in..."]}):"Sign in"}),e.jsx("div",{className:"relative py-1 text-center",children:e.jsx("span",{className:"bg-card px-2 text-xs text-muted-foreground",children:"or"})}),e.jsx("button",{type:"button",onClick:w,disabled:n,className:"w-full rounded-lg border border-border py-2.5 text-sm font-medium text-primary hover:bg-muted",children:"Email me a sign-in link"}),g&&e.jsx("p",{role:"status",className:"rounded-lg border border-emerald-200 bg-emerald-50 p-3 text-center text-sm text-emerald-900",children:"If that email is registered, weâve sent a sign-in link. Check your inbox (and spam folder)."}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"No password? Use the sign-in link, it logs you straight in."}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("button",{type:"button",onClick:b,className:"text-secondary underline",children:"Forgot password?"}),e.jsx(k,{to:"/plan-selection",className:"text-secondary underline",children:"Create account"})]})]})]})})}export{O as component};
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.