"use client"; import { useState } from "react"; import { LightButton } from "@/design-system/base/button"; import { Input } from "@/design-system/base/input"; import { POPULAR_LANGUAGES } from "./constants"; import { useTranslations } from "next-intl"; interface LanguageSelectorProps { label: string; hint: string; value: string; onChange: (value: string) => void; } export function LanguageSelector({ label, hint, value, onChange }: LanguageSelectorProps) { const t = useTranslations("dictionary"); const [showCustomInput, setShowCustomInput] = useState(false); const [customLang, setCustomLang] = useState(""); const isPresetLanguage = POPULAR_LANGUAGES.some((lang) => lang.code === value); const handlePresetSelect = (code: string) => { onChange(code); setShowCustomInput(false); setCustomLang(""); }; const handleCustomToggle = () => { setShowCustomInput(!showCustomInput); if (!showCustomInput && customLang.trim()) { onChange(customLang.trim()); } }; const handleCustomChange = (newValue: string) => { setCustomLang(newValue); if (newValue.trim()) { onChange(newValue.trim()); } }; return (