'use client'; import clsx from 'clsx'; import { useIsProcessingOss } from '@/backend/oss/useIsProcessingOss'; import { IconAnimation, IconAnimationOff, IconDestroy, IconEdit2, IconExecute, IconFitImage, IconGrid, IconImage, IconLineStraight, IconLineWave, IconNewItem, IconReset, IconSave } from '@/components/Icons'; import BadgeHelp from '@/components/info/BadgeHelp'; import MiniButton from '@/components/ui/MiniButton'; import { HelpTopic } from '@/models/miscellaneous'; import { OperationType } from '@/models/oss'; import { useModificationStore } from '@/stores/modification'; import { useOSSGraphStore } from '@/stores/ossGraph'; import { PARAMETER } from '@/utils/constants'; import { prepareTooltip } from '@/utils/labels'; import { useOssEdit } from '../OssEditContext'; interface ToolbarOssGraphProps { onCreate: () => void; onDelete: () => void; onEdit: () => void; onExecute: () => void; onFitView: () => void; onSaveImage: () => void; onSavePositions: () => void; onResetPositions: () => void; } function ToolbarOssGraph({ onCreate, onDelete, onEdit, onExecute, onFitView, onSaveImage, onSavePositions, onResetPositions }: ToolbarOssGraphProps) { const controller = useOssEdit(); const { isModified } = useModificationStore(); const isProcessing = useIsProcessingOss(); const selectedOperation = controller.schema.operationByID.get(controller.selected[0]); const showGrid = useOSSGraphStore(state => state.showGrid); const edgeAnimate = useOSSGraphStore(state => state.edgeAnimate); const edgeStraight = useOSSGraphStore(state => state.edgeStraight); const toggleShowGrid = useOSSGraphStore(state => state.toggleShowGrid); const toggleEdgeAnimate = useOSSGraphStore(state => state.toggleEdgeAnimate); const toggleEdgeStraight = useOSSGraphStore(state => state.toggleEdgeStraight); const readyForSynthesis = (() => { if (!selectedOperation || selectedOperation.operation_type !== OperationType.SYNTHESIS) { return false; } if (selectedOperation.result) { return false; } const argumentIDs = controller.schema.graph.expandInputs([selectedOperation.id]); if (!argumentIDs || argumentIDs.length < 1) { return false; } const argumentOperations = argumentIDs.map(id => controller.schema.operationByID.get(id)!); if (argumentOperations.some(item => item.result === null)) { return false; } return true; })(); return (