import { useMemo } from 'react'; import { errorMessages, MarkerType, type EdgeMarker } from '@xyflow/system'; import { useStoreApi } from '../../hooks/useStore'; type SymbolProps = Omit; const ArrowSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => { const style = { strokeWidth, ...(color && { stroke: color }), }; return ; }; const ArrowClosedSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => { const style = { strokeWidth, ...(color && { stroke: color, fill: color }), }; return ; }; export const MarkerSymbols = { [MarkerType.Arrow]: ArrowSymbol, [MarkerType.ArrowClosed]: ArrowClosedSymbol, }; export function useMarkerSymbol(type: MarkerType | `${MarkerType}`) { const store = useStoreApi(); const symbol = useMemo(() => { const symbolExists = Object.prototype.hasOwnProperty.call(MarkerSymbols, type); if (!symbolExists) { store.getState().onError?.('009', errorMessages['error009'](type)); return null; } return MarkerSymbols[type]; }, [type]); return symbol; }