import { useState } from 'react'; import { Icon } from '@/components/ui/icon'; import { cn } from '@/lib/utils'; import type { CheatOption } from '../protocol'; import { resolveOption } from '../protocol'; import type { ControlInternalProps } from './shared'; export const SelectionControl = ({ cheat, value, disabled, onChange }: ControlInternalProps) => { const options = (cheat.args.options ?? []).map(resolveOption); const [open, setOpen] = useState(false); if (options.length === 0) { return No options; } const selectedOption = findOption(options, String(value ?? options[0].value)) ?? options[0]; const handleToggle = () => { if (disabled) { return; } setOpen((current) => !current); }; const handleSelect = (option: CheatOption) => { onChange(option.value); setOpen(false); }; return (