"use client"

import { Icon } from "@iconify/react"
import {
  AGENDA_VIDEO_PROVIDER_ICONS,
  type AgendaVideoIcon,
} from "@/lib/agenda/agenda-video-conference"
import type { AgendaVideoProvider } from "@/lib/agenda/agenda-settings-types"
import { cn } from "@/lib/utils"

export function AgendaVideoProviderIcon({
  provider,
  className,
}: {
  provider: AgendaVideoProvider
  className?: string
}) {
  if (provider === "none") {
    return (
      <Icon
        icon="mdi:video-off-outline"
        className={cn("size-5 shrink-0 text-muted-foreground", className)}
        aria-hidden
      />
    )
  }

  const spec: AgendaVideoIcon = AGENDA_VIDEO_PROVIDER_ICONS[provider]
  if (spec.kind === "image") {
    return (
      <img
        src={spec.src}
        alt=""
        className={cn("size-5 shrink-0 object-contain", className)}
      />
    )
  }

  return (
    <Icon icon={spec.icon} className={cn("size-5 shrink-0", className)} aria-hidden />
  )
}
