"use client"; import React, { useState } from "react"; import { MacOSWindow } from "./macos-window"; import { useAuth, type TokenSource } from "@/lib/auth-context"; import { Key, ExternalLink, Sparkles, Eye, EyeOff, ArrowRight } from "lucide-react"; export function TokenScreen() { const { setAuth } = useAuth(); const [step, setStep] = useState<"choose" | "input">("choose"); const [selectedSource, setSelectedSource] = useState(null); const [tokenValue, setTokenValue] = useState(""); const [showToken, setShowToken] = useState(false); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleSourceSelect = (source: TokenSource) => { if (source === "demo") { setLoading(true); // Demo mode: token is managed server-side via HF_DEMO_TOKEN env var setAuth("__demo__", "demo"); return; } setSelectedSource(source); setStep("input"); }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!tokenValue.trim()) { setError("Please enter your API token"); return; } if (!selectedSource) return; setAuth(tokenValue.trim(), selectedSource); }; return (
{/* Background pattern */}
{step === "choose" ? (
{/* Logo and title */}
Y

Welcome to Yuuki Chat

Choose how to authenticate to start chatting

{/* Two big buttons */}
{/* Small demo button */}
) : ( { setStep("choose"); setError(""); setTokenValue(""); }} >
{selectedSource === "yuuki-api" ? ( ) : ( )}

{selectedSource === "yuuki-api" ? "Enter Yuuki API Token" : "Enter Hugging Face Token"}

{selectedSource === "yuuki-api" ? "Get your token from yuuki-api.vercel.app" : "Get your token from huggingface.co/settings/tokens"}

{ setTokenValue(e.target.value); setError(""); }} placeholder={selectedSource === "yuuki-api" ? "yk-xxxxxxxxxx" : "hf_xxxxxxxxxx"} className="w-full rounded-lg border border-border bg-background px-4 py-3 pr-10 text-sm text-foreground font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-ring/20 focus:border-foreground/30" autoFocus />
{error &&

{error}

}
)}
); }