import { useState } from "react"; import { Button, Divider, Stack, Text, TextInput } from "@mantine/core"; import { IconLink, IconRotateClockwise, IconShieldLock } from "@tabler/icons-react"; import { AuthCard, AuthHeader } from "./AuthShell"; // extractToken pulls the invite token out of whatever the user pastes: a full // link (.../join?token=XXX), a bare "token=XXX", or just the token itself. function extractToken(input: string): string { const s = input.trim(); if (!s) return ""; const m = s.match(/[?&]token=([^&\s]+)/); if (m) return decodeURIComponent(m[1]); if (s.startsWith("token=")) return s.slice("token=".length); return s; } // Welcome is the entry screen on a device with no local identity. It offers the // two ways in: open an invite link (new account) or recover an existing account // from its 12-word seed. export function Welcome({ onJoinToken, onRecover, }: { onJoinToken: (token: string) => void; onRecover: () => void; }) { const [link, setLink] = useState(""); const token = extractToken(link); return ( } title="unibus" subtitle="Mensajería cifrada de extremo a extremo. Tu identidad vive en tu dispositivo." /> Tengo un enlace de invitación } value={link} onChange={(e) => setLink(e.currentTarget.value)} onKeyDown={(e) => e.key === "Enter" && token && onJoinToken(token)} /> Ya tengo una cuenta ); }