"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import { useFeature } from "../../hooks/useFeature";
import { useTranslations } from "next-intl";
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
import { Button } from "../ui/button";
import { Lock } from "lucide-react";
function FeatureGate({
  feature,
  children,
  fallback,
  showUpgradePrompt = true,
  onUpgrade
}) {
  const hasFeature = useFeature(feature);
  const t = useTranslations("billing");
  if (hasFeature) {
    return /* @__PURE__ */ jsx(Fragment, { children });
  }
  if (fallback) {
    return /* @__PURE__ */ jsx("div", { "data-cy": `feature-gate-fallback-${feature}`, children: fallback });
  }
  if (showUpgradePrompt) {
    return /* @__PURE__ */ jsx("div", { "data-cy": `feature-gate-${feature}`, children: /* @__PURE__ */ jsxs(Alert, { className: "border-muted", children: [
      /* @__PURE__ */ jsx(Lock, { className: "h-4 w-4" }),
      /* @__PURE__ */ jsx(AlertTitle, { children: t("errors.featureNotAvailable") }),
      /* @__PURE__ */ jsxs(AlertDescription, { className: "flex items-center justify-between", children: [
        /* @__PURE__ */ jsx("span", { children: t("errors.upgradeRequired") }),
        onUpgrade && /* @__PURE__ */ jsx(
          Button,
          {
            variant: "outline",
            size: "sm",
            onClick: onUpgrade,
            "data-cy": "feature-gate-upgrade-btn",
            children: t("upgrade")
          }
        )
      ] })
    ] }) });
  }
  return null;
}
export {
  FeatureGate
};
