'use client' import { useMemo, } from 'react' import useSWR from 'swr' import { SupportUploadFileTypes, } from '@/app/components/workflow/types' import { useWorkflowInit, } from './hooks' import { initialEdges, initialNodes, } from '@/app/components/workflow/utils' import Loading from '@/app/components/base/loading' import { FeaturesProvider } from '@/app/components/base/features' import type { Features as FeaturesData } from '@/app/components/base/features/types' import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants' import { fetchFileUploadConfig } from '@/service/common' import { useAppContext } from '@/context/app-context' import WorkflowWithDefaultContext from '@/app/components/workflow' import { WorkflowContextProvider, } from '@/app/components/workflow/context' import { createWorkflowSlice } from './store/workflow/workflow-slice' import WorkflowAppMain from './components/workflow-main' const WorkflowAppWithAdditionalContext = () => { const { data, isLoading, } = useWorkflowInit() const { isLoadingCurrentWorkspace, currentWorkspace } = useAppContext() const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig) const nodesData = useMemo(() => { if (data) return initialNodes(data.graph.nodes, data.graph.edges) return [] }, [data]) const edgesData = useMemo(() => { if (data) return initialEdges(data.graph.edges, data.graph.nodes) return [] }, [data]) if (!data || isLoading || isLoadingCurrentWorkspace || !currentWorkspace.id) { return (