import { useState } from 'react' import { VARIABLES, CATEGORIES } from '../engine/variables.js' import { PaletteCard } from './VariableCard.jsx' export function VariablePalette({ workspaceVarIds, onAddVariable }) { const [search, setSearch] = useState('') const [collapsed, setCollapsed] = useState({}) const toggleCategory = (cat) => setCollapsed(prev => ({ ...prev, [cat]: !prev[cat] })) const q = search.toLowerCase() const filtered = (varIds) => varIds.filter(id => { if (!q) return true const v = VARIABLES[id] return ( v.name.toLowerCase().includes(q) || v.symbol.toLowerCase().includes(q) || v.id.toLowerCase().includes(q) ) }) // Group vars by category const byCategory = {} for (const [id, v] of Object.entries(VARIABLES)) { if (!byCategory[v.category]) byCategory[v.category] = [] byCategory[v.category].push(id) } return ( ) }