"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import Link from "next/link";
import { useTranslations } from "next-intl";
import { Button } from "../ui/button.js";
import { Lock, ArrowLeft, ArrowRight } from "lucide-react";
import { useQuotaCheck } from "../../hooks/useQuotaCheck.js";
function QuotaGate({ action, entityName, backHref, children }) {
  const t = useTranslations("billing");
  const { canCreate, isLoading, isQuotaExceeded } = useQuotaCheck(action);
  if (isLoading) return null;
  if (canCreate) return /* @__PURE__ */ jsx(Fragment, { children });
  return /* @__PURE__ */ jsx("div", { className: "px-2 sm:px-4 lg:px-6 py-12 max-w-md mx-auto", "data-cy": "quota-gate", children: /* @__PURE__ */ jsxs("div", { className: "rounded-xl border bg-card p-8 text-center space-y-5", children: [
    /* @__PURE__ */ jsx("div", { className: "inline-flex items-center justify-center w-12 h-12 rounded-full bg-muted mx-auto", children: /* @__PURE__ */ jsx(Lock, { className: "h-6 w-6 text-muted-foreground", "aria-hidden": "true" }) }),
    /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
      /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-foreground", children: isQuotaExceeded ? t("quota.limitReached", { entity: entityName }) : t("quota.featureNotIncluded") }),
      /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground leading-relaxed", children: isQuotaExceeded ? t("quota.limitReachedDetail", { entity: entityName }) : t("quota.featureNotIncludedDetail") })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row justify-center gap-3 pt-1", children: [
      /* @__PURE__ */ jsx(Button, { asChild: true, className: "gap-1.5", children: /* @__PURE__ */ jsxs(Link, { href: "/dashboard/settings/plans", children: [
        t("quota.viewPlans"),
        /* @__PURE__ */ jsx(ArrowRight, { className: "h-4 w-4", "aria-hidden": "true" })
      ] }) }),
      /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", className: "gap-1.5", children: /* @__PURE__ */ jsxs(Link, { href: backHref, children: [
        /* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4", "aria-hidden": "true" }),
        t("quota.goBack")
      ] }) })
    ] })
  ] }) });
}
export {
  QuotaGate
};
