"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ProgressLoader_exports = {};
__export(ProgressLoader_exports, {
  default: () => ProgressLoader
});
module.exports = __toCommonJS(ProgressLoader_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_Text = __toESM(require("../../asorted/Text"));
const StyledCircle = import_styled_components.default.circle.attrs({
  fill: "transparent",
  cx: "50%",
  cy: "50%"
})`
  transition: stroke-dashoffset 0.35s;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
`;
const StyledCircleBackground = (0, import_styled_components.default)(StyledCircle).attrs((props) => ({
  stroke: props.stroke || props.theme.colors.primary.c30
}))``;
const StyledCircleFront = (0, import_styled_components.default)(StyledCircle).attrs((props) => ({
  stroke: props.stroke || props.theme.colors.primary.c80
}))``;
const StyledCenteredText = (0, import_styled_components.default)(import_Text.default)`
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
`;
const StyledProgressLoaderContainer = import_styled_components.default.div`
  display: flex;
  position: absolute;
`;
const StyledSpinningContainer = import_styled_components.default.div`
  animation: rotation 1s infinite linear;
  display: flex;
  align-items: center;
  justify-content: center;
  @keyframes rotation {
    from {
      transform: rotate(0deg);
    }
    to {
      transform: rotate(360deg);
    }
  }
`;
function ProgressCircleSvg({
  radius,
  stroke,
  progress,
  backgroundStrokeColor,
  frontStrokeColor,
  frontStrokeLinecap
}) {
  const normalizedRadius = radius - stroke / 2;
  const circumference = normalizedRadius * 2 * Math.PI;
  const strokeDashoffset = circumference - progress / 100 * circumference;
  return /* @__PURE__ */ import_react.default.createElement("svg", { height: radius * 2, width: radius * 2 }, /* @__PURE__ */ import_react.default.createElement(
    StyledCircleBackground,
    {
      strokeWidth: stroke,
      strokeDasharray: circumference + " " + circumference,
      style: { strokeDashoffset: 0 },
      stroke: backgroundStrokeColor,
      r: normalizedRadius
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    StyledCircleFront,
    {
      strokeWidth: stroke,
      strokeDasharray: circumference + " " + circumference,
      style: { strokeDashoffset },
      stroke: frontStrokeColor,
      strokeLinecap: frontStrokeLinecap,
      r: normalizedRadius
    }
  ));
}
function ProgressLoader({
  radius = 32,
  stroke = 6,
  progress = 0,
  showPercentage = true,
  infinite,
  textColor,
  frontStrokeColor,
  frontStrokeLinecap,
  backgroundStrokeColor
}) {
  return /* @__PURE__ */ import_react.default.createElement(StyledProgressLoaderContainer, null, showPercentage && /* @__PURE__ */ import_react.default.createElement(StyledCenteredText, { variant: "body", color: textColor || "primary.c80" }, Math.floor(progress), "%"), infinite ? /* @__PURE__ */ import_react.default.createElement(StyledSpinningContainer, null, /* @__PURE__ */ import_react.default.createElement(
    ProgressCircleSvg,
    {
      radius,
      stroke,
      progress: 25,
      frontStrokeColor,
      frontStrokeLinecap,
      backgroundStrokeColor
    }
  )) : /* @__PURE__ */ import_react.default.createElement(
    ProgressCircleSvg,
    {
      radius,
      stroke,
      progress,
      frontStrokeColor,
      frontStrokeLinecap,
      backgroundStrokeColor
    }
  ));
}
//# sourceMappingURL=index.js.map
