/* eslint-disable import/no-extraneous-dependencies */
import { base64SVG } from '@supabase/build-icons'

export default ({ componentName, iconName, children, getSvg, deprecated, svgAttributes = {} }) => {
  const svgContents = getSvg()
  const svgBase64 = base64SVG(svgContents)

  const hasAttrs = Object.keys(svgAttributes).length > 0
  const attrsArg = hasAttrs ? `, ${JSON.stringify(svgAttributes)}` : ''

  return `
import createBrivenIcon from '../createBrivenIcon';

/**
 * @component @name ${componentName}
 * @description Briven SVG icon component, renders SVG Element with children.
 *
 * @preview ![img](data:image/svg+xml;base64,${svgBase64})
 *
 * @param {Object} props - Briven icons props and any valid SVG attribute
 * @returns {JSX.Element} JSX Element
 * ${deprecated ? '@deprecated' : ''}
 */
const ${componentName} = createBrivenIcon('${componentName}', ${JSON.stringify(children)}${attrsArg});

export default ${componentName};
`
}
