import React from 'react';

import type { CDNIconProps } from '@redocly/theme/icons/types';

import { CDNIcon } from '@redocly/theme/icons/CDNIcon/CDNIcon';
import { resolveIcon } from '@redocly/theme/core/utils';

export function Icon(props: CDNIconProps) {
  const { name, ...rest } = props;

  const resolvedIcon = resolveIcon(name);
  if (resolvedIcon.type === 'font-awesome') {
    return <CDNIcon name={resolvedIcon.name} type={resolvedIcon.style} {...rest} />;
  }
  return null;
}
