import { MaterialSymbol, type MaterialSymbolProps } from './MaterialSymbol'

import { iconVariants } from '../variants'

import type { VariantProps } from 'class-variance-authority'

export interface MaterialIconProps
  extends Pick<MaterialSymbolProps, 'size' | 'icon' | 'className' | 'style'>,
    VariantProps<typeof iconVariants> {
  isFilled?: boolean
}
export type MaterialIconSetIconProps = Omit<MaterialIconProps, 'icon'>
export function MaterialIcon({
  color,
  size = 24,
  className,
  isFilled = false,
  ...props
}: MaterialIconProps) {
  const classNames = iconVariants({ className, color })
  return (
    // The span is used to prevent the MaterialSymbol from being underlined when used inside a link or button
    <span>
      <MaterialSymbol
        className={classNames}
        size={size}
        {...props}
        fill={isFilled}
      />
    </span>
  )
}
