'use client' import type { App } from '@/models/explore' import type { TryAppSelection } from '@/types/try-app' import { cn } from '@langgenius/dify-ui/cn' import { useSuspenseQuery } from '@tanstack/react-query' import { useId } from 'react' import { useTranslation } from 'react-i18next' import { trackEvent } from '@/app/components/base/amplitude' import AppIcon from '@/app/components/base/app-icon' import { systemFeaturesQueryOptions } from '@/features/system-features/client' import { AppModeEnum } from '@/types/app' import { AppTypeIcon } from '../../app/type-selector' export type AppCardProps = { app: App canCreate: boolean onCreate: () => void onTry: (params: TryAppSelection) => void isExplore?: boolean } const AppCard = ({ app, canCreate, onCreate, onTry, isExplore = true }: AppCardProps) => { const { t } = useTranslation() const { data: deploymentEdition } = useSuspenseQuery({ ...systemFeaturesQueryOptions(), select: ({ deployment_edition }) => deployment_edition, }) const nameId = useId() const descriptionId = useId() const { app: appBasicInfo } = app const canViewApp = deploymentEdition === 'CLOUD' const isClickable = isExplore && (canViewApp || canCreate) const handleTryApp = () => { trackEvent('preview_template', { template_id: app.app_id, template_name: appBasicInfo.name, template_mode: appBasicInfo.mode, template_categories: app.categories, page: 'explore', }) onTry({ appId: app.app_id, app }) } const handleCardClick = () => { if (canViewApp) { handleTryApp() return } if (canCreate) onCreate() } return (