"use client";

import dynamic from "next/dynamic";
import type { FeatureIconName } from "@/static/features";

type FeatureIconProps = {
  name: FeatureIconName;
  width?: number | string;
  height?: number | string;
  className?: string;
};

function IconSkeleton() {
  return (
    <div
      className="size-24 animate-pulse rounded-xl bg-black/5"
      aria-hidden="true"
    />
  );
}

const loading = () => <IconSkeleton />;

const featureIcons = {
  AIPoweredInbox: dynamic(
    () => import("@/components/animation/feature-list/AIPoweredInbox"),
    { ssr: false, loading },
  ),
  CentralizedCustomerInformation: dynamic(
    () =>
      import(
        "@/components/animation/feature-list/CentralizedCustomerInformation"
      ),
    { ssr: false, loading },
  ),
  ChannelSpecificThemes: dynamic(
    () => import("@/components/animation/feature-list/ChannelSpecificThemes"),
    { ssr: false, loading },
  ),
  ChatHistory: dynamic(
    () => import("@/components/animation/feature-list/ChatHistory"),
    { ssr: false, loading },
  ),
  SessionWiseBrowsingLog: dynamic(
    () => import("@/components/animation/feature-list/SessionWiseBrowsingLog"),
    { ssr: false, loading },
  ),
  AdvancedRouting: dynamic(
    () => import("@/components/animation/feature-list/AdvancedRouting"),
    { ssr: false, loading },
  ),
  ChatbotReports: dynamic(
    () => import("@/components/animation/feature-list/ChatbotReports"),
    { ssr: false, loading },
  ),
  AgentPerformance: dynamic(
    () => import("@/components/animation/feature-list/AgentPerformance"),
    { ssr: false, loading },
  ),
  RealTimeAgentActivityDashboard: dynamic(
    () =>
      import(
        "@/components/animation/feature-list/RealTimeAgentActivityDashboard"
      ),
    { ssr: false, loading },
  ),
};

export default function FeatureIcon({ name, ...props }: FeatureIconProps) {
  const Icon = featureIcons[name];
  return <Icon {...props} />;
}
