"use strict";
var import_Spinner = require("../Spinner.css");
const jsxRuntime = require("react/jsx-runtime");
const antd = require("antd");
const kit_Icon = require("./Icon.cjs");
const kit_Theme_UI = require("./Theme/UI.cjs");
require("./Theme/themeUtils.cjs");
require("./Theme/themes.cjs");
const kit_utils_loadable = require("./utils/loadable.cjs");
const base = "Spinner_base_bfbc6";
const spin = "Spinner_spin_bfbc6";
const rotate = "Spinner_rotate_bfbc6";
const center = "Spinner_center_bfbc6";
const css = {
  base,
  spin,
  rotate,
  center
};
function Spinner({
  center: center2,
  children,
  conditionalRender,
  size = "medium",
  spinning = true,
  tip,
  data
}) {
  const {
    themeSettings: { className }
  } = kit_Theme_UI.useTheme();
  const classes = [className, css.base];
  if (center2 || tip)
    classes.push(css.center);
  const spinner = /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.join(" "), children: /* @__PURE__ */ jsxRuntime.jsx(
    antd.Spin,
    {
      "data-testid": "custom-spinner",
      indicator: /* @__PURE__ */ jsxRuntime.jsx("div", { className: css.spin, children: /* @__PURE__ */ jsxRuntime.jsx(kit_Icon.default, { name: "spinner", size, title: "Spinner" }) }),
      spinning,
      tip,
      children: data !== void 0 || conditionalRender && spinning ? null : children
    }
  ) });
  if (!data) {
    return spinner;
  } else {
    return kit_utils_loadable.Loadable.match(data, {
      Failed: () => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}),
      Loaded: children,
      NotLoaded: () => spinner
      // TODO circle back with design to find an appropriate error state here
    });
  }
}
module.exports = Spinner;
