'use client' import { useState, useEffect, useRef } from 'react' import type { Encoder, Decoder } from '@/lib/api' const ENCODERS: { value: Encoder; label: string }[] = [ { value: 'xlm-roberta-large', label: 'xlm-roberta-large' }, ] const DECODERS: { value: Decoder; label: string }[] = [ { value: 'gemma3', label: 'gemma-3-1b-it' }, { value: 'qwen3', label: 'Qwen3-4B-Instruct-2507' }, ] const MAX_CHARS = 10000 const LOADING_MESSAGES = [ '🏷️✍️ Annotating...', 'β³βš™οΈ Processing...', 'πŸ§ πŸ€”πŸ’­ Thinking...', 'πŸ”πŸ“Š Analyzing...', 'πŸ”€βž‘οΈπŸ˜„ Emojinizing...', ] interface Props { onSubmit: (encoder: Encoder, decoder: Decoder, text: string) => void onStop: () => void loading: boolean } export default function AnnotationForm({ onSubmit, onStop, loading }: Props) { const [encoder, setEncoder] = useState('xlm-roberta-large') const [decoder, setDecoder] = useState('gemma3') const [text, setText] = useState('') const [msgIdx, setMsgIdx] = useState(0) useEffect(() => { if (!loading) return setMsgIdx(0) const id = setInterval( () => setMsgIdx((i) => (i + 1) % LOADING_MESSAGES.length), 3000 ) return () => clearInterval(id) }, [loading]) function handleSubmit(e: React.FormEvent) { e.preventDefault() if (!text.trim()) return onSubmit(encoder, decoder, text) } return (
setEncoder(v as Encoder)} />
setDecoder(v as Decoder)} />