"use client";

import MenuItemRenderer from "@/components/listview/MenuItemRenderer";
import VerticalScrollView from "@/components/listview/VerticalScrollView";
import { Skeleton } from "@/components/ui/skeleton";
import clsx from "clsx";

type Props = {
  embedded?: boolean;
};

const MenuSkeleton = ({ embedded = false }: Props) => {
  return (
    <div className={clsx("flex flex-col gap-4 items-center w-full", !embedded && "pt-5 mb-8")}>
      <div className="w-full">
        <Skeleton className="h-12 w-full rounded-xl mb-4" />
        <div className="flex gap-3 overflow-x-hidden py-4">
          {[...Array(5)].map((_, index) => (
            <Skeleton key={index} className="h-24 w-24 rounded-xl shrink-0" />
          ))}
        </div>
      </div>

      <section className="w-full">
        <div className="flex justify-between items-center mb-5">
          <Skeleton className="h-5 w-20 rounded-md" />
          <div className="flex gap-2">
            <Skeleton className="h-8 w-24 rounded-xl" />
            <Skeleton className="h-8 w-28 rounded-xl" />
          </div>
        </div>

        <VerticalScrollView className="mt-5! overflow-y-auto h-full">
          {[...Array(6)].map((_, index) => (
            <MenuItemRenderer key={index}>
              <div className="flex gap-4 w-full h-full items-center">
                <Skeleton className="min-w-28 w-28 h-28 rounded-xl" />
                <div className="w-full inline-flex flex-col justify-between">
                  <div>
                    <Skeleton className="h-5 w-32 rounded-md mb-2" />
                    <Skeleton className="h-4 w-full rounded-md mb-1" />
                    <Skeleton className="h-4 w-3/4 rounded-md" />
                  </div>
                  <div className="inline-flex mt-2 gap-2 justify-between w-full items-center">
                    <div className="w-full flex flex-col gap-1">
                      <Skeleton className="h-4 w-16 rounded-md" />
                    </div>
                    <Skeleton className="max-w-[115px] w-full h-8 rounded-md" />
                  </div>
                </div>
              </div>
            </MenuItemRenderer>
          ))}
        </VerticalScrollView>
      </section>
    </div>
  );
};

export default MenuSkeleton;
