import * as React from "react"; import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"; import { type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; import { toggleVariants } from "@/components/ui/toggle"; import { VideoFormat } from "@/types/video"; import { determineFileType, formatBitrate, formatCodec, formatFileSize } from "@/utils"; import { Music, Video, File } from "lucide-react"; const FormatToggleGroupContext = React.createContext< VariantProps & { toggleType?: "single" | "multiple" } >({ size: "default", variant: "default", toggleType: "multiple", }); type FormatToggleGroupProps = | (Omit, "type"> & VariantProps & { type: "single", value?: string, onValueChange?: (value: string) => void }) | (Omit, "type"> & VariantProps & { type: "multiple", value?: string[], onValueChange?: (value: string[]) => void }); export const FormatToggleGroup = React.forwardRef< React.ComponentRef, FormatToggleGroupProps >(({ className, variant, size, children, type = "multiple", ...props }, ref) => { if (type === "single") { return ( {children} ); } return ( {children} ); }); FormatToggleGroup.displayName = "FormatToggleGroup"; export const FormatToggleGroupItem = React.forwardRef< React.ComponentRef, React.ComponentPropsWithoutRef & VariantProps & { format: VideoFormat } >(({ className, children, variant, size, format, value, ...props }, ref) => { const determineFileTypeIcon = (format: VideoFormat) => { const fileFormat = determineFileType(/*format.video_ext, format.audio_ext,*/ format.vcodec, format.acodec) switch (fileFormat) { case 'video+audio': return ( ) case 'video': return (