import clsx from 'clsx'; import { useCallback } from 'react'; import { IconGraphCollapse, IconGraphCore, IconGraphExpand, IconGraphInputs, IconGraphInverse, IconGraphMaximize, IconGraphOutputs, IconPredecessor, IconReset } from '@/components/Icons'; import { CProps } from '@/components/props'; import MiniButton from '@/components/ui/MiniButton'; import { Graph } from '@/models/Graph'; interface ToolbarGraphSelectionProps extends CProps.Styling { value: number[]; onChange: (newSelection: number[]) => void; graph: Graph; isCore: (item: number) => boolean; isOwned?: (item: number) => boolean; emptySelection?: boolean; } function ToolbarGraphSelection({ className, graph, value: selected, isCore, isOwned, onChange, emptySelection, ...restProps }: ToolbarGraphSelectionProps) { const handleSelectCore = useCallback(() => { const core = [...graph.nodes.keys()].filter(isCore); onChange([...core, ...graph.expandInputs(core)]); }, [onChange, graph, isCore]); const handleSelectOwned = useCallback( () => (isOwned ? onChange([...graph.nodes.keys()].filter(isOwned)) : undefined), [onChange, graph, isOwned] ); const handleInvertSelection = useCallback( () => onChange([...graph.nodes.keys()].filter(item => !selected.includes(item))), [onChange, selected, graph] ); return (