import { createFM } from "@/api/fm" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog" import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { Input } from "@/components/ui/input" import { useMediaQuery } from "@/hooks/useMediaQuery" import { copyToClipboard, fm, formatPath, fmWorker as worker } from "@/lib/utils" import { FMEntry, FMIdentifier, FMOpcode, FMWorkerData, FMWorkerOpcode, ModelCreateFMResponse, } from "@/types" import { ColumnDef } from "@tanstack/react-table" import { Row, flexRender } from "@tanstack/react-table" import { File, Folder } from "lucide-react" import { HTMLAttributes, JSX, useEffect, useRef, useState } from "react" import { useTranslation } from "react-i18next" import { toast } from "sonner" import { Button } from "./ui/button" import { TableCell, TableRow } from "./ui/table" import { Filepath } from "./xui/filepath" import { IconButton } from "./xui/icon-button" import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger, } from "./xui/overlayless-sheet" import { DataTable } from "./xui/virtulized-data-table" interface FMProps { wsUrl: string } const arraysEqual = (a: Uint8Array, b: Uint8Array) => { if (a.length !== b.length) return false for (let i = 0; i < a.length; i++) { if (a[i] !== b[i]) return false } return true } const FMComponent: React.FC = ({ wsUrl, ...props }) => { const { t } = useTranslation() const fmRef = useRef(null) const wsRef = useRef(null) useEffect(() => { return () => { wsRef.current?.close() } }, []) const [dOpen, setdOpen] = useState(false) const [uOpen, setuOpen] = useState(false) const columns: ColumnDef[] = [ { id: "type", header: () => {t("Type")}, accessorFn: (row) => row.type, cell: ({ row }) => (row.original.type == 0 ? : ), }, { header: () => {t("Name")}, id: "name", accessorFn: (row) => row.name, cell: ({ row }) => (
{row.original.name}
), size: 5000, }, { header: () => {t("Actions")}, id: "download", cell: ({ row }) => { return row.original.type == 0 ? ( { if (!dOpen) setdOpen(true) downloadFile(row.original.name) }} /> ) : (