import { jsxs, jsx } from "react/jsx-runtime";
import { useMemo } from "react";
/* empty css                   */
import Box from "../../node_modules/@mui/material/Box/Box.js";
import Skeleton from "../../node_modules/@mui/material/Skeleton/Skeleton.js";
function getSkeletonDimensions(size) {
  switch (size) {
    case "small":
      return { circular: 20, rectangularWidth: 200, rectangularHeight: 10 };
    case "medium":
      return { circular: 25, rectangularWidth: 250, rectangularHeight: 12 };
    case "large":
    default:
      return { circular: 30, rectangularWidth: 268, rectangularHeight: 12 };
  }
}
function Loader({
  size = "large",
  progress = "",
  showSkeleton = false,
  text = "Loading...",
  className,
  boxProps,
  skeletonProps,
  ...props
}) {
  const skeletonDimensions = useMemo(() => getSkeletonDimensions(size), [size]);
  if (showSkeleton) {
    return /* @__PURE__ */ jsxs(Box, { alignItems: "center", className, display: "flex", ...boxProps, children: [
      /* @__PURE__ */ jsx(
        Skeleton,
        {
          height: skeletonDimensions.circular,
          sx: { borderRadius: 1 },
          variant: "rectangular",
          width: skeletonDimensions.circular,
          ...skeletonProps
        }
      ),
      /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", justifyContent: "space-between", ml: 2, children: [
        /* @__PURE__ */ jsx(
          Skeleton,
          {
            height: skeletonDimensions.rectangularHeight,
            style: { marginBottom: 4 },
            variant: "rectangular",
            width: skeletonDimensions.rectangularWidth,
            ...skeletonProps
          }
        ),
        /* @__PURE__ */ jsx(
          Skeleton,
          {
            height: skeletonDimensions.rectangularHeight,
            variant: "rectangular",
            width: skeletonDimensions.rectangularWidth,
            ...skeletonProps
          }
        )
      ] })
    ] });
  }
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: `ia-styles ia-loader-container ${className ?? ""}`.trim(),
      "data-testid": props["data-testid"],
      children: [
        /* @__PURE__ */ jsx("div", { className: `ia-styles ia-loader-outer ia-loader-${size}`, children: /* @__PURE__ */ jsx("div", { className: "ia-loader ia-loader-inner", children: size !== "small" && progress }) }),
        (progress || text) && /* @__PURE__ */ jsx("div", { className: "ia-loaderText", children: text })
      ]
    }
  );
}
Loader.displayName = "Loader";
export {
  Loader
};
