import * as React from "react"; import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"; import { type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; import { toggleVariants } from "@/components/ui/toggle"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { ProxyImage } from "@/components/custom/proxyImage"; import { Clock } from "lucide-react"; import clsx from "clsx"; import { formatDurationString } from "@/utils"; import { RawVideoInfo } from "@/types/video"; const PlaylistToggleGroupContext = React.createContext< VariantProps & { toggleType?: "single" | "multiple" } >({ size: "default", variant: "default", toggleType: "multiple", }); type PlaylistToggleGroupProps = | (Omit, "type"> & VariantProps & { type: "single", value?: string, onValueChange?: (value: string) => void }) | (Omit, "type"> & VariantProps & { type: "multiple", value?: string[], onValueChange?: (value: string[]) => void }); export const PlaylistToggleGroup = React.forwardRef< React.ComponentRef, PlaylistToggleGroupProps >(({ className, variant, size, children, type = "multiple", ...props }, ref) => { if (type === "single") { return ( {children} ); } return ( {children} ); }); PlaylistToggleGroup.displayName = "PlaylistToggleGroup"; export const PlaylistToggleGroupItem = React.forwardRef< React.ComponentRef, React.ComponentPropsWithoutRef & VariantProps & { video: RawVideoInfo; } >(({ className, children, variant, size, video, value, ...props }, ref) => { return (

{video.title}

{video.creator || video.channel || video.uploader || 'unknown'}

{video.duration_string ? formatDurationString(video.duration_string) : 'unknown'}
); }); PlaylistToggleGroupItem.displayName = "PlaylistToggleGroupItem";