PageSourceSearch

https://trybrain.io/assets/signup-Da-eKN0V.js

js trybrain.io collected 2026-10-02 01:58:28 UTC 5,899 bytes, 1 lines download raw bytes

1import{v as z,u as H,c as $,w as J,d as B,r as o,j as e,e as T,f as E,g as F,h as I,i as L,L as P,k as p,x as Q,a as _,I as y,t as c,s as Z}from"./index-DQ05VIVn.js";import{g as M}from"./platform-settings.functions-slJEVV3s.js";import{l as X}from"./index-CHf9UDQJ.js";import{u as ee}from"./auth-context-BDbMEkbx.js";import{B as se}from"./bundles-DzjaU-un.js";function te(u){if(!u)return null;const m=u.match(/^\/accept-invite\/([A-Za-z0-9._-]{8,})/);return m?m[1]:null}function oe(){const{user:u,loading:m}=ee(),{redirect:a,plan:i,cycle:x}=z.useSearch(),v=H(),t=te(a),q=$(J),W=$(M),{data:A}=B({queryKey:["trials-enabled"],queryFn:()=>W()}),U=!!A?.trials_enabled,{data:n,isLoading:D}=B({queryKey:["signup-invite",t],queryFn:()=>q({data:{token:t}}),enabled:!!t}),j=!!n&&n.status==="pending",g=j||!t,[w,b]=o.useState(""),[N,R]=o.useState(""),[S,G]=o.useState(""),[k,f]=o.useState(!1),[l,O]=o.useState(["sales","marketing"]),Y=(s,r)=>{O(d=>{const h=new Set(d);return r?h.add(s):h.delete(s),s==="sales_floor"&&r&&h.add("sales"),s==="sales"&&!r&&h.delete("sales_floor"),[...h]})},C=()=>{t||window.localStorage.setItem("brain-signup-bundles",JSON.stringify(l))};o.useEffect(()=>{n?.email&&b(n.email)},[n?.email]),o.useEffect(()=>{if(!m&&u){if(!t&&i){const s=new URLSearchParams({autostart:"1",plan:i,cycle:x??"yearly"});window.location.href=`/settings/billing?${s.toString()}`;return}a&&a.startsWith("/")?window.location.href=a:v({to:"/dashboard",replace:!0})}},[u,m,v,a,i,x,t]);const K=async s=>{if(s.preventDefault(),!g){c.error("This invite link is no longer valid.");return}if(!t&&l.length===0){c.error("Pick at least one bundle to start your trial.");return}f(!0),C();const r=a&&a.startsWith("/")?`${window.location.origin}${a}`:!t&&i?`${window.location.origin}/settings/billing?autostart=1&plan=${i}&cycle=${x??"yearly"}`:window.location.origin,{error:d}=await Z.auth.signUp({email:w,password:N,options:{emailRedirectTo:r,data:{full_name:S,...t?{}:{bundles:l}}}});f(!1),d?c.error(d.message):c.success("Verification email sent")},V=async()=>{if(!g){c.error("This invite link is no longer valid.");return}if(!t&&l.length===0){c.error("Pick at least one bundle to start your trial.");return}f(!0),C();const s=a&&a.startsWith("/")?`${window.location.origin}${a}`:!t&&i?`${window.location.origin}/settings/billing?autostart=1&plan=${i}&cycle=${x??"yearly"}`:window.location.origin,r=await X.auth.signInWithOAuth("google",{redirect_uri:s});r.error&&(f(!1),c.error(r.error.message??"Google sign-in failed"))};return t&&!D&&!j?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/30 p-4",children:e.jsxs(T,{className:"w-full max-w-md",children:[e.jsxs(E,{children:[e.jsx(F,{className:"text-2xl",children:"Invite unavailable"}),e.jsx(I,{children:n?`This invite is ${n.status}.`:"This invite link is invalid."})]}),e.jsx(L,{children:e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Already have an account?"," ",e.jsx(P,{to:"/login",className:"text-primary underline-offset-4 hover:underline",children:"Sign in"})]})})]})}):e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/30 p-4",children:e.jsxs(T,{className:"w-full max-w-2xl",children:[e.jsxs(E,{children:[e.jsx(F,{className:"text-2xl",children:"Sign up"}),e.jsx(I,{children:t&&n?`You're invited to ${n.workspace_name} as ${n.role}.`:t?"Checking your invite…":i?`Create your account to start your ${i} plan (${x??"yearly"}).`:U?"Choose what you want to use Brain for. Your selected bundles share one 14-day trial.":"Choose what you want to use Brain for."})]}),e.jsxs(L,{className:"space-y-4",children:[t?null:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(p,{children:"What do you want to use Brain for?"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Pick one or more bundles. You can add more later."})]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:se.map(s=>{const r=l.includes(s.code);return e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-md border border-border p-3 transition-colors hover:bg-muted/50",children:[e.jsx(Q,{checked:r,onCheckedChange:d=>Y(s.code,d===!0),"aria-label":s.name}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:s.name}),e.jsx("span",{className:"block text-xs leading-relaxed text-muted-foreground",children:s.tagline})]})]},s.code)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sales Floor includes Sales. Working seats are paid; view-only seats are free."})]}),e.jsx(_,{onClick:V,disabled:k||!g||!t&&l.length===0,variant:"outline",className:"w-full",children:"Continue with Google"}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsx("div",{className:"h-px flex-1 bg-border"})," or ",e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsxs("form",{onSubmit:K,className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{htmlFor:"name",children:"Name"}),e.jsx(y,{id:"name",value:S,onChange:s=>G(s.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{htmlFor:"email",children:"Email"}),e.jsx(y,{id:"email",type:"email",required:!0,value:w,onChange:s=>b(s.target.value),readOnly:!!n?.email})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(p,{htmlFor:"password",children:"Password"}),e.jsx(y,{id:"password",type:"password",required:!0,minLength:8,value:N,onChange:s=>R(s.target.value)})]}),e.jsx(_,{type:"submit",disabled:k||!g||!t&&l.length===0,className:"w-full",children:t?"Sign up":"Start 14-day trial"})]}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Already have an account?"," ",e.jsx(P,{to:"/login",className:"text-primary underline-offset-4 hover:underline",children:"Sign in"})]})]})]})})}export{oe 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.