"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Spinner } from "./spinner.js";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function DataLoader({
  isLoading,
  children,
  loadingMessage,
  spinnerSize = "md",
  className = "",
  loadingClassName = "",
  showSkeleton = false,
  skeletonComponent
}) {
  const t = useT();
  const resolvedLoadingMessage = loadingMessage ?? t("ui.dataLoader.loading", "Loading...");
  if (isLoading) {
    if (showSkeleton && skeletonComponent) {
      return /* @__PURE__ */ jsx("div", { className, children: skeletonComponent });
    }
    return /* @__PURE__ */ jsxs("div", { className: `flex items-center justify-center gap-2 py-4 ${loadingClassName} ${className}`, children: [
      /* @__PURE__ */ jsx(Spinner, { size: spinnerSize }),
      /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: resolvedLoadingMessage })
    ] });
  }
  return /* @__PURE__ */ jsx("div", { className, children });
}
function InlineLoader({
  isLoading,
  children,
  loadingMessage,
  spinnerSize = "sm"
}) {
  return /* @__PURE__ */ jsx(
    DataLoader,
    {
      isLoading,
      loadingMessage,
      spinnerSize,
      className: "inline-flex items-center",
      loadingClassName: "py-2",
      children
    }
  );
}
function PageLoader({
  isLoading,
  children,
  loadingMessage,
  spinnerSize = "lg"
}) {
  return /* @__PURE__ */ jsx(
    DataLoader,
    {
      isLoading,
      loadingMessage,
      spinnerSize,
      className: "min-h-[200px] flex items-center justify-center",
      children
    }
  );
}
export {
  DataLoader,
  InlineLoader,
  PageLoader
};
//# sourceMappingURL=DataLoader.js.map
