import {
  DropdownMenu as BaseDropdownMenu,
  DropdownMenuCheckboxItem as BaseDropdownMenuCheckboxItem,
  DropdownMenuContent as BaseDropdownMenuContent,
  DropdownMenuGroup as BaseDropdownMenuGroup,
  DropdownMenuItem as BaseDropdownMenuItem,
  DropdownMenuLabel as BaseDropdownMenuLabel,
  DropdownMenuPortal as BaseDropdownMenuPortal,
  DropdownMenuRadioGroup as BaseDropdownMenuRadioGroup,
  DropdownMenuRadioItem as BaseDropdownMenuRadioItem,
  DropdownMenuSeparator as BaseDropdownMenuSeparator,
  DropdownMenuShortcut as BaseDropdownMenuShortcut,
  DropdownMenuSub as BaseDropdownMenuSub,
  DropdownMenuSubContent as BaseDropdownMenuSubContent,
  DropdownMenuSubTrigger as BaseDropdownMenuSubTrigger,
  DropdownMenuTrigger as BaseDropdownMenuTrigger,
} from '@/shadcn/dropdown-menu';
import * as React from 'react';
import styles from './DropdownMenu.module.css';

export interface DropdownMenuProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenu> {
  variant?: string;
}

const DropdownMenu = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenu>,
  DropdownMenuProps
>(({ variant, ...props }) => <BaseDropdownMenu {...props} />);

DropdownMenu.displayName = 'DropdownMenu';

export interface DropdownMenuTriggerProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuTrigger> {
  variant?: string;
}

const DropdownMenuTrigger = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuTrigger>,
  DropdownMenuTriggerProps
>(({ variant, ...props }, ref) => (
  <BaseDropdownMenuTrigger ref={ref} {...props} />
));

DropdownMenuTrigger.displayName = 'DropdownMenuTrigger';

export interface DropdownMenuContentProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuContent> {
  variant?: string;
}

const DropdownMenuContent = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuContent>,
  DropdownMenuContentProps
>(({ ...props }, ref) => <BaseDropdownMenuContent ref={ref} {...props} />);

DropdownMenuContent.displayName = 'DropdownMenuContent';

export interface DropdownMenuItemProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuItem> {
  variant?: string;
}

const DropdownMenuItem = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuItem>,
  DropdownMenuItemProps
>(({ ...props }, ref) => <BaseDropdownMenuItem ref={ref} {...props} />);

DropdownMenuItem.displayName = 'DropdownMenuItem';

export interface DropdownMenuCheckboxItemProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuCheckboxItem> {
  variant?: string;
}

const DropdownMenuCheckboxItem = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuCheckboxItem>,
  DropdownMenuCheckboxItemProps
>(({ ...props }, ref) => <BaseDropdownMenuCheckboxItem ref={ref} {...props} />);

DropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';

export interface DropdownMenuRadioItemProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuRadioItem> {
  variant?: string;
}

const DropdownMenuRadioItem = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuRadioItem>,
  DropdownMenuRadioItemProps
>(({ ...props }, ref) => <BaseDropdownMenuRadioItem ref={ref} {...props} />);

DropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';

export interface DropdownMenuLabelProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuLabel> {
  variant?: string;
}

const DropdownMenuLabel = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuLabel>,
  DropdownMenuLabelProps
>(({ ...props }, ref) => <BaseDropdownMenuLabel ref={ref} {...props} />);

DropdownMenuLabel.displayName = 'DropdownMenuLabel';

export interface DropdownMenuSeparatorProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuSeparator> {
  variant?: string;
}

const DropdownMenuSeparator = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuSeparator>,
  DropdownMenuSeparatorProps
>(({ ...props }, ref) => <BaseDropdownMenuSeparator ref={ref} {...props} />);

DropdownMenuSeparator.displayName = 'DropdownMenuSeparator';

export interface DropdownMenuShortcutProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuShortcut> {
  variant?: string;
}

const DropdownMenuShortcut = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuShortcut>,
  DropdownMenuShortcutProps
>(({ className, variant, ...props }, _ref) => (
  <BaseDropdownMenuShortcut
    className={`${className} ${variant ? styles[variant] : ''}`}
    {...props}
  />
));

DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';

export interface DropdownMenuGroupProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuGroup> {
  variant?: string;
}

const DropdownMenuGroup = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuGroup>,
  DropdownMenuGroupProps
>(({ ...props }, ref) => <BaseDropdownMenuGroup ref={ref} {...props} />);

DropdownMenuGroup.displayName = 'DropdownMenuGroup';

export interface DropdownMenuPortalProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuPortal> {
  variant?: string;
}

const DropdownMenuPortal = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuPortal>,
  DropdownMenuPortalProps
>(({ ...props }) => <BaseDropdownMenuPortal {...props} />);

DropdownMenuPortal.displayName = 'DropdownMenuPortal';

export interface DropdownMenuSubProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuSub> {
  variant?: string;
}

const DropdownMenuSub = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuSub>,
  DropdownMenuSubProps
>(({ ...props }) => <BaseDropdownMenuSub {...props} />);

DropdownMenuSub.displayName = 'DropdownMenuSub';

export interface DropdownMenuSubContentProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuSubContent> {
  variant?: string;
}

const DropdownMenuSubContent = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuSubContent>,
  DropdownMenuSubContentProps
>(({ ...props }, ref) => <BaseDropdownMenuSubContent ref={ref} {...props} />);

DropdownMenuSubContent.displayName = 'DropdownMenuSubContent';

export interface DropdownMenuSubTriggerProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuSubTrigger> {
  variant?: string;
}

const DropdownMenuSubTrigger = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuSubTrigger>,
  DropdownMenuSubTriggerProps
>(({ variant, ...props }, ref) => (
  <BaseDropdownMenuSubTrigger ref={ref} {...props} />
));

DropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';

export interface DropdownMenuRadioGroupProps
  extends React.ComponentPropsWithoutRef<typeof BaseDropdownMenuRadioGroup> {
  variant?: string;
}

const DropdownMenuRadioGroup = React.forwardRef<
  React.ElementRef<typeof BaseDropdownMenuRadioGroup>,
  DropdownMenuRadioGroupProps
>(({ variant, ...props }, ref) => (
  <BaseDropdownMenuRadioGroup ref={ref} {...props} />
));

DropdownMenuRadioGroup.displayName = 'DropdownMenuRadioGroup';

export {
  DropdownMenu,
  DropdownMenuTrigger,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuCheckboxItem,
  DropdownMenuRadioItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuShortcut,
  DropdownMenuGroup,
  DropdownMenuPortal,
  DropdownMenuSub,
  DropdownMenuSubContent,
  DropdownMenuSubTrigger,
  DropdownMenuRadioGroup,
};
