"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import {
  Sheet,
  SheetContent,
  SheetHeader,
  SheetTitle,
  SheetDescription
} from "../../ui/sheet.js";
import Link from "next/link";
import { Loader2 } from "lucide-react";
import { useQuickCreateEntities } from "../../../hooks/useQuickCreateEntities.js";
import { sel } from "../../../lib/test/index.js";
import { useTranslations } from "next-intl";
function QuickCreateSheet({ isOpen, onOpenChange }) {
  const t = useTranslations();
  const { entities: availableEntities, isLoading, hasEntities } = useQuickCreateEntities();
  const handleLinkClick = () => {
    onOpenChange(false);
  };
  return /* @__PURE__ */ jsx(Sheet, { open: isOpen, onOpenChange, children: /* @__PURE__ */ jsxs(
    SheetContent,
    {
      side: "bottom",
      className: "rounded-t-[20px]",
      "data-cy": sel("dashboard.mobile.quickCreateSheet.container"),
      children: [
        /* @__PURE__ */ jsxs(SheetHeader, { children: [
          /* @__PURE__ */ jsx(SheetTitle, { children: t("common.mobileNav.create") }),
          /* @__PURE__ */ jsx(SheetDescription, { children: t("common.mobileNav.quickCreateDescription") })
        ] }),
        /* @__PURE__ */ jsxs("div", { className: "mt-6 space-y-2", children: [
          isLoading && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }),
          !isLoading && !hasEntities && /* @__PURE__ */ jsx("div", { className: "py-8 text-center text-sm text-muted-foreground", children: t("common.mobileNav.noEntitiesAvailable") }),
          !isLoading && hasEntities && availableEntities.map((entity) => {
            var _a, _b;
            const Icon = entity.icon;
            return /* @__PURE__ */ jsxs(
              Link,
              {
                href: `/dashboard/${entity.slug}/create`,
                onClick: handleLinkClick,
                className: "flex items-center gap-3 px-4 py-3 rounded-lg hover:bg-accent transition-colors",
                "data-cy": sel("dashboard.mobile.quickCreateSheet.item", { slug: entity.slug }),
                children: [
                  /* @__PURE__ */ jsx(Icon, { className: "h-5 w-5 text-muted-foreground", "aria-hidden": "true" }),
                  /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
                    /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: ((_a = entity.names) == null ? void 0 : _a.singular) || entity.slug }),
                    /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
                      t("common.mobileNav.createNew"),
                      " ",
                      (((_b = entity.names) == null ? void 0 : _b.singular) || entity.slug).toLowerCase()
                    ] })
                  ] })
                ]
              },
              entity.slug
            );
          })
        ] })
      ]
    }
  ) });
}
export {
  QuickCreateSheet
};
