{"version":3,"file":"Badge.cjs","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import type { ComponentProps, FC } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { mergeDeep } from \"../../helpers/merge-deep\";\nimport { getTheme } from \"../../theme-store\";\nimport type { DeepPartial } from \"../../types\";\nimport type { FlowbiteBoolean, FlowbiteColors, FlowbiteSizes } from \"../Flowbite\";\n\nexport interface FlowbiteBadgeTheme {\n  root: FlowbiteBadgeRootTheme;\n  icon: FlowbiteBadgeIconTheme;\n}\n\nexport interface FlowbiteBadgeRootTheme {\n  base: string;\n  color: FlowbiteColors;\n  href: string;\n  size: BadgeSizes;\n}\n\nexport interface FlowbiteBadgeIconTheme extends FlowbiteBoolean {\n  size: BadgeSizes;\n}\n\nexport interface BadgeSizes extends Pick<FlowbiteSizes, \"xs\" | \"sm\"> {\n  [key: string]: string;\n}\n\nexport interface BadgeProps extends Omit<ComponentProps<\"span\">, \"color\"> {\n  color?: keyof FlowbiteColors;\n  href?: string;\n  icon?: FC<ComponentProps<\"svg\">>;\n  size?: keyof BadgeSizes;\n  theme?: DeepPartial<FlowbiteBadgeTheme>;\n}\n\nexport const Badge: FC<BadgeProps> = ({\n  children,\n  color = \"info\",\n  href,\n  icon: Icon,\n  size = \"xs\",\n  className,\n  theme: customTheme = {},\n  ...props\n}) => {\n  const theme = mergeDeep(getTheme().badge, customTheme);\n\n  const Content: FC = () => (\n    <span\n      className={twMerge(\n        theme.root.base,\n        theme.root.color[color],\n        theme.root.size[size],\n        theme.icon[Icon ? \"on\" : \"off\"],\n        className,\n      )}\n      data-testid=\"flowbite-badge\"\n      {...props}\n    >\n      {Icon && <Icon aria-hidden className={theme.icon.size[size]} data-testid=\"flowbite-badge-icon\" />}\n      {children && <span>{children}</span>}\n    </span>\n  );\n\n  return href ? (\n    <a className={theme.root.href} href={href}>\n      <Content />\n    </a>\n  ) : (\n    <Content />\n  );\n};\n\nBadge.displayName = \"Badge\";\n"],"names":["mergeDeep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